1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-28 16:00:12 +02:00

Use animated upload icon for installation progress notification

Also fix a bug which caused the main gadgetbridge service notification to be reused for the installation notification
This commit is contained in:
Andreas Shimokawa 2015-07-28 23:10:21 +02:00
parent 1bef702485
commit f51ffcf16f

View File

@ -36,6 +36,8 @@ import nodomain.freeyourgadget.gadgetbridge.externalevents.TimeChangeReceiver;
public class GB {
public static final int NOTIFICATION_ID = 1;
public static final int NOTIFICATION_ID_INSTALL = 2;
private static final Logger LOG = LoggerFactory.getLogger(GB.class);
public static final int INFO = 1;
public static final int WARN = 2;
@ -268,8 +270,8 @@ public class GB {
}
private static Notification createInstallNotification(String text, boolean ongoing,
int percentage, Context context) {
Intent notificationIntent = new Intent(context, AppManagerActivity.class);
int percentage, Context context) {
Intent notificationIntent = new Intent(context, ControlCenter.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
@ -279,13 +281,15 @@ public class GB {
.setContentTitle(context.getString(R.string.app_name))
.setContentText(text)
.setTicker(text)
.setSmallIcon(R.drawable.ic_notification)
.setContentIntent(pendingIntent)
.setOngoing(ongoing);
if (ongoing) {
nb.setProgress(100, percentage, percentage == 0);
nb.setSmallIcon(android.R.drawable.stat_sys_upload);
} else {
nb.setSmallIcon(android.R.drawable.stat_sys_upload_done);
}
return nb.build();
@ -295,7 +299,7 @@ public class GB {
Notification notification = createInstallNotification(text, ongoing, percentage, context);
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(NOTIFICATION_ID, notification);
nm.notify(NOTIFICATION_ID_INSTALL, notification);
}
}