diff --git a/packages/SystemUI/res-keyguard/values/attrs.xml b/packages/SystemUI/res-keyguard/values/attrs.xml
index d3d60a1e18d24..802bd308d4073 100644
--- a/packages/SystemUI/res-keyguard/values/attrs.xml
+++ b/packages/SystemUI/res-keyguard/values/attrs.xml
@@ -41,7 +41,4 @@
-
-
-
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index f942be6a72d18..5274b6476abaf 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -295,8 +295,6 @@
- @style/DualToneDarkTheme
- ?android:attr/textColorPrimaryInverse
- ?android:attr/textColorSecondaryInverse
- - @color/pin_divider_color
- - @color/pin_delete_color
- @style/LockPatternStyle
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index d98bed10435c8..305cf0c3f906e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -48,6 +48,7 @@ import android.app.PendingIntent;
import android.app.RemoteInput;
import android.app.StatusBarManager;
import android.app.TaskStackBuilder;
+import android.app.WallpaperColors;
import android.app.WallpaperManager;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
@@ -103,7 +104,6 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.os.Vibrator;
import android.provider.Settings;
-import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationListenerService.RankingMap;
import android.service.notification.StatusBarNotification;
import android.service.vr.IVrManager;
@@ -139,6 +139,7 @@ import android.widget.RemoteViews;
import android.widget.TextView;
import android.widget.Toast;
+import com.android.internal.graphics.ColorUtils;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
@@ -213,7 +214,6 @@ import com.android.systemui.statusbar.notification.AboveShelfObserver;
import com.android.systemui.statusbar.notification.InflationException;
import com.android.systemui.statusbar.notification.RowInflaterTask;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
-import com.android.systemui.statusbar.phone.StatusBarIconController.IconManager;
import com.android.systemui.statusbar.phone.UnlockMethodCache.OnUnlockMethodChangedListener;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
@@ -1301,10 +1301,6 @@ public class StatusBar extends SystemUI implements DemoMode,
}
public void onOverlayChanged() {
- final boolean usingDarkTheme = isUsingDarkTheme();
- if (DEBUG) {
- Log.d(TAG, "Updating theme because overlay changed. Is theme dark? " + usingDarkTheme);
- }
reevaluateStyles();
// Clock and bottom icons
@@ -2844,6 +2840,17 @@ public class StatusBar extends SystemUI implements DemoMode,
updateTheme();
}
+ public boolean isUsingDarkText() {
+ OverlayInfo themeInfo = null;
+ try {
+ themeInfo = mOverlayManager.getOverlayInfo("com.android.systemui.theme.lightwallpaper",
+ mCurrentUserId);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ return themeInfo != null && themeInfo.isEnabled();
+ }
+
public boolean isUsingDarkTheme() {
OverlayInfo themeInfo = null;
try {
@@ -4522,30 +4529,49 @@ public class StatusBar extends SystemUI implements DemoMode,
* Switches theme from light to dark and vice-versa.
*/
private void updateTheme() {
- boolean useDarkTheme;
- // Ignore visibility since we calculate the theme based on the real colors,
- // not the current state.
+
+ int which;
if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) {
- useDarkTheme = mColorExtractor.getColors(WallpaperManager.FLAG_LOCK, true /* vis */)
- .supportsDarkText();
+ which = WallpaperManager.FLAG_LOCK;
} else {
- useDarkTheme = mColorExtractor.getColors(WallpaperManager.FLAG_SYSTEM, true /* vis */)
- .supportsDarkText();
+ which = WallpaperManager.FLAG_SYSTEM;
}
- // Enable/Disable dark overlay
- if (isUsingDarkTheme() != useDarkTheme) {
- if (DEBUG) {
- Log.d(TAG, "Switching theme to: " + (useDarkTheme ? "Dark" : "Light"));
+ // Gradient defines if text color should be light or dark.
+ final boolean useDarkText = mColorExtractor.getColors(which, true /* ignoreVisibility */)
+ .supportsDarkText();
+ // And wallpaper defines if QS should be light or dark.
+ boolean useDarkTheme = false;
+ final WallpaperManager wallpaperManager = mContext.getSystemService(WallpaperManager.class);
+ if (wallpaperManager != null) {
+ WallpaperColors wallpaperColors = wallpaperManager
+ .getWallpaperColors(WallpaperManager.FLAG_SYSTEM);
+ if (wallpaperColors != null) {
+ final int mainColor = wallpaperColors.getPrimaryColor().toArgb();
+ final float[] hsl = new float[3];
+ ColorUtils.colorToHSL(mainColor, hsl);
+ useDarkTheme = hsl[2] < 0.2f;
}
+ }
+
+ // Enable/disable dark UI.
+ if (isUsingDarkTheme() != useDarkTheme) {
try {
mOverlayManager.setEnabled("com.android.systemui.theme.dark",
useDarkTheme, mCurrentUserId);
} catch (RemoteException e) {
Log.w(TAG, "Can't change theme", e);
- return;
}
- mStatusBarWindowManager.setKeyguardDark(useDarkTheme);
+ }
+ // Enable/disable dark text overlay.
+ if (isUsingDarkText() != useDarkText) {
+ try {
+ mOverlayManager.setEnabled("com.android.systemui.theme.lightwallpaper",
+ useDarkText, mCurrentUserId);
+ mStatusBarWindowManager.setKeyguardDark(useDarkText);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Can't change theme", e);
+ }
}
}
diff --git a/packages/SysuiDarkThemeOverlay/Android.mk b/packages/overlays/SysuiDarkThemeOverlay/Android.mk
similarity index 100%
rename from packages/SysuiDarkThemeOverlay/Android.mk
rename to packages/overlays/SysuiDarkThemeOverlay/Android.mk
diff --git a/packages/SysuiDarkThemeOverlay/AndroidManifest.xml b/packages/overlays/SysuiDarkThemeOverlay/AndroidManifest.xml
similarity index 100%
rename from packages/SysuiDarkThemeOverlay/AndroidManifest.xml
rename to packages/overlays/SysuiDarkThemeOverlay/AndroidManifest.xml
diff --git a/packages/SysuiDarkThemeOverlay/res/values/strings.xml b/packages/overlays/SysuiDarkThemeOverlay/res/values/strings.xml
similarity index 100%
rename from packages/SysuiDarkThemeOverlay/res/values/strings.xml
rename to packages/overlays/SysuiDarkThemeOverlay/res/values/strings.xml
diff --git a/packages/SysuiDarkThemeOverlay/res/values/themes_device_defaults.xml b/packages/overlays/SysuiDarkThemeOverlay/res/values/themes_device_defaults.xml
similarity index 71%
rename from packages/SysuiDarkThemeOverlay/res/values/themes_device_defaults.xml
rename to packages/overlays/SysuiDarkThemeOverlay/res/values/themes_device_defaults.xml
index 28ecfa0b37fa8..7e2b955a8871a 100644
--- a/packages/SysuiDarkThemeOverlay/res/values/themes_device_defaults.xml
+++ b/packages/overlays/SysuiDarkThemeOverlay/res/values/themes_device_defaults.xml
@@ -1,12 +1,13 @@
-
+
\ No newline at end of file