Loading packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +48 −34 Original line number Diff line number Diff line Loading @@ -195,9 +195,9 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, private final LifecycleRegistry mLifecycle = new LifecycleRegistry(this); @VisibleForTesting protected ArrayList<Action> mItems; protected final ArrayList<Action> mItems = new ArrayList<>(); @VisibleForTesting protected ArrayList<Action> mOverflowItems; protected final ArrayList<Action> mOverflowItems = new ArrayList<>(); private ActionsDialog mDialog; Loading Loading @@ -453,12 +453,6 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, prepareDialog(); seedFavorites(); // If we only have 1 item and it's a simple press action, just do this action. if (mAdapter.getCount() == 1 && mAdapter.getItem(0) instanceof SinglePressAction && !(mAdapter.getItem(0) instanceof LongPressAction)) { ((SinglePressAction) mAdapter.getItem(0)).onPress(); } else { WindowManager.LayoutParams attrs = mDialog.getWindow().getAttributes(); attrs.setTitle("ActionsDialog"); attrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; Loading @@ -466,7 +460,6 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, mDialog.show(); mWindowManagerFuncs.onGlobalActionsShown(); } } @VisibleForTesting protected boolean shouldShowAction(Action action) { Loading @@ -485,7 +478,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, */ @VisibleForTesting protected int getMaxShownPowerItems() { if (shouldShowControls()) { if (shouldUseControlsLayout()) { return mResources.getInteger(com.android.systemui.R.integer.power_menu_max_columns); } else { return Integer.MAX_VALUE; Loading @@ -497,10 +490,10 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, * whether controls are enabled and whether the max number of shown items has been reached. */ private void addActionItem(Action action) { if (mItems != null && shouldShowAction(action)) { if (shouldShowAction(action)) { if (mItems.size() < getMaxShownPowerItems()) { mItems.add(action); } else if (mOverflowItems != null) { } else { mOverflowItems.add(action); } } Loading @@ -522,8 +515,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, mAirplaneModeOn = new AirplaneModeAction(); onAirplaneModeChanged(); mItems = new ArrayList<Action>(); mOverflowItems = new ArrayList<Action>(); mItems.clear(); mOverflowItems.clear(); String[] defaultActions = getDefaultActions(); // make sure emergency affordance action is first, if needed Loading Loading @@ -588,6 +581,11 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } } private void onRotate() { // re-allocate actions between main and overflow lists this.createActionItems(); } /** * Create the global actions dialog. * Loading @@ -599,11 +597,12 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, mAdapter = new MyAdapter(); mOverflowAdapter = new MyOverflowAdapter(); mDepthController.setShowingHomeControls(shouldShowControls()); mDepthController.setShowingHomeControls(shouldUseControlsLayout()); ActionsDialog dialog = new ActionsDialog(mContext, mAdapter, mOverflowAdapter, getWalletPanelViewController(), mDepthController, mSysuiColorExtractor, mStatusBarService, mNotificationShadeWindowController, shouldShowControls() ? mControlsUiController : null, mBlurUtils); shouldShowControls() ? mControlsUiController : null, mBlurUtils, shouldUseControlsLayout(), this::onRotate); dialog.setCanceledOnTouchOutside(false); // Handled by the custom class. dialog.setKeyguardShowing(mKeyguardShowing); Loading Loading @@ -704,7 +703,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, @Override public boolean shouldBeSeparated() { return !shouldShowControls(); return !shouldUseControlsLayout(); } @Override Loading @@ -712,7 +711,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { View v = super.create(context, convertView, parent, inflater); int textColor; if (shouldShowControls()) { if (shouldUseControlsLayout()) { v.setBackgroundTintList(ColorStateList.valueOf(v.getResources().getColor( com.android.systemui.R.color.global_actions_emergency_background))); textColor = v.getResources().getColor( Loading Loading @@ -1152,7 +1151,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } private int getActionLayoutId() { if (shouldShowControls()) { if (shouldUseControlsLayout()) { return com.android.systemui.R.layout.global_actions_grid_item_v2; } return com.android.systemui.R.layout.global_actions_grid_item; Loading Loading @@ -1275,12 +1274,12 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, public class MyOverflowAdapter extends BaseAdapter { @Override public int getCount() { return mOverflowItems != null ? mOverflowItems.size() : 0; return mOverflowItems.size(); } @Override public Action getItem(int position) { return mOverflowItems != null ? mOverflowItems.get(position) : null; return mOverflowItems.get(position); } @Override Loading Loading @@ -1888,7 +1887,9 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, private final NotificationShadeWindowController mNotificationShadeWindowController; private final NotificationShadeDepthController mDepthController; private final BlurUtils mBlurUtils; private final boolean mUseControlsLayout; private ListPopupWindow mOverflowPopup; private final Runnable mOnRotateCallback; private ControlsUiController mControlsUiController; private ViewGroup mControlsView; Loading @@ -1898,7 +1899,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, NotificationShadeDepthController depthController, SysuiColorExtractor sysuiColorExtractor, IStatusBarService statusBarService, NotificationShadeWindowController notificationShadeWindowController, ControlsUiController controlsUiController, BlurUtils blurUtils) { ControlsUiController controlsUiController, BlurUtils blurUtils, boolean useControlsLayout, Runnable onRotateCallback) { super(context, com.android.systemui.R.style.Theme_SystemUI_Dialog_GlobalActions); mContext = context; mAdapter = adapter; Loading @@ -1909,6 +1911,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, mNotificationShadeWindowController = notificationShadeWindowController; mControlsUiController = controlsUiController; mBlurUtils = blurUtils; mUseControlsLayout = useControlsLayout; mOnRotateCallback = onRotateCallback; // Window initialization Window window = getWindow(); Loading Loading @@ -2068,7 +2072,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } if (mBackgroundDrawable == null) { mBackgroundDrawable = new ScrimDrawable(); if (mControlsUiController != null) { if (mUseControlsLayout) { mScrimAlpha = 1.0f; } else { mScrimAlpha = mBlurUtils.supportsBlursOnWindows() Loading @@ -2088,7 +2092,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } private int getGlobalActionsLayoutId(Context context) { if (mControlsUiController != null) { if (mUseControlsLayout) { return com.android.systemui.R.layout.global_actions_grid_v2; } Loading Loading @@ -2133,9 +2137,9 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, if (!(mBackgroundDrawable instanceof ScrimDrawable)) { return; } boolean hasControls = mControlsUiController != null; ((ScrimDrawable) mBackgroundDrawable).setColor( !hasControls && colors.supportsDarkText() ? Color.WHITE : Color.BLACK, animate); !mUseControlsLayout && colors.supportsDarkText() ? Color.WHITE : Color.BLACK, animate); View decorView = getWindow().getDecorView(); if (colors.supportsDarkText()) { decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR | Loading Loading @@ -2177,7 +2181,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, .start(); ViewGroup root = (ViewGroup) mGlobalActionsLayout.getRootView(); root.setOnApplyWindowInsetsListener((v, windowInsets) -> { if (mControlsUiController != null) { if (mUseControlsLayout) { root.setPadding(windowInsets.getStableInsetLeft(), windowInsets.getStableInsetTop(), windowInsets.getStableInsetRight(), Loading Loading @@ -2281,10 +2285,14 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, public void refreshDialog() { initializeLayout(); mGlobalActionsLayout.updateList(); if (mControlsUiController != null) { mControlsUiController.show(mControlsView); } } public void onRotate(int from, int to) { if (mShowing) { mOnRotateCallback.run(); refreshDialog(); } } Loading Loading @@ -2317,4 +2325,10 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, && mControlsUiController.getAvailable() && !mControlsServiceInfos.isEmpty(); } // TODO: Remove legacy layout XML and classes. protected boolean shouldUseControlsLayout() { // always use new controls layout return true; } } No newline at end of file Loading
packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +48 −34 Original line number Diff line number Diff line Loading @@ -195,9 +195,9 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, private final LifecycleRegistry mLifecycle = new LifecycleRegistry(this); @VisibleForTesting protected ArrayList<Action> mItems; protected final ArrayList<Action> mItems = new ArrayList<>(); @VisibleForTesting protected ArrayList<Action> mOverflowItems; protected final ArrayList<Action> mOverflowItems = new ArrayList<>(); private ActionsDialog mDialog; Loading Loading @@ -453,12 +453,6 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, prepareDialog(); seedFavorites(); // If we only have 1 item and it's a simple press action, just do this action. if (mAdapter.getCount() == 1 && mAdapter.getItem(0) instanceof SinglePressAction && !(mAdapter.getItem(0) instanceof LongPressAction)) { ((SinglePressAction) mAdapter.getItem(0)).onPress(); } else { WindowManager.LayoutParams attrs = mDialog.getWindow().getAttributes(); attrs.setTitle("ActionsDialog"); attrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; Loading @@ -466,7 +460,6 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, mDialog.show(); mWindowManagerFuncs.onGlobalActionsShown(); } } @VisibleForTesting protected boolean shouldShowAction(Action action) { Loading @@ -485,7 +478,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, */ @VisibleForTesting protected int getMaxShownPowerItems() { if (shouldShowControls()) { if (shouldUseControlsLayout()) { return mResources.getInteger(com.android.systemui.R.integer.power_menu_max_columns); } else { return Integer.MAX_VALUE; Loading @@ -497,10 +490,10 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, * whether controls are enabled and whether the max number of shown items has been reached. */ private void addActionItem(Action action) { if (mItems != null && shouldShowAction(action)) { if (shouldShowAction(action)) { if (mItems.size() < getMaxShownPowerItems()) { mItems.add(action); } else if (mOverflowItems != null) { } else { mOverflowItems.add(action); } } Loading @@ -522,8 +515,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, mAirplaneModeOn = new AirplaneModeAction(); onAirplaneModeChanged(); mItems = new ArrayList<Action>(); mOverflowItems = new ArrayList<Action>(); mItems.clear(); mOverflowItems.clear(); String[] defaultActions = getDefaultActions(); // make sure emergency affordance action is first, if needed Loading Loading @@ -588,6 +581,11 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } } private void onRotate() { // re-allocate actions between main and overflow lists this.createActionItems(); } /** * Create the global actions dialog. * Loading @@ -599,11 +597,12 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, mAdapter = new MyAdapter(); mOverflowAdapter = new MyOverflowAdapter(); mDepthController.setShowingHomeControls(shouldShowControls()); mDepthController.setShowingHomeControls(shouldUseControlsLayout()); ActionsDialog dialog = new ActionsDialog(mContext, mAdapter, mOverflowAdapter, getWalletPanelViewController(), mDepthController, mSysuiColorExtractor, mStatusBarService, mNotificationShadeWindowController, shouldShowControls() ? mControlsUiController : null, mBlurUtils); shouldShowControls() ? mControlsUiController : null, mBlurUtils, shouldUseControlsLayout(), this::onRotate); dialog.setCanceledOnTouchOutside(false); // Handled by the custom class. dialog.setKeyguardShowing(mKeyguardShowing); Loading Loading @@ -704,7 +703,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, @Override public boolean shouldBeSeparated() { return !shouldShowControls(); return !shouldUseControlsLayout(); } @Override Loading @@ -712,7 +711,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { View v = super.create(context, convertView, parent, inflater); int textColor; if (shouldShowControls()) { if (shouldUseControlsLayout()) { v.setBackgroundTintList(ColorStateList.valueOf(v.getResources().getColor( com.android.systemui.R.color.global_actions_emergency_background))); textColor = v.getResources().getColor( Loading Loading @@ -1152,7 +1151,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } private int getActionLayoutId() { if (shouldShowControls()) { if (shouldUseControlsLayout()) { return com.android.systemui.R.layout.global_actions_grid_item_v2; } return com.android.systemui.R.layout.global_actions_grid_item; Loading Loading @@ -1275,12 +1274,12 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, public class MyOverflowAdapter extends BaseAdapter { @Override public int getCount() { return mOverflowItems != null ? mOverflowItems.size() : 0; return mOverflowItems.size(); } @Override public Action getItem(int position) { return mOverflowItems != null ? mOverflowItems.get(position) : null; return mOverflowItems.get(position); } @Override Loading Loading @@ -1888,7 +1887,9 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, private final NotificationShadeWindowController mNotificationShadeWindowController; private final NotificationShadeDepthController mDepthController; private final BlurUtils mBlurUtils; private final boolean mUseControlsLayout; private ListPopupWindow mOverflowPopup; private final Runnable mOnRotateCallback; private ControlsUiController mControlsUiController; private ViewGroup mControlsView; Loading @@ -1898,7 +1899,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, NotificationShadeDepthController depthController, SysuiColorExtractor sysuiColorExtractor, IStatusBarService statusBarService, NotificationShadeWindowController notificationShadeWindowController, ControlsUiController controlsUiController, BlurUtils blurUtils) { ControlsUiController controlsUiController, BlurUtils blurUtils, boolean useControlsLayout, Runnable onRotateCallback) { super(context, com.android.systemui.R.style.Theme_SystemUI_Dialog_GlobalActions); mContext = context; mAdapter = adapter; Loading @@ -1909,6 +1911,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, mNotificationShadeWindowController = notificationShadeWindowController; mControlsUiController = controlsUiController; mBlurUtils = blurUtils; mUseControlsLayout = useControlsLayout; mOnRotateCallback = onRotateCallback; // Window initialization Window window = getWindow(); Loading Loading @@ -2068,7 +2072,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } if (mBackgroundDrawable == null) { mBackgroundDrawable = new ScrimDrawable(); if (mControlsUiController != null) { if (mUseControlsLayout) { mScrimAlpha = 1.0f; } else { mScrimAlpha = mBlurUtils.supportsBlursOnWindows() Loading @@ -2088,7 +2092,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } private int getGlobalActionsLayoutId(Context context) { if (mControlsUiController != null) { if (mUseControlsLayout) { return com.android.systemui.R.layout.global_actions_grid_v2; } Loading Loading @@ -2133,9 +2137,9 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, if (!(mBackgroundDrawable instanceof ScrimDrawable)) { return; } boolean hasControls = mControlsUiController != null; ((ScrimDrawable) mBackgroundDrawable).setColor( !hasControls && colors.supportsDarkText() ? Color.WHITE : Color.BLACK, animate); !mUseControlsLayout && colors.supportsDarkText() ? Color.WHITE : Color.BLACK, animate); View decorView = getWindow().getDecorView(); if (colors.supportsDarkText()) { decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR | Loading Loading @@ -2177,7 +2181,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, .start(); ViewGroup root = (ViewGroup) mGlobalActionsLayout.getRootView(); root.setOnApplyWindowInsetsListener((v, windowInsets) -> { if (mControlsUiController != null) { if (mUseControlsLayout) { root.setPadding(windowInsets.getStableInsetLeft(), windowInsets.getStableInsetTop(), windowInsets.getStableInsetRight(), Loading Loading @@ -2281,10 +2285,14 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, public void refreshDialog() { initializeLayout(); mGlobalActionsLayout.updateList(); if (mControlsUiController != null) { mControlsUiController.show(mControlsView); } } public void onRotate(int from, int to) { if (mShowing) { mOnRotateCallback.run(); refreshDialog(); } } Loading Loading @@ -2317,4 +2325,10 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, && mControlsUiController.getAvailable() && !mControlsServiceInfos.isEmpty(); } // TODO: Remove legacy layout XML and classes. protected boolean shouldUseControlsLayout() { // always use new controls layout return true; } } No newline at end of file