Loading packages/SystemUI/res/layout/global_actions_power_dialog.xml 0 → 100644 +24 −0 Original line number Original line Diff line number Diff line <!-- ~ Copyright (C) 2020 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. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:divider="@drawable/controls_list_divider" android:showDividers="middle" /> packages/SystemUI/res/layout/global_actions_power_item.xml 0 → 100644 +45 −0 Original line number Original line Diff line number Diff line <!-- ~ Copyright (C) 2020 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. --> <com.android.systemui.globalactions.GlobalActionsItem xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="@dimen/global_actions_power_dialog_item_width" android:layout_height="@dimen/global_actions_power_dialog_item_height" android:gravity="bottom|center_horizontal" android:orientation="vertical" android:paddingTop="12dp" android:paddingBottom="12dp" android:stateListAnimator="@anim/control_state_list_animator"> <ImageView android:id="@*android:id/icon" android:layout_width="24dp" android:layout_height="24dp" android:layout_marginBottom="45dp" android:scaleType="centerInside" android:tint="@color/control_primary_text" /> <TextView android:id="@*android:id/message" android:layout_width="match_parent" android:layout_height="wrap_content" android:marqueeRepeatLimit="marquee_forever" android:ellipsize="marquee" android:layout_marginBottom="16dp" android:maxLines="1" android:textSize="16sp" android:gravity="center" android:textColor="@color/control_primary_text" android:textAppearance="?android:attr/textAppearanceSmall" /> </com.android.systemui.globalactions.GlobalActionsItem> packages/SystemUI/res/values/dimens.xml +4 −0 Original line number Original line Diff line number Diff line Loading @@ -1058,6 +1058,10 @@ <!-- Shift quick access wallet down in Global Actions when Controls are unavailable --> <!-- Shift quick access wallet down in Global Actions when Controls are unavailable --> <dimen name="global_actions_wallet_top_margin">40dp</dimen> <dimen name="global_actions_wallet_top_margin">40dp</dimen> <!-- Shutdown and restart actions are larger in power options dialog --> <dimen name="global_actions_power_dialog_item_height">190dp</dimen> <dimen name="global_actions_power_dialog_item_width">255dp</dimen> <!-- The maximum offset in either direction that elements are moved horizontally to prevent <!-- The maximum offset in either direction that elements are moved horizontally to prevent burn-in on AOD. --> burn-in on AOD. --> <dimen name="burn_in_prevention_offset_x">8dp</dimen> <dimen name="burn_in_prevention_offset_x">8dp</dimen> Loading packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +50 −33 Original line number Original line Diff line number Diff line Loading @@ -1425,16 +1425,26 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, Log.w(TAG, "No power options action found at position: " + position); Log.w(TAG, "No power options action found at position: " + position); return null; return null; } } int viewLayoutResource = com.android.systemui.R.layout.controls_more_item; int viewLayoutResource = com.android.systemui.R.layout.global_actions_power_item; View view = convertView != null ? convertView View view = convertView != null ? convertView : LayoutInflater.from(mContext).inflate(viewLayoutResource, parent, false); : LayoutInflater.from(mContext).inflate(viewLayoutResource, parent, false); TextView textView = (TextView) view; view.setOnClickListener(v -> onClickItem(position)); if (action.getMessageResId() != 0) { if (action instanceof LongPressAction) { textView.setText(action.getMessageResId()); view.setOnLongClickListener(v -> onLongClickItem(position)); } ImageView icon = view.findViewById(R.id.icon); TextView messageView = view.findViewById(R.id.message); messageView.setSelected(true); // necessary for marquee to work icon.setImageDrawable(action.getIcon(mContext)); icon.setScaleType(ScaleType.CENTER_CROP); if (action.getMessage() != null) { messageView.setText(action.getMessage()); } else { } else { textView.setText(action.getMessage()); messageView.setText(action.getMessageResId()); } } return textView; return view; } } private boolean onLongClickItem(int position) { private boolean onLongClickItem(int position) { Loading Loading @@ -1569,6 +1579,11 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, */ */ int getMessageResId(); int getMessageResId(); /** * Return the icon drawable for this action. */ Drawable getIcon(Context context); /** /** * Return the message associated with this action, or null if it doesn't have one. * Return the message associated with this action, or null if it doesn't have one. * @return * @return Loading Loading @@ -1633,6 +1648,15 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, return mMessage; return mMessage; } } @Override public Drawable getIcon(Context context) { if (mIcon != null) { return mIcon; } else { return context.getDrawable(mIconResId); } } public View create( public View create( Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { View v = inflater.inflate(com.android.systemui.R.layout.global_actions_grid_item_v2, View v = inflater.inflate(com.android.systemui.R.layout.global_actions_grid_item_v2, Loading @@ -1642,12 +1666,9 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, TextView messageView = v.findViewById(R.id.message); TextView messageView = v.findViewById(R.id.message); messageView.setSelected(true); // necessary for marquee to work messageView.setSelected(true); // necessary for marquee to work if (mIcon != null) { icon.setImageDrawable(getIcon(context)); icon.setImageDrawable(mIcon); icon.setScaleType(ScaleType.CENTER_CROP); icon.setScaleType(ScaleType.CENTER_CROP); } else if (mIconResId != 0) { icon.setImageDrawable(context.getDrawable(mIconResId)); } if (mMessage != null) { if (mMessage != null) { messageView.setText(mMessage); messageView.setText(mMessage); } else { } else { Loading Loading @@ -1738,6 +1759,11 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, return isOn() ? mEnabledIconResId : mDisabledIconResid; return isOn() ? mEnabledIconResId : mDisabledIconResid; } } @Override public Drawable getIcon(Context context) { return context.getDrawable(getIconResId()); } public View create(Context context, View convertView, ViewGroup parent, public View create(Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { LayoutInflater inflater) { willCreate(); willCreate(); Loading Loading @@ -1904,6 +1930,12 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, return null; return null; } } @Override public Drawable getIcon(Context context) { return null; } public View create(Context context, View convertView, ViewGroup parent, public View create(Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { LayoutInflater inflater) { View v = inflater.inflate(R.layout.global_actions_silent_mode, parent, false); View v = inflater.inflate(R.layout.global_actions_silent_mode, parent, false); Loading Loading @@ -2075,7 +2107,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, private final NotificationShadeDepthController mDepthController; private final NotificationShadeDepthController mDepthController; private final SysUiState mSysUiState; private final SysUiState mSysUiState; private ListPopupWindow mOverflowPopup; private ListPopupWindow mOverflowPopup; private ListPopupWindow mPowerOptionsPopup; private Dialog mPowerOptionsDialog; private final Runnable mOnRotateCallback; private final Runnable mOnRotateCallback; private final boolean mControlsAvailable; private final boolean mControlsAvailable; Loading Loading @@ -2211,21 +2243,6 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } } } } private ListPopupWindow createPowerOptionsPopup() { GlobalActionsPopupMenu popup = new GlobalActionsPopupMenu( new ContextThemeWrapper( mContext, com.android.systemui.R.style.Control_ListPopupWindow ), false /* isDropDownMode */); popup.setOnItemClickListener( (parent, view, position, id) -> mPowerOptionsAdapter.onClickItem(position)); popup.setOnItemLongClickListener( (parent, view, position, id) -> mPowerOptionsAdapter.onLongClickItem(position)); popup.setAnchorView(mGlobalActionsLayout); popup.setAdapter(mPowerOptionsAdapter); return popup; } private ListPopupWindow createPowerOverflowPopup() { private ListPopupWindow createPowerOverflowPopup() { GlobalActionsPopupMenu popup = new GlobalActionsPopupMenu( GlobalActionsPopupMenu popup = new GlobalActionsPopupMenu( new ContextThemeWrapper( new ContextThemeWrapper( Loading @@ -2244,8 +2261,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } } public void showPowerOptionsMenu() { public void showPowerOptionsMenu() { mPowerOptionsPopup = createPowerOptionsPopup(); mPowerOptionsDialog = GlobalActionsPowerDialog.create(mContext, mPowerOptionsAdapter); mPowerOptionsPopup.show(); mPowerOptionsDialog.show(); } } private void showPowerOverflowMenu() { private void showPowerOverflowMenu() { Loading Loading @@ -2479,11 +2496,11 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } } private void dismissPowerOptions(boolean immediate) { private void dismissPowerOptions(boolean immediate) { if (mPowerOptionsPopup != null) { if (mPowerOptionsDialog != null) { if (immediate) { if (immediate) { mPowerOptionsPopup.dismissImmediate(); mPowerOptionsDialog.dismiss(); } else { } else { mPowerOptionsPopup.dismiss(); mPowerOptionsDialog.dismiss(); } } } } } } Loading packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsPowerDialog.java 0 → 100644 +60 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2020 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.systemui.globalactions; import android.annotation.NonNull; import android.app.Dialog; import android.content.Context; import android.content.res.Resources; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.ListAdapter; /** * Creates a customized Dialog for displaying the Shut Down and Restart actions. */ public class GlobalActionsPowerDialog { /** * Create a dialog for displaying Shut Down and Restart actions. */ public static Dialog create(@NonNull Context context, ListAdapter adapter) { ViewGroup listView = (ViewGroup) LayoutInflater.from(context).inflate( com.android.systemui.R.layout.global_actions_power_dialog, null); for (int i = 0; i < adapter.getCount(); i++) { View action = adapter.getView(i, null, listView); listView.addView(action); } Resources res = context.getResources(); Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(listView); Window window = dialog.getWindow(); window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY); window.setTitle(""); // prevent Talkback from speaking first item name twice window.setBackgroundDrawable(res.getDrawable( com.android.systemui.R.drawable.control_background, context.getTheme())); return dialog; } } Loading
packages/SystemUI/res/layout/global_actions_power_dialog.xml 0 → 100644 +24 −0 Original line number Original line Diff line number Diff line <!-- ~ Copyright (C) 2020 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. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:divider="@drawable/controls_list_divider" android:showDividers="middle" />
packages/SystemUI/res/layout/global_actions_power_item.xml 0 → 100644 +45 −0 Original line number Original line Diff line number Diff line <!-- ~ Copyright (C) 2020 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. --> <com.android.systemui.globalactions.GlobalActionsItem xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="@dimen/global_actions_power_dialog_item_width" android:layout_height="@dimen/global_actions_power_dialog_item_height" android:gravity="bottom|center_horizontal" android:orientation="vertical" android:paddingTop="12dp" android:paddingBottom="12dp" android:stateListAnimator="@anim/control_state_list_animator"> <ImageView android:id="@*android:id/icon" android:layout_width="24dp" android:layout_height="24dp" android:layout_marginBottom="45dp" android:scaleType="centerInside" android:tint="@color/control_primary_text" /> <TextView android:id="@*android:id/message" android:layout_width="match_parent" android:layout_height="wrap_content" android:marqueeRepeatLimit="marquee_forever" android:ellipsize="marquee" android:layout_marginBottom="16dp" android:maxLines="1" android:textSize="16sp" android:gravity="center" android:textColor="@color/control_primary_text" android:textAppearance="?android:attr/textAppearanceSmall" /> </com.android.systemui.globalactions.GlobalActionsItem>
packages/SystemUI/res/values/dimens.xml +4 −0 Original line number Original line Diff line number Diff line Loading @@ -1058,6 +1058,10 @@ <!-- Shift quick access wallet down in Global Actions when Controls are unavailable --> <!-- Shift quick access wallet down in Global Actions when Controls are unavailable --> <dimen name="global_actions_wallet_top_margin">40dp</dimen> <dimen name="global_actions_wallet_top_margin">40dp</dimen> <!-- Shutdown and restart actions are larger in power options dialog --> <dimen name="global_actions_power_dialog_item_height">190dp</dimen> <dimen name="global_actions_power_dialog_item_width">255dp</dimen> <!-- The maximum offset in either direction that elements are moved horizontally to prevent <!-- The maximum offset in either direction that elements are moved horizontally to prevent burn-in on AOD. --> burn-in on AOD. --> <dimen name="burn_in_prevention_offset_x">8dp</dimen> <dimen name="burn_in_prevention_offset_x">8dp</dimen> Loading
packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +50 −33 Original line number Original line Diff line number Diff line Loading @@ -1425,16 +1425,26 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, Log.w(TAG, "No power options action found at position: " + position); Log.w(TAG, "No power options action found at position: " + position); return null; return null; } } int viewLayoutResource = com.android.systemui.R.layout.controls_more_item; int viewLayoutResource = com.android.systemui.R.layout.global_actions_power_item; View view = convertView != null ? convertView View view = convertView != null ? convertView : LayoutInflater.from(mContext).inflate(viewLayoutResource, parent, false); : LayoutInflater.from(mContext).inflate(viewLayoutResource, parent, false); TextView textView = (TextView) view; view.setOnClickListener(v -> onClickItem(position)); if (action.getMessageResId() != 0) { if (action instanceof LongPressAction) { textView.setText(action.getMessageResId()); view.setOnLongClickListener(v -> onLongClickItem(position)); } ImageView icon = view.findViewById(R.id.icon); TextView messageView = view.findViewById(R.id.message); messageView.setSelected(true); // necessary for marquee to work icon.setImageDrawable(action.getIcon(mContext)); icon.setScaleType(ScaleType.CENTER_CROP); if (action.getMessage() != null) { messageView.setText(action.getMessage()); } else { } else { textView.setText(action.getMessage()); messageView.setText(action.getMessageResId()); } } return textView; return view; } } private boolean onLongClickItem(int position) { private boolean onLongClickItem(int position) { Loading Loading @@ -1569,6 +1579,11 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, */ */ int getMessageResId(); int getMessageResId(); /** * Return the icon drawable for this action. */ Drawable getIcon(Context context); /** /** * Return the message associated with this action, or null if it doesn't have one. * Return the message associated with this action, or null if it doesn't have one. * @return * @return Loading Loading @@ -1633,6 +1648,15 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, return mMessage; return mMessage; } } @Override public Drawable getIcon(Context context) { if (mIcon != null) { return mIcon; } else { return context.getDrawable(mIconResId); } } public View create( public View create( Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { View v = inflater.inflate(com.android.systemui.R.layout.global_actions_grid_item_v2, View v = inflater.inflate(com.android.systemui.R.layout.global_actions_grid_item_v2, Loading @@ -1642,12 +1666,9 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, TextView messageView = v.findViewById(R.id.message); TextView messageView = v.findViewById(R.id.message); messageView.setSelected(true); // necessary for marquee to work messageView.setSelected(true); // necessary for marquee to work if (mIcon != null) { icon.setImageDrawable(getIcon(context)); icon.setImageDrawable(mIcon); icon.setScaleType(ScaleType.CENTER_CROP); icon.setScaleType(ScaleType.CENTER_CROP); } else if (mIconResId != 0) { icon.setImageDrawable(context.getDrawable(mIconResId)); } if (mMessage != null) { if (mMessage != null) { messageView.setText(mMessage); messageView.setText(mMessage); } else { } else { Loading Loading @@ -1738,6 +1759,11 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, return isOn() ? mEnabledIconResId : mDisabledIconResid; return isOn() ? mEnabledIconResId : mDisabledIconResid; } } @Override public Drawable getIcon(Context context) { return context.getDrawable(getIconResId()); } public View create(Context context, View convertView, ViewGroup parent, public View create(Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { LayoutInflater inflater) { willCreate(); willCreate(); Loading Loading @@ -1904,6 +1930,12 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, return null; return null; } } @Override public Drawable getIcon(Context context) { return null; } public View create(Context context, View convertView, ViewGroup parent, public View create(Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { LayoutInflater inflater) { View v = inflater.inflate(R.layout.global_actions_silent_mode, parent, false); View v = inflater.inflate(R.layout.global_actions_silent_mode, parent, false); Loading Loading @@ -2075,7 +2107,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, private final NotificationShadeDepthController mDepthController; private final NotificationShadeDepthController mDepthController; private final SysUiState mSysUiState; private final SysUiState mSysUiState; private ListPopupWindow mOverflowPopup; private ListPopupWindow mOverflowPopup; private ListPopupWindow mPowerOptionsPopup; private Dialog mPowerOptionsDialog; private final Runnable mOnRotateCallback; private final Runnable mOnRotateCallback; private final boolean mControlsAvailable; private final boolean mControlsAvailable; Loading Loading @@ -2211,21 +2243,6 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } } } } private ListPopupWindow createPowerOptionsPopup() { GlobalActionsPopupMenu popup = new GlobalActionsPopupMenu( new ContextThemeWrapper( mContext, com.android.systemui.R.style.Control_ListPopupWindow ), false /* isDropDownMode */); popup.setOnItemClickListener( (parent, view, position, id) -> mPowerOptionsAdapter.onClickItem(position)); popup.setOnItemLongClickListener( (parent, view, position, id) -> mPowerOptionsAdapter.onLongClickItem(position)); popup.setAnchorView(mGlobalActionsLayout); popup.setAdapter(mPowerOptionsAdapter); return popup; } private ListPopupWindow createPowerOverflowPopup() { private ListPopupWindow createPowerOverflowPopup() { GlobalActionsPopupMenu popup = new GlobalActionsPopupMenu( GlobalActionsPopupMenu popup = new GlobalActionsPopupMenu( new ContextThemeWrapper( new ContextThemeWrapper( Loading @@ -2244,8 +2261,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } } public void showPowerOptionsMenu() { public void showPowerOptionsMenu() { mPowerOptionsPopup = createPowerOptionsPopup(); mPowerOptionsDialog = GlobalActionsPowerDialog.create(mContext, mPowerOptionsAdapter); mPowerOptionsPopup.show(); mPowerOptionsDialog.show(); } } private void showPowerOverflowMenu() { private void showPowerOverflowMenu() { Loading Loading @@ -2479,11 +2496,11 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, } } private void dismissPowerOptions(boolean immediate) { private void dismissPowerOptions(boolean immediate) { if (mPowerOptionsPopup != null) { if (mPowerOptionsDialog != null) { if (immediate) { if (immediate) { mPowerOptionsPopup.dismissImmediate(); mPowerOptionsDialog.dismiss(); } else { } else { mPowerOptionsPopup.dismiss(); mPowerOptionsDialog.dismiss(); } } } } } } Loading
packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsPowerDialog.java 0 → 100644 +60 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2020 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.systemui.globalactions; import android.annotation.NonNull; import android.app.Dialog; import android.content.Context; import android.content.res.Resources; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.ListAdapter; /** * Creates a customized Dialog for displaying the Shut Down and Restart actions. */ public class GlobalActionsPowerDialog { /** * Create a dialog for displaying Shut Down and Restart actions. */ public static Dialog create(@NonNull Context context, ListAdapter adapter) { ViewGroup listView = (ViewGroup) LayoutInflater.from(context).inflate( com.android.systemui.R.layout.global_actions_power_dialog, null); for (int i = 0; i < adapter.getCount(); i++) { View action = adapter.getView(i, null, listView); listView.addView(action); } Resources res = context.getResources(); Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(listView); Window window = dialog.getWindow(); window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY); window.setTitle(""); // prevent Talkback from speaking first item name twice window.setBackgroundDrawable(res.getDrawable( com.android.systemui.R.drawable.control_background, context.getTheme())); return dialog; } }