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
This commit is contained in:
Gabriele M
2018-06-10 16:44:44 +02:00
parent acab307e82
commit b9c9037c34
3 changed files with 37 additions and 12 deletions

View File

@@ -0,0 +1,9 @@
<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>

View File

@@ -141,7 +141,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());

View File

@@ -233,6 +233,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);
@@ -243,7 +245,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);
@@ -259,7 +263,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);
@@ -277,7 +283,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);
@@ -290,6 +298,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);
@@ -299,10 +309,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);
@@ -312,10 +323,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);
@@ -325,6 +337,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() ?
@@ -340,10 +354,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());
@@ -356,10 +371,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);