mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Notification settings: pick custom sounds for messages and call ringtones (#6897)
* Notification settings: pick custom sounds for messages and call ringtones (#6702) * Feature: add notification sound settings for messages and calls * Add sound not available banner, accessibility checks * Fix build and Konsist convention violations - libraries:preferences:api now uses io.element.android-compose-library so NotificationSound's @Immutable annotation can resolve, matching the pattern in libraries:matrix:api. - Rename SoundUnavailableBannerStateProvider to NotificationSoundUnavailableStateProvider so the class name contains the parameter type as required by KonsistClassNameTest. * Suppress LargeClass on RoomListPresenterTest The three new sound-unavailable tests pushed the class past Detekt's default LargeClass threshold. Matches the suppression pattern already used on five presenter test classes under features/messages/impl/test. * NotificationSettingsView: guard ringtone-picker launchers in inspection mode rememberLauncherForActivityResult requires a LocalActivityResultRegistryOwner, which Paparazzi-driven preview snapshot tests don't provide, causing NotificationSettingsViewPreview to throw IllegalStateException for every preview parameter. Extract the click handlers into a helper that returns a no-op when LocalInspectionMode.current is true; the runtime path is unchanged. * Handle unresolved notification sounds mid session * Quality checks, refactor mid session error ui * Suppress detekt LargeClass on NotificationSettingsPresenterTest * Remove notification sound resilience layer, replace with file copy * Reselect element sound option, code cleanup * Add element fade notification sound option * Fix new file headers * Revert to flowOf(Unit) for announcement service * Add ringtone picker dialog to match message selector * Update strings in conjunction with ios * Update test to reflect new string * Sync strings. * Update screenshots * Fix test * Remove not properly located translations. This will be fixed in the next String sync. * Fix test on CI --------- Co-authored-by: Jenna Vassar <jenna.vassar@toptal.com> Co-authored-by: ElementBot <android@element.io>
This commit is contained in:
+56
-2
@@ -12,8 +12,11 @@ import io.element.android.libraries.matrix.api.media.MediaPreviewValue
|
||||
import io.element.android.libraries.matrix.api.tracing.LogLevel
|
||||
import io.element.android.libraries.matrix.api.tracing.TraceLogPack
|
||||
import io.element.android.libraries.preferences.api.store.AppPreferencesStore
|
||||
import io.element.android.libraries.preferences.api.store.NotificationSound
|
||||
import io.element.android.libraries.preferences.api.store.NotificationSoundChannelConfig
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.updateAndGet
|
||||
|
||||
class InMemoryAppPreferencesStore(
|
||||
isDeveloperModeEnabled: Boolean = false,
|
||||
@@ -23,16 +26,28 @@ class InMemoryAppPreferencesStore(
|
||||
theme: String? = null,
|
||||
liveLocationMinimumDistanceUpdate: Int = 10,
|
||||
logLevel: LogLevel = LogLevel.INFO,
|
||||
traceLockPacks: Set<TraceLogPack> = emptySet(),
|
||||
traceLogPacks: Set<TraceLogPack> = emptySet(),
|
||||
messageSound: NotificationSound = NotificationSound.SystemDefault,
|
||||
messageSoundChannelVersion: Int = 0,
|
||||
messageSoundDisplayName: String? = null,
|
||||
callRingtone: NotificationSound = NotificationSound.SystemDefault,
|
||||
callRingtoneChannelVersion: Int = 0,
|
||||
callRingtoneDisplayName: String? = null,
|
||||
) : AppPreferencesStore {
|
||||
private val isDeveloperModeEnabled = MutableStateFlow(isDeveloperModeEnabled)
|
||||
private val customElementCallBaseUrl = MutableStateFlow(customElementCallBaseUrl)
|
||||
private val theme = MutableStateFlow(theme)
|
||||
private val liveLocationMinimumDistanceUpdate = MutableStateFlow(liveLocationMinimumDistanceUpdate)
|
||||
private val logLevel = MutableStateFlow(logLevel)
|
||||
private val tracingLogPacks = MutableStateFlow(traceLockPacks)
|
||||
private val tracingLogPacks = MutableStateFlow(traceLogPacks)
|
||||
private val hideInviteAvatars = MutableStateFlow(hideInviteAvatars)
|
||||
private val timelineMediaPreviewValue = MutableStateFlow(timelineMediaPreviewValue)
|
||||
private val messageSound = MutableStateFlow(messageSound)
|
||||
private val messageSoundChannelVersion = MutableStateFlow(messageSoundChannelVersion)
|
||||
private val messageSoundDisplayName = MutableStateFlow(messageSoundDisplayName)
|
||||
private val callRingtone = MutableStateFlow(callRingtone)
|
||||
private val callRingtoneChannelVersion = MutableStateFlow(callRingtoneChannelVersion)
|
||||
private val callRingtoneDisplayName = MutableStateFlow(callRingtoneDisplayName)
|
||||
|
||||
override suspend fun setDeveloperModeEnabled(enabled: Boolean) {
|
||||
isDeveloperModeEnabled.value = enabled
|
||||
@@ -102,6 +117,45 @@ class InMemoryAppPreferencesStore(
|
||||
return tracingLogPacks
|
||||
}
|
||||
|
||||
override fun getMessageSoundFlow(): Flow<NotificationSound> {
|
||||
return messageSound
|
||||
}
|
||||
|
||||
override suspend fun setMessageSoundAndIncrementVersion(sound: NotificationSound, title: String?): Int {
|
||||
messageSound.value = sound
|
||||
messageSoundDisplayName.value = if (sound is NotificationSound.Custom && !title.isNullOrBlank()) title else null
|
||||
return messageSoundChannelVersion.updateAndGet { it + 1 }
|
||||
}
|
||||
|
||||
override fun getMessageSoundDisplayNameFlow(): Flow<String?> {
|
||||
return messageSoundDisplayName
|
||||
}
|
||||
|
||||
override fun getCallRingtoneFlow(): Flow<NotificationSound> {
|
||||
return callRingtone
|
||||
}
|
||||
|
||||
override suspend fun setCallRingtoneAndIncrementVersion(sound: NotificationSound, title: String?): Int {
|
||||
callRingtone.value = sound
|
||||
callRingtoneDisplayName.value = if (sound is NotificationSound.Custom && !title.isNullOrBlank()) title else null
|
||||
return callRingtoneChannelVersion.updateAndGet { it + 1 }
|
||||
}
|
||||
|
||||
override fun getCallRingtoneDisplayNameFlow(): Flow<String?> {
|
||||
return callRingtoneDisplayName
|
||||
}
|
||||
|
||||
override suspend fun getNotificationSoundChannelConfig(): NotificationSoundChannelConfig {
|
||||
return NotificationSoundChannelConfig(
|
||||
messageSound = messageSound.value,
|
||||
messageSoundVersion = messageSoundChannelVersion.value,
|
||||
messageSoundDisplayName = messageSoundDisplayName.value,
|
||||
callRingtone = callRingtone.value,
|
||||
callRingtoneVersion = callRingtoneChannelVersion.value,
|
||||
callRingtoneDisplayName = callRingtoneDisplayName.value,
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun reset() {
|
||||
// No op
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user