Added setting to hide chat message content in notifications
This commit is contained in:
parent
31bbc9a4d5
commit
4ffc6881a8
5 changed files with 43 additions and 3 deletions
|
@ -67,11 +67,20 @@ class ChatSettingsViewModel : GenericSettingsViewModel() {
|
||||||
|
|
||||||
val downloadedMediaPublicListener = object : SettingListenerStub() {
|
val downloadedMediaPublicListener = object : SettingListenerStub() {
|
||||||
override fun onBoolValueChanged(newValue: Boolean) {
|
override fun onBoolValueChanged(newValue: Boolean) {
|
||||||
|
prefs.makePublicMediaFilesDownloaded = newValue
|
||||||
downloadedMediaPublic.value = newValue
|
downloadedMediaPublic.value = newValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val downloadedMediaPublic = MutableLiveData<Boolean>()
|
val downloadedMediaPublic = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
|
val hideNotificationContentListener = object : SettingListenerStub() {
|
||||||
|
override fun onBoolValueChanged(newValue: Boolean) {
|
||||||
|
prefs.hideChatMessageContentInNotification = newValue
|
||||||
|
hideNotificationContent.value = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val hideNotificationContent = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
val launcherShortcutsListener = object : SettingListenerStub() {
|
val launcherShortcutsListener = object : SettingListenerStub() {
|
||||||
override fun onBoolValueChanged(newValue: Boolean) {
|
override fun onBoolValueChanged(newValue: Boolean) {
|
||||||
prefs.chatRoomShortcuts = newValue
|
prefs.chatRoomShortcuts = newValue
|
||||||
|
@ -104,6 +113,7 @@ class ChatSettingsViewModel : GenericSettingsViewModel() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
downloadedMediaPublic.value = prefs.makePublicMediaFilesDownloaded
|
downloadedMediaPublic.value = prefs.makePublicMediaFilesDownloaded
|
||||||
|
hideNotificationContent.value = prefs.hideChatMessageContentInNotification
|
||||||
initAutoDownloadList()
|
initAutoDownloadList()
|
||||||
launcherShortcuts.value = prefs.chatRoomShortcuts
|
launcherShortcuts.value = prefs.chatRoomShortcuts
|
||||||
hideEmptyRooms.value = prefs.hideEmptyRooms
|
hideEmptyRooms.value = prefs.hideEmptyRooms
|
||||||
|
|
|
@ -107,6 +107,12 @@ class CorePreferences constructor(private val context: Context) {
|
||||||
config.setBool("app", "make_downloaded_images_public_in_gallery", value)
|
config.setBool("app", "make_downloaded_images_public_in_gallery", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hideChatMessageContentInNotification: Boolean
|
||||||
|
get() = config.getBool("app", "hide_chat_message_content_in_notification", false)
|
||||||
|
set(value) {
|
||||||
|
config.setBool("app", "hide_chat_message_content_in_notification", value)
|
||||||
|
}
|
||||||
|
|
||||||
var hideEmptyRooms: Boolean
|
var hideEmptyRooms: Boolean
|
||||||
get() = config.getBool("app", "hide_empty_chat_rooms", true)
|
get() = config.getBool("app", "hide_empty_chat_rooms", true)
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.linphone.compatibility.Compatibility
|
||||||
import org.linphone.contact.Contact
|
import org.linphone.contact.Contact
|
||||||
import org.linphone.core.*
|
import org.linphone.core.*
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
|
import org.linphone.utils.AppUtils
|
||||||
import org.linphone.utils.FileUtils
|
import org.linphone.utils.FileUtils
|
||||||
import org.linphone.utils.ImageUtils
|
import org.linphone.utils.ImageUtils
|
||||||
import org.linphone.utils.LinphoneUtils
|
import org.linphone.utils.LinphoneUtils
|
||||||
|
@ -636,13 +637,26 @@ class NotificationsManager(private val context: Context) {
|
||||||
contact.getPerson()
|
contact.getPerson()
|
||||||
} else {
|
} else {
|
||||||
val builder = Person.Builder().setName(message.sender)
|
val builder = Person.Builder().setName(message.sender)
|
||||||
val userIcon = if (message.senderAvatar != null) IconCompat.createWithBitmap(message.senderAvatar) else IconCompat.createWithResource(context, R.drawable.avatar)
|
val userIcon =
|
||||||
|
if (message.senderAvatar != null) {
|
||||||
|
IconCompat.createWithBitmap(message.senderAvatar)
|
||||||
|
} else {
|
||||||
|
IconCompat.createWithResource(context, R.drawable.avatar)
|
||||||
|
}
|
||||||
if (userIcon != null) builder.setIcon(userIcon)
|
if (userIcon != null) builder.setIcon(userIcon)
|
||||||
builder.build()
|
builder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
val msg = NotificationCompat.MessagingStyle.Message(message.message, message.time, person)
|
val msg = if (!corePreferences.hideChatMessageContentInNotification) {
|
||||||
if (message.filePath != null) msg.setData(message.fileMime, message.filePath)
|
NotificationCompat.MessagingStyle.Message(message.message, message.time, person)
|
||||||
|
} else {
|
||||||
|
NotificationCompat.MessagingStyle.Message(AppUtils.getString(R.string.chat_message_notification_hidden_content), message.time, person)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.filePath != null && !corePreferences.hideChatMessageContentInNotification) {
|
||||||
|
msg.setData(message.fileMime, message.filePath)
|
||||||
|
}
|
||||||
|
|
||||||
style.addMessage(msg)
|
style.addMessage(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,13 @@
|
||||||
linphone:listener="@{viewModel.downloadedMediaPublicListener}"
|
linphone:listener="@{viewModel.downloadedMediaPublicListener}"
|
||||||
linphone:checked="@={viewModel.downloadedMediaPublic}"/>
|
linphone:checked="@={viewModel.downloadedMediaPublic}"/>
|
||||||
|
|
||||||
|
<include
|
||||||
|
layout="@layout/settings_widget_switch"
|
||||||
|
linphone:title="@{@string/chat_settings_hide_notification_content_title}"
|
||||||
|
linphone:subtitle="@{@string/chat_settings_hide_notification_content_summary}"
|
||||||
|
linphone:listener="@{viewModel.hideNotificationContentListener}"
|
||||||
|
linphone:checked="@={viewModel.hideNotificationContent}"/>
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/settings_widget_switch"
|
layout="@layout/settings_widget_switch"
|
||||||
linphone:title="@{@string/chat_settings_launcher_shortcuts_title}"
|
linphone:title="@{@string/chat_settings_launcher_shortcuts_title}"
|
||||||
|
|
|
@ -198,6 +198,7 @@
|
||||||
<item quantity="one">@string/chat_room_delete_one_dialog</item>
|
<item quantity="one">@string/chat_room_delete_one_dialog</item>
|
||||||
<item quantity="other">@string/chat_room_delete_many_dialog</item>
|
<item quantity="other">@string/chat_room_delete_many_dialog</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
<string name="chat_message_notification_hidden_content"><Redacted></string>
|
||||||
|
|
||||||
<!-- Recordings -->
|
<!-- Recordings -->
|
||||||
<string name="recordings_empty_list">No recordings</string>
|
<string name="recordings_empty_list">No recordings</string>
|
||||||
|
@ -412,6 +413,8 @@
|
||||||
<string name="chat_settings_auto_download_max_size_summary">in bytes</string>
|
<string name="chat_settings_auto_download_max_size_summary">in bytes</string>
|
||||||
<string name="chat_settings_downloaded_media_public_title">Make downloaded media public</string>
|
<string name="chat_settings_downloaded_media_public_title">Make downloaded media public</string>
|
||||||
<string name="chat_settings_downloaded_media_public_summary">Files in ephemeral messages won\'t be, doesn\'t work with auto download feature</string>
|
<string name="chat_settings_downloaded_media_public_summary">Files in ephemeral messages won\'t be, doesn\'t work with auto download feature</string>
|
||||||
|
<string name="chat_settings_hide_notification_content_title">Hide message content in notifications</string>
|
||||||
|
<string name="chat_settings_hide_notification_content_summary">Only sender name will be displayed</string>
|
||||||
<string name="chat_settings_launcher_shortcuts_title">Create shortcuts to chat rooms in launcher</string>
|
<string name="chat_settings_launcher_shortcuts_title">Create shortcuts to chat rooms in launcher</string>
|
||||||
<string name="chat_settings_launcher_shortcuts_summary">Will be replaced by contacts shortcuts if enabled</string>
|
<string name="chat_settings_launcher_shortcuts_summary">Will be replaced by contacts shortcuts if enabled</string>
|
||||||
<string name="chat_settings_hide_empty_rooms_title">Hide empty chat rooms</string>
|
<string name="chat_settings_hide_empty_rooms_title">Hide empty chat rooms</string>
|
||||||
|
|
Loading…
Reference in a new issue