Skip to content

Commit

Permalink
SystemUI: Follow light/dark theme in quick settings
Browse files Browse the repository at this point in the history
Android 12's dual-tone style where the quick settings panel is always
dark makes the light theme look like a second-class citizen. Pure black
also looks out-of-place next to QS tiles and the notification panel
because dynamic themes don't affect it at all.

Revert to the ~Beta 1 style where quick settings used the same theme as
the notification shade.

- colorAccentPrimary has been replaced with colorAccent for contrast in
  light mode, because colorAccentPrimary is system_accent1_100 (dark
  accent color)
- Footer chips have been converted to surfaces (similar to QS tiles and
  notifications), which makes more sense with the new style
- The QS background is now the same as the notification shade background
  in both light and dark modes

Demo screenshots (with dual-tone commit):
https://twitter.com/kdrag0n/status/1445922541218922496

[kdrag0n: ported to 12L]

Change-Id: I3d45b72f0f119e100505409d178ab8f698993881
  • Loading branch information
kdrag0n committed Jun 7, 2022
1 parent f8c73f0 commit 813681b
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
android:height="@dimen/rounded_slider_height">
<shape>
<size android:height="@dimen/rounded_slider_height" />
<solid android:color="?priv-android:attr/colorAccentPrimary" />
<solid android:color="?android:attr/colorAccent" />
<corners android:radius="@dimen/rounded_slider_corner_radius"/>
</shape>
</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="?attr/underSurfaceColor"/>
<corners android:radius="@dimen/qs_footer_action_corner_radius"/>
</shape>
</item>
<item>
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="?android:attr/colorBackground"/>
<solid android:color="?attr/offStateColor"/>
<corners android:radius="@dimen/qs_footer_action_corner_radius"/>
</shape>
</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
</item>
<item>
<shape android:shape="rectangle">
<stroke android:width="1dp"
android:color="?android:attr/colorBackground"/>
<solid android:color="?attr/offStateColor"/>
<corners android:radius="@dimen/qs_security_footer_corner_radius"/>
</shape>
</item>
Expand Down
4 changes: 2 additions & 2 deletions packages/SystemUI/res/layout/combined_qs_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:paddingLeft="@dimen/qs_panel_padding"
android:paddingRight="@dimen/qs_panel_padding"
android:visibility="gone"
android:theme="@style/Theme.SystemUI.QuickSettings.Header"
android:theme="@style/QSHeaderTheme"
app:layoutDescription="@xml/combined_qs_header_scene">

<androidx.constraintlayout.widget.Guideline
Expand Down Expand Up @@ -101,4 +101,4 @@
app:layout_constraintBottom_toBottomOf="parent"
/>

</androidx.constraintlayout.motion.widget.MotionLayout>
</androidx.constraintlayout.motion.widget.MotionLayout>
2 changes: 1 addition & 1 deletion packages/SystemUI/res/layout/split_shade_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
android:paddingLeft="@dimen/qs_panel_padding"
android:paddingRight="@dimen/qs_panel_padding"
android:visibility="gone"
android:theme="@style/Theme.SystemUI.QuickSettings.Header">
android:theme="@style/QSHeaderTheme">

<com.android.systemui.statusbar.policy.Clock
android:id="@+id/clock"
Expand Down
12 changes: 12 additions & 0 deletions packages/SystemUI/res/values-night/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@
<item name="android:windowIsFloating">true</item>
</style>

<style name="Theme.SystemUI.QuickSettings" parent="@*android:style/Theme.DeviceDefault.SystemUI">
<item name="lightIconTheme">@style/QSIconTheme</item>
<item name="darkIconTheme">@style/QSIconTheme</item>
<item name="android:colorError">@*android:color/error_color_material_dark</item>
<item name="android:windowIsFloating">true</item>
<item name="android:homeAsUpIndicator">@drawable/ic_arrow_back</item>
<item name="offStateColor">@android:color/system_neutral1_800</item>
<item name="underSurfaceColor">@android:color/system_neutral1_900</item>
<item name="android:colorBackground">@android:color/system_neutral1_900</item>
<item name="android:itemTextAppearance">@style/Control.MenuItem</item>
</style>

<style name="TextAppearance.QS.Status" parent="TextAppearance.QS.TileLabel.Secondary">
<item name="android:fontFamily">@*android:string/config_bodyFontFamily</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
Expand Down
10 changes: 5 additions & 5 deletions packages/SystemUI/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,12 @@
<style name="Theme.SystemUI.QuickSettings" parent="@*android:style/Theme.DeviceDefault.SystemUI">
<item name="lightIconTheme">@style/QSIconTheme</item>
<item name="darkIconTheme">@style/QSIconTheme</item>
<item name="android:colorError">@*android:color/error_color_material_dark</item>
<item name="android:colorError">@*android:color/error_color_material_light</item>
<item name="android:windowIsFloating">true</item>
<item name="android:homeAsUpIndicator">@drawable/ic_arrow_back</item>
<item name="offStateColor">@android:color/system_neutral1_800</item>
<item name="underSurfaceColor">@android:color/system_neutral1_1000</item>
<item name="android:colorBackground">@android:color/system_neutral1_900</item>
<item name="offStateColor">@*android:color/surface_light</item>
<item name="underSurfaceColor">@android:color/system_neutral1_50</item>
<item name="android:colorBackground">@android:color/system_neutral1_50</item>
<item name="android:itemTextAppearance">@style/Control.MenuItem</item>
</style>

