From 17aab38616e211b26b8b88a858e02fd4850242bd Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Mon, 20 Dec 2021 13:22:43 -0800 Subject: [PATCH] Consolidate PiP demos in ApiDemos app Put various configurations for PiP into one Activity, access by navigate to `App > Activity > Picture in Picture`. Current supports - Enter PiP with on-screen button - Enter PiP by swiping up to home or tap on home button - Toggle the auto enter PiP flag on and off - Toggle the source rect hint on and off - Toggle the seamless resize flag on and off - Change the position of current and next source rect hint - Tablet layout on foldables The upcoming content PiP will also be hosted here. Added also support passing the intent extra, full command ``` adb shell am start \ --ez auto_pip [true|false] \ --ez source_rect_hint [true|false] \ --ez seamless_resize [true|false] \ --es current_position [start|end] \ com.example.android.apis/.app.PictureInPicture ``` Bug: 175727044 Video: http://recall/-/aaaaaabFQoRHlzixHdtY/gdcklbUsT7SmbUhNcVSXfd Test: manual, see Video Change-Id: I60233f2d6e428d11d4ab1b566e36c38fd4c4f937 --- samples/ApiDemos/AndroidManifest.xml | 38 +-- .../res/layout/picture_in_picture.xml | 110 +++++++- .../layout/picture_in_picture_auto_enter.xml | 48 ---- .../picture_in_picture_seamless_resize.xml | 47 ---- .../picture_in_picture_source_rect_hint.xml | 56 ----- samples/ApiDemos/res/values/strings.xml | 22 +- .../android/apis/app/PictureInPicture.java | 235 +++++++++++++++++- .../apis/app/PictureInPictureAutoEnter.java | 138 ---------- .../app/PictureInPictureSeamlessResize.java | 62 ----- .../app/PictureInPictureSourceRectHint.java | 156 ------------ .../apis/view/FixedAspectRatioImageView.java | 1 - 11 files changed, 340 insertions(+), 573 deletions(-) delete mode 100644 samples/ApiDemos/res/layout/picture_in_picture_auto_enter.xml delete mode 100644 samples/ApiDemos/res/layout/picture_in_picture_seamless_resize.xml delete mode 100644 samples/ApiDemos/res/layout/picture_in_picture_source_rect_hint.xml delete mode 100644 samples/ApiDemos/src/com/example/android/apis/app/PictureInPictureAutoEnter.java delete mode 100644 samples/ApiDemos/src/com/example/android/apis/app/PictureInPictureSeamlessResize.java delete mode 100644 samples/ApiDemos/src/com/example/android/apis/app/PictureInPictureSourceRectHint.java diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml index 8b6e5efc4..0bac8eaa4 100644 --- a/samples/ApiDemos/AndroidManifest.xml +++ b/samples/ApiDemos/AndroidManifest.xml @@ -290,45 +290,9 @@ android:label="@string/activity_picture_in_picture" android:resizeableActivity="true" android:supportsPictureInPicture="true" - android:configChanges= - "screenSize|smallestScreenSize|screenLayout|orientation"> - - - - - - - - - - - - - - - - - - - - - + "screenSize|smallestScreenSize|screenLayout|orientation"> diff --git a/samples/ApiDemos/res/layout/picture_in_picture.xml b/samples/ApiDemos/res/layout/picture_in_picture.xml index 2f333ac8a..d7d9d90cf 100644 --- a/samples/ApiDemos/res/layout/picture_in_picture.xml +++ b/samples/ApiDemos/res/layout/picture_in_picture.xml @@ -15,18 +15,106 @@ ~ limitations under the License. --> - - + + android:layout_height="match_parent" + android:orientation="vertical"> - - + android:scaleType="fitXY" + android:src="@drawable/sample_1" + app:aspectRatio="16/9" /> + + + + + + + + + + + + + + + + + + + + +