fix notification display issue

This commit is contained in:
Phillip Thelen 2020-06-25 14:39:06 +02:00
parent c083deef26
commit 0f05045d2d
6 changed files with 24 additions and 15 deletions

View file

@ -162,7 +162,7 @@ android {
multiDexEnabled true
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 2450
versionCode 2459
versionName "2.7"
}

View file

@ -15,12 +15,17 @@ import com.habitrpg.android.habitica.models.notifications.FirstDropData
import com.habitrpg.android.habitica.models.notifications.LoginIncentiveData
import com.habitrpg.android.habitica.models.user.User
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar
import com.habitrpg.android.habitica.ui.views.dialogs.AchievementDialog
import io.reactivex.BackpressureStrategy
import io.reactivex.Completable
import io.reactivex.Flowable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Action
import io.reactivex.functions.Consumer
import io.reactivex.subjects.BehaviorSubject
import org.greenrobot.eventbus.EventBus
import java.util.*
import java.util.concurrent.TimeUnit
class NotificationsManager (private val context: Context) {
private val seenNotifications: MutableMap<String, Boolean>
@ -74,7 +79,7 @@ class NotificationsManager (private val context: Context) {
Notification.Type.ACHIEVEMENT_GUILD_JOINED.type -> displayAchievementNotification(it)
Notification.Type.ACHIEVEMENT_CHALLENGE_JOINED.type -> displayAchievementNotification(it)
Notification.Type.ACHIEVEMENT_INVITED_FRIEND.type -> displayAchievementNotification(it)
Notification.Type.ACHIEVEMENT_GENERIC.type -> displayGenericAchievementNotification(it, notifications.find { notif ->
Notification.Type.ACHIEVEMENT_GENERIC.type -> displayAchievementNotification(it, notifications.find { notif ->
notif.type == Notification.Type.ACHIEVEMENT_ONBOARDING_COMPLETE.type
} != null)
Notification.Type.ACHIEVEMENT_ONBOARDING_COMPLETE.type -> displayAchievementNotification(it)
@ -117,15 +122,18 @@ class NotificationsManager (private val context: Context) {
return true
}
private fun displayAchievementNotification(notification: Notification): Boolean {
EventBus.getDefault().post(ShowAchievementDialog(notification.type ?: "", notification.id))
logOnboardingEvents(notification.type ?: "")
return true
}
private fun displayGenericAchievementNotification(notification: Notification, isLastOnboardingAchievement: Boolean): Boolean {
val achievement = (notification.data as? AchievementData)?.achievement ?: ""
EventBus.getDefault().post(ShowAchievementDialog(achievement, notification.id, isLastOnboardingAchievement))
private fun displayAchievementNotification(notification: Notification, isLastOnboardingAchievement: Boolean = false): Boolean {
val achievement = (notification.data as? AchievementData)?.achievement ?: notification.type ?: ""
val delay: Long = if (achievement == "createdTask" || achievement == Notification.Type.ACHIEVEMENT_ONBOARDING_COMPLETE.type) {
1000
} else {
200
}
val sub = Completable.complete()
.delay(delay, TimeUnit.MILLISECONDS)
.subscribe(Action {
EventBus.getDefault().post(ShowAchievementDialog(achievement, notification.id, isLastOnboardingAchievement))
}, RxErrorHandler.handleEmptyError())
logOnboardingEvents(achievement)
return true
}

View file

@ -81,6 +81,7 @@ import io.realm.Realm
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import java.util.*
import java.util.concurrent.TimeUnit
import javax.inject.Inject
open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {

View file

@ -97,7 +97,7 @@ class MountDetailRecyclerAdapter(data: OrderedRealmCollection<Mount>?, autoUpdat
return
}
val menu = BottomSheetMenu(itemView.context)
menu.addMenuItem(BottomSheetMenuItem(resources.getString(R.string.use_animal)))
menu.addMenuItem(BottomSheetMenuItem(resources.getString(R.string.equip)))
menu.setSelectionRunnable {
animal?.let { equipEvents.onNext(it.key) }
}

View file

@ -131,7 +131,7 @@ class PetDetailRecyclerAdapter(data: OrderedRealmCollection<Pet>?, autoUpdate: B
}
val context = context ?: return
val menu = BottomSheetMenu(context)
menu.addMenuItem(BottomSheetMenuItem(itemView.resources.getString(R.string.use_animal)))
menu.addMenuItem(BottomSheetMenuItem(itemView.resources.getString(R.string.equip)))
if (canRaiseToMount) {
menu.addMenuItem(BottomSheetMenuItem(itemView.resources.getString(R.string.feed)))
}

View file

@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"properties": [],
"versionCode": 2450,
"versionName": "2450",
"versionCode": 2459,
"versionName": "2459",
"enabled": true,
"outputFile": "Habitica-staff-release.apk"
}