mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 08:15:02 +00:00
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:
@@ -22,5 +22,6 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.coroutines.core)
|
||||
implementation(projects.libraries.matrix.api)
|
||||
}
|
||||
|
||||
+3
-1
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.pushstore.api
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
|
||||
/**
|
||||
* Store data related to push about a user.
|
||||
@@ -25,7 +27,7 @@ interface UserPushStore {
|
||||
suspend fun getCurrentRegisteredPushKey(): String?
|
||||
suspend fun setCurrentRegisteredPushKey(value: String)
|
||||
|
||||
suspend fun areNotificationEnabledForDevice(): Boolean
|
||||
fun getNotificationEnabledForDevice(): Flow<Boolean>
|
||||
suspend fun setNotificationEnabledForDevice(enabled: Boolean)
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user