Modify notification procedure.
Bug: 2733143
Change-Id: Id1982857288301f56f51a958b3176adecf45959b
diff --git a/src/com/android/contacts/vcard/ExportProcessor.java b/src/com/android/contacts/vcard/ExportProcessor.java
index 15f6fd8..6a3dd86 100644
--- a/src/com/android/contacts/vcard/ExportProcessor.java
+++ b/src/com/android/contacts/vcard/ExportProcessor.java
@@ -224,31 +224,35 @@
final Notification notification = new Notification();
notification.icon = android.R.drawable.stat_sys_upload;
notification.flags |= Notification.FLAG_ONGOING_EVENT;
-
+ notification.tickerText = title;
+
final RemoteViews remoteView = new RemoteViews(mService.getPackageName(),
R.layout.status_bar_ongoing_event_progress_bar);
remoteView.setTextViewText(R.id.description, message);
remoteView.setProgressBar(R.id.progress_bar, total, current, (total == -1));
+
final String percentage = mService.getString(R.string.percentage,
String.valueOf((current * 100)/total));
remoteView.setTextViewText(R.id.progress_text, percentage);
remoteView.setImageViewResource(R.id.appIcon, android.R.drawable.stat_sys_download);
notification.contentView = remoteView;
+ notification.setLatestEventInfo(mService, title, message, null);
final Intent intent = new Intent(mService, ContactsListActivity.class);
notification.contentIntent =
PendingIntent.getActivity(mService, 0, intent, 0);
-
+ PendingIntent.getActivity(mService, 0, intent, 0);
mNotificationManager.notify(VCardService.EXPORT_NOTIFICATION_ID, notification);
}
private void doFinishNotification(final String title, final String message) {
final Notification notification = new Notification();
notification.icon = android.R.drawable.stat_sys_upload_done;
+ notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.setLatestEventInfo(mService, title, message, null);
final Intent intent = new Intent(mService, ContactsListActivity.class);
notification.contentIntent =
PendingIntent.getActivity(mService, 0, intent, 0);
- mNotificationManager.notify(VCardService.IMPORT_NOTIFICATION_ID, notification);
+ mNotificationManager.notify(VCardService.EXPORT_NOTIFICATION_ID, notification);
}
}
\ No newline at end of file
diff --git a/src/com/android/contacts/vcard/ImportProcessor.java b/src/com/android/contacts/vcard/ImportProcessor.java
index be7d2ea..73d5dff 100644
--- a/src/com/android/contacts/vcard/ImportProcessor.java
+++ b/src/com/android/contacts/vcard/ImportProcessor.java
@@ -166,7 +166,7 @@
// Currenty we don't have an appropriate way to let users see all entries
// imported in this procedure. Instead, we show them entries only when
// there's just one created uri.
- doFinishNotification(mCreatedUris.size() == 1 ? mCreatedUris.get(0) : null);
+ doFinishNotification(mCreatedUris.size() > 0 ? mCreatedUris.get(0) : null);
} finally {
// TODO: verify this works fine.
mReadyForRequest = false; // Just in case.
@@ -233,6 +233,7 @@
private void doErrorNotification(int id) {
final Notification notification = new Notification();
notification.icon = android.R.drawable.stat_sys_download_done;
+ notification.flags |= Notification.FLAG_AUTO_CANCEL;
final String title = mService.getString(R.string.reading_vcard_failed_title);
final PendingIntent intent =
PendingIntent.getActivity(mService, 0, new Intent(), 0);
@@ -244,6 +245,8 @@
private void doFinishNotification(Uri createdUri) {
final Notification notification = new Notification();
notification.icon = android.R.drawable.stat_sys_download_done;
+ notification.flags |= Notification.FLAG_AUTO_CANCEL;
+
final String title = mService.getString(R.string.importing_vcard_finished_title);
final Intent intent;
diff --git a/src/com/android/contacts/vcard/ImportProgressNotifier.java b/src/com/android/contacts/vcard/ImportProgressNotifier.java
index db70218..e16980f 100644
--- a/src/com/android/contacts/vcard/ImportProgressNotifier.java
+++ b/src/com/android/contacts/vcard/ImportProgressNotifier.java
@@ -20,6 +20,7 @@
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
+import android.util.Log;
import android.widget.RemoteViews;
import com.android.contacts.ContactsListActivity;
@@ -56,9 +57,9 @@
// - We cannot know name there but here.
// - There's high probability where name comes soon after the beginning of entry, so
// we don't need to hurry to show something.
- final String packageName = "com.android.contacts.vcard";
- // TODO: should not create this everytime?
- final RemoteViews remoteViews = new RemoteViews(packageName,
+
+ // TODO: should not create this every time?
+ final RemoteViews remoteViews = new RemoteViews(mContext.getPackageName(),
R.layout.status_bar_ongoing_event_progress_bar);
final String title = mContext.getString(R.string.reading_vcard_title);
String totalCountString;
@@ -70,19 +71,21 @@
totalCountString,
contactStruct.getDisplayName());
- // TODO: uploading image does not work correctly. (looks like a static image).
remoteViews.setTextViewText(R.id.description, text);
remoteViews.setProgressBar(R.id.progress_bar, mTotalCount, mCurrentCount,
mTotalCount == -1);
final String percentage =
mContext.getString(R.string.percentage,
String.valueOf(mCurrentCount * 100/mTotalCount));
+
remoteViews.setTextViewText(R.id.progress_text, percentage);
remoteViews.setImageViewResource(R.id.appIcon, android.R.drawable.stat_sys_download);
final Notification notification = new Notification();
notification.icon = android.R.drawable.stat_sys_download;
+ notification.tickerText = text;
notification.flags |= Notification.FLAG_ONGOING_EVENT;
+
notification.contentView = remoteViews;
notification.contentIntent =