Prevent files from being made public when VFS is enabled

This commit is contained in:
Sylvain Berfini 2021-04-07 15:51:16 +02:00
parent d1cbff473b
commit fedb9f079e
4 changed files with 10 additions and 3 deletions

View file

@ -76,7 +76,7 @@ class ChatMessageData(
Log.i("[Chat Message] File transfer done") Log.i("[Chat Message] File transfer done")
updateContentsList() updateContentsList()
if (!message.isEphemeral && corePreferences.makePublicMediaFilesDownloaded) { if (!message.isEphemeral && !corePreferences.vfsEnabled && corePreferences.makePublicMediaFilesDownloaded) {
if (Version.sdkAboveOrEqual(Version.API29_ANDROID_10) || PermissionHelper.get().hasWriteExternalStorage()) { if (Version.sdkAboveOrEqual(Version.API29_ANDROID_10) || PermissionHelper.get().hasWriteExternalStorage()) {
for (content in message.contents) { for (content in message.contents) {
if (content.isFile && content.filePath != null && content.userData == null) { if (content.isFile && content.filePath != null && content.userData == null) {

View file

@ -108,7 +108,11 @@ class AdvancedSettingsViewModel : GenericSettingsViewModel() {
val vfsListener = object : SettingListenerStub() { val vfsListener = object : SettingListenerStub() {
override fun onBoolValueChanged(newValue: Boolean) { override fun onBoolValueChanged(newValue: Boolean) {
prefs.vfsEnabled = newValue prefs.vfsEnabled = newValue
if (newValue) CoreContext.activateVFS() if (newValue) {
CoreContext.activateVFS()
// Don't do that when VFS is enabled
prefs.makePublicMediaFilesDownloaded = false
}
} }
} }
val vfs = MutableLiveData<Boolean>() val vfs = MutableLiveData<Boolean>()

View file

@ -118,6 +118,8 @@ class ChatSettingsViewModel : GenericSettingsViewModel() {
} }
val goToAndroidNotificationSettingsEvent = MutableLiveData<Event<Boolean>>() val goToAndroidNotificationSettingsEvent = MutableLiveData<Event<Boolean>>()
val vfs = MutableLiveData<Boolean>()
init { init {
markAsReadNotifDismissal.value = prefs.markAsReadUponChatMessageNotificationDismissal markAsReadNotifDismissal.value = prefs.markAsReadUponChatMessageNotificationDismissal
downloadedMediaPublic.value = prefs.makePublicMediaFilesDownloaded downloadedMediaPublic.value = prefs.makePublicMediaFilesDownloaded
@ -127,6 +129,7 @@ class ChatSettingsViewModel : GenericSettingsViewModel() {
hideEmptyRooms.value = prefs.hideEmptyRooms hideEmptyRooms.value = prefs.hideEmptyRooms
hideRoomsRemovedProxies.value = prefs.hideRoomsFromRemovedProxies hideRoomsRemovedProxies.value = prefs.hideRoomsFromRemovedProxies
fileSharingUrl.value = core.fileTransferServer fileSharingUrl.value = core.fileTransferServer
vfs.value = prefs.vfsEnabled
} }
private fun initAutoDownloadList() { private fun initAutoDownloadList() {

View file

@ -93,7 +93,7 @@
<include <include
layout="@layout/settings_widget_switch" layout="@layout/settings_widget_switch"
linphone:title="@{@string/chat_settings_downloaded_media_public_title}" linphone:title="@{@string/chat_settings_downloaded_media_public_title}"
linphone:enabled="@{viewModel.autoDownloadIndex == 0}" linphone:enabled="@{viewModel.autoDownloadIndex == 0 &amp;&amp; !viewModel.vfs}"
linphone:subtitle="@{@string/chat_settings_downloaded_media_public_summary}" linphone:subtitle="@{@string/chat_settings_downloaded_media_public_summary}"
linphone:listener="@{viewModel.downloadedMediaPublicListener}" linphone:listener="@{viewModel.downloadedMediaPublicListener}"
linphone:checked="@={viewModel.downloadedMediaPublic}"/> linphone:checked="@={viewModel.downloadedMediaPublic}"/>