Adding new override setting in the debug private settings

This commit is contained in:
Maxime Naturel 2022-03-18 17:27:47 +01:00 committed by Maxime NATUREL
parent 93876737e7
commit 424f70bc58
5 changed files with 25 additions and 3 deletions

View File

@ -46,6 +46,9 @@ class DebugPrivateSettingsFragment : VectorBaseFragment<FragmentDebugPrivateSett
views.forceLoginFallback.setOnCheckedChangeListener { _, isChecked ->
viewModel.handle(DebugPrivateSettingsViewActions.SetForceLoginFallbackEnabled(isChecked))
}
views.forceEnableLiveLocationSharing.setOnCheckedChangeListener { _, isChecked ->
viewModel.handle(DebugPrivateSettingsViewActions.SetEnableLiveLocationSharing(isChecked))
}
}
override fun invalidate() = withState(viewModel) {
@ -57,5 +60,6 @@ class DebugPrivateSettingsFragment : VectorBaseFragment<FragmentDebugPrivateSett
viewModel.handle(DebugPrivateSettingsViewActions.SetAvatarCapabilityOverride(option))
}
views.forceLoginFallback.isChecked = it.forceLoginFallback
views.forceEnableLiveLocationSharing.isChecked = it.forceEnableLiveLocationSharing
}
}

View File

@ -23,4 +23,5 @@ sealed interface DebugPrivateSettingsViewActions : VectorViewModelAction {
data class SetForceLoginFallbackEnabled(val force: Boolean) : DebugPrivateSettingsViewActions
data class SetDisplayNameCapabilityOverride(val option: BooleanHomeserverCapabilitiesOverride?) : DebugPrivateSettingsViewActions
data class SetAvatarCapabilityOverride(val option: BooleanHomeserverCapabilitiesOverride?) : DebugPrivateSettingsViewActions
data class SetEnableLiveLocationSharing(val force: Boolean) : DebugPrivateSettingsViewActions
}

View File

@ -62,6 +62,9 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor(
avatar = homeserverCapabilityOverrides.avatar.copy(activeOption = activeAvatarOption),
))
}
debugVectorOverrides.forceEnableLiveLocationSharing.setOnEach {
copy(forceEnableLiveLocationSharing = it)
}
}
override fun handle(action: DebugPrivateSettingsViewActions) {
@ -70,6 +73,7 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor(
is DebugPrivateSettingsViewActions.SetForceLoginFallbackEnabled -> handleSetForceLoginFallbackEnabled(action)
is SetDisplayNameCapabilityOverride -> handSetDisplayNameCapabilityOverride(action)
is SetAvatarCapabilityOverride -> handSetAvatarCapabilityOverride(action)
is DebugPrivateSettingsViewActions.SetEnableLiveLocationSharing -> handleSetEnableLiveLocationSharingOverride(action)
}
}
@ -85,17 +89,23 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor(
}
}
private fun handSetDisplayNameCapabilityOverride(action: SetDisplayNameCapabilityOverride) {
private fun handleSetDisplayNameCapabilityOverride(action: SetDisplayNameCapabilityOverride) {
viewModelScope.launch {
val forceDisplayName = action.option.toBoolean()
debugVectorOverrides.setHomeserverCapabilities { copy(canChangeDisplayName = forceDisplayName) }
}
}
private fun handSetAvatarCapabilityOverride(action: SetAvatarCapabilityOverride) {
private fun handleSetAvatarCapabilityOverride(action: SetAvatarCapabilityOverride) {
viewModelScope.launch {
val forceAvatar = action.option.toBoolean()
debugVectorOverrides.setHomeserverCapabilities { copy(canChangeAvatar = forceAvatar) }
}
}
private fun handleSetEnableLiveLocationSharingOverride(action: DebugPrivateSettingsViewActions.SetEnableLiveLocationSharing) {
viewModelScope.launch {
debugVectorOverrides.setForceEnableLiveLocationSharing(action.force)
}
}
}

View File

@ -22,7 +22,8 @@ import im.vector.app.features.debug.settings.OverrideDropdownView.OverrideDropdo
data class DebugPrivateSettingsViewState(
val dialPadVisible: Boolean = false,
val forceLoginFallback: Boolean = false,
val homeserverCapabilityOverrides: HomeserverCapabilityOverrides = HomeserverCapabilityOverrides()
val homeserverCapabilityOverrides: HomeserverCapabilityOverrides = HomeserverCapabilityOverrides(),
val forceEnableLiveLocationSharing: Boolean = false
) : MavericksState
data class HomeserverCapabilityOverrides(

View File

@ -49,6 +49,12 @@
android:layout_marginEnd="16dp"
android:layout_marginBottom="4dp" />
<CheckBox
android:id="@+id/forceEnableLiveLocationSharing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Force enable of live location sharing" />
</LinearLayout>
</ScrollView>