From f41ab951e23372429ab03788b525d635e3970e1e Mon Sep 17 00:00:00 2001 From: jubb Date: Mon, 28 Jun 2021 12:12:34 +1000 Subject: [PATCH] refactor: simplify the long message activity --- .../conversation/v2/ConversationActivityV2.kt | 5 ---- .../longmessage/LongMessageActivity.java | 29 ++++--------------- .../main/res/layout/longmessage_activity.xml | 21 +++++++------- 3 files changed, 16 insertions(+), 39 deletions(-) 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 0d70f24e0a..df917e50cb 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 @@ -2,10 +2,8 @@ package org.thoughtcrime.securesms.conversation.v2 import android.animation.FloatEvaluator import android.animation.ValueAnimator -import android.app.Activity import android.content.Context import android.content.Intent -import android.content.Intent import android.content.res.Resources import android.database.Cursor import android.graphics.Rect @@ -45,7 +43,6 @@ import org.session.libsession.messaging.open_groups.OpenGroupAPIV2 import org.session.libsession.messaging.sending_receiving.MessageSender import org.session.libsession.messaging.sending_receiving.attachments.Attachment import org.session.libsession.utilities.MediaTypes -import org.session.libsession.utilities.ServiceUtil import org.session.libsession.utilities.TextSecurePreferences import org.session.libsignal.utilities.ListenableFuture import org.thoughtcrime.securesms.ApplicationContext @@ -71,13 +68,11 @@ import org.thoughtcrime.securesms.linkpreview.LinkPreviewViewModel import org.thoughtcrime.securesms.linkpreview.LinkPreviewViewModel.LinkPreviewState import org.thoughtcrime.securesms.loki.utilities.ActivityDispatcher import org.thoughtcrime.securesms.loki.utilities.push -import org.thoughtcrime.securesms.loki.utilities.show import org.thoughtcrime.securesms.loki.utilities.toPx import org.thoughtcrime.securesms.mediasend.Media import org.thoughtcrime.securesms.mediasend.MediaSendActivity import org.thoughtcrime.securesms.mms.* import org.thoughtcrime.securesms.notifications.MarkReadReceiver -import org.thoughtcrime.securesms.providers.BlobProvider import org.thoughtcrime.securesms.util.DateUtils import org.thoughtcrime.securesms.util.MediaUtil import java.util.* diff --git a/app/src/main/java/org/thoughtcrime/securesms/longmessage/LongMessageActivity.java b/app/src/main/java/org/thoughtcrime/securesms/longmessage/LongMessageActivity.java index d3c683dd46..03af13d6b2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/longmessage/LongMessageActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/longmessage/LongMessageActivity.java @@ -43,8 +43,8 @@ public class LongMessageActivity extends PassphraseRequiredActionBarActivity { private static final int MAX_DISPLAY_LENGTH = 64 * 1024; - private Stub sentBubble; - private Stub receivedBubble; + private TextView textBody; + private ConversationItemFooter footerText; private LongMessageViewModel viewModel; @@ -60,9 +60,8 @@ public class LongMessageActivity extends PassphraseRequiredActionBarActivity { protected void onCreate(Bundle savedInstanceState, boolean ready) { super.onCreate(savedInstanceState, ready); setContentView(R.layout.longmessage_activity); - - sentBubble = new Stub<>(findViewById(R.id.longmessage_sent_stub)); - receivedBubble = new Stub<>(findViewById(R.id.longmessage_received_stub)); + textBody = findViewById(R.id.longmessage_text); + footerText = findViewById(R.id.longmessage_footer); initViewModel(getIntent().getLongExtra(KEY_MESSAGE_ID, -1), getIntent().getBooleanExtra(KEY_IS_MMS, false)); } @@ -102,27 +101,11 @@ public class LongMessageActivity extends PassphraseRequiredActionBarActivity { getSupportActionBar().setTitle(getString(R.string.LongMessageActivity_message_from_s, name)); } - ViewGroup bubble; - - if (message.get().getMessageRecord().isOutgoing()) { - bubble = sentBubble.get(); - bubble.getBackground().setColorFilter(ThemeUtil.getThemedColor(this, R.attr.message_sent_background_color), PorterDuff.Mode.MULTIPLY); - } else { - bubble = receivedBubble.get(); - bubble.getBackground().setColorFilter(ThemeUtil.getThemedColor(this, R.attr.message_received_background_color), PorterDuff.Mode.MULTIPLY); - } - - TextView text = bubble.findViewById(R.id.longmessage_text); - ConversationItemFooter footer = bubble.findViewById(R.id.longmessage_footer); - String trimmedBody = getTrimmedBody(message.get().getFullBody()); SpannableString styledBody = linkifyMessageBody(new SpannableString(trimmedBody)); - bubble.setVisibility(View.VISIBLE); - text.setText(styledBody); - text.setMovementMethod(LinkMovementMethod.getInstance()); - text.setTextSize(TypedValue.COMPLEX_UNIT_SP, TextSecurePreferences.getMessageBodyTextSize(this)); - footer.setMessageRecord(message.get().getMessageRecord(), Locale.getDefault()); + textBody.setText(styledBody); + footerText.setMessageRecord(message.get().getMessageRecord(), Locale.getDefault()); }); } diff --git a/app/src/main/res/layout/longmessage_activity.xml b/app/src/main/res/layout/longmessage_activity.xml index 49f0641ab5..382b0c6bcf 100644 --- a/app/src/main/res/layout/longmessage_activity.xml +++ b/app/src/main/res/layout/longmessage_activity.xml @@ -4,23 +4,22 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - + android:layout_height="wrap_content"/> - + - + \ No newline at end of file