mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
Fix message details screen styling
This commit is contained in:
parent
3f83cc9450
commit
f1aa6e2697
@ -151,4 +151,11 @@
|
|||||||
|
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/separator"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1px"
|
||||||
|
android:background="?android:dividerHorizontal" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -8,25 +8,21 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="16dp">
|
android:padding="16dp">
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.AvatarImageView
|
<org.thoughtcrime.securesms.loki.views.ProfilePictureView
|
||||||
android:id="@+id/contact_photo_image"
|
android:id="@+id/profilePictureView"
|
||||||
android:foreground="@drawable/contact_photo_background"
|
android:layout_width="@dimen/medium_profile_picture_size"
|
||||||
android:layout_width="40dp"
|
android:layout_height="@dimen/medium_profile_picture_size"
|
||||||
android:layout_height="40dp"
|
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_marginTop="3dp"
|
android:layout_marginTop="3dp"
|
||||||
android:layout_marginBottom="3dp"
|
android:layout_marginBottom="3dp"
|
||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="10dp" />
|
||||||
android:cropToPadding="true"
|
|
||||||
tools:src="@drawable/ic_contact_picture"
|
|
||||||
android:contentDescription="@string/SingleContactSelectionActivity_contact_photo" />
|
|
||||||
|
|
||||||
<LinearLayout android:layout_width="match_parent"
|
<LinearLayout android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="4dip"
|
android:layout_marginTop="4dip"
|
||||||
android:layout_marginBottom="4dip"
|
android:layout_marginBottom="4dip"
|
||||||
android:layout_toEndOf="@id/contact_photo_image"
|
android:layout_toEndOf="@id/profilePictureView"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
@ -59,6 +59,7 @@ import org.thoughtcrime.securesms.util.DynamicLanguage;
|
|||||||
import org.thoughtcrime.securesms.util.ExpirationUtil;
|
import org.thoughtcrime.securesms.util.ExpirationUtil;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
|
import org.whispersystems.signalservice.loki.api.opengroups.PublicChat;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.sql.Date;
|
import java.sql.Date;
|
||||||
@ -97,6 +98,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
|
|||||||
private View receivedContainer;
|
private View receivedContainer;
|
||||||
private TextView transport;
|
private TextView transport;
|
||||||
private TextView toFrom;
|
private TextView toFrom;
|
||||||
|
private View separator;
|
||||||
private ListView recipientsList;
|
private ListView recipientsList;
|
||||||
private LayoutInflater inflater;
|
private LayoutInflater inflater;
|
||||||
|
|
||||||
@ -177,6 +179,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
|
|||||||
receivedDate = header.findViewById(R.id.received_time);
|
receivedDate = header.findViewById(R.id.received_time);
|
||||||
transport = header.findViewById(R.id.transport);
|
transport = header.findViewById(R.id.transport);
|
||||||
toFrom = header.findViewById(R.id.tofrom);
|
toFrom = header.findViewById(R.id.tofrom);
|
||||||
|
separator = header.findViewById(R.id.separator);
|
||||||
expiresContainer = header.findViewById(R.id.expires_container);
|
expiresContainer = header.findViewById(R.id.expires_container);
|
||||||
expiresInText = header.findViewById(R.id.expires_in);
|
expiresInText = header.findViewById(R.id.expires_in);
|
||||||
recipientsList.setHeaderDividersEnabled(false);
|
recipientsList.setHeaderDividersEnabled(false);
|
||||||
@ -262,6 +265,12 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
|
|||||||
toFromRes = R.string.message_details_header__from;
|
toFromRes = R.string.message_details_header__from;
|
||||||
}
|
}
|
||||||
toFrom.setText(toFromRes);
|
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);
|
conversationItem.bind(messageRecord, Optional.absent(), Optional.absent(), glideRequests, dynamicLanguage.getCurrentLocale(), new HashSet<>(), recipient, null, false);
|
||||||
recipientsList.setAdapter(new MessageDetailsRecipientAdapter(this, glideRequests, messageRecord, recipients, isPushGroup));
|
recipientsList.setAdapter(new MessageDetailsRecipientAdapter(this, glideRequests, messageRecord, recipients, isPushGroup));
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
package org.thoughtcrime.securesms;
|
package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||||
|
import org.thoughtcrime.securesms.loki.views.UserView;
|
||||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.util.Conversions;
|
import org.thoughtcrime.securesms.util.Conversions;
|
||||||
@ -17,8 +18,6 @@ import java.security.MessageDigest;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
|
||||||
|
|
||||||
class MessageDetailsRecipientAdapter extends BaseAdapter implements AbsListView.RecyclerListener {
|
class MessageDetailsRecipientAdapter extends BaseAdapter implements AbsListView.RecyclerListener {
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
@ -59,14 +58,11 @@ class MessageDetailsRecipientAdapter extends BaseAdapter implements AbsListView.
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
if (convertView == null) {
|
UserView result = new UserView(context);
|
||||||
convertView = LayoutInflater.from(context).inflate(R.layout.message_recipient_list_item, parent, false);
|
Recipient recipient = members.get(position).getRecipient();
|
||||||
}
|
result.setOpenGroupThreadID(record.getThreadId());
|
||||||
|
result.bind(recipient, glideRequests, UserView.ActionIndicator.None, false);
|
||||||
RecipientDeliveryStatus member = members.get(position);
|
return result;
|
||||||
|
|
||||||
((MessageRecipientListItem)convertView).set(glideRequests, record, member, isPushGroup);
|
|
||||||
return convertView;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -793,7 +793,7 @@ public class ConversationItem extends LinearLayout
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setContactPhoto(@NonNull Recipient recipient) {
|
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();
|
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)bodyBubble.getLayoutParams();
|
||||||
int groupThreadMargin = (int)((12 * getResources().getDisplayMetrics().density) + getResources().getDimension(R.dimen.small_profile_picture_size));
|
int groupThreadMargin = (int)((12 * getResources().getDisplayMetrics().density) + getResources().getDimension(R.dimen.small_profile_picture_size));
|
||||||
int defaultMargin = 0;
|
int defaultMargin = 0;
|
||||||
@ -803,7 +803,7 @@ public class ConversationItem extends LinearLayout
|
|||||||
boolean isRSSFeed = threadName != null && (threadName.equals("Loki News") || threadName.equals("Session Updates"));
|
boolean isRSSFeed = threadName != null && (threadName.equals("Loki News") || threadName.equals("Session Updates"));
|
||||||
layoutParams.setMarginStart((groupThread && !isRSSFeed) ? groupThreadMargin : defaultMargin);
|
layoutParams.setMarginStart((groupThread && !isRSSFeed) ? groupThreadMargin : defaultMargin);
|
||||||
bodyBubble.setLayoutParams(layoutParams);
|
bodyBubble.setLayoutParams(layoutParams);
|
||||||
if (profilePictureView == null) return;
|
if (profilePictureView == null) { return; }
|
||||||
String publicKey = recipient.getAddress().toString();
|
String publicKey = recipient.getAddress().toString();
|
||||||
profilePictureView.setPublicKey(publicKey);
|
profilePictureView.setPublicKey(publicKey);
|
||||||
String displayName = recipient.getName();
|
String displayName = recipient.getName();
|
||||||
|
@ -96,7 +96,7 @@ class ProfilePictureView : RelativeLayout {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
publicKey = recipient.address.toString()
|
publicKey = recipient.address.toString()
|
||||||
displayName = recipient.name
|
displayName = getUserDisplayName(publicKey)
|
||||||
additionalPublicKey = null
|
additionalPublicKey = null
|
||||||
isRSSFeed = false
|
isRSSFeed = false
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import org.thoughtcrime.securesms.recipients.Recipient
|
|||||||
import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager
|
import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager
|
||||||
|
|
||||||
class UserView : LinearLayout {
|
class UserView : LinearLayout {
|
||||||
|
var openGroupThreadID: Long = -1 // FIXME: This is a bit ugly
|
||||||
|
|
||||||
enum class ActionIndicator {
|
enum class ActionIndicator {
|
||||||
None,
|
None,
|
||||||
@ -53,7 +54,12 @@ class UserView : LinearLayout {
|
|||||||
if (publicKey == null || publicKey.isBlank()) {
|
if (publicKey == null || publicKey.isBlank()) {
|
||||||
return null
|
return null
|
||||||
} else {
|
} 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()
|
val address = user.address.serialize()
|
||||||
@ -84,7 +90,7 @@ class UserView : LinearLayout {
|
|||||||
actionIndicatorImageView.setImageResource(R.drawable.ic_baseline_edit_24)
|
actionIndicatorImageView.setImageResource(R.drawable.ic_baseline_edit_24)
|
||||||
profilePictureView.glide = glide
|
profilePictureView.glide = glide
|
||||||
profilePictureView.update()
|
profilePictureView.update()
|
||||||
nameTextView.text = user.name ?: "Unknown Contact"
|
nameTextView.text = getUserDisplayName(address)
|
||||||
when (actionIndicator) {
|
when (actionIndicator) {
|
||||||
ActionIndicator.None -> {
|
ActionIndicator.None -> {
|
||||||
actionIndicatorImageView.visibility = View.GONE
|
actionIndicatorImageView.visibility = View.GONE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user