summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2012-05-09 21:25:57 -0400
committerChris Wren <cwren@android.com>2012-05-10 13:40:19 -0400
commit8fd12657e353a4a6f6d875a0d86850426fec00e8 (patch)
tree8762625601aa5429950fe9605e1e47bddac4870a /packages/SystemUI/src/com/android
parent0c8275b392344c24bb621b2a8af360f48a6459f9 (diff)
downloadframeworks_base-8fd12657e353a4a6f6d875a0d86850426fec00e8.zip
frameworks_base-8fd12657e353a4a6f6d875a0d86850426fec00e8.tar.gz
frameworks_base-8fd12657e353a4a6f6d875a0d86850426fec00e8.tar.bz2
Auto-expand the top notification.
Bug: 6455789 Change-Id: Ia455f204544ad0c41ace77ea3ece6e0d3d3110d9
Diffstat (limited to 'packages/SystemUI/src/com/android')
-rw-r--r--packages/SystemUI/src/com/android/systemui/ExpandHelper.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java55
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java59
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java5
6 files changed, 117 insertions, 16 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java
index c5928f1..7a7afa7 100644
--- a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java
@@ -34,6 +34,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
View getChildAtPosition(MotionEvent ev);
View getChildAtPosition(float x, float y);
boolean canChildBeExpanded(View v);
+ boolean setUserExpandedChild(View v, boolean userxpanded);
}
private static final String TAG = "ExpandHelper";
@@ -272,6 +273,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
mScaleAnimation.start();
mStretching = false;
setGlow(0f);
+ mCallback.setUserExpandedChild(mCurrView, h == mNaturalHeight);
if (DEBUG) Log.d(TAG, "scale was finished on view: " + mCurrView);
clearView();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index a7cc812..af48f88 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -485,17 +485,7 @@ public abstract class BaseStatusBar extends SystemUI implements
// for blaming (see SwipeHelper.setLongPressListener)
row.setTag(sbn.pkg);
- // XXX: temporary: while testing big notifications, auto-expand all of them
ViewGroup.LayoutParams lp = row.getLayoutParams();
- Boolean expandable = Boolean.FALSE;
- if (large != null) {
- lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
- expandable = Boolean.TRUE;
- } else {
- lp.height = rowHeight;
- }
- row.setLayoutParams(lp);
- row.setTag(R.id.expandable_tag, expandable);
workAroundBadLayerDrawableOpacity(row);
View vetoButton = updateNotificationVetoButton(row, sbn);
vetoButton.setContentDescription(mContext.getString(
@@ -561,10 +551,11 @@ public abstract class BaseStatusBar extends SystemUI implements
applyLegacyRowBackground(sbn, content);
+ row.setTag(R.id.expandable_tag, Boolean.valueOf(large != null));
entry.row = row;
entry.content = content;
entry.expanded = expandedOneU;
- entry.expandedLarge = expandedOneU;
+ entry.setLargeView(expandedLarge);
return true;
}
@@ -673,6 +664,7 @@ public abstract class BaseStatusBar extends SystemUI implements
// Remove the expanded view.
ViewGroup rowParent = (ViewGroup)entry.row.getParent();
if (rowParent != null) rowParent.removeView(entry.row);
+ updateExpansionStates();
updateNotificationIcons();
return entry.notification;
@@ -711,16 +703,53 @@ public abstract class BaseStatusBar extends SystemUI implements
if (DEBUG) {
Slog.d(TAG, "addNotificationViews: added at " + pos);
}
+ updateExpansionStates();
updateNotificationIcons();
return iconView;
}
+ protected boolean expandView(NotificationData.Entry entry, boolean expand) {
+ if (entry.expandable()) {
+ int rowHeight =
+ mContext.getResources().getDimensionPixelSize(R.dimen.notification_height);
+ ViewGroup.LayoutParams lp = entry.row.getLayoutParams();
+ if (expand) {
+ lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
+ } else {
+ lp.height = rowHeight;
+ }
+ entry.row.setLayoutParams(lp);
+ return expand;
+ } else {
+ return false;
+ }
+ }
+
+ protected void updateExpansionStates() {
+ int N = mNotificationData.size();
+ for (int i = 0; i < N; i++) {
+ NotificationData.Entry entry = mNotificationData.get(i);
+ if (i == (N-1)) {
+ if (DEBUG) Slog.d(TAG, "expanding top notification at " + i);
+ expandView(entry, true);
+ } else {
+ if (!entry.userExpanded()) {
+ if (DEBUG) Slog.d(TAG, "collapsing notification at " + i);
+ expandView(entry, false);
+ } else {
+ if (DEBUG) Slog.d(TAG, "ignoring user-modified notification at " + i);
+ }
+ }
+ }
+ }
+
protected abstract void haltTicker();
protected abstract void setAreThereNotifications();
protected abstract void updateNotificationIcons();
protected abstract void tick(IBinder key, StatusBarNotification n, boolean firstTime);
protected abstract void updateExpandedViewPos(int expandedPosition);
+ protected abstract int getExpandedViewMaxHeight();
protected boolean isTopNotification(ViewGroup parent, NotificationData.Entry entry) {
return parent.indexOfChild(entry.row) == 0;
@@ -797,6 +826,7 @@ public abstract class BaseStatusBar extends SystemUI implements
handleNotificationError(key, notification, "Couldn't update icon: " + ic);
return;
}
+ updateExpansionStates();
}
catch (RuntimeException e) {
// It failed to add cleanly. Log, and remove the view from the panel.
@@ -806,6 +836,9 @@ public abstract class BaseStatusBar extends SystemUI implements
}
} else {
if (DEBUG) Slog.d(TAG, "not reusing notification for key: " + key);
+ if (DEBUG) Slog.d(TAG, "contents was " + (contentsUnchanged ? "unchanged" : "changed"));
+ if (DEBUG) Slog.d(TAG, "order was " + (orderUnchanged ? "unchanged" : "changed"));
+ if (DEBUG) Slog.d(TAG, "notification is " + (isTopAnyway ? "top" : "not top"));
removeNotificationViews(key);
addNotificationViews(key, notification);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
index 3ff85d9..1a07ed3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
@@ -22,6 +22,7 @@ import android.view.View;
import android.widget.ImageView;
import com.android.internal.statusbar.StatusBarNotification;
+import com.android.systemui.R;
import java.util.Comparator;
import java.util.ArrayList;
@@ -38,13 +39,32 @@ public class NotificationData {
public View content; // takes the click events and sends the PendingIntent
public View expanded; // the inflated RemoteViews
public ImageView largeIcon;
- public View expandedLarge;
+ protected View expandedLarge;
public Entry() {}
public Entry(IBinder key, StatusBarNotification n, StatusBarIconView ic) {
this.key = key;
this.notification = n;
this.icon = ic;
}
+ public void setLargeView(View expandedLarge) {
+ this.expandedLarge = expandedLarge;
+ writeBooleanTag(row, R.id.expandable_tag, expandedLarge != null);
+ }
+ public View getLargeView() {
+ return expandedLarge;
+ }
+ /**
+ * Return whether the entry can be expanded.
+ */
+ public boolean expandable() {
+ return NotificationData.getIsExpandable(row);
+ }
+ /**
+ * Return whether the entry has been manually expanded by the user.
+ */
+ public boolean userExpanded() {
+ return NotificationData.getUserExpanded(row);
+ }
}
private final ArrayList<Entry> mEntries = new ArrayList<Entry>();
private final Comparator<Entry> mEntryCmp = new Comparator<Entry>() {
@@ -134,4 +154,41 @@ public class NotificationData {
}
return false;
}
+
+ protected static boolean readBooleanTag(View view, int id) {
+ if (view != null) {
+ Object value = view.getTag(id);
+ return value != null && value instanceof Boolean && ((Boolean) value).booleanValue();
+ }
+ return false;
+ }
+
+ protected static boolean writeBooleanTag(View view, int id, boolean value) {
+ if (view != null) {
+ view.setTag(id, Boolean.valueOf(value));
+ return value;
+ }
+ return false;
+ }
+
+ /**
+ * Return whether the entry can be expanded.
+ */
+ public static boolean getIsExpandable(View row) {
+ return readBooleanTag(row, R.id.expandable_tag);
+ }
+
+ /**
+ * Return whether the entry has been manually expanded by the user.
+ */
+ public static boolean getUserExpanded(View row) {
+ return readBooleanTag(row, R.id.user_expanded_tag);
+ }
+
+ /**
+ * Set whether the entry has been manually expanded by the user.
+ */
+ public static boolean setUserExpanded(View row, boolean userExpanded) {
+ return writeBooleanTag(row, R.id.user_expanded_tag, userExpanded);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 320dd6a..d1498c7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -1771,7 +1771,8 @@ public class PhoneStatusBar extends BaseStatusBar {
return a < 0f ? 0f : (a > 1f ? 1f : a);
}
- int getExpandedViewMaxHeight() {
+ @Override
+ protected int getExpandedViewMaxHeight() {
return mDisplayMetrics.heightPixels - mNotificationPanelMarginBottomPx;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
index 03dfd1c..0fe7a0a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
@@ -39,6 +39,7 @@ import com.android.systemui.ExpandHelper;
import com.android.systemui.Gefingerpoken;
import com.android.systemui.R;
import com.android.systemui.SwipeHelper;
+import com.android.systemui.statusbar.NotificationData;
import java.util.HashMap;
@@ -175,9 +176,11 @@ public class NotificationRowLayout
}
public boolean canChildBeExpanded(View v) {
- Object isExpandable = v.getTag(R.id.expandable_tag);
- return isExpandable != null && isExpandable instanceof Boolean &&
- ((Boolean)isExpandable).booleanValue();
+ return NotificationData.getIsExpandable(v);
+ }
+
+ public boolean setUserExpandedChild(View v, boolean userExpanded) {
+ return NotificationData.setUserExpanded(v, userExpanded);
}
public void onChildDismissed(View v) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index 6a7d6b0..e8583d7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -348,6 +348,11 @@ public class TabletStatusBar extends BaseStatusBar implements
scroller.setFillViewport(true);
}
+ @Override
+ protected int getExpandedViewMaxHeight() {
+ return getNotificationPanelHeight();
+ }
+
private int getNotificationPanelHeight() {
final Resources res = mContext.getResources();
final Display d = WindowManagerImpl.getDefault().getDefaultDisplay();