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

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

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

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

Loading…
Cancel
Save