OSDN Git Service

Clear notifications when the user presses clear from the notifications bar.
authorLixin Yue <L.X.YUE@motorola.com>
Fri, 26 Mar 2010 01:27:20 +0000 (09:27 +0800)
committerJaikumar Ganesh <jaikumar@google.com>
Wed, 31 Mar 2010 17:52:56 +0000 (10:52 -0700)
Bug: 2542260
Change-Id: I00f9d8216d70543b93cfbcdb2cd8da8331044d77

src/com/android/bluetooth/opp/BluetoothOppNotification.java
src/com/android/bluetooth/opp/BluetoothOppReceiver.java
src/com/android/bluetooth/opp/Constants.java

index 3a034c8..310a289 100644 (file)
@@ -353,6 +353,9 @@ class BluetoothOppNotification {
             intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName());
             outNoti.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast(
                     mContext, 0, intent, 0));
+            intent = new Intent(Constants.ACTION_COMPLETE_HIDE);
+            intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName());
+            outNoti.deleteIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
             outNoti.when = timeStamp;
             mNotificationMgr.notify(NOTIFICATION_ID_OUTBOUND, outNoti);
         } else {
@@ -397,6 +400,9 @@ class BluetoothOppNotification {
             intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName());
             inNoti.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast(
                     mContext, 0, intent, 0));
+            intent = new Intent(Constants.ACTION_COMPLETE_HIDE);
+            intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName());
+            inNoti.deleteIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
             inNoti.when = timeStamp;
             mNotificationMgr.notify(NOTIFICATION_ID_INBOUND, inNoti);
         } else {
index 8700390..98800d4 100644 (file)
@@ -196,7 +196,7 @@ public class BluetoothOppReceiver extends BroadcastReceiver {
                     int userConfirmationColumn = cursor
                             .getColumnIndexOrThrow(BluetoothShare.USER_CONFIRMATION);
                     int userConfirmation = cursor.getInt(userConfirmationColumn);
-                    if ((BluetoothShare.isStatusCompleted(status) || (userConfirmation == BluetoothShare.USER_CONFIRMATION_PENDING))
+                    if (((userConfirmation == BluetoothShare.USER_CONFIRMATION_PENDING))
                             && visibility == BluetoothShare.VISIBILITY_VISIBLE) {
                         ContentValues values = new ContentValues();
                         values.put(BluetoothShare.VISIBILITY, BluetoothShare.VISIBILITY_HIDDEN);
@@ -206,6 +206,12 @@ public class BluetoothOppReceiver extends BroadcastReceiver {
                 }
                 cursor.close();
             }
+        } else if (action.equals(Constants.ACTION_COMPLETE_HIDE)) {
+            if (V) Log.v(TAG, "Receiver ACTION_COMPLETE_HIDE");
+            ContentValues updateValues = new ContentValues();
+            updateValues.put(BluetoothShare.VISIBILITY, BluetoothShare.VISIBILITY_HIDDEN);
+            context.getContentResolver().update(BluetoothShare.CONTENT_URI, updateValues,
+                    BluetoothOppNotification.WHERE_COMPLETED, null);
         } else if (action.equals(BluetoothShare.TRANSFER_COMPLETED_ACTION)) {
             if (V) Log.v(TAG, "Receiver Transfer Complete Intent for " + intent.getData());
 
index a07eef2..582b825 100644 (file)
@@ -69,12 +69,18 @@ public class Constants {
     public static final String ACTION_LIST = "android.btopp.intent.action.LIST";
 
     /**
-     * the intent that gets sent when deleting the notification of a completed
-     * transfer
+     * the intent that gets sent when deleting the incoming file confirmation
+     * notification
      */
     public static final String ACTION_HIDE = "android.btopp.intent.action.HIDE";
 
     /**
+     * the intent that gets sent when deleting the notifications of outbound and
+     * inbound completed transfer
+     */
+    public static final String ACTION_COMPLETE_HIDE = "android.btopp.intent.action.HIDE_COMPLETE";
+
+    /**
      * the intent that gets sent when clicking a incoming file confirm
      * notification
      */