AmbientIndication: Move into container
This allows fixing the following bugs:
- ambient indication should be hidden outside keyguard
- ambient indication should animate with the unlock hint
- ambient indication should fade out when unlocking
Fixes: 38289189
Test: observe that the things above are working correctly
Change-Id: I34aff69bb5621a3f12c25e87eac6a89c8c7e2165
diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml
index 8db00b0..07a9a60 100644
--- a/packages/SystemUI/res/layout/status_bar_expanded.xml
+++ b/packages/SystemUI/res/layout/status_bar_expanded.xml
@@ -56,7 +56,8 @@
android:layout_gravity="@integer/notification_panel_layout_gravity"
android:layout_marginBottom="@dimen/close_handle_underlap" />
- <include layout="@layout/ambient_indication" />
+ <include layout="@layout/ambient_indication"
+ android:id="@+id/ambient_indication_container" />
<ViewStub
android:id="@+id/keyguard_user_switcher"
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 8fe3096..3dc6827 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -1672,6 +1672,10 @@
mKeyguardBottomArea.setImportantForAccessibility(alpha == 0f
? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
: IMPORTANT_FOR_ACCESSIBILITY_AUTO);
+ View ambientIndicationContainer = mStatusBar.getAmbientIndicationContainer();
+ if (ambientIndicationContainer != null) {
+ ambientIndicationContainer.setAlpha(alpha);
+ }
}
private float getNotificationsTopY() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 4b1d7d7..9cb4488 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -28,6 +28,7 @@
import android.util.Log;
import android.view.InputDevice;
import android.view.MotionEvent;
+import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewTreeObserver;
import android.view.animation.Interpolator;
@@ -1071,21 +1072,25 @@
});
animator.start();
mHeightAnimator = animator;
- mKeyguardBottomArea.getIndicationArea().animate()
- .translationY(-mHintDistance)
- .setDuration(250)
- .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
- .withEndAction(new Runnable() {
- @Override
- public void run() {
- mKeyguardBottomArea.getIndicationArea().animate()
- .translationY(0)
- .setDuration(450)
- .setInterpolator(mBounceInterpolator)
- .start();
- }
- })
- .start();
+
+ View[] viewsToAnimate = {
+ mKeyguardBottomArea.getIndicationArea(),
+ mStatusBar.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();
+ }
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 923993a..ae8f46f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -36,6 +36,7 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManager.StackId;
import android.app.ActivityOptions;
@@ -730,6 +731,7 @@
private boolean mReinflateNotificationsOnUserSwitched;
private HashMap<String, Entry> mPendingNotifications = new HashMap<>();
private boolean mClearAllEnabled;
+ @Nullable private View mAmbientIndicationContainer;
private void recycleAllVisibilityObjects(ArraySet<NotificationVisibility> array) {
final int N = array.size();
@@ -1081,6 +1083,9 @@
mKeyguardBottomArea.getLockIcon());
mKeyguardBottomArea.setKeyguardIndicationController(mKeyguardIndicationController);
+ mAmbientIndicationContainer = mStatusBarWindow.findViewById(
+ R.id.ambient_indication_container);
+
// set the initial view visibility
setAreThereNotifications();
@@ -2785,6 +2790,11 @@
return mKeyguardIndicationController;
}
+ @Nullable
+ public View getAmbientIndicationContainer() {
+ return mAmbientIndicationContainer;
+ }
+
/**
* All changes to the status bar and notifications funnel through here and are batched.
*/
@@ -4393,6 +4403,9 @@
mKeyguardUserSwitcher.setKeyguard(true, fromShadeLocked);
}
mStatusBarView.removePendingHideExpandedRunnables();
+ if (mAmbientIndicationContainer != null) {
+ mAmbientIndicationContainer.setVisibility(View.VISIBLE);
+ }
} else {
mKeyguardIndicationController.setVisible(false);
if (mKeyguardUserSwitcher != null) {
@@ -4401,6 +4414,9 @@
mState == StatusBarState.SHADE_LOCKED ||
fromShadeLocked);
}
+ if (mAmbientIndicationContainer != null) {
+ mAmbientIndicationContainer.setVisibility(View.INVISIBLE);
+ }
}
if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) {
mScrimController.setKeyguardShowing(true);