From 7b8636fdb0dfc5ef727365cdf42a2fb56bdffeb2 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Thu, 19 Nov 2020 03:18:10 +0000 Subject: 1/N The road to Material NEXT (bouncer and shade) Styling bouncer and shade so they have solid backgrounds and read colors from themes instead of named resources. Scrim now fetches colorBackgroundFloating, and views get their background from colorBackground. Switching from light to dark theme will make bouncer colors update without re-inflating any views. Bug: 173561906 Bug: 173561901 Test: atest ScrimControllerTest Test: atest KeyguardSecurityContainerControllerTest Test: manual, switching to dark theme annd showing notif guts Change-Id: I372e8b688d7bbddd698381accd074b7655788cd0 --- core/java/android/app/Notification.java | 24 +++++++--- .../android/internal/widget/LockPatternView.java | 14 ++++++ core/res/res/values-night/colors.xml | 3 -- core/res/res/values/colors.xml | 2 - core/res/res/values/colors_device_defaults.xml | 8 ++-- core/res/res/values/symbols.xml | 1 - .../color/notification_background_dimmed_color.xml | 19 ++++++++ .../drawable/kg_emergency_button_background.xml | 4 +- .../res-keyguard/layout/keyguard_password_view.xml | 6 +-- .../res-keyguard/layout/keyguard_pin_view.xml | 3 +- .../res-keyguard/layout/keyguard_sim_pin_view.xml | 1 - .../res-keyguard/layout/keyguard_sim_puk_view.xml | 1 - packages/SystemUI/res-keyguard/values/styles.xml | 35 +++++++------- .../res/color/background_protect_secondary.xml | 20 -------- packages/SystemUI/res/color/pin_delete_color.xml | 2 +- packages/SystemUI/res/color/pin_divider_color.xml | 2 +- packages/SystemUI/res/color/qs_background_dark.xml | 2 +- .../SystemUI/res/drawable/notification_guts_bg.xml | 2 +- .../res/drawable/notification_material_bg.xml | 2 +- .../res/drawable/notification_material_bg_dim.xml | 2 +- packages/SystemUI/res/layout/app_ops_info.xml | 2 +- packages/SystemUI/res/layout/feedback_info.xml | 2 +- .../res/layout/notification_conversation_info.xml | 2 +- packages/SystemUI/res/layout/notification_guts.xml | 3 +- .../SystemUI/res/layout/notification_snooze.xml | 2 +- .../status_bar_notification_section_header.xml | 1 - packages/SystemUI/res/values-night/colors.xml | 11 +---- packages/SystemUI/res/values/colors.xml | 9 ---- packages/SystemUI/res/values/styles.xml | 9 ++-- .../src/com/android/keyguard/EmergencyButton.java | 12 +++++ .../KeyguardAbsKeyInputViewController.java | 9 ++++ .../keyguard/KeyguardInputViewController.java | 14 ++++++ .../com/android/keyguard/KeyguardMessageArea.java | 8 +++- .../keyguard/KeyguardMessageAreaController.java | 7 +++ .../keyguard/KeyguardPasswordViewController.java | 21 ++++++-- .../keyguard/KeyguardPatternViewController.java | 12 +++++ .../keyguard/KeyguardPinBasedInputView.java | 30 +++++++++++- .../keyguard/KeyguardPinViewController.java | 6 +++ .../KeyguardSecurityContainerController.java | 28 +++++++++-- .../KeyguardSecurityViewFlipperController.java | 9 ++++ .../keyguard/KeyguardSimPinViewController.java | 2 +- .../keyguard/KeyguardSimPukViewController.java | 2 +- .../src/com/android/keyguard/NumPadKey.java | 22 ++++++++- .../src/com/android/keyguard/PasswordTextView.java | 14 +++++- .../notification/MediaNotificationProcessor.java | 5 +- .../row/ActivatableNotificationView.java | 6 ++- .../notification/row/NotificationGuts.java | 5 -- .../row/wrapper/NotificationViewWrapper.java | 5 +- .../stack/NotificationStackScrollLayout.java | 12 +---- .../NotificationStackScrollLayoutController.java | 10 +--- .../android/systemui/statusbar/phone/LockIcon.java | 7 ++- .../phone/LockscreenLockIconController.java | 41 ++++++++++------ .../systemui/statusbar/phone/ScrimController.java | 56 +++++++++++++--------- .../systemui/statusbar/phone/StatusBar.java | 3 +- .../KeyguardSecurityContainerControllerTest.java | 7 ++- .../statusbar/phone/ScrimControllerTest.java | 17 ++++--- .../devicepolicy/DevicePolicyManagerTest.java | 10 +--- 57 files changed, 373 insertions(+), 201 deletions(-) create mode 100644 packages/SystemUI/res-keyguard/color/notification_background_dimmed_color.xml delete mode 100644 packages/SystemUI/res/color/background_protect_secondary.xml diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index d5977e7711fd..a1135809fd4c 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -5932,8 +5932,7 @@ public class Notification implements Parcelable } int color; - int background = mContext.getColor( - com.android.internal.R.color.notification_material_background_color); + int background = obtainBackgroundColor(); if (rawColor == COLOR_DEFAULT) { ensureColors(p); color = ContrastColorUtil.resolveDefaultColor(mContext, background, mInNightMode); @@ -5966,8 +5965,7 @@ public class Notification implements Parcelable if (mNeutralColor != COLOR_INVALID) { return mNeutralColor; } - int background = mContext.getColor( - com.android.internal.R.color.notification_material_background_color); + int background = obtainBackgroundColor(); mNeutralColor = ContrastColorUtil.resolveDefaultColor(mContext, background, mInNightMode); if (Color.alpha(mNeutralColor) < 255) { @@ -6118,6 +6116,21 @@ public class Notification implements Parcelable return mN; } + private @ColorInt int obtainBackgroundColor() { + int defaultColor = mInNightMode ? Color.BLACK : Color.WHITE; + Resources.Theme theme = mContext.getTheme(); + if (theme == null) { + return defaultColor; + } + TypedArray ta = theme.obtainStyledAttributes(new int[]{R.attr.colorBackground}); + if (ta == null) { + return defaultColor; + } + int background = ta.getColor(0, defaultColor); + ta.recycle(); + return background; + } + /** * Apply this Builder to an existing {@link Notification} object. * @@ -6251,8 +6264,7 @@ public class Notification implements Parcelable private int resolveBackgroundColor(StandardTemplateParams p) { int backgroundColor = getBackgroundColor(p); if (backgroundColor == COLOR_DEFAULT) { - backgroundColor = mContext.getColor( - com.android.internal.R.color.notification_material_background_color); + backgroundColor = obtainBackgroundColor(); } return backgroundColor; } diff --git a/core/java/com/android/internal/widget/LockPatternView.java b/core/java/com/android/internal/widget/LockPatternView.java index 4ddc782aacb4..bad21d28416b 100644 --- a/core/java/com/android/internal/widget/LockPatternView.java +++ b/core/java/com/android/internal/widget/LockPatternView.java @@ -1090,6 +1090,20 @@ public class LockPatternView extends View { } } + /** + * Change theme colors + * @param regularColor The dot color + * @param successColor Color used when pattern is correct + * @param errorColor Color used when authentication fails + */ + public void setColors(int regularColor, int successColor, int errorColor) { + mRegularColor = regularColor; + mErrorColor = errorColor; + mSuccessColor = successColor; + mPathPaint.setColor(regularColor); + invalidate(); + } + private float getCenterXForColumn(int column) { return mPaddingLeft + column * mSquareWidth + mSquareWidth / 2f; } diff --git a/core/res/res/values-night/colors.xml b/core/res/res/values-night/colors.xml index 39cdce9cc46b..29f2b6f14b57 100644 --- a/core/res/res/values-night/colors.xml +++ b/core/res/res/values-night/colors.xml @@ -26,9 +26,6 @@ #ddffffff - - @color/black - @color/list_divider_color_dark @color/loading_gradient_background_color_dark @color/loading_gradient_highlight_color_dark diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml index 1242c6dc8217..0079d8cd0276 100644 --- a/core/res/res/values/colors.xml +++ b/core/res/res/values/colors.xml @@ -143,8 +143,6 @@ @color/primary_text_default_material_light #a3202124 - #ffffffff - #757575 @color/notification_default_color diff --git a/core/res/res/values/colors_device_defaults.xml b/core/res/res/values/colors_device_defaults.xml index 7a8f411992ce..310ca893ac39 100644 --- a/core/res/res/values/colors_device_defaults.xml +++ b/core/res/res/values/colors_device_defaults.xml @@ -37,10 +37,10 @@ @color/accent_material_dark @color/accent_device_default_light - @color/background_material_dark - @color/background_material_light - @color/background_floating_material_dark - @color/background_floating_material_light + #1A1A1A + #F2F2F2 + #0D0D0D + #CCCCCC @color/error_color_material_dark diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 84556d41a07e..56284ff41bf9 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3002,7 +3002,6 @@ - diff --git a/packages/SystemUI/res-keyguard/color/notification_background_dimmed_color.xml b/packages/SystemUI/res-keyguard/color/notification_background_dimmed_color.xml new file mode 100644 index 000000000000..3345e6e42500 --- /dev/null +++ b/packages/SystemUI/res-keyguard/color/notification_background_dimmed_color.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res-keyguard/drawable/kg_emergency_button_background.xml b/packages/SystemUI/res-keyguard/drawable/kg_emergency_button_background.xml index cc2089f69287..99c70a54a3cd 100644 --- a/packages/SystemUI/res-keyguard/drawable/kg_emergency_button_background.xml +++ b/packages/SystemUI/res-keyguard/drawable/kg_emergency_button_background.xml @@ -19,13 +19,13 @@ - + - + diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_password_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_password_view.xml index b06d6a989cb8..e1550aa0c87c 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_password_view.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_password_view.xml @@ -34,7 +34,7 @@ android:layout_weight="7" /> - + @@ -65,7 +65,7 @@ android:contentDescription="@string/accessibility_ime_switch_button" android:clickable="true" android:padding="8dip" - android:tint="@color/background_protected" + android:tint="?android:attr/textColorPrimary" android:layout_gravity="end|center_vertical" android:background="?android:attr/selectableItemBackground" android:visibility="gone" diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml index a75b35d117b6..87c98d2e9597 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml @@ -46,11 +46,10 @@ android:id="@+id/pinEntry" android:layout_width="@dimen/keyguard_security_width" android:layout_height="match_parent" - android:gravity="center" + style="@style/Widget.TextView.Password" android:layout_centerHorizontal="true" android:layout_marginRight="72dp" androidprv:scaledTextSize="@integer/scaled_password_text_size" - android:textColor="?attr/wallpaperTextColor" android:contentDescription="@string/keyguard_accessibility_pin_area" /> - + - - - @@ -95,15 +100,9 @@ - - @@ -555,8 +554,8 @@