mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-05-14 09:46:48 -04:00
fix: cancel new message notification when message is marked as read (#2057)
Co-authored-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import android.content.SharedPreferences
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.ProcessLifecycleOwner
|
||||
import com.geeksville.mesh.service.MeshServiceNotifications
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
@@ -45,4 +46,9 @@ object ApplicationModule {
|
||||
fun provideProcessLifecycle(processLifecycleOwner: LifecycleOwner): Lifecycle {
|
||||
return processLifecycleOwner.lifecycle
|
||||
}
|
||||
|
||||
@Provides
|
||||
fun providesMeshServiceNotifications(application: Application): MeshServiceNotifications {
|
||||
return MeshServiceNotifications(application)
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,7 @@ import com.geeksville.mesh.repository.datastore.RadioConfigRepository
|
||||
import com.geeksville.mesh.repository.location.LocationRepository
|
||||
import com.geeksville.mesh.repository.radio.RadioInterfaceService
|
||||
import com.geeksville.mesh.service.MeshService
|
||||
import com.geeksville.mesh.service.MeshServiceNotifications
|
||||
import com.geeksville.mesh.service.ServiceAction
|
||||
import com.geeksville.mesh.ui.map.MAP_STYLE_ID
|
||||
import com.geeksville.mesh.ui.node.components.NodeMenuAction
|
||||
@@ -190,7 +191,8 @@ class UIViewModel @Inject constructor(
|
||||
private val quickChatActionRepository: QuickChatActionRepository,
|
||||
private val locationRepository: LocationRepository,
|
||||
firmwareReleaseRepository: FirmwareReleaseRepository,
|
||||
private val preferences: SharedPreferences
|
||||
private val preferences: SharedPreferences,
|
||||
private val meshServiceNotifications: MeshServiceNotifications
|
||||
) : ViewModel(), Logging {
|
||||
|
||||
private val _theme =
|
||||
@@ -573,6 +575,8 @@ class UIViewModel @Inject constructor(
|
||||
|
||||
fun clearUnreadCount(contact: String, timestamp: Long) = viewModelScope.launch(Dispatchers.IO) {
|
||||
packetRepository.clearUnreadCount(contact, timestamp)
|
||||
val unreadCount = packetRepository.getUnreadCount(contact)
|
||||
if (unreadCount == 0) meshServiceNotifications.cancelMessageNotification(contact)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -150,6 +150,9 @@ class MeshService : Service(), Logging {
|
||||
@Inject
|
||||
lateinit var mqttRepository: MQTTRepository
|
||||
|
||||
@Inject
|
||||
lateinit var serviceNotifications: MeshServiceNotifications
|
||||
|
||||
companion object : Logging {
|
||||
|
||||
// Intents broadcast by MeshService
|
||||
@@ -212,7 +215,6 @@ class MeshService : Service(), Logging {
|
||||
|
||||
// A mapping of receiver class name to package name - used for explicit broadcasts
|
||||
private val clientPackages = mutableMapOf<String, String>()
|
||||
private val serviceNotifications = MeshServiceNotifications(this)
|
||||
private val serviceBroadcasts = MeshServiceBroadcasts(this, clientPackages) {
|
||||
connectionState.also { radioConfigRepository.setConnectionState(it) }
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ class ReplyReceiver : BroadcastReceiver() {
|
||||
@Inject
|
||||
lateinit var serviceRepository: ServiceRepository
|
||||
|
||||
@Inject
|
||||
lateinit var meshServiceNotifications: MeshServiceNotifications
|
||||
|
||||
companion object {
|
||||
const val REPLY_ACTION = "com.geeksville.mesh.REPLY_ACTION"
|
||||
const val CONTACT_KEY = "contactKey"
|
||||
|
||||
Reference in New Issue
Block a user