From d3e895eac6fadbdfa80bc2c8af0357cd4336b880 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Fri, 4 Sep 2020 10:58:57 +1000 Subject: [PATCH 01/33] Don't append short IDs to display names --- .../loki/protocol/SessionMetaProtocol.kt | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt b/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt index a7acaa25fe..9f9a38427d 100644 --- a/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt +++ b/src/org/thoughtcrime/securesms/loki/protocol/SessionMetaProtocol.kt @@ -10,7 +10,6 @@ import org.thoughtcrime.securesms.recipients.Recipient import org.thoughtcrime.securesms.util.TextSecurePreferences import org.whispersystems.signalservice.api.messages.SignalServiceContent import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage -import org.whispersystems.signalservice.loki.protocol.shelved.multidevice.MultiDeviceProtocol import java.security.MessageDigest object SessionMetaProtocol { @@ -37,24 +36,16 @@ object SessionMetaProtocol { @JvmStatic fun handleProfileUpdateIfNeeded(context: Context, content: SignalServiceContent) { - val rawDisplayName = content.senderDisplayName.orNull() ?: return - if (rawDisplayName.isBlank()) { return } + val displayName = content.senderDisplayName.orNull() ?: return + if (displayName.isBlank()) { return } val userPublicKey = TextSecurePreferences.getLocalNumber(context) val userMasterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context) val sender = content.sender.toLowerCase() if (userMasterPublicKey == sender) { // Update the user's local name if the message came from their master device - TextSecurePreferences.setProfileName(context, rawDisplayName) - } - // Don't overwrite if the message came from a linked device; the device name is - // stored as a user name - val allUserDevices = MultiDeviceProtocol.shared.getAllLinkedDevices(userPublicKey) - if (!allUserDevices.contains(sender)) { - val displayName = rawDisplayName + " (..." + sender.substring(sender.length - 8) + ")" - DatabaseFactory.getLokiUserDatabase(context).setDisplayName(sender, displayName) - } else { - DatabaseFactory.getLokiUserDatabase(context).setDisplayName(sender, rawDisplayName) + TextSecurePreferences.setProfileName(context, displayName) } + DatabaseFactory.getLokiUserDatabase(context).setDisplayName(sender, displayName) } @JvmStatic From 31916a95d52b72f5186d9b52e1179522ae08f78e Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Fri, 4 Sep 2020 11:32:43 +1000 Subject: [PATCH 02/33] Don't show Session ID in conversation title view --- res/values-small/dimens.xml | 2 +- res/values/dimens.xml | 2 +- .../conversation/ConversationActivity.java | 14 +------------- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/res/values-small/dimens.xml b/res/values-small/dimens.xml index 4775251f06..81c5c4100b 100644 --- a/res/values-small/dimens.xml +++ b/res/values-small/dimens.xml @@ -8,7 +8,7 @@ 13sp 15sp 20sp - 25sp + 24sp 50sp diff --git a/res/values/dimens.xml b/res/values/dimens.xml index d255ee2585..1c0282a999 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -8,7 +8,7 @@ 15sp 17sp 22sp - 27sp + 26sp 50sp diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java index 4a06575a30..02a68f3e2c 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java @@ -3103,15 +3103,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity private void updateSubtitleTextView() { muteIndicatorImageView.setVisibility(View.GONE); subtitleTextView.setVisibility(View.VISIBLE); - if (messageStatus != null) { - switch (messageStatus) { - case "calculatingPoW": subtitleTextView.setText("Encrypting message"); break; - case "contactingNetwork": subtitleTextView.setText("Tracing a path"); break; - case "sendingMessage": subtitleTextView.setText("Sending message"); break; - case "messageSent": subtitleTextView.setText("Message sent securely"); break; - case "messageFailed": subtitleTextView.setText("Message failed to send"); break; - } - } else if (recipient.isMuted()) { + if (recipient.isMuted()) { muteIndicatorImageView.setVisibility(View.VISIBLE); subtitleTextView.setText("Muted until " + DateUtils.getFormattedDateTime(recipient.mutedUntil, "EEE, MMM d, yyyy HH:mm", Locale.getDefault())); } else if (recipient.isGroupRecipient() && recipient.getName() != null && !recipient.getName().equals("Session Updates") && !recipient.getName().equals("Loki News")) { @@ -3125,10 +3117,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity } else { subtitleTextView.setVisibility(View.GONE); } - } else if (PublicKeyValidation.isValid(recipient.getAddress().toString())) { - String ourMasterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(this); - String hexEncodedPublicKey = (recipient.isLocalNumber() && ourMasterHexEncodedPublicKey != null) ? ourMasterHexEncodedPublicKey : recipient.getAddress().toPhoneString(); - subtitleTextView.setText(hexEncodedPublicKey); } else { subtitleTextView.setVisibility(View.GONE); } From db0fd21097c3ed66e9633c6aef745dbb0e0e2b3b Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Fri, 4 Sep 2020 14:58:45 +1000 Subject: [PATCH 03/33] Make text bubbles a bit smaller --- res/layout/conversation_item_received.xml | 42 +++++++++---------- res/layout/conversation_item_sent.xml | 36 ++++++++-------- res/layout/document_view.xml | 1 + res/layout/quote_view.xml | 3 +- .../conversation/ConversationItem.java | 11 ++--- 5 files changed, 48 insertions(+), 45 deletions(-) diff --git a/res/layout/conversation_item_received.xml b/res/layout/conversation_item_received.xml index 5b7d503cdf..063b5dd939 100644 --- a/res/layout/conversation_item_received.xml +++ b/res/layout/conversation_item_received.xml @@ -59,8 +59,8 @@ android:layout_height="wrap_content" android:layout_marginEnd="@dimen/massive_spacing" android:layout_marginStart="12dp" - android:paddingTop="@dimen/medium_spacing" - android:paddingBottom="@dimen/medium_spacing" + android:paddingTop="12dp" + android:paddingBottom="12dp" android:orientation="vertical" android:clipToPadding="false" android:clipChildren="false" @@ -71,9 +71,9 @@ android:id="@+id/group_sender_holder" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="@dimen/message_bubble_horizontal_padding" - android:layout_marginBottom="@dimen/medium_spacing" - android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" + android:layout_marginStart="12dp" + android:layout_marginBottom="12dp" + android:layout_marginEnd="12dp" android:orientation="horizontal" android:visibility="gone" tools:visibility="visible"> @@ -113,9 +113,9 @@ android:id="@+id/quote_view" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="@dimen/large_spacing" - android:layout_marginBottom="@dimen/medium_spacing" - android:layout_marginEnd="@dimen/large_spacing" + android:layout_marginStart="20dp" + android:layout_marginBottom="12dp" + android:layout_marginEnd="20dp" android:visibility="gone" app:message_type="incoming" app:quote_colorPrimary="@color/text" @@ -127,7 +127,7 @@ android:layout="@layout/conversation_item_received_shared_contact" android:layout_width="@dimen/media_bubble_default_dimens" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/message_bubble_top_padding" + android:layout_marginTop="12dp" android:visibility="gone"/> + android:layout_marginStart="12dp" + android:layout_marginBottom="4dp" + android:layout_marginEnd="12dp" /> + android:layout_marginStart="12dp" + android:layout_marginEnd="12dp" /> + android:layout_marginStart="12dp" + android:layout_marginBottom="4dp" + android:layout_marginEnd="12dp" /> + android:layout_marginEnd="12dp" /> diff --git a/res/layout/quote_view.xml b/res/layout/quote_view.xml index 50b270b500..8b1fa969df 100644 --- a/res/layout/quote_view.xml +++ b/res/layout/quote_view.xml @@ -73,7 +73,7 @@ android:layout_height="wrap_content" style="@style/Signal.Text.Body" android:textColor="@color/text" - android:textSize="@dimen/medium_font_size" + android:textSize="@dimen/small_font_size" android:maxLines="1" android:ellipsize="end" tools:text="The-Amazing-Spider-Man.cba" /> @@ -99,6 +99,7 @@ android:layout_height="wrap_content" android:layout_marginTop="4dp" style="@style/Signal.Text.Body" + android:textSize="@dimen/small_font_size" android:ellipsize="end" android:maxLines="2" tools:text="With great power comes great responsibility." diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationItem.java b/src/org/thoughtcrime/securesms/conversation/ConversationItem.java index ca3d10db17..385c0fa9ab 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationItem.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationItem.java @@ -87,6 +87,7 @@ import org.thoughtcrime.securesms.jobs.SmsSendJob; import org.thoughtcrime.securesms.linkpreview.LinkPreview; import org.thoughtcrime.securesms.linkpreview.LinkPreviewUtil; import org.thoughtcrime.securesms.logging.Log; +import org.thoughtcrime.securesms.loki.utilities.GeneralUtilitiesKt; import org.thoughtcrime.securesms.loki.utilities.MentionUtilities; import org.thoughtcrime.securesms.loki.views.ProfilePictureView; import org.thoughtcrime.securesms.mms.GlideRequests; @@ -502,23 +503,23 @@ public class ConversationItem extends LinearLayout if (hasOnlyThumbnail(messageRecord)) { int topPadding = 0; if (groupSenderHolder.getVisibility() == VISIBLE) { - topPadding = (int)getResources().getDimension(R.dimen.medium_spacing); + topPadding = GeneralUtilitiesKt.toPx(12, getResources()); } int bottomPadding = 0; if (messageRecord.getBody().length() > 0) { - bodyTextLayoutParams.topMargin = (int)getResources().getDimension(R.dimen.medium_spacing); - bottomPadding = (int)getResources().getDimension(R.dimen.medium_spacing); + bodyTextLayoutParams.topMargin = GeneralUtilitiesKt.toPx(12, getResources()); + bottomPadding = GeneralUtilitiesKt.toPx(12, getResources()); } bodyBubble.setPadding(0, topPadding, 0, bottomPadding); } else { - bodyBubble.setPadding(0, (int)getResources().getDimension(R.dimen.medium_spacing), 0, (int)getResources().getDimension(R.dimen.medium_spacing)); + bodyBubble.setPadding(0, GeneralUtilitiesKt.toPx(12, getResources()), 0, GeneralUtilitiesKt.toPx(12, getResources())); } bodyText.setLayoutParams(bodyTextLayoutParams); LinearLayout.LayoutParams senderHolderLayoutParams = (LinearLayout.LayoutParams)groupSenderHolder.getLayoutParams(); if (groupSenderHolder.getVisibility() == VISIBLE && hasOnlyText(messageRecord)) { senderHolderLayoutParams.bottomMargin = (int)(getResources().getDisplayMetrics().density * 4); } else { - senderHolderLayoutParams.bottomMargin = (int)getResources().getDimension(R.dimen.medium_spacing); + senderHolderLayoutParams.bottomMargin = GeneralUtilitiesKt.toPx(12, getResources()); } groupSenderHolder.setLayoutParams(senderHolderLayoutParams); if (documentViewStub.resolved()) { From efbce3afa3f962102b8e5237881e820889b6ea17 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Fri, 4 Sep 2020 15:52:32 +1000 Subject: [PATCH 04/33] Fix inconsistent button styles --- res/layout-sw400dp/fragment_enter_chat_url.xml | 2 +- res/layout-sw400dp/fragment_enter_public_key.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/res/layout-sw400dp/fragment_enter_chat_url.xml b/res/layout-sw400dp/fragment_enter_chat_url.xml index 564580c481..f1a0feb4a0 100644 --- a/res/layout-sw400dp/fragment_enter_chat_url.xml +++ b/res/layout-sw400dp/fragment_enter_chat_url.xml @@ -23,7 +23,7 @@ android:layout_weight="1" />