Fix message details screen styling

This commit is contained in:
nielsandriesse 2020-09-17 11:39:34 +10:00
parent 3f83cc9450
commit f1aa6e2697
7 changed files with 41 additions and 27 deletions

View File

@ -151,4 +151,11 @@
</TableLayout>
</LinearLayout>
<View
android:id="@+id/separator"
android:layout_width="match_parent"
android:layout_height="1px"
android:background="?android:dividerHorizontal" />
</LinearLayout>

View File

@ -8,25 +8,21 @@
android:layout_height="wrap_content"
android:padding="16dp">
<org.thoughtcrime.securesms.components.AvatarImageView
android:id="@+id/contact_photo_image"
android:foreground="@drawable/contact_photo_background"
android:layout_width="40dp"
android:layout_height="40dp"
<org.thoughtcrime.securesms.loki.views.ProfilePictureView
android:id="@+id/profilePictureView"
android:layout_width="@dimen/medium_profile_picture_size"
android:layout_height="@dimen/medium_profile_picture_size"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:layout_marginEnd="10dp"
android:cropToPadding="true"
tools:src="@drawable/ic_contact_picture"
android:contentDescription="@string/SingleContactSelectionActivity_contact_photo" />
android:layout_marginEnd="10dp" />
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dip"
android:layout_marginBottom="4dip"
android:layout_toEndOf="@id/contact_photo_image"
android:layout_toEndOf="@id/profilePictureView"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:orientation="horizontal">

View File

@ -59,6 +59,7 @@ import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.ExpirationUtil;
import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.loki.api.opengroups.PublicChat;
import java.lang.ref.WeakReference;
import java.sql.Date;
@ -97,6 +98,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
private View receivedContainer;
private TextView transport;
private TextView toFrom;
private View separator;
private ListView recipientsList;
private LayoutInflater inflater;
@ -177,6 +179,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
receivedDate = header.findViewById(R.id.received_time);
transport = header.findViewById(R.id.transport);
toFrom = header.findViewById(R.id.tofrom);
separator = header.findViewById(R.id.separator);
expiresContainer = header.findViewById(R.id.expires_container);
expiresInText = header.findViewById(R.id.expires_in);
recipientsList.setHeaderDividersEnabled(false);
@ -262,6 +265,12 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
toFromRes = R.string.message_details_header__from;
}
toFrom.setText(toFromRes);
long threadID = messageRecord.getThreadId();
PublicChat openGroup = DatabaseFactory.getLokiThreadDatabase(this).getPublicChat(threadID);
if (openGroup != null && messageRecord.isOutgoing()) {
toFrom.setVisibility(View.GONE);
separator.setVisibility(View.GONE);
}
conversationItem.bind(messageRecord, Optional.absent(), Optional.absent(), glideRequests, dynamicLanguage.getCurrentLocale(), new HashSet<>(), recipient, null, false);
recipientsList.setAdapter(new MessageDetailsRecipientAdapter(this, glideRequests, messageRecord, recipients, isPushGroup));
}

View File

@ -1,14 +1,15 @@
package org.thoughtcrime.securesms;
import android.content.Context;
import androidx.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.database.model.MessageRecord;
import org.thoughtcrime.securesms.loki.views.UserView;
import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.Conversions;
@ -17,8 +18,6 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import network.loki.messenger.R;
class MessageDetailsRecipientAdapter extends BaseAdapter implements AbsListView.RecyclerListener {
private final Context context;
@ -59,14 +58,11 @@ class MessageDetailsRecipientAdapter extends BaseAdapter implements AbsListView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.message_recipient_list_item, parent, false);
}
RecipientDeliveryStatus member = members.get(position);
((MessageRecipientListItem)convertView).set(glideRequests, record, member, isPushGroup);
return convertView;
UserView result = new UserView(context);
Recipient recipient = members.get(position).getRecipient();
result.setOpenGroupThreadID(record.getThreadId());
result.bind(recipient, glideRequests, UserView.ActionIndicator.None, false);
return result;
}
@Override

View File

@ -793,7 +793,7 @@ public class ConversationItem extends LinearLayout
}
private void setContactPhoto(@NonNull Recipient recipient) {
if (messageRecord == null) return; // TODO: Figure out how this happens
if (messageRecord == null) { return; } // TODO: Figure out how this happens
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)bodyBubble.getLayoutParams();
int groupThreadMargin = (int)((12 * getResources().getDisplayMetrics().density) + getResources().getDimension(R.dimen.small_profile_picture_size));
int defaultMargin = 0;
@ -803,7 +803,7 @@ public class ConversationItem extends LinearLayout
boolean isRSSFeed = threadName != null && (threadName.equals("Loki News") || threadName.equals("Session Updates"));
layoutParams.setMarginStart((groupThread && !isRSSFeed) ? groupThreadMargin : defaultMargin);
bodyBubble.setLayoutParams(layoutParams);
if (profilePictureView == null) return;
if (profilePictureView == null) { return; }
String publicKey = recipient.getAddress().toString();
profilePictureView.setPublicKey(publicKey);
String displayName = recipient.getName();

View File

@ -96,7 +96,7 @@ class ProfilePictureView : RelativeLayout {
}
} else {
publicKey = recipient.address.toString()
displayName = recipient.name
displayName = getUserDisplayName(publicKey)
additionalPublicKey = null
isRSSFeed = false
}

View File

@ -16,6 +16,7 @@ import org.thoughtcrime.securesms.recipients.Recipient
import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager
class UserView : LinearLayout {
var openGroupThreadID: Long = -1 // FIXME: This is a bit ugly
enum class ActionIndicator {
None,
@ -53,7 +54,12 @@ class UserView : LinearLayout {
if (publicKey == null || publicKey.isBlank()) {
return null
} else {
return DatabaseFactory.getLokiUserDatabase(context).getDisplayName(publicKey!!)
var result = DatabaseFactory.getLokiUserDatabase(context).getDisplayName(publicKey)
val publicChat = DatabaseFactory.getLokiThreadDatabase(context).getPublicChat(openGroupThreadID)
if (result == null && publicChat != null) {
result = DatabaseFactory.getLokiUserDatabase(context).getServerDisplayName(publicChat.id, publicKey)
}
return result
}
}
val address = user.address.serialize()
@ -84,7 +90,7 @@ class UserView : LinearLayout {
actionIndicatorImageView.setImageResource(R.drawable.ic_baseline_edit_24)
profilePictureView.glide = glide
profilePictureView.update()
nameTextView.text = user.name ?: "Unknown Contact"
nameTextView.text = getUserDisplayName(address)
when (actionIndicator) {
ActionIndicator.None -> {
actionIndicatorImageView.visibility = View.GONE