Added back auto download chat settings
This commit is contained in:
parent
af2105e193
commit
fe8524da14
3 changed files with 72 additions and 0 deletions
|
@ -20,6 +20,7 @@
|
|||
package org.linphone.activities.main.settings.viewmodels
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.main.settings.SettingListenerStub
|
||||
import org.linphone.utils.Event
|
||||
|
||||
|
@ -31,6 +32,32 @@ class ChatSettingsViewModel : GenericSettingsViewModel() {
|
|||
}
|
||||
val fileSharingUrl = MutableLiveData<String>()
|
||||
|
||||
val autoDownloadListener = object : SettingListenerStub() {
|
||||
override fun onListValueChanged(position: Int) {
|
||||
val maxSize = when (position) {
|
||||
0 -> -1
|
||||
1 -> 0
|
||||
else -> 10000000
|
||||
}
|
||||
core.maxSizeForAutoDownloadIncomingFiles = maxSize
|
||||
autoDownloadMaxSize.value = maxSize
|
||||
updateAutoDownloadIndexFromMaxSize(maxSize)
|
||||
}
|
||||
}
|
||||
val autoDownloadIndex = MutableLiveData<Int>()
|
||||
val autoDownloadLabels = MutableLiveData<ArrayList<String>>()
|
||||
|
||||
val autoDownloadMaxSizeListener = object : SettingListenerStub() {
|
||||
override fun onTextValueChanged(newValue: String) {
|
||||
if (newValue.isNotEmpty()) {
|
||||
val maxSize = newValue.toInt()
|
||||
core.maxSizeForAutoDownloadIncomingFiles = maxSize
|
||||
updateAutoDownloadIndexFromMaxSize(maxSize)
|
||||
}
|
||||
}
|
||||
}
|
||||
val autoDownloadMaxSize = MutableLiveData<Int>()
|
||||
|
||||
val downloadedImagesPublicListener = object : SettingListenerStub() {
|
||||
override fun onBoolValueChanged(newValue: Boolean) {
|
||||
prefs.makePublicDownloadedImages = newValue
|
||||
|
@ -63,9 +90,30 @@ class ChatSettingsViewModel : GenericSettingsViewModel() {
|
|||
|
||||
init {
|
||||
downloadedImagesPublic.value = prefs.makePublicDownloadedImages
|
||||
initAutoDownloadList()
|
||||
launcherShortcuts.value = prefs.chatRoomShortcuts
|
||||
hideEmptyRooms.value = prefs.hideEmptyRooms
|
||||
hideRoomsRemovedProxies.value = prefs.hideRoomsFromRemovedProxies
|
||||
fileSharingUrl.value = core.fileTransferServer
|
||||
}
|
||||
|
||||
private fun initAutoDownloadList() {
|
||||
val labels = arrayListOf<String>()
|
||||
labels.add(prefs.getString(R.string.chat_settings_auto_download_never))
|
||||
labels.add(prefs.getString(R.string.chat_settings_auto_download_always))
|
||||
labels.add(prefs.getString(R.string.chat_settings_auto_download_under_size))
|
||||
autoDownloadLabels.value = labels
|
||||
|
||||
val currentValue = core.maxSizeForAutoDownloadIncomingFiles
|
||||
autoDownloadMaxSize.value = currentValue
|
||||
updateAutoDownloadIndexFromMaxSize(currentValue)
|
||||
}
|
||||
|
||||
private fun updateAutoDownloadIndexFromMaxSize(maxSize: Int) {
|
||||
autoDownloadIndex.value = when (maxSize) {
|
||||
-1 -> 0
|
||||
0 -> 1
|
||||
else -> 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,23 @@
|
|||
linphone:defaultValue="@{viewModel.fileSharingUrl}"
|
||||
linphone:inputType="@{InputType.TYPE_TEXT_VARIATION_URI}"/>
|
||||
|
||||
<include
|
||||
layout="@layout/settings_widget_list"
|
||||
linphone:title="@{@string/chat_settings_auto_download_title}"
|
||||
linphone:subtitle="@{@string/chat_settings_auto_download_summary}"
|
||||
linphone:listener="@{viewModel.autoDownloadListener}"
|
||||
linphone:selectedIndex="@{viewModel.autoDownloadIndex}"
|
||||
linphone:labels="@{viewModel.autoDownloadLabels}"/>
|
||||
|
||||
<include
|
||||
layout="@layout/settings_widget_text"
|
||||
linphone:title="@{@string/chat_settings_auto_download_max_size_title}"
|
||||
linphone:subtitle="@{@string/chat_settings_auto_download_max_size_summary}"
|
||||
linphone:listener="@{viewModel.autoDownloadMaxSizeListener}"
|
||||
linphone:defaultValue="@{viewModel.autoDownloadMaxSize.toString()}"
|
||||
linphone:inputType="@{InputType.TYPE_CLASS_NUMBER}"
|
||||
linphone:enabled="@{viewModel.autoDownloadIndex == 2}"/>
|
||||
|
||||
<include
|
||||
layout="@layout/settings_widget_switch"
|
||||
linphone:title="@{@string/chat_settings_downloaded_images_public_title}"
|
||||
|
|
|
@ -347,6 +347,13 @@
|
|||
<!-- Chat settings -->
|
||||
<string name="chat_settings_file_sharing_url_title">Sharing server URL</string>
|
||||
<string name="chat_settings_file_sharing_url_summary">Do not edit unless you know what you are doing!</string>
|
||||
<string name="chat_settings_auto_download_title">Auto download incoming files policy</string>
|
||||
<string name="chat_settings_auto_download_summary">Whether to download files attached in received chat messages automatically or not</string>
|
||||
<string name="chat_settings_auto_download_always">Always</string>
|
||||
<string name="chat_settings_auto_download_never">Never</string>
|
||||
<string name="chat_settings_auto_download_under_size">If lighter than given maximum size</string>
|
||||
<string name="chat_settings_auto_download_max_size_title">Max size</string>
|
||||
<string name="chat_settings_auto_download_max_size_summary">in bytes</string>
|
||||
<string name="chat_settings_downloaded_images_public_title">Make downloaded images visible in native gallery</string>
|
||||
<string name="chat_settings_downloaded_images_public_summary">Images in ephemeral messages won\'t be</string>
|
||||
<string name="chat_settings_launcher_shortcuts_title">Create shortcuts to chat rooms in launcher</string>
|
||||
|
|
Loading…
Reference in a new issue