diff --git a/app/src/main/kotlin/de/hbch/traewelling/api/models/notifications/Notification.kt b/app/src/main/kotlin/de/hbch/traewelling/api/models/notifications/Notification.kt index 840baeb7..3a6490c0 100644 --- a/app/src/main/kotlin/de/hbch/traewelling/api/models/notifications/Notification.kt +++ b/app/src/main/kotlin/de/hbch/traewelling/api/models/notifications/Notification.kt @@ -328,6 +328,49 @@ enum class NotificationType { val targetType = object: TypeToken() {}.type return gson.fromJson(gson.toJson(data), targetType) as? MastodonNotSentData } + }, + UserMentioned { + override val icon = R.drawable.ic_user_mention + override val channel = NotificationChannelType.UserMentioned + override fun getHeadline(context: Context, notification: Notification): String { + val data = getData(notification) + var headline = "" + if (data != null) { + headline = context.getString(R.string.user_mentioned_you, data.creator.username) + } + return headline + } + override fun getOnClick(notification: Notification): (NavHostController) -> Unit { + val data = getData(notification) + var onClick: (NavHostController) -> Unit = { } + if (data != null) { + onClick = { + it.navigate("status-details/${data.status.id}") + } + } + return onClick + } + override fun getIntent(context: Context, notification: Notification): Intent? { + val data = getData(notification) + var intent: Intent? = null + if (data != null) { + intent = Intent( + Intent.ACTION_VIEW, + TraewelldroidUriBuilder() + .appendPath("status") + .appendPath(data.status.id.toString()) + .build() + ) + } + return intent + } + + private fun getData(notification: Notification): UserMentionedData? { + val gson = Gson() + val data = notification.data + val targetType = object: TypeToken() {}.type + return gson.fromJson(gson.toJson(data), targetType) as? UserMentionedData + } }; abstract val icon: Int diff --git a/app/src/main/kotlin/de/hbch/traewelling/api/models/notifications/NotificationChannelType.kt b/app/src/main/kotlin/de/hbch/traewelling/api/models/notifications/NotificationChannelType.kt index d94ca5fa..d4dd783e 100644 --- a/app/src/main/kotlin/de/hbch/traewelling/api/models/notifications/NotificationChannelType.kt +++ b/app/src/main/kotlin/de/hbch/traewelling/api/models/notifications/NotificationChannelType.kt @@ -26,6 +26,11 @@ enum class NotificationChannelType { override val importance = NotificationManager.IMPORTANCE_HIGH override val title = R.string.channel_mastodon_errors override val description = R.string.channel_description_mastodon_errors + }, + UserMentioned { + override val importance = NotificationManager.IMPORTANCE_HIGH + override val title = R.string.channel_mentions + override val description = R.string.channel_description_mentions }; abstract val title: Int abstract val description: Int diff --git a/app/src/main/kotlin/de/hbch/traewelling/api/models/notifications/NotificationData.kt b/app/src/main/kotlin/de/hbch/traewelling/api/models/notifications/NotificationData.kt index dd0ca42f..0ee27773 100644 --- a/app/src/main/kotlin/de/hbch/traewelling/api/models/notifications/NotificationData.kt +++ b/app/src/main/kotlin/de/hbch/traewelling/api/models/notifications/NotificationData.kt @@ -63,3 +63,8 @@ data class MastodonNotSentData( val status: NotificationStatus, val httpResponseCode: Int ) + +data class UserMentionedData( + val status: NotificationStatus, + val creator: NotificationUser +) diff --git a/app/src/main/res/drawable/ic_tag.xml b/app/src/main/res/drawable/ic_tag.xml index 6448806f..e2f9da7b 100644 --- a/app/src/main/res/drawable/ic_tag.xml +++ b/app/src/main/res/drawable/ic_tag.xml @@ -1,5 +1,5 @@ diff --git a/app/src/main/res/drawable/ic_taxi.xml b/app/src/main/res/drawable/ic_taxi.xml index dea38aef..d7c008de 100644 --- a/app/src/main/res/drawable/ic_taxi.xml +++ b/app/src/main/res/drawable/ic_taxi.xml @@ -1,4 +1,4 @@ - diff --git a/app/src/main/res/drawable/ic_user_mention.xml b/app/src/main/res/drawable/ic_user_mention.xml new file mode 100644 index 00000000..f086434f --- /dev/null +++ b/app/src/main/res/drawable/ic_user_mention.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/values-de-rDE/strings.xml b/app/src/main/res/values-de-rDE/strings.xml index d82c2f99..7755a053 100644 --- a/app/src/main/res/values-de-rDE/strings.xml +++ b/app/src/main/res/values-de-rDE/strings.xml @@ -163,6 +163,7 @@ \@%1$s möchte dir folgen! Fehler beim Posten auf Mastodon! Dein Check-In wurde aufgrund von Fehler %1$d nicht auf Mastodon geteilt. + \@%1$s hat dich in einem Status erwähnt. Kartenansicht Hier kannst du die Kartenansicht konfigurieren. Standard @@ -215,6 +216,8 @@ Bearbeitete Eventvorschläge Gefällt mir-Angaben Nutzer:innen, denen deine Check-Ins gefallen + Erwähnungen + Nutzer:innen, die dich in deren Check-Ins erwähnen Unified Push-Distributor wählen Es wurde kein Unified Push Distributor gefunden. Bitte installiere einen deiner Wahl und starte die App neu. Gewählter UnifiedPush Distributor: %1$s diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 27ac6550..7d669c78 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -167,6 +167,7 @@ \@%1$s would like to follow you! Error when sharing to Mastodon! Your check-in wasn\'t shared to Mastodon due to error %1$d. + \@%1$s mentioned you in their status. Map view Here you can configure the map view. OpenRailwayMap @@ -220,6 +221,8 @@ Processed event suggestions Likes Users liking your check-ins + Mentions + Users mentioning you in their check-ins Select UnifiedPush distributor No UnifiedPush distributor was found. Please install one of your choice and restart the app. Selected UnifiedPush distributor: %1$s