Merge "Separate theme breakpoints" into oc-dr1-dev

This commit is contained in:
TreeHugger Robot
2017-06-20 16:51:38 +00:00
committed by Android (Google) Code Review
11 changed files with 102 additions and 28 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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);
}
}
}

View File

@@ -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>

View File

@@ -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)

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>