diff options
author | Gabriele M <moto.falcon.git@gmail.com> | 2018-06-10 16:44:44 +0200 |
---|---|---|
committer | Gabriele M <moto.falcon.git@gmail.com> | 2018-06-13 23:30:08 +0200 |
commit | 0332be5ec7f1637101434c335ba78ed0dce30baa (patch) | |
tree | 62d3e179a60b58bac89873af3b58fb9ff490aafd | |
parent | ce4b02697f7a79f0bf24632981fbce92725e0e42 (diff) | |
download | android_packages_apps_Updater-0332be5ec7f1637101434c335ba78ed0dce30baa.tar.gz android_packages_apps_Updater-0332be5ec7f1637101434c335ba78ed0dce30baa.tar.bz2 android_packages_apps_Updater-0332be5ec7f1637101434c335ba78ed0dce30baa.zip |
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
-rw-r--r-- | res/drawable/ic_pause.xml | 9 | ||||
-rw-r--r-- | src/org/lineageos/updater/ExportUpdateService.java | 2 | ||||
-rw-r--r-- | src/org/lineageos/updater/controller/UpdaterService.java | 38 |
3 files changed, 37 insertions, 12 deletions
diff --git a/res/drawable/ic_pause.xml b/res/drawable/ic_pause.xml new file mode 100644 index 0000000..3b2d509 --- /dev/null +++ b/res/drawable/ic_pause.xml @@ -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> diff --git a/src/org/lineageos/updater/ExportUpdateService.java b/src/org/lineageos/updater/ExportUpdateService.java index 37c1239..c1393f8 100644 --- a/src/org/lineageos/updater/ExportUpdateService.java +++ b/src/org/lineageos/updater/ExportUpdateService.java @@ -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()); diff --git a/src/org/lineageos/updater/controller/UpdaterService.java b/src/org/lineageos/updater/controller/UpdaterService.java index 9763bf3..dde8c04 100644 --- a/src/org/lineageos/updater/controller/UpdaterService.java +++ b/src/org/lineageos/updater/controller/UpdaterService.java @@ -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); |