From fbe68d5bb823e5d605ad379a4183f7c50e0ae9ef Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 15 Jul 2020 17:21:52 +0200 Subject: [PATCH] Renamed & improved text for making media files public + disable when auto download is enabled as it doesn't work yet --- .../main/chat/viewmodels/ChatMessageViewModel.kt | 2 +- .../settings/viewmodels/ChatSettingsViewModel.kt | 13 +++++++++---- .../main/java/org/linphone/core/CorePreferences.kt | 3 ++- app/src/main/res/layout/settings_chat_fragment.xml | 9 +++++---- app/src/main/res/values/strings.xml | 4 ++-- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/linphone/activities/main/chat/viewmodels/ChatMessageViewModel.kt b/app/src/main/java/org/linphone/activities/main/chat/viewmodels/ChatMessageViewModel.kt index 79d313371..8b89b32d0 100644 --- a/app/src/main/java/org/linphone/activities/main/chat/viewmodels/ChatMessageViewModel.kt +++ b/app/src/main/java/org/linphone/activities/main/chat/viewmodels/ChatMessageViewModel.kt @@ -81,7 +81,7 @@ class ChatMessageViewModel( // It will even cause the app to crash if updateContentsList is not call right after updateContentsList() - if (!message.isEphemeral && corePreferences.makePublicDownloadedImages) { + if (!message.isEphemeral && corePreferences.makePublicMediaFilesDownloaded) { if (Version.sdkAboveOrEqual(Version.API29_ANDROID_10) || PermissionHelper.get().hasWriteExternalStorage()) { for (content in message.contents) { if (content.isFile && content.filePath != null && content.userData == null) { diff --git a/app/src/main/java/org/linphone/activities/main/settings/viewmodels/ChatSettingsViewModel.kt b/app/src/main/java/org/linphone/activities/main/settings/viewmodels/ChatSettingsViewModel.kt index 726a8d62b..a55f58a91 100644 --- a/app/src/main/java/org/linphone/activities/main/settings/viewmodels/ChatSettingsViewModel.kt +++ b/app/src/main/java/org/linphone/activities/main/settings/viewmodels/ChatSettingsViewModel.kt @@ -42,6 +42,11 @@ class ChatSettingsViewModel : GenericSettingsViewModel() { core.maxSizeForAutoDownloadIncomingFiles = maxSize autoDownloadMaxSize.value = maxSize updateAutoDownloadIndexFromMaxSize(maxSize) + + // Auto download isn't compatible with making downloaded images public + if (position > 0 && downloadedMediaPublic.value == true) { + downloadedMediaPublic.value = false + } } } val autoDownloadIndex = MutableLiveData() @@ -58,12 +63,12 @@ class ChatSettingsViewModel : GenericSettingsViewModel() { } val autoDownloadMaxSize = MutableLiveData() - val downloadedImagesPublicListener = object : SettingListenerStub() { + val downloadedMediaPublicListener = object : SettingListenerStub() { override fun onBoolValueChanged(newValue: Boolean) { - prefs.makePublicDownloadedImages = newValue + downloadedMediaPublic.value = newValue } } - val downloadedImagesPublic = MutableLiveData() + val downloadedMediaPublic = MutableLiveData() val launcherShortcutsListener = object : SettingListenerStub() { override fun onBoolValueChanged(newValue: Boolean) { @@ -96,7 +101,7 @@ class ChatSettingsViewModel : GenericSettingsViewModel() { val goToAndroidNotificationSettingsEvent = MutableLiveData>() init { - downloadedImagesPublic.value = prefs.makePublicDownloadedImages + downloadedMediaPublic.value = prefs.makePublicMediaFilesDownloaded initAutoDownloadList() launcherShortcuts.value = prefs.chatRoomShortcuts hideEmptyRooms.value = prefs.hideEmptyRooms diff --git a/app/src/main/java/org/linphone/core/CorePreferences.kt b/app/src/main/java/org/linphone/core/CorePreferences.kt index 0ba5f50de..0ce8ab23d 100644 --- a/app/src/main/java/org/linphone/core/CorePreferences.kt +++ b/app/src/main/java/org/linphone/core/CorePreferences.kt @@ -88,7 +88,8 @@ class CorePreferences constructor(private val context: Context) { /* Chat */ - var makePublicDownloadedImages: Boolean + var makePublicMediaFilesDownloaded: Boolean + // Keep old name for backward compatibility get() = config.getBool("app", "make_downloaded_images_public_in_gallery", true) set(value) { config.setBool("app", "make_downloaded_images_public_in_gallery", value) diff --git a/app/src/main/res/layout/settings_chat_fragment.xml b/app/src/main/res/layout/settings_chat_fragment.xml index 2ea011553..b02500635 100644 --- a/app/src/main/res/layout/settings_chat_fragment.xml +++ b/app/src/main/res/layout/settings_chat_fragment.xml @@ -93,10 +93,11 @@ + linphone:title="@{@string/chat_settings_downloaded_media_public_title}" + linphone:enabled="@{viewModel.autoDownloadIndex == 0}" + linphone:subtitle="@{@string/chat_settings_downloaded_media_public_summary}" + linphone:listener="@{viewModel.downloadedMediaPublicListener}" + linphone:checked="@={viewModel.downloadedMediaPublic}"/> If lighter than given maximum size Max size in bytes - Make downloaded images visible in native gallery - Images in ephemeral messages won\'t be + Make downloaded media public + Files in ephemeral messages won\'t be, doesn\'t work with auto download feature Create shortcuts to chat rooms in launcher Will be replaced by contacts shortcuts if enabled Hide empty chat rooms