diff options
author | Scott Lobdell <slobdell@google.com> | 2020-11-05 18:29:12 -0800 |
---|---|---|
committer | Scott Lobdell <slobdell@google.com> | 2020-11-13 11:48:49 -0800 |
commit | 3933f277a025be704e68ea593536e492831a7e05 (patch) | |
tree | 084aa5e0858c449a63dd18cc57fb21ab054d363a /packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java | |
parent | 248a6ce2e2ee65f367b01c43edeecef5a6d57581 (diff) | |
parent | 9c74513b2d828d5169e9942b58b2f93bb3e04aff (diff) |
Merge SP1A.201105.002
Change-Id: Iec83a0c1f6f286a1e51abfc4356633ca9d8aea5f
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java')
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java | 112 |
1 files changed, 58 insertions, 54 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java index 2470b958a85f..02b18b28a5ea 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java @@ -42,8 +42,12 @@ import com.android.systemui.Dumpable; import com.android.systemui.dump.DumpManager; import com.android.systemui.keyguard.KeyguardSliceProvider; import com.android.systemui.plugins.ActivityStarter; +import com.android.systemui.statusbar.notification.AnimatableProperty; +import com.android.systemui.statusbar.notification.PropertyAnimator; +import com.android.systemui.statusbar.notification.stack.AnimationProperties; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.tuner.TunerService; +import com.android.systemui.util.ViewController; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -55,11 +59,10 @@ import javax.inject.Inject; /** Controller for a {@link KeyguardSliceView}. */ @KeyguardStatusViewScope -public class KeyguardSliceViewController implements Dumpable { +public class KeyguardSliceViewController extends ViewController<KeyguardSliceView> implements + Dumpable { private static final String TAG = "KeyguardSliceViewCtrl"; - private final KeyguardSliceView mView; - private final KeyguardStatusView mKeyguardStatusView; private final ActivityStarter mActivityStarter; private final ConfigurationController mConfigurationController; private final TunerService mTunerService; @@ -69,41 +72,7 @@ public class KeyguardSliceViewController implements Dumpable { private Uri mKeyguardSliceUri; private Slice mSlice; private Map<View, PendingIntent> mClickActions; - - private final View.OnAttachStateChangeListener mOnAttachStateChangeListener = - new View.OnAttachStateChangeListener() { - - @Override - public void onViewAttachedToWindow(View v) { - - Display display = mView.getDisplay(); - if (display != null) { - mDisplayId = display.getDisplayId(); - } - mTunerService.addTunable(mTunable, Settings.Secure.KEYGUARD_SLICE_URI); - // Make sure we always have the most current slice - if (mDisplayId == DEFAULT_DISPLAY && mLiveData != null) { - mLiveData.observeForever(mObserver); - } - mConfigurationController.addCallback(mConfigurationListener); - mDumpManager.registerDumpable( - TAG + "@" + Integer.toHexString( - KeyguardSliceViewController.this.hashCode()), - KeyguardSliceViewController.this); - } - - @Override - public void onViewDetachedFromWindow(View v) { - - // TODO(b/117344873) Remove below work around after this issue be fixed. - if (mDisplayId == DEFAULT_DISPLAY) { - mLiveData.removeObserver(mObserver); - } - mTunerService.removeTunable(mTunable); - mConfigurationController.removeCallback(mConfigurationListener); - mDumpManager.unregisterDumpable(TAG); - } - }; + private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL; TunerService.Tunable mTunable = (key, newValue) -> setupUri(newValue); @@ -134,27 +103,57 @@ public class KeyguardSliceViewController implements Dumpable { }; @Inject - public KeyguardSliceViewController(KeyguardSliceView keyguardSliceView, - KeyguardStatusView keyguardStatusView, ActivityStarter activityStarter, - ConfigurationController configurationController, TunerService tunerService, + public KeyguardSliceViewController( + KeyguardSliceView keyguardSliceView, + ActivityStarter activityStarter, + ConfigurationController configurationController, + TunerService tunerService, DumpManager dumpManager) { - mView = keyguardSliceView; - mKeyguardStatusView = keyguardStatusView; + super(keyguardSliceView); mActivityStarter = activityStarter; mConfigurationController = configurationController; mTunerService = tunerService; mDumpManager = dumpManager; } - /** Initialize the controller. */ - public void init() { - if (mView.isAttachedToWindow()) { - mOnAttachStateChangeListener.onViewAttachedToWindow(mView); + @Override + protected void onViewAttached() { + Display display = mView.getDisplay(); + if (display != null) { + mDisplayId = display.getDisplayId(); + } + mTunerService.addTunable(mTunable, Settings.Secure.KEYGUARD_SLICE_URI); + // Make sure we always have the most current slice + if (mDisplayId == DEFAULT_DISPLAY && mLiveData != null) { + mLiveData.observeForever(mObserver); + } + mConfigurationController.addCallback(mConfigurationListener); + mDumpManager.registerDumpable( + TAG + "@" + Integer.toHexString( + KeyguardSliceViewController.this.hashCode()), + KeyguardSliceViewController.this); + mView.updateLockScreenMode(mLockScreenMode); + } + + @Override + protected void onViewDetached() { + // TODO(b/117344873) Remove below work around after this issue be fixed. + if (mDisplayId == DEFAULT_DISPLAY) { + mLiveData.removeObserver(mObserver); } - mView.addOnAttachStateChangeListener(mOnAttachStateChangeListener); - mView.setOnClickListener(mOnClickListener); - // TODO: remove the line below. - mKeyguardStatusView.setKeyguardSliceViewController(this); + mTunerService.removeTunable(mTunable); + mConfigurationController.removeCallback(mConfigurationListener); + mDumpManager.unregisterDumpable( + TAG + "@" + Integer.toHexString( + KeyguardSliceViewController.this.hashCode())); + } + + /** + * Updates the lockscreen mode which may change the layout of the keyguard slice view. + */ + public void updateLockScreenMode(int mode) { + mLockScreenMode = mode; + mView.updateLockScreenMode(mLockScreenMode); } /** @@ -203,6 +202,13 @@ public class KeyguardSliceViewController implements Dumpable { Trace.endSection(); } + /** + * Update position of the view, with optional animation + */ + void updatePosition(int x, AnimationProperties props, boolean animate) { + PropertyAnimator.setProperty(mView, AnimatableProperty.TRANSLATION_X, x, props, animate); + } + void showSlice(Slice slice) { Trace.beginSection("KeyguardSliceViewController#showSlice"); if (slice == null) { @@ -228,12 +234,10 @@ public class KeyguardSliceViewController implements Dumpable { Trace.endSection(); } - @Override public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) { pw.println(" mSlice: " + mSlice); pw.println(" mClickActions: " + mClickActions); - - mKeyguardStatusView.dump(fd, pw, args); + pw.println(" mLockScreenMode: " + mLockScreenMode); } } |