Enabled usage of expand button in heads up notifications
Heads up notifications can now be expanded with the expand
button. The notification stays there until the user dismisses it
or collapses it again.
Change-Id: I0f1b729915317bbbd6f13c3d968c933ffbe6feeb
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 83853a2..fe219b7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -36,6 +36,7 @@
import com.android.systemui.R;
import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
+import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.stack.NotificationChildrenContainer;
import com.android.systemui.statusbar.stack.StackScrollState;
import com.android.systemui.statusbar.stack.StackStateAnimator;
@@ -59,6 +60,11 @@
private boolean mHasUserChangedExpansion;
/** If {@link #mHasUserChangedExpansion}, has the user expanded this row */
private boolean mUserExpanded;
+
+ /**
+ * Has this notification been expanded while it was pinned
+ */
+ private boolean mExpandedWhenPinned;
/** Is the user touching this row */
private boolean mUserLocked;
/** Are we showing the "public" version */
@@ -103,6 +109,7 @@
private boolean mIsSystemChildExpanded;
private boolean mIsPinned;
private FalsingManager mFalsingManager;
+ private HeadsUpManager mHeadsUpManager;
private NotificationHeaderUtil mHeaderUtil = new NotificationHeaderUtil(this);
private boolean mJustClicked;
@@ -115,14 +122,19 @@
public void onClick(View v) {
if (!mShowingPublic && mGroupManager.isSummaryOfGroup(mStatusBarNotification)) {
mGroupManager.toggleGroupExpansion(mStatusBarNotification);
- mOnExpandClickListener.onExpandClicked(ExpandableNotificationRow.this,
+ mOnExpandClickListener.onExpandClicked(mEntry,
mGroupManager.isGroupExpanded(mStatusBarNotification));
} else {
- boolean nowExpanded = !isExpanded();
- setUserExpanded(nowExpanded);
+ boolean nowExpanded;
+ if (isPinned()) {
+ nowExpanded = !mExpandedWhenPinned;
+ mExpandedWhenPinned = nowExpanded;
+ } else {
+ nowExpanded = !isExpanded();
+ setUserExpanded(nowExpanded);
+ }
notifyHeightChanged(true);
- mOnExpandClickListener.onExpandClicked(ExpandableNotificationRow.this,
- nowExpanded);
+ mOnExpandClickListener.onExpandClicked(mEntry, nowExpanded);
}
}
};
@@ -386,6 +398,12 @@
*/
public void setPinned(boolean pinned) {
mIsPinned = pinned;
+ if (pinned) {
+ setIconAnimationRunning(true);
+ mExpandedWhenPinned = false;
+ } else if (mExpandedWhenPinned) {
+ setUserExpanded(true);
+ }
setChronometerRunning(mLastChronometerRunning);
}
@@ -393,11 +411,22 @@
return mIsPinned;
}
- public int getHeadsUpHeight() {
+ /**
+ * @param atLeastMinHeight should the value returned be at least the minimum height.
+ * Used to avoid cyclic calls
+ * @return the height of the heads up notification when pinned
+ */
+ public int getPinnedHeadsUpHeight(boolean atLeastMinHeight) {
if (mIsSummaryWithChildren) {
return mChildrenContainer.getIntrinsicHeight();
}
- return mHeadsUpHeight;
+ if(mExpandedWhenPinned) {
+ return Math.max(getMaxExpandHeight(), mHeadsUpHeight);
+ } else if (atLeastMinHeight) {
+ return Math.max(getMinHeight(), mHeadsUpHeight);
+ } else {
+ return mHeadsUpHeight;
+ }
}
/**
@@ -461,6 +490,10 @@
mOnExpandClickListener = onExpandClickListener;
}
+ public void setHeadsUpManager(HeadsUpManager headsUpManager) {
+ mHeadsUpManager = headsUpManager;
+ }
+
public interface ExpansionLogger {
public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
}
@@ -718,7 +751,6 @@
if (isUserLocked()) {
return getActualHeight();
}
- boolean inExpansionState = isExpanded();
if (mGuts != null && mGuts.areGutsExposed()) {
return mGuts.getHeight();
} else if ((isChildInGroup() && !isGroupExpanded())) {
@@ -728,12 +760,14 @@
} else if (mIsSummaryWithChildren && !mOnKeyguard) {
return mChildrenContainer.getIntrinsicHeight();
} else if (mIsHeadsUp) {
- if (inExpansionState) {
+ if (isPinned()) {
+ return getPinnedHeadsUpHeight(true /* atLeastMinHeight */);
+ } else if (isExpanded()) {
return Math.max(getMaxExpandHeight(), mHeadsUpHeight);
} else {
return Math.max(getMinHeight(), mHeadsUpHeight);
}
- } else if (inExpansionState) {
+ } else if (isExpanded()) {
return getMaxExpandHeight();
} else {
return getMinHeight();
@@ -961,8 +995,12 @@
@Override
public int getMinHeight() {
- if (mIsSummaryWithChildren && !isGroupExpanded() && !mShowingPublic) {
+ if (mIsHeadsUp && mHeadsUpManager.isTrackingHeadsUp()) {
+ return getPinnedHeadsUpHeight(false /* atLeastMinHeight */);
+ } else if (mIsSummaryWithChildren && !isGroupExpanded() && !mShowingPublic) {
return mChildrenContainer.getMinHeight();
+ } else if (mIsHeadsUp) {
+ return mHeadsUpHeight;
}
NotificationContentView showingLayout = getShowingLayout();
return showingLayout.getMinHeight();
@@ -1067,6 +1105,6 @@
}
public interface OnExpandClickListener {
- void onExpandClicked(View clickedView, boolean nowExpanded);
+ void onExpandClicked(NotificationData.Entry clickedEntry, boolean nowExpanded);
}
}