Implement Notification Settings

- Add UI and logic to inform the user of mismatched notification settings and help them correct it.
- Display a warning when the system notification settings are disabled and a link out to the app settings.
- A toggle to disable notifications for the device
- A screen for editing the group and direct chat notification defaults.
- A toggle for switching on/off atRoom and call notifications.
This commit is contained in:
David Langley 2023-09-12 01:11:13 +01:00
parent e64f0bd7d9
commit a0ac324e3f
27 changed files with 924 additions and 59 deletions

View file

@ -20,6 +20,7 @@ import androidx.test.platform.app.InstrumentationRegistry
import io.element.android.libraries.matrix.api.core.SessionId
import io.element.android.libraries.pushstore.api.UserPushStore
import io.element.android.libraries.sessionstorage.test.observer.NoOpSessionObserver
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import org.junit.Test
import kotlin.concurrent.thread
@ -49,8 +50,8 @@ class DefaultUserPushStoreFactoryTest {
thread1.join()
thread2.join()
runBlocking {
userPushStore1!!.areNotificationEnabledForDevice()
userPushStore2!!.areNotificationEnabledForDevice()
userPushStore1!!.getNotificationEnabledForDevice().first()
userPushStore2!!.getNotificationEnabledForDevice().first()
}
}
}

View file

@ -26,7 +26,9 @@ import androidx.datastore.preferences.preferencesDataStore
import io.element.android.libraries.core.bool.orTrue
import io.element.android.libraries.matrix.api.core.SessionId
import io.element.android.libraries.pushstore.api.UserPushStore
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
/**
* Store data related to push about a user.
@ -60,8 +62,8 @@ class UserPushStoreDataStore(
}
}
override suspend fun areNotificationEnabledForDevice(): Boolean {
return context.dataStore.data.first()[notificationEnabled].orTrue()
override fun getNotificationEnabledForDevice(): Flow<Boolean> {
return context.dataStore.data.map{ it[notificationEnabled].orTrue() }
}
override suspend fun setNotificationEnabledForDevice(enabled: Boolean) {