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
This commit is contained in:
Alejandro Nijamkin
2022-07-12 17:25:11 -07:00
parent 93afb088f3
commit c3e3320e50
5 changed files with 41 additions and 31 deletions

View File

@@ -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

View File

@@ -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}

View File

@@ -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<ViewPropertyAnimator> getIndicationAreaAnimators() {
List<ViewPropertyAnimator> 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);

View File

@@ -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);
}

View File

@@ -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<ViewPropertyAnimator> 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();
}
}