mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-18 07:11:58 +03:00
Adds new app layout enabled feature flag
This commit is contained in:
parent
069c0c7cb4
commit
fbd1763dcf
7 changed files with 38 additions and 7 deletions
|
@ -31,6 +31,7 @@ import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "vector_overrides")
|
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "vector_overrides")
|
||||||
private val keyForceDialPadDisplay = booleanPreferencesKey("force_dial_pad_display")
|
private val keyForceDialPadDisplay = booleanPreferencesKey("force_dial_pad_display")
|
||||||
private val keyForceLoginFallback = booleanPreferencesKey("force_login_fallback")
|
private val keyForceLoginFallback = booleanPreferencesKey("force_login_fallback")
|
||||||
|
private val keyNewAppLayoutEnabled = booleanPreferencesKey("new_app_layout_enabled")
|
||||||
private val forceCanChangeDisplayName = booleanPreferencesKey("force_can_change_display_name")
|
private val forceCanChangeDisplayName = booleanPreferencesKey("force_can_change_display_name")
|
||||||
private val forceCanChangeAvatar = booleanPreferencesKey("force_can_change_avatar")
|
private val forceCanChangeAvatar = booleanPreferencesKey("force_can_change_avatar")
|
||||||
|
|
||||||
|
@ -44,6 +45,10 @@ class DebugVectorOverrides(private val context: Context) : VectorOverrides {
|
||||||
preferences[keyForceLoginFallback].orFalse()
|
preferences[keyForceLoginFallback].orFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val newAppLayoutEnabled = context.dataStore.data.map { preferences ->
|
||||||
|
preferences[keyNewAppLayoutEnabled].orFalse()
|
||||||
|
}
|
||||||
|
|
||||||
override val forceHomeserverCapabilities = context.dataStore.data.map { preferences ->
|
override val forceHomeserverCapabilities = context.dataStore.data.map { preferences ->
|
||||||
HomeserverCapabilitiesOverride(
|
HomeserverCapabilitiesOverride(
|
||||||
canChangeDisplayName = preferences[forceCanChangeDisplayName],
|
canChangeDisplayName = preferences[forceCanChangeDisplayName],
|
||||||
|
@ -63,6 +68,12 @@ class DebugVectorOverrides(private val context: Context) : VectorOverrides {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun setNewAppLayoutEnabled(enabled: Boolean) {
|
||||||
|
context.dataStore.edit { settings ->
|
||||||
|
settings[keyNewAppLayoutEnabled] = enabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun setHomeserverCapabilities(block: HomeserverCapabilitiesOverride.() -> HomeserverCapabilitiesOverride) {
|
suspend fun setHomeserverCapabilities(block: HomeserverCapabilitiesOverride.() -> HomeserverCapabilitiesOverride) {
|
||||||
val capabilitiesOverride = block(forceHomeserverCapabilities.firstOrNull() ?: HomeserverCapabilitiesOverride(null, null))
|
val capabilitiesOverride = block(forceHomeserverCapabilities.firstOrNull() ?: HomeserverCapabilitiesOverride(null, null))
|
||||||
context.dataStore.edit { settings ->
|
context.dataStore.edit { settings ->
|
||||||
|
|
|
@ -46,6 +46,9 @@ class DebugPrivateSettingsFragment : VectorBaseFragment<FragmentDebugPrivateSett
|
||||||
views.forceLoginFallback.setOnCheckedChangeListener { _, isChecked ->
|
views.forceLoginFallback.setOnCheckedChangeListener { _, isChecked ->
|
||||||
viewModel.handle(DebugPrivateSettingsViewActions.SetForceLoginFallbackEnabled(isChecked))
|
viewModel.handle(DebugPrivateSettingsViewActions.SetForceLoginFallbackEnabled(isChecked))
|
||||||
}
|
}
|
||||||
|
views.newAppLayoutEnabled.setOnCheckedChangeListener { _, isChecked ->
|
||||||
|
viewModel.handle(DebugPrivateSettingsViewActions.SetNewAppLayoutEnabled(isChecked))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun invalidate() = withState(viewModel) {
|
override fun invalidate() = withState(viewModel) {
|
||||||
|
@ -57,5 +60,6 @@ class DebugPrivateSettingsFragment : VectorBaseFragment<FragmentDebugPrivateSett
|
||||||
viewModel.handle(DebugPrivateSettingsViewActions.SetAvatarCapabilityOverride(option))
|
viewModel.handle(DebugPrivateSettingsViewActions.SetAvatarCapabilityOverride(option))
|
||||||
}
|
}
|
||||||
views.forceLoginFallback.isChecked = it.forceLoginFallback
|
views.forceLoginFallback.isChecked = it.forceLoginFallback
|
||||||
|
views.newAppLayoutEnabled.isChecked = it.newAppLayoutEnabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import im.vector.app.core.platform.VectorViewModelAction
|
||||||
sealed interface DebugPrivateSettingsViewActions : VectorViewModelAction {
|
sealed interface DebugPrivateSettingsViewActions : VectorViewModelAction {
|
||||||
data class SetDialPadVisibility(val force: Boolean) : DebugPrivateSettingsViewActions
|
data class SetDialPadVisibility(val force: Boolean) : DebugPrivateSettingsViewActions
|
||||||
data class SetForceLoginFallbackEnabled(val force: Boolean) : DebugPrivateSettingsViewActions
|
data class SetForceLoginFallbackEnabled(val force: Boolean) : DebugPrivateSettingsViewActions
|
||||||
|
data class SetNewAppLayoutEnabled(val enabled: Boolean) : DebugPrivateSettingsViewActions
|
||||||
data class SetDisplayNameCapabilityOverride(val option: BooleanHomeserverCapabilitiesOverride?) : DebugPrivateSettingsViewActions
|
data class SetDisplayNameCapabilityOverride(val option: BooleanHomeserverCapabilitiesOverride?) : DebugPrivateSettingsViewActions
|
||||||
data class SetAvatarCapabilityOverride(val option: BooleanHomeserverCapabilitiesOverride?) : DebugPrivateSettingsViewActions
|
data class SetAvatarCapabilityOverride(val option: BooleanHomeserverCapabilitiesOverride?) : DebugPrivateSettingsViewActions
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,22 +47,21 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor(
|
||||||
|
|
||||||
private fun observeVectorOverrides() {
|
private fun observeVectorOverrides() {
|
||||||
debugVectorOverrides.forceDialPad.setOnEach {
|
debugVectorOverrides.forceDialPad.setOnEach {
|
||||||
copy(
|
copy(dialPadVisible = it)
|
||||||
dialPadVisible = it
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
debugVectorOverrides.forceLoginFallback.setOnEach {
|
debugVectorOverrides.forceLoginFallback.setOnEach {
|
||||||
copy(forceLoginFallback = it)
|
copy(forceLoginFallback = it)
|
||||||
}
|
}
|
||||||
|
debugVectorOverrides.newAppLayoutEnabled.setOnEach {
|
||||||
|
copy(newAppLayoutEnabled = it)
|
||||||
|
}
|
||||||
debugVectorOverrides.forceHomeserverCapabilities.setOnEach {
|
debugVectorOverrides.forceHomeserverCapabilities.setOnEach {
|
||||||
val activeDisplayNameOption = BooleanHomeserverCapabilitiesOverride.from(it.canChangeDisplayName)
|
val activeDisplayNameOption = BooleanHomeserverCapabilitiesOverride.from(it.canChangeDisplayName)
|
||||||
val activeAvatarOption = BooleanHomeserverCapabilitiesOverride.from(it.canChangeAvatar)
|
val activeAvatarOption = BooleanHomeserverCapabilitiesOverride.from(it.canChangeAvatar)
|
||||||
copy(
|
copy(homeserverCapabilityOverrides = homeserverCapabilityOverrides.copy(
|
||||||
homeserverCapabilityOverrides = homeserverCapabilityOverrides.copy(
|
|
||||||
displayName = homeserverCapabilityOverrides.displayName.copy(activeOption = activeDisplayNameOption),
|
displayName = homeserverCapabilityOverrides.displayName.copy(activeOption = activeDisplayNameOption),
|
||||||
avatar = homeserverCapabilityOverrides.avatar.copy(activeOption = activeAvatarOption),
|
avatar = homeserverCapabilityOverrides.avatar.copy(activeOption = activeAvatarOption),
|
||||||
)
|
))
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +69,7 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor(
|
||||||
when (action) {
|
when (action) {
|
||||||
is DebugPrivateSettingsViewActions.SetDialPadVisibility -> handleSetDialPadVisibility(action)
|
is DebugPrivateSettingsViewActions.SetDialPadVisibility -> handleSetDialPadVisibility(action)
|
||||||
is DebugPrivateSettingsViewActions.SetForceLoginFallbackEnabled -> handleSetForceLoginFallbackEnabled(action)
|
is DebugPrivateSettingsViewActions.SetForceLoginFallbackEnabled -> handleSetForceLoginFallbackEnabled(action)
|
||||||
|
is DebugPrivateSettingsViewActions.SetNewAppLayoutEnabled -> handleSetNewAppLayoutEnabled(action)
|
||||||
is SetDisplayNameCapabilityOverride -> handleSetDisplayNameCapabilityOverride(action)
|
is SetDisplayNameCapabilityOverride -> handleSetDisplayNameCapabilityOverride(action)
|
||||||
is SetAvatarCapabilityOverride -> handleSetAvatarCapabilityOverride(action)
|
is SetAvatarCapabilityOverride -> handleSetAvatarCapabilityOverride(action)
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,12 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleSetNewAppLayoutEnabled(action: DebugPrivateSettingsViewActions.SetNewAppLayoutEnabled) {
|
||||||
|
viewModelScope.launch {
|
||||||
|
debugVectorOverrides.setNewAppLayoutEnabled(action.enabled)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun handleSetDisplayNameCapabilityOverride(action: SetDisplayNameCapabilityOverride) {
|
private fun handleSetDisplayNameCapabilityOverride(action: SetDisplayNameCapabilityOverride) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val forceDisplayName = action.option.toBoolean()
|
val forceDisplayName = action.option.toBoolean()
|
||||||
|
|
|
@ -22,6 +22,7 @@ import im.vector.app.features.debug.settings.OverrideDropdownView.OverrideDropdo
|
||||||
data class DebugPrivateSettingsViewState(
|
data class DebugPrivateSettingsViewState(
|
||||||
val dialPadVisible: Boolean = false,
|
val dialPadVisible: Boolean = false,
|
||||||
val forceLoginFallback: Boolean = false,
|
val forceLoginFallback: Boolean = false,
|
||||||
|
val newAppLayoutEnabled: Boolean = false,
|
||||||
val homeserverCapabilityOverrides: HomeserverCapabilityOverrides = HomeserverCapabilityOverrides()
|
val homeserverCapabilityOverrides: HomeserverCapabilityOverrides = HomeserverCapabilityOverrides()
|
||||||
) : MavericksState
|
) : MavericksState
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,12 @@
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_marginBottom="4dp" />
|
android:layout_marginBottom="4dp" />
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/newAppLayoutEnabled"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Enable new app layout" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
|
@ -22,6 +22,7 @@ import kotlinx.coroutines.flow.flowOf
|
||||||
interface VectorOverrides {
|
interface VectorOverrides {
|
||||||
val forceDialPad: Flow<Boolean>
|
val forceDialPad: Flow<Boolean>
|
||||||
val forceLoginFallback: Flow<Boolean>
|
val forceLoginFallback: Flow<Boolean>
|
||||||
|
val newAppLayoutEnabled: Flow<Boolean>
|
||||||
val forceHomeserverCapabilities: Flow<HomeserverCapabilitiesOverride>?
|
val forceHomeserverCapabilities: Flow<HomeserverCapabilitiesOverride>?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,5 +34,6 @@ data class HomeserverCapabilitiesOverride(
|
||||||
class DefaultVectorOverrides : VectorOverrides {
|
class DefaultVectorOverrides : VectorOverrides {
|
||||||
override val forceDialPad = flowOf(false)
|
override val forceDialPad = flowOf(false)
|
||||||
override val forceLoginFallback = flowOf(false)
|
override val forceLoginFallback = flowOf(false)
|
||||||
|
override val newAppLayoutEnabled = flowOf(false)
|
||||||
override val forceHomeserverCapabilities: Flow<HomeserverCapabilitiesOverride>? = null
|
override val forceHomeserverCapabilities: Flow<HomeserverCapabilitiesOverride>? = null
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue