| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.app; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.annotation.RequiresFeature; |
| 22 |
import android.annotation.TestApi; |
| 23 |
import android.content.pm.PackageManager; |
| 24 |
import android.graphics.Rect; |
| 25 |
import android.os.Parcel; |
| 26 |
import android.os.Parcelable; |
| 27 |
import android.util.Rational; |
| 28 |
|
| 29 |
import java.util.ArrayList; |
| 30 |
import java.util.List; |
| 31 |
import java.util.Objects; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public final class PictureInPictureParams implements Parcelable { |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
public static class Builder { |
| 43 |
|
| 44 |
@Nullable |
| 45 |
private Rational mAspectRatio; |
| 46 |
|
| 47 |
@Nullable |
| 48 |
private Rational mExpandedAspectRatio; |
| 49 |
|
| 50 |
@Nullable |
| 51 |
private List<RemoteAction> mUserActions; |
| 52 |
|
| 53 |
@Nullable |
| 54 |
private RemoteAction mCloseAction; |
| 55 |
|
| 56 |
@Nullable |
| 57 |
private Rect mSourceRectHint; |
| 58 |
|
| 59 |
private Boolean mAutoEnterEnabled; |
| 60 |
|
| 61 |
private Boolean mSeamlessResizeEnabled; |
| 62 |
|
| 63 |
private CharSequence mTitle; |
| 64 |
|
| 65 |
private CharSequence mSubtitle; |
| 66 |
|
| 67 |
private Boolean mIsLaunchIntoPip; |
| 68 |
|
| 69 |
|
| 70 |
public Builder() {} |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
public Builder(@NonNull PictureInPictureParams original) { |
| 77 |
mAspectRatio = original.mAspectRatio; |
| 78 |
mUserActions = original.mUserActions; |
| 79 |
mCloseAction = original.mCloseAction; |
| 80 |
mSourceRectHint = original.mSourceRectHint; |
| 81 |
mAutoEnterEnabled = original.mAutoEnterEnabled; |
| 82 |
mSeamlessResizeEnabled = original.mSeamlessResizeEnabled; |
| 83 |
mTitle = original.mTitle; |
| 84 |
mSubtitle = original.mSubtitle; |
| 85 |
mIsLaunchIntoPip = original.mIsLaunchIntoPip; |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
public Builder setAspectRatio(Rational aspectRatio) { |
| 97 |
mAspectRatio = aspectRatio; |
| 98 |
return this; |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
@RequiresFeature(PackageManager.FEATURE_EXPANDED_PICTURE_IN_PICTURE) |
| 114 |
public @NonNull Builder setExpandedAspectRatio(@Nullable Rational expandedAspectRatio) { |
| 115 |
mExpandedAspectRatio = expandedAspectRatio; |
| 116 |
return this; |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
public Builder setActions(List<RemoteAction> actions) { |
| 131 |
if (mUserActions != null) { |
| 132 |
mUserActions = null; |
| 133 |
} |
| 134 |
if (actions != null) { |
| 135 |
mUserActions = new ArrayList<>(actions); |
| 136 |
} |
| 137 |
return this; |
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
@NonNull |
| 154 |
public Builder setCloseAction(@Nullable RemoteAction action) { |
| 155 |
mCloseAction = action; |
| 156 |
return this; |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
public Builder setSourceRectHint(Rect launchBounds) { |
| 172 |
if (launchBounds == null) { |
| 173 |
mSourceRectHint = null; |
| 174 |
} else { |
| 175 |
mSourceRectHint = new Rect(launchBounds); |
| 176 |
} |
| 177 |
return this; |
| 178 |
} |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
@NonNull |
| 194 |
public Builder setAutoEnterEnabled(boolean autoEnterEnabled) { |
| 195 |
mAutoEnterEnabled = autoEnterEnabled; |
| 196 |
return this; |
| 197 |
} |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
@NonNull |
| 211 |
public Builder setSeamlessResizeEnabled(boolean seamlessResizeEnabled) { |
| 212 |
mSeamlessResizeEnabled = seamlessResizeEnabled; |
| 213 |
return this; |
| 214 |
} |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
@NonNull |
| 224 |
public Builder setTitle(@Nullable CharSequence title) { |
| 225 |
mTitle = title; |
| 226 |
return this; |
| 227 |
} |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
@NonNull |
| 240 |
public Builder setSubtitle(@Nullable CharSequence subtitle) { |
| 241 |
mSubtitle = subtitle; |
| 242 |
return this; |
| 243 |
} |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
@NonNull |
| 255 |
Builder setIsLaunchIntoPip(boolean isLaunchIntoPip) { |
| 256 |
mIsLaunchIntoPip = isLaunchIntoPip; |
| 257 |
return this; |
| 258 |
} |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
public PictureInPictureParams build() { |
| 268 |
PictureInPictureParams params = new PictureInPictureParams(mAspectRatio, |
| 269 |
mExpandedAspectRatio, mUserActions, mCloseAction, mSourceRectHint, |
| 270 |
mAutoEnterEnabled, mSeamlessResizeEnabled, mTitle, mSubtitle, |
| 271 |
mIsLaunchIntoPip); |
| 272 |
return params; |
| 273 |
} |
| 274 |
} |
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
@Nullable |
| 280 |
private Rational mAspectRatio; |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
@Nullable |
| 286 |
private Rational mExpandedAspectRatio; |
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
@Nullable |
| 292 |
private List<RemoteAction> mUserActions; |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
@Nullable |
| 298 |
private RemoteAction mCloseAction; |
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
@Nullable |
| 306 |
private Rect mSourceRectHint; |
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
private Boolean mAutoEnterEnabled; |
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
private Boolean mSeamlessResizeEnabled; |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
@Nullable |
| 325 |
private CharSequence mTitle; |
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
@Nullable |
| 331 |
private CharSequence mSubtitle; |
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
private Boolean mIsLaunchIntoPip; |
| 339 |
|
| 340 |
|
| 341 |
PictureInPictureParams() { |
| 342 |
} |
| 343 |
|
| 344 |
|
| 345 |
PictureInPictureParams(Parcel in) { |
| 346 |
mAspectRatio = readRationalFromParcel(in); |
| 347 |
mExpandedAspectRatio = readRationalFromParcel(in); |
| 348 |
if (in.readInt() != 0) { |
| 349 |
mUserActions = new ArrayList<>(); |
| 350 |
in.readTypedList(mUserActions, RemoteAction.CREATOR); |
| 351 |
} |
| 352 |
mCloseAction = in.readTypedObject(RemoteAction.CREATOR); |
| 353 |
if (in.readInt() != 0) { |
| 354 |
mSourceRectHint = Rect.CREATOR.createFromParcel(in); |
| 355 |
} |
| 356 |
if (in.readInt() != 0) { |
| 357 |
mAutoEnterEnabled = in.readBoolean(); |
| 358 |
} |
| 359 |
if (in.readInt() != 0) { |
| 360 |
mSeamlessResizeEnabled = in.readBoolean(); |
| 361 |
} |
| 362 |
if (in.readInt() != 0) { |
| 363 |
mTitle = in.readCharSequence(); |
| 364 |
} |
| 365 |
if (in.readInt() != 0) { |
| 366 |
mSubtitle = in.readCharSequence(); |
| 367 |
} |
| 368 |
if (in.readInt() != 0) { |
| 369 |
mIsLaunchIntoPip = in.readBoolean(); |
| 370 |
} |
| 371 |
} |
| 372 |
|
| 373 |
|
| 374 |
PictureInPictureParams(Rational aspectRatio, Rational expandedAspectRatio, |
| 375 |
List<RemoteAction> actions, RemoteAction closeAction, Rect sourceRectHint, |
| 376 |
Boolean autoEnterEnabled, Boolean seamlessResizeEnabled, CharSequence title, |
| 377 |
CharSequence subtitle, Boolean isLaunchIntoPip) { |
| 378 |
mAspectRatio = aspectRatio; |
| 379 |
mExpandedAspectRatio = expandedAspectRatio; |
| 380 |
mUserActions = actions; |
| 381 |
mCloseAction = closeAction; |
| 382 |
mSourceRectHint = sourceRectHint; |
| 383 |
mAutoEnterEnabled = autoEnterEnabled; |
| 384 |
mSeamlessResizeEnabled = seamlessResizeEnabled; |
| 385 |
mTitle = title; |
| 386 |
mSubtitle = subtitle; |
| 387 |
mIsLaunchIntoPip = isLaunchIntoPip; |
| 388 |
} |
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
public PictureInPictureParams(PictureInPictureParams other) { |
| 395 |
this(other.mAspectRatio, other.mExpandedAspectRatio, other.mUserActions, other.mCloseAction, |
| 396 |
other.hasSourceBoundsHint() ? new Rect(other.getSourceRectHint()) : null, |
| 397 |
other.mAutoEnterEnabled, other.mSeamlessResizeEnabled, |
| 398 |
other.mTitle, other.mSubtitle, other.mIsLaunchIntoPip); |
| 399 |
} |
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
public void copyOnlySet(PictureInPictureParams otherArgs) { |
| 406 |
if (otherArgs.hasSetAspectRatio()) { |
| 407 |
mAspectRatio = otherArgs.mAspectRatio; |
| 408 |
} |
| 409 |
|
| 410 |
|
| 411 |
mExpandedAspectRatio = otherArgs.mExpandedAspectRatio; |
| 412 |
|
| 413 |
if (otherArgs.hasSetActions()) { |
| 414 |
mUserActions = otherArgs.mUserActions; |
| 415 |
} |
| 416 |
if (otherArgs.hasSetCloseAction()) { |
| 417 |
mCloseAction = otherArgs.mCloseAction; |
| 418 |
} |
| 419 |
if (otherArgs.hasSourceBoundsHint()) { |
| 420 |
mSourceRectHint = new Rect(otherArgs.getSourceRectHint()); |
| 421 |
} |
| 422 |
if (otherArgs.mAutoEnterEnabled != null) { |
| 423 |
mAutoEnterEnabled = otherArgs.mAutoEnterEnabled; |
| 424 |
} |
| 425 |
if (otherArgs.mSeamlessResizeEnabled != null) { |
| 426 |
mSeamlessResizeEnabled = otherArgs.mSeamlessResizeEnabled; |
| 427 |
} |
| 428 |
if (otherArgs.hasSetTitle()) { |
| 429 |
mTitle = otherArgs.mTitle; |
| 430 |
} |
| 431 |
if (otherArgs.hasSetSubtitle()) { |
| 432 |
mSubtitle = otherArgs.mSubtitle; |
| 433 |
} |
| 434 |
if (otherArgs.mIsLaunchIntoPip != null) { |
| 435 |
mIsLaunchIntoPip = otherArgs.mIsLaunchIntoPip; |
| 436 |
} |
| 437 |
} |
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
@TestApi |
| 444 |
public float getAspectRatioFloat() { |
| 445 |
if (mAspectRatio != null) { |
| 446 |
return mAspectRatio.floatValue(); |
| 447 |
} |
| 448 |
return 0f; |
| 449 |
} |
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
@Nullable |
| 458 |
public Rational getAspectRatio() { |
| 459 |
return mAspectRatio; |
| 460 |
} |
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
public boolean hasSetAspectRatio() { |
| 467 |
return mAspectRatio != null; |
| 468 |
} |
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
@TestApi |
| 475 |
public float getExpandedAspectRatioFloat() { |
| 476 |
if (mExpandedAspectRatio != null) { |
| 477 |
return mExpandedAspectRatio.floatValue(); |
| 478 |
} |
| 479 |
return 0f; |
| 480 |
} |
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
@Nullable |
| 489 |
public Rational getExpandedAspectRatio() { |
| 490 |
return mExpandedAspectRatio; |
| 491 |
} |
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
public boolean hasSetExpandedAspectRatio() { |
| 498 |
return mExpandedAspectRatio != null; |
| 499 |
} |
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
@NonNull |
| 509 |
public List<RemoteAction> getActions() { |
| 510 |
if (mUserActions == null) { |
| 511 |
return new ArrayList<>(); |
| 512 |
} |
| 513 |
return mUserActions; |
| 514 |
} |
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
public boolean hasSetActions() { |
| 521 |
return mUserActions != null; |
| 522 |
} |
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
@Nullable |
| 531 |
public RemoteAction getCloseAction() { |
| 532 |
return mCloseAction; |
| 533 |
} |
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
public boolean hasSetCloseAction() { |
| 540 |
return mCloseAction != null; |
| 541 |
} |
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
public void truncateActions(int size) { |
| 549 |
if (hasSetActions()) { |
| 550 |
mUserActions = mUserActions.subList(0, Math.min(mUserActions.size(), size)); |
| 551 |
} |
| 552 |
} |
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
@Nullable |
| 561 |
public Rect getSourceRectHint() { |
| 562 |
return mSourceRectHint; |
| 563 |
} |
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
public boolean hasSourceBoundsHint() { |
| 570 |
return mSourceRectHint != null && !mSourceRectHint.isEmpty(); |
| 571 |
} |
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
public boolean isAutoEnterEnabled() { |
| 581 |
return mAutoEnterEnabled == null ? false : mAutoEnterEnabled; |
| 582 |
} |
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
public boolean isSeamlessResizeEnabled() { |
| 592 |
return mSeamlessResizeEnabled == null ? true : mSeamlessResizeEnabled; |
| 593 |
} |
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
public boolean hasSetTitle() { |
| 600 |
return mTitle != null; |
| 601 |
} |
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
@Nullable |
| 610 |
public CharSequence getTitle() { |
| 611 |
return mTitle; |
| 612 |
} |
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
public boolean hasSetSubtitle() { |
| 619 |
return mSubtitle != null; |
| 620 |
} |
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
@Nullable |
| 629 |
public CharSequence getSubtitle() { |
| 630 |
return mSubtitle; |
| 631 |
} |
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
public boolean isLaunchIntoPip() { |
| 638 |
return mIsLaunchIntoPip == null ? false : mIsLaunchIntoPip; |
| 639 |
} |
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
public boolean empty() { |
| 646 |
return !hasSourceBoundsHint() && !hasSetActions() && !hasSetCloseAction() |
| 647 |
&& !hasSetAspectRatio() && !hasSetExpandedAspectRatio() && mAutoEnterEnabled == null |
| 648 |
&& mSeamlessResizeEnabled == null && !hasSetTitle() |
| 649 |
&& !hasSetSubtitle() && mIsLaunchIntoPip == null; |
| 650 |
} |
| 651 |
|
| 652 |
@Override |
| 653 |
public boolean equals(Object o) { |
| 654 |
if (this == o) return true; |
| 655 |
if (!(o instanceof PictureInPictureParams)) return false; |
| 656 |
PictureInPictureParams that = (PictureInPictureParams) o; |
| 657 |
return Objects.equals(mAutoEnterEnabled, that.mAutoEnterEnabled) |
| 658 |
&& Objects.equals(mSeamlessResizeEnabled, that.mSeamlessResizeEnabled) |
| 659 |
&& Objects.equals(mAspectRatio, that.mAspectRatio) |
| 660 |
&& Objects.equals(mExpandedAspectRatio, that.mExpandedAspectRatio) |
| 661 |
&& Objects.equals(mUserActions, that.mUserActions) |
| 662 |
&& Objects.equals(mCloseAction, that.mCloseAction) |
| 663 |
&& Objects.equals(mSourceRectHint, that.mSourceRectHint) |
| 664 |
&& Objects.equals(mTitle, that.mTitle) |
| 665 |
&& Objects.equals(mSubtitle, that.mSubtitle) |
| 666 |
&& Objects.equals(mIsLaunchIntoPip, that.mIsLaunchIntoPip); |
| 667 |
} |
| 668 |
|
| 669 |
@Override |
| 670 |
public int hashCode() { |
| 671 |
return Objects.hash(mAspectRatio, mExpandedAspectRatio, mUserActions, mCloseAction, |
| 672 |
mSourceRectHint, mAutoEnterEnabled, mSeamlessResizeEnabled, mTitle, mSubtitle, |
| 673 |
mIsLaunchIntoPip); |
| 674 |
} |
| 675 |
|
| 676 |
@Override |
| 677 |
public int describeContents() { |
| 678 |
return 0; |
| 679 |
} |
| 680 |
|
| 681 |
@Override |
| 682 |
public void writeToParcel(Parcel out, int flags) { |
| 683 |
writeRationalToParcel(mAspectRatio, out); |
| 684 |
writeRationalToParcel(mExpandedAspectRatio, out); |
| 685 |
if (mUserActions != null) { |
| 686 |
out.writeInt(1); |
| 687 |
out.writeTypedList(mUserActions, 0); |
| 688 |
} else { |
| 689 |
out.writeInt(0); |
| 690 |
} |
| 691 |
|
| 692 |
out.writeTypedObject(mCloseAction, 0); |
| 693 |
|
| 694 |
if (mSourceRectHint != null) { |
| 695 |
out.writeInt(1); |
| 696 |
mSourceRectHint.writeToParcel(out, 0); |
| 697 |
} else { |
| 698 |
out.writeInt(0); |
| 699 |
} |
| 700 |
if (mAutoEnterEnabled != null) { |
| 701 |
out.writeInt(1); |
| 702 |
out.writeBoolean(mAutoEnterEnabled); |
| 703 |
} else { |
| 704 |
out.writeInt(0); |
| 705 |
} |
| 706 |
if (mSeamlessResizeEnabled != null) { |
| 707 |
out.writeInt(1); |
| 708 |
out.writeBoolean(mSeamlessResizeEnabled); |
| 709 |
} else { |
| 710 |
out.writeInt(0); |
| 711 |
} |
| 712 |
if (mTitle != null) { |
| 713 |
out.writeInt(1); |
| 714 |
out.writeCharSequence(mTitle); |
| 715 |
} else { |
| 716 |
out.writeInt(0); |
| 717 |
} |
| 718 |
if (mSubtitle != null) { |
| 719 |
out.writeInt(1); |
| 720 |
out.writeCharSequence(mSubtitle); |
| 721 |
} else { |
| 722 |
out.writeInt(0); |
| 723 |
} |
| 724 |
if (mIsLaunchIntoPip != null) { |
| 725 |
out.writeInt(1); |
| 726 |
out.writeBoolean(mIsLaunchIntoPip); |
| 727 |
} else { |
| 728 |
out.writeInt(0); |
| 729 |
} |
| 730 |
} |
| 731 |
|
| 732 |
private void writeRationalToParcel(Rational rational, Parcel out) { |
| 733 |
if (rational != null) { |
| 734 |
out.writeInt(1); |
| 735 |
out.writeInt(rational.getNumerator()); |
| 736 |
out.writeInt(rational.getDenominator()); |
| 737 |
} else { |
| 738 |
out.writeInt(0); |
| 739 |
} |
| 740 |
} |
| 741 |
|
| 742 |
private Rational readRationalFromParcel(Parcel in) { |
| 743 |
if (in.readInt() != 0) { |
| 744 |
return new Rational(in.readInt(), in.readInt()); |
| 745 |
} |
| 746 |
return null; |
| 747 |
} |
| 748 |
|
| 749 |
@Override |
| 750 |
public String toString() { |
| 751 |
return "PictureInPictureParams(" |
| 752 |
+ " aspectRatio=" + getAspectRatio() |
| 753 |
+ " expandedAspectRatio=" + mExpandedAspectRatio |
| 754 |
+ " sourceRectHint=" + getSourceRectHint() |
| 755 |
+ " hasSetActions=" + hasSetActions() |
| 756 |
+ " hasSetCloseAction=" + hasSetCloseAction() |
| 757 |
+ " isAutoPipEnabled=" + isAutoEnterEnabled() |
| 758 |
+ " isSeamlessResizeEnabled=" + isSeamlessResizeEnabled() |
| 759 |
+ " title=" + getTitle() |
| 760 |
+ " subtitle=" + getSubtitle() |
| 761 |
+ " isLaunchIntoPip=" + isLaunchIntoPip() |
| 762 |
+ ")"; |
| 763 |
} |
| 764 |
|
| 765 |
public static final @android.annotation.NonNull Creator<PictureInPictureParams> CREATOR = |
| 766 |
new Creator<PictureInPictureParams>() { |
| 767 |
public PictureInPictureParams createFromParcel(Parcel in) { |
| 768 |
return new PictureInPictureParams(in); |
| 769 |
} |
| 770 |
public PictureInPictureParams[] newArray(int size) { |
| 771 |
return new PictureInPictureParams[size]; |
| 772 |
} |
| 773 |
}; |
| 774 |
} |