mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
Show profile picture in conversation screen
This commit is contained in:
parent
3f208383f3
commit
7209686322
@ -20,9 +20,15 @@
|
|||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<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" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/medium_spacing"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -160,6 +160,7 @@ import org.thoughtcrime.securesms.loki.protocol.ClosedGroupsProtocol;
|
|||||||
import org.thoughtcrime.securesms.loki.protocol.SessionManagementProtocol;
|
import org.thoughtcrime.securesms.loki.protocol.SessionManagementProtocol;
|
||||||
import org.thoughtcrime.securesms.loki.utilities.MentionManagerUtilities;
|
import org.thoughtcrime.securesms.loki.utilities.MentionManagerUtilities;
|
||||||
import org.thoughtcrime.securesms.loki.views.MentionCandidateSelectionView;
|
import org.thoughtcrime.securesms.loki.views.MentionCandidateSelectionView;
|
||||||
|
import org.thoughtcrime.securesms.loki.views.ProfilePictureView;
|
||||||
import org.thoughtcrime.securesms.loki.views.SessionRestoreBannerView;
|
import org.thoughtcrime.securesms.loki.views.SessionRestoreBannerView;
|
||||||
import org.thoughtcrime.securesms.mediasend.Media;
|
import org.thoughtcrime.securesms.mediasend.Media;
|
||||||
import org.thoughtcrime.securesms.mediasend.MediaSendActivity;
|
import org.thoughtcrime.securesms.mediasend.MediaSendActivity;
|
||||||
@ -234,6 +235,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -300,6 +302,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
private AnimatingToggle buttonToggle;
|
private AnimatingToggle buttonToggle;
|
||||||
private SendButton sendButton;
|
private SendButton sendButton;
|
||||||
private ImageButton attachButton;
|
private ImageButton attachButton;
|
||||||
|
private ProfilePictureView profilePictureView;
|
||||||
private TextView titleTextView;
|
private TextView titleTextView;
|
||||||
private TextView charactersLeft;
|
private TextView charactersLeft;
|
||||||
private ConversationFragment fragment;
|
private ConversationFragment fragment;
|
||||||
@ -527,6 +530,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
composeText.setTransport(sendButton.getSelectedTransport());
|
composeText.setTransport(sendButton.getSelectedTransport());
|
||||||
|
|
||||||
updateTitleTextView(recipient);
|
updateTitleTextView(recipient);
|
||||||
|
updateProfilePicture();
|
||||||
updateSubtitleTextView();
|
updateSubtitleTextView();
|
||||||
setActionBarColor(recipient.getColor());
|
setActionBarColor(recipient.getColor());
|
||||||
updateInputUI(recipient, isSecureText, isDefaultSms);
|
updateInputUI(recipient, isSecureText, isDefaultSms);
|
||||||
@ -621,6 +625,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
recipient = Recipient.from(this, data.getParcelableExtra(GroupCreateActivity.GROUP_ADDRESS_EXTRA), true);
|
recipient = Recipient.from(this, data.getParcelableExtra(GroupCreateActivity.GROUP_ADDRESS_EXTRA), true);
|
||||||
recipient.addListener(this);
|
recipient.addListener(this);
|
||||||
updateTitleTextView(recipient);
|
updateTitleTextView(recipient);
|
||||||
|
updateProfilePicture();
|
||||||
updateSubtitleTextView();
|
updateSubtitleTextView();
|
||||||
NotificationChannels.updateContactChannelName(this, recipient);
|
NotificationChannels.updateContactChannelName(this, recipient);
|
||||||
updateInputUI(recipient, isSecureText, isDefaultSms);
|
updateInputUI(recipient, isSecureText, isDefaultSms);
|
||||||
@ -1654,6 +1659,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initializeViews() {
|
private void initializeViews() {
|
||||||
|
profilePictureView = findViewById(R.id.profilePictureView);
|
||||||
titleTextView = findViewById(R.id.titleTextView);
|
titleTextView = findViewById(R.id.titleTextView);
|
||||||
buttonToggle = ViewUtil.findById(this, R.id.button_toggle);
|
buttonToggle = ViewUtil.findById(this, R.id.button_toggle);
|
||||||
sendButton = ViewUtil.findById(this, R.id.send_button);
|
sendButton = ViewUtil.findById(this, R.id.send_button);
|
||||||
@ -1872,6 +1878,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
Util.runOnMain(() -> {
|
Util.runOnMain(() -> {
|
||||||
Log.i(TAG, "onModifiedRun(): " + recipient.getRegistered());
|
Log.i(TAG, "onModifiedRun(): " + recipient.getRegistered());
|
||||||
updateTitleTextView(recipient);
|
updateTitleTextView(recipient);
|
||||||
|
updateProfilePicture();
|
||||||
updateSubtitleTextView();
|
updateSubtitleTextView();
|
||||||
// titleView.setVerified(identityRecords.isVerified());
|
// titleView.setVerified(identityRecords.isVerified());
|
||||||
updateInputUI(recipient, isSecureText, isDefaultSms);
|
updateInputUI(recipient, isSecureText, isDefaultSms);
|
||||||
@ -3100,6 +3107,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateProfilePicture() {
|
||||||
|
profilePictureView.glide = GlideApp.with(this);
|
||||||
|
profilePictureView.update(recipient, threadId);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateSubtitleTextView() {
|
private void updateSubtitleTextView() {
|
||||||
muteIndicatorImageView.setVisibility(View.GONE);
|
muteIndicatorImageView.setVisibility(View.GONE);
|
||||||
subtitleTextView.setVisibility(View.VISIBLE);
|
subtitleTextView.setVisibility(View.VISIBLE);
|
||||||
|
@ -55,30 +55,8 @@ class ConversationView : LinearLayout {
|
|||||||
accentView.setBackgroundResource(R.color.accent)
|
accentView.setBackgroundResource(R.color.accent)
|
||||||
accentView.visibility = if (thread.unreadCount > 0) View.VISIBLE else View.INVISIBLE
|
accentView.visibility = if (thread.unreadCount > 0) View.VISIBLE else View.INVISIBLE
|
||||||
}
|
}
|
||||||
if (thread.recipient.isGroupRecipient) {
|
|
||||||
if ("Session Public Chat" == thread.recipient.name) {
|
|
||||||
profilePictureView.publicKey = ""
|
|
||||||
profilePictureView.additionalPublicKey = null
|
|
||||||
profilePictureView.isRSSFeed = true
|
|
||||||
} else {
|
|
||||||
val users = MentionsManager.shared.userPublicKeyCache[thread.threadId]?.toMutableList() ?: mutableListOf()
|
|
||||||
users.remove(TextSecurePreferences.getLocalNumber(context))
|
|
||||||
val masterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
|
||||||
if (masterPublicKey != null) {
|
|
||||||
users.remove(masterPublicKey)
|
|
||||||
}
|
|
||||||
val randomUsers = users.sorted() // Sort to provide a level of stability
|
|
||||||
profilePictureView.publicKey = randomUsers.getOrNull(0) ?: ""
|
|
||||||
profilePictureView.additionalPublicKey = randomUsers.getOrNull(1) ?: ""
|
|
||||||
profilePictureView.isRSSFeed = thread.recipient.name == "Loki News" || thread.recipient.name == "Session Updates"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
profilePictureView.publicKey = thread.recipient.address.toString()
|
|
||||||
profilePictureView.additionalPublicKey = null
|
|
||||||
profilePictureView.isRSSFeed = false
|
|
||||||
}
|
|
||||||
profilePictureView.glide = glide
|
profilePictureView.glide = glide
|
||||||
profilePictureView.update()
|
profilePictureView.update(thread.recipient, thread.threadId)
|
||||||
val senderDisplayName = if (thread.recipient.isLocalNumber) context.getString(R.string.note_to_self) else if (!thread.recipient.name.isNullOrEmpty()) thread.recipient.name else thread.recipient.address.toString()
|
val senderDisplayName = if (thread.recipient.isLocalNumber) context.getString(R.string.note_to_self) else if (!thread.recipient.name.isNullOrEmpty()) thread.recipient.name else thread.recipient.address.toString()
|
||||||
btnGroupNameDisplay.text = senderDisplayName
|
btnGroupNameDisplay.text = senderDisplayName
|
||||||
timestampTextView.text = DateUtils.getBriefRelativeTimeSpanString(context, Locale.getDefault(), thread.date)
|
timestampTextView.text = DateUtils.getBriefRelativeTimeSpanString(context, Locale.getDefault(), thread.date)
|
||||||
|
@ -8,6 +8,7 @@ import android.view.View
|
|||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
|
import kotlinx.android.synthetic.main.view_conversation.view.*
|
||||||
import kotlinx.android.synthetic.main.view_profile_picture.view.*
|
import kotlinx.android.synthetic.main.view_profile_picture.view.*
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto
|
import org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto
|
||||||
@ -16,6 +17,7 @@ import org.thoughtcrime.securesms.loki.todo.JazzIdenticonDrawable
|
|||||||
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.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
|
import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager
|
||||||
|
|
||||||
// TODO: Look into a better way of handling different sizes. Maybe an enum (with associated values) encapsulating the different modes?
|
// TODO: Look into a better way of handling different sizes. Maybe an enum (with associated values) encapsulating the different modes?
|
||||||
|
|
||||||
@ -51,6 +53,32 @@ class ProfilePictureView : RelativeLayout {
|
|||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region Updating
|
// region Updating
|
||||||
|
fun update(recipient: Recipient, threadID: Long) {
|
||||||
|
if (recipient.isGroupRecipient) {
|
||||||
|
if ("Session Public Chat" == recipient.name) {
|
||||||
|
publicKey = ""
|
||||||
|
additionalPublicKey = null
|
||||||
|
isRSSFeed = true
|
||||||
|
} else {
|
||||||
|
val users = MentionsManager.shared.userPublicKeyCache[threadID]?.toMutableList() ?: mutableListOf()
|
||||||
|
users.remove(TextSecurePreferences.getLocalNumber(context))
|
||||||
|
val masterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
||||||
|
if (masterPublicKey != null) {
|
||||||
|
users.remove(masterPublicKey)
|
||||||
|
}
|
||||||
|
val randomUsers = users.sorted() // Sort to provide a level of stability
|
||||||
|
publicKey = randomUsers.getOrNull(0) ?: ""
|
||||||
|
additionalPublicKey = randomUsers.getOrNull(1) ?: ""
|
||||||
|
isRSSFeed = recipient.name == "Loki News" || recipient.name == "Session Updates"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
publicKey = recipient.address.toString()
|
||||||
|
additionalPublicKey = null
|
||||||
|
isRSSFeed = false
|
||||||
|
}
|
||||||
|
update()
|
||||||
|
}
|
||||||
|
|
||||||
fun update() {
|
fun update() {
|
||||||
val publicKey = publicKey ?: return
|
val publicKey = publicKey ?: return
|
||||||
val additionalPublicKey = additionalPublicKey
|
val additionalPublicKey = additionalPublicKey
|
||||||
|
Loading…
x
Reference in New Issue
Block a user