mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 12:49:02 +00:00
Notification improvements
This commit is contained in:
parent
de0a6ec7c4
commit
6e47d276c9
20 changed files with 106 additions and 69 deletions
|
|
@ -146,7 +146,7 @@ android {
|
|||
buildConfigField "String", "TESTING_LEVEL", "\"production\""
|
||||
resConfigs "en", "bg", "de", "en-rGB", "es", "fr", "hr-rHR", "in", "it", "iw", "ja", "ko", "lt", "nl", "pl", "pt-rBR", "pt-rPT", "ru", "tr", "zh", "zh-rTW"
|
||||
|
||||
versionCode 3006
|
||||
versionCode 3011
|
||||
versionName "3.3"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@
|
|||
android:id="@+id/skillsFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.skills.SkillsFragment"
|
||||
android:label="@string/sidebar_skills">
|
||||
|
||||
<deepLink app:uri="habitica.com/user/skills" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/statsFragment"
|
||||
|
|
@ -111,6 +111,7 @@
|
|||
android:id="@+id/avatarOverviewFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.inventory.customization.AvatarOverviewFragment"
|
||||
android:label="@string/sidebar_avatar" >
|
||||
<deepLink app:uri="habitica.com/user/avatar" />
|
||||
<action
|
||||
android:id="@+id/openAvatarDetail"
|
||||
app:destination="@id/avatarCustomizationFragment" />
|
||||
|
|
@ -145,6 +146,7 @@
|
|||
android:id="@+id/subscriptionPurchaseActivity"
|
||||
android:name="com.habitrpg.android.habitica.ui.activities.GemPurchaseActivity"
|
||||
android:label="@string/gem_purchase_toolbartitle" >
|
||||
<deepLink app:uri="habitica.com/user/settings/subscription" />
|
||||
<argument
|
||||
android:name="openSubscription"
|
||||
app:argType="boolean"
|
||||
|
|
@ -154,6 +156,7 @@
|
|||
android:id="@+id/gemPurchaseActivity"
|
||||
android:name="com.habitrpg.android.habitica.ui.activities.GemPurchaseActivity"
|
||||
android:label="@string/gem_purchase_toolbartitle">
|
||||
<deepLink app:uri="habitica.com/user/settings/gems" />
|
||||
<argument
|
||||
android:name="openSubscription"
|
||||
app:argType="boolean"
|
||||
|
|
@ -188,7 +191,9 @@
|
|||
<fragment
|
||||
android:id="@+id/newsFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.NewsFragment"
|
||||
android:label="@string/sidebar_news" />
|
||||
android:label="@string/sidebar_news">
|
||||
<deepLink app:uri="habitica.com/static/new-stuff" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/FAQOverviewFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.support.FAQOverviewFragment"
|
||||
|
|
@ -218,11 +223,14 @@
|
|||
<fragment
|
||||
android:id="@+id/aboutFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.AboutFragment"
|
||||
android:label="@string/sidebar_about" />
|
||||
android:label="@string/sidebar_about">
|
||||
<deepLink app:uri="habitica.com/static/about" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/inboxFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.social.InboxOverviewFragment"
|
||||
android:label="@string/sidebar_inbox" >
|
||||
android:label="@string/sidebar_inbox">
|
||||
<deepLink app:uri="habitica.com/private-messages" />
|
||||
<action
|
||||
android:id="@+id/openInboxDetail"
|
||||
app:destination="@id/inboxMessageListFragment" />
|
||||
|
|
@ -279,6 +287,7 @@
|
|||
android:name="com.habitrpg.android.habitica.ui.activities.PrefsActivity"
|
||||
android:label="@string/app_settings"
|
||||
tools:layout="@layout/activity_prefs">
|
||||
<deepLink app:uri="habitica.com/settings" />
|
||||
</activity>
|
||||
<fragment
|
||||
android:id="@+id/inboxMessageListFragment"
|
||||
|
|
@ -296,6 +305,7 @@
|
|||
android:id="@+id/notificationsActivity"
|
||||
android:name="com.habitrpg.android.habitica.ui.activities.NotificationsActivity"
|
||||
android:label="@string/notifications">
|
||||
<deepLink app:uri="habitica.com/user/notifications" />
|
||||
</activity>
|
||||
<fragment
|
||||
android:id="@+id/petDetailRecyclerFragment"
|
||||
|
|
@ -389,6 +399,7 @@
|
|||
android:id="@+id/achievementsFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.AchievementsFragment"
|
||||
android:label="@string/sidebar_achievements" >
|
||||
<deepLink app:uri="habitica.com/user/achievements" />
|
||||
<argument
|
||||
android:name="userID"
|
||||
app:argType="string"
|
||||
|
|
@ -397,19 +408,27 @@
|
|||
<fragment
|
||||
android:id="@+id/marketFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.inventory.shops.MarketFragment"
|
||||
android:label="@string/market" />
|
||||
android:label="@string/market">
|
||||
<deepLink app:uri="habitica.com/inventory/market" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/questShopFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.inventory.shops.QuestShopFragment"
|
||||
android:label="@string/questShop" />
|
||||
android:label="@string/questShop">
|
||||
<deepLink app:uri="habitica.com/inventory/quests" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/seasonalShopFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.inventory.shops.SeasonalShopFragment"
|
||||
android:label="@string/seasonalShop" />
|
||||
android:label="@string/seasonalShop">
|
||||
<deepLink app:uri="habitica.com/inventory/seasonal" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/timeTravelersShopFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.inventory.shops.TimeTravelersShopFragment"
|
||||
android:label="@string/timeTravelers" />
|
||||
android:label="@string/timeTravelers">
|
||||
<deepLink app:uri="habitica.com/inventory/time" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/supportMainFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.support.SupportMainFragment"
|
||||
|
|
@ -425,7 +444,9 @@
|
|||
<activity
|
||||
android:id="@+id/adventureGuideActivity"
|
||||
android:name="com.habitrpg.android.habitica.ui.activities.AdventureGuideActivity"
|
||||
android:label="" />
|
||||
android:label="">
|
||||
<deepLink app:uri="habitica.com/user/onboarding" />
|
||||
</activity>
|
||||
<fragment
|
||||
android:id="@+id/promoInfoFragment"
|
||||
android:name="com.habitrpg.android.habitica.ui.fragments.PromoInfoFragment"
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ class NotificationOpenHandler {
|
|||
PushNotificationManager.GROUP_ACTIVITY_NOTIFICATION_KEY -> handleChatMessage(intent.getStringExtra("type"), intent.getStringExtra("groupID"))
|
||||
PushNotificationManager.G1G1_PROMO_KEY -> openGiftOneGetOneInfoScreen()
|
||||
else -> {
|
||||
if (intent.hasExtra("openURL")) {
|
||||
MainNavigationController.navigate(intent.getStringExtra("openURL"))
|
||||
intent.getStringExtra("openURL")?.let {
|
||||
MainNavigationController.navigate(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@ package com.habitrpg.android.habitica.helpers.notifications
|
|||
|
||||
import android.content.Context
|
||||
|
||||
class ChangeUsernameLocalNotification(context: Context, identifier: String) : HabiticaLocalNotification(context, identifier)
|
||||
class ChangeUsernameLocalNotification(context: Context, identifier: String?) : HabiticaLocalNotification(context, identifier)
|
||||
|
|
@ -4,7 +4,7 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import androidx.core.app.NotificationCompat
|
||||
|
||||
class ChatMentionNotification(context: Context, identifier: String) : HabiticaLocalNotification(context, identifier) {
|
||||
class ChatMentionNotification(context: Context, identifier: String?) : HabiticaLocalNotification(context, identifier) {
|
||||
|
||||
override fun configureNotificationBuilder(data: MutableMap<String, String>): NotificationCompat.Builder {
|
||||
val style = NotificationCompat.BigTextStyle()
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@ package com.habitrpg.android.habitica.helpers.notifications
|
|||
|
||||
import android.content.Context
|
||||
|
||||
class GenericLocalNotification(context: Context, identifier: String) : HabiticaLocalNotification(context, identifier)
|
||||
class GenericLocalNotification(context: Context, identifier: String?) : HabiticaLocalNotification(context, identifier)
|
||||
|
|
@ -2,4 +2,4 @@ package com.habitrpg.android.habitica.helpers.notifications
|
|||
|
||||
import android.content.Context
|
||||
|
||||
class GiftOneGetOneLocalNotification(context: Context, identifier: String) : HabiticaLocalNotification(context, identifier)
|
||||
class GiftOneGetOneLocalNotification(context: Context, identifier: String?) : HabiticaLocalNotification(context, identifier)
|
||||
|
|
@ -15,7 +15,7 @@ import com.habitrpg.android.habitica.ui.helpers.EmojiParser
|
|||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
class GroupActivityNotification(context: Context, identifier: String) : HabiticaLocalNotification(context, identifier) {
|
||||
class GroupActivityNotification(context: Context, identifier: String?) : HabiticaLocalNotification(context, identifier) {
|
||||
|
||||
override fun getNotificationID(data: MutableMap<String, String>): Int {
|
||||
return data["groupID"].hashCode()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import com.habitrpg.android.habitica.receivers.LocalNotificationActionReceiver
|
|||
/**
|
||||
* Created by keithholliday on 7/1/16.
|
||||
*/
|
||||
class GuildInviteLocalNotification(context: Context, identifier: String) : HabiticaLocalNotification(context, identifier) {
|
||||
class GuildInviteLocalNotification(context: Context, identifier: String?) : HabiticaLocalNotification(context, identifier) {
|
||||
|
||||
override fun configureMainIntent(intent: Intent) {
|
||||
super.configureMainIntent(intent)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import java.util.*
|
|||
/**
|
||||
* Created by keithholliday on 6/28/16.
|
||||
*/
|
||||
abstract class HabiticaLocalNotification(protected var context: Context, protected var identifier: String) {
|
||||
abstract class HabiticaLocalNotification(protected var context: Context, protected var identifier: String?) {
|
||||
|
||||
protected var data: Map<String, String>? = null
|
||||
protected var title: String? = null
|
||||
|
|
@ -56,8 +56,6 @@ abstract class HabiticaLocalNotification(protected var context: Context, protect
|
|||
|
||||
protected open fun setNotificationActions(data: Map<String, String>) {
|
||||
val intent = Intent(context, MainActivity::class.java)
|
||||
intent.putExtra("notificationIdentifier", identifier)
|
||||
intent.putExtra("notificationTimeStamp", Date().time)
|
||||
configureMainIntent(intent)
|
||||
val pendingIntent = PendingIntent.getActivity(
|
||||
context,
|
||||
|
|
@ -69,6 +67,11 @@ abstract class HabiticaLocalNotification(protected var context: Context, protect
|
|||
}
|
||||
|
||||
protected open fun configureMainIntent(intent: Intent) {
|
||||
intent.putExtra("notificationIdentifier", identifier)
|
||||
intent.putExtra("notificationTimeStamp", Date().time)
|
||||
if (data?.containsKey("openURL") == true) {
|
||||
intent.putExtra("openURL", data?.get("openURL"))
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun getNotificationID(data: MutableMap<String, String>): Int {
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
package com.habitrpg.android.habitica.helpers.notifications;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* Created by keithholliday on 6/28/16.
|
||||
*/
|
||||
public class HabiticaLocalNotificationFactory {
|
||||
|
||||
//use getShape method to get object of type shape
|
||||
public HabiticaLocalNotification build(String notificationType, Context context) {
|
||||
if (notificationType.equalsIgnoreCase(PushNotificationManager.PARTY_INVITE_PUSH_NOTIFICATION_KEY)) {
|
||||
return new PartyInviteLocalNotification(context, notificationType);
|
||||
} else if (notificationType.contains(PushNotificationManager.RECEIVED_PRIVATE_MESSAGE_PUSH_NOTIFICATION_KEY)) {
|
||||
return new ReceivedPrivateMessageLocalNotification(context, notificationType);
|
||||
} else if (notificationType.contains(PushNotificationManager.RECEIVED_GEMS_PUSH_NOTIFICATION_KEY)) {
|
||||
return new ReceivedGemsGiftLocalNotification(context, notificationType);
|
||||
} else if (notificationType.contains(PushNotificationManager.RECEIVED_SUBSCRIPTION_GIFT_PUSH_NOTIFICATION_KEY)) {
|
||||
return new ReceivedSubscriptionGiftLocalNotification(context, notificationType);
|
||||
} else if (notificationType.contains(PushNotificationManager.GUILD_INVITE_PUSH_NOTIFICATION_KEY)) {
|
||||
return new GuildInviteLocalNotification(context, notificationType);
|
||||
} else if (notificationType.contains(PushNotificationManager.QUEST_INVITE_PUSH_NOTIFICATION_KEY)) {
|
||||
return new QuestInviteLocalNotification(context, notificationType);
|
||||
} else if (notificationType.contains(PushNotificationManager.QUEST_BEGUN_PUSH_NOTIFICATION_KEY)) {
|
||||
return new QuestBegunLocalNotification(context, notificationType);
|
||||
} else if (notificationType.contains(PushNotificationManager.WON_CHALLENGE_PUSH_NOTIFICATION_KEY)) {
|
||||
return new WonChallengeLocalNotification(context, notificationType);
|
||||
} else if (notificationType.contains(PushNotificationManager.CHANGE_USERNAME_PUSH_NOTIFICATION_KEY)) {
|
||||
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 if (notificationType.contains(PushNotificationManager.GROUP_ACTIVITY_NOTIFICATION_KEY)) {
|
||||
return new GroupActivityNotification(context, notificationType);
|
||||
} else {
|
||||
return new GenericLocalNotification(context, notificationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package com.habitrpg.android.habitica.helpers.notifications
|
||||
|
||||
import android.content.Context
|
||||
|
||||
/**
|
||||
* Created by keithholliday on 6/28/16.
|
||||
*/
|
||||
class HabiticaLocalNotificationFactory {
|
||||
//use getShape method to get object of type shape
|
||||
fun build(notificationType: String?, context: Context?): HabiticaLocalNotification {
|
||||
return when {
|
||||
PushNotificationManager.PARTY_INVITE_PUSH_NOTIFICATION_KEY.equals(notificationType, true)-> {
|
||||
PartyInviteLocalNotification(context!!, notificationType)
|
||||
}
|
||||
PushNotificationManager.RECEIVED_PRIVATE_MESSAGE_PUSH_NOTIFICATION_KEY.equals(notificationType, true)-> {
|
||||
ReceivedPrivateMessageLocalNotification(context!!, notificationType)
|
||||
}
|
||||
PushNotificationManager.RECEIVED_GEMS_PUSH_NOTIFICATION_KEY.equals(notificationType, true)-> {
|
||||
ReceivedGemsGiftLocalNotification(context!!, notificationType)
|
||||
}
|
||||
PushNotificationManager.RECEIVED_SUBSCRIPTION_GIFT_PUSH_NOTIFICATION_KEY.equals(notificationType, true)-> {
|
||||
ReceivedSubscriptionGiftLocalNotification(context!!, notificationType)
|
||||
}
|
||||
PushNotificationManager.GUILD_INVITE_PUSH_NOTIFICATION_KEY.equals(notificationType, true)-> {
|
||||
GuildInviteLocalNotification(context!!, notificationType)
|
||||
}
|
||||
PushNotificationManager.QUEST_INVITE_PUSH_NOTIFICATION_KEY.equals(notificationType, true)-> {
|
||||
QuestInviteLocalNotification(context!!, notificationType)
|
||||
}
|
||||
PushNotificationManager.QUEST_BEGUN_PUSH_NOTIFICATION_KEY.equals(notificationType, true)-> {
|
||||
QuestBegunLocalNotification(context!!, notificationType)
|
||||
}
|
||||
PushNotificationManager.WON_CHALLENGE_PUSH_NOTIFICATION_KEY.equals(notificationType, true)-> {
|
||||
WonChallengeLocalNotification(context!!, notificationType)
|
||||
}
|
||||
PushNotificationManager.CHANGE_USERNAME_PUSH_NOTIFICATION_KEY.equals(notificationType, true)-> {
|
||||
ChangeUsernameLocalNotification(context!!, notificationType)
|
||||
}
|
||||
PushNotificationManager.GIFT_ONE_GET_ONE_PUSH_NOTIFICATION_KEY.equals(notificationType, true)-> {
|
||||
GiftOneGetOneLocalNotification(context!!, notificationType)
|
||||
}
|
||||
PushNotificationManager.CHAT_MENTION_NOTIFICATION_KEY.equals(notificationType, true)-> {
|
||||
ChatMentionNotification(context!!, notificationType)
|
||||
}
|
||||
PushNotificationManager.GROUP_ACTIVITY_NOTIFICATION_KEY.equals(notificationType, true)-> {
|
||||
GroupActivityNotification(context!!, notificationType)
|
||||
}
|
||||
else -> {
|
||||
GenericLocalNotification(context!!, notificationType)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ import com.habitrpg.android.habitica.receivers.LocalNotificationActionReceiver
|
|||
/**
|
||||
* Created by keithholliday on 6/28/16.
|
||||
*/
|
||||
class PartyInviteLocalNotification(context: Context, identifier: String) : HabiticaLocalNotification(context, identifier) {
|
||||
class PartyInviteLocalNotification(context: Context, identifier: String?) : HabiticaLocalNotification(context, identifier) {
|
||||
|
||||
override fun setNotificationActions(data: Map<String, String>) {
|
||||
super.setNotificationActions(data)
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@ import android.content.Context
|
|||
/**
|
||||
* Created by keithholliday on 7/1/16.
|
||||
*/
|
||||
class QuestBegunLocalNotification(context: Context, identifier: String) : HabiticaLocalNotification(context, identifier)
|
||||
class QuestBegunLocalNotification(context: Context, identifier: String?) : HabiticaLocalNotification(context, identifier)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import com.habitrpg.android.habitica.receivers.LocalNotificationActionReceiver
|
|||
/**
|
||||
* Created by keithholliday on 7/1/16.
|
||||
*/
|
||||
class QuestInviteLocalNotification(context: Context, identifier: String) : HabiticaLocalNotification(context, identifier) {
|
||||
class QuestInviteLocalNotification(context: Context, identifier: String?) : HabiticaLocalNotification(context, identifier) {
|
||||
|
||||
override fun getNotificationID(data: MutableMap<String, String>): Int {
|
||||
return 1000
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@ import android.content.Context
|
|||
/**
|
||||
* Created by keithholliday on 7/1/16.
|
||||
*/
|
||||
class ReceivedGemsGiftLocalNotification(context: Context, identifier: String) : HabiticaLocalNotification(context, identifier)
|
||||
class ReceivedGemsGiftLocalNotification(context: Context, identifier: String?) : HabiticaLocalNotification(context, identifier)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import com.habitrpg.android.habitica.receivers.LocalNotificationActionReceiver
|
|||
import com.habitrpg.android.habitica.ui.helpers.EmojiParser
|
||||
|
||||
|
||||
class ReceivedPrivateMessageLocalNotification(context: Context, identifier: String) : HabiticaLocalNotification(context, identifier) {
|
||||
class ReceivedPrivateMessageLocalNotification(context: Context, identifier: String?) : HabiticaLocalNotification(context, identifier) {
|
||||
override fun configureNotificationBuilder(data: MutableMap<String, String>): NotificationCompat.Builder {
|
||||
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager
|
||||
val existingNotifications = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@ import android.content.Context
|
|||
/**
|
||||
* Created by keithholliday on 7/1/16.
|
||||
*/
|
||||
class ReceivedSubscriptionGiftLocalNotification(context: Context, identifier: String) : HabiticaLocalNotification(context, identifier)
|
||||
class ReceivedSubscriptionGiftLocalNotification(context: Context, identifier: String?) : HabiticaLocalNotification(context, identifier)
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@ import android.content.Context
|
|||
/**
|
||||
* Created by keithholliday on 7/2/16.
|
||||
*/
|
||||
class WonChallengeLocalNotification(context: Context, identifier: String) : HabiticaLocalNotification(context, identifier)
|
||||
class WonChallengeLocalNotification(context: Context, identifier: String?) : HabiticaLocalNotification(context, identifier)
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
putBoolean("preventDailyReminder", false)
|
||||
}
|
||||
|
||||
if (intent.hasExtra("notificationIdentifier") && lastNotificationOpen != intent.getLongExtra("notificationTimeStamp", 0)) {
|
||||
if ((intent.hasExtra("notificationIdentifier") || intent.hasExtra("openURL")) && lastNotificationOpen != intent.getLongExtra("notificationTimeStamp", 0)) {
|
||||
lastNotificationOpen = intent.getLongExtra("notificationTimeStamp", 0)
|
||||
val identifier = intent.getStringExtra("notificationIdentifier") ?: ""
|
||||
val additionalData = HashMap<String, Any>()
|
||||
|
|
|
|||
Loading…
Reference in a new issue