The heads up now correctly dissapears when clicking

Bug: 22729955
Change-Id: I977b36823bf936baab527f932b1e5576241f4d71
This commit is contained in:
Selim Cinek
2015-07-29 17:04:36 -07:00
parent 26ae600b5f
commit 0fccc729fd
7 changed files with 41 additions and 2 deletions

View File

@@ -49,5 +49,6 @@
<!-- For notification icons for which targetSdk < L, this caches whether the icon is grayscale -->
<item type="id" name="icon_is_grayscale" />
<item type="id" name="is_clicked_heads_up_tag" />
</resources>

View File

@@ -1525,6 +1525,7 @@ public abstract class BaseStatusBar extends SystemUI implements
//
// In most cases, when FLAG_AUTO_CANCEL is set, the notification will
// become canceled shortly by NoMan, but we can't assume that.
HeadsUpManager.setIsClickedNotification(row, true);
mHeadsUpManager.releaseImmediately(notificationKey);
}
new Thread() {

View File

@@ -32,7 +32,6 @@ import android.util.MathUtils;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewRootImpl;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.view.accessibility.AccessibilityEvent;
@@ -203,10 +202,12 @@ public class NotificationPanelView extends PanelView implements
private int mPositionMinSideMargin;
private int mLastOrientation = -1;
private boolean mClosingWithAlphaFadeOut;
private boolean mHeadsUpAnimatingAway;
private Runnable mHeadsUpExistenceChangedRunnable = new Runnable() {
@Override
public void run() {
mHeadsUpAnimatingAway = false;
notifyBarPanelExpansionChanged();
}
};
@@ -2292,6 +2293,7 @@ public class NotificationPanelView extends PanelView implements
mHeadsUpExistenceChangedRunnable.run();
updateNotificationTranslucency();
} else {
mHeadsUpAnimatingAway = true;
mNotificationStackScroller.runAfterAnimationFinished(
mHeadsUpExistenceChangedRunnable);
}
@@ -2382,4 +2384,8 @@ public class NotificationPanelView extends PanelView implements
public void clearNotificattonEffects() {
mStatusBar.clearNotificationEffects();
}
protected boolean isPanelVisibleBecauseOfHeadsUp() {
return mHeadsUpManager.hasPinnedHeadsUp() || mHeadsUpAnimatingAway;
}
}

View File

@@ -1009,10 +1009,12 @@ public abstract class PanelView extends FrameLayout {
protected void notifyBarPanelExpansionChanged() {
mBar.panelExpansionChanged(this, mExpandedFraction, mExpandedFraction > 0f || mPeekPending
|| mPeekAnimator != null || mInstantExpanding || mHeadsUpManager.hasPinnedHeadsUp()
|| mPeekAnimator != null || mInstantExpanding || isPanelVisibleBecauseOfHeadsUp()
|| mTracking || mHeightAnimator != null);
}
protected abstract boolean isPanelVisibleBecauseOfHeadsUp();
/**
* Gets called when the user performs a click anywhere in the empty area of the panel.
*

View File

@@ -51,6 +51,7 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL
private static final String TAG = "HeadsUpManager";
private static final boolean DEBUG = false;
private static final String SETTING_HEADS_UP_SNOOZE_LENGTH_MS = "heads_up_snooze_length_ms";
private static final int TAG_CLICKED_NOTIFICATION = R.id.is_clicked_heads_up_tag;
private final int mHeadsUpNotificationDecay;
private final int mMinimumDisplayTime;
@@ -526,6 +527,15 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL
});
}
public static void setIsClickedNotification(View child, boolean clicked) {
child.setTag(TAG_CLICKED_NOTIFICATION, clicked ? true : null);
}
public static boolean isClickedHeadsUpNotification(View child) {
Boolean clicked = (Boolean) child.getTag(TAG_CLICKED_NOTIFICATION);
return clicked != null && clicked;
}
/**
* This represents a notification and how long it is in a heads up mode. It also manages its
* lifecycle automatically when created.

View File

@@ -222,6 +222,7 @@ public class NotificationStackScrollLayout extends ViewGroup
private int[] mTempInt2 = new int[2];
private boolean mGenerateChildOrderChangedEvent;
private HashSet<Runnable> mAnimationFinishedRunnables = new HashSet<>();
private HashSet<View> mClearOverlayViewsWhenFinished = new HashSet<>();
private HashSet<Pair<ExpandableNotificationRow, Boolean>> mHeadsUpChangeAnimations
= new HashSet<>();
private HeadsUpManager mHeadsUpManager;
@@ -1656,6 +1657,11 @@ public class NotificationStackScrollLayout extends ViewGroup
mAddedHeadsUpChildren.remove(child);
return false;
}
if (isClickedHeadsUp(child)) {
// An animation is already running, add it to the Overlay
mClearOverlayViewsWhenFinished.add(child);
return true;
}
if (mIsExpanded && mAnimationsEnabled && !isChildInInvisibleGroup(child)) {
if (!mChildrenToAddAnimated.contains(child)) {
// Generate Animations
@@ -1671,6 +1677,10 @@ public class NotificationStackScrollLayout extends ViewGroup
return false;
}
private boolean isClickedHeadsUp(View child) {
return HeadsUpManager.isClickedHeadsUpNotification(child);
}
/**
* Remove a removed child view from the heads up animations if it was just added there
*
@@ -2327,6 +2337,13 @@ public class NotificationStackScrollLayout extends ViewGroup
public void onChildAnimationFinished() {
requestChildrenUpdate();
runAnimationFinishedRunnables();
clearViewOverlays();
}
private void clearViewOverlays() {
for (View view : mClearOverlayViewsWhenFinished) {
getOverlay().remove(view);
}
}
private void runAnimationFinishedRunnables() {

View File

@@ -29,6 +29,7 @@ import com.android.systemui.R;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.ExpandableView;
import com.android.systemui.statusbar.SpeedBumpView;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import java.util.ArrayList;
import java.util.HashSet;
@@ -670,6 +671,7 @@ public class StackStateAnimator {
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
HeadsUpManager.setIsClickedNotification(child, false);
child.setTag(TAG_ANIMATOR_TRANSLATION_Y, null);
child.setTag(TAG_START_TRANSLATION_Y, null);
child.setTag(TAG_END_TRANSLATION_Y, null);