Merge branch 'dla/feature/custom_room_notification_settings_list' of https://github.com/vector-im/element-x-android into dla/feature/room_notification_settings_ui_update
This commit is contained in:
commit
03315ae77b
9 changed files with 47 additions and 15 deletions
|
|
@ -89,6 +89,7 @@ fun NotificationSettingsView(
|
|||
onGroupChatsClicked = { onOpenEditDefault(false) },
|
||||
onDirectChatsClicked = { onOpenEditDefault(true) },
|
||||
onMentionNotificationsChanged = { state.eventSink(NotificationSettingsEvents.SetAtRoomNotificationsEnabled(it)) },
|
||||
// TODO We are removing the call notification toggle until support for call notifications has been added
|
||||
// onCallsNotificationsChanged = { state.eventSink(NotificationSettingsEvents.SetCallNotificationsEnabled(it)) },
|
||||
)
|
||||
}
|
||||
|
|
@ -116,6 +117,7 @@ private fun NotificationSettingsContentView(
|
|||
onGroupChatsClicked: () -> Unit,
|
||||
onDirectChatsClicked: () -> Unit,
|
||||
onMentionNotificationsChanged: (Boolean) -> Unit,
|
||||
// TODO We are removing the call notification toggle until support for call notifications has been added
|
||||
// onCallsNotificationsChanged: (Boolean) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
|
|
@ -166,7 +168,7 @@ private fun NotificationSettingsContentView(
|
|||
onCheckedChange = onMentionNotificationsChanged
|
||||
)
|
||||
}
|
||||
// We are removing the call notification toggle until call support has been added
|
||||
// TODO We are removing the call notification toggle until support for call notifications has been added
|
||||
// PreferenceCategory(title = stringResource(id = CommonStrings.screen_notification_settings_additional_settings_section_title)) {
|
||||
// PreferenceSwitch(
|
||||
// modifier = Modifier,
|
||||
|
|
|
|||
|
|
@ -27,11 +27,12 @@ open class EditDefaultNotificationSettingStateProvider: PreviewParameterProvider
|
|||
override val values: Sequence<EditDefaultNotificationSettingState>
|
||||
get() = sequenceOf(
|
||||
anEditDefaultNotificationSettingsState(),
|
||||
anEditDefaultNotificationSettingsState(isOneToOne = true)
|
||||
)
|
||||
}
|
||||
|
||||
fun anEditDefaultNotificationSettingsState() = EditDefaultNotificationSettingState(
|
||||
isOneToOne = false,
|
||||
fun anEditDefaultNotificationSettingsState(isOneToOne: Boolean = false) = EditDefaultNotificationSettingState(
|
||||
isOneToOne = isOneToOne,
|
||||
mode = RoomNotificationMode.MENTIONS_AND_KEYWORDS_ONLY,
|
||||
roomsWithUserDefinedMode = listOf(aRoomSummary()),
|
||||
changeNotificationSettingAction = Async.Uninitialized,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import io.element.android.services.analytics.api.AnalyticsService
|
|||
class RoomNotificationSettingsNode @AssistedInject constructor(
|
||||
@Assisted buildContext: BuildContext,
|
||||
@Assisted plugins: List<Plugin>,
|
||||
private val presenter: RoomNotificationSettingsPresenter,
|
||||
presenterFactory: RoomNotificationSettingsPresenter.Factory,
|
||||
private val analyticsService: AnalyticsService,
|
||||
) : Node(buildContext, plugins = plugins) {
|
||||
|
||||
|
|
@ -53,6 +53,7 @@ class RoomNotificationSettingsNode @AssistedInject constructor(
|
|||
callbacks.forEach { it.openGlobalNotificationSettings() }
|
||||
}
|
||||
|
||||
private val presenter = presenterFactory.create(inputs.showUserDefinedSettingStyle)
|
||||
init {
|
||||
lifecycle.subscribe(
|
||||
onResume = {
|
||||
|
|
@ -64,19 +65,11 @@ class RoomNotificationSettingsNode @AssistedInject constructor(
|
|||
@Composable
|
||||
override fun View(modifier: Modifier) {
|
||||
val state = presenter.present()
|
||||
if(inputs.showUserDefinedSettingStyle) {
|
||||
UserDefinedRoomNotificationSettingsView(
|
||||
state = state,
|
||||
modifier = modifier,
|
||||
onBackPressed = this::navigateUp,
|
||||
)
|
||||
} else {
|
||||
RoomNotificationSettingsView(
|
||||
state = state,
|
||||
modifier = modifier,
|
||||
onShowGlobalNotifications = this::openGlobalNotificationSettings,
|
||||
onBackPressed = this::navigateUp,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ import androidx.compose.runtime.mutableStateOf
|
|||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import io.element.android.libraries.architecture.Async
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import io.element.android.libraries.architecture.runCatchingUpdatingState
|
||||
|
|
@ -36,13 +39,19 @@ import kotlinx.coroutines.flow.debounce
|
|||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
class RoomNotificationSettingsPresenter @Inject constructor(
|
||||
class RoomNotificationSettingsPresenter @AssistedInject constructor(
|
||||
private val room: MatrixRoom,
|
||||
private val notificationSettingsService: NotificationSettingsService,
|
||||
@Assisted private val showUserDefinedSettingStyle: Boolean,
|
||||
) : Presenter<RoomNotificationSettingsState> {
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
fun create(showUserDefinedSettingStyle: Boolean): RoomNotificationSettingsPresenter
|
||||
}
|
||||
|
||||
@Composable
|
||||
override fun present(): RoomNotificationSettingsState {
|
||||
val defaultRoomNotificationMode: MutableState<RoomNotificationMode?> = rememberSaveable {
|
||||
|
|
@ -107,6 +116,7 @@ class RoomNotificationSettingsPresenter @Inject constructor(
|
|||
}
|
||||
|
||||
return RoomNotificationSettingsState(
|
||||
showUserDefinedSettingStyle = showUserDefinedSettingStyle,
|
||||
roomName = room.displayName,
|
||||
roomNotificationSettings = roomNotificationSettings.value,
|
||||
pendingRoomNotificationMode = pendingRoomNotificationMode.value,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import io.element.android.libraries.matrix.api.room.RoomNotificationMode
|
|||
import io.element.android.libraries.matrix.api.room.RoomNotificationSettings
|
||||
|
||||
data class RoomNotificationSettingsState(
|
||||
val showUserDefinedSettingStyle: Boolean,
|
||||
val roomName: String,
|
||||
val roomNotificationSettings: Async<RoomNotificationSettings>,
|
||||
val pendingRoomNotificationMode: RoomNotificationMode?,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ internal class RoomNotificationSettingsStateProvider : PreviewParameterProvider<
|
|||
override val values: Sequence<RoomNotificationSettingsState>
|
||||
get() = sequenceOf(
|
||||
RoomNotificationSettingsState(
|
||||
showUserDefinedSettingStyle = false,
|
||||
roomName = "Room 1",
|
||||
Async.Success(RoomNotificationSettings(
|
||||
mode = RoomNotificationMode.MUTE,
|
||||
|
|
|
|||
|
|
@ -49,12 +49,34 @@ import io.element.android.libraries.matrix.api.room.RoomNotificationMode
|
|||
import io.element.android.libraries.theme.ElementTheme
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
|
||||
|
||||
@Composable
|
||||
fun RoomNotificationSettingsView(
|
||||
state: RoomNotificationSettingsState,
|
||||
modifier: Modifier = Modifier,
|
||||
onShowGlobalNotifications: () -> Unit = {},
|
||||
onBackPressed: () -> Unit = {},
|
||||
) {
|
||||
if(state.showUserDefinedSettingStyle) {
|
||||
UserDefinedRoomNotificationSettingsView(
|
||||
state = state,
|
||||
modifier = modifier,
|
||||
onBackPressed = onBackPressed,
|
||||
)
|
||||
} else {
|
||||
RoomSpecificNotificationSettingsView(
|
||||
state = state,
|
||||
modifier = modifier,
|
||||
onBackPressed = onBackPressed,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RoomSpecificNotificationSettingsView(
|
||||
state: RoomNotificationSettingsState,
|
||||
modifier: Modifier = Modifier,
|
||||
onBackPressed: () -> Unit = {},
|
||||
) {
|
||||
Scaffold(
|
||||
modifier = modifier,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ internal class UserDefinedRoomNotificationSettingsStateProvider : PreviewParamet
|
|||
override val values: Sequence<RoomNotificationSettingsState>
|
||||
get() = sequenceOf(
|
||||
RoomNotificationSettingsState(
|
||||
showUserDefinedSettingStyle = false,
|
||||
roomName = "Room 1",
|
||||
Async.Success(
|
||||
RoomNotificationSettings(
|
||||
|
|
|
|||
|
|
@ -136,7 +136,8 @@ class RoomNotificationSettingsPresenterTests {
|
|||
val room = aMatrixRoom(notificationSettingsService = notificationSettingsService)
|
||||
return RoomNotificationSettingsPresenter(
|
||||
room = room,
|
||||
notificationSettingsService = notificationSettingsService
|
||||
notificationSettingsService = notificationSettingsService,
|
||||
showUserDefinedSettingStyle = false,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue