From 3c40bf3d6fba55401e7949bab6679b87e894a67b Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 16 Jun 2025 11:28:16 +0200 Subject: [PATCH] Show event at top of conversation in case of unsecure conversation (like we do for e2e encrypted ones) + icon under conversation title --- .../chat/adapter/ConversationEventAdapter.kt | 7 +- .../chat/fragment/ConversationFragment.kt | 5 +- .../main/res/drawable/lock_simple_bold.xml | 9 --- .../main/res/drawable/lock_simple_open.xml | 9 +++ .../res/drawable/lock_simple_open_bold.xml | 9 --- .../res/layout/call_media_encryption_info.xml | 2 +- ...conversation_e2e_encrypted_first_event.xml | 2 +- .../res/layout/chat_conversation_fragment.xml | 40 +++++++++- ...n_send_area_disabled_unsecured_warning.xml | 2 +- ...n_unsafe_disabled_details_bottom_sheet.xml | 4 +- .../chat_conversation_unsafe_first_event.xml | 75 +++++++++++++++++++ app/src/main/res/layout/chat_list_cell.xml | 2 +- app/src/main/res/values-fr/strings.xml | 3 + app/src/main/res/values/strings.xml | 5 +- 14 files changed, 143 insertions(+), 31 deletions(-) delete mode 100644 app/src/main/res/drawable/lock_simple_bold.xml create mode 100644 app/src/main/res/drawable/lock_simple_open.xml delete mode 100644 app/src/main/res/drawable/lock_simple_open_bold.xml create mode 100644 app/src/main/res/layout/chat_conversation_unsafe_first_event.xml diff --git a/app/src/main/java/org/linphone/ui/main/chat/adapter/ConversationEventAdapter.kt b/app/src/main/java/org/linphone/ui/main/chat/adapter/ConversationEventAdapter.kt index f53551ec7..c02f7097b 100644 --- a/app/src/main/java/org/linphone/ui/main/chat/adapter/ConversationEventAdapter.kt +++ b/app/src/main/java/org/linphone/ui/main/chat/adapter/ConversationEventAdapter.kt @@ -36,6 +36,7 @@ import org.linphone.databinding.ChatBubbleIncomingBinding import org.linphone.databinding.ChatBubbleOutgoingBinding import org.linphone.databinding.ChatConversationEventBinding import org.linphone.databinding.ChatConversationE2eEncryptedFirstEventBinding +import org.linphone.databinding.ChatConversationUnsafeFirstEventBinding import org.linphone.ui.main.chat.model.EventLogModel import org.linphone.ui.main.chat.model.EventModel import org.linphone.ui.main.chat.model.MessageModel @@ -82,7 +83,11 @@ class ConversationEventAdapter : } override fun getHeaderViewForPosition(context: Context, position: Int): View { - val binding = ChatConversationE2eEncryptedFirstEventBinding.inflate(LayoutInflater.from(context)) + val binding = if (isConversationSecured) { + ChatConversationE2eEncryptedFirstEventBinding.inflate(LayoutInflater.from(context)) + } else { + ChatConversationUnsafeFirstEventBinding.inflate(LayoutInflater.from(context)) + } return binding.root } 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 f0c2d5bd3..3c19ae72c 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 @@ -315,6 +315,8 @@ open class ConversationFragment : SlidingPaneChildFragment() { if (e.y >= 0 && e.y <= headerItemDecoration.getDecorationHeight(0)) { if (viewModel.isEndToEndEncrypted.value == true) { showEndToEndEncryptionDetailsBottomSheet() + } else { + showUnsafeConversationDisabledDetailsBottomSheet() } return true } @@ -588,8 +590,7 @@ open class ConversationFragment : SlidingPaneChildFragment() { viewModel.isEndToEndEncrypted.observe(viewLifecycleOwner) { encrypted -> adapter.setIsConversationSecured(encrypted) - - if (encrypted) { + if (encrypted || (!encrypted && viewModel.isEndToEndEncryptionAvailable.value == true)) { binding.eventsList.addItemDecoration(headerItemDecoration) binding.eventsList.addOnItemTouchListener(listItemTouchListener) } diff --git a/app/src/main/res/drawable/lock_simple_bold.xml b/app/src/main/res/drawable/lock_simple_bold.xml deleted file mode 100644 index d8cbf8026..000000000 --- a/app/src/main/res/drawable/lock_simple_bold.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/lock_simple_open.xml b/app/src/main/res/drawable/lock_simple_open.xml new file mode 100644 index 000000000..34d68ddeb --- /dev/null +++ b/app/src/main/res/drawable/lock_simple_open.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/lock_simple_open_bold.xml b/app/src/main/res/drawable/lock_simple_open_bold.xml deleted file mode 100644 index 29f7aea35..000000000 --- a/app/src/main/res/drawable/lock_simple_open_bold.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/layout/call_media_encryption_info.xml b/app/src/main/res/layout/call_media_encryption_info.xml index c011d486c..9dd6e4c96 100644 --- a/app/src/main/res/layout/call_media_encryption_info.xml +++ b/app/src/main/res/layout/call_media_encryption_info.xml @@ -75,7 +75,7 @@ android:adjustViewBounds="true" android:paddingTop="3dp" android:contentDescription="@null" - android:src="@drawable/lock_simple_open_bold" + android:src="@drawable/lock_simple_open" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="@id/no_media_encryption_label" app:layout_constraintBottom_toBottomOf="@id/no_media_encryption_label" diff --git a/app/src/main/res/layout/chat_conversation_e2e_encrypted_first_event.xml b/app/src/main/res/layout/chat_conversation_e2e_encrypted_first_event.xml index c6bfda8f6..10f87a905 100644 --- a/app/src/main/res/layout/chat_conversation_e2e_encrypted_first_event.xml +++ b/app/src/main/res/layout/chat_conversation_e2e_encrypted_first_event.xml @@ -33,7 +33,7 @@ android:paddingTop="3dp" android:adjustViewBounds="true" android:contentDescription="@null" - android:src="@drawable/lock_simple_bold" + android:src="@drawable/lock_simple" app:tint="@color/blue_info_500" app:layout_constraintTop_toTopOf="@id/secured_title" app:layout_constraintBottom_toBottomOf="@id/secured_subtitle" diff --git a/app/src/main/res/layout/chat_conversation_fragment.xml b/app/src/main/res/layout/chat_conversation_fragment.xml index 9605a8231..0de030d66 100644 --- a/app/src/main/res/layout/chat_conversation_fragment.xml +++ b/app/src/main/res/layout/chat_conversation_fragment.xml @@ -119,7 +119,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" app:barrierDirection="top" - app:constraint_referenced_ids="muted, ephemeral_enabled" /> + app:constraint_referenced_ids="unsecure, unsecure_label, muted, ephemeral_enabled, ephemeral_duration" /> + + + + @@ -159,6 +191,8 @@ android:paddingBottom="2dp" android:text="@{viewModel.ephemeralLifeTimeLabel, default=`1 day`}" android:textSize="12sp" + android:maxLines="1" + android:ellipsize="end" android:visibility="@{viewModel.ephemeralLifetime > 0L ? View.VISIBLE : View.GONE, default=gone}" app:layout_constraintStart_toEndOf="@id/ephemeral_enabled" app:layout_constraintTop_toTopOf="@id/ephemeral_enabled" diff --git a/app/src/main/res/layout/chat_conversation_send_area_disabled_unsecured_warning.xml b/app/src/main/res/layout/chat_conversation_send_area_disabled_unsecured_warning.xml index 95184a9a5..d916febca 100644 --- a/app/src/main/res/layout/chat_conversation_send_area_disabled_unsecured_warning.xml +++ b/app/src/main/res/layout/chat_conversation_send_area_disabled_unsecured_warning.xml @@ -33,7 +33,7 @@ android:paddingTop="3dp" android:adjustViewBounds="true" android:contentDescription="@null" - android:src="@drawable/lock_simple_open_bold" + android:src="@drawable/lock_simple_open" app:tint="@color/orange_warning_600" app:layout_constraintTop_toTopOf="@id/disabled_title" app:layout_constraintBottom_toBottomOf="@id/disabled_subtitle" diff --git a/app/src/main/res/layout/chat_conversation_unsafe_disabled_details_bottom_sheet.xml b/app/src/main/res/layout/chat_conversation_unsafe_disabled_details_bottom_sheet.xml index 18deddcbe..1776fcf51 100644 --- a/app/src/main/res/layout/chat_conversation_unsafe_disabled_details_bottom_sheet.xml +++ b/app/src/main/res/layout/chat_conversation_unsafe_disabled_details_bottom_sheet.xml @@ -24,7 +24,7 @@ android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:gravity="center" - android:text="@string/conversation_warning_disabled_encrypted_bottom_sheet_title" + android:text="@string/conversation_warning_unsafe_bottom_sheet_title" android:textSize="16sp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -51,7 +51,7 @@ android:layout_marginStart="16dp" android:layout_marginEnd="16dp" android:gravity="center" - android:text="@string/conversation_warning_disabled_encrypted_bottom_sheet_message" + android:text="@string/conversation_warning_unsafe_bottom_sheet_message" android:textSize="12sp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/layout/chat_conversation_unsafe_first_event.xml b/app/src/main/res/layout/chat_conversation_unsafe_first_event.xml new file mode 100644 index 000000000..0901cda21 --- /dev/null +++ b/app/src/main/res/layout/chat_conversation_unsafe_first_event.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/chat_list_cell.xml b/app/src/main/res/layout/chat_list_cell.xml index d3d51de76..3d7e91307 100644 --- a/app/src/main/res/layout/chat_list_cell.xml +++ b/app/src/main/res/layout/chat_list_cell.xml @@ -201,7 +201,7 @@ android:layout_height="@dimen/small_icon_size" android:layout_marginStart="5dp" android:layout_marginEnd="10dp" - android:src="@drawable/lock_simple_open_bold" + android:src="@drawable/lock_simple_open" android:contentDescription="@string/content_description_chat_unsecured" android:visibility="@{model.isEncrypted || !model.isEncryptionAvailable ? View.GONE : View.VISIBLE}" app:layout_constraintTop_toBottomOf="@id/date_time" diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 3a640ce44..a4c07454b 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -495,6 +495,9 @@ Les messages de cette conversation sont chiffrés de bout en bout. Seul votre correspondant peut les déchiffrer. La confidentialité de vos échanges garantie 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;. + Les messages ne sont pas chiffrés, assurez-vous de ne pas partager d\'informations sensibles ! + Conversation non chiffrée + Les messages échangés dans cette conversation peuvent être interceptés et consultés par des personnes autres que le destinataire désiré, la confidentialité n\'est pas garantie ! Cette conversation n\'est pas chiffrée ! Cette conversation a été désactivée pour garantir votre sécurité. Chiffrement obligatoire diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 634a43771..29a082dc7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -537,10 +537,13 @@ Messages in this conversation are e2e encrypted. Only your correspondent can decrypt them. Guaranteed confidentiality 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. + Messages aren\'t encrypted, make sure you don\'t share sensitive information! + Unencrypted conversation + Messages exchanged in this conversation can be intercepted and read by other people than your correspondent, confidentiality is not guaranteed! This conversation is not encrypted! For your safety, this conversation was disabled. Mandatory encryption - You enabled mandatory encryption. Non encrypted conversations are disabled for your safety. You can re-create this conversation or disable mandatory encryption in your account parameters. + You enabled mandatory encryption. Unencrypted conversations are disabled for your safety. You can re-create this conversation or disable mandatory encryption in your account parameters. Maximum number of attachments reached! Set conversation subject Edit conversation subject