Tap contact photo to go to contact

pull/164/head
M66B 5 years ago
parent 7fd055fa6e
commit b6ec653f2e

@ -259,15 +259,15 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private View vwColor; private View vwColor;
private ImageButton ibExpander; private ImageButton ibExpander;
private ImageView ibFlagged; private ImageView ibFlagged;
private ImageView ivAvatar; private ImageButton ibAvatar;
private ImageView ibAuth; private ImageButton ibAuth;
private ImageView ivPriorityHigh; private ImageView ivPriorityHigh;
private ImageView ivPriorityLow; private ImageView ivPriorityLow;
private TextView tvFrom; private TextView tvFrom;
private TextView tvSize; private TextView tvSize;
private TextView tvTime; private TextView tvTime;
private ImageView ivType; private ImageView ivType;
private ImageView ibSnoozed; private ImageButton ibSnoozed;
private ImageView ivAnswered; private ImageView ivAnswered;
private ImageView ivAttachments; private ImageView ivAttachments;
private TextView tvSubject; private TextView tvSubject;
@ -377,7 +377,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
vwColor = itemView.findViewById(R.id.vwColor); vwColor = itemView.findViewById(R.id.vwColor);
ibExpander = itemView.findViewById(R.id.ibExpander); ibExpander = itemView.findViewById(R.id.ibExpander);
ibFlagged = itemView.findViewById(R.id.ibFlagged); ibFlagged = itemView.findViewById(R.id.ibFlagged);
ivAvatar = itemView.findViewById(R.id.ivAvatar); ibAvatar = itemView.findViewById(R.id.ibAvatar);
ibAuth = itemView.findViewById(R.id.ibAuth); ibAuth = itemView.findViewById(R.id.ibAuth);
ivPriorityHigh = itemView.findViewById(R.id.ivPriorityHigh); ivPriorityHigh = itemView.findViewById(R.id.ivPriorityHigh);
ivPriorityLow = itemView.findViewById(R.id.ivPriorityLow); ivPriorityLow = itemView.findViewById(R.id.ivPriorityLow);
@ -546,6 +546,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}); });
view.setOnKeyListener(this); view.setOnKeyListener(this);
ibAvatar.setOnClickListener(this);
ibAuth.setOnClickListener(this); ibAuth.setOnClickListener(this);
ibSnoozed.setOnClickListener(this); ibSnoozed.setOnClickListener(this);
ibFlagged.setOnClickListener(this); ibFlagged.setOnClickListener(this);
@ -601,6 +602,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
touch.setOnClickListener(null); touch.setOnClickListener(null);
view.setOnKeyListener(null); view.setOnKeyListener(null);
ibAvatar.setOnClickListener(null);
ibAuth.setOnClickListener(null); ibAuth.setOnClickListener(null);
ibSnoozed.setOnClickListener(null); ibSnoozed.setOnClickListener(null);
ibFlagged.setOnClickListener(null); ibFlagged.setOnClickListener(null);
@ -640,7 +642,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
vwColor.setVisibility(View.GONE); vwColor.setVisibility(View.GONE);
ibExpander.setVisibility(View.GONE); ibExpander.setVisibility(View.GONE);
ibFlagged.setVisibility(View.GONE); ibFlagged.setVisibility(View.GONE);
ivAvatar.setVisibility(View.GONE); ibAvatar.setVisibility(View.GONE);
ibAuth.setVisibility(View.GONE); ibAuth.setVisibility(View.GONE);
ivPriorityHigh.setVisibility(View.GONE); ivPriorityHigh.setVisibility(View.GONE);
ivPriorityLow.setVisibility(View.GONE); ivPriorityLow.setVisibility(View.GONE);
@ -687,11 +689,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
textSize * (message.unseen > 0 ? 1.1f : 1f) + textSize * (message.unseen > 0 ? 1.1f : 1f) +
textSize * 0.9f + textSize * 0.9f +
(compact ? 0 : textSize * 0.9f)); (compact ? 0 : textSize * 0.9f));
ViewGroup.LayoutParams lparams = ivAvatar.getLayoutParams(); ViewGroup.LayoutParams lparams = ibAvatar.getLayoutParams();
if (lparams.height != px) { if (lparams.height != px) {
lparams.width = px; lparams.width = px;
lparams.height = px; lparams.height = px;
ivAvatar.requestLayout(); ibAvatar.requestLayout();
} }
} }
@ -707,7 +709,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (viewType == ViewType.THREAD) { if (viewType == ViewType.THREAD) {
boolean dim = (message.duplicate || EntityFolder.TRASH.equals(message.folderType)); boolean dim = (message.duplicate || EntityFolder.TRASH.equals(message.folderType));
ibFlagged.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f); ibFlagged.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivAvatar.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f); ibAvatar.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ibAuth.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f); ibAuth.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivPriorityHigh.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f); ivPriorityHigh.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
ivPriorityLow.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f); ivPriorityLow.setAlpha(dim ? Helper.LOW_LIGHT : 1.0f);
@ -769,7 +771,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibExpander.setVisibility(View.GONE); ibExpander.setVisibility(View.GONE);
// Photo // Photo
ivAvatar.setVisibility(avatars ? View.INVISIBLE : View.GONE); ibAvatar.setVisibility(avatars ? View.INVISIBLE : View.GONE);
// Line 1 // Line 1
ibAuth.setVisibility(authentication && !authenticated ? View.VISIBLE : View.GONE); ibAuth.setVisibility(authentication && !authenticated ? View.VISIBLE : View.GONE);
@ -1016,10 +1018,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private void bindContactInfo(ContactInfo info, TupleMessageEx message) { private void bindContactInfo(ContactInfo info, TupleMessageEx message) {
if (info.hasPhoto()) { if (info.hasPhoto()) {
ivAvatar.setImageBitmap(info.getPhotoBitmap()); ibAvatar.setImageBitmap(info.getPhotoBitmap());
ivAvatar.setVisibility(View.VISIBLE); ibAvatar.setVisibility(View.VISIBLE);
} else } else
ivAvatar.setVisibility(View.GONE); ibAvatar.setVisibility(View.GONE);
Uri lookupUri = info.getLookupUri();
ibAvatar.setTag(lookupUri);
ibAvatar.setEnabled(lookupUri != null);
if (distinguish_contacts && info.isKnown()) if (distinguish_contacts && info.isKnown())
tvFrom.setPaintFlags(tvFrom.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); tvFrom.setPaintFlags(tvFrom.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
@ -1923,7 +1929,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (message == null) if (message == null)
return; return;
if (view.getId() == R.id.ibAuth) if (view.getId() == R.id.ibAvatar)
onViewContact(message);
else if (view.getId() == R.id.ibAuth)
onShowAuth(message); onShowAuth(message);
else if (view.getId() == R.id.ibSnoozed) else if (view.getId() == R.id.ibSnoozed)
onShowSnoozed(message); onShowSnoozed(message);
@ -2136,6 +2144,15 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
return false; return false;
} }
private void onViewContact(TupleMessageEx message) {
Uri lookupUri = (Uri) ibAvatar.getTag();
if (lookupUri != null) {
Intent intent = new Intent(Intent.ACTION_VIEW, lookupUri);
if (intent.resolveActivity(context.getPackageManager()) != null)
context.startActivity(intent);
}
}
private void onShowAuth(TupleMessageEx message) { private void onShowAuth(TupleMessageEx message) {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
if (Boolean.FALSE.equals(message.dkim)) if (Boolean.FALSE.equals(message.dkim))

@ -44,12 +44,14 @@
app:layout_constraintStart_toEndOf="@+id/ibExpander" app:layout_constraintStart_toEndOf="@+id/ibExpander"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageButton
android:id="@+id/ivAvatar" android:id="@+id/ibAvatar"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_legend_avatar" android:contentDescription="@string/title_legend_avatar"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="@+id/tvFolder" app:layout_constraintBottom_toBottomOf="@+id/tvFolder"
app:layout_constraintDimensionRatio="1:1" app:layout_constraintDimensionRatio="1:1"
app:layout_constraintStart_toEndOf="@id/paddingStart" app:layout_constraintStart_toEndOf="@id/paddingStart"
@ -65,7 +67,7 @@
android:contentDescription="@string/title_legend_auth" android:contentDescription="@string/title_legend_auth"
android:tint="@color/colorError" android:tint="@color/colorError"
app:layout_constraintBottom_toBottomOf="@+id/tvFrom" app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintStart_toEndOf="@id/ivAvatar" app:layout_constraintStart_toEndOf="@id/ibAvatar"
app:layout_constraintTop_toTopOf="@+id/tvFrom" app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/baseline_flag_24" /> app:srcCompat="@drawable/baseline_flag_24" />
@ -141,7 +143,7 @@
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:contentDescription="@string/title_legend_folder_type" android:contentDescription="@string/title_legend_folder_type"
app:layout_constraintBottom_toBottomOf="@+id/tvSubject" app:layout_constraintBottom_toBottomOf="@+id/tvSubject"
app:layout_constraintStart_toEndOf="@id/ivAvatar" app:layout_constraintStart_toEndOf="@id/ibAvatar"
app:layout_constraintTop_toTopOf="@+id/tvSubject" app:layout_constraintTop_toTopOf="@+id/tvSubject"
app:srcCompat="@drawable/baseline_edit_24" /> app:srcCompat="@drawable/baseline_edit_24" />
@ -246,7 +248,7 @@
android:text="Folder" android:text="Folder"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toStartOf="@+id/ibFlagged" app:layout_constraintEnd_toStartOf="@+id/ibFlagged"
app:layout_constraintStart_toEndOf="@id/ivAvatar" app:layout_constraintStart_toEndOf="@id/ibAvatar"
app:layout_constraintTop_toBottomOf="@id/tvSubject" /> app:layout_constraintTop_toBottomOf="@id/tvSubject" />
<TextView <TextView

@ -42,13 +42,15 @@
app:layout_constraintStart_toEndOf="@+id/ibExpander" app:layout_constraintStart_toEndOf="@+id/ibExpander"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageButton
android:id="@+id/ivAvatar" android:id="@+id/ibAvatar"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_legend_avatar" android:contentDescription="@string/title_legend_avatar"
android:paddingStart="6dp" android:paddingStart="6dp"
android:paddingEnd="6dp" android:paddingEnd="6dp"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="@+id/tvFolder" app:layout_constraintBottom_toBottomOf="@+id/tvFolder"
app:layout_constraintDimensionRatio="1:1" app:layout_constraintDimensionRatio="1:1"
app:layout_constraintStart_toEndOf="@id/paddingStart" app:layout_constraintStart_toEndOf="@id/paddingStart"
@ -64,7 +66,7 @@
android:contentDescription="@string/title_legend_auth" android:contentDescription="@string/title_legend_auth"
android:tint="@color/colorError" android:tint="@color/colorError"
app:layout_constraintBottom_toBottomOf="@+id/tvFrom" app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintStart_toEndOf="@id/ivAvatar" app:layout_constraintStart_toEndOf="@id/ibAvatar"
app:layout_constraintTop_toTopOf="@+id/tvFrom" app:layout_constraintTop_toTopOf="@+id/tvFrom"
app:srcCompat="@drawable/baseline_flag_24" /> app:srcCompat="@drawable/baseline_flag_24" />
@ -143,7 +145,7 @@
android:text="Subject" android:text="Subject"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toStartOf="@+id/ibFlagged" app:layout_constraintEnd_toStartOf="@+id/ibFlagged"
app:layout_constraintStart_toEndOf="@id/ivAvatar" app:layout_constraintStart_toEndOf="@id/ibAvatar"
app:layout_constraintTop_toBottomOf="@id/tvFrom" /> app:layout_constraintTop_toBottomOf="@id/tvFrom" />
<ImageButton <ImageButton
@ -166,7 +168,7 @@
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:contentDescription="@string/title_legend_folder_type" android:contentDescription="@string/title_legend_folder_type"
app:layout_constraintBottom_toBottomOf="@+id/tvFolder" app:layout_constraintBottom_toBottomOf="@+id/tvFolder"
app:layout_constraintStart_toEndOf="@id/ivAvatar" app:layout_constraintStart_toEndOf="@id/ibAvatar"
app:layout_constraintTop_toTopOf="@+id/tvFolder" app:layout_constraintTop_toTopOf="@+id/tvFolder"
app:srcCompat="@drawable/baseline_edit_24" /> app:srcCompat="@drawable/baseline_edit_24" />

Loading…
Cancel
Save