Use rich format for showing the progress of vCard import.
Use a custom layout file for showing the progress by Progress Bar.
Change-Id: Iab64549414050cd627cb9a5617581304b3f2fd26
diff --git a/res/layout/status_bar_ongoing_event_progress_bar.xml b/res/layout/status_bar_ongoing_event_progress_bar.xml
index 5eb4e9d..3c7530a 100644
--- a/res/layout/status_bar_ongoing_event_progress_bar.xml
+++ b/res/layout/status_bar_ongoing_event_progress_bar.xml
@@ -37,9 +37,8 @@
android:orientation="vertical"
android:paddingTop="8dp"
android:focusable="true"
- android:clickable="true"
>
- <com.android.contacts.vcard.AnimatedImageView
+ <ImageView
android:id="@+id/status_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -52,59 +51,44 @@
android:textColor="#ff000000"
android:singleLine="true"
android:textSize="14sp"
- android:layout_gravity="center_horizontal"
- />
+ android:layout_gravity="center_horizontal" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:focusable="true"
- android:clickable="true"
- >
+ android:focusable="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:focusable="true"
- android:clickable="true"
android:layout_alignParentTop="true"
- android:paddingTop="10dp"
- >
- <TextView android:id="@+id/status_title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textSize="18sp"
- android:textColor="#ff000000"
- android:paddingLeft="2dp"
- />
+ android:paddingTop="10dp">
<TextView android:id="@+id/status_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff000000"
android:singleLine="true"
- android:textSize="14sp"
- android:paddingLeft="5dp"
- />
+ android:textSize="18sp"
+ android:paddingLeft="5dp" />
</LinearLayout>
- <ProgressBar android:id="@+id/status_progress_bar"
- style="?android:attr/progressBarStyleHorizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:paddingBottom="8dp"
- android:paddingRight="25dp"
- />
+ <ProgressBar
+ android:id="@+id/status_progress_bar"
+ style="?android:attr/progressBarStyleHorizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:paddingBottom="8dp"
+ android:paddingRight="25dp" />
</RelativeLayout>
</LinearLayout>
-
- <com.android.contacts.vcard.AnimatedImageView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:src="@android:drawable/divider_horizontal_bright"
- />
+ <ImageView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:src="@android:drawable/divider_horizontal_bright"
+ />
</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 100dcc4..5bdfdf8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -755,11 +755,12 @@
<!-- The message shown while importing vCard(s).
First argument is current index of contacts to be imported.
Second argument is the total number of contacts.
- Third argument is the Uri which is being read. -->
- <string name="progress_notifier_message"><xliff:g id="current_number">%s</xliff:g>/<xliff:g id="total_number">%s</xliff:g>: <xliff:g id="filename" example="foo.vcf">%s</xliff:g></string>
+ Third argument is the name of a contact which is being read. -->
+ <string name="progress_notifier_message">Importing <xliff:g id="current_number">%s</xliff:g>/<xliff:g id="total_number">%s</xliff:g>: <xliff:g id="name" example="Joe Due">%s</xliff:g></string>
- <!-- Dialog title shown when reading vCard data -->
- <string name="reading_vcard_title">Reading vCard(s)</string>
+ <!-- Description shown when importing vCard data.
+ The argument is the name of a contact which is being read. -->
+ <string name="importing_vcard_description">Importing <xliff:g id="name" example="Joe Due">%s</xliff:g></string>
<!-- Dialog title shown when reading vCard data failed -->
<string name="reading_vcard_failed_title">Failed to Read vCard data</string>
diff --git a/src/com/android/contacts/vcard/ImportProgressNotifier.java b/src/com/android/contacts/vcard/ImportProgressNotifier.java
index ad88f64..286bb43 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.widget.RemoteViews;
import com.android.contacts.R;
import com.android.contacts.activities.ContactBrowserActivity;
@@ -56,24 +57,25 @@
// - 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 title = mContext.getString(R.string.reading_vcard_title);
- String totalCountString;
+ final String totalCountString;
synchronized (this) {
totalCountString = String.valueOf(mTotalCount);
}
- final String description = mContext.getString(R.string.progress_notifier_message,
- String.valueOf(mCurrentCount),
- totalCountString,
- contactStruct.getDisplayName());
+ final String tickerText =
+ mContext.getString(R.string.progress_notifier_message,
+ String.valueOf(mCurrentCount),
+ totalCountString,
+ contactStruct.getDisplayName());
+
final Context context = mContext.getApplicationContext();
- /* TODO: fix this.
+ final String description = mContext.getString(R.string.importing_vcard_description,
+ contactStruct.getDisplayName());
final RemoteViews remoteViews =
new RemoteViews(context.getPackageName(),
R.layout.status_bar_ongoing_event_progress_bar);
- remoteViews.setTextViewText(R.id.status_title, title);
remoteViews.setTextViewText(R.id.status_description, description);
remoteViews.setProgressBar(R.id.status_progress_bar, mTotalCount, mCurrentCount,
mTotalCount == -1);
@@ -89,23 +91,17 @@
final Notification notification = new Notification();
notification.icon = android.R.drawable.stat_sys_download;
- notification.tickerText = description;
+ notification.tickerText = tickerText;
+ notification.contentView = remoteViews;
notification.flags |= Notification.FLAG_ONGOING_EVENT;
- notification.tickerText = description;
- notification.contentView = remoteViews;*/
-
- final long when = System.currentTimeMillis();
- final Notification notification = new Notification(
- android.R.drawable.stat_sys_download,
- description,
- when);
final PendingIntent pendingIntent =
PendingIntent.getActivity(context, 0,
new Intent(context, ContactBrowserActivity.class),
PendingIntent.FLAG_UPDATE_CURRENT);
- notification.setLatestEventInfo(context, title, description, pendingIntent);
+ notification.contentIntent = pendingIntent;
+ // notification.setLatestEventInfo(context, title, description, pendingIntent);
mNotificationManager.notify(VCardService.IMPORT_NOTIFICATION_ID, notification);
}