Allow to enable URL preview in encrypted rooms

Change-Id: Iac2fff47cc86bd77203c44ce0f39ff131c60a16c
This commit is contained in:
SpiritCroc 2020-12-19 20:24:27 +01:00
parent 11ef70d495
commit f689576fbf
5 changed files with 21 additions and 1 deletions

View File

@ -1395,7 +1395,7 @@ class RoomDetailViewModel @AssistedInject constructor(
if (vectorPreferences.showUrlPreviews()) { if (vectorPreferences.showUrlPreviews()) {
withState { state -> withState { state ->
snapshot snapshot
.takeIf { state.asyncRoomSummary.invoke()?.isEncrypted == false } .takeIf { state.asyncRoomSummary.invoke()?.isEncrypted == false || vectorPreferences.allowUrlPreviewsInEncryptedRooms() }
?.forEach { ?.forEach {
previewUrlRetriever.getPreviewUrl(it.root, viewModelScope) previewUrlRetriever.getPreviewUrl(it.root, viewModelScope)
} }

View File

@ -186,6 +186,7 @@ class VectorPreferences @Inject constructor(private val context: Context) {
private const val SETTINGS_UNIMPORTANT_COUNTER_BADGE = "SETTINGS_UNIMPORTANT_COUNTER_BADGE" private const val SETTINGS_UNIMPORTANT_COUNTER_BADGE = "SETTINGS_UNIMPORTANT_COUNTER_BADGE"
private const val SETTINGS_SIMPLIFIED_MODE = "SETTINGS_SIMPLIFIED_MODE" private const val SETTINGS_SIMPLIFIED_MODE = "SETTINGS_SIMPLIFIED_MODE"
private const val SETTINGS_LABS_ALLOW_MARK_UNREAD = "SETTINGS_LABS_ALLOW_MARK_UNREAD" private const val SETTINGS_LABS_ALLOW_MARK_UNREAD = "SETTINGS_LABS_ALLOW_MARK_UNREAD"
private const val SETTINGS_ALLOW_URL_PREVIEW_IN_ENCRYPTED_ROOM_KEY = "SETTINGS_ALLOW_URL_PREVIEW_IN_ENCRYPTED_ROOM_KEY"
private const val DID_ASK_TO_ENABLE_SESSION_PUSH = "DID_ASK_TO_ENABLE_SESSION_PUSH" private const val DID_ASK_TO_ENABLE_SESSION_PUSH = "DID_ASK_TO_ENABLE_SESSION_PUSH"
@ -801,6 +802,15 @@ class VectorPreferences @Inject constructor(private val context: Context) {
return defaultPrefs.getBoolean(SETTINGS_SHOW_URL_PREVIEW_KEY, true) return defaultPrefs.getBoolean(SETTINGS_SHOW_URL_PREVIEW_KEY, true)
} }
/**
* Tells if the user wants to see URL previews in encrypted rooms as well
*
* @return true if the user wants to see URL previews in encrypted rooms
*/
fun allowUrlPreviewsInEncryptedRooms(): Boolean {
return defaultPrefs.getBoolean(SETTINGS_ALLOW_URL_PREVIEW_IN_ENCRYPTED_ROOM_KEY, false)
}
/** /**
* Enable or disable the analytics tracking. * Enable or disable the analytics tracking.
* *

View File

@ -46,6 +46,8 @@
<string name="labs_mark_rooms_unread">Chats als ungelesen markieren</string> <string name="labs_mark_rooms_unread">Chats als ungelesen markieren</string>
<string name="labs_mark_rooms_unread_summary">Erlaube, Chats als ungelesen zu markieren. Andere Matrix-Clients unterstützen diese Funktionalität möglicherweise noch nicht.</string> <string name="labs_mark_rooms_unread_summary">Erlaube, Chats als ungelesen zu markieren. Andere Matrix-Clients unterstützen diese Funktionalität möglicherweise noch nicht.</string>
<string name="url_previews_in_encrypted_rooms">URL-Vorschau in verschlüsselten Chats</string>
<string name="url_previews_in_encrypted_rooms_summary">Dies offenbart in Nachrichten enthaltene URLs gegenüber dem Homeserver!</string>
<string name="login_mobile_device_sc">SchildiChat Android</string> <string name="login_mobile_device_sc">SchildiChat Android</string>
<string name="bottom_action_all">Übersicht</string> <string name="bottom_action_all">Übersicht</string>

View File

@ -46,6 +46,8 @@
<string name="labs_mark_rooms_unread">Mark chats as unread</string> <string name="labs_mark_rooms_unread">Mark chats as unread</string>
<string name="labs_mark_rooms_unread_summary">Allow to mark chats as unread. Other matrix clients might not support this functionality yet.</string> <string name="labs_mark_rooms_unread_summary">Allow to mark chats as unread. Other matrix clients might not support this functionality yet.</string>
<string name="url_previews_in_encrypted_rooms">URL previews in encrypted chats</string>
<string name="url_previews_in_encrypted_rooms_summary">This will leak URLs from your messages to your homeserver!</string>
<string name="login_mobile_device_sc">SchildiChat Android</string> <string name="login_mobile_device_sc">SchildiChat Android</string>
<string name="bottom_action_all">Overview</string> <string name="bottom_action_all">Overview</string>

View File

@ -40,6 +40,12 @@
android:title="@string/settings_system_dark_theme_pre_ten" android:title="@string/settings_system_dark_theme_pre_ten"
android:summary="@string/settings_system_dark_theme_pre_ten_summary" /> android:summary="@string/settings_system_dark_theme_pre_ten_summary" />
<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="false"
android:key="SETTINGS_ALLOW_URL_PREVIEW_IN_ENCRYPTED_ROOM_KEY"
android:title="@string/url_previews_in_encrypted_rooms"
android:summary="@string/url_previews_in_encrypted_rooms_summary" />
<im.vector.app.core.preference.VectorSwitchPreference <im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="SETTINGS_LABS_ALLOW_MARK_UNREAD" android:key="SETTINGS_LABS_ALLOW_MARK_UNREAD"