Fix hide shields setting getting reset to true when opening Labs page

This commit is contained in:
Jarno Rankinen 2023-09-01 23:08:17 +03:00
parent aa609fdeb6
commit 86878e70f9
3 changed files with 8 additions and 6 deletions

View File

@ -85,6 +85,11 @@ class DebugFeaturesStateFactory @Inject constructor(
key = DebugFeatureKeys.newAppLayoutEnabled, key = DebugFeatureKeys.newAppLayoutEnabled,
factory = VectorFeatures::isNewAppLayoutFeatureEnabled factory = VectorFeatures::isNewAppLayoutFeatureEnabled
), ),
createBooleanFeature(
label = "Disable Encryption Shields",
key = DebugFeatureKeys.shieldVisibilityDisabled,
factory = VectorFeatures::isShieldVisibilityDisabled
),
createBooleanFeature( createBooleanFeature(
label = "Enable QR Code Login", label = "Enable QR Code Login",
key = DebugFeatureKeys.qrCodeLoginEnabled, key = DebugFeatureKeys.qrCodeLoginEnabled,

View File

@ -306,6 +306,8 @@ class VectorPreferences @Inject constructor(
SETTINGS_SECURITY_USE_FLAG_SECURE, SETTINGS_SECURITY_USE_FLAG_SECURE,
SETTINGS_SECURITY_INCOGNITO_KEYBOARD_PREFERENCE_KEY, SETTINGS_SECURITY_INCOGNITO_KEYBOARD_PREFERENCE_KEY,
SETTINGS_LABS_HIDE_SHIELDS_KEY,
ShortcutsHandler.SHARED_PREF_KEY, ShortcutsHandler.SHARED_PREF_KEY,
) )
} }
@ -1222,8 +1224,7 @@ class VectorPreferences @Inject constructor(
* Indicates if the encryption shields in rooms next to messages are hidden * Indicates if the encryption shields in rooms next to messages are hidden
*/ */
fun isShieldVisibilityDisabled() : Boolean { fun isShieldVisibilityDisabled() : Boolean {
return vectorFeatures.isShieldVisibilityDisabled() && return defaultPrefs.getBoolean(SETTINGS_LABS_HIDE_SHIELDS_KEY, getDefault(R.bool.settings_labs_hide_shields_default))
defaultPrefs.getBoolean(SETTINGS_LABS_HIDE_SHIELDS_KEY, getDefault(R.bool.settings_labs_hide_shields_default))
} }
/** /**

View File

@ -96,10 +96,6 @@ class VectorSettingsLabsFragment :
} }
} }
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_HIDE_SHIELDS_KEY)?.let { pref ->
pref.isChecked = vectorFeatures.isShieldVisibilityDisabled()
}
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_VOICE_BROADCAST_KEY)?.let { pref -> findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_VOICE_BROADCAST_KEY)?.let { pref ->
// Voice Broadcast recording is not available on Android < 10 // Voice Broadcast recording is not available on Android < 10
pref.isVisible = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && vectorFeatures.isVoiceBroadcastEnabled() pref.isVisible = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && vectorFeatures.isVoiceBroadcastEnabled()