Expand Down Expand Up @@ -540,7 +540,7 @@

<style name="QSCustomizeToolbar" parent="@*android:style/Widget.DeviceDefault.Toolbar">
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:elevation">10dp</item>
<item name="android:elevation">0dp</item>
</style>

<!-- Media controls always have light background -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ class OngoingPrivacyChip @JvmOverloads constructor(
.getDimensionPixelSize(R.dimen.ongoing_appops_chip_icon_margin)
iconSize = context.resources
.getDimensionPixelSize(R.dimen.ongoing_appops_chip_icon_size)
iconColor =
Utils.getColorAttrDefaultColor(context, com.android.internal.R.attr.colorPrimary)
iconColor = context.resources
.getColor(android.R.color.system_neutral1_900)

val padding = context.resources
.getDimensionPixelSize(R.dimen.ongoing_appops_chip_side_padding)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ open class QSTileViewImpl @JvmOverloads constructor(
}

private val colorActive = Utils.getColorAttrDefaultColor(context,
com.android.internal.R.attr.colorAccentPrimary)
android.R.attr.colorAccent)
private val colorInactive = Utils.getColorAttrDefaultColor(context, R.attr.offStateColor)
private val colorUnavailable = Utils.applyAlpha(UNAVAILABLE_ALPHA, colorInactive)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ private void applyState() {
mNotificationsAlpha = behindAlpha;
mNotificationsTint = behindTint;
mBehindAlpha = 1;
mBehindTint = Color.BLACK;
mBehindTint = Color.TRANSPARENT;
} else {
mBehindAlpha = behindAlpha;
if (mState == ScrimState.SHADE_LOCKED) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void prepare(ScrimState previousState) {
mBehindAlpha = mClipQsScrim ? 1 : mScrimBehindAlphaKeyguard;
mNotifAlpha = mClipQsScrim ? mScrimBehindAlphaKeyguard : 0;
if (mClipQsScrim) {
updateScrimColor(mScrimBehind, 1f /* alpha */, Color.BLACK);
updateScrimColor(mScrimBehind, 1f /* alpha */, Color.TRANSPARENT);
}
}
},
Expand Down Expand Up @@ -119,7 +119,7 @@ public void prepare(ScrimState previousState) {
@Override
public void prepare(ScrimState previousState) {
mBehindAlpha = mClipQsScrim ? 1 : mDefaultScrimAlpha;
mBehindTint = mClipQsScrim ? Color.BLACK : Color.TRANSPARENT;
mBehindTint = Color.TRANSPARENT;
mNotifAlpha = mClipQsScrim ? mDefaultScrimAlpha : 0;
mNotifTint = Color.TRANSPARENT;
mFrontAlpha = 0f;
Expand All @@ -143,17 +143,17 @@ public void prepare(ScrimState previousState) {
mBehindAlpha = mClipQsScrim ? 1 : mDefaultScrimAlpha;
mNotifAlpha = 1f;
mFrontAlpha = 0f;
mBehindTint = Color.BLACK;
mBehindTint = Color.TRANSPARENT;

if (mClipQsScrim) {
updateScrimColor(mScrimBehind, 1f /* alpha */, Color.BLACK);
updateScrimColor(mScrimBehind, 1f /* alpha */, Color.TRANSPARENT);
}
}

// to make sure correct color is returned before "prepare" is called
@Override
public int getBehindTint() {
return Color.BLACK;
return Color.TRANSPARENT;
}
},

Expand Down Expand Up @@ -244,22 +244,22 @@ public void prepare(ScrimState previousState) {
mAnimateChange = !mLaunchingAffordanceWithPreview && !fromAod;

mFrontTint = Color.TRANSPARENT;
mBehindTint = Color.BLACK;
mBehindTint = Color.TRANSPARENT;
mBlankScreen = false;

if (previousState == ScrimState.AOD) {
// Set all scrims black, before they fade transparent.
updateScrimColor(mScrimInFront, 1f /* alpha */, Color.BLACK /* tint */);
updateScrimColor(mScrimBehind, 1f /* alpha */, Color.BLACK /* tint */);
updateScrimColor(mScrimBehind, 1f /* alpha */, Color.TRANSPARENT /* tint */);

// Scrims should still be black at the end of the transition.
mFrontTint = Color.BLACK;
mBehindTint = Color.BLACK;
mBehindTint = Color.TRANSPARENT;
mBlankScreen = true;
}

if (mClipQsScrim) {
updateScrimColor(mScrimBehind, 1f /* alpha */, Color.BLACK);
updateScrimColor(mScrimBehind, 1f /* alpha */, Color.TRANSPARENT);
}
}
};
Expand Down Expand Up @@ -399,4 +399,4 @@ public void setKeyguardFadingAway(boolean fadingAway, long duration) {
public void setClipQsScrim(boolean clipsQsScrim) {
mClipQsScrim = clipsQsScrim;
}
}
}

0 comments on commit 813681b

Please sign in to comment.