diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl index 852630dfa4433..23076696b4df0 100644 --- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl @@ -40,4 +40,5 @@ interface IStatusBarService void onNotificationError(String pkg, String tag, int id, int uid, int initialPid, String message); void onClearAllNotifications(); + void onNotificationClear(String pkg, String tag, int id); } diff --git a/core/res/res/drawable-hdpi/status_bar_item_background_normal.9.png b/core/res/res/drawable-hdpi/status_bar_item_background_normal.9.png index c01c018683f29..810c950ae43fd 100644 Binary files a/core/res/res/drawable-hdpi/status_bar_item_background_normal.9.png and b/core/res/res/drawable-hdpi/status_bar_item_background_normal.9.png differ diff --git a/core/res/res/drawable-mdpi/status_bar_item_background_normal.9.png b/core/res/res/drawable-mdpi/status_bar_item_background_normal.9.png index b8e399d9d514a..f0e4d068cbfee 100644 Binary files a/core/res/res/drawable-mdpi/status_bar_item_background_normal.9.png and b/core/res/res/drawable-mdpi/status_bar_item_background_normal.9.png differ diff --git a/core/res/res/layout-xlarge/status_bar_latest_event_content.xml b/core/res/res/layout-xlarge/status_bar_latest_event_content.xml new file mode 100644 index 0000000000000..c64b90ea1daa8 --- /dev/null +++ b/core/res/res/layout-xlarge/status_bar_latest_event_content.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + diff --git a/core/res/res/values-xlarge/styles.xml b/core/res/res/values-xlarge/styles.xml new file mode 100644 index 0000000000000..40e423e23be17 --- /dev/null +++ b/core/res/res/values-xlarge/styles.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + diff --git a/packages/SystemUI/res/drawable-hdpi/status_bar_veto_normal.png b/packages/SystemUI/res/drawable-hdpi/status_bar_veto_normal.png new file mode 100644 index 0000000000000..df532b844ea9d Binary files /dev/null and b/packages/SystemUI/res/drawable-hdpi/status_bar_veto_normal.png differ diff --git a/packages/SystemUI/res/drawable-hdpi/status_bar_veto_pressed.png b/packages/SystemUI/res/drawable-hdpi/status_bar_veto_pressed.png new file mode 100644 index 0000000000000..118c01bb12af1 Binary files /dev/null and b/packages/SystemUI/res/drawable-hdpi/status_bar_veto_pressed.png differ diff --git a/packages/SystemUI/res/drawable-mdpi/status_bar_veto_normal.png b/packages/SystemUI/res/drawable-mdpi/status_bar_veto_normal.png new file mode 100644 index 0000000000000..f9a7cc2d1a818 Binary files /dev/null and b/packages/SystemUI/res/drawable-mdpi/status_bar_veto_normal.png differ diff --git a/packages/SystemUI/res/drawable-mdpi/status_bar_veto_pressed.png b/packages/SystemUI/res/drawable-mdpi/status_bar_veto_pressed.png new file mode 100644 index 0000000000000..4461ac8ac9280 Binary files /dev/null and b/packages/SystemUI/res/drawable-mdpi/status_bar_veto_pressed.png differ diff --git a/packages/SystemUI/res/drawable/status_bar_veto.xml b/packages/SystemUI/res/drawable/status_bar_veto.xml new file mode 100644 index 0000000000000..6e1b68155b49f --- /dev/null +++ b/packages/SystemUI/res/drawable/status_bar_veto.xml @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/packages/SystemUI/res/layout-xlarge/status_bar_latest_event.xml b/packages/SystemUI/res/layout-xlarge/status_bar_latest_event.xml new file mode 100644 index 0000000000000..fa492d0788348 --- /dev/null +++ b/packages/SystemUI/res/layout-xlarge/status_bar_latest_event.xml @@ -0,0 +1,36 @@ + + + + + + + + + diff --git a/packages/SystemUI/res/layout-xlarge/sysbar_panel_notifications.xml b/packages/SystemUI/res/layout-xlarge/sysbar_panel_notifications.xml index 4a34f037e1d21..84a718a704486 100644 --- a/packages/SystemUI/res/layout-xlarge/sysbar_panel_notifications.xml +++ b/packages/SystemUI/res/layout-xlarge/sysbar_panel_notifications.xml @@ -19,14 +19,33 @@ --> - - + + + + + - - + diff --git a/packages/SystemUI/res/layout/status_bar_latest_event.xml b/packages/SystemUI/res/layout/status_bar_latest_event.xml deleted file mode 100644 index 88d973985d713..0000000000000 --- a/packages/SystemUI/res/layout/status_bar_latest_event.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - diff --git a/packages/SystemUI/res/values-xlarge/strings.xml b/packages/SystemUI/res/values-xlarge/strings.xml new file mode 100644 index 0000000000000..4aa4b4731939f --- /dev/null +++ b/packages/SystemUI/res/values-xlarge/strings.xml @@ -0,0 +1,23 @@ + + + + + Clear all + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java index 6bb5e8f2625aa..45abe930a380c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java @@ -54,6 +54,10 @@ public class NotificationData { return mEntries.size(); } + public Entry get(int i) { + return mEntries.get(i); + } + public Entry findByKey(IBinder key) { for (Entry e : mEntries) { if (e.key == key) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java index 9d643d850f198..b1c4ee3d9c536 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java @@ -37,6 +37,7 @@ import android.view.WindowManager; import android.graphics.Rect; import android.os.RemoteException; import android.view.WindowManagerImpl; +import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -59,18 +60,19 @@ public class TabletStatusBarService extends StatusBarService { H mHandler = new H(); - private View mNotificationPanel; - private View mSystemPanel; + View mNotificationPanel; + View mSystemPanel; - private NotificationIconArea.IconLayout mIconLayout; + ViewGroup mPile; + TextView mClearButton; - private NotificationData mHaps = new NotificationData(); + NotificationIconArea.IconLayout mIconLayout; + + private NotificationData mNotns = new NotificationData(); protected void addPanelWindows() { - if (mNotificationPanel == null) { - mNotificationPanel = View.inflate(this, R.layout.sysbar_panel_notifications, null); - mSystemPanel = View.inflate(this, R.layout.sysbar_panel_system, null); - } + mNotificationPanel = View.inflate(this, R.layout.sysbar_panel_notifications, null); + mSystemPanel = View.inflate(this, R.layout.sysbar_panel_system, null); mNotificationPanel.setVisibility(View.GONE); mSystemPanel.setVisibility(View.GONE); @@ -80,7 +82,7 @@ public class TabletStatusBarService extends StatusBarService { com.android.internal.R.dimen.status_bar_height); WindowManager.LayoutParams lp = new WindowManager.LayoutParams( - 300, // ViewGroup.LayoutParams.WRAP_CONTENT, + 400, // ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN @@ -112,10 +114,14 @@ public class TabletStatusBarService extends StatusBarService { WindowManagerImpl.getDefault().addView(mSystemPanel, lp); // Lorem ipsum, Dolores - TextView tv = ((TextView) mNotificationPanel.findViewById(R.id.notificationPanelDummy)); - if (tv != null) tv.setText("(You probably have new email)"); - tv = ((TextView) mSystemPanel.findViewById(R.id.systemPanelDummy)); + TextView tv = ((TextView) mSystemPanel.findViewById(R.id.systemPanelDummy)); if (tv != null) tv.setText("System status: great"); + + mPile = (ViewGroup)mNotificationPanel.findViewById(R.id.content); + mPile.removeAllViews(); + + mClearButton = (TextView)mNotificationPanel.findViewById(R.id.clear_all_button); + mClearButton.setOnClickListener(mClearButtonListener); } @Override @@ -196,7 +202,7 @@ public class TabletStatusBarService extends StatusBarService { public void updateNotification(IBinder key, StatusBarNotification notification) { if (DEBUG) Slog.d(TAG, "updateNotification(" + key + " -> " + notification + ") // TODO"); - final NotificationData.Entry oldEntry = mHaps.findByKey(key); + final NotificationData.Entry oldEntry = mNotns.findByKey(key); if (oldEntry == null) { Slog.w(TAG, "updateNotification for unknown key: " + key); return; @@ -285,6 +291,9 @@ public class TabletStatusBarService extends StatusBarService { public void notificationIconsClicked(View v) { if (DEBUG) Slog.d(TAG, "clicked notification icons"); + mHandler.removeMessages(H.MSG_CLOSE_SYSTEM_PANEL); + mHandler.sendEmptyMessage(H.MSG_CLOSE_SYSTEM_PANEL); + int msg = (mNotificationPanel.getVisibility() == View.GONE) ? H.MSG_OPEN_NOTIFICATION_PANEL : H.MSG_CLOSE_NOTIFICATION_PANEL; @@ -294,6 +303,9 @@ public class TabletStatusBarService extends StatusBarService { public void systemInfoClicked(View v) { if (DEBUG) Slog.d(TAG, "clicked system info"); + mHandler.removeMessages(H.MSG_CLOSE_NOTIFICATION_PANEL); + mHandler.sendEmptyMessage(H.MSG_CLOSE_NOTIFICATION_PANEL); + int msg = (mSystemPanel.getVisibility() == View.GONE) ? H.MSG_OPEN_SYSTEM_PANEL : H.MSG_CLOSE_SYSTEM_PANEL; @@ -313,6 +325,17 @@ public class TabletStatusBarService extends StatusBarService { } } + private View.OnClickListener mClearButtonListener = new View.OnClickListener() { + public void onClick(View v) { + try { + mBarService.onClearAllNotifications(); + } catch (RemoteException ex) { + // system process is dead if we're here. + } + animateCollapse(); + } + }; + private class NotificationClicker implements View.OnClickListener { private PendingIntent mIntent; private String mPkg; @@ -365,7 +388,7 @@ public class TabletStatusBarService extends StatusBarService { } StatusBarNotification removeNotificationViews(IBinder key) { - NotificationData.Entry entry = mHaps.remove(key); + NotificationData.Entry entry = mNotns.remove(key); if (entry == null) { Slog.w(TAG, "removeNotification for unknown key: " + key); return null; @@ -374,21 +397,16 @@ public class TabletStatusBarService extends StatusBarService { ViewGroup rowParent = (ViewGroup)entry.row.getParent(); if (rowParent != null) rowParent.removeView(entry.row); // Remove the icon. - ViewGroup iconParent = (ViewGroup)entry.icon.getParent(); - if (iconParent != null) iconParent.removeView(entry.icon); +// ViewGroup iconParent = (ViewGroup)entry.icon.getParent(); +// if (iconParent != null) iconParent.removeView(entry.icon); + refreshIcons(); return entry.notification; } StatusBarIconView addNotificationViews(IBinder key, StatusBarNotification notification) { - NotificationData list = mHaps; - ViewGroup parent = null; - final boolean isOngoing = notification.isOngoing(); - if (isOngoing) { -// parent = mOngoingItems; - } else { -// parent = mIconLayout; - } + NotificationData list = mNotns; + ViewGroup parent = mPile; // Construct the icon. final StatusBarIconView iconView = new StatusBarIconView(this, notification.pkg + "/0x" + Integer.toHexString(notification.id)); @@ -413,12 +431,27 @@ public class TabletStatusBarService extends StatusBarService { final int viewIndex = list.add(entry); if (parent != null) parent.addView(entry.row, viewIndex); // Add the icon. - final int iconIndex = 0; // XXX: sort into ongoing and regular buckets - mIconLayout.addView(iconView, iconIndex, - new LinearLayout.LayoutParams(mIconSize, mIconSize)); +// final int iconIndex = 0; // XXX: sort into ongoing and regular buckets +// mIconLayout.addView(iconView, iconIndex, +// new LinearLayout.LayoutParams(mIconSize, mIconSize)); + + refreshIcons(); + return iconView; } + private void refreshIcons() { + // XXX: need to implement a new limited linear layout class + // to avoid removing & readding everything + mIconLayout.removeAllViews(); + int N = mNotns.size(); + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(mIconSize, mIconSize); + for (int i=0; i<4; i++) { + if (i>=N) break; + mIconLayout.addView(mNotns.get(N-i-1).icon, i, params); + } + } + private boolean inflateViews(NotificationData.Entry entry, ViewGroup parent) { StatusBarNotification sbn = entry.notification; RemoteViews remoteViews = sbn.notification.contentView; @@ -429,6 +462,20 @@ public class TabletStatusBarService extends StatusBarService { // create the row view LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); View row = inflater.inflate(R.layout.status_bar_latest_event, parent, false); + View vetoButton = row.findViewById(R.id.veto); + final String _pkg = sbn.pkg; + final String _tag = sbn.tag; + final int _id = sbn.id; + vetoButton.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + try { + mBarService.onNotificationClear(_pkg, _tag, _id); + } catch (RemoteException ex) { + // system process is dead if we're here. + } +// animateCollapse(); + } + }); // bind the click event to the content area ViewGroup content = (ViewGroup)row.findViewById(R.id.content); diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java index 25de8b0c49b82..4f11231d49788 100755 --- a/services/java/com/android/server/NotificationManagerService.java +++ b/services/java/com/android/server/NotificationManagerService.java @@ -61,6 +61,7 @@ import android.util.Log; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import android.widget.Toast; +import android.widget.Toast; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -280,6 +281,10 @@ class NotificationManagerService extends INotificationManager.Stub Notification.FLAG_FOREGROUND_SERVICE); } + public void onNotificationClear(String pkg, String tag, int id) { + cancelNotification(pkg, tag, id, 0, 0); // maybe add some flags? + } + public void onPanelRevealed() { synchronized (mNotificationList) { // sound diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java index 4177432c9d37b..717c3098398b8 100644 --- a/services/java/com/android/server/StatusBarManagerService.java +++ b/services/java/com/android/server/StatusBarManagerService.java @@ -84,6 +84,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub void onSetDisabled(int status); void onClearAll(); void onNotificationClick(String pkg, String tag, int id); + void onNotificationClear(String pkg, String tag, int id); void onPanelRevealed(); void onNotificationError(String pkg, String tag, int id, int uid, int initialPid, String message); @@ -302,6 +303,12 @@ public class StatusBarManagerService extends IStatusBarService.Stub mNotificationCallbacks.onNotificationError(pkg, tag, id, uid, initialPid, message); } + public void onNotificationClear(String pkg, String tag, int id) { + enforceStatusBarService(); + + mNotificationCallbacks.onNotificationClear(pkg, tag, id); + } + public void onClearAllNotifications() { enforceStatusBarService();