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:
9
res/drawable/ic_pause.xml
Normal file
9
res/drawable/ic_pause.xml
Normal 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>
|
@@ -151,7 +151,7 @@ public class ExportUpdateService extends Service {
|
|||||||
notificationStyle.bigText(destination.getName());
|
notificationStyle.bigText(destination.getName());
|
||||||
notificationBuilder.setStyle(notificationStyle);
|
notificationBuilder.setStyle(notificationStyle);
|
||||||
notificationBuilder.setSmallIcon(R.drawable.ic_system_update);
|
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),
|
getString(android.R.string.cancel),
|
||||||
getStopPendingIntent());
|
getStopPendingIntent());
|
||||||
|
|
||||||
|
@@ -243,6 +243,8 @@ public class UpdaterService extends Service {
|
|||||||
mNotificationStyle.setSummaryText(null);
|
mNotificationStyle.setSummaryText(null);
|
||||||
String text = getString(R.string.download_starting_notification);
|
String text = getString(R.string.download_starting_notification);
|
||||||
mNotificationStyle.bigText(text);
|
mNotificationStyle.bigText(text);
|
||||||
|
mNotificationBuilder.setStyle(mNotificationStyle);
|
||||||
|
mNotificationBuilder.setSmallIcon(android.R.drawable.stat_sys_download);
|
||||||
mNotificationBuilder.setTicker(text);
|
mNotificationBuilder.setTicker(text);
|
||||||
mNotificationBuilder.setOngoing(true);
|
mNotificationBuilder.setOngoing(true);
|
||||||
mNotificationBuilder.setAutoCancel(false);
|
mNotificationBuilder.setAutoCancel(false);
|
||||||
@@ -253,7 +255,9 @@ public class UpdaterService extends Service {
|
|||||||
case DOWNLOADING: {
|
case DOWNLOADING: {
|
||||||
String text = getString(R.string.downloading_notification);
|
String text = getString(R.string.downloading_notification);
|
||||||
mNotificationStyle.bigText(text);
|
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),
|
getString(R.string.pause_button),
|
||||||
getPausePendingIntent(update.getDownloadId()));
|
getPausePendingIntent(update.getDownloadId()));
|
||||||
mNotificationBuilder.setTicker(text);
|
mNotificationBuilder.setTicker(text);
|
||||||
@@ -269,7 +273,9 @@ public class UpdaterService extends Service {
|
|||||||
mNotificationBuilder.mActions.clear();
|
mNotificationBuilder.mActions.clear();
|
||||||
String text = getString(R.string.download_paused_notification);
|
String text = getString(R.string.download_paused_notification);
|
||||||
mNotificationStyle.bigText(text);
|
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),
|
getString(R.string.resume_button),
|
||||||
getResumePendingIntent(update.getDownloadId()));
|
getResumePendingIntent(update.getDownloadId()));
|
||||||
mNotificationBuilder.setTicker(text);
|
mNotificationBuilder.setTicker(text);
|
||||||
@@ -287,7 +293,9 @@ public class UpdaterService extends Service {
|
|||||||
mNotificationBuilder.mActions.clear();
|
mNotificationBuilder.mActions.clear();
|
||||||
String text = getString(R.string.download_paused_error_notification);
|
String text = getString(R.string.download_paused_error_notification);
|
||||||
mNotificationStyle.bigText(text);
|
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),
|
getString(R.string.resume_button),
|
||||||
getResumePendingIntent(update.getDownloadId()));
|
getResumePendingIntent(update.getDownloadId()));
|
||||||
mNotificationBuilder.setTicker(text);
|
mNotificationBuilder.setTicker(text);
|
||||||
@@ -300,6 +308,8 @@ public class UpdaterService extends Service {
|
|||||||
case VERIFYING: {
|
case VERIFYING: {
|
||||||
mNotificationBuilder.setProgress(0, 0, true);
|
mNotificationBuilder.setProgress(0, 0, true);
|
||||||
mNotificationStyle.setSummaryText(null);
|
mNotificationStyle.setSummaryText(null);
|
||||||
|
mNotificationBuilder.setStyle(mNotificationStyle);
|
||||||
|
mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update);
|
||||||
mNotificationBuilder.mActions.clear();
|
mNotificationBuilder.mActions.clear();
|
||||||
String text = getString(R.string.verifying_download_notification);
|
String text = getString(R.string.verifying_download_notification);
|
||||||
mNotificationStyle.bigText(text);
|
mNotificationStyle.bigText(text);
|
||||||
@@ -309,10 +319,11 @@ public class UpdaterService extends Service {
|
|||||||
}
|
}
|
||||||
case VERIFIED: {
|
case VERIFIED: {
|
||||||
stopForeground(STOP_FOREGROUND_DETACH);
|
stopForeground(STOP_FOREGROUND_DETACH);
|
||||||
mNotificationStyle.setSummaryText(null);
|
mNotificationBuilder.setStyle(null);
|
||||||
|
mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update);
|
||||||
mNotificationBuilder.setProgress(0, 0, false);
|
mNotificationBuilder.setProgress(0, 0, false);
|
||||||
String text = getString(R.string.download_completed_notification);
|
String text = getString(R.string.download_completed_notification);
|
||||||
mNotificationStyle.bigText(text);
|
mNotificationBuilder.setContentText(text);
|
||||||
mNotificationBuilder.setTicker(text);
|
mNotificationBuilder.setTicker(text);
|
||||||
mNotificationBuilder.setOngoing(false);
|
mNotificationBuilder.setOngoing(false);
|
||||||
mNotificationBuilder.setAutoCancel(true);
|
mNotificationBuilder.setAutoCancel(true);
|
||||||
@@ -322,10 +333,11 @@ public class UpdaterService extends Service {
|
|||||||
}
|
}
|
||||||
case VERIFICATION_FAILED: {
|
case VERIFICATION_FAILED: {
|
||||||
stopForeground(STOP_FOREGROUND_DETACH);
|
stopForeground(STOP_FOREGROUND_DETACH);
|
||||||
mNotificationStyle.setSummaryText(null);
|
mNotificationBuilder.setStyle(null);
|
||||||
|
mNotificationBuilder.setSmallIcon(android.R.drawable.stat_sys_warning);
|
||||||
mNotificationBuilder.setProgress(0, 0, false);
|
mNotificationBuilder.setProgress(0, 0, false);
|
||||||
String text = getString(R.string.verification_failed_notification);
|
String text = getString(R.string.verification_failed_notification);
|
||||||
mNotificationStyle.bigText(text);
|
mNotificationBuilder.setContentText(text);
|
||||||
mNotificationBuilder.setTicker(text);
|
mNotificationBuilder.setTicker(text);
|
||||||
mNotificationBuilder.setOngoing(false);
|
mNotificationBuilder.setOngoing(false);
|
||||||
mNotificationBuilder.setAutoCancel(true);
|
mNotificationBuilder.setAutoCancel(true);
|
||||||
@@ -335,6 +347,8 @@ public class UpdaterService extends Service {
|
|||||||
}
|
}
|
||||||
case INSTALLING: {
|
case INSTALLING: {
|
||||||
mNotificationBuilder.mActions.clear();
|
mNotificationBuilder.mActions.clear();
|
||||||
|
mNotificationBuilder.setStyle(mNotificationStyle);
|
||||||
|
mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update);
|
||||||
mNotificationBuilder.setProgress(0, 0, false);
|
mNotificationBuilder.setProgress(0, 0, false);
|
||||||
mNotificationStyle.setSummaryText(null);
|
mNotificationStyle.setSummaryText(null);
|
||||||
String text = UpdateInstaller.isInstalling() ?
|
String text = UpdateInstaller.isInstalling() ?
|
||||||
@@ -350,10 +364,11 @@ public class UpdaterService extends Service {
|
|||||||
}
|
}
|
||||||
case INSTALLED: {
|
case INSTALLED: {
|
||||||
stopForeground(STOP_FOREGROUND_DETACH);
|
stopForeground(STOP_FOREGROUND_DETACH);
|
||||||
mNotificationStyle.setSummaryText(null);
|
mNotificationBuilder.setStyle(null);
|
||||||
|
mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update);
|
||||||
mNotificationBuilder.setProgress(0, 0, false);
|
mNotificationBuilder.setProgress(0, 0, false);
|
||||||
String text = getString(R.string.installing_update_finished);
|
String text = getString(R.string.installing_update_finished);
|
||||||
mNotificationStyle.bigText(text);
|
mNotificationBuilder.setContentText(text);
|
||||||
mNotificationBuilder.addAction(R.drawable.ic_system_update,
|
mNotificationBuilder.addAction(R.drawable.ic_system_update,
|
||||||
getString(R.string.reboot),
|
getString(R.string.reboot),
|
||||||
getRebootPendingIntent());
|
getRebootPendingIntent());
|
||||||
@@ -366,10 +381,11 @@ public class UpdaterService extends Service {
|
|||||||
}
|
}
|
||||||
case INSTALLATION_FAILED: {
|
case INSTALLATION_FAILED: {
|
||||||
stopForeground(STOP_FOREGROUND_DETACH);
|
stopForeground(STOP_FOREGROUND_DETACH);
|
||||||
mNotificationStyle.setSummaryText(null);
|
mNotificationBuilder.setStyle(null);
|
||||||
|
mNotificationBuilder.setSmallIcon(android.R.drawable.stat_sys_warning);
|
||||||
mNotificationBuilder.setProgress(0, 0, false);
|
mNotificationBuilder.setProgress(0, 0, false);
|
||||||
String text = getString(R.string.installing_update_error);
|
String text = getString(R.string.installing_update_error);
|
||||||
mNotificationStyle.bigText(text);
|
mNotificationBuilder.setContentText(text);
|
||||||
mNotificationBuilder.setTicker(text);
|
mNotificationBuilder.setTicker(text);
|
||||||
mNotificationBuilder.setOngoing(false);
|
mNotificationBuilder.setOngoing(false);
|
||||||
mNotificationBuilder.setAutoCancel(true);
|
mNotificationBuilder.setAutoCancel(true);
|
||||||
|
Reference in New Issue
Block a user