Changes vector override to vector feature
This commit is contained in:
parent
b769eafcc3
commit
2f408656a7
|
@ -80,6 +80,11 @@ class DebugFeaturesStateFactory @Inject constructor(
|
||||||
key = DebugFeatureKeys.startDmOnFirstMsg,
|
key = DebugFeatureKeys.startDmOnFirstMsg,
|
||||||
factory = VectorFeatures::shouldStartDmOnFirstMessage
|
factory = VectorFeatures::shouldStartDmOnFirstMessage
|
||||||
),
|
),
|
||||||
|
createBooleanFeature(
|
||||||
|
label = "Enable New App Layout",
|
||||||
|
key = DebugFeatureKeys.newAppLayoutEnabled,
|
||||||
|
factory = VectorFeatures::isNewAppLayoutEnabled
|
||||||
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,9 @@ class DebugVectorFeatures(
|
||||||
override fun shouldStartDmOnFirstMessage(): Boolean = read(DebugFeatureKeys.startDmOnFirstMsg)
|
override fun shouldStartDmOnFirstMessage(): Boolean = read(DebugFeatureKeys.startDmOnFirstMsg)
|
||||||
?: vectorFeatures.shouldStartDmOnFirstMessage()
|
?: vectorFeatures.shouldStartDmOnFirstMessage()
|
||||||
|
|
||||||
|
override fun isNewAppLayoutEnabled(): Boolean = read(DebugFeatureKeys.newAppLayoutEnabled)
|
||||||
|
?: vectorFeatures.isNewAppLayoutEnabled()
|
||||||
|
|
||||||
fun <T> override(value: T?, key: Preferences.Key<T>) = updatePreferences {
|
fun <T> override(value: T?, key: Preferences.Key<T>) = updatePreferences {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
it.remove(key)
|
it.remove(key)
|
||||||
|
@ -131,4 +134,5 @@ object DebugFeatureKeys {
|
||||||
val screenSharing = booleanPreferencesKey("screen-sharing")
|
val screenSharing = booleanPreferencesKey("screen-sharing")
|
||||||
val forceUsageOfOpusEncoder = booleanPreferencesKey("force-usage-of-opus-encoder")
|
val forceUsageOfOpusEncoder = booleanPreferencesKey("force-usage-of-opus-encoder")
|
||||||
val startDmOnFirstMsg = booleanPreferencesKey("start-dm-on-first-msg")
|
val startDmOnFirstMsg = booleanPreferencesKey("start-dm-on-first-msg")
|
||||||
|
val newAppLayoutEnabled = booleanPreferencesKey("new-app-layout-enabled")
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ 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")
|
||||||
|
|
||||||
|
@ -45,10 +44,6 @@ 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],
|
||||||
|
@ -68,12 +63,6 @@ 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,9 +46,6 @@ 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) {
|
||||||
|
@ -60,6 +57,5 @@ 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,7 +21,6 @@ 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,21 +47,22 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor(
|
||||||
|
|
||||||
private fun observeVectorOverrides() {
|
private fun observeVectorOverrides() {
|
||||||
debugVectorOverrides.forceDialPad.setOnEach {
|
debugVectorOverrides.forceDialPad.setOnEach {
|
||||||
copy(dialPadVisible = it)
|
copy(
|
||||||
|
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(homeserverCapabilityOverrides = homeserverCapabilityOverrides.copy(
|
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),
|
||||||
))
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +70,6 @@ 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,12 +87,6 @@ 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,7 +22,6 @@ 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,12 +49,6 @@
|
||||||
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,7 +22,6 @@ 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>?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +33,5 @@ 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
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ interface VectorFeatures {
|
||||||
fun isScreenSharingEnabled(): Boolean
|
fun isScreenSharingEnabled(): Boolean
|
||||||
fun forceUsageOfOpusEncoder(): Boolean
|
fun forceUsageOfOpusEncoder(): Boolean
|
||||||
fun shouldStartDmOnFirstMessage(): Boolean
|
fun shouldStartDmOnFirstMessage(): Boolean
|
||||||
|
fun isNewAppLayoutEnabled(): Boolean
|
||||||
|
|
||||||
enum class OnboardingVariant {
|
enum class OnboardingVariant {
|
||||||
LEGACY,
|
LEGACY,
|
||||||
|
@ -52,4 +53,5 @@ class DefaultVectorFeatures : VectorFeatures {
|
||||||
override fun isScreenSharingEnabled(): Boolean = true
|
override fun isScreenSharingEnabled(): Boolean = true
|
||||||
override fun forceUsageOfOpusEncoder(): Boolean = false
|
override fun forceUsageOfOpusEncoder(): Boolean = false
|
||||||
override fun shouldStartDmOnFirstMessage(): Boolean = false
|
override fun shouldStartDmOnFirstMessage(): Boolean = false
|
||||||
|
override fun isNewAppLayoutEnabled(): Boolean = false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue