Merge "Polish the PipMenuView when showing the controls" into sc-dev

This commit is contained in:
Hongwei Wang
2021-02-18 23:37:31 +00:00
committed by Android (Google) Code Review
14 changed files with 90 additions and 132 deletions

View File

@@ -14,8 +14,8 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="36dp"
android:height="36dp"
android:width="@dimen/pip_expand_action_inner_size"
android:height="@dimen/pip_expand_action_inner_size"
android:viewportWidth="36"
android:viewportHeight="36">
@@ -25,4 +25,4 @@
android:fillColor="#FFFFFF"
android:pathData="M10 21H7v8h8v-3h-5v-5zm-3-6h3v-5h5V7H7v8zm19 11h-5v3h8v-8h-3v5zM21
7v3h5v5h3V7h-8z" />
</vector>
</vector>

View File

@@ -15,8 +15,8 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24.0dp"
android:height="24.0dp"
android:width="@dimen/pip_action_inner_size"
android:height="@dimen/pip_action_inner_size"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path

View File

@@ -15,8 +15,8 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:width="@dimen/pip_action_inner_size"
android:height="@dimen/pip_action_inner_size"
android:viewportWidth="24"
android:viewportHeight="24">

View File

@@ -15,8 +15,8 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:width="@dimen/pip_action_inner_size"
android:height="@dimen/pip_action_inner_size"
android:viewportWidth="24"
android:viewportHeight="24">

View File

@@ -15,8 +15,8 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:width="@dimen/pip_action_inner_size"
android:height="@dimen/pip_action_inner_size"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path

View File

@@ -15,8 +15,8 @@ Copyright (C) 2017 The Android Open Source Project
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:width="@dimen/pip_action_inner_size"
android:height="@dimen/pip_action_inner_size"
android:viewportWidth="24"
android:viewportHeight="24">
@@ -25,4 +25,4 @@ Copyright (C) 2017 The Android Open Source Project
android:pathData="M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z" />
<path
android:pathData="M0 0h24v24H0z" />
</vector>
</vector>

View File

@@ -15,8 +15,8 @@ Copyright (C) 2017 The Android Open Source Project
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:width="@dimen/pip_action_inner_size"
android:height="@dimen/pip_action_inner_size"
android:viewportWidth="24"
android:viewportHeight="24">
@@ -25,4 +25,4 @@ Copyright (C) 2017 The Android Open Source Project
android:pathData="M6 6h2v12H6zm3.5 6l8.5 6V6z" />
<path
android:pathData="M0 0h24v24H0z" />
</vector>
</vector>

View File

@@ -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" />
</FrameLayout>
@@ -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" />
</LinearLayout>

View File

@@ -14,10 +14,18 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<ImageButton
<com.android.wm.shell.pip.phone.PipMenuActionView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/pip_action_size"
android:layout_height="@dimen/pip_action_size"
android:padding="@dimen/pip_action_padding"
android:background="?android:selectableItemBackgroundBorderless"
android:forceHasOverlappingRendering="false" />
android:forceHasOverlappingRendering="false">
<ImageView
android:id="@+id/image"
android:layout_width="@dimen/pip_action_inner_size"
android:layout_height="@dimen/pip_action_inner_size"
android:layout_gravity="center"
android:scaleType="fitXY"/>
</com.android.wm.shell.pip.phone.PipMenuActionView>

View File

@@ -21,14 +21,20 @@
<dimen name="floating_dismiss_gradient_height">250dp</dimen>
<!-- The padding around a PiP actions. -->
<dimen name="pip_action_padding">12dp</dimen>
<dimen name="pip_action_padding">16dp</dimen>
<!-- The height of the PiP actions container in which the actions are vertically centered. -->
<dimen name="pip_action_size">48dp</dimen>
<!-- The width and height of the PiP expand action. -->
<!-- The width and height of the PiP action asset drawn within the container. -->
<dimen name="pip_action_inner_size">20dp</dimen>
<!-- The width and height of the PiP expand action container. -->
<dimen name="pip_expand_action_size">60dp</dimen>
<!-- The width and height of the PiP expand action asset drawn within the container. -->
<dimen name="pip_expand_action_inner_size">28dp</dimen>
<!-- The padding between actions in the PiP in landscape Note that the PiP does not reflect
the configuration of the device, so we can't use -land resources. -->
<dimen name="pip_between_action_padding_land">8dp</dimen>

View File

@@ -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);
}
}

View File

@@ -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;
@@ -407,7 +406,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);
}
@@ -424,7 +423,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 -> {

View File

@@ -1,93 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 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.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Menu layout -->
<FrameLayout
android:id="@+id/menu_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:forceHasOverlappingRendering="false"
android:accessibilityTraversalAfter="@id/dismiss">
<!-- The margins for this container is calculated in the code depending on whether the
actions_container is visible. -->
<FrameLayout
android:id="@+id/expand_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/expand_button"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center"
android:contentDescription="@string/pip_phone_expand"
android:padding="10dp"
android:src="@drawable/pip_expand"
android:background="?android:selectableItemBackgroundBorderless" />
</FrameLayout>
<FrameLayout
android:id="@+id/actions_container"
android:layout_width="match_parent"
android:layout_height="@dimen/pip_action_size"
android:layout_gravity="bottom"
android:visibility="invisible">
<LinearLayout
android:id="@+id/actions_group"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:orientation="horizontal"
android:divider="@android:color/transparent"
android:showDividers="middle" />
</FrameLayout>
</FrameLayout>
<ImageButton
android:id="@+id/settings"
android:layout_width="@dimen/pip_action_size"
android:layout_height="@dimen/pip_action_size"
android:layout_gravity="top|start"
android:padding="@dimen/pip_action_padding"
android:contentDescription="@string/pip_phone_settings"
android:src="@drawable/ic_settings"
android:background="?android:selectableItemBackgroundBorderless" />
<ImageButton
android:id="@+id/dismiss"
android:layout_width="@dimen/pip_action_size"
android:layout_height="@dimen/pip_action_size"
android:layout_gravity="top|end"
android:padding="@dimen/pip_action_padding"
android:contentDescription="@string/pip_phone_close"
android:src="@drawable/ic_close_white"
android:background="?android:selectableItemBackgroundBorderless" />
<!--TODO (b/156917828): Add content description for a11y purposes?-->
<ImageButton
android:id="@+id/resize_handle"
android:layout_width="@dimen/pip_resize_handle_size"
android:layout_height="@dimen/pip_resize_handle_size"
android:layout_gravity="top|start"
android:layout_margin="@dimen/pip_resize_handle_margin"
android:src="@drawable/pip_resize_handle"
android:background="?android:selectableItemBackgroundBorderless" />
</FrameLayout>

View File

@@ -1259,17 +1259,6 @@
column="1"/>
</issue>
<issue
id="MergeRootFrame"
message="This `&lt;FrameLayout>` can be replaced with a `&lt;merge>` tag"
errorLine1="&lt;FrameLayout"
errorLine2="^">
<location
file="res/layout/pip_menu_activity.xml"
line="16"
column="1"/>
</issue>
<issue
id="MergeRootFrame"
message="This `&lt;FrameLayout>` can be replaced with a `&lt;merge>` tag"