notifications show
Change-Id: I9240b803c643874828c95afcf1ba9ed91194dbc0
This commit is contained in:
@@ -70,6 +70,7 @@ public class StatusBarIcon implements Parcelable {
|
|||||||
out.writeString(this.iconPackage);
|
out.writeString(this.iconPackage);
|
||||||
out.writeInt(this.iconId);
|
out.writeInt(this.iconId);
|
||||||
out.writeInt(this.iconLevel);
|
out.writeInt(this.iconLevel);
|
||||||
|
out.writeInt(this.visible ? 1 : 0);
|
||||||
out.writeInt(this.number);
|
out.writeInt(this.number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,6 +107,10 @@ public class StatusBarNotification implements Parcelable {
|
|||||||
+ " notification=" + notification + ")";
|
+ " notification=" + notification + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOngoing() {
|
||||||
|
return (notification.flags & Notification.FLAG_ONGOING_EVENT) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingTop="3dp"
|
android:paddingTop="3dp"
|
||||||
>
|
>
|
||||||
<com.android.server.status.AnimatedImageView android:id="@+id/icon"
|
<!--com.android.server.status.AnimatedImageView android:id="@+id/icon" -->
|
||||||
|
<ImageView android:id="@+id/icon"
|
||||||
android:layout_width="25dp"
|
android:layout_width="25dp"
|
||||||
android:layout_height="25dp"
|
android:layout_height="25dp"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
|
|||||||
@@ -16,29 +16,51 @@
|
|||||||
|
|
||||||
package com.android.policy.statusbar.phone;
|
package com.android.policy.statusbar.phone;
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
import android.os.IBinder;
|
||||||
import android.widget.RemoteViews;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.android.internal.statusbar.StatusBarNotification;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of currently displaying notifications.
|
||||||
|
*/
|
||||||
public class NotificationData {
|
public class NotificationData {
|
||||||
public String pkg;
|
public static final class Entry {
|
||||||
public String tag;
|
public IBinder key;
|
||||||
public int id;
|
public StatusBarNotification notification;
|
||||||
public CharSequence tickerText;
|
public StatusBarIconView icon;
|
||||||
|
public View expanded;
|
||||||
|
}
|
||||||
|
private final ArrayList<Entry> mEntries = new ArrayList<Entry>();
|
||||||
|
|
||||||
public long when;
|
public int size() {
|
||||||
public boolean ongoingEvent;
|
return mEntries.size();
|
||||||
public boolean clearable;
|
}
|
||||||
|
|
||||||
public RemoteViews contentView;
|
public Entry getEntryAt(int index) {
|
||||||
public PendingIntent contentIntent;
|
return mEntries.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
public PendingIntent deleteIntent;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
private int chooseIndex(final long when) {
|
||||||
return "NotificationData(package=" + pkg + " id=" + id + " tickerText=" + tickerText
|
final int N = mEntries.size();
|
||||||
+ " ongoingEvent=" + ongoingEvent + " contentIntent=" + contentIntent
|
for (int i=0; i<N; i++) {
|
||||||
+ " deleteIntent=" + deleteIntent
|
Entry entry = mEntries.get(i);
|
||||||
+ " clearable=" + clearable
|
if (entry.notification.notification.when > when) {
|
||||||
+ " contentView=" + contentView + " when=" + when + ")";
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return N;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import com.android.internal.statusbar.StatusBarNotification;
|
|||||||
|
|
||||||
import android.app.ActivityManagerNative;
|
import android.app.ActivityManagerNative;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.app.Notification;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.app.StatusBarManager;
|
import android.app.StatusBarManager;
|
||||||
@@ -127,22 +128,28 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
LinearLayout mStatusIcons;
|
LinearLayout mStatusIcons;
|
||||||
|
|
||||||
// expanded notifications
|
// expanded notifications
|
||||||
NotificationViewList mNotificationData = new NotificationViewList();
|
|
||||||
Dialog mExpandedDialog;
|
Dialog mExpandedDialog;
|
||||||
ExpandedView mExpandedView;
|
ExpandedView mExpandedView;
|
||||||
WindowManager.LayoutParams mExpandedParams;
|
WindowManager.LayoutParams mExpandedParams;
|
||||||
ScrollView mScrollView;
|
ScrollView mScrollView;
|
||||||
View mNotificationLinearLayout;
|
View mNotificationLinearLayout;
|
||||||
TextView mOngoingTitle;
|
View mExpandedContents;
|
||||||
LinearLayout mOngoingItems;
|
// top bar
|
||||||
TextView mLatestTitle;
|
|
||||||
LinearLayout mLatestItems;
|
|
||||||
TextView mNoNotificationsTitle;
|
TextView mNoNotificationsTitle;
|
||||||
TextView mSpnLabel;
|
TextView mSpnLabel;
|
||||||
TextView mPlmnLabel;
|
TextView mPlmnLabel;
|
||||||
TextView mClearButton;
|
TextView mClearButton;
|
||||||
View mExpandedContents;
|
// drag bar
|
||||||
CloseDragHandle mCloseView;
|
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];
|
int[] mPositionTmp = new int[2];
|
||||||
boolean mExpanded;
|
boolean mExpanded;
|
||||||
boolean mExpandedVisible;
|
boolean mExpandedVisible;
|
||||||
@@ -317,6 +324,36 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addNotification(IBinder key, StatusBarNotification notification) {
|
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) {
|
public void updateNotification(IBinder key, StatusBarNotification notification) {
|
||||||
@@ -385,8 +422,17 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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) {
|
View makeNotificationView(StatusBarNotification notification, ViewGroup parent) {
|
||||||
NotificationData n = notification.data;
|
Notification n = notification.notification;
|
||||||
RemoteViews remoteViews = n.contentView;
|
RemoteViews remoteViews = n.contentView;
|
||||||
if (remoteViews == null) {
|
if (remoteViews == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -403,7 +449,8 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
content.setOnFocusChangeListener(mFocusChangeListener);
|
content.setOnFocusChangeListener(mFocusChangeListener);
|
||||||
PendingIntent contentIntent = n.contentIntent;
|
PendingIntent contentIntent = n.contentIntent;
|
||||||
if (contentIntent != null) {
|
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;
|
View child = null;
|
||||||
@@ -415,15 +462,17 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
exception = e;
|
exception = e;
|
||||||
}
|
}
|
||||||
if (child == null) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
content.addView(child);
|
content.addView(child);
|
||||||
|
|
||||||
row.setDrawingCacheEnabled(true);
|
row.setDrawingCacheEnabled(true);
|
||||||
|
|
||||||
|
/*
|
||||||
notification.view = row;
|
notification.view = row;
|
||||||
notification.contentView = child;
|
notification.contentView = child;
|
||||||
|
*/
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
@@ -433,6 +482,7 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
notification.iconLevel);
|
notification.iconLevel);
|
||||||
icon.number = notification.number;
|
icon.number = notification.number;
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
void addNotificationView(StatusBarNotification notification) {
|
void addNotificationView(StatusBarNotification notification) {
|
||||||
if (notification.view != null) {
|
if (notification.view != null) {
|
||||||
throw new RuntimeException("Assertion failed: notification.view="
|
throw new RuntimeException("Assertion failed: notification.view="
|
||||||
@@ -449,11 +499,13 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
int index = mNotificationData.getExpandedIndex(notification);
|
int index = mNotificationData.getExpandedIndex(notification);
|
||||||
parent.addView(child, index);
|
parent.addView(child, index);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the old one and put the new one in its place.
|
* Remove the old one and put the new one in its place.
|
||||||
* @param notification the notification
|
* @param notification the notification
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
void updateNotificationView(StatusBarNotification notification, NotificationData oldData) {
|
void updateNotificationView(StatusBarNotification notification, NotificationData oldData) {
|
||||||
NotificationData n = notification.data;
|
NotificationData n = notification.data;
|
||||||
if (oldData != null && n != null
|
if (oldData != null && n != null
|
||||||
@@ -498,8 +550,10 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
notification.view = null;
|
notification.view = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
private void setAreThereNotifications() {
|
private void setAreThereNotifications() {
|
||||||
|
/*
|
||||||
boolean ongoing = mOngoingItems.getChildCount() != 0;
|
boolean ongoing = mOngoingItems.getChildCount() != 0;
|
||||||
boolean latest = mLatestItems.getChildCount() != 0;
|
boolean latest = mLatestItems.getChildCount() != 0;
|
||||||
|
|
||||||
@@ -517,6 +571,7 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
} else {
|
} else {
|
||||||
mNoNotificationsTitle.setVisibility(View.VISIBLE);
|
mNoNotificationsTitle.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeExpandedVisible() {
|
private void makeExpandedVisible() {
|
||||||
@@ -588,15 +643,6 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// It seems strange to sometimes not expand...
|
|
||||||
if (false) {
|
|
||||||
synchronized (mNotificationData) {
|
|
||||||
if (mNotificationData.size() == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mExpanded = true;
|
mExpanded = true;
|
||||||
makeExpandedVisible();
|
makeExpandedVisible();
|
||||||
updateExpandedViewPos(EXPANDED_FULL_OPEN);
|
updateExpandedViewPos(EXPANDED_FULL_OPEN);
|
||||||
|
|||||||
@@ -33,12 +33,14 @@ import android.widget.ImageSwitcher;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import com.android.internal.statusbar.StatusBarNotification;
|
||||||
|
|
||||||
|
|
||||||
public abstract class Ticker {
|
public abstract class Ticker {
|
||||||
private static final int TICKER_SEGMENT_DELAY = 3000;
|
private static final int TICKER_SEGMENT_DELAY = 3000;
|
||||||
|
|
||||||
private final class Segment {
|
private final class Segment {
|
||||||
NotificationData notificationData;
|
StatusBarNotification notificationData;
|
||||||
Drawable icon;
|
Drawable icon;
|
||||||
CharSequence text;
|
CharSequence text;
|
||||||
int current;
|
int current;
|
||||||
@@ -114,7 +116,7 @@ public abstract class Ticker {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Segment(NotificationData n, Drawable icon, CharSequence text) {
|
Segment(StatusBarNotification n, Drawable icon, CharSequence text) {
|
||||||
this.notificationData = n;
|
this.notificationData = n;
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
@@ -156,7 +158,7 @@ public abstract class Ticker {
|
|||||||
mPaint = text.getPaint();
|
mPaint = text.getPaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void addEntry(NotificationData n, Drawable icon, CharSequence text) {
|
void addEntry(StatusBarNotification n, Drawable icon, CharSequence text) {
|
||||||
int initialCount = mSegments.size();
|
int initialCount = mSegments.size();
|
||||||
|
|
||||||
Segment newSegment = new Segment(n, icon, text);
|
Segment newSegment = new Segment(n, icon, text);
|
||||||
|
|||||||
@@ -271,7 +271,12 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
|||||||
synchronized (mNotifications) {
|
synchronized (mNotifications) {
|
||||||
IBinder key = new Binder();
|
IBinder key = new Binder();
|
||||||
mNotifications.add(key, notification);
|
mNotifications.add(key, notification);
|
||||||
// TODO: tell mBar
|
if (mBar != null) {
|
||||||
|
try {
|
||||||
|
mBar.addNotification(key, notification);
|
||||||
|
} catch (RemoteException ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -279,14 +284,24 @@ public class StatusBarManagerService extends IStatusBarService.Stub
|
|||||||
public void updateNotification(IBinder key, StatusBarNotification notification) {
|
public void updateNotification(IBinder key, StatusBarNotification notification) {
|
||||||
synchronized (mNotifications) {
|
synchronized (mNotifications) {
|
||||||
mNotifications.update(key, notification);
|
mNotifications.update(key, notification);
|
||||||
// TODO: tell mBar
|
if (mBar != null) {
|
||||||
|
try {
|
||||||
|
mBar.updateNotification(key, notification);
|
||||||
|
} catch (RemoteException ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeNotification(IBinder key) {
|
public void removeNotification(IBinder key) {
|
||||||
synchronized (mNotifications) {
|
synchronized (mNotifications) {
|
||||||
mNotifications.remove(key);
|
mNotifications.remove(key);
|
||||||
// TODO: tell mBar
|
if (mBar != null) {
|
||||||
|
try {
|
||||||
|
mBar.removeNotification(key);
|
||||||
|
} catch (RemoteException ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user