Add a public version of the notification to make it possible to optionally hide sensitive information

Also don't override the visibility to respect the user's notification
settings
This commit is contained in:
Florian Angermeier 2018-04-10 23:40:55 +02:00
parent 2b71625de5
commit 3ef480a80d
29 changed files with 43 additions and 7 deletions

View File

@ -167,7 +167,7 @@ fun Context.notifyEvent(event: Event) {
}
@SuppressLint("NewApi")
fun Context.getNotification(pendingIntent: PendingIntent, event: Event, content: String): Notification {
fun Context.getNotification(pendingIntent: PendingIntent, event: Event, content: String, publicVersion: Boolean = false): Notification {
val channelId = "reminder_channel"
if (isOreoPlus()) {
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
@ -184,9 +184,17 @@ fun Context.getNotification(pendingIntent: PendingIntent, event: Event, content:
val soundUri = Uri.parse(config.reminderSoundUri)
grantReadUriPermission(config.reminderSoundUri)
val contentTitle = when (publicVersion) {
false -> event.title
true -> resources.getString(R.string.app_name)
}
val contentText = when (publicVersion) {
false -> content
true -> resources.getString(R.string.public_event_notification_text)
}
val builder = NotificationCompat.Builder(this)
.setContentTitle(event.title)
.setContentText(content)
.setContentTitle(contentTitle)
.setContentText(contentText)
.setSmallIcon(R.drawable.ic_calendar)
.setContentIntent(pendingIntent)
.setPriority(Notification.PRIORITY_HIGH)
@ -196,14 +204,14 @@ fun Context.getNotification(pendingIntent: PendingIntent, event: Event, content:
.setChannelId(channelId)
.addAction(R.drawable.ic_snooze, getString(R.string.snooze), getSnoozePendingIntent(this, event))
if (isLollipopPlus()) {
builder.setVisibility(Notification.VISIBILITY_PUBLIC)
}
if (config.vibrateOnReminder) {
builder.setVibrate(longArrayOf(0, 300, 300, 300))
}
if (!publicVersion) {
builder.setPublicVersion(getNotification(pendingIntent, event, content, true))
}
return builder.build()
}

View File

@ -26,6 +26,7 @@
<string name="event_updated">Hadisə uğurla yeniləndi</string>
<string name="filter_events_by_type">Hadisələri yazıya görə sırala</string>
<string name="please_fill_location">Xahiş olunur məkan parametrini doldurun ki hadisədə görünsün</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Təkrarlama</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Darvoud hizivaet gant berzh</string>
<string name="filter_events_by_type">Silañ an darvoudoù dre rizh</string>
<string name="please_fill_location">Please fill in a location to be shown on a map</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Addegouezh</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Událost úspěšně změněna</string>
<string name="filter_events_by_type">Filtrovat události podle typu</string>
<string name="please_fill_location">Please fill in a location to be shown on a map</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Opakovaná událost</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Begivenhed ændret</string>
<string name="filter_events_by_type">Filtrer begivenheder efter type</string>
<string name="please_fill_location">Indtast et sted der kan vises på et kort</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Gentagelse</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Termin erfolgreich aktualisiert</string>
<string name="filter_events_by_type">Sortiere Termine nach Typ</string>
<string name="please_fill_location">Bitte trage einen Ort ein, der auf einer Karte angezeigt werden soll</string>
<string name="public_event_notification_text">Ein Termin steht an</string>
<!-- Event Repetition -->
<string name="repetition">Wiederholung</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">El evento se ha actualizado con éxito</string>
<string name="filter_events_by_type">Filtrar eventos según tipo</string>
<string name="please_fill_location">Please fill in a location to be shown on a map</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Repetición</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Événement ajouté avec succès</string>
<string name="filter_events_by_type">Filtrer les événements par type</string>
<string name="please_fill_location">Veuillez remplir un emplacement pour être affiché sur une carte</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Répétition</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">O evento foi actualizado correctamente</string>
<string name="filter_events_by_type">Filtrar eventos por tipo</string>
<string name="please_fill_location">Please fill in a location to be shown on a map</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Repetición</string>

View File

@ -27,6 +27,7 @@
<string name="filter">Filter</string>
<string name="filter_events_by_type">Filter events by type</string>
<string name="please_fill_location">Please fill in a location to be shown on a map</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">दुहराव</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Događaj je uspješno ažuriran</string>
<string name="filter_events_by_type">Sortiranje prema vrsti događaja</string>
<string name="please_fill_location">Ispunite lokaciju za prikazivanje na karti</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Ponavljanje</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Bejegyzés frissítve</string>
<string name="filter_events_by_type">Filter events by type</string>
<string name="please_fill_location">Please fill in a location to be shown on a map</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Ismétlés</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Evento aggiornato correttamente</string>
<string name="filter_events_by_type">Filtra eventi per tipologia</string>
<string name="please_fill_location">Please fill in a location to be shown on a map</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Ripeti</string>

View File

@ -27,6 +27,7 @@
<string name="filter">Filter</string>
<string name="filter_events_by_type">Filter events by type</string>
<string name="please_fill_location">Please fill in a location to be shown on a map</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Repetition</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">イベントを正常に更新しました</string>
<string name="filter_events_by_type">Filter events by type</string>
<string name="please_fill_location">Please fill in a location to be shown on a map</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">繰り返し</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">이벤트를 수정했습니다</string>
<string name="filter_events_by_type">유형별 이벤트</string>
<string name="please_fill_location">Please fill in a location to be shown on a map</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">반복</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Įvykis atnaujintas sėkmingai</string>
<string name="filter_events_by_type">Filtruoti įvykius pagal tipą</string>
<string name="please_fill_location">Prašome įvesti vietą, kad būtų rodoma žemėlapyje</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Pasikartojimas</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Hendelse vellykket oppdatert</string>
<string name="filter_events_by_type">Filtrer hendelser etter type</string>
<string name="please_fill_location">Oppfør et sted som skal vises på et kart</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Gjentagelse</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Afspraak bijgewerkt</string>
<string name="filter_events_by_type">Afspraken op type filteren</string>
<string name="please_fill_location">Vul de locatie in om deze op de kaart te tonen</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Herhaling</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Hendelse vellykket oppdatert</string>
<string name="filter_events_by_type">Filtrer hendelser etter type</string>
<string name="please_fill_location">Please fill in a location to be shown on a map</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Gjentagelse</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Wydarzenie zostało zaktualizowane</string>
<string name="filter_events_by_type">Filtruj wydarzenia według typu</string>
   <string name="please_fill_location">Wpisz lokalizację, która ma być pokazana na mapie</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Powtórzenie</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Evento atualizado com sucesso</string>
<string name="filter_events_by_type">Filtrar eventos por tipo</string>
<string name="please_fill_location">Please fill in a location to be shown on a map</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Repetição</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Evento atualizado com sucesso</string>
<string name="filter_events_by_type">Filtrar eventos por tipo</string>
<string name="please_fill_location">Introduza a localização para a mostrar no maps</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Repetição</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Событие успешно обновлено</string>
<string name="filter_events_by_type">Фильтровать события по типу</string>
<string name="please_fill_location">Пожалуйста, введите место, которое будет показано на карте</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Повторять</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Udalosť bola úspešne upravená</string>
<string name="filter_events_by_type">Filtrovať udalosti podľa typu</string>
<string name="please_fill_location">Prosím zadajte polohu, ktorá má byť zobrazená na mape</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Opakovanie</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Händelsen har uppdaterats</string>
<string name="filter_events_by_type">Filtrera händelser efter typ</string>
<string name="please_fill_location">Du måste ange en plats som kan visas på en karta</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Upprepning</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Etkinlik başarıyla güncellendi</string>
<string name="filter_events_by_type">Etkinlikleri türe göre filtreleyin</string>
<string name="please_fill_location">Please fill in a location to be shown on a map</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Tekrarla</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">活動更新成功</string>
<string name="filter_events_by_type">依類型篩選活動</string>
<string name="please_fill_location">請填入要顯示在地圖上的地點</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">重複</string>

View File

@ -26,6 +26,7 @@
<string name="event_updated">Event updated successfully</string>
<string name="filter_events_by_type">Filter events by type</string>
<string name="please_fill_location">Please fill in a location to be shown on a map</string>
<string name="public_event_notification_text">An event is upcoming</string>
<!-- Event Repetition -->
<string name="repetition">Repetition</string>