Add legacy and pre-release ui updates

This commit is contained in:
charles 2022-12-01 13:40:48 +11:00
parent cc8fdb58dd
commit 84ee3eba21
7 changed files with 49 additions and 4 deletions

View File

@ -75,7 +75,12 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() {
} }
val deleteTypeOptions = listOf( 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( RadioOption(
value = ExpirationType.DELETE_AFTER_READ_VALUE.toString(), value = ExpirationType.DELETE_AFTER_READ_VALUE.toString(),
title = getString(R.string.expiration_type_disappear_after_read), title = getString(R.string.expiration_type_disappear_after_read),

View File

@ -362,6 +362,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
setUpRecipientObserver() setUpRecipientObserver()
getLatestOpenGroupInfoIfNeeded() getLatestOpenGroupInfoIfNeeded()
setUpBlockedBanner() setUpBlockedBanner()
setUpOutdatedClientBanner();
binding!!.searchBottomBar.setEventListener(this) binding!!.searchBottomBar.setEventListener(this)
setUpSearchResultObserver() setUpSearchResultObserver()
scrollToFirstUnreadMessageIfNeeded() scrollToFirstUnreadMessageIfNeeded()
@ -567,6 +568,13 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
binding?.blockedBanner?.setOnClickListener { viewModel.unblock() } 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() { private fun setUpLinkPreviewObserver() {
if (!textSecurePreferences.isLinkPreviewsEnabled()) { if (!textSecurePreferences.isLinkPreviewsEnabled()) {
linkPreviewViewModel.onUserCancel(); return linkPreviewViewModel.onUserCancel(); return

View File

@ -198,6 +198,28 @@
</RelativeLayout> </RelativeLayout>
<RelativeLayout
android:id="@+id/outdatedBanner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/blockedBanner"
android:background="@color/outdated_client_banner_background_color"
android:visibility="gone"
tools:visibility="visible">
<TextView
android:id="@+id/outdatedBannerTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="@dimen/medium_spacing"
android:textColor="@color/black"
android:textSize="@dimen/small_font_size"
android:textStyle="bold"
tools:text="This user's client is outdated, things may not work as expected" />
</RelativeLayout>
<LinearLayout <LinearLayout
android:id="@+id/messageRequestBar" android:id="@+id/messageRequestBar"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -159,4 +159,6 @@
<color name="danger">#EA5545</color> <color name="danger">#EA5545</color>
<color name="outdated_client_banner_background_color">#00F782</color>
</resources> </resources>

View File

@ -873,6 +873,8 @@
<string name="new_conversation_dialog_close_button_content_description">Close Dialog</string> <string name="new_conversation_dialog_close_button_content_description">Close Dialog</string>
<string name="activity_expiration_settings_title">Disappearing Messages</string> <string name="activity_expiration_settings_title">Disappearing Messages</string>
<string name="activity_expiration_settings_subtitle">This setting applies to everyone in this conversation.</string> <string name="activity_expiration_settings_subtitle">This setting applies to everyone in this conversation.</string>
<string name="expiration_type_disappear_legacy_description">Use the original version of disappearing messages.</string>
<string name="expiration_type_disappear_legacy">Legacy</string>
<string name="activity_expiration_settings_subtitle_sent">Messages disappear after they have been sent.</string> <string name="activity_expiration_settings_subtitle_sent">Messages disappear after they have been sent.</string>
<string name="expiration_type_disappear_after_read">Disappear After Read</string> <string name="expiration_type_disappear_after_read">Disappear After Read</string>
<string name="expiration_type_disappear_after_read_description">Messages delete after they have been read.</string> <string name="expiration_type_disappear_after_read_description">Messages delete after they have been read.</string>
@ -882,4 +884,5 @@
<string name="activity_expiration_settings_delete_type">Delete Type</string> <string name="activity_expiration_settings_delete_type">Delete Type</string>
<string name="activity_expiration_settings_timer">Timer</string> <string name="activity_expiration_settings_timer">Timer</string>
<string name="activity_expiration_settings_group_footer"><![CDATA[This setting applies to everyone in this conversation.<br/>Only group admins can change this setting.]]></string> <string name="activity_expiration_settings_group_footer"><![CDATA[This setting applies to everyone in this conversation.<br/>Only group admins can change this setting.]]></string>
<string name="activity_conversation_outdated_client_banner_text">This user\'s client is outdated.</string>
</resources> </resources>

View File

@ -115,7 +115,7 @@ class JobQueue : JobDelegate {
while (isActive) { while (isActive) {
when (val job = queue.receive()) { when (val job = queue.receive()) {
is NotifyPNServerJob, is AttachmentUploadJob, is MessageSendJob -> { is NotifyPNServerJob, is AttachmentUploadJob, is MessageSendJob, is DisappearingMessagesJob -> {
txQueue.send(job) txQueue.send(job)
} }
is AttachmentDownloadJob -> { is AttachmentDownloadJob -> {
@ -136,7 +136,7 @@ class JobQueue : JobDelegate {
} }
} }
else -> { else -> {
throw IllegalStateException("Unexpected job type.") throw IllegalStateException("Unexpected job type: ${job.getFactoryKey()}")
} }
} }
} }

View File

@ -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.ClosedGroupControlMessage
import org.session.libsession.messaging.messages.control.ConfigurationMessage import org.session.libsession.messaging.messages.control.ConfigurationMessage
import org.session.libsession.messaging.messages.control.ExpirationTimerUpdate 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.control.UnsendRequest
import org.session.libsession.messaging.messages.visible.LinkPreview import org.session.libsession.messaging.messages.visible.LinkPreview
import org.session.libsession.messaging.messages.visible.Profile import org.session.libsession.messaging.messages.visible.Profile
@ -131,7 +132,11 @@ object MessageSender {
// Convert it to protobuf // Convert it to protobuf
val proto = message.toProto() ?: throw Error.ProtoConversionFailed val proto = message.toProto() ?: throw Error.ProtoConversionFailed
// Serialize the protobuf // 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 // Encrypt the serialized protobuf
val ciphertext = when (destination) { val ciphertext = when (destination) {
is Destination.Contact -> MessageEncrypter.encrypt(plaintext, destination.publicKey) is Destination.Contact -> MessageEncrypter.encrypt(plaintext, destination.publicKey)