Merge "Uses a tag for vCard-related notifications."
diff --git a/src/com/android/contacts/vcard/ExportProcessor.java b/src/com/android/contacts/vcard/ExportProcessor.java
index e9697d3..6dc2c34 100644
--- a/src/com/android/contacts/vcard/ExportProcessor.java
+++ b/src/com/android/contacts/vcard/ExportProcessor.java
@@ -237,7 +237,7 @@
final Notification notification =
VCardService.constructProgressNotification(mService, VCardService.TYPE_EXPORT,
description, tickerText, mJobId, displayName, totalCount, currentCount);
- mNotificationManager.notify(mJobId, notification);
+ mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mJobId, notification);
}
private void doCancelNotification() {
@@ -246,7 +246,7 @@
mExportRequest.destUri.getLastPathSegment());
final Notification notification =
VCardService.constructCancelNotification(mService, description);
- mNotificationManager.notify(mJobId, notification);
+ mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mJobId, notification);
}
private void doFinishNotification(final String title, final String description) {
@@ -254,7 +254,7 @@
final Intent intent = new Intent(mService, PeopleActivity.class);
final Notification notification =
VCardService.constructFinishNotification(mService, title, description, intent);
- mNotificationManager.notify(mJobId, notification);
+ mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mJobId, notification);
}
@Override
diff --git a/src/com/android/contacts/vcard/ImportProcessor.java b/src/com/android/contacts/vcard/ImportProcessor.java
index 4ea1ead..1f5779a 100644
--- a/src/com/android/contacts/vcard/ImportProcessor.java
+++ b/src/com/android/contacts/vcard/ImportProcessor.java
@@ -180,7 +180,7 @@
mImportRequest.originalUri.getLastPathSegment());
final Notification notification =
VCardService.constructCancelNotification(mService, description);
- mNotificationManager.notify(mJobId, notification);
+ mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mJobId, notification);
}
private void doFinishNotification(final Uri createdUri) {
@@ -199,7 +199,7 @@
final Notification notification =
VCardService.constructFinishNotification(mService,
description, null, intent);
- mNotificationManager.notify(mJobId, notification);
+ mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mJobId, notification);
}
private boolean readOneVCard(Uri uri, int vcardType, String charset,
diff --git a/src/com/android/contacts/vcard/ImportProgressNotifier.java b/src/com/android/contacts/vcard/ImportProgressNotifier.java
index d6d0f3f..698487d 100644
--- a/src/com/android/contacts/vcard/ImportProgressNotifier.java
+++ b/src/com/android/contacts/vcard/ImportProgressNotifier.java
@@ -71,7 +71,7 @@
final Notification notification = VCardService.constructProgressNotification(
mContext.getApplicationContext(), VCardService.TYPE_IMPORT, description, tickerText,
mJobId, mDisplayName, mTotalCount, mCurrentCount);
- mNotificationManager.notify(mJobId, notification);
+ mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mJobId, notification);
}
public synchronized void addTotalCount(int additionalCount) {
diff --git a/src/com/android/contacts/vcard/ImportVCardActivity.java b/src/com/android/contacts/vcard/ImportVCardActivity.java
index 1397dd7..2cfd71a 100644
--- a/src/com/android/contacts/vcard/ImportVCardActivity.java
+++ b/src/com/android/contacts/vcard/ImportVCardActivity.java
@@ -107,7 +107,7 @@
/**
* Notification id used when error happened before sending an import request to VCardServer.
*/
- private static final int DEFAULT_NOTIFICATION_ID = 1000;
+ private static final int FAILURE_NOTIFICATION_ID = 1;
final static String CACHED_URIS = "cached_uris";
@@ -974,7 +974,8 @@
VCardService.constructImportFailureNotification(
ImportVCardActivity.this,
getString(reasonId));
- notificationManager.notify(DEFAULT_NOTIFICATION_ID, notification);
+ notificationManager.notify(VCardService.FAILURE_NOTIFICATION_TAG, FAILURE_NOTIFICATION_ID,
+ notification);
mHandler.post(new Runnable() {
@Override
public void run() {
diff --git a/src/com/android/contacts/vcard/VCardService.java b/src/com/android/contacts/vcard/VCardService.java
index e927757..261c1c8 100644
--- a/src/com/android/contacts/vcard/VCardService.java
+++ b/src/com/android/contacts/vcard/VCardService.java
@@ -59,6 +59,17 @@
// works fine enough. Investigate the feasibility.
public class VCardService extends Service {
private final static String LOG_TAG = "VCardService";
+
+ /** The tag used by vCard-related notifications. */
+ /* package */ static final String DEFAULT_NOTIFICATION_TAG = "VCardServiceProgress";
+ /**
+ * The tag used by vCard-related failure notifications.
+ * <p>
+ * Use a different tag from {@link #DEFAULT_NOTIFICATION_TAG} so that failures do not get
+ * replaced by other notifications and vice-versa.
+ */
+ /* package */ static final String FAILURE_NOTIFICATION_TAG = "VCardServiceFailure";
+
/* package */ final static boolean DEBUG = false;
/* package */ static final int MSG_IMPORT_REQUEST = 1;
@@ -153,6 +164,7 @@
/* ** vCard exporter params ** */
// If true, VCardExporter is able to emits files longer than 8.3 format.
private static final boolean ALLOW_LONG_FILE_NAME = false;
+
private String mTargetDirectory;
private String mFileNamePrefix;
private String mFileNameSuffix;
@@ -258,7 +270,8 @@
constructProgressNotification(
this, TYPE_IMPORT, message, message, mCurrentJobId,
displayName, -1, 0);
- mNotificationManager.notify(mCurrentJobId, notification);
+ mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mCurrentJobId,
+ notification);
mCurrentJobId++;
} else {
// TODO: a little unkind to show Toast in this case, which is shown just a moment.
@@ -292,7 +305,7 @@
final Notification notification =
constructProgressNotification(this, TYPE_EXPORT, message, message,
mCurrentJobId, displayName, -1, 0);
- mNotificationManager.notify(mCurrentJobId, notification);
+ mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mCurrentJobId, notification);
mCurrentJobId++;
} else {
Toast.makeText(this, getString(R.string.vcard_export_request_rejected_message),
@@ -330,7 +343,7 @@
getString(R.string.importing_vcard_canceled_title, request.displayName) :
getString(R.string.exporting_vcard_canceled_title, request.displayName);
final Notification notification = constructCancelNotification(this, description);
- mNotificationManager.notify(jobId, notification);
+ mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, jobId, notification);
if (processor.getType() == TYPE_EXPORT) {
final String path =
((ExportProcessor)processor).getRequest().destUri.getEncodedPath();