Show blue toast when entering an end-to-end encrypted conversation

This commit is contained in:
Sylvain Berfini 2024-01-15 10:54:33 +01:00
parent 6f623ae080
commit 4b2058fbe6
4 changed files with 26 additions and 3 deletions

View file

@ -308,6 +308,16 @@ class MainActivity : GenericActivity() {
)
}
fun showBlueToast(message: String, @DrawableRes icon: Int) {
val blueToast = ToastUtils.getBlueToast(this, binding.toastsArea, message, icon)
binding.toastsArea.addView(blueToast.root)
blueToast.root.slideInToastFromTopForDuration(
binding.toastsArea as ViewGroup,
lifecycleScope
)
}
fun showRedToast(message: String, @DrawableRes icon: Int) {
val redToast = ToastUtils.getRedToast(this, binding.toastsArea, message, icon)
binding.toastsArea.addView(redToast.root)

View file

@ -326,6 +326,13 @@ class ConversationFragment : SlidingPaneChildFragment() {
(requireActivity() as MainActivity).showRedToast(message, R.drawable.x)
}
} else {
if (viewModel.isEndToEndEncrypted.value == true) {
Log.i("$TAG Conversation is end-to-end encrypted, showing toast")
val message = getString(R.string.toast_end_to_end_encrypted_conversation)
val icon = R.drawable.media_encryption_srtp
(requireActivity() as MainActivity).showBlueToast(message, icon)
}
sendMessageViewModel.configureChatRoom(viewModel.chatRoom)
// Wait for chat room to be ready before trying to forward a message in it

View file

@ -56,6 +56,8 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
val events = MutableLiveData<ArrayList<EventLogModel>>()
var isEndToEndEncrypted = MutableLiveData<Boolean>()
val isGroup = MutableLiveData<Boolean>()
val subject = MutableLiveData<String>()
@ -453,6 +455,9 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
if (readOnly) {
Log.w("$TAG Conversation with subject [${chatRoom.subject}] is read only!")
}
isEndToEndEncrypted.postValue(
chatRoom.hasCapability(ChatRoom.Capabilities.Encrypted.toInt())
)
computeConversationInfo()

View file

@ -164,6 +164,10 @@
</plurals>
<string name="toast_text_waiting_to_be_shared">Text is waiting to be shared</string>
<string name="toast_message_waiting_to_be_forwarded">A message is waiting to be forwarded</string>
<string name="toast_end_to_end_encrypted_conversation">Conversation is end-to-end encrypted</string>
<string name="toast_call_transfer_in_progress">Call is being transferred to %s</string>
<string name="toast_call_transfer_successful">Call has been transferred to %s</string>
<string name="toast_call_transfer_failed">Call transfer to %s failed!</string>
<string name="assistant_account_login">Login</string>
<string name="assistant_scan_qr_code">Scan QR code</string>
@ -509,9 +513,6 @@
<string name="calls_list_title">Calls list</string>
<string name="call_transfer_title">Transfer call to</string>
<string name="call_remote_is_recording">%s is recording</string>
<string name="toast_call_transfer_in_progress">Call is being transferred to %s</string>
<string name="toast_call_transfer_successful">Call has been transferred to %s</string>
<string name="toast_call_transfer_failed">Call transfer to %s failed!</string>
<string name="calls_count_label">%s calls</string>
<string name="calls_paused_count_label">%s paused calls</string>