summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorJoe Onorato <joeo@android.com>2010-05-23 15:18:27 -0400
committerJoe Onorato <joeo@android.com>2010-06-02 14:48:43 -0700
commite345fff2f80947b0a821f6674c197a02b7bff08e (patch)
tree0e6189b3f1716931b8fe28a8ce1ddc83dadea299 /packages
parenta0c56fe93925d20d9c0b830b9664699ce557e78c (diff)
downloadframeworks_base-e345fff2f80947b0a821f6674c197a02b7bff08e.zip
frameworks_base-e345fff2f80947b0a821f6674c197a02b7bff08e.tar.gz
frameworks_base-e345fff2f80947b0a821f6674c197a02b7bff08e.tar.bz2
notifications show
Change-Id: I9240b803c643874828c95afcf1ba9ed91194dbc0
Diffstat (limited to 'packages')
-rw-r--r--packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationData.java66
-rw-r--r--packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java82
-rw-r--r--packages/StatusBarPhone/src/com/android/policy/statusbar/phone/Ticker.java8
3 files changed, 113 insertions, 43 deletions
diff --git a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationData.java b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationData.java
index ca2d79b..ae71bda 100644
--- a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationData.java
+++ b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/NotificationData.java
@@ -16,29 +16,51 @@
package com.android.policy.statusbar.phone;
-import android.app.PendingIntent;
-import android.widget.RemoteViews;
+import android.os.IBinder;
+import android.view.View;
+import com.android.internal.statusbar.StatusBarNotification;
+
+import java.util.ArrayList;
+
+/**
+ * The list of currently displaying notifications.
+ */
public class NotificationData {
- public String pkg;
- public String tag;
- public int id;
- public CharSequence tickerText;
-
- public long when;
- public boolean ongoingEvent;
- public boolean clearable;
-
- public RemoteViews contentView;
- public PendingIntent contentIntent;
-
- public PendingIntent deleteIntent;
-
- public String toString() {
- return "NotificationData(package=" + pkg + " id=" + id + " tickerText=" + tickerText
- + " ongoingEvent=" + ongoingEvent + " contentIntent=" + contentIntent
- + " deleteIntent=" + deleteIntent
- + " clearable=" + clearable
- + " contentView=" + contentView + " when=" + when + ")";
+ public static final class Entry {
+ public IBinder key;
+ public StatusBarNotification notification;
+ public StatusBarIconView icon;
+ public View expanded;
+ }
+ private final ArrayList<Entry> mEntries = new ArrayList<Entry>();
+
+ public int size() {
+ return mEntries.size();
+ }
+
+ public Entry getEntryAt(int index) {
+ return mEntries.get(index);
+ }
+
+ public int add(IBinder key, StatusBarNotification notification, View expanded) {
+ Entry entry = new Entry();
+ entry.key = key;
+ entry.notification = notification;
+ entry.expanded = expanded;
+ final int index = chooseIndex(notification.notification.when);
+ mEntries.add(index, entry);
+ return index;
+ }
+
+ private int chooseIndex(final long when) {
+ final int N = mEntries.size();
+ for (int i=0; i<N; i++) {
+ Entry entry = mEntries.get(i);
+ if (entry.notification.notification.when > when) {
+ return i;
+ }
+ }
+ return N;
}
}
diff --git a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java
index c626c45..37b3655 100644
--- a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java
+++ b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/PhoneStatusBarService.java
@@ -24,6 +24,7 @@ import com.android.internal.statusbar.StatusBarNotification;
import android.app.ActivityManagerNative;
import android.app.Dialog;
+import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.app.StatusBarManager;
@@ -127,22 +128,28 @@ public class PhoneStatusBarService extends StatusBarService {
LinearLayout mStatusIcons;
// expanded notifications
- NotificationViewList mNotificationData = new NotificationViewList();
Dialog mExpandedDialog;
ExpandedView mExpandedView;
WindowManager.LayoutParams mExpandedParams;
ScrollView mScrollView;
View mNotificationLinearLayout;
- TextView mOngoingTitle;
- LinearLayout mOngoingItems;
- TextView mLatestTitle;
- LinearLayout mLatestItems;
+ View mExpandedContents;
+ // top bar
TextView mNoNotificationsTitle;
TextView mSpnLabel;
TextView mPlmnLabel;
TextView mClearButton;
- View mExpandedContents;
+ // drag bar
CloseDragHandle mCloseView;
+ // ongoing
+ NotificationData mOngoing = new NotificationData();
+ TextView mOngoingTitle;
+ LinearLayout mOngoingItems;
+ // latest
+ NotificationData mLatest = new NotificationData();
+ TextView mLatestTitle;
+ LinearLayout mLatestItems;
+ // position
int[] mPositionTmp = new int[2];
boolean mExpanded;
boolean mExpandedVisible;
@@ -317,6 +324,36 @@ public class PhoneStatusBarService extends StatusBarService {
}
public void addNotification(IBinder key, StatusBarNotification notification) {
+ NotificationData list;
+ ViewGroup parent;
+ final boolean isOngoing = notification.isOngoing();
+ if (isOngoing) {
+ list = mOngoing;
+ parent = mOngoingItems;
+ } else {
+ list = mLatest;
+ parent = mLatestItems;
+ }
+ // Construct the expanded view.
+ final View view = makeNotificationView(notification, parent);
+ // Construct the icon.
+ StatusBarIconView iconView = new StatusBarIconView(this,
+ notification.pkg + "/" + notification.id);
+ iconView.set(new StatusBarIcon(notification.pkg, notification.notification.icon,
+ notification.notification.iconLevel));
+ // Add the expanded view.
+ final int viewIndex = list.add(key, notification, view);
+ parent.addView(view, viewIndex);
+ // Add the icon.
+ final int iconIndex = chooseIconIndex(isOngoing, viewIndex);
+ mNotificationIcons.addView(iconView, iconIndex,
+ new LinearLayout.LayoutParams(mIconWidth, mHeight));
+
+ // show the ticker
+ // TODO
+
+ // recalculate the position of the sliding windows
+ updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
}
public void updateNotification(IBinder key, StatusBarNotification notification) {
@@ -384,9 +421,18 @@ public class PhoneStatusBarService extends StatusBarService {
v.setSelected(hasFocus);
}
};
+
+ private int chooseIconIndex(boolean isOngoing, int index) {
+ final int ongoingSize = mOngoing.size();
+ final int latestSize = mLatest.size();
+ if (!isOngoing) {
+ index = mLatest.size() + index;
+ }
+ return (ongoingSize + latestSize) - index - 1;
+ }
View makeNotificationView(StatusBarNotification notification, ViewGroup parent) {
- NotificationData n = notification.data;
+ Notification n = notification.notification;
RemoteViews remoteViews = n.contentView;
if (remoteViews == null) {
return null;
@@ -403,7 +449,8 @@ public class PhoneStatusBarService extends StatusBarService {
content.setOnFocusChangeListener(mFocusChangeListener);
PendingIntent contentIntent = n.contentIntent;
if (contentIntent != null) {
- content.setOnClickListener(new Launcher(contentIntent, n.pkg, n.tag, n.id));
+ content.setOnClickListener(new Launcher(contentIntent, notification.pkg,
+ notification.tag, notification.id));
}
View child = null;
@@ -415,15 +462,17 @@ public class PhoneStatusBarService extends StatusBarService {
exception = e;
}
if (child == null) {
- Slog.e(TAG, "couldn't inflate view for package " + n.pkg, exception);
+ Slog.e(TAG, "couldn't inflate view for package " + notification.pkg, exception);
return null;
}
content.addView(child);
row.setDrawingCacheEnabled(true);
+ /*
notification.view = row;
notification.contentView = child;
+ */
return row;
}
@@ -433,6 +482,7 @@ public class PhoneStatusBarService extends StatusBarService {
notification.iconLevel);
icon.number = notification.number;
*/
+ /*
void addNotificationView(StatusBarNotification notification) {
if (notification.view != null) {
throw new RuntimeException("Assertion failed: notification.view="
@@ -449,11 +499,13 @@ public class PhoneStatusBarService extends StatusBarService {
int index = mNotificationData.getExpandedIndex(notification);
parent.addView(child, index);
}
+ */
/**
* Remove the old one and put the new one in its place.
* @param notification the notification
*/
+ /*
void updateNotificationView(StatusBarNotification notification, NotificationData oldData) {
NotificationData n = notification.data;
if (oldData != null && n != null
@@ -498,8 +550,10 @@ public class PhoneStatusBarService extends StatusBarService {
notification.view = null;
}
}
+ */
private void setAreThereNotifications() {
+ /*
boolean ongoing = mOngoingItems.getChildCount() != 0;
boolean latest = mLatestItems.getChildCount() != 0;
@@ -517,6 +571,7 @@ public class PhoneStatusBarService extends StatusBarService {
} else {
mNoNotificationsTitle.setVisibility(View.VISIBLE);
}
+ */
}
private void makeExpandedVisible() {
@@ -588,15 +643,6 @@ public class PhoneStatusBarService extends StatusBarService {
return;
}
- // It seems strange to sometimes not expand...
- if (false) {
- synchronized (mNotificationData) {
- if (mNotificationData.size() == 0) {
- return;
- }
- }
- }
-
mExpanded = true;
makeExpandedVisible();
updateExpandedViewPos(EXPANDED_FULL_OPEN);
diff --git a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/Ticker.java b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/Ticker.java
index ee82948..b9181a7 100644
--- a/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/Ticker.java
+++ b/packages/StatusBarPhone/src/com/android/policy/statusbar/phone/Ticker.java
@@ -33,12 +33,14 @@ import android.widget.ImageSwitcher;
import java.util.ArrayList;
+import com.android.internal.statusbar.StatusBarNotification;
+
public abstract class Ticker {
private static final int TICKER_SEGMENT_DELAY = 3000;
private final class Segment {
- NotificationData notificationData;
+ StatusBarNotification notificationData;
Drawable icon;
CharSequence text;
int current;
@@ -114,7 +116,7 @@ public abstract class Ticker {
return null;
}
- Segment(NotificationData n, Drawable icon, CharSequence text) {
+ Segment(StatusBarNotification n, Drawable icon, CharSequence text) {
this.notificationData = n;
this.icon = icon;
this.text = text;
@@ -156,7 +158,7 @@ public abstract class Ticker {
mPaint = text.getPaint();
}
- void addEntry(NotificationData n, Drawable icon, CharSequence text) {
+ void addEntry(StatusBarNotification n, Drawable icon, CharSequence text) {
int initialCount = mSegments.size();
Segment newSegment = new Segment(n, icon, text);