From 300b48ff117c4f98ebc2d71e0594a9504f33348a Mon Sep 17 00:00:00 2001 From: Steve Elliott Date: Wed, 29 May 2019 14:13:50 -0400 Subject: [PATCH] Constrain global actions panel to available space Formerly, the global actions panel was given the entire screen, and was rendered above the global actions menu. Now, we limit it to the space unused by the menu. Bug: 133511683 Test: manual Change-Id: I74f4db0b9a2a4e030ec1fd53ddd65e7c372d229c --- packages/SystemUI/Android.bp | 2 + .../res/layout/global_actions_grid.xml | 130 ++++++++++-------- .../globalactions/GlobalActionsDialog.java | 21 ++- .../GlobalActionsGridLayout.java | 15 -- .../GlobalActionsGridLayoutTest.java | 5 +- .../globalactions/ListGridLayoutTest.java | 5 +- 6 files changed, 98 insertions(+), 80 deletions(-) diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp index 94259416d274a..91a8ab5f692f1 100644 --- a/packages/SystemUI/Android.bp +++ b/packages/SystemUI/Android.bp @@ -58,6 +58,7 @@ android_library { "androidx.arch.core_core-runtime", "androidx.lifecycle_lifecycle-extensions", "androidx.dynamicanimation_dynamicanimation", + "androidx-constraintlayout_constraintlayout", "iconloader_base", "SystemUI-tags", "SystemUI-proto", @@ -111,6 +112,7 @@ android_library { "androidx.arch.core_core-runtime", "androidx.lifecycle_lifecycle-extensions", "androidx.dynamicanimation_dynamicanimation", + "androidx-constraintlayout_constraintlayout", "SystemUI-tags", "SystemUI-proto", "metrics-helper-lib", diff --git a/packages/SystemUI/res/layout/global_actions_grid.xml b/packages/SystemUI/res/layout/global_actions_grid.xml index 3928062e43d2c..456553d404dc1 100644 --- a/packages/SystemUI/res/layout/global_actions_grid.xml +++ b/packages/SystemUI/res/layout/global_actions_grid.xml @@ -1,73 +1,95 @@ - - + + - - - + + + - - - - + android:orientation="vertical" + android:gravity="right" + android:layout_marginRight="@dimen/global_actions_grid_side_margin" + android:translationZ="@dimen/global_actions_translate" + android:paddingLeft="@dimen/global_actions_grid_horizontal_padding" + android:paddingRight="@dimen/global_actions_grid_horizontal_padding" + android:paddingTop="@dimen/global_actions_grid_vertical_padding" + android:paddingBottom="@dimen/global_actions_grid_vertical_padding" + > + + + + + - + + \ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java index ff16ed0f14772..86472008688f5 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java @@ -1588,17 +1588,13 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, // Disable rotation suggestions, if enabled setRotationSuggestionsEnabled(false); - FrameLayout panelContainer = new FrameLayout(mContext); + FrameLayout panelContainer = + findViewById(com.android.systemui.R.id.global_actions_panel_container); FrameLayout.LayoutParams panelParams = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, - FrameLayout.LayoutParams.WRAP_CONTENT); + FrameLayout.LayoutParams.MATCH_PARENT); panelContainer.addView(mPanelController.getPanelContent(), panelParams); - addContentView( - panelContainer, - new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT)); mBackgroundDrawable = mPanelController.getBackgroundDrawable(); mScrimAlpha = 1f; } @@ -1606,8 +1602,10 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, private void initializeLayout() { setContentView(getGlobalActionsLayoutId(mContext)); + fixNavBarClipping(); mGlobalActionsLayout = findViewById(com.android.systemui.R.id.global_actions_view); mGlobalActionsLayout.setOutsideTouchListener(view -> dismiss()); + ((View) mGlobalActionsLayout.getParent()).setOnClickListener(view -> dismiss()); mGlobalActionsLayout.setListViewAccessibilityDelegate(new View.AccessibilityDelegate() { @Override public boolean dispatchPopulateAccessibilityEvent( @@ -1630,6 +1628,15 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, getWindow().setBackgroundDrawable(mBackgroundDrawable); } + private void fixNavBarClipping() { + ViewGroup content = findViewById(android.R.id.content); + content.setClipChildren(false); + content.setClipToPadding(false); + ViewGroup contentParent = (ViewGroup) content.getParent(); + contentParent.setClipChildren(false); + contentParent.setClipToPadding(false); + } + private int getGlobalActionsLayoutId(Context context) { int rotation = RotationUtils.getRotation(context); boolean useGridLayout = isForceGridEnabled(context) diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsGridLayout.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsGridLayout.java index 03165f47c472b..e1462d15c8871 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsGridLayout.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsGridLayout.java @@ -42,8 +42,6 @@ public class GlobalActionsGridLayout extends GlobalActionsLayout { listView.setReverseSublists(shouldReverseSublists()); listView.setReverseItems(shouldReverseListItems()); listView.setSwapRowsAndColumns(shouldSwapRowsAndColumns()); - - fixNavBarClipping(); } @Override @@ -75,19 +73,6 @@ public class GlobalActionsGridLayout extends GlobalActionsLayout { } } - /** - * Allows the dialog to clip over the navbar, which prevents shadows and animations from being - * cut off. - */ - private void fixNavBarClipping() { - ViewGroup parent = (ViewGroup) this.getParent(); - ViewGroup parentParent = (ViewGroup) parent.getParent(); - parent.setClipChildren(false); - parent.setClipToPadding(false); - parentParent.setClipChildren(false); - parentParent.setClipToPadding(false); - } - @Override protected ListGridLayout getListView() { return (ListGridLayout) super.getListView(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsGridLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsGridLayoutTest.java index a396f3e8bf467..ea478597ef77e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsGridLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsGridLayoutTest.java @@ -48,8 +48,9 @@ public class GlobalActionsGridLayoutTest extends SysuiTestCase { @Before public void setUp() throws Exception { - mGridLayout = spy((GlobalActionsGridLayout) - LayoutInflater.from(mContext).inflate(R.layout.global_actions_grid, null)); + mGridLayout = spy(LayoutInflater.from(mContext) + .inflate(R.layout.global_actions_grid, null) + .requireViewById(R.id.global_actions_view)); mListGrid = spy(mGridLayout.getListView()); doReturn(mListGrid).when(mGridLayout).getListView(); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/globalactions/ListGridLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/globalactions/ListGridLayoutTest.java index 746140fc725d0..74e8cc2809795 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/globalactions/ListGridLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/globalactions/ListGridLayoutTest.java @@ -43,8 +43,9 @@ public class ListGridLayoutTest extends SysuiTestCase { @Before public void setUp() throws Exception { - GlobalActionsGridLayout globalActions = (GlobalActionsGridLayout) - LayoutInflater.from(mContext).inflate(R.layout.global_actions_grid, null); + GlobalActionsGridLayout globalActions = LayoutInflater.from(mContext) + .inflate(R.layout.global_actions_grid, null) + .requireViewById(R.id.global_actions_view); mListGridLayout = globalActions.getListView(); }