diff options
| author | 2017-06-20 17:00:02 +0000 | |
|---|---|---|
| committer | 2017-06-20 17:00:02 +0000 | |
| commit | 159c24ec5823a207fa3cfb00364479f06fa997a1 (patch) | |
| tree | 235a79781aa0c357294aef62ec8f1cbdb0cf9ce6 | |
| parent | 9a0894b930033892ee6a2b66c0845ffe580336b8 (diff) | |
| parent | 52e6e12ad6fb8a7f80d1d209bbd6ade0f63d92f2 (diff) | |
Merge "Separate theme breakpoints" into oc-dr1-dev
am: 52e6e12ad6
Change-Id: Ic6847e9c0dcca85da8c8ff9a4b628d094ed04e1e
11 files changed, 102 insertions, 28 deletions
diff --git a/packages/SystemUI/res-keyguard/values/attrs.xml b/packages/SystemUI/res-keyguard/values/attrs.xml index d3d60a1e18d2..802bd308d407 100644 --- a/packages/SystemUI/res-keyguard/values/attrs.xml +++ b/packages/SystemUI/res-keyguard/values/attrs.xml @@ -41,7 +41,4 @@ <declare-styleable name="CarrierText"> <attr name="allCaps" format="boolean" /> </declare-styleable> - - <attr name="pinDividerColor" format="color" /> - <attr name="pinDeleteColor" format="color" /> </resources> diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index f942be6a72d1..5274b6476aba 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -295,8 +295,6 @@ <item name="darkIconTheme">@style/DualToneDarkTheme</item> <item name="bgProtectTextColor">?android:attr/textColorPrimaryInverse</item> <item name="bgProtectSecondaryTextColor">?android:attr/textColorSecondaryInverse</item> - <item name="pinDividerColor">@color/pin_divider_color</item> - <item name="pinDeleteColor">@color/pin_delete_color</item> <item name="*android:lockPatternStyle">@style/LockPatternStyle</item> </style> 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 d98bed10435c..305cf0c3f906 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 index 4b83058ab481..4b83058ab481 100644 --- a/packages/SysuiDarkThemeOverlay/Android.mk +++ b/packages/overlays/SysuiDarkThemeOverlay/Android.mk diff --git a/packages/SysuiDarkThemeOverlay/AndroidManifest.xml b/packages/overlays/SysuiDarkThemeOverlay/AndroidManifest.xml index ba1c91cbdebe..ba1c91cbdebe 100644 --- a/packages/SysuiDarkThemeOverlay/AndroidManifest.xml +++ b/packages/overlays/SysuiDarkThemeOverlay/AndroidManifest.xml diff --git a/packages/SysuiDarkThemeOverlay/res/values/strings.xml b/packages/overlays/SysuiDarkThemeOverlay/res/values/strings.xml index 71f48d6279f1..71f48d6279f1 100644 --- a/packages/SysuiDarkThemeOverlay/res/values/strings.xml +++ b/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 index 28ecfa0b37fa..7e2b955a8871 100644 --- a/packages/SysuiDarkThemeOverlay/res/values/themes_device_defaults.xml +++ b/packages/overlays/SysuiDarkThemeOverlay/res/values/themes_device_defaults.xml @@ -1,12 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <!-- Dark theme for a window that should look like the Settings app. --> <style name="Theme.DeviceDefault.QuickSettings" parent="android:Theme.DeviceDefault"> - <!-- Color palette --> <item name="android:colorPrimary">@*android:color/primary_device_default_settings</item> <item name="android:colorPrimaryDark">@*android:color/primary_dark_device_default_settings</item> - <item name="android:textColorPrimaryInverse">@*android:color/primary_text_material_light</item> - <item name="android:textColorSecondaryInverse">@*android:color/secondary_text_material_light</item> + <!-- textColorPrimaryInverse is used on the lock screen and this means that we can't just + invert text colors otherwise we won't have contrast on the keyguard --> + <item name="android:textColorPrimaryInverse">@*android:color/primary_text_material_dark</item> + <!-- same for textColorSecondaryInverse --> + <item name="android:textColorSecondaryInverse">@*android:color/secondary_text_material_dark</item> <item name="android:colorSecondary">@*android:color/secondary_device_default_settings</item> <item name="android:colorAccent">@*android:color/accent_device_default_dark</item> <item name="android:colorControlNormal">?android:attr/textColorPrimary</item> diff --git a/packages/overlays/SysuiLightWallpaperThemeOverlay/Android.mk b/packages/overlays/SysuiLightWallpaperThemeOverlay/Android.mk new file mode 100644 index 000000000000..4782a166146b --- /dev/null +++ b/packages/overlays/SysuiLightWallpaperThemeOverlay/Android.mk @@ -0,0 +1,13 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_RRO_THEME := SysuiLightWallpaperTheme +LOCAL_CERTIFICATE := platform + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res + +LOCAL_PACKAGE_NAME := SysuiLightWallpaperThemeOverlay + +include $(BUILD_RRO_PACKAGE) diff --git a/packages/overlays/SysuiLightWallpaperThemeOverlay/AndroidManifest.xml b/packages/overlays/SysuiLightWallpaperThemeOverlay/AndroidManifest.xml new file mode 100644 index 000000000000..1745b4cda03d --- /dev/null +++ b/packages/overlays/SysuiLightWallpaperThemeOverlay/AndroidManifest.xml @@ -0,0 +1,8 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.systemui.theme.lightwallpaper" + android:versionCode="1" + android:versionName="1.0"> + <overlay android:targetPackage="android" android:priority="2"/> + + <application android:label="@string/sysui_overlay_light" android:hasCode="false"/> +</manifest> diff --git a/packages/overlays/SysuiLightWallpaperThemeOverlay/res/values/strings.xml b/packages/overlays/SysuiLightWallpaperThemeOverlay/res/values/strings.xml new file mode 100644 index 000000000000..acc3d16610ec --- /dev/null +++ b/packages/overlays/SysuiLightWallpaperThemeOverlay/res/values/strings.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright (c) 2017, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + + <string name="sysui_overlay_light">Light</string> + +</resources> + diff --git a/packages/overlays/SysuiLightWallpaperThemeOverlay/res/values/themes_device_defaults.xml b/packages/overlays/SysuiLightWallpaperThemeOverlay/res/values/themes_device_defaults.xml new file mode 100644 index 000000000000..877ebf8c4e9d --- /dev/null +++ b/packages/overlays/SysuiLightWallpaperThemeOverlay/res/values/themes_device_defaults.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style name="Theme.DeviceDefault.QuickSettings" parent="android:Theme.DeviceDefault.Light"> + <item name="android:textColorPrimaryInverse">@*android:color/primary_text_material_light</item> + <item name="android:textColorSecondaryInverse">@*android:color/secondary_text_material_light</item> + </style> +</resources>
\ No newline at end of file |