mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-16 11:11:41 +00:00
Change badge color to gray if all notifications seen
This commit is contained in:
parent
edc54be6a4
commit
140f3eefea
3 changed files with 904 additions and 880 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -2,11 +2,14 @@ package com.habitrpg.android.habitica.ui.fragments
|
|||
|
||||
|
||||
import android.app.ActionBar
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import com.habitrpg.android.habitica.HabiticaBaseApplication
|
||||
|
|
@ -315,6 +318,15 @@ class NavigationDrawerFragment : DialogFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
fun setNotificationsSeen(allSeen: Boolean) {
|
||||
context.notNull {
|
||||
val colorId = if (allSeen) R.color.gray_200 else R.color.brand_400
|
||||
|
||||
val bg = notificationsBadge.background as GradientDrawable
|
||||
bg.color = ColorStateList.valueOf(ContextCompat.getColor(it, colorId))
|
||||
}
|
||||
}
|
||||
|
||||
fun setMessagesCount(unreadMessages: Int) {
|
||||
if (unreadMessages == 0) {
|
||||
messagesBadge.visibility = View.GONE
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.habitrpg.android.habitica.ui.viewmodels
|
||||
|
||||
import com.habitrpg.android.habitica.components.AppComponent
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.models.notifications.GlobalNotification
|
||||
import com.habitrpg.android.habitica.models.notifications.NewChatMessageData
|
||||
import com.habitrpg.android.habitica.models.notifications.NotificationType
|
||||
|
|
@ -8,6 +9,7 @@ import com.habitrpg.android.habitica.models.social.UserParty
|
|||
import com.playseeds.android.sdk.inappmessaging.Log
|
||||
import io.reactivex.Flowable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.functions.Consumer
|
||||
import io.realm.RealmList
|
||||
|
||||
|
||||
|
|
@ -28,10 +30,17 @@ open class NotificationsViewModel : BaseViewModel() {
|
|||
fun getNotificationCount(): Flowable<Int> {
|
||||
return getNotifications()
|
||||
.map { it.count() }
|
||||
.distinctUntilChanged()
|
||||
}
|
||||
|
||||
fun allNotificationsSeen(): Flowable<Boolean> {
|
||||
return getNotifications()
|
||||
.map { it.all { notification -> notification.seen == true } }
|
||||
.distinctUntilChanged()
|
||||
}
|
||||
|
||||
fun refreshNotifications(): Flowable<RealmList<GlobalNotification>> {
|
||||
return userRepository.retrieveUser(false, true).map { it.notifications }
|
||||
return userRepository.retrieveUser(withTasks = false, forced = true).map { it.notifications }
|
||||
}
|
||||
|
||||
private fun filterSupportedTypes(notifications: List<GlobalNotification>): List<GlobalNotification> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue