From 84ee3eba21e99997c4b02b7ce2cb2983e8227af1 Mon Sep 17 00:00:00 2001 From: charles Date: Thu, 1 Dec 2022 13:40:48 +1100 Subject: [PATCH] Add legacy and pre-release ui updates --- .../expiration/ExpirationSettingsActivity.kt | 7 +++++- .../conversation/v2/ConversationActivityV2.kt | 8 +++++++ .../res/layout/activity_conversation_v2.xml | 22 +++++++++++++++++++ app/src/main/res/values/colors.xml | 2 ++ app/src/main/res/values/strings.xml | 3 +++ .../libsession/messaging/jobs/JobQueue.kt | 4 ++-- .../sending_receiving/MessageSender.kt | 7 +++++- 7 files changed, 49 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsActivity.kt index a6bc80d5b7..ee53e59f54 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsActivity.kt @@ -75,7 +75,12 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() { } val deleteTypeOptions = listOf( - RadioOption("off", getString(R.string.expiration_off)), + RadioOption(value = "-1", title = getString(R.string.expiration_off)), + RadioOption( + value = "0", + title = getString(R.string.expiration_type_disappear_legacy), + subtitle = getString(R.string.expiration_type_disappear_legacy_description) + ), RadioOption( value = ExpirationType.DELETE_AFTER_READ_VALUE.toString(), title = getString(R.string.expiration_type_disappear_after_read), diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index f52c365da3..480ab9f5cf 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -362,6 +362,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe setUpRecipientObserver() getLatestOpenGroupInfoIfNeeded() setUpBlockedBanner() + setUpOutdatedClientBanner(); binding!!.searchBottomBar.setEventListener(this) setUpSearchResultObserver() scrollToFirstUnreadMessageIfNeeded() @@ -567,6 +568,13 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe binding?.blockedBanner?.setOnClickListener { viewModel.unblock() } } + private fun setUpOutdatedClientBanner() { + val recipient = viewModel.recipient ?: return + if (recipient.expireMessages == 0) { return } + binding?.outdatedBannerTextView?.text = resources.getString(R.string.activity_conversation_outdated_client_banner_text) + binding?.outdatedBanner?.isVisible = true + } + private fun setUpLinkPreviewObserver() { if (!textSecurePreferences.isLinkPreviewsEnabled()) { linkPreviewViewModel.onUserCancel(); return diff --git a/app/src/main/res/layout/activity_conversation_v2.xml b/app/src/main/res/layout/activity_conversation_v2.xml index b458739217..5df54c7809 100644 --- a/app/src/main/res/layout/activity_conversation_v2.xml +++ b/app/src/main/res/layout/activity_conversation_v2.xml @@ -198,6 +198,28 @@ + + + + + + #EA5545 + #00F782 + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 783f036d45..3232e0bb7e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -873,6 +873,8 @@ Close Dialog Disappearing Messages This setting applies to everyone in this conversation. + Use the original version of disappearing messages. + Legacy Messages disappear after they have been sent. Disappear After Read Messages delete after they have been read. @@ -882,4 +884,5 @@ Delete Type Timer Only group admins can change this setting.]]> + This user\'s client is outdated. diff --git a/libsession/src/main/java/org/session/libsession/messaging/jobs/JobQueue.kt b/libsession/src/main/java/org/session/libsession/messaging/jobs/JobQueue.kt index 215d20834a..c47621682e 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/jobs/JobQueue.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/jobs/JobQueue.kt @@ -115,7 +115,7 @@ class JobQueue : JobDelegate { while (isActive) { when (val job = queue.receive()) { - is NotifyPNServerJob, is AttachmentUploadJob, is MessageSendJob -> { + is NotifyPNServerJob, is AttachmentUploadJob, is MessageSendJob, is DisappearingMessagesJob -> { txQueue.send(job) } is AttachmentDownloadJob -> { @@ -136,7 +136,7 @@ class JobQueue : JobDelegate { } } else -> { - throw IllegalStateException("Unexpected job type.") + throw IllegalStateException("Unexpected job type: ${job.getFactoryKey()}") } } } diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt index 12c8627b8d..11818fb1ca 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/MessageSender.kt @@ -12,6 +12,7 @@ import org.session.libsession.messaging.messages.control.CallMessage import org.session.libsession.messaging.messages.control.ClosedGroupControlMessage import org.session.libsession.messaging.messages.control.ConfigurationMessage import org.session.libsession.messaging.messages.control.ExpirationTimerUpdate +import org.session.libsession.messaging.messages.control.SyncedExpiriesMessage import org.session.libsession.messaging.messages.control.UnsendRequest import org.session.libsession.messaging.messages.visible.LinkPreview import org.session.libsession.messaging.messages.visible.Profile @@ -131,7 +132,11 @@ object MessageSender { // Convert it to protobuf val proto = message.toProto() ?: throw Error.ProtoConversionFailed // Serialize the protobuf - val plaintext = PushTransportDetails.getPaddedMessageBody(proto.toByteArray()) + val plaintext = if (message is SyncedExpiriesMessage) { + proto.toByteArray() + } else { + PushTransportDetails.getPaddedMessageBody(proto.toByteArray()) + } // Encrypt the serialized protobuf val ciphertext = when (destination) { is Destination.Contact -> MessageEncrypter.encrypt(plaintext, destination.publicKey)