Handle chat mention push notifications. Fixes #1110

This commit is contained in:
Phillip Thelen 2019-02-28 21:19:14 +01:00
parent 2e0ef079d4
commit 35c2737aaa
5 changed files with 31 additions and 6 deletions

View file

@ -60,10 +60,10 @@ dependencies {
//Dependency Injection
implementation 'com.google.dagger:dagger:2.21'
kapt 'com.google.dagger:dagger-compiler:2.21'
compileOnly 'javax.annotation:javax.annotation-api:1.3.1'
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
//App Compatibility and Material Design
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.1.0-alpha03'
implementation 'com.google.android.material:material:1.1.0-alpha04'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
//QR Code
@ -116,8 +116,8 @@ dependencies {
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.2'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.2'
//Push Notifications
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-messaging:17.4.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'io.realm:android-adapters:3.1.0'
implementation(project(':seeds-sdk')) {
@ -131,8 +131,8 @@ dependencies {
implementation 'androidx.core:core-ktx:1.0.1'
implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
kapt "androidx.lifecycle:lifecycle-compiler:2.0.0"
implementation 'android.arch.navigation:navigation-fragment-ktx:1.0.0-beta02'
implementation 'android.arch.navigation:navigation-ui-ktx:1.0.0-beta02'
implementation 'android.arch.navigation:navigation-fragment-ktx:1.0.0-rc02'
implementation 'android.arch.navigation:navigation-ui-ktx:1.0.0-rc02'
implementation 'com.plattysoft.leonids:LeonidsLib:1.3.2'
}

View file

@ -21,6 +21,7 @@ class NotificationOpenHandler {
PushNotificationManager.RECEIVED_PRIVATE_MESSAGE_PUSH_NOTIFICATION_KEY -> openPrivateMessageScreen(intent.getStringExtra("replyTo"))
PushNotificationManager.CHANGE_USERNAME_PUSH_NOTIFICATION_KEY -> openSettingsScreen()
PushNotificationManager.GIFT_ONE_GET_ONE_PUSH_NOTIFICATION_KEY -> openSubscriptionScreen()
PushNotificationManager.CHAT_MENTION_NOTIFICATION_KEY -> handleChatMention(intent.getStringExtra("type"), intent.getStringExtra("groupID"))
}
}
@ -57,5 +58,13 @@ class NotificationOpenHandler {
private fun openSettingsScreen() {
MainNavigationController.navigate(R.id.prefsActivity)
}
private fun handleChatMention(type: String, groupID: String) {
when (type) {
"party" -> MainNavigationController.navigate(R.id.partyFragment)
"tavern" -> MainNavigationController.navigate(R.id.tavernFragment)
"guild" -> MainNavigationController.navigate(R.id.guildFragment, bundleOf("groupId" to groupID))
}
}
}
}

View file

@ -0,0 +1,13 @@
package com.habitrpg.android.habitica.helpers.notifications
import android.content.Context
import android.content.Intent
class ChatMentionNotification(context: Context, identifier: String) : HabiticaLocalNotification(context, identifier) {
override fun configureMainIntent(intent: Intent) {
super.configureMainIntent(intent)
intent.putExtra("type", data?.get("type"))
intent.putExtra("groupID", data?.get("groupID"))
}
}

View file

@ -29,6 +29,8 @@ public class HabiticaLocalNotificationFactory {
return new ChangeUsernameLocalNotification(context, notificationType);
} else if (notificationType.contains(PushNotificationManager.GIFT_ONE_GET_ONE_PUSH_NOTIFICATION_KEY)) {
return new GiftOneGetOneLocalNotification(context, notificationType);
} else if (notificationType.contains(PushNotificationManager.CHAT_MENTION_NOTIFICATION_KEY)) {
return new ChatMentionNotification(context, notificationType);
} else {
return new GenericLocalNotification(context, notificationType);
}

View file

@ -121,6 +121,7 @@ class PushNotificationManager(var apiClient: ApiClient, private val sharedPrefer
const val WON_CHALLENGE_PUSH_NOTIFICATION_KEY = "wonChallenge"
const val CHANGE_USERNAME_PUSH_NOTIFICATION_KEY = "changeUsername"
const val GIFT_ONE_GET_ONE_PUSH_NOTIFICATION_KEY = "gift1get1"
const val CHAT_MENTION_NOTIFICATION_KEY = "chatMention"
private const val DEVICE_TOKEN_PREFERENCE_KEY = "device-token-preference"
}
}