diff options
author | Dave Mankoff <mankoff@google.com> | 2020-09-22 00:24:04 +0000 |
---|---|---|
committer | Dave Mankoff <mankoff@google.com> | 2020-09-22 13:25:48 +0000 |
commit | dd7312c20ad29c133a32ffd170919bec5f98f215 (patch) | |
tree | e0deda441bd7d6d37cd47e2d03725be07d27190b /packages/SystemUI/src | |
parent | b00c929394cb6bce158265af9606a8eb5a79e47a (diff) |
Revert "8/N Remove View Injection from KeyguardMessageArea"
Revert submission 12585643-b166448040-keyguard-message-area
Reason for revert: http://b/169081305 & http://b/169020145
Reverted Changes:
I6fa05012c:4/N Setup Controller fo KeyguardSecurityContainer....
Iecf265744:5/N Add KeyguardSecurityViewFlipperController.
I90ab99b2f:6/N Add Controller for KeyguardPatternView
I4b74eddd1:7/N controllers for remaining Keyguard Password Vi...
I805286374:8/N Remove View Injection from KeyguardMessageArea...
I362755980:9/N Clean Up Keyguard Class Structure
Change-Id: Ie84234cb8ae9eaae6ec52900cb215ddf6e6213f1
Fixes: 169081305
Fixes: 169020145
Diffstat (limited to 'packages/SystemUI/src')
7 files changed, 84 insertions, 62 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java index 0ddc9680a217..3108ae3d2354 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java @@ -82,12 +82,6 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey abstract void resetState(); @Override - public void init() { - super.init(); - mMessageAreaController.init(); - } - - @Override protected void onViewAttached() { mView.setKeyDownListener(mKeyDownListener); mView.setEnableHaptics(mLockPatternUtils.isTactileFeedbackEnabled()); diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java index 36d5543f1c01..be21d203411e 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java @@ -39,6 +39,7 @@ import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.navigationbar.NavigationBarController; import com.android.systemui.navigationbar.NavigationBarView; +import com.android.systemui.util.InjectionInflationController; import javax.inject.Inject; @@ -48,6 +49,7 @@ public class KeyguardDisplayManager { private final MediaRouter mMediaRouter; private final DisplayManager mDisplayService; + private final InjectionInflationController mInjectableInflater; private final KeyguardStatusViewComponent.Factory mKeyguardStatusViewComponentFactory; private final Context mContext; @@ -90,8 +92,10 @@ public class KeyguardDisplayManager { @Inject public KeyguardDisplayManager(Context context, + InjectionInflationController injectableInflater, KeyguardStatusViewComponent.Factory keyguardStatusViewComponentFactory) { mContext = context; + mInjectableInflater = injectableInflater; mKeyguardStatusViewComponentFactory = keyguardStatusViewComponentFactory; mMediaRouter = mContext.getSystemService(MediaRouter.class); mDisplayService = mContext.getSystemService(DisplayManager.class); @@ -127,7 +131,8 @@ public class KeyguardDisplayManager { Presentation presentation = mPresentations.get(displayId); if (presentation == null) { final Presentation newPresentation = new KeyguardPresentation(mContext, display, - mKeyguardStatusViewComponentFactory, LayoutInflater.from(mContext)); + mKeyguardStatusViewComponentFactory, + mInjectableInflater.injectable(LayoutInflater.from(mContext))); newPresentation.setOnDismissListener(dialog -> { if (newPresentation.equals(mPresentations.get(displayId))) { mPresentations.remove(displayId); @@ -245,7 +250,7 @@ public class KeyguardDisplayManager { private static final int VIDEO_SAFE_REGION = 80; // Percentage of display width & height private static final int MOVE_CLOCK_TIMEOUT = 10000; // 10s private final KeyguardStatusViewComponent.Factory mKeyguardStatusViewComponentFactory; - private final LayoutInflater mLayoutInflater; + private final LayoutInflater mInjectableLayoutInflater; private KeyguardClockSwitchController mKeyguardClockSwitchController; private View mClock; private int mUsableWidth; @@ -265,10 +270,10 @@ public class KeyguardDisplayManager { KeyguardPresentation(Context context, Display display, KeyguardStatusViewComponent.Factory keyguardStatusViewComponentFactory, - LayoutInflater layoutInflater) { + LayoutInflater injectionLayoutInflater) { super(context, display, R.style.Theme_SystemUI_KeyguardPresentation); mKeyguardStatusViewComponentFactory = keyguardStatusViewComponentFactory; - mLayoutInflater = layoutInflater; + mInjectableLayoutInflater = injectionLayoutInflater; getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); setCancelable(false); } @@ -294,7 +299,7 @@ public class KeyguardDisplayManager { mMarginLeft = (100 - VIDEO_SAFE_REGION) * p.x / 200; mMarginTop = (100 - VIDEO_SAFE_REGION) * p.y / 200; - setContentView(mLayoutInflater.inflate(R.layout.keyguard_presentation, null)); + setContentView(mInjectableLayoutInflater.inflate(R.layout.keyguard_presentation, null)); // Logic to make the lock screen fullscreen getWindow().getDecorView().setSystemUiVisibility( diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java index 1a0a4370fca4..a8b1451d92c7 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java @@ -16,6 +16,8 @@ package com.android.keyguard; +import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT; + import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; @@ -29,14 +31,20 @@ import android.util.TypedValue; import android.view.View; import android.widget.TextView; +import com.android.systemui.Dependency; import com.android.systemui.R; +import com.android.systemui.statusbar.policy.ConfigurationController; import java.lang.ref.WeakReference; +import javax.inject.Inject; +import javax.inject.Named; + /*** * Manages a number of views inside of the given layout. See below for a list of widgets. */ -public class KeyguardMessageArea extends TextView implements SecurityMessageDisplay { +public class KeyguardMessageArea extends TextView implements SecurityMessageDisplay, + ConfigurationController.ConfigurationListener { /** Handler token posted with accessibility announcement runnables. */ private static final Object ANNOUNCE_TOKEN = new Object(); @@ -48,26 +56,71 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp private static final int DEFAULT_COLOR = -1; private final Handler mHandler; + private final ConfigurationController mConfigurationController; private ColorStateList mDefaultColorState; private CharSequence mMessage; private ColorStateList mNextMessageColorState = ColorStateList.valueOf(DEFAULT_COLOR); private boolean mBouncerVisible; - public KeyguardMessageArea(Context context, AttributeSet attrs) { + private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() { + public void onFinishedGoingToSleep(int why) { + setSelected(false); + } + + public void onStartedWakingUp() { + setSelected(true); + } + + @Override + public void onKeyguardBouncerChanged(boolean bouncer) { + mBouncerVisible = bouncer; + update(); + } + }; + + public KeyguardMessageArea(Context context) { + super(context, null); + throw new IllegalStateException("This constructor should never be invoked"); + } + + @Inject + public KeyguardMessageArea(@Named(VIEW_CONTEXT) Context context, AttributeSet attrs, + ConfigurationController configurationController) { + this(context, attrs, Dependency.get(KeyguardUpdateMonitor.class), configurationController); + } + + public KeyguardMessageArea(Context context, AttributeSet attrs, KeyguardUpdateMonitor monitor, + ConfigurationController configurationController) { super(context, attrs); setLayerType(LAYER_TYPE_HARDWARE, null); // work around nested unclipped SaveLayer bug + monitor.registerCallback(mInfoCallback); mHandler = new Handler(Looper.myLooper()); + mConfigurationController = configurationController; onThemeChanged(); } @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + mConfigurationController.addCallback(this); + onThemeChanged(); + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + mConfigurationController.removeCallback(this); + } + + @Override public void setNextMessageColor(ColorStateList colorState) { mNextMessageColorState = colorState; } - void onThemeChanged() { + @Override + public void onThemeChanged() { TypedArray array = mContext.obtainStyledAttributes(new int[] { R.attr.wallpaperTextColor }); @@ -77,7 +130,8 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp update(); } - void onDensityOrFontScaleChanged() { + @Override + public void onDensityOrFontScaleChanged() { TypedArray array = mContext.obtainStyledAttributes(R.style.Keyguard_TextView, new int[] { android.R.attr.textSize }); @@ -123,6 +177,12 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp return messageArea; } + @Override + protected void onFinishInflate() { + boolean shouldMarquee = Dependency.get(KeyguardUpdateMonitor.class).isDeviceInteractive(); + setSelected(shouldMarquee); // This is required to ensure marquee works + } + private void securityMessageChanged(CharSequence message) { mMessage = message; update(); @@ -136,7 +196,7 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp update(); } - void update() { + private void update() { CharSequence status = mMessage; setVisibility(TextUtils.isEmpty(status) || !mBouncerVisible ? INVISIBLE : VISIBLE); setText(status); @@ -148,9 +208,6 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp setTextColor(colorState); } - public void setBouncerVisible(boolean bouncerVisible) { - mBouncerVisible = bouncerVisible; - } /** * Runnable used to delay accessibility announcements. diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java index 1618e8e58055..78ac4e48501b 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java @@ -19,7 +19,6 @@ package com.android.keyguard; import android.content.res.ColorStateList; import com.android.systemui.statusbar.policy.ConfigurationController; -import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; import com.android.systemui.util.ViewController; import javax.inject.Inject; @@ -29,35 +28,6 @@ public class KeyguardMessageAreaController extends ViewController<KeyguardMessag private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final ConfigurationController mConfigurationController; - - private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() { - public void onFinishedGoingToSleep(int why) { - mView.setSelected(false); - } - - public void onStartedWakingUp() { - mView.setSelected(true); - } - - @Override - public void onKeyguardBouncerChanged(boolean bouncer) { - mView.setBouncerVisible(bouncer); - mView.update(); - } - }; - - private ConfigurationListener mConfigurationListener = new ConfigurationListener() { - @Override - public void onThemeChanged() { - mView.onThemeChanged(); - } - - @Override - public void onDensityOrFontScaleChanged() { - mView.onDensityOrFontScaleChanged(); - } - }; - private KeyguardMessageAreaController(KeyguardMessageArea view, KeyguardUpdateMonitor keyguardUpdateMonitor, ConfigurationController configurationController) { @@ -69,16 +39,10 @@ public class KeyguardMessageAreaController extends ViewController<KeyguardMessag @Override protected void onViewAttached() { - mConfigurationController.addCallback(mConfigurationListener); - mKeyguardUpdateMonitor.registerCallback(mInfoCallback); - mView.setSelected(mKeyguardUpdateMonitor.isDeviceInteractive()); - mView.onThemeChanged(); } @Override protected void onViewDetached() { - mConfigurationController.removeCallback(mConfigurationListener); - mKeyguardUpdateMonitor.removeCallback(mInfoCallback); } public void setMessage(CharSequence s) { diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java index 38b535049fb4..13a16360be04 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java @@ -191,12 +191,6 @@ public class KeyguardPatternViewController } @Override - public void init() { - super.init(); - mMessageAreaController.init(); - } - - @Override protected void onViewAttached() { mLockPatternView.setOnPatternListener(new UnlockPatternListener()); mLockPatternView.setSaveEnabled(false); diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java index 73adff94650a..806847579d61 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java @@ -26,6 +26,7 @@ import com.android.keyguard.KeyguardInputViewController.Factory; import com.android.keyguard.KeyguardSecurityModel.SecurityMode; import com.android.keyguard.dagger.KeyguardBouncerScope; import com.android.systemui.R; +import com.android.systemui.util.InjectionInflationController; import com.android.systemui.util.ViewController; import java.util.ArrayList; @@ -50,10 +51,11 @@ public class KeyguardSecurityViewFlipperController @Inject protected KeyguardSecurityViewFlipperController(KeyguardSecurityViewFlipper view, LayoutInflater layoutInflater, + InjectionInflationController injectionInflationController, KeyguardInputViewController.Factory keyguardSecurityViewControllerFactory) { super(view); mKeyguardSecurityViewControllerFactory = keyguardSecurityViewControllerFactory; - mLayoutInflater = layoutInflater; + mLayoutInflater = injectionInflationController.injectable(layoutInflater); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java b/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java index a6cd350b33ce..eb8f065149c8 100644 --- a/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java +++ b/packages/SystemUI/src/com/android/systemui/util/InjectionInflationController.java @@ -23,6 +23,7 @@ import android.view.InflateException; import android.view.LayoutInflater; import android.view.View; +import com.android.keyguard.KeyguardMessageArea; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.qs.QSFooterImpl; import com.android.systemui.qs.QSPanel; @@ -107,6 +108,11 @@ public class InjectionInflationController { NotificationStackScrollLayout createNotificationStackScrollLayout(); /** + * Creates the KeyguardMessageArea. + */ + KeyguardMessageArea createKeyguardMessageArea(); + + /** * Creates the QSPanel. */ QSPanel createQSPanel(); |