From f689576fbf7d035436e90562e4fa03958eec4cac Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Sat, 19 Dec 2020 20:24:27 +0100 Subject: [PATCH] Allow to enable URL preview in encrypted rooms Change-Id: Iac2fff47cc86bd77203c44ce0f39ff131c60a16c --- .../features/home/room/detail/RoomDetailViewModel.kt | 2 +- .../vector/app/features/settings/VectorPreferences.kt | 10 ++++++++++ vector/src/main/res/values-de/strings_sc.xml | 2 ++ vector/src/main/res/values/strings_sc.xml | 2 ++ vector/src/main/res/xml/vector_settings_labs.xml | 6 ++++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt index 2bd92414e7..0d53ad01cc 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt @@ -1395,7 +1395,7 @@ class RoomDetailViewModel @AssistedInject constructor( if (vectorPreferences.showUrlPreviews()) { withState { state -> snapshot - .takeIf { state.asyncRoomSummary.invoke()?.isEncrypted == false } + .takeIf { state.asyncRoomSummary.invoke()?.isEncrypted == false || vectorPreferences.allowUrlPreviewsInEncryptedRooms() } ?.forEach { previewUrlRetriever.getPreviewUrl(it.root, viewModelScope) } diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index c1f851910f..80f06154ba 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -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_SIMPLIFIED_MODE = "SETTINGS_SIMPLIFIED_MODE" 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" @@ -801,6 +802,15 @@ class VectorPreferences @Inject constructor(private val context: Context) { 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. * diff --git a/vector/src/main/res/values-de/strings_sc.xml b/vector/src/main/res/values-de/strings_sc.xml index 5f1434a9cc..f4f8ac1335 100644 --- a/vector/src/main/res/values-de/strings_sc.xml +++ b/vector/src/main/res/values-de/strings_sc.xml @@ -46,6 +46,8 @@ Chats als ungelesen markieren Erlaube, Chats als ungelesen zu markieren. Andere Matrix-Clients unterstützen diese Funktionalität möglicherweise noch nicht. + URL-Vorschau in verschlüsselten Chats + Dies offenbart in Nachrichten enthaltene URLs gegenüber dem Homeserver! SchildiChat Android Übersicht diff --git a/vector/src/main/res/values/strings_sc.xml b/vector/src/main/res/values/strings_sc.xml index f56bf9f619..63273f64e5 100644 --- a/vector/src/main/res/values/strings_sc.xml +++ b/vector/src/main/res/values/strings_sc.xml @@ -46,6 +46,8 @@ Mark chats as unread Allow to mark chats as unread. Other matrix clients might not support this functionality yet. + URL previews in encrypted chats + This will leak URLs from your messages to your homeserver! SchildiChat Android Overview diff --git a/vector/src/main/res/xml/vector_settings_labs.xml b/vector/src/main/res/xml/vector_settings_labs.xml index 3bf97eb18c..5bab221660 100644 --- a/vector/src/main/res/xml/vector_settings_labs.xml +++ b/vector/src/main/res/xml/vector_settings_labs.xml @@ -40,6 +40,12 @@ android:title="@string/settings_system_dark_theme_pre_ten" android:summary="@string/settings_system_dark_theme_pre_ten_summary" /> + +