From 7cf51f51a1c45fa99f41270585364ddae037c7aa Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 17 May 2024 17:18:56 +0200 Subject: [PATCH] Added explanation bottom sheet for unsafe conversations instead of going into account profile mode fragment that was recently removed --- .../chat/fragment/ConversationFragment.kt | 14 ++-- ...UnsafeConversationDetailsDialogFragment.kt | 72 +++++++++++++++++++ .../java/org/linphone/utils/AudioUtils.kt | 2 +- ...nversation_unsafe_details_bottom_sheet.xml | 62 ++++++++++++++++ app/src/main/res/values-fr/strings.xml | 4 +- app/src/main/res/values/strings.xml | 4 +- 6 files changed, 151 insertions(+), 7 deletions(-) create mode 100644 app/src/main/java/org/linphone/ui/main/chat/fragment/UnsafeConversationDetailsDialogFragment.kt create mode 100644 app/src/main/res/layout/chat_conversation_unsafe_details_bottom_sheet.xml diff --git a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt index 246bd426c..f5c59bf6d 100644 --- a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt @@ -565,10 +565,7 @@ class ConversationFragment : SlidingPaneChildFragment() { } binding.setWarningConversationDisabledClickListener { - Log.i( - "$TAG Navigating to account profile mode fragment to let user change mode to interop" - ) - // TODO FIXME: show bottom dialog like for encrypted conversation + showUnsafeConversationDetailsBottomSheet() } sendMessageViewModel.emojiToAddEvent.observe(viewLifecycleOwner) { @@ -1279,6 +1276,15 @@ class ConversationFragment : SlidingPaneChildFragment() { bottomSheetDialog = e2eEncryptionDetailsBottomSheet } + private fun showUnsafeConversationDetailsBottomSheet() { + val unsafeConversationDetailsBottomSheet = UnsafeConversationDetailsDialogFragment() + unsafeConversationDetailsBottomSheet.show( + requireActivity().supportFragmentManager, + UnsafeConversationDetailsDialogFragment.TAG + ) + bottomSheetDialog = unsafeConversationDetailsBottomSheet + } + private fun showOpenOrExportFileDialog(path: String, mime: String) { val model = ConfirmationDialogModel() val dialog = DialogUtils.getOpenOrExportFileDialog( diff --git a/app/src/main/java/org/linphone/ui/main/chat/fragment/UnsafeConversationDetailsDialogFragment.kt b/app/src/main/java/org/linphone/ui/main/chat/fragment/UnsafeConversationDetailsDialogFragment.kt new file mode 100644 index 000000000..30de06821 --- /dev/null +++ b/app/src/main/java/org/linphone/ui/main/chat/fragment/UnsafeConversationDetailsDialogFragment.kt @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of linphone-android + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.linphone.ui.main.chat.fragment + +import android.app.Dialog +import android.content.DialogInterface +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.annotation.UiThread +import com.google.android.material.bottomsheet.BottomSheetBehavior +import com.google.android.material.bottomsheet.BottomSheetDialog +import com.google.android.material.bottomsheet.BottomSheetDialogFragment +import org.linphone.R +import org.linphone.databinding.ChatConversationUnsafeDetailsBottomSheetBinding + +@UiThread +class UnsafeConversationDetailsDialogFragment( + private val onDismiss: (() -> Unit)? = null +) : BottomSheetDialogFragment() { + companion object { + const val TAG = "UnsafeConversationDetailsDialogFragment" + } + + override fun onCancel(dialog: DialogInterface) { + onDismiss?.invoke() + super.onCancel(dialog) + } + + override fun onDismiss(dialog: DialogInterface) { + onDismiss?.invoke() + super.onDismiss(dialog) + } + + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { + val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog + // Makes sure all menu entries are visible, + // required for landscape mode (otherwise only first item is visible) + dialog.behavior.state = BottomSheetBehavior.STATE_EXPANDED + + // Force this navigation bar color + dialog.window?.navigationBarColor = requireContext().getColor(R.color.gray_600) + return dialog + } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + val view = ChatConversationUnsafeDetailsBottomSheetBinding.inflate(layoutInflater) + return view.root + } +} diff --git a/app/src/main/java/org/linphone/utils/AudioUtils.kt b/app/src/main/java/org/linphone/utils/AudioUtils.kt index 2c839c015..f7929c9e9 100644 --- a/app/src/main/java/org/linphone/utils/AudioUtils.kt +++ b/app/src/main/java/org/linphone/utils/AudioUtils.kt @@ -234,7 +234,7 @@ class AudioUtils { val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager val audioAttrs = AudioAttributesCompat.Builder() .setUsage(AudioAttributesCompat.USAGE_MEDIA) - .setContentType(AudioAttributesCompat.CONTENT_TYPE_SPEECH) + .setContentType(AudioAttributesCompat.CONTENT_TYPE_MUSIC) .build() val request = diff --git a/app/src/main/res/layout/chat_conversation_unsafe_details_bottom_sheet.xml b/app/src/main/res/layout/chat_conversation_unsafe_details_bottom_sheet.xml new file mode 100644 index 000000000..0c5210e27 --- /dev/null +++ b/app/src/main/res/layout/chat_conversation_unsafe_details_bottom_sheet.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 44afe725f..159b181da 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -451,7 +451,9 @@ Grâce à la technologie de chiffrement de bout en bout de &appName;, la confidentialité de vos messages, appels et réunions avec vos correspondants est garantie. Personne ne pourra déchiffrer vos conversations, pas même &appName;. https://linphone.org/security Cette conversation n\'est pas chiffrée ! - Cette conversation a été désactivée car elle n\'est pas chiffrée. Vous pouvez l\'activer en changeant le mode de votre compte pour Intéropérable. + Cette conversation a été désactivée pour garantir votre sécurité. + Chiffrement obligatoire + Vous avez activé le chiffrement obligatoire. Vos conversations non chiffrées sont désactivées pour garantir votre sécurité. Vous pouvez recréer cette conversation ou bien désactiver le chiffrement obligatoire dans vos paramètres de compte. Nommer la conversation Renommer la conversation Nom de la conversation diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index de5b099c2..01c4c9409 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -487,7 +487,9 @@ Thanks to end-to-end encryption technology in &appName;, messages, calls and meetings confidentiality are guaranteed. No-one can decrypt exchanged data, not even ourselves. https://linphone.org/security This conversation is not encrypted! - This conversation was disabled because it is not encrypted. You can enable it back by switching your account profile mode from Secure to Interoperable. + For your safety, this conversation was disabled. + Mandatory encryption + Set conversation subject Edit conversation subject Conversation subject