From 424f70bc58f8fcc3d4dfa6708c166c24c042d605 Mon Sep 17 00:00:00 2001 From: Maxime Naturel Date: Fri, 18 Mar 2022 17:27:47 +0100 Subject: [PATCH] Adding new override setting in the debug private settings --- .../debug/settings/DebugPrivateSettingsFragment.kt | 4 ++++ .../settings/DebugPrivateSettingsViewActions.kt | 1 + .../settings/DebugPrivateSettingsViewModel.kt | 14 ++++++++++++-- .../settings/DebugPrivateSettingsViewState.kt | 3 ++- .../res/layout/fragment_debug_private_settings.xml | 6 ++++++ 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt b/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt index 38253fe7c2..735b4079c0 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt @@ -46,6 +46,9 @@ class DebugPrivateSettingsFragment : VectorBaseFragment 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 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) + } + } } diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewState.kt b/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewState.kt index 749b11a744..2eff1575c7 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewState.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewState.kt @@ -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( diff --git a/vector/src/debug/res/layout/fragment_debug_private_settings.xml b/vector/src/debug/res/layout/fragment_debug_private_settings.xml index c42ad68dce..3e89ac9120 100644 --- a/vector/src/debug/res/layout/fragment_debug_private_settings.xml +++ b/vector/src/debug/res/layout/fragment_debug_private_settings.xml @@ -49,6 +49,12 @@ android:layout_marginEnd="16dp" android:layout_marginBottom="4dp" /> + +