Allow transfered files through chat to be automatically exported to native gallery

This commit is contained in:
Sylvain Berfini 2023-01-05 10:58:55 +01:00
parent 8e156c0b33
commit 5ff7ea66e2
3 changed files with 3 additions and 6 deletions

View file

@ -50,11 +50,6 @@ 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<Int>()

View file

@ -838,6 +838,7 @@ class CoreContext(
/* Coroutine related */
private fun exportFileInMessage(message: ChatMessage) {
// Only do it if auto download feature isn't disabled, otherwise it's done in the user-initiated download process
if (core.maxSizeForAutoDownloadIncomingFiles != -1) {
var hasFile = false
for (content in message.contents) {
@ -869,6 +870,7 @@ class CoreContext(
if (PermissionHelper.get().hasWriteExternalStoragePermission()) {
for (content in message.contents) {
if (content.isFile && content.filePath != null && content.userData == null) {
Log.i("[Context] Trying to export file [${content.name}] to MediaStore")
addContentToMediaStore(content)
}
}

View file

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