From 1c2fd3aa7fc8b7e5027aeba485b4d9affcbb1399 Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Thu, 4 Feb 2021 16:29:10 -0800 Subject: [PATCH] Polish the PipMenuView when showing the controls - Decreases the menu action size - Wraps custom actions into PipMenuActionView and restricts the size to be identical to other PiP actions such as settings and dismiss - Removed unused pip_menu_activity.xml layout Screenshot: https://screenshot.googleplex.com/6LFk5WJFfC4FQyA.png Bug: 179312210 Test: Enter PiP and tap to show controls, see screenshot Change-Id: I9de63be60ff66ee5198785885a28d495f1fb7af3 --- .../Shell/res/drawable/pip_expand.xml | 6 +- .../Shell/res/drawable/pip_ic_close_white.xml | 4 +- .../Shell/res/drawable/pip_ic_pause_white.xml | 4 +- .../res/drawable/pip_ic_play_arrow_white.xml | 4 +- .../Shell/res/drawable/pip_ic_settings.xml | 4 +- .../res/drawable/pip_ic_skip_next_white.xml | 6 +- .../drawable/pip_ic_skip_previous_white.xml | 6 +- .../Shell/res/layout/pip_menu.xml | 6 +- .../Shell/res/layout/pip_menu_action.xml | 14 ++- libs/WindowManager/Shell/res/values/dimen.xml | 10 +- .../wm/shell/pip/phone/PipMenuActionView.java | 48 ++++++++++ .../wm/shell/pip/phone/PipMenuView.java | 6 +- .../SystemUI/res/layout/pip_menu_activity.xml | 93 ------------------- packages/SystemUI/tools/lint/baseline.xml | 11 --- 14 files changed, 90 insertions(+), 132 deletions(-) create mode 100644 libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuActionView.java delete mode 100644 packages/SystemUI/res/layout/pip_menu_activity.xml diff --git a/libs/WindowManager/Shell/res/drawable/pip_expand.xml b/libs/WindowManager/Shell/res/drawable/pip_expand.xml index c99d81934aab2..d36c4f72ecd0a 100644 --- a/libs/WindowManager/Shell/res/drawable/pip_expand.xml +++ b/libs/WindowManager/Shell/res/drawable/pip_expand.xml @@ -14,8 +14,8 @@ limitations under the License. --> @@ -25,4 +25,4 @@ android:fillColor="#FFFFFF" android:pathData="M10 21H7v8h8v-3h-5v-5zm-3-6h3v-5h5V7H7v8zm19 11h-5v3h8v-8h-3v5zM21 7v3h5v5h3V7h-8z" /> - \ No newline at end of file + diff --git a/libs/WindowManager/Shell/res/drawable/pip_ic_close_white.xml b/libs/WindowManager/Shell/res/drawable/pip_ic_close_white.xml index bcc850a854de1..60456267afeff 100644 --- a/libs/WindowManager/Shell/res/drawable/pip_ic_close_white.xml +++ b/libs/WindowManager/Shell/res/drawable/pip_ic_close_white.xml @@ -15,8 +15,8 @@ limitations under the License. --> diff --git a/libs/WindowManager/Shell/res/drawable/pip_ic_play_arrow_white.xml b/libs/WindowManager/Shell/res/drawable/pip_ic_play_arrow_white.xml index f12d2cbebc87b..8567afa3232c0 100644 --- a/libs/WindowManager/Shell/res/drawable/pip_ic_play_arrow_white.xml +++ b/libs/WindowManager/Shell/res/drawable/pip_ic_play_arrow_white.xml @@ -15,8 +15,8 @@ limitations under the License. --> diff --git a/libs/WindowManager/Shell/res/drawable/pip_ic_settings.xml b/libs/WindowManager/Shell/res/drawable/pip_ic_settings.xml index b61e98ce2f9f5..73ec167f1f6f8 100644 --- a/libs/WindowManager/Shell/res/drawable/pip_ic_settings.xml +++ b/libs/WindowManager/Shell/res/drawable/pip_ic_settings.xml @@ -15,8 +15,8 @@ limitations under the License. --> @@ -25,4 +25,4 @@ Copyright (C) 2017 The Android Open Source Project android:pathData="M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z" /> - \ No newline at end of file + diff --git a/libs/WindowManager/Shell/res/drawable/pip_ic_skip_previous_white.xml b/libs/WindowManager/Shell/res/drawable/pip_ic_skip_previous_white.xml index b9b94b73a00fc..6b5382b662b1d 100644 --- a/libs/WindowManager/Shell/res/drawable/pip_ic_skip_previous_white.xml +++ b/libs/WindowManager/Shell/res/drawable/pip_ic_skip_previous_white.xml @@ -15,8 +15,8 @@ Copyright (C) 2017 The Android Open Source Project limitations under the License. --> @@ -25,4 +25,4 @@ Copyright (C) 2017 The Android Open Source Project android:pathData="M6 6h2v12H6zm3.5 6l8.5 6V6z" /> - \ No newline at end of file + diff --git a/libs/WindowManager/Shell/res/layout/pip_menu.xml b/libs/WindowManager/Shell/res/layout/pip_menu.xml index b581f555c234c..9fe0247486101 100644 --- a/libs/WindowManager/Shell/res/layout/pip_menu.xml +++ b/libs/WindowManager/Shell/res/layout/pip_menu.xml @@ -40,7 +40,7 @@ android:layout_height="@dimen/pip_expand_action_size" android:layout_gravity="center" android:contentDescription="@string/pip_phone_expand" - android:padding="10dp" + android:gravity="center" android:src="@drawable/pip_expand" android:background="?android:selectableItemBackgroundBorderless" /> @@ -72,8 +72,8 @@ android:id="@+id/settings" android:layout_width="@dimen/pip_action_size" android:layout_height="@dimen/pip_action_size" - android:padding="@dimen/pip_action_padding" android:contentDescription="@string/pip_phone_settings" + android:gravity="center" android:src="@drawable/pip_ic_settings" android:background="?android:selectableItemBackgroundBorderless" /> @@ -81,8 +81,8 @@ android:id="@+id/dismiss" android:layout_width="@dimen/pip_action_size" android:layout_height="@dimen/pip_action_size" - android:padding="@dimen/pip_action_padding" android:contentDescription="@string/pip_phone_close" + android:gravity="center" android:src="@drawable/pip_ic_close_white" android:background="?android:selectableItemBackgroundBorderless" /> diff --git a/libs/WindowManager/Shell/res/layout/pip_menu_action.xml b/libs/WindowManager/Shell/res/layout/pip_menu_action.xml index 7a026ca63f501..a733b31d9fb0e 100644 --- a/libs/WindowManager/Shell/res/layout/pip_menu_action.xml +++ b/libs/WindowManager/Shell/res/layout/pip_menu_action.xml @@ -14,10 +14,18 @@ See the License for the specific language governing permissions and limitations under the License. --> - + android:forceHasOverlappingRendering="false"> + + + + diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml index 583964b2f4a4d..75bed3777a9d0 100644 --- a/libs/WindowManager/Shell/res/values/dimen.xml +++ b/libs/WindowManager/Shell/res/values/dimen.xml @@ -21,14 +21,20 @@ 250dp - 12dp + 16dp 48dp - + + 20dp + + 60dp + + 28dp + 8dp diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuActionView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuActionView.java new file mode 100644 index 0000000000000..f11ae422e837f --- /dev/null +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuActionView.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.wm.shell.pip.phone; + +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.widget.FrameLayout; +import android.widget.ImageView; + +import com.android.wm.shell.R; + +/** + * Container layout wraps single action image view drawn in PiP menu and can restrict the size of + * action image view (see pip_menu_action.xml). + */ +public class PipMenuActionView extends FrameLayout { + private ImageView mImageView; + + public PipMenuActionView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + mImageView = findViewById(R.id.image); + } + + /** pass through to internal {@link #mImageView} */ + public void setImageDrawable(Drawable drawable) { + mImageView.setImageDrawable(drawable); + } +} diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java index 962c4672644a7..ed0ce4a90fe24 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java @@ -59,7 +59,6 @@ import android.view.ViewRootImpl; import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.FrameLayout; -import android.widget.ImageButton; import android.widget.LinearLayout; import com.android.wm.shell.R; @@ -403,7 +402,7 @@ public class PipMenuView extends FrameLayout { // Ensure we have as many buttons as actions final LayoutInflater inflater = LayoutInflater.from(mContext); while (mActionsGroup.getChildCount() < mActions.size()) { - final ImageButton actionView = (ImageButton) inflater.inflate( + final PipMenuActionView actionView = (PipMenuActionView) inflater.inflate( R.layout.pip_menu_action, mActionsGroup, false); mActionsGroup.addView(actionView); } @@ -420,7 +419,8 @@ public class PipMenuView extends FrameLayout { && (stackBounds.width() > stackBounds.height()); for (int i = 0; i < mActions.size(); i++) { final RemoteAction action = mActions.get(i); - final ImageButton actionView = (ImageButton) mActionsGroup.getChildAt(i); + final PipMenuActionView actionView = + (PipMenuActionView) mActionsGroup.getChildAt(i); // TODO: Check if the action drawable has changed before we reload it action.getIcon().loadDrawableAsync(mContext, d -> { diff --git a/packages/SystemUI/res/layout/pip_menu_activity.xml b/packages/SystemUI/res/layout/pip_menu_activity.xml deleted file mode 100644 index 2b33e17a5fbdf..0000000000000 --- a/packages/SystemUI/res/layout/pip_menu_activity.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/SystemUI/tools/lint/baseline.xml b/packages/SystemUI/tools/lint/baseline.xml index 3e494032b8e25..9a2e3207a6f48 100644 --- a/packages/SystemUI/tools/lint/baseline.xml +++ b/packages/SystemUI/tools/lint/baseline.xml @@ -1259,17 +1259,6 @@ column="1"/> - - - -