From ca0fa06df6276c821fde3496b9345df62776d38a Mon Sep 17 00:00:00 2001 From: Joshua Mokut Date: Wed, 18 Oct 2023 09:20:05 +0100 Subject: Updated brightness dialog width logic The new default width for brightness slider UI when in landscape mode is half width. However for settings we want full width. Hence now settings will also send a boolean along with the Intent to start brightness dialog activity, specifying that the width of the brightness dialog should be full width. Test: open settings->display. click or press "Brightness Level" and check that the brightness slider UI takes the full width of the right hand pane of settings Fixes: 303633970 Change-Id: I82d0c33e533bd366d68d8dcba9c9e741144481ac --- core/java/android/content/Intent.java | 8 ++++++++ .../systemui/settings/brightness/BrightnessDialog.java | 12 +++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 44a9acd6ba2f..b90a0e84ed7a 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -4266,6 +4266,14 @@ public class Intent implements Parcelable, Cloneable { public static final String ACTION_SHOW_BRIGHTNESS_DIALOG = "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG"; + /** + * Intent Extra: holds boolean that determines whether brightness dialog is full width when + * in landscape mode. + * @hide + */ + public static final String EXTRA_BRIGHTNESS_DIALOG_IS_FULL_WIDTH = + "android.intent.extra.BRIGHTNESS_DIALOG_IS_FULL_WIDTH"; + /** * Activity Action: Shows the contrast setting dialog. * @hide diff --git a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessDialog.java b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessDialog.java index 1ecb127f0c92..ead10d6da860 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessDialog.java +++ b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessDialog.java @@ -16,6 +16,7 @@ package com.android.systemui.settings.brightness; +import static android.content.Intent.EXTRA_BRIGHTNESS_DIALOG_IS_FULL_WIDTH; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import static android.view.WindowManagerPolicyConstants.EXTRA_FROM_BRIGHTNESS_KEY; @@ -83,7 +84,7 @@ public class BrightnessDialog extends Activity { private void setWindowAttributes() { final Window window = getWindow(); - window.setGravity(Gravity.TOP | Gravity.LEFT); + window.setGravity(Gravity.TOP | Gravity.START); window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); window.requestFeature(Window.FEATURE_NO_TITLE); @@ -130,13 +131,14 @@ public class BrightnessDialog extends Activity { Configuration configuration = getResources().getConfiguration(); int orientation = configuration.orientation; + int screenWidth = getWindowManager().getDefaultDisplay().getWidth(); if (orientation == Configuration.ORIENTATION_LANDSCAPE) { - lp.width = getWindowManager().getDefaultDisplay().getWidth() / 2 - - lp.leftMargin * 2; + boolean shouldBeFullWidth = getIntent() + .getBooleanExtra(EXTRA_BRIGHTNESS_DIALOG_IS_FULL_WIDTH, false); + lp.width = (shouldBeFullWidth ? screenWidth : screenWidth / 2) - horizontalMargin * 2; } else if (orientation == Configuration.ORIENTATION_PORTRAIT) { - lp.width = getWindowManager().getDefaultDisplay().getWidth() - - lp.leftMargin * 2; + lp.width = screenWidth - horizontalMargin * 2; } frame.setLayoutParams(lp); -- cgit v1.2.3-59-g8ed1b