Use default Notification builder during vCard import
Bug: 5389192
Bug: 5143034
Change-Id: Iecb1d09b6c1dfa03513f197811a64064c23b2dc9
diff --git a/res/layout/status_bar_ongoing_event_progress_bar.xml b/res/layout/status_bar_ongoing_event_progress_bar.xml
deleted file mode 100644
index e3edf95..0000000
--- a/res/layout/status_bar_ongoing_event_progress_bar.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
- * Copyright 2010, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- /
-TODO: This is copied from DownloadProvider, and looks similar to Bluetooth's.
- It might be better to have this in framework.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:background="@android:drawable/status_bar_item_app_background"
- >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal"
- >
- <LinearLayout
- android:layout_width="40dp"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:paddingTop="8dp"
- android:focusable="true"
- >
- <ImageView
- android:id="@+id/status_icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:src="@android:drawable/sym_def_app_icon"
- />
- <TextView android:id="@+id/status_progress_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textColor="#ff000000"
- android:singleLine="true"
- android:textSize="14sp"
- android:layout_gravity="center_horizontal" />
- </LinearLayout>
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:focusable="true">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:focusable="true"
- android:layout_alignParentTop="true"
- android:paddingTop="10dp">
- <TextView android:id="@+id/status_description"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textColor="?android:attr/textColorPrimary"
- android:singleLine="true"
- 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" />
- </RelativeLayout>
- </LinearLayout>
-
- <ImageView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:src="@android:drawable/divider_horizontal_bright"
- />
-</LinearLayout>
-
diff --git a/src/com/android/contacts/vcard/NotificationImportExportListener.java b/src/com/android/contacts/vcard/NotificationImportExportListener.java
index fb83cec..06cf73f 100644
--- a/src/com/android/contacts/vcard/NotificationImportExportListener.java
+++ b/src/com/android/contacts/vcard/NotificationImportExportListener.java
@@ -197,30 +197,6 @@
/* package */ static Notification constructProgressNotification(
Context context, int type, String description, String tickerText,
int jobId, String displayName, int totalCount, int currentCount) {
- final RemoteViews remoteViews =
- new RemoteViews(context.getPackageName(),
- R.layout.status_bar_ongoing_event_progress_bar);
- remoteViews.setTextViewText(R.id.status_description, description);
- remoteViews.setProgressBar(R.id.status_progress_bar, totalCount, currentCount,
- totalCount == -1);
- final String percentage;
- if (totalCount > 0) {
- percentage = context.getString(R.string.percentage,
- String.valueOf(currentCount * 100/totalCount));
- } else {
- percentage = "";
- }
- remoteViews.setTextViewText(R.id.status_progress_text, percentage);
- final int icon = (type == VCardService.TYPE_IMPORT ? android.R.drawable.stat_sys_download :
- android.R.drawable.stat_sys_upload);
- remoteViews.setImageViewResource(R.id.status_icon, icon);
-
- final Notification notification = new Notification();
- notification.icon = icon;
- notification.tickerText = tickerText;
- notification.contentView = remoteViews;
- notification.flags |= Notification.FLAG_ONGOING_EVENT;
-
// Note: We cannot use extra values here (like setIntExtra()), as PendingIntent doesn't
// preserve them across multiple Notifications. PendingIntent preserves the first extras
// (when flag is not set), or update them when PendingIntent#getActivity() is called
@@ -238,8 +214,20 @@
.appendQueryParameter(CancelActivity.TYPE, String.valueOf(type)).build();
intent.setData(uri);
- notification.contentIntent = PendingIntent.getActivity(context, 0, intent, 0);
- return notification;
+ final Notification.Builder builder = new Notification.Builder(context);
+ builder.setOngoing(true)
+ .setProgress(totalCount, currentCount, totalCount == - 1)
+ .setTicker(tickerText)
+ .setContentTitle(description)
+ .setSmallIcon(type == VCardService.TYPE_IMPORT
+ ? android.R.drawable.stat_sys_download
+ : android.R.drawable.stat_sys_upload)
+ .setContentIntent(PendingIntent.getActivity(context, 0, intent, 0));
+ if (totalCount > 0) {
+ builder.setContentText(context.getString(R.string.percentage,
+ String.valueOf(currentCount * 100 / totalCount)));
+ }
+ return builder.getNotification();
}
/**