mirror of https://github.com/M66B/FairEmail.git
Show avatar in message view
This commit is contained in:
parent
80f7031b26
commit
7b70586778
|
@ -19,6 +19,7 @@ package eu.faircode.email;
|
|||
Copyright 2018 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
|
@ -31,6 +32,7 @@ import android.graphics.drawable.Drawable;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.ContactsContract;
|
||||
import android.text.Editable;
|
||||
import android.text.Html;
|
||||
import android.text.Layout;
|
||||
|
@ -93,11 +95,12 @@ public class FragmentMessage extends FragmentEx {
|
|||
private ViewGroup view;
|
||||
private View vwAnswerAnchor;
|
||||
private ImageView ivFlagged;
|
||||
private ImageView ivAvatar;
|
||||
private TextView tvFrom;
|
||||
private TextView tvTime;
|
||||
private TextView tvCount;
|
||||
private TextView tvTo;
|
||||
private TextView tvSubject;
|
||||
private TextView tvCount;
|
||||
private TextView tvReplyTo;
|
||||
private TextView tvCc;
|
||||
private TextView tvBcc;
|
||||
|
@ -152,11 +155,12 @@ public class FragmentMessage extends FragmentEx {
|
|||
// Get controls
|
||||
vwAnswerAnchor = view.findViewById(R.id.vwAnswerAnchor);
|
||||
ivFlagged = view.findViewById(R.id.ivFlagged);
|
||||
ivAvatar = view.findViewById(R.id.ivAvatar);
|
||||
tvFrom = view.findViewById(R.id.tvFrom);
|
||||
tvTime = view.findViewById(R.id.tvTime);
|
||||
tvCount = view.findViewById(R.id.tvCount);
|
||||
tvTo = view.findViewById(R.id.tvTo);
|
||||
tvSubject = view.findViewById(R.id.tvSubject);
|
||||
tvCount = view.findViewById(R.id.tvCount);
|
||||
tvReplyTo = view.findViewById(R.id.tvReplyTo);
|
||||
tvCc = view.findViewById(R.id.tvCc);
|
||||
tvBcc = view.findViewById(R.id.tvBcc);
|
||||
|
@ -387,11 +391,10 @@ public class FragmentMessage extends FragmentEx {
|
|||
ivFlagged.setImageResource(message.ui_flagged ? R.drawable.baseline_star_24 : R.drawable.baseline_star_border_24);
|
||||
tvFrom.setText(MessageHelper.getFormattedAddresses(message.from, true));
|
||||
tvTime.setText(message.sent == null ? null : df.format(new Date(message.sent)));
|
||||
tvCount.setText(Integer.toString(message.count));
|
||||
tvTo.setText(MessageHelper.getFormattedAddresses(message.to, true));
|
||||
tvSubject.setText(message.subject);
|
||||
|
||||
tvCount.setText(Integer.toString(message.count));
|
||||
|
||||
tvReplyTo.setText(MessageHelper.getFormattedAddresses(message.reply, true));
|
||||
tvCc.setText(MessageHelper.getFormattedAddresses(message.cc, true));
|
||||
tvBcc.setText(MessageHelper.getFormattedAddresses(message.bcc, true));
|
||||
|
@ -427,6 +430,17 @@ public class FragmentMessage extends FragmentEx {
|
|||
|
||||
setSeen();
|
||||
|
||||
if (message.avatar == null) {
|
||||
ViewGroup.LayoutParams lp = ivAvatar.getLayoutParams();
|
||||
lp.height = 0;
|
||||
lp.width = 0;
|
||||
ivAvatar.setLayoutParams(lp);
|
||||
} else {
|
||||
ContentResolver resolver = getContext().getContentResolver();
|
||||
InputStream is = ContactsContract.Contacts.openContactPhotoInputStream(resolver, Uri.parse(message.avatar));
|
||||
ivAvatar.setImageDrawable(Drawable.createFromStream(is, "avatar"));
|
||||
}
|
||||
|
||||
pbWait.setVisibility(View.GONE);
|
||||
|
||||
grpHeader.setVisibility(free ? View.GONE : View.VISIBLE);
|
||||
|
|
|
@ -25,6 +25,16 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/tvFrom" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivAvatar"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:src="@drawable/baseline_person_24"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
|
||||
app:layout_constraintStart_toEndOf="@id/ivFlagged"
|
||||
app:layout_constraintTop_toTopOf="@+id/tvFrom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFrom"
|
||||
android:layout_width="0dp"
|
||||
|
@ -36,33 +46,56 @@
|
|||
android:text="From"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tvTime"
|
||||
app:layout_constraintStart_toEndOf="@id/ivFlagged"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/ivAvatar"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:freezesText="true"
|
||||
android:maxLines="1"
|
||||
android:text="Time"
|
||||
android:text="12:34:56"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tvCount"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvFrom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCount"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="3dp"
|
||||
android:maxLines="1"
|
||||
android:text="3"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivThread"
|
||||
app:layout_constraintTop_toTopOf="@id/tvTime" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivThread"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_message_24"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvTime"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/tvFrom" />
|
||||
app:layout_constraintTop_toTopOf="@id/tvTime" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvToTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:text="@string/title_to"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvFrom" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvTime" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTo"
|
||||
|
@ -70,14 +103,13 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:freezesText="true"
|
||||
android:text="To"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/tvToTitle"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvFrom" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvTime" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSubject"
|
||||
|
@ -89,32 +121,10 @@
|
|||
android:text="Subject"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tvCount"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvTo" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCount"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="3dp"
|
||||
android:maxLines="1"
|
||||
android:text="3"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvSubject"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivThread"
|
||||
app:layout_constraintTop_toTopOf="@id/tvSubject" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivThread"
|
||||
android:layout_width="15dp"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_message_24"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tvSubject"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/tvSubject" />
|
||||
|
||||
<View
|
||||
android:id="@+id/vSeparatorAddress"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -380,7 +390,7 @@
|
|||
android:id="@+id/grpHeader"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="ivFlagged,tvFrom,tvToTitle,tvTo,tvSize,tvTime,tvSubject" />
|
||||
app:constraint_referenced_ids="ivFlagged,ivAvatar,tvFrom,tvToTitle,tvTo,tvSize,tvTime,tvSubject" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpThread"
|
||||
|
|
Loading…
Reference in New Issue