Fix Global Actions animations, and use old power menu when panel is disabled.
Also tweak feature flags setup to use old flag as a force option for debugging.
Test: Automated tests pass. Long-press power menu without plugin installed from different device orientations -- menu should animate in from the closest screen edge in all orientations and rotate correctly when device is rotated. Repeat after enabling the settings_global_actions_force_grid_enabled option in Feature Flags to ensure the correct behavior persists when using the new grid layout.
Fixes: 126444760
Fixes: 129698948
Change-Id: I9ac387244a5904f832c5d8b6c40362c00c6a22a2
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
index dcacd0f..e22b24e 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
@@ -1127,10 +1127,7 @@
}
protected int getActionLayoutId(Context context) {
- if (isGridEnabled(context)) {
- return com.android.systemui.R.layout.global_actions_grid_item;
- }
- return com.android.systemui.R.layout.global_actions_item;
+ return com.android.systemui.R.layout.global_actions_grid_item;
}
public View create(
@@ -1540,26 +1537,28 @@
initializeLayout();
}
- private boolean initializePanel() {
+ private boolean shouldUsePanel() {
if (!isPanelEnabled(mContext) || mPanelController == null) {
return false;
}
- View panelView = mPanelController.getPanelContent();
- if (panelView == null) {
+ if (mPanelController.getPanelContent() == null) {
return false;
}
+ return true;
+ }
+
+ private void initializePanel() {
FrameLayout panelContainer = new FrameLayout(mContext);
FrameLayout.LayoutParams panelParams =
new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
- panelContainer.addView(panelView, panelParams);
+ panelContainer.addView(mPanelController.getPanelContent(), panelParams);
addContentView(
panelContainer,
new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
- return true;
}
private void initializeLayout() {
@@ -1578,8 +1577,7 @@
mGlobalActionsLayout.setRotationListener(this::onRotate);
mGlobalActionsLayout.setAdapter(mAdapter);
- boolean panelEnabled = initializePanel();
- if (!panelEnabled) {
+ if (!shouldUsePanel()) {
if (mBackgroundDrawable == null) {
mBackgroundDrawable = new GradientDrawable(mContext);
}
@@ -1589,12 +1587,12 @@
com.android.systemui.R.drawable.global_action_panel_scrim);
mScrimAlpha = 1f;
}
- mGlobalActionsLayout.setSnapToEdge(panelEnabled);
+ mGlobalActionsLayout.setSnapToEdge(true);
getWindow().setBackgroundDrawable(mBackgroundDrawable);
}
private int getGlobalActionsLayoutId(Context context) {
- if (isGridEnabled(context)) {
+ if (isForceGridEnabled(context) || shouldUsePanel()) {
if (RotationUtils.getRotation(context) == RotationUtils.ROTATION_SEASCAPE) {
return com.android.systemui.R.layout.global_actions_grid_seascape;
}
@@ -1653,11 +1651,13 @@
super.show();
mShowing = true;
mBackgroundDrawable.setAlpha(0);
- mGlobalActionsLayout.setTranslationX(getAnimTranslation());
+ mGlobalActionsLayout.setTranslationX(mGlobalActionsLayout.getAnimationOffsetX());
+ mGlobalActionsLayout.setTranslationY(mGlobalActionsLayout.getAnimationOffsetY());
mGlobalActionsLayout.setAlpha(0);
mGlobalActionsLayout.animate()
.alpha(1)
.translationX(0)
+ .translationY(0)
.setDuration(300)
.setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
.setUpdateListener(animation -> {
@@ -1675,10 +1675,12 @@
}
mShowing = false;
mGlobalActionsLayout.setTranslationX(0);
+ mGlobalActionsLayout.setTranslationY(0);
mGlobalActionsLayout.setAlpha(1);
mGlobalActionsLayout.animate()
.alpha(0)
- .translationX(getAnimTranslation())
+ .translationX(mGlobalActionsLayout.getAnimationOffsetX())
+ .translationY(mGlobalActionsLayout.getAnimationOffsetY())
.setDuration(300)
.withEndAction(super::dismiss)
.setInterpolator(new LogAccelerateInterpolator())
@@ -1701,11 +1703,6 @@
}
}
- private float getAnimTranslation() {
- return getContext().getResources().getDimension(
- com.android.systemui.R.dimen.global_actions_panel_width) / 2;
- }
-
@Override
public void onColorsChanged(ColorExtractor extractor, int which) {
if (mKeyguardShowing) {
@@ -1731,17 +1728,19 @@
}
public void onRotate(int from, int to) {
- if (mShowing && isGridEnabled(mContext)) {
+ if (mShowing && (shouldUsePanel() || isForceGridEnabled(mContext))) {
refreshDialog();
}
}
}
/**
- * Determines whether or not the Global Actions menu should use the newer grid-style layout.
+ * Determines whether or not the Global Actions menu should be forced to
+ * use the newer grid-style layout.
*/
- private static boolean isGridEnabled(Context context) {
- return FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.GLOBAL_ACTIONS_GRID_ENABLED);
+ private static boolean isForceGridEnabled(Context context) {
+ return FeatureFlagUtils.isEnabled(context,
+ FeatureFlagUtils.FORCE_GLOBAL_ACTIONS_GRID_ENABLED);
}
/**