Skip to content

Commit 0fccc72

Browse files
author
Selim Cinek
committed
The heads up now correctly dissapears when clicking
Bug: 22729955 Change-Id: I977b36823bf936baab527f932b1e5576241f4d71
1 parent 26ae600 commit 0fccc72

7 files changed

Lines changed: 41 additions & 2 deletions

File tree

packages/SystemUI/res/values/ids.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@
4949

5050
<!-- For notification icons for which targetSdk < L, this caches whether the icon is grayscale -->
5151
<item type="id" name="icon_is_grayscale" />
52+
<item type="id" name="is_clicked_heads_up_tag" />
5253
</resources>
5354

packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,7 @@ public boolean onDismiss() {
15251525
//
15261526
// In most cases, when FLAG_AUTO_CANCEL is set, the notification will
15271527
// become canceled shortly by NoMan, but we can't assume that.
1528+
HeadsUpManager.setIsClickedNotification(row, true);
15281529
mHeadsUpManager.releaseImmediately(notificationKey);
15291530
}
15301531
new Thread() {

packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import android.view.MotionEvent;
3333
import android.view.VelocityTracker;
3434
import android.view.View;
35-
import android.view.ViewRootImpl;
3635
import android.view.ViewTreeObserver;
3736
import android.view.WindowInsets;
3837
import android.view.accessibility.AccessibilityEvent;
@@ -203,10 +202,12 @@ public class NotificationPanelView extends PanelView implements
203202
private int mPositionMinSideMargin;
204203
private int mLastOrientation = -1;
205204
private boolean mClosingWithAlphaFadeOut;
205+
private boolean mHeadsUpAnimatingAway;
206206

207207
private Runnable mHeadsUpExistenceChangedRunnable = new Runnable() {
208208
@Override
209209
public void run() {
210+
mHeadsUpAnimatingAway = false;
210211
notifyBarPanelExpansionChanged();
211212
}
212213
};
@@ -2292,6 +2293,7 @@ public void onHeadsUpPinnedModeChanged(final boolean inPinnedMode) {
22922293
mHeadsUpExistenceChangedRunnable.run();
22932294
updateNotificationTranslucency();
22942295
} else {
2296+
mHeadsUpAnimatingAway = true;
22952297
mNotificationStackScroller.runAfterAnimationFinished(
22962298
mHeadsUpExistenceChangedRunnable);
22972299
}
@@ -2382,4 +2384,8 @@ public void setPanelScrimMinFraction(float minFraction) {
23822384
public void clearNotificattonEffects() {
23832385
mStatusBar.clearNotificationEffects();
23842386
}
2387+
2388+
protected boolean isPanelVisibleBecauseOfHeadsUp() {
2389+
return mHeadsUpManager.hasPinnedHeadsUp() || mHeadsUpAnimatingAway;
2390+
}
23852391
}

packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,10 +1009,12 @@ public void onAnimationUpdate(ValueAnimator animation) {
10091009

10101010
protected void notifyBarPanelExpansionChanged() {
10111011
mBar.panelExpansionChanged(this, mExpandedFraction, mExpandedFraction > 0f || mPeekPending
1012-
|| mPeekAnimator != null || mInstantExpanding || mHeadsUpManager.hasPinnedHeadsUp()
1012+
|| mPeekAnimator != null || mInstantExpanding || isPanelVisibleBecauseOfHeadsUp()
10131013
|| mTracking || mHeightAnimator != null);
10141014
}
10151015

1016+
protected abstract boolean isPanelVisibleBecauseOfHeadsUp();
1017+
10161018
/**
10171019
* Gets called when the user performs a click anywhere in the empty area of the panel.
10181020
*

packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL
5151
private static final String TAG = "HeadsUpManager";
5252
private static final boolean DEBUG = false;
5353
private static final String SETTING_HEADS_UP_SNOOZE_LENGTH_MS = "heads_up_snooze_length_ms";
54+
private static final int TAG_CLICKED_NOTIFICATION = R.id.is_clicked_heads_up_tag;
5455

5556
private final int mHeadsUpNotificationDecay;
5657
private final int mMinimumDisplayTime;
@@ -526,6 +527,15 @@ public void onLayoutChange(View v, int left, int top, int right, int bottom,
526527
});
527528
}
528529

530+
public static void setIsClickedNotification(View child, boolean clicked) {
531+
child.setTag(TAG_CLICKED_NOTIFICATION, clicked ? true : null);
532+
}
533+
534+
public static boolean isClickedHeadsUpNotification(View child) {
535+
Boolean clicked = (Boolean) child.getTag(TAG_CLICKED_NOTIFICATION);
536+
return clicked != null && clicked;
537+
}
538+
529539
/**
530540
* This represents a notification and how long it is in a heads up mode. It also manages its
531541
* lifecycle automatically when created.

packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public boolean onPreDraw() {
222222
private int[] mTempInt2 = new int[2];
223223
private boolean mGenerateChildOrderChangedEvent;
224224
private HashSet<Runnable> mAnimationFinishedRunnables = new HashSet<>();
225+
private HashSet<View> mClearOverlayViewsWhenFinished = new HashSet<>();
225226
private HashSet<Pair<ExpandableNotificationRow, Boolean>> mHeadsUpChangeAnimations
226227
= new HashSet<>();
227228
private HeadsUpManager mHeadsUpManager;
@@ -1656,6 +1657,11 @@ private boolean generateRemoveAnimation(View child) {
16561657
mAddedHeadsUpChildren.remove(child);
16571658
return false;
16581659
}
1660+
if (isClickedHeadsUp(child)) {
1661+
// An animation is already running, add it to the Overlay
1662+
mClearOverlayViewsWhenFinished.add(child);
1663+
return true;
1664+
}
16591665
if (mIsExpanded && mAnimationsEnabled && !isChildInInvisibleGroup(child)) {
16601666
if (!mChildrenToAddAnimated.contains(child)) {
16611667
// Generate Animations
@@ -1671,6 +1677,10 @@ private boolean generateRemoveAnimation(View child) {
16711677
return false;
16721678
}
16731679

1680+
private boolean isClickedHeadsUp(View child) {
1681+
return HeadsUpManager.isClickedHeadsUpNotification(child);
1682+
}
1683+
16741684
/**
16751685
* Remove a removed child view from the heads up animations if it was just added there
16761686
*
@@ -2327,6 +2337,13 @@ public void setOnEmptySpaceClickListener(OnEmptySpaceClickListener listener) {
23272337
public void onChildAnimationFinished() {
23282338
requestChildrenUpdate();
23292339
runAnimationFinishedRunnables();
2340+
clearViewOverlays();
2341+
}
2342+
2343+
private void clearViewOverlays() {
2344+
for (View view : mClearOverlayViewsWhenFinished) {
2345+
getOverlay().remove(view);
2346+
}
23302347
}
23312348

23322349
private void runAnimationFinishedRunnables() {

packages/SystemUI/src/com/android/systemui/statusbar/stack/StackStateAnimator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.android.systemui.statusbar.ExpandableNotificationRow;
3030
import com.android.systemui.statusbar.ExpandableView;
3131
import com.android.systemui.statusbar.SpeedBumpView;
32+
import com.android.systemui.statusbar.policy.HeadsUpManager;
3233

3334
import java.util.ArrayList;
3435
import java.util.HashSet;
@@ -670,6 +671,7 @@ private void startYTranslationAnimation(final View child,
670671
animator.addListener(new AnimatorListenerAdapter() {
671672
@Override
672673
public void onAnimationEnd(Animator animation) {
674+
HeadsUpManager.setIsClickedNotification(child, false);
673675
child.setTag(TAG_ANIMATOR_TRANSLATION_Y, null);
674676
child.setTag(TAG_START_TRANSLATION_Y, null);
675677
child.setTag(TAG_END_TRANSLATION_Y, null);

0 commit comments

Comments
 (0)