1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 22:31:16 +00:00

Use expandable notification for new device/folder (fixes #614).

This commit is contained in:
Felix Ableitner 2016-06-12 22:15:36 +02:00
parent 788af35c00
commit d29b675a1e

View file

@ -182,18 +182,21 @@ public class EventProcessor implements SyncthingService.OnWebGuiAvailableListene
}
}
private void notify(String title, PendingIntent pi) {
private void notify(String text, PendingIntent pi) {
NotificationManager nm = (NotificationManager)
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
Notification n = new NotificationCompat.Builder(mContext)
.setContentTitle(title)
.setContentTitle(mContext.getString(R.string.app_name))
.setContentText(text)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(text))
.setContentIntent(pi)
.setSmallIcon(R.drawable.ic_stat_notify)
.setAutoCancel(true)
.build();
// HACK: Use a random, deterministic ID between 1000 and 2000 to avoid duplicate
// notifications.
int notificationId = 1000 + title.hashCode() % 1000;
int notificationId = 1000 + text.hashCode() % 1000;
nm.notify(notificationId, n);
}
}