Commit 0332be5e authored by Gabriele M's avatar Gabriele M

Minor app notification improvements

- Don't use BigTextStyle if we only need to show a single line of
  text, but keep using it if the progressbar is visible.
- Change the icon to reflect the currrent state.
- Use android.R.drawable instead of com.android.internal.R.drawable

Change-Id: I0f69fe5f4fa63cdec180e89afa098d27819f33fd
parent ce4b0269
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M6,19h4L10,5L6,5v14zM14,5v14h4L18,5h-4z" />
</vector>
......@@ -151,7 +151,7 @@ public class ExportUpdateService extends Service {
notificationStyle.bigText(destination.getName());
notificationBuilder.setStyle(notificationStyle);
notificationBuilder.setSmallIcon(R.drawable.ic_system_update);
notificationBuilder.addAction(com.android.internal.R.drawable.ic_media_pause,
notificationBuilder.addAction(android.R.drawable.ic_media_pause,
getString(android.R.string.cancel),
getStopPendingIntent());
......
......@@ -243,6 +243,8 @@ public class UpdaterService extends Service {
mNotificationStyle.setSummaryText(null);
String text = getString(R.string.download_starting_notification);
mNotificationStyle.bigText(text);
mNotificationBuilder.setStyle(mNotificationStyle);
mNotificationBuilder.setSmallIcon(android.R.drawable.stat_sys_download);
mNotificationBuilder.setTicker(text);
mNotificationBuilder.setOngoing(true);
mNotificationBuilder.setAutoCancel(false);
......@@ -253,7 +255,9 @@ public class UpdaterService extends Service {
case DOWNLOADING: {
String text = getString(R.string.downloading_notification);
mNotificationStyle.bigText(text);
mNotificationBuilder.addAction(com.android.internal.R.drawable.ic_media_pause,
mNotificationBuilder.setStyle(mNotificationStyle);
mNotificationBuilder.setSmallIcon(android.R.drawable.stat_sys_download);
mNotificationBuilder.addAction(android.R.drawable.ic_media_pause,
getString(R.string.pause_button),
getPausePendingIntent(update.getDownloadId()));
mNotificationBuilder.setTicker(text);
......@@ -269,7 +273,9 @@ public class UpdaterService extends Service {
mNotificationBuilder.mActions.clear();
String text = getString(R.string.download_paused_notification);
mNotificationStyle.bigText(text);
mNotificationBuilder.addAction(com.android.internal.R.drawable.ic_media_play,
mNotificationBuilder.setStyle(mNotificationStyle);
mNotificationBuilder.setSmallIcon(R.drawable.ic_pause);
mNotificationBuilder.addAction(android.R.drawable.ic_media_play,
getString(R.string.resume_button),
getResumePendingIntent(update.getDownloadId()));
mNotificationBuilder.setTicker(text);
......@@ -287,7 +293,9 @@ public class UpdaterService extends Service {
mNotificationBuilder.mActions.clear();
String text = getString(R.string.download_paused_error_notification);
mNotificationStyle.bigText(text);
mNotificationBuilder.addAction(com.android.internal.R.drawable.ic_media_play,
mNotificationBuilder.setStyle(mNotificationStyle);
mNotificationBuilder.setSmallIcon(android.R.drawable.stat_sys_warning);
mNotificationBuilder.addAction(android.R.drawable.ic_media_play,
getString(R.string.resume_button),
getResumePendingIntent(update.getDownloadId()));
mNotificationBuilder.setTicker(text);
......@@ -300,6 +308,8 @@ public class UpdaterService extends Service {
case VERIFYING: {
mNotificationBuilder.setProgress(0, 0, true);
mNotificationStyle.setSummaryText(null);
mNotificationBuilder.setStyle(mNotificationStyle);
mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update);
mNotificationBuilder.mActions.clear();
String text = getString(R.string.verifying_download_notification);
mNotificationStyle.bigText(text);
......@@ -309,10 +319,11 @@ public class UpdaterService extends Service {
}
case VERIFIED: {
stopForeground(STOP_FOREGROUND_DETACH);
mNotificationStyle.setSummaryText(null);
mNotificationBuilder.setStyle(null);
mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update);
mNotificationBuilder.setProgress(0, 0, false);
String text = getString(R.string.download_completed_notification);
mNotificationStyle.bigText(text);
mNotificationBuilder.setContentText(text);
mNotificationBuilder.setTicker(text);
mNotificationBuilder.setOngoing(false);
mNotificationBuilder.setAutoCancel(true);
......@@ -322,10 +333,11 @@ public class UpdaterService extends Service {
}
case VERIFICATION_FAILED: {
stopForeground(STOP_FOREGROUND_DETACH);
mNotificationStyle.setSummaryText(null);
mNotificationBuilder.setStyle(null);
mNotificationBuilder.setSmallIcon(android.R.drawable.stat_sys_warning);
mNotificationBuilder.setProgress(0, 0, false);
String text = getString(R.string.verification_failed_notification);
mNotificationStyle.bigText(text);
mNotificationBuilder.setContentText(text);
mNotificationBuilder.setTicker(text);
mNotificationBuilder.setOngoing(false);
mNotificationBuilder.setAutoCancel(true);
......@@ -335,6 +347,8 @@ public class UpdaterService extends Service {
}
case INSTALLING: {
mNotificationBuilder.mActions.clear();
mNotificationBuilder.setStyle(mNotificationStyle);
mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update);
mNotificationBuilder.setProgress(0, 0, false);
mNotificationStyle.setSummaryText(null);
String text = UpdateInstaller.isInstalling() ?
......@@ -350,10 +364,11 @@ public class UpdaterService extends Service {
}
case INSTALLED: {
stopForeground(STOP_FOREGROUND_DETACH);
mNotificationStyle.setSummaryText(null);
mNotificationBuilder.setStyle(null);
mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update);
mNotificationBuilder.setProgress(0, 0, false);
String text = getString(R.string.installing_update_finished);
mNotificationStyle.bigText(text);
mNotificationBuilder.setContentText(text);
mNotificationBuilder.addAction(R.drawable.ic_system_update,
getString(R.string.reboot),
getRebootPendingIntent());
......@@ -366,10 +381,11 @@ public class UpdaterService extends Service {
}
case INSTALLATION_FAILED: {
stopForeground(STOP_FOREGROUND_DETACH);
mNotificationStyle.setSummaryText(null);
mNotificationBuilder.setStyle(null);
mNotificationBuilder.setSmallIcon(android.R.drawable.stat_sys_warning);
mNotificationBuilder.setProgress(0, 0, false);
String text = getString(R.string.installing_update_error);
mNotificationStyle.bigText(text);
mNotificationBuilder.setContentText(text);
mNotificationBuilder.setTicker(text);
mNotificationBuilder.setOngoing(false);
mNotificationBuilder.setAutoCancel(true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment