diff options
| author | 2019-10-29 16:49:51 +0000 | |
|---|---|---|
| committer | 2019-10-29 16:49:51 +0000 | |
| commit | 6209f7f5fe1ac0420a30289b297cb5cd6227f602 (patch) | |
| tree | 1ce51ffc812b2c075aa737d7ac30ea6dceba5b7a | |
| parent | a462b8b6b9f438b45f200b58c484a6bea192674f (diff) | |
| parent | cf7b3360200bb38564e67131e390bf0ca57f9880 (diff) | |
Merge "Changed Notification shade's background alpha initial and final values to be configurable."
| -rw-r--r-- | packages/CarSystemUI/res/values/config.xml | 15 | ||||
| -rw-r--r-- | packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java | 39 |
2 files changed, 48 insertions, 6 deletions
diff --git a/packages/CarSystemUI/res/values/config.xml b/packages/CarSystemUI/res/values/config.xml index fe042fe2e17f..329225cf94fb 100644 --- a/packages/CarSystemUI/res/values/config.xml +++ b/packages/CarSystemUI/res/values/config.xml @@ -40,6 +40,21 @@ slots that may be reused for things like IME control. --> <integer name="config_maxNotificationIcons">0</integer> + <!-- + Initial alpha percent value for the background when the notification + shade is open. Should be a number between, and inclusive, 0 and 100. + If the number is 0, then the background alpha starts off fully + transparent. If the number if 100, then the background alpha starts off + fully opaque. --> + <integer name="config_initialNotificationBackgroundAlpha">0</integer> + <!-- + Final alpha percent value for the background when the notification + shade is fully open. Should be a number between, and inclusive, 0 and + 100. If this value is smaller than + config_initialNotificationBackgroundAlpha, the background will default + to a constant alpha percent value using the initial alpha. --> + <integer name="config_finalNotificationBackgroundAlpha">100</integer> + <!-- SystemUI Services: The classes of the stuff to start. --> <string-array name="config_systemUIServiceComponents" translatable="false"> <item>com.android.systemui.util.NotificationChannels</item> diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java index faf6ee4cc7b4..601bc4030226 100644 --- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java +++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java @@ -158,6 +158,9 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt private float mOpeningVelocity = DEFAULT_FLING_VELOCITY; private float mClosingVelocity = DEFAULT_FLING_VELOCITY; + private float mBackgroundAlphaDiff; + private float mInitialBackgroundAlpha; + private FullscreenUserSwitcher mFullscreenUserSwitcher; private CarBatteryController mCarBatteryController; @@ -386,6 +389,25 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt mScreenLifecycle = Dependency.get(ScreenLifecycle.class); mScreenLifecycle.addObserver(mScreenObserver); + // Notification bar related setup. + mInitialBackgroundAlpha = (float) mContext.getResources().getInteger( + R.integer.config_initialNotificationBackgroundAlpha) / 100; + if (mInitialBackgroundAlpha < 0 || mInitialBackgroundAlpha > 100) { + throw new RuntimeException( + "Unable to setup notification bar due to incorrect initial background alpha" + + " percentage"); + } + float finalBackgroundAlpha = Math.max( + mInitialBackgroundAlpha, + (float) mContext.getResources().getInteger( + R.integer.config_finalNotificationBackgroundAlpha) / 100); + if (finalBackgroundAlpha < 0 || finalBackgroundAlpha > 100) { + throw new RuntimeException( + "Unable to setup notification bar due to incorrect final background alpha" + + " percentage"); + } + mBackgroundAlphaDiff = finalBackgroundAlpha - mInitialBackgroundAlpha; + super.start(); mNotificationPanel.setScrollingEnabled(true); @@ -1105,17 +1127,22 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt mHandleBar.setTranslationY(height - mHandleBar.getHeight() - lp.bottomMargin); } if (mNotificationView.getHeight() > 0) { - // Calculates the alpha value for the background based on how much of the notification - // shade is visible to the user. When the notification shade is completely open then - // alpha value will be 1. - float alpha = (float) height / mNotificationView.getHeight(); Drawable background = mNotificationView.getBackground().mutate(); - - background.setAlpha((int) (alpha * 255)); + background.setAlpha((int) (getBackgroundAlpha(height) * 255)); mNotificationView.setBackground(background); } } + /** + * Calculates the alpha value for the background based on how much of the notification + * shade is visible to the user. When the notification shade is completely open then + * alpha value will be 1. + */ + private float getBackgroundAlpha(int height) { + return mInitialBackgroundAlpha + + ((float) height / mNotificationView.getHeight() * mBackgroundAlphaDiff); + } + @Override public void onConfigChanged(Configuration newConfig) { super.onConfigChanged(newConfig); |