1
0
Fork 0
mirror of https://github.com/MatomoCamp/matomocamp-companion-android.git synced 2024-09-19 16:13:46 +02:00

Use BigText-styled notifications to show a bit more information in

expanded state.
This commit is contained in:
Christophe Beyls 2014-01-24 02:02:25 +01:00
parent 24b8dc9e2e
commit b6c5159069

View file

@ -139,16 +139,27 @@ public class AlarmIntentService extends IntentService {
} }
String personsSummary = event.getPersonsSummary(); String personsSummary = event.getPersonsSummary();
String trackName = event.getTrack().getName();
String bigText;
String contentText; String contentText;
if (TextUtils.isEmpty(personsSummary)) { if (TextUtils.isEmpty(personsSummary)) {
contentText = event.getTrack().getName(); contentText = trackName;
bigText = event.getSubTitle();
} else { } else {
contentText = String.format("%1$s - %2$s", event.getTrack().getName(), personsSummary); contentText = String.format("%1$s - %2$s", trackName, personsSummary);
String subTitle = event.getSubTitle();
if (TextUtils.isEmpty(subTitle)) {
bigText = personsSummary;
} else {
bigText = String.format("%1s\n\n%2$s", subTitle, personsSummary);
}
} }
Notification notification = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_launcher).setWhen(event.getStartTime().getTime()) Notification notification = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_launcher).setWhen(event.getStartTime().getTime())
.setContentTitle(event.getTitle()).setContentText(contentText).setContentInfo(event.getRoomName()).setContentIntent(eventPendingIntent) .setContentTitle(event.getTitle()).setContentText(contentText)
.setAutoCancel(true).setDefaults(defaultFlags).setPriority(NotificationCompat.PRIORITY_DEFAULT).build(); .setStyle(new NotificationCompat.BigTextStyle().bigText(bigText).setSummaryText(trackName)).setContentInfo(event.getRoomName())
.setContentIntent(eventPendingIntent).setAutoCancel(true).setDefaults(defaultFlags).setPriority(NotificationCompat.PRIORITY_DEFAULT)
.build();
notificationManager.notify((int) eventId, notification); notificationManager.notify((int) eventId, notification);
} }