mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 05:16:51 +01: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:
parent
1bef702485
commit
f51ffcf16f
@ -36,6 +36,8 @@ import nodomain.freeyourgadget.gadgetbridge.externalevents.TimeChangeReceiver;
|
|||||||
|
|
||||||
public class GB {
|
public class GB {
|
||||||
public static final int NOTIFICATION_ID = 1;
|
public static final int NOTIFICATION_ID = 1;
|
||||||
|
public static final int NOTIFICATION_ID_INSTALL = 2;
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(GB.class);
|
private static final Logger LOG = LoggerFactory.getLogger(GB.class);
|
||||||
public static final int INFO = 1;
|
public static final int INFO = 1;
|
||||||
public static final int WARN = 2;
|
public static final int WARN = 2;
|
||||||
@ -269,7 +271,7 @@ public class GB {
|
|||||||
|
|
||||||
private static Notification createInstallNotification(String text, boolean ongoing,
|
private static Notification createInstallNotification(String text, boolean ongoing,
|
||||||
int percentage, Context context) {
|
int percentage, Context context) {
|
||||||
Intent notificationIntent = new Intent(context, AppManagerActivity.class);
|
Intent notificationIntent = new Intent(context, ControlCenter.class);
|
||||||
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
|
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
|
||||||
@ -279,13 +281,15 @@ public class GB {
|
|||||||
.setContentTitle(context.getString(R.string.app_name))
|
.setContentTitle(context.getString(R.string.app_name))
|
||||||
.setContentText(text)
|
.setContentText(text)
|
||||||
.setTicker(text)
|
.setTicker(text)
|
||||||
|
|
||||||
.setSmallIcon(R.drawable.ic_notification)
|
|
||||||
.setContentIntent(pendingIntent)
|
.setContentIntent(pendingIntent)
|
||||||
.setOngoing(ongoing);
|
.setOngoing(ongoing);
|
||||||
|
|
||||||
if (ongoing) {
|
if (ongoing) {
|
||||||
nb.setProgress(100, percentage, percentage == 0);
|
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();
|
return nb.build();
|
||||||
@ -295,7 +299,7 @@ public class GB {
|
|||||||
Notification notification = createInstallNotification(text, ongoing, percentage, context);
|
Notification notification = createInstallNotification(text, ongoing, percentage, context);
|
||||||
|
|
||||||
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
nm.notify(NOTIFICATION_ID, notification);
|
nm.notify(NOTIFICATION_ID_INSTALL, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user