Replace ImageViews by ImageButtons

pull/156/head
M66B 5 years ago
parent 39808f4195
commit 5c02f1453e

@ -31,6 +31,7 @@ import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
@ -63,46 +64,46 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
private List<EntityAttachment> items = new ArrayList<>(); private List<EntityAttachment> items = new ArrayList<>();
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
View view; private View view;
ImageView ivDelete; private ImageButton ibDelete;
TextView tvName; private TextView tvName;
TextView tvType; private TextView tvType;
TextView tvSize; private TextView tvSize;
ImageView ivStatus; private ImageView ivStatus;
ImageView ivSave; private ImageButton ibSave;
TextView tvDebug; private TextView tvDebug;
ProgressBar progressbar; private ProgressBar progressbar;
ViewHolder(View itemView) { ViewHolder(View itemView) {
super(itemView); super(itemView);
view = itemView.findViewById(R.id.clItem); view = itemView.findViewById(R.id.clItem);
ivDelete = itemView.findViewById(R.id.ivDelete); ibDelete = itemView.findViewById(R.id.ibDelete);
tvName = itemView.findViewById(R.id.tvName); tvName = itemView.findViewById(R.id.tvName);
tvType = itemView.findViewById(R.id.tvType); tvType = itemView.findViewById(R.id.tvType);
tvSize = itemView.findViewById(R.id.tvSize); tvSize = itemView.findViewById(R.id.tvSize);
ivStatus = itemView.findViewById(R.id.ivStatus); ivStatus = itemView.findViewById(R.id.ivStatus);
ivSave = itemView.findViewById(R.id.ivSave); ibSave = itemView.findViewById(R.id.ibSave);
tvDebug = itemView.findViewById(R.id.tvDebug); tvDebug = itemView.findViewById(R.id.tvDebug);
progressbar = itemView.findViewById(R.id.progressbar); progressbar = itemView.findViewById(R.id.progressbar);
} }
private void wire() { private void wire() {
view.setOnClickListener(this); view.setOnClickListener(this);
ivDelete.setOnClickListener(this); ibDelete.setOnClickListener(this);
ivSave.setOnClickListener(this); ibSave.setOnClickListener(this);
} }
private void unwire() { private void unwire() {
view.setOnClickListener(null); view.setOnClickListener(null);
ivDelete.setOnClickListener(null); ibDelete.setOnClickListener(null);
ivSave.setOnClickListener(null); ibSave.setOnClickListener(null);
} }
private void bindTo(EntityAttachment attachment) { private void bindTo(EntityAttachment attachment) {
view.setAlpha(attachment.isInline() ? Helper.LOW_LIGHT : 1.0f); view.setAlpha(attachment.isInline() ? Helper.LOW_LIGHT : 1.0f);
ivDelete.setVisibility(readonly ? View.GONE : attachment.isInline() ? View.INVISIBLE : View.VISIBLE); ibDelete.setVisibility(readonly ? View.GONE : attachment.isInline() ? View.INVISIBLE : View.VISIBLE);
tvName.setText(attachment.name); tvName.setText(attachment.name);
tvType.setText(attachment.type); tvType.setText(attachment.type);
tvType.setVisibility(debug || BuildConfig.DEBUG ? View.VISIBLE : View.GONE); tvType.setVisibility(debug || BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
@ -122,7 +123,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
ivStatus.setVisibility(View.GONE); ivStatus.setVisibility(View.GONE);
} }
ivSave.setVisibility(readonly && attachment.available ? View.VISIBLE : View.GONE); ibSave.setVisibility(readonly && attachment.available ? View.VISIBLE : View.GONE);
if (attachment.progress != null) if (attachment.progress != null)
progressbar.setProgress(attachment.progress); progressbar.setProgress(attachment.progress);
@ -146,9 +147,9 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
return; return;
final EntityAttachment attachment = items.get(pos); final EntityAttachment attachment = items.get(pos);
if (view.getId() == R.id.ivDelete) if (view.getId() == R.id.ibDelete)
onDelete(attachment); onDelete(attachment);
else if (view.getId() == R.id.ivSave) else if (view.getId() == R.id.ibSave)
onSave(attachment); onSave(attachment);
else { else {
if (attachment.available) if (attachment.available)

@ -209,9 +209,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private ImageView ivExpanderAddress; private ImageView ivExpanderAddress;
private ImageView ivSearchContact; private ImageButton ibSearchContact;
private ImageView ivNotifyContact; private ImageButton ibNotifyContact;
private ImageView ivAddContact; private ImageButton ibAddContact;
private TextView tvFromExTitle; private TextView tvFromExTitle;
private TextView tvToTitle; private TextView tvToTitle;
@ -297,9 +297,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivExpanderAddress = itemView.findViewById(R.id.ivExpanderAddress); ivExpanderAddress = itemView.findViewById(R.id.ivExpanderAddress);
ivSearchContact = itemView.findViewById(R.id.ivSearchContact); ibSearchContact = itemView.findViewById(R.id.ibSearchContact);
ivNotifyContact = itemView.findViewById(R.id.ivNotifyContact); ibNotifyContact = itemView.findViewById(R.id.ibNotifyContact);
ivAddContact = itemView.findViewById(R.id.ivAddContact); ibAddContact = itemView.findViewById(R.id.ibAddContact);
tvFromExTitle = itemView.findViewById(R.id.tvFromExTitle); tvFromExTitle = itemView.findViewById(R.id.tvFromExTitle);
tvToTitle = itemView.findViewById(R.id.tvToTitle); tvToTitle = itemView.findViewById(R.id.tvToTitle);
@ -391,10 +391,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivFlagged.setOnClickListener(this); ivFlagged.setOnClickListener(this);
ivExpanderAddress.setOnClickListener(this); ivExpanderAddress.setOnClickListener(this);
ivSearchContact.setOnClickListener(this); ibSearchContact.setOnClickListener(this);
ivNotifyContact.setOnClickListener(this); ibNotifyContact.setOnClickListener(this);
ivNotifyContact.setOnLongClickListener(this); ibNotifyContact.setOnLongClickListener(this);
ivAddContact.setOnClickListener(this); ibAddContact.setOnClickListener(this);
btnDownloadAttachments.setOnClickListener(this); btnDownloadAttachments.setOnClickListener(this);
btnSaveAttachments.setOnClickListener(this); btnSaveAttachments.setOnClickListener(this);
@ -415,10 +415,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivSnoozed.setOnClickListener(null); ivSnoozed.setOnClickListener(null);
ivFlagged.setOnClickListener(null); ivFlagged.setOnClickListener(null);
ivExpanderAddress.setOnClickListener(null); ivExpanderAddress.setOnClickListener(null);
ivSearchContact.setOnClickListener(null); ibSearchContact.setOnClickListener(null);
ivNotifyContact.setOnClickListener(null); ibNotifyContact.setOnClickListener(null);
ivNotifyContact.setOnLongClickListener(null); ibNotifyContact.setOnLongClickListener(null);
ivAddContact.setOnClickListener(null); ibAddContact.setOnClickListener(null);
btnDownloadAttachments.setOnClickListener(null); btnDownloadAttachments.setOnClickListener(null);
btnSaveAttachments.setOnClickListener(null); btnSaveAttachments.setOnClickListener(null);
tbHtml.setOnCheckedChangeListener(null); tbHtml.setOnCheckedChangeListener(null);
@ -690,9 +690,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
grpAttachments.setVisibility(View.GONE); grpAttachments.setVisibility(View.GONE);
grpExpanded.setVisibility(View.GONE); grpExpanded.setVisibility(View.GONE);
ivSearchContact.setVisibility(View.GONE); ibSearchContact.setVisibility(View.GONE);
ivNotifyContact.setVisibility(View.GONE); ibNotifyContact.setVisibility(View.GONE);
ivAddContact.setVisibility(View.GONE); ibAddContact.setVisibility(View.GONE);
tvFromExTitle.setVisibility(View.GONE); tvFromExTitle.setVisibility(View.GONE);
tvToTitle.setVisibility(View.GONE); tvToTitle.setVisibility(View.GONE);
@ -761,9 +761,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean hasFrom = (message.from != null && message.from.length > 0); boolean hasFrom = (message.from != null && message.from.length > 0);
boolean hasChannel = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O); boolean hasChannel = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O);
ivSearchContact.setVisibility(show_addresses && search && BuildConfig.DEBUG ? View.VISIBLE : View.GONE); ibSearchContact.setVisibility(show_addresses && search && BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
ivNotifyContact.setVisibility(show_addresses && hasChannel && hasFrom ? View.VISIBLE : View.GONE); ibNotifyContact.setVisibility(show_addresses && hasChannel && hasFrom ? View.VISIBLE : View.GONE);
ivAddContact.setVisibility(show_addresses && contacts && hasFrom ? View.VISIBLE : View.GONE); ibAddContact.setVisibility(show_addresses && contacts && hasFrom ? View.VISIBLE : View.GONE);
grpHeaders.setVisibility(show_headers ? View.VISIBLE : View.GONE); grpHeaders.setVisibility(show_headers ? View.VISIBLE : View.GONE);
if (show_headers && message.headers == null) { if (show_headers && message.headers == null) {
@ -1055,11 +1055,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
onShowSnoozed(message); onShowSnoozed(message);
else if (view.getId() == R.id.ivFlagged) else if (view.getId() == R.id.ivFlagged)
onToggleFlag(message); onToggleFlag(message);
else if (view.getId() == R.id.ivSearchContact) else if (view.getId() == R.id.ibSearchContact)
onSearchContact(message); onSearchContact(message);
else if (view.getId() == R.id.ivNotifyContact) else if (view.getId() == R.id.ibNotifyContact)
onNotifyContact(message); onNotifyContact(message);
else if (view.getId() == R.id.ivAddContact) else if (view.getId() == R.id.ibAddContact)
onAddContact(message); onAddContact(message);
else if (viewType == ViewType.THREAD) { else if (viewType == ViewType.THREAD) {
if (view.getId() == R.id.ivExpanderAddress) if (view.getId() == R.id.ivExpanderAddress)

@ -4,32 +4,32 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<ImageView <ImageButton
android:id="@+id/ivSearchContact" android:id="@+id/ibSearchContact"
android:layout_width="21dp" android:layout_width="wrap_content"
android:layout_height="21dp" android:layout_height="wrap_content"
android:layout_marginEnd="12dp" android:layout_marginEnd="12dp"
android:background="?android:attr/selectableItemBackgroundBorderless" android:background="@null"
android:src="@drawable/baseline_search_24" android:src="@drawable/baseline_search_24"
app:layout_constraintEnd_toStartOf="@+id/ivNotifyContact" app:layout_constraintEnd_toStartOf="@+id/ibNotifyContact"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageButton
android:id="@+id/ivNotifyContact" android:id="@+id/ibNotifyContact"
android:layout_width="21dp" android:layout_width="wrap_content"
android:layout_height="21dp" android:layout_height="wrap_content"
android:layout_marginEnd="12dp" android:layout_marginEnd="12dp"
android:background="?android:attr/selectableItemBackgroundBorderless" android:background="@null"
android:contentDescription="@string/title_legend_notify" android:contentDescription="@string/title_legend_notify"
android:src="@drawable/baseline_notifications_24" android:src="@drawable/baseline_notifications_24"
app:layout_constraintEnd_toStartOf="@+id/ivAddContact" app:layout_constraintEnd_toStartOf="@+id/ibAddContact"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageButton
android:id="@+id/ivAddContact" android:id="@+id/ibAddContact"
android:layout_width="21dp" android:layout_width="wrap_content"
android:layout_height="21dp" android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackgroundBorderless" android:background="@null"
android:contentDescription="@string/title_legend_contacts" android:contentDescription="@string/title_legend_contacts"
android:src="@drawable/baseline_import_contacts_24" android:src="@drawable/baseline_import_contacts_24"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
@ -40,7 +40,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:barrierDirection="bottom" app:barrierDirection="bottom"
app:constraint_referenced_ids="ivSearchContact,ivNotifyContact,ivAddContact" /> app:constraint_referenced_ids="ibSearchContact,ibNotifyContact,ibAddContact" />
<TextView <TextView
android:id="@+id/tvFromExTitle" android:id="@+id/tvFromExTitle"

@ -13,10 +13,11 @@
android:paddingTop="6dp" android:paddingTop="6dp"
android:paddingBottom="6dp"> android:paddingBottom="6dp">
<ImageView <ImageButton
android:id="@+id/ivDelete" android:id="@+id/ibDelete"
android:layout_width="36dp" android:layout_width="wrap_content"
android:layout_height="24dp" android:layout_height="0dp"
android:background="@null"
android:contentDescription="@string/title_legend_delete" android:contentDescription="@string/title_legend_delete"
android:paddingEnd="12dp" android:paddingEnd="12dp"
android:src="@drawable/baseline_delete_24" android:src="@drawable/baseline_delete_24"
@ -30,7 +31,7 @@
android:layout_height="24dp" android:layout_height="24dp"
android:contentDescription="@string/title_legend_attachment" android:contentDescription="@string/title_legend_attachment"
android:src="@drawable/baseline_attachment_24" android:src="@drawable/baseline_attachment_24"
app:layout_constraintStart_toEndOf="@id/ivDelete" app:layout_constraintStart_toEndOf="@id/ibDelete"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
@ -83,14 +84,15 @@
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:contentDescription="@string/title_legend_download_state" android:contentDescription="@string/title_legend_download_state"
android:src="@drawable/baseline_cloud_download_24" android:src="@drawable/baseline_cloud_download_24"
app:layout_constraintEnd_toStartOf="@+id/ivSave" app:layout_constraintEnd_toStartOf="@+id/ibSave"
app:layout_constraintStart_toEndOf="@id/tvSize" app:layout_constraintStart_toEndOf="@id/tvSize"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageButton
android:id="@+id/ivSave" android:id="@+id/ibSave"
android:layout_width="36dp" android:layout_width="wrap_content"
android:layout_height="24dp" android:layout_height="0dp"
android:background="@null"
android:contentDescription="@string/title_legend_save" android:contentDescription="@string/title_legend_save"
android:paddingStart="12dp" android:paddingStart="12dp"
android:src="@drawable/baseline_save_24" android:src="@drawable/baseline_save_24"

Loading…
Cancel
Save