From c3e3320e50747aaddc41803b057a923794e1b329 Mon Sep 17 00:00:00 2001 From: Alejandro Nijamkin Date: Tue, 12 Jul 2022 17:25:11 -0700 Subject: [PATCH] KeygaurdBottomArea additional API cleanup * Moves alpha setting of the ambient indication area into KBAV, as it already manages alpha for other child views * Removes the need to get the ambient indication area from CentralSurfaces * Cleans up overly poweful getter that gets the indication area from KBAV to only return a weaker object: an animator, one per each of the two indication areas Bug: 235403546 Test: manually verified that the bottom buttons and "which song is playing?" area show, hide, and animate appropriately. Change-Id: I47760e3d400e01bfb6b1fa1cdaa6ae6dcd5ea521 --- .../statusbar/phone/CentralSurfaces.java | 3 -- .../statusbar/phone/CentralSurfacesImpl.java | 6 ---- .../phone/KeyguardBottomAreaView.java | 29 ++++++++++++++++--- .../NotificationPanelViewController.java | 9 +----- .../statusbar/phone/PanelViewController.java | 25 +++++++++------- 5 files changed, 41 insertions(+), 31 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java index d25bbbd2a591f..c669057ffb95c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java @@ -265,9 +265,6 @@ public interface CentralSurfaces extends Dumpable, ActivityStarter, LifecycleOwn boolean isPulsing(); - @Nullable - View getAmbientIndicationContainer(); - boolean isOccluded(); //TODO: These can / should probably be moved to NotificationPresenter or ShadeController diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 6258deda804f8..b4383ba170701 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -1888,12 +1888,6 @@ public class CentralSurfacesImpl extends CoreStartable implements return mDozeServiceHost.isPulsing(); } - @androidx.annotation.Nullable - @Override - public View getAmbientIndicationContainer() { - return mAmbientIndicationContainer; - } - /** * When the keyguard is showing and covered by a "showWhenLocked" activity it * is occluded. This is controlled by {@link com.android.server.policy.PhoneWindowManager} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index a6fcde3be2a89..43a5451f4bb6e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -39,6 +39,7 @@ import android.util.Log; import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; +import android.view.ViewPropertyAnimator; import android.view.WindowInsets; import android.widget.FrameLayout; import android.widget.ImageView; @@ -62,6 +63,9 @@ import com.android.systemui.qrcodescanner.controller.QRCodeScannerController; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.wallet.controller.QuickAccessWalletController; +import java.util.ArrayList; +import java.util.List; + /** * Implementation for the bottom area of the Keyguard, including camera/phone affordance and status * text. @@ -347,8 +351,17 @@ public class KeyguardBottomAreaView extends FrameLayout { dozeTimeTick(); } - public View getIndicationArea() { - return mIndicationArea; + /** + * Returns a list of animators to use to animate the indication areas. + */ + public List getIndicationAreaAnimators() { + List animators = + new ArrayList<>(mAmbientIndicationArea != null ? 2 : 1); + animators.add(mIndicationArea.animate()); + if (mAmbientIndicationArea != null) { + animators.add(mAmbientIndicationArea.animate()); + } + return animators; } @Override @@ -418,9 +431,17 @@ public class KeyguardBottomAreaView extends FrameLayout { } /** - * Sets the alpha of the indication areas and affordances, excluding the lock icon. + * Sets the alpha of various sub-components, for example the indication areas and bottom quick + * action buttons. Does not set the alpha of the lock icon. */ - public void setAffordanceAlpha(float alpha) { + public void setComponentAlphas(float alpha) { + setImportantForAccessibility( + alpha == 0f + ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS + : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); + if (mAmbientIndicationArea != null) { + mAmbientIndicationArea.setAlpha(alpha); + } mIndicationArea.setAlpha(alpha); mWalletButton.setAlpha(alpha); mQRCodeScannerButton.setAlpha(alpha); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index b257d14dc4d55..91b1673485ba1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -3194,14 +3194,7 @@ public final class NotificationPanelViewController extends PanelViewController { getExpandedFraction()); float alpha = Math.min(expansionAlpha, 1 - computeQsExpansionFraction()); alpha *= mBottomAreaShadeAlpha; - mKeyguardBottomArea.setAffordanceAlpha(alpha); - mKeyguardBottomArea.setImportantForAccessibility( - alpha == 0f ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS - : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); - View ambientIndicationContainer = mCentralSurfaces.getAmbientIndicationContainer(); - if (ambientIndicationContainer != null) { - ambientIndicationContainer.setAlpha(alpha); - } + mKeyguardBottomArea.setComponentAlphas(alpha); mLockIconViewController.setAlpha(alpha); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java index d2fc1af010b93..d31e6afe3264f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java @@ -41,6 +41,7 @@ import android.view.VelocityTracker; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; +import android.view.ViewPropertyAnimator; import android.view.ViewTreeObserver; import android.view.animation.Interpolator; @@ -66,6 +67,7 @@ import com.android.systemui.util.time.SystemClock; import com.android.wm.shell.animation.FlingAnimationUtils; import java.io.PrintWriter; +import java.util.List; public abstract class PanelViewController { public static final boolean DEBUG = PanelView.DEBUG; @@ -1034,16 +1036,19 @@ public abstract class PanelViewController { animator.start(); setAnimator(animator); - View[] viewsToAnimate = { - mKeyguardBottomArea.getIndicationArea(), - mCentralSurfaces.getAmbientIndicationContainer()}; - for (View v : viewsToAnimate) { - if (v == null) { - continue; - } - v.animate().translationY(-mHintDistance).setDuration(250).setInterpolator( - Interpolators.FAST_OUT_SLOW_IN).withEndAction(() -> v.animate().translationY( - 0).setDuration(450).setInterpolator(mBounceInterpolator).start()).start(); + final List indicationAnimators = + mKeyguardBottomArea.getIndicationAreaAnimators(); + for (final ViewPropertyAnimator indicationAreaAnimator : indicationAnimators) { + indicationAreaAnimator + .translationY(-mHintDistance) + .setDuration(250) + .setInterpolator(Interpolators.FAST_OUT_SLOW_IN) + .withEndAction(() -> indicationAreaAnimator + .translationY(0) + .setDuration(450) + .setInterpolator(mBounceInterpolator) + .start()) + .start(); } }