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 544928adb..7b77c50ae 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 @@ -67,11 +67,20 @@ class ChatSettingsViewModel : GenericSettingsViewModel() { val downloadedMediaPublicListener = object : SettingListenerStub() { override fun onBoolValueChanged(newValue: Boolean) { + prefs.makePublicMediaFilesDownloaded = newValue downloadedMediaPublic.value = newValue } } val downloadedMediaPublic = MutableLiveData() + val hideNotificationContentListener = object : SettingListenerStub() { + override fun onBoolValueChanged(newValue: Boolean) { + prefs.hideChatMessageContentInNotification = newValue + hideNotificationContent.value = newValue + } + } + val hideNotificationContent = MutableLiveData() + val launcherShortcutsListener = object : SettingListenerStub() { override fun onBoolValueChanged(newValue: Boolean) { prefs.chatRoomShortcuts = newValue @@ -104,6 +113,7 @@ class ChatSettingsViewModel : GenericSettingsViewModel() { init { downloadedMediaPublic.value = prefs.makePublicMediaFilesDownloaded + hideNotificationContent.value = prefs.hideChatMessageContentInNotification 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 1282872eb..649e18f6c 100644 --- a/app/src/main/java/org/linphone/core/CorePreferences.kt +++ b/app/src/main/java/org/linphone/core/CorePreferences.kt @@ -107,6 +107,12 @@ class CorePreferences constructor(private val context: Context) { 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 get() = config.getBool("app", "hide_empty_chat_rooms", true) set(value) { diff --git a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt index 810bb8d40..a26bc279e 100644 --- a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt +++ b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt @@ -46,6 +46,7 @@ import org.linphone.compatibility.Compatibility import org.linphone.contact.Contact import org.linphone.core.* import org.linphone.core.tools.Log +import org.linphone.utils.AppUtils import org.linphone.utils.FileUtils import org.linphone.utils.ImageUtils import org.linphone.utils.LinphoneUtils @@ -636,13 +637,26 @@ class NotificationsManager(private val context: Context) { contact.getPerson() } else { 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) builder.build() } - val msg = NotificationCompat.MessagingStyle.Message(message.message, message.time, person) - if (message.filePath != null) msg.setData(message.fileMime, message.filePath) + val msg = if (!corePreferences.hideChatMessageContentInNotification) { + 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) } diff --git a/app/src/main/res/layout/settings_chat_fragment.xml b/app/src/main/res/layout/settings_chat_fragment.xml index b02500635..127e482ca 100644 --- a/app/src/main/res/layout/settings_chat_fragment.xml +++ b/app/src/main/res/layout/settings_chat_fragment.xml @@ -99,6 +99,13 @@ linphone:listener="@{viewModel.downloadedMediaPublicListener}" linphone:checked="@={viewModel.downloadedMediaPublic}"/> + + @string/chat_room_delete_one_dialog @string/chat_room_delete_many_dialog + <Redacted> No recordings @@ -412,6 +413,8 @@ in bytes Make downloaded media public Files in ephemeral messages won\'t be, doesn\'t work with auto download feature + Hide message content in notifications + Only sender name will be displayed Create shortcuts to chat rooms in launcher Will be replaced by contacts shortcuts if enabled Hide empty chat rooms