Make all SystemUIDialog's the same configurable width (1/2)
This CL sets the default width of SystemUIDialog to be MATCH_PARENT on phones and 624dp on tablets/foldables. Moreover, as part of b/203389579, the width on tablets/foldables can be configured using a system property. That configurable width will be removed once b/203389579 is fixed, before the sc-v2 release. Bug: 203389579 Test: Manual Change-Id: I5a54914666415c9aa278d42492d9339480222df0
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<>();
|
||||
@@ -65,6 +73,41 @@ public class SystemUIDialog extends AlertDialog implements ListenableDialog {
|
||||
mDismissReceiver = new DismissReceiver(this);
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
Reference in New Issue
Block a user