diff --git a/Habitica/build.gradle b/Habitica/build.gradle index e99b0ed82..1a361209b 100644 --- a/Habitica/build.gradle +++ b/Habitica/build.gradle @@ -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' } diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/NotificationOpenHandler.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/NotificationOpenHandler.kt index df7bf9a57..31466bf69 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/NotificationOpenHandler.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/NotificationOpenHandler.kt @@ -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)) + } + } } } \ No newline at end of file diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/ChatMentionNotification.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/ChatMentionNotification.kt new file mode 100644 index 000000000..344e607b0 --- /dev/null +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/ChatMentionNotification.kt @@ -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")) + } +} \ No newline at end of file diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/HabiticaLocalNotificationFactory.java b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/HabiticaLocalNotificationFactory.java index 2f9acecc7..cd75bdbe9 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/HabiticaLocalNotificationFactory.java +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/HabiticaLocalNotificationFactory.java @@ -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); } diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/PushNotificationManager.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/PushNotificationManager.kt index 309f1bee8..f253ad7e9 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/PushNotificationManager.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/PushNotificationManager.kt @@ -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" } }