From ec6f2d44491bf1e3ffa7c75875985f9c16cf721d Mon Sep 17 00:00:00 2001 From: Lixin Yue Date: Fri, 26 Mar 2010 09:27:20 +0800 Subject: [PATCH] Clear notifications when the user presses clear from the notifications bar. Bug: 2542260 Change-Id: I00f9d8216d70543b93cfbcdb2cd8da8331044d77 --- src/com/android/bluetooth/opp/BluetoothOppNotification.java | 6 ++++++ src/com/android/bluetooth/opp/BluetoothOppReceiver.java | 8 +++++++- src/com/android/bluetooth/opp/Constants.java | 10 ++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/com/android/bluetooth/opp/BluetoothOppNotification.java b/src/com/android/bluetooth/opp/BluetoothOppNotification.java index 3a034c83..310a289a 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppNotification.java +++ b/src/com/android/bluetooth/opp/BluetoothOppNotification.java @@ -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 { diff --git a/src/com/android/bluetooth/opp/BluetoothOppReceiver.java b/src/com/android/bluetooth/opp/BluetoothOppReceiver.java index 87003907..98800d47 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppReceiver.java +++ b/src/com/android/bluetooth/opp/BluetoothOppReceiver.java @@ -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()); diff --git a/src/com/android/bluetooth/opp/Constants.java b/src/com/android/bluetooth/opp/Constants.java index a07eef21..582b8251 100644 --- a/src/com/android/bluetooth/opp/Constants.java +++ b/src/com/android/bluetooth/opp/Constants.java @@ -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 */ -- 2.11.0