diff options
6 files changed, 44 insertions, 13 deletions
diff --git a/packages/SystemUI/res/values-sw600dp/dimens.xml b/packages/SystemUI/res/values-sw600dp/dimens.xml index 85f8f0957a08..4e578615f30f 100644 --- a/packages/SystemUI/res/values-sw600dp/dimens.xml +++ b/packages/SystemUI/res/values-sw600dp/dimens.xml @@ -105,5 +105,5 @@ <dimen name="qs_detail_margin_top">0dp</dimen> <!-- The width of large/content heavy dialogs (e.g. Internet, Media output, etc) --> - <dimen name="large_dialog_width">624dp</dimen> + <dimen name="large_dialog_width">504dp</dimen> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java index 6895ef10fd07..26ce645eefc5 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java @@ -104,8 +104,6 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements lp.setFitInsetsIgnoringVisibility(true); window.setAttributes(lp); window.setContentView(mDialogView); - window.setLayout(mContext.getResources().getDimensionPixelSize(R.dimen.large_dialog_width), - ViewGroup.LayoutParams.WRAP_CONTENT); mHeaderTitle = mDialogView.requireViewById(R.id.header_title); mHeaderSubtitle = mDialogView.requireViewById(R.id.header_subtitle); diff --git a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialog.kt b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialog.kt index 9e8f6b82c182..23482677038c 100644 --- a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyDialog.kt @@ -24,7 +24,6 @@ import android.view.Gravity import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.view.ViewGroup.LayoutParams.WRAP_CONTENT import android.view.WindowInsets import android.widget.ImageView import android.widget.TextView @@ -65,7 +64,6 @@ class PrivacyDialog( window?.apply { attributes.fitInsetsTypes = attributes.fitInsetsTypes or WindowInsets.Type.statusBars() attributes.receiveInsetsIgnoringZOrder = true - setLayout(context.resources.getDimensionPixelSize(R.dimen.qs_panel_width), WRAP_CONTENT) setGravity(Gravity.TOP or Gravity.CENTER_HORIZONTAL) } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java index dd03f6e35c45..204dd46189d8 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java @@ -37,7 +37,6 @@ import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.FrameLayout; @@ -187,9 +186,6 @@ public class InternetDialog extends SystemUIDialog implements final Window window = getWindow(); window.setContentView(mDialogView); - // Only fix the width for large screen or tablet. - window.setLayout(mContext.getResources().getDimensionPixelSize( - R.dimen.large_dialog_width), ViewGroup.LayoutParams.WRAP_CONTENT); window.setWindowAnimations(R.style.Animation_InternetDialog); mInternetDialogLayout = mDialogView.requireViewById(R.id.internet_connectivity_dialog); diff --git a/packages/SystemUI/src/com/android/systemui/qs/user/UserDialog.kt b/packages/SystemUI/src/com/android/systemui/qs/user/UserDialog.kt index 01afa56fc496..26d1bbde2a54 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/user/UserDialog.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/user/UserDialog.kt @@ -71,10 +71,6 @@ class UserDialog( setType(WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL) attributes.fitInsetsTypes = attributes.fitInsetsTypes or WindowInsets.Type.statusBars() attributes.receiveInsetsIgnoringZOrder = true - setLayout( - context.resources.getDimensionPixelSize(R.dimen.notification_panel_width), - ViewGroup.LayoutParams.WRAP_CONTENT - ) setGravity(Gravity.CENTER) } setContentView(R.layout.qs_user_dialog_content) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java index 9415d5082d10..18aa6893e7bc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java @@ -22,7 +22,11 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.os.Bundle; +import android.os.SystemProperties; import android.os.UserHandle; +import android.util.TypedValue; +import android.view.ViewGroup; import android.view.Window; import android.view.WindowInsets.Type; import android.view.WindowManager; @@ -45,6 +49,10 @@ import java.util.Set; * and dismisses itself when it receives the broadcast. */ public class SystemUIDialog extends AlertDialog implements ListenableDialog { + // TODO(b/203389579): Remove this once the dialog width on large screens has been agreed on. + private static final String FLAG_TABLET_DIALOG_WIDTH = + "persist.systemui.flag_tablet_dialog_width"; + private final Context mContext; private final DismissReceiver mDismissReceiver; private final Set<DialogListener> mDialogListeners = new LinkedHashSet<>(); @@ -66,6 +74,41 @@ public class SystemUIDialog extends AlertDialog implements ListenableDialog { } @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Set the dialog window size. + getWindow().setLayout(getDialogWidth(), ViewGroup.LayoutParams.WRAP_CONTENT); + } + + private int getDialogWidth() { + boolean isOnTablet = + mContext.getResources().getConfiguration().smallestScreenWidthDp >= 600; + if (!isOnTablet) { + return ViewGroup.LayoutParams.MATCH_PARENT; + } + + int flagValue = SystemProperties.getInt(FLAG_TABLET_DIALOG_WIDTH, 0); + if (flagValue == -1) { + // The width of bottom sheets (624dp). + return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 624, + mContext.getResources().getDisplayMetrics())); + } else if (flagValue == -2) { + // The suggested small width for all dialogs (348dp) + return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 348, + mContext.getResources().getDisplayMetrics())); + } else if (flagValue > 0) { + // Any given width. + return Math.round( + TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, flagValue, + mContext.getResources().getDisplayMetrics())); + } else { + // By default we use the same width as the notification shade in portrait mode (504dp). + return mContext.getResources().getDimensionPixelSize(R.dimen.large_dialog_width); + } + } + + @Override protected void onStart() { super.onStart(); mDismissReceiver.register(); |