summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
diff options
context:
space:
mode:
authorMatt Pietal <mpietal@google.com>2021-04-13 17:08:11 -0400
committerMatt Pietal <mpietal@google.com>2021-04-14 09:45:39 -0400
commita76c5b2bed5d474c6b51a91da6c9d8f8b1e54acf (patch)
tree35b7092ab951bad066316bceff7e83f7cff20619 /packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
parentf63b7f050157942bd6c1046853dc60e8f67a5a9c (diff)
Smartspace - Allow primary card colors to be updated
This is largely for both AOD and lockscreen, while may have different colors than launcher. Particularly for AOD, we need to transition to a WHITE color. Set a primary text color, with expectations that a secondary color will later be set in order to support cards with various background colors. Fixes: 185211979 Test: manual, change to AOD <-> LS Change-Id: I36fb8e5cfcbac1ec999b2b9df08f42d47507990f
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java')
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java57
1 files changed, 56 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
index cb825c043642..f89e365bc995 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
@@ -26,14 +26,18 @@ import android.app.smartspace.SmartspaceSession;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.Color;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.colorextraction.ColorExtractor;
+import com.android.internal.graphics.ColorUtils;
import com.android.keyguard.clock.ClockManager;
+import com.android.settingslib.Utils;
import com.android.systemui.R;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.colorextraction.SysuiColorExtractor;
@@ -50,6 +54,7 @@ import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.phone.NotificationIconAreaController;
import com.android.systemui.statusbar.phone.NotificationIconContainer;
import com.android.systemui.statusbar.policy.BatteryController;
+import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.util.ViewController;
import java.util.Locale;
@@ -87,6 +92,10 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
private Executor mUiExecutor;
private SmartspaceSession mSmartspaceSession;
private SmartspaceSession.Callback mSmartspaceCallback;
+ private float mDozeAmount;
+ private int mWallpaperTextColor;
+ private int mDozeColor = Color.WHITE;
+ private ConfigurationController mConfigurationController;
/**
* Listener for changes to the color palette.
@@ -103,8 +112,25 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
}
};
+ private final ConfigurationController.ConfigurationListener mConfigurationListener =
+ new ConfigurationController.ConfigurationListener() {
+ @Override
+ public void onThemeChanged() {
+ updateWallpaperColor();
+ }
+ };
+
private ClockManager.ClockChangedListener mClockChangedListener = this::setClockPlugin;
+ private final StatusBarStateController.StateListener mStatusBarStateListener =
+ new StatusBarStateController.StateListener() {
+ @Override
+ public void onDozeAmountChanged(float linear, float eased) {
+ mDozeAmount = eased;
+ updateSmartspaceColor();
+ }
+ };
+
// If set, will replace keyguard_status_area
private BcSmartspaceDataPlugin.SmartspaceView mSmartspaceView;
@@ -121,7 +147,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
PluginManager pluginManager,
FeatureFlags featureFlags,
@Main Executor uiExecutor,
- BatteryController batteryController) {
+ BatteryController batteryController,
+ ConfigurationController configurationController) {
super(keyguardClockSwitch);
mResources = resources;
mStatusBarStateController = statusBarStateController;
@@ -134,6 +161,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mIsSmartspaceEnabled = featureFlags.isSmartspaceEnabled();
mUiExecutor = uiExecutor;
mBatteryController = batteryController;
+ mConfigurationController = configurationController;
}
/**
@@ -172,6 +200,12 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mBatteryController);
mLargeClockViewController.init();
+ mDozeAmount = mStatusBarStateController.getDozeAmount();
+ updateWallpaperColor();
+
+ mStatusBarStateController.addCallback(mStatusBarStateListener);
+ mConfigurationController.addCallback(mConfigurationListener);
+
// If a smartspace plugin is detected, replace the existing smartspace
// (keyguard_status_area), and initialize a new session
mPluginListener = new PluginListener<BcSmartspaceDataPlugin>() {
@@ -186,6 +220,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mSmartspaceView = plugin.getView(mView);
mSmartspaceView.registerDataProvider(plugin);
+ updateSmartspaceColor();
View asView = (View) mSmartspaceView;
// Place plugin view below normal clock...
@@ -242,6 +277,19 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mPluginManager.addPluginListener(mPluginListener, BcSmartspaceDataPlugin.class, false);
}
+ private void updateWallpaperColor() {
+ mWallpaperTextColor = Utils.getColorAttrDefaultColor(getContext(),
+ R.attr.wallpaperTextColor);
+ updateSmartspaceColor();
+ }
+
+ private void updateSmartspaceColor() {
+ if (mSmartspaceView != null) {
+ int color = ColorUtils.blendARGB(mWallpaperTextColor, mDozeColor, mDozeAmount);
+ mSmartspaceView.setPrimaryTextColor(color);
+ }
+ }
+
@Override
protected void onViewDetached() {
if (CUSTOM_CLOCKS_ENABLED) {
@@ -256,6 +304,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mSmartspaceSession = null;
}
mPluginManager.removePluginListener(mPluginListener);
+ mStatusBarStateController.removeCallback(mStatusBarStateListener);
+ mConfigurationController.removeCallback(mConfigurationListener);
}
/**
@@ -399,4 +449,9 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
private int getCurrentLayoutDirection() {
return TextUtils.getLayoutDirectionFromLocale(Locale.getDefault());
}
+
+ @VisibleForTesting
+ ConfigurationController.ConfigurationListener getConfigurationListener() {
+ return mConfigurationListener;
+ }
}