Add setting in Labs to hide the encyption shields from next to messages in rooms

This commit is contained in:
Jarno Rankinen 2023-10-07 13:54:36 +03:00
parent 80c35b3145
commit 8115e2eb0f
8 changed files with 32 additions and 1 deletions

View File

@ -463,6 +463,9 @@
<string name="labs_enable_new_app_layout_title">Enable new layout</string> <string name="labs_enable_new_app_layout_title">Enable new layout</string>
<string name="labs_enable_new_app_layout_summary">A simplified Element with optional tabs</string> <string name="labs_enable_new_app_layout_summary">A simplified Element with optional tabs</string>
<string name="labs_enable_hide_shields_title">Hide encryption shields</string>
<string name="labs_enable_hide_shields_summary">Hide encryption shields next to messages in rooms</string>
<string name="labs_enable_deferred_dm_title">Enable deferred DMs</string> <string name="labs_enable_deferred_dm_title">Enable deferred DMs</string>
<string name="labs_enable_deferred_dm_summary">Create DM only on first message</string> <string name="labs_enable_deferred_dm_summary">Create DM only on first message</string>

View File

@ -76,6 +76,9 @@ class DebugVectorFeatures(
override fun isNewAppLayoutFeatureEnabled(): Boolean = read(DebugFeatureKeys.newAppLayoutEnabled) override fun isNewAppLayoutFeatureEnabled(): Boolean = read(DebugFeatureKeys.newAppLayoutEnabled)
?: vectorFeatures.isNewAppLayoutFeatureEnabled() ?: vectorFeatures.isNewAppLayoutFeatureEnabled()
override fun isShieldVisibilityDisabled(): Boolean = read(DebugFeatureKeys.shieldVisibilityDisabled)
?: vectorFeatures.isShieldVisibilityDisabled()
override fun isQrCodeLoginEnabled() = read(DebugFeatureKeys.qrCodeLoginEnabled) override fun isQrCodeLoginEnabled() = read(DebugFeatureKeys.qrCodeLoginEnabled)
?: vectorFeatures.isQrCodeLoginEnabled() ?: vectorFeatures.isQrCodeLoginEnabled()
@ -150,6 +153,7 @@ 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 newAppLayoutEnabled = booleanPreferencesKey("new-app-layout-enabled") val newAppLayoutEnabled = booleanPreferencesKey("new-app-layout-enabled")
val shieldVisibilityDisabled = booleanPreferencesKey("shield-visibility-disabled")
val qrCodeLoginEnabled = booleanPreferencesKey("qr-code-login-enabled") val qrCodeLoginEnabled = booleanPreferencesKey("qr-code-login-enabled")
val qrCodeLoginForAllServers = booleanPreferencesKey("qr-code-login-for-all-servers") val qrCodeLoginForAllServers = booleanPreferencesKey("qr-code-login-for-all-servers")
val reciprocateQrCodeLogin = booleanPreferencesKey("reciprocate-qr-code-login") val reciprocateQrCodeLogin = booleanPreferencesKey("reciprocate-qr-code-login")

View File

@ -41,6 +41,7 @@
<bool name="settings_labs_deferred_dm_default">true</bool> <bool name="settings_labs_deferred_dm_default">true</bool>
<bool name="settings_labs_thread_messages_default">true</bool> <bool name="settings_labs_thread_messages_default">true</bool>
<bool name="settings_labs_new_app_layout_default">true</bool> <bool name="settings_labs_new_app_layout_default">true</bool>
<bool name="settings_labs_hide_shields_default">true</bool>
<bool name="settings_labs_new_session_manager_default">false</bool> <bool name="settings_labs_new_session_manager_default">false</bool>
<bool name="settings_labs_new_session_manager_visible">true</bool> <bool name="settings_labs_new_session_manager_visible">true</bool>
<bool name="settings_labs_client_info_recording_default">false</bool> <bool name="settings_labs_client_info_recording_default">false</bool>

View File

@ -40,6 +40,7 @@ interface VectorFeatures {
* use [VectorPreferences.isNewAppLayoutEnabled] instead. * use [VectorPreferences.isNewAppLayoutEnabled] instead.
*/ */
fun isNewAppLayoutFeatureEnabled(): Boolean fun isNewAppLayoutFeatureEnabled(): Boolean
fun isShieldVisibilityDisabled(): Boolean
fun isQrCodeLoginEnabled(): Boolean fun isQrCodeLoginEnabled(): Boolean
fun isQrCodeLoginForAllServers(): Boolean fun isQrCodeLoginForAllServers(): Boolean
fun isReciprocateQrCodeLogin(): Boolean fun isReciprocateQrCodeLogin(): Boolean
@ -60,6 +61,7 @@ class DefaultVectorFeatures : VectorFeatures {
override fun isLocationSharingEnabled() = Config.ENABLE_LOCATION_SHARING override fun isLocationSharingEnabled() = Config.ENABLE_LOCATION_SHARING
override fun forceUsageOfOpusEncoder(): Boolean = false override fun forceUsageOfOpusEncoder(): Boolean = false
override fun isNewAppLayoutFeatureEnabled(): Boolean = true override fun isNewAppLayoutFeatureEnabled(): Boolean = true
override fun isShieldVisibilityDisabled(): Boolean = true
override fun isQrCodeLoginEnabled(): Boolean = true override fun isQrCodeLoginEnabled(): Boolean = true
override fun isQrCodeLoginForAllServers(): Boolean = false override fun isQrCodeLoginForAllServers(): Boolean = false
override fun isReciprocateQrCodeLogin(): Boolean = false override fun isReciprocateQrCodeLogin(): Boolean = false

View File

@ -26,6 +26,7 @@ import im.vector.app.features.home.room.detail.timeline.item.MessageInformationD
import im.vector.app.features.home.room.detail.timeline.item.ReferencesInfoData import im.vector.app.features.home.room.detail.timeline.item.ReferencesInfoData
import im.vector.app.features.home.room.detail.timeline.item.SendStateDecoration import im.vector.app.features.home.room.detail.timeline.item.SendStateDecoration
import im.vector.app.features.home.room.detail.timeline.style.TimelineMessageLayoutFactory import im.vector.app.features.home.room.detail.timeline.style.TimelineMessageLayoutFactory
import im.vector.app.features.settings.VectorPreferences
import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.crypto.model.MessageVerificationState import org.matrix.android.sdk.api.session.crypto.model.MessageVerificationState
@ -55,6 +56,7 @@ class MessageInformationDataFactory @Inject constructor(
private val messageLayoutFactory: TimelineMessageLayoutFactory, private val messageLayoutFactory: TimelineMessageLayoutFactory,
private val reactionsSummaryFactory: ReactionsSummaryFactory, private val reactionsSummaryFactory: ReactionsSummaryFactory,
private val pollResponseDataFactory: PollResponseDataFactory, private val pollResponseDataFactory: PollResponseDataFactory,
private val vectorPreferences: VectorPreferences,
) { ) {
fun create(params: TimelineItemFactoryParams): MessageInformationData { fun create(params: TimelineItemFactoryParams): MessageInformationData {
@ -147,7 +149,7 @@ class MessageInformationDataFactory @Inject constructor(
} }
private fun getE2EDecorationV2(roomSummary: RoomSummary?, event: Event): E2EDecoration { private fun getE2EDecorationV2(roomSummary: RoomSummary?, event: Event): E2EDecoration {
if (roomSummary?.isEncrypted != true) { if (roomSummary?.isEncrypted != true || vectorPreferences.isShieldVisibilityDisabled()) {
// No decoration for clear room // No decoration for clear room
// Questionable? what if the event is E2E? // Questionable? what if the event is E2E?
return E2EDecoration.NONE return E2EDecoration.NONE

View File

@ -70,6 +70,7 @@ class VectorPreferences @Inject constructor(
const val SETTINGS_BACKGROUND_SYNC_DIVIDER_PREFERENCE_KEY = "SETTINGS_BACKGROUND_SYNC_DIVIDER_PREFERENCE_KEY" const val SETTINGS_BACKGROUND_SYNC_DIVIDER_PREFERENCE_KEY = "SETTINGS_BACKGROUND_SYNC_DIVIDER_PREFERENCE_KEY"
const val SETTINGS_LABS_PREFERENCE_KEY = "SETTINGS_LABS_PREFERENCE_KEY" const val SETTINGS_LABS_PREFERENCE_KEY = "SETTINGS_LABS_PREFERENCE_KEY"
const val SETTINGS_LABS_NEW_APP_LAYOUT_KEY = "SETTINGS_LABS_NEW_APP_LAYOUT_KEY" const val SETTINGS_LABS_NEW_APP_LAYOUT_KEY = "SETTINGS_LABS_NEW_APP_LAYOUT_KEY"
const val SETTINGS_LABS_HIDE_SHIELDS_KEY = "SETTINGS_LABS_HIDE_SHIELDS_KEY"
const val SETTINGS_LABS_DEFERRED_DM_KEY = "SETTINGS_LABS_DEFERRED_DM_KEY" const val SETTINGS_LABS_DEFERRED_DM_KEY = "SETTINGS_LABS_DEFERRED_DM_KEY"
const val SETTINGS_LABS_RICH_TEXT_EDITOR_KEY = "SETTINGS_LABS_RICH_TEXT_EDITOR_KEY" const val SETTINGS_LABS_RICH_TEXT_EDITOR_KEY = "SETTINGS_LABS_RICH_TEXT_EDITOR_KEY"
const val SETTINGS_LABS_NEW_SESSION_MANAGER_KEY = "SETTINGS_LABS_NEW_SESSION_MANAGER_KEY" const val SETTINGS_LABS_NEW_SESSION_MANAGER_KEY = "SETTINGS_LABS_NEW_SESSION_MANAGER_KEY"
@ -1217,6 +1218,14 @@ class VectorPreferences @Inject constructor(
defaultPrefs.getBoolean(SETTINGS_LABS_NEW_APP_LAYOUT_KEY, getDefault(R.bool.settings_labs_new_app_layout_default)) defaultPrefs.getBoolean(SETTINGS_LABS_NEW_APP_LAYOUT_KEY, getDefault(R.bool.settings_labs_new_app_layout_default))
} }
/**
* Indicates if the encryption shields in rooms next to messages are hidden
*/
fun isShieldVisibilityDisabled() : Boolean {
return vectorFeatures.isShieldVisibilityDisabled() &&
defaultPrefs.getBoolean(SETTINGS_LABS_HIDE_SHIELDS_KEY, getDefault(R.bool.settings_labs_hide_shields_default))
}
/** /**
* Indicates whether or not deferred DMs are enabled. * Indicates whether or not deferred DMs are enabled.
*/ */

View File

@ -96,6 +96,10 @@ 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()

View File

@ -89,6 +89,12 @@
android:summary="@string/labs_enable_new_app_layout_summary" android:summary="@string/labs_enable_new_app_layout_summary"
android:title="@string/labs_enable_new_app_layout_title" /> android:title="@string/labs_enable_new_app_layout_title" />
<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="@bool/settings_labs_hide_shields_default"
android:key="SETTINGS_LABS_HIDE_SHIELDS_KEY"
android:summary="@string/labs_enable_hide_shields_summary"
android:title="@string/labs_enable_hide_shields_title" />
<im.vector.app.core.preference.VectorSwitchPreference <im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="@bool/settings_labs_deferred_dm_default" android:defaultValue="@bool/settings_labs_deferred_dm_default"
android:key="SETTINGS_LABS_DEFERRED_DM_KEY" android:key="SETTINGS_LABS_DEFERRED_DM_KEY"