Add KeyguardSliceViewController.

This removes view injection from KeyguardSliceView.

It also creates a KeyguardStatusView Dagger Subcomponent should be
initilialized whenever a KeyguardStatusView is inflated. From that
subcomponent, KeyguardClockSwitchController and
KeyguardSliceViewController can both be created and initialized,
passing their related views into their constructor.

This fixes a bug introduced earlier where a
KeyguardClockSwitchController was not being created in one place
where it was needed.

Bug: 162525274
Test: atest SystemUITests
Change-Id: Ie571cb0ca2b793c363e3c8ab397828f0ee939763
This commit is contained in:
Dave Mankoff
2020-07-31 14:12:39 -04:00
parent 71f5744319
commit cd42c08702
17 changed files with 508 additions and 236 deletions

View File

@@ -34,10 +34,11 @@ import javax.inject.Inject;
public class KeyguardClockSwitchController {
private static final boolean CUSTOM_CLOCKS_ENABLED = true;
private final KeyguardClockSwitch mView;
private final StatusBarStateController mStatusBarStateController;
private final SysuiColorExtractor mColorExtractor;
private final ClockManager mClockManager;
private KeyguardClockSwitch mView;
private final KeyguardSliceViewController mKeyguardSliceViewController;
private final StatusBarStateController.StateListener mStateListener =
new StatusBarStateController.StateListener() {
@@ -52,9 +53,13 @@ public class KeyguardClockSwitchController {
*
* The color palette changes when the wallpaper is changed.
*/
private final ColorExtractor.OnColorsChangedListener mColorsListener = (extractor, which) -> {
if ((which & WallpaperManager.FLAG_LOCK) != 0) {
mView.updateColors(getGradientColors());
private final ColorExtractor.OnColorsChangedListener mColorsListener =
new ColorExtractor.OnColorsChangedListener() {
@Override
public void onColorsChanged(ColorExtractor extractor, int which) {
if ((which & WallpaperManager.FLAG_LOCK) != 0) {
mView.updateColors(getGradientColors());
}
}
};
@@ -84,22 +89,27 @@ public class KeyguardClockSwitchController {
};
@Inject
public KeyguardClockSwitchController(StatusBarStateController statusBarStateController,
SysuiColorExtractor colorExtractor, ClockManager clockManager) {
public KeyguardClockSwitchController(KeyguardClockSwitch keyguardClockSwitch,
StatusBarStateController statusBarStateController,
SysuiColorExtractor colorExtractor, ClockManager clockManager,
KeyguardSliceViewController keyguardSliceViewController) {
mView = keyguardClockSwitch;
mStatusBarStateController = statusBarStateController;
mColorExtractor = colorExtractor;
mClockManager = clockManager;
mKeyguardSliceViewController = keyguardSliceViewController;
}
/**
* Attach the controller to the view it relates to.
*/
public void attach(KeyguardClockSwitch view) {
mView = view;
public void init() {
if (mView.isAttachedToWindow()) {
mOnAttachStateChangeListener.onViewAttachedToWindow(mView);
}
mView.addOnAttachStateChangeListener(mOnAttachStateChangeListener);
mKeyguardSliceViewController.init();
}
/**