From e28295bb22dea8e76855f5273c1fee1a829225ad Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Thu, 6 May 2021 09:02:17 -0400 Subject: [PATCH 1/2] Cleanup support for multiple PIN views Had to support both old/new UX for PIN for a while. Cleanup the unneeded code and simply the ripple. Fixes: 187340770 Test: atest KeyguardPinBasedInputViewControllerTest and visual check Change-Id: Ie12cd93c7aaba5a3ef172792a5dd2a41f2196447 --- .../drawable/num_pad_key_background.xml | 17 ++----- .../keyguard/KeyguardInputViewController.java | 13 ++--- .../keyguard/KeyguardPinBasedInputView.java | 14 ------ .../keyguard/KeyguardPinViewController.java | 3 +- .../KeyguardSimPinViewController.java | 3 +- .../KeyguardSimPukViewController.java | 3 +- .../com/android/keyguard/NumPadAnimator.java | 14 ++---- .../com/android/keyguard/NumPadButton.java | 48 +++---------------- .../src/com/android/keyguard/NumPadKey.java | 37 +++----------- 9 files changed, 30 insertions(+), 122 deletions(-) diff --git a/packages/SystemUI/res-keyguard/drawable/num_pad_key_background.xml b/packages/SystemUI/res-keyguard/drawable/num_pad_key_background.xml index 604ab723da90c..3a7a8ae5bc3c4 100644 --- a/packages/SystemUI/res-keyguard/drawable/num_pad_key_background.xml +++ b/packages/SystemUI/res-keyguard/drawable/num_pad_key_background.xml @@ -16,23 +16,14 @@ * limitations under the License. */ --> - + - - - - - - - - - - - + diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java index 3d42da2e51584..97d3a5a4cd183 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java @@ -28,7 +28,6 @@ import com.android.keyguard.KeyguardSecurityModel.SecurityMode; import com.android.systemui.R; import com.android.systemui.classifier.FalsingCollector; import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.statusbar.FeatureFlags; import com.android.systemui.util.ViewController; import com.android.systemui.util.concurrency.DelayableExecutor; @@ -167,7 +166,6 @@ public abstract class KeyguardInputViewController private final TelephonyManager mTelephonyManager; private final EmergencyButtonController.Factory mEmergencyButtonControllerFactory; private final FalsingCollector mFalsingCollector; - private final boolean mIsNewLayoutEnabled; @Inject public Factory(KeyguardUpdateMonitor keyguardUpdateMonitor, @@ -177,8 +175,7 @@ public abstract class KeyguardInputViewController InputMethodManager inputMethodManager, @Main DelayableExecutor mainExecutor, @Main Resources resources, LiftToActivateListener liftToActivateListener, TelephonyManager telephonyManager, FalsingCollector falsingCollector, - EmergencyButtonController.Factory emergencyButtonControllerFactory, - FeatureFlags featureFlags) { + EmergencyButtonController.Factory emergencyButtonControllerFactory) { mKeyguardUpdateMonitor = keyguardUpdateMonitor; mLockPatternUtils = lockPatternUtils; mLatencyTracker = latencyTracker; @@ -190,7 +187,6 @@ public abstract class KeyguardInputViewController mTelephonyManager = telephonyManager; mEmergencyButtonControllerFactory = emergencyButtonControllerFactory; mFalsingCollector = falsingCollector; - mIsNewLayoutEnabled = featureFlags.isKeyguardLayoutEnabled(); } /** Create a new {@link KeyguardInputViewController}. */ @@ -216,20 +212,19 @@ public abstract class KeyguardInputViewController return new KeyguardPinViewController((KeyguardPINView) keyguardInputView, mKeyguardUpdateMonitor, securityMode, mLockPatternUtils, keyguardSecurityCallback, mMessageAreaControllerFactory, mLatencyTracker, - mLiftToActivateListener, emergencyButtonController, mFalsingCollector, - mIsNewLayoutEnabled); + mLiftToActivateListener, emergencyButtonController, mFalsingCollector); } else if (keyguardInputView instanceof KeyguardSimPinView) { return new KeyguardSimPinViewController((KeyguardSimPinView) keyguardInputView, mKeyguardUpdateMonitor, securityMode, mLockPatternUtils, keyguardSecurityCallback, mMessageAreaControllerFactory, mLatencyTracker, mLiftToActivateListener, mTelephonyManager, mFalsingCollector, - emergencyButtonController, mIsNewLayoutEnabled); + emergencyButtonController); } else if (keyguardInputView instanceof KeyguardSimPukView) { return new KeyguardSimPukViewController((KeyguardSimPukView) keyguardInputView, mKeyguardUpdateMonitor, securityMode, mLockPatternUtils, keyguardSecurityCallback, mMessageAreaControllerFactory, mLatencyTracker, mLiftToActivateListener, mTelephonyManager, mFalsingCollector, - emergencyButtonController, mIsNewLayoutEnabled); + emergencyButtonController); } throw new RuntimeException("Unable to find controller for " + keyguardInputView); diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java index 09fb8efba4e85..0b8868f6d3c48 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputView.java @@ -168,20 +168,6 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView return mButtons; } - /** - * By default, the new layout will be enabled. When false, revert to the old style. - */ - public void setIsNewLayoutEnabled(boolean isEnabled) { - if (!isEnabled) { - for (int i = 0; i < mButtons.length; i++) { - mButtons[i].disableNewLayout(); - } - mDeleteButton.disableNewLayout(); - mOkButton.disableNewLayout(); - reloadColors(); - } - } - /** * Reload colors from resources. **/ diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java index a456d42f5be59..262bed3f695c9 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinViewController.java @@ -35,12 +35,11 @@ public class KeyguardPinViewController KeyguardMessageAreaController.Factory messageAreaControllerFactory, LatencyTracker latencyTracker, LiftToActivateListener liftToActivateListener, EmergencyButtonController emergencyButtonController, - FalsingCollector falsingCollector, boolean isNewLayoutEnabled) { + FalsingCollector falsingCollector) { super(view, keyguardUpdateMonitor, securityMode, lockPatternUtils, keyguardSecurityCallback, messageAreaControllerFactory, latencyTracker, liftToActivateListener, emergencyButtonController, falsingCollector); mKeyguardUpdateMonitor = keyguardUpdateMonitor; - view.setIsNewLayoutEnabled(isNewLayoutEnabled); } @Override diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinViewController.java index fddbb3cdfc845..e04bfdc3868d3 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinViewController.java @@ -79,14 +79,13 @@ public class KeyguardSimPinViewController KeyguardMessageAreaController.Factory messageAreaControllerFactory, LatencyTracker latencyTracker, LiftToActivateListener liftToActivateListener, TelephonyManager telephonyManager, FalsingCollector falsingCollector, - EmergencyButtonController emergencyButtonController, boolean isNewLayoutEnabled) { + EmergencyButtonController emergencyButtonController) { super(view, keyguardUpdateMonitor, securityMode, lockPatternUtils, keyguardSecurityCallback, messageAreaControllerFactory, latencyTracker, liftToActivateListener, emergencyButtonController, falsingCollector); mKeyguardUpdateMonitor = keyguardUpdateMonitor; mTelephonyManager = telephonyManager; mSimImageView = mView.findViewById(R.id.keyguard_sim); - view.setIsNewLayoutEnabled(isNewLayoutEnabled); } @Override diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukViewController.java index 50bd0c71752b6..07309224608e6 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukViewController.java @@ -85,14 +85,13 @@ public class KeyguardSimPukViewController KeyguardMessageAreaController.Factory messageAreaControllerFactory, LatencyTracker latencyTracker, LiftToActivateListener liftToActivateListener, TelephonyManager telephonyManager, FalsingCollector falsingCollector, - EmergencyButtonController emergencyButtonController, boolean isNewLayoutEnabled) { + EmergencyButtonController emergencyButtonController) { super(view, keyguardUpdateMonitor, securityMode, lockPatternUtils, keyguardSecurityCallback, messageAreaControllerFactory, latencyTracker, liftToActivateListener, emergencyButtonController, falsingCollector); mKeyguardUpdateMonitor = keyguardUpdateMonitor; mTelephonyManager = telephonyManager; mSimImageView = mView.findViewById(R.id.keyguard_sim); - view.setIsNewLayoutEnabled(isNewLayoutEnabled); } @Override diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java b/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java index abdd770c37d4a..e6298a426c5be 100644 --- a/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java +++ b/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java @@ -21,7 +21,6 @@ import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.graphics.drawable.GradientDrawable; -import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.RippleDrawable; import android.view.ContextThemeWrapper; @@ -40,17 +39,14 @@ class NumPadAnimator { private ValueAnimator mContractAnimator; private GradientDrawable mBackground; private RippleDrawable mRipple; - private GradientDrawable mRippleMask; private int mNormalColor; private int mHighlightColor; private int mStyle; - NumPadAnimator(Context context, LayerDrawable drawable, @StyleRes int style) { - LayerDrawable ld = (LayerDrawable) drawable.mutate(); - mBackground = (GradientDrawable) ld.findDrawableByLayerId(R.id.background); - mRipple = (RippleDrawable) ld.findDrawableByLayerId(R.id.ripple); - mRippleMask = (GradientDrawable) mRipple.findDrawableByLayerId(android.R.id.mask); + NumPadAnimator(Context context, final RippleDrawable drawable, @StyleRes int style) { mStyle = style; + mRipple = (RippleDrawable) drawable.mutate(); + mBackground = (GradientDrawable) mRipple.findDrawableByLayerId(R.id.background); reloadColors(context); @@ -62,7 +58,7 @@ class NumPadAnimator { mExpandAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator anim) { mBackground.setCornerRadius((float) anim.getAnimatedValue()); - mRippleMask.setCornerRadius((float) anim.getAnimatedValue()); + mRipple.invalidateSelf(); } }); @@ -73,7 +69,7 @@ class NumPadAnimator { mContractAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator anim) { mBackground.setCornerRadius((float) anim.getAnimatedValue()); - mRippleMask.setCornerRadius((float) anim.getAnimatedValue()); + mRipple.invalidateSelf(); } }); mAnimator.playSequentially(mExpandAnimator, mContractAnimator); diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadButton.java b/packages/SystemUI/src/com/android/keyguard/NumPadButton.java index b76499a39ff8f..096597afa8891 100644 --- a/packages/SystemUI/src/com/android/keyguard/NumPadButton.java +++ b/packages/SystemUI/src/com/android/keyguard/NumPadButton.java @@ -16,37 +16,22 @@ package com.android.keyguard; import android.content.Context; -import android.content.res.ColorStateList; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.LayerDrawable; -import android.graphics.drawable.VectorDrawable; +import android.graphics.drawable.RippleDrawable; import android.util.AttributeSet; -import android.view.ContextThemeWrapper; import android.view.MotionEvent; -import androidx.annotation.Nullable; - -import com.android.settingslib.Utils; -import com.android.systemui.R; - /** * Similar to the {@link NumPadKey}, but displays an image. */ public class NumPadButton extends AlphaOptimizedImageButton { - @Nullable private NumPadAnimator mAnimator; public NumPadButton(Context context, AttributeSet attrs) { super(context, attrs); - Drawable background = getBackground(); - if (background instanceof LayerDrawable) { - mAnimator = new NumPadAnimator(context, (LayerDrawable) background, - attrs.getStyleAttribute()); - } else { - mAnimator = null; - } + mAnimator = new NumPadAnimator(context, (RippleDrawable) getBackground(), + attrs.getStyleAttribute()); } @Override @@ -56,7 +41,7 @@ public class NumPadButton extends AlphaOptimizedImageButton { // Set width/height to the same value to ensure a smooth circle for the bg, but shrink // the height to match the old pin bouncer int width = getMeasuredWidth(); - int height = mAnimator == null ? (int) (width * .75f) : width; + int height = width; setMeasuredDimension(getMeasuredWidth(), height); } @@ -65,13 +50,13 @@ public class NumPadButton extends AlphaOptimizedImageButton { protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); - if (mAnimator != null) mAnimator.onLayout(b - t); + mAnimator.onLayout(b - t); } @Override public boolean onTouchEvent(MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { - if (mAnimator != null) mAnimator.start(); + mAnimator.start(); } return super.onTouchEvent(event); } @@ -80,25 +65,6 @@ public class NumPadButton extends AlphaOptimizedImageButton { * Reload colors from resources. **/ public void reloadColors() { - if (mAnimator != null) { - mAnimator.reloadColors(getContext()); - } else { - // Needed for old style pin - int textColor = Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary) - .getDefaultColor(); - ((VectorDrawable) getDrawable()).setTintList(ColorStateList.valueOf(textColor)); - } - } - - /** - * By default, the new layout will be enabled. Invoking will revert to the old style - */ - public void disableNewLayout() { - if (mAnimator != null) { - mAnimator = null; - ContextThemeWrapper ctw = new ContextThemeWrapper(getContext(), R.style.NumPadKey); - setBackground(getContext().getResources().getDrawable( - R.drawable.ripple_drawable_pin, ctw.getTheme())); - } + mAnimator.reloadColors(getContext()); } } diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadKey.java b/packages/SystemUI/src/com/android/keyguard/NumPadKey.java index 89c1a7fe21caf..35ace0d1a4044 100644 --- a/packages/SystemUI/src/com/android/keyguard/NumPadKey.java +++ b/packages/SystemUI/src/com/android/keyguard/NumPadKey.java @@ -18,12 +18,10 @@ package com.android.keyguard; import android.content.Context; import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.LayerDrawable; +import android.graphics.drawable.RippleDrawable; import android.os.PowerManager; import android.os.SystemClock; import android.util.AttributeSet; -import android.view.ContextThemeWrapper; import android.view.HapticFeedbackConstants; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -32,8 +30,6 @@ import android.view.ViewGroup; import android.view.accessibility.AccessibilityManager; import android.widget.TextView; -import androidx.annotation.Nullable; - import com.android.internal.widget.LockPatternUtils; import com.android.settingslib.Utils; import com.android.systemui.R; @@ -51,7 +47,6 @@ public class NumPadKey extends ViewGroup { private int mTextViewResId; private PasswordTextView mTextView; - @Nullable private NumPadAnimator mAnimator; private View.OnClickListener mListener = new View.OnClickListener() { @@ -131,26 +126,8 @@ public class NumPadKey extends ViewGroup { setContentDescription(mDigitText.getText().toString()); - Drawable background = getBackground(); - if (background instanceof LayerDrawable) { - mAnimator = new NumPadAnimator(context, (LayerDrawable) background, - R.style.NumPadKey); - } else { - mAnimator = null; - } - } - - /** - * By default, the new layout will be enabled. Invoking will revert to the old style - */ - public void disableNewLayout() { - findViewById(R.id.klondike_text).setVisibility(View.VISIBLE); - if (mAnimator != null) { - mAnimator = null; - ContextThemeWrapper ctw = new ContextThemeWrapper(getContext(), R.style.NumPadKey); - setBackground(getContext().getResources().getDrawable( - R.drawable.ripple_drawable_pin, ctw.getTheme())); - } + mAnimator = new NumPadAnimator(context, (RippleDrawable) getBackground(), + R.style.NumPadKey); } /** @@ -164,14 +141,14 @@ public class NumPadKey extends ViewGroup { mDigitText.setTextColor(textColor); mKlondikeText.setTextColor(klondikeColor); - if (mAnimator != null) mAnimator.reloadColors(getContext()); + mAnimator.reloadColors(getContext()); } @Override public boolean onTouchEvent(MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { doHapticKeyClick(); - if (mAnimator != null) mAnimator.start(); + mAnimator.start(); } return super.onTouchEvent(event); @@ -185,7 +162,7 @@ public class NumPadKey extends ViewGroup { // Set width/height to the same value to ensure a smooth circle for the bg, but shrink // the height to match the old pin bouncer int width = getMeasuredWidth(); - int height = mAnimator == null ? (int) (width * .75f) : width; + int height = width; setMeasuredDimension(getMeasuredWidth(), height); } @@ -206,7 +183,7 @@ public class NumPadKey extends ViewGroup { left = centerX - mKlondikeText.getMeasuredWidth() / 2; mKlondikeText.layout(left, top, left + mKlondikeText.getMeasuredWidth(), bottom); - if (mAnimator != null) mAnimator.onLayout(b - t); + mAnimator.onLayout(b - t); } @Override From bf934d220197b3307ab6f20688e443448f6b2277 Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Fri, 7 May 2021 08:24:01 -0400 Subject: [PATCH 2/2] Smartspace - Next alarm Support next alarm appearing next to DnD. If weather is showing, show inline, otherwise below the smartspace content. Next alarm will not fade out but DnD will. Fixes: 185678563 Test: atest KeyguardZenAlarmViewControllerTest Change-Id: I21e95470d0013bfb6900c1c228dda69f5707c9e6 --- .../systemui/plugins/BcSmartspaceDataPlugin.java | 11 ++++++++--- .../keyguard/KeyguardClockSwitchControllerTest.java | 6 ++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java b/packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java index 69ce2754ca43b..32def0309aaa1 100644 --- a/packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java +++ b/packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java @@ -20,7 +20,7 @@ import android.app.PendingIntent; import android.app.smartspace.SmartspaceAction; import android.app.smartspace.SmartspaceTarget; import android.content.Intent; -import android.graphics.drawable.Icon; +import android.graphics.drawable.Drawable; import android.os.Parcelable; import android.view.View; import android.view.ViewGroup; @@ -93,9 +93,14 @@ public interface BcSmartspaceDataPlugin extends Plugin { void setFalsingManager(com.android.systemui.plugins.FalsingManager falsingManager); /** - * Set or clear any Do Not Disturb information. + * Set or clear Do Not Disturb information. */ - void setDnd(@Nullable Icon dndIcon, @Nullable String description); + void setDnd(@Nullable Drawable image, @Nullable String description); + + /** + * Set or clear next alarm information + */ + void setNextAlarm(@Nullable Drawable image, @Nullable String description); } /** Interface for launching Intents, which can differ on the lockscreen */ diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java index 495489f1ab6ed..8c5f74dc7c93f 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java @@ -32,7 +32,7 @@ import android.app.smartspace.SmartspaceTarget; import android.content.Context; import android.content.pm.UserInfo; import android.content.res.Resources; -import android.graphics.drawable.Icon; +import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.UserHandle; import android.test.suitebuilder.annotation.SmallTest; @@ -394,6 +394,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { public void setFalsingManager(FalsingManager falsingManager) { } - public void setDnd(@Nullable Icon dndIcon, @Nullable String description) { } + public void setDnd(@Nullable Drawable dndIcon, @Nullable String description) { } + + public void setNextAlarm(@Nullable Drawable dndIcon, @Nullable String description) { } } }