1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-24 16:53:37 +00:00

Added optional seen/unseen icon button

This commit is contained in:
M66B 2020-08-20 09:34:08 +02:00
parent c89143ff02
commit e1d32d9535
4 changed files with 48 additions and 17 deletions

View file

@ -420,6 +420,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private ImageButton ibUnsubscribe;
private ImageButton ibPrint;
private ImageButton ibEvent;
private ImageButton ibSeen;
private ImageButton ibAnswer;
private ImageButton ibLabels;
private ImageButton ibCopy;
@ -441,7 +442,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private Group grpDownloading;
private ImageButton ibTrashBottom;
private ImageButton ibArchiveBottom;
private ImageButton ibSeen;
private ImageButton ibSeenBottom;
private Flow flow;
private ImageButton ibCalendar;
@ -629,6 +630,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibUnsubscribe = vsBody.findViewById(R.id.ibUnsubscribe);
ibPrint = vsBody.findViewById(R.id.ibPrint);
ibEvent = vsBody.findViewById(R.id.ibEvent);
ibSeen = vsBody.findViewById(R.id.ibSeen);
ibAnswer = vsBody.findViewById(R.id.ibAnswer);
ibLabels = vsBody.findViewById(R.id.ibLabels);
ibCopy = vsBody.findViewById(R.id.ibCopy);
@ -650,7 +652,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
grpDownloading = vsBody.findViewById(R.id.grpDownloading);
ibTrashBottom = vsBody.findViewById(R.id.ibTrashBottom);
ibArchiveBottom = vsBody.findViewById(R.id.ibArchiveBottom);
ibSeen = vsBody.findViewById(R.id.ibSeen);
ibSeenBottom = vsBody.findViewById(R.id.ibSeenBottom);
flow = vsBody.findViewById(R.id.flow);
rvImage = vsBody.findViewById(R.id.rvImage);
@ -724,6 +726,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibUnsubscribe.setOnClickListener(this);
ibPrint.setOnClickListener(this);
ibEvent.setOnClickListener(this);
ibSeen.setOnClickListener(this);
ibAnswer.setOnClickListener(this);
ibLabels.setOnClickListener(this);
ibCopy.setOnClickListener(this);
@ -738,7 +741,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibDownloading.setOnClickListener(this);
ibTrashBottom.setOnClickListener(this);
ibArchiveBottom.setOnClickListener(this);
ibSeen.setOnClickListener(this);
ibSeenBottom.setOnClickListener(this);
tvBody.setOnTouchListener(this);
tvBody.addOnLayoutChangeListener(this);
@ -815,6 +818,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibUnsubscribe.setOnClickListener(null);
ibPrint.setOnClickListener(null);
ibEvent.setOnClickListener(null);
ibSeen.setOnClickListener(null);
ibAnswer.setOnClickListener(null);
ibLabels.setOnClickListener(null);
ibCopy.setOnClickListener(null);
@ -829,7 +833,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibDownloading.setOnClickListener(null);
ibTrashBottom.setOnClickListener(null);
ibArchiveBottom.setOnClickListener(null);
ibSeen.setOnClickListener(null);
ibSeenBottom.setOnClickListener(null);
tvBody.setOnTouchListener(null);
tvBody.removeOnLayoutChangeListener(this);
@ -1292,6 +1296,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibUnsubscribe.setVisibility(View.GONE);
ibPrint.setVisibility(View.GONE);
ibEvent.setVisibility(View.GONE);
ibSeen.setVisibility(View.GONE);
ibAnswer.setVisibility(View.GONE);
ibLabels.setVisibility(View.GONE);
ibCopy.setVisibility(View.GONE);
@ -1316,7 +1321,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
clearActions();
ibTrashBottom.setVisibility(View.GONE);
ibArchiveBottom.setVisibility(View.GONE);
ibSeen.setVisibility(View.GONE);
ibSeenBottom.setVisibility(View.GONE);
}
private void clearActions() {
@ -1427,6 +1432,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibUnsubscribe.setVisibility(View.GONE);
ibPrint.setVisibility(View.GONE);
ibEvent.setVisibility(View.GONE);
ibSeen.setVisibility(View.GONE);
ibAnswer.setVisibility(View.GONE);
ibLabels.setVisibility(View.GONE);
ibCopy.setVisibility(View.GONE);
@ -1463,7 +1469,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
clearActions();
ibTrashBottom.setVisibility(View.GONE);
ibArchiveBottom.setVisibility(View.GONE);
ibSeen.setVisibility(View.GONE);
ibSeenBottom.setVisibility(View.GONE);
db.attachment().liveAttachments(message.id).observe(cowner, new Observer<List<EntityAttachment>>() {
@Override
@ -1559,6 +1565,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean junk = (move && (hasJunk && !inJunk));
boolean inbox = (move && (inArchive || inTrash || inJunk));
boolean labels = (gmail && move && !inTrash && !inJunk && !outbox);
boolean seen = (!(message.folderReadOnly || message.uid == null) ||
message.accountProtocol == EntityAccount.TYPE_POP);
final boolean delete = (inTrash || !hasTrash || inJunk || outbox ||
message.uid == null || message.accountProtocol == EntityAccount.TYPE_POP);
@ -1572,11 +1580,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean button_archive = prefs.getBoolean("button_archive", true);
boolean button_move = prefs.getBoolean("button_move", true);
boolean button_copy = prefs.getBoolean("button_copy", false);
boolean button_seen = prefs.getBoolean("button_seen", false);
boolean button_event = prefs.getBoolean("button_event", false);
boolean button_print = prefs.getBoolean("button_print", false);
boolean button_unsubscribe = prefs.getBoolean("button_unsubscribe", true);
boolean button_rule = prefs.getBoolean("button_rule", false);
ibSeen.setImageResource(message.ui_seen ? R.drawable.baseline_visibility_off_24 : R.drawable.baseline_visibility_24);
ibTrash.setTag(delete);
ibUndo.setVisibility(outbox ? View.VISIBLE : View.GONE);
@ -1584,6 +1594,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibUnsubscribe.setVisibility(tools && button_unsubscribe && message.unsubscribe != null ? View.VISIBLE : View.GONE);
ibPrint.setVisibility(tools && button_print && hasWebView && message.content && Helper.canPrint(context) ? View.VISIBLE : View.GONE);
ibEvent.setVisibility(tools && button_event && message.content ? View.VISIBLE : View.GONE);
ibSeen.setVisibility(tools && button_seen && !outbox && seen ? View.VISIBLE : View.GONE);
ibAnswer.setVisibility(!tools || outbox || (!expand_all && expand_one) ? View.GONE : View.VISIBLE);
ibLabels.setVisibility(tools && labels_header && labels ? View.VISIBLE : View.GONE);
ibCopy.setVisibility(tools && button_copy && move ? View.VISIBLE : View.GONE);
@ -1772,15 +1783,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvBody.setText(null);
clearActions();
ibSeen.setImageResource(message.ui_seen
ibSeenBottom.setImageResource(message.ui_seen
? R.drawable.baseline_visibility_off_24 : R.drawable.baseline_visibility_24);
ibSeen.setContentDescription(context.getString(message.ui_seen
? R.string.title_unseen : R.string.title_seen));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
ibSeen.setTooltipText(context.getString(message.ui_seen
? R.string.title_unseen : R.string.title_seen));
ibSeen.setVisibility(message.folderReadOnly || message.uid == null
? View.GONE : View.VISIBLE);
ibSeenBottom.setVisibility(!(message.folderReadOnly || message.uid == null) ||
message.accountProtocol == EntityAccount.TYPE_POP
? View.VISIBLE : View.GONE);
if (!message.content) {
if (scroll)
@ -2884,7 +2891,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
case R.id.ibDownloading:
Helper.viewFAQ(context, 15);
break;
case R.id.ibSeen:
case R.id.ibSeenBottom:
onMenuUnseen(message);
break;
@ -3773,6 +3782,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean button_archive = prefs.getBoolean("button_archive", true);
boolean button_move = prefs.getBoolean("button_move", true);
boolean button_copy = prefs.getBoolean("button_copy", false);
boolean button_seen = prefs.getBoolean("button_seen", false);
boolean button_event = prefs.getBoolean("button_event", false);
boolean button_print = prefs.getBoolean("button_print", false);
boolean button_unsubscribe = prefs.getBoolean("button_unsubscribe", true);
@ -3786,6 +3796,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
popupMenu.getMenu().findItem(R.id.menu_button_archive).setChecked(button_archive);
popupMenu.getMenu().findItem(R.id.menu_button_move).setChecked(button_move);
popupMenu.getMenu().findItem(R.id.menu_button_copy).setChecked(button_copy);
popupMenu.getMenu().findItem(R.id.menu_button_seen).setChecked(button_seen);
popupMenu.getMenu().findItem(R.id.menu_button_event).setChecked(button_event);
popupMenu.getMenu().findItem(R.id.menu_button_print).setChecked(button_print);
popupMenu.getMenu().findItem(R.id.menu_button_unsubscribe).setChecked(button_unsubscribe);
@ -3858,6 +3869,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
case R.id.menu_button_copy:
onMenuButton(message, "copy", target.isChecked());
return true;
case R.id.menu_button_seen:
onMenuButton(message, "seen", target.isChecked());
return true;
case R.id.menu_button_event:
onMenuButton(message, "event", target.isChecked());
return true;

View file

@ -140,7 +140,7 @@
app:srcCompat="@drawable/baseline_archive_24" />
<ImageButton
android:id="@+id/ibSeen"
android:id="@+id/ibSeenBottom"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
@ -148,6 +148,7 @@
android:padding="6dp"
android:scaleType="fitCenter"
android:tint="?attr/colorSeparator"
android:tooltipText="@string/title_seen"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/wvBody"
app:srcCompat="@drawable/baseline_visibility_24" />
@ -159,7 +160,7 @@
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ibSeen" />
app:layout_constraintTop_toBottomOf="@id/ibSeenBottom" />
<include
android:id="@+id/InCalendar"

View file

@ -41,7 +41,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="3dp"
app:constraint_referenced_ids="ibMore,ibInbox,ibJunk,ibTrash,ibArchive,ibMove,ibCopy,ibLabels,ibAnswer,ibEvent,ibPrint,ibUnsubscribe,ibRule,ibUndo"
app:constraint_referenced_ids="ibMore,ibInbox,ibJunk,ibTrash,ibArchive,ibMove,ibCopy,ibLabels,ibAnswer,ibSeen,ibEvent,ibPrint,ibUnsubscribe,ibRule,ibUndo"
app:flow_horizontalBias="0"
app:flow_horizontalGap="3dp"
app:flow_horizontalStyle="packed"
@ -156,6 +156,18 @@
app:srcCompat="@drawable/baseline_reply_24"
tools:ignore="MissingConstraints" />
<ImageButton
android:id="@+id/ibSeen"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_seen"
android:padding="6dp"
android:scaleType="fitCenter"
android:tooltipText="@string/title_seen"
app:srcCompat="@drawable/baseline_visibility_24"
tools:ignore="MissingConstraints" />
<ImageButton
android:id="@+id/ibEvent"
android:layout_width="36dp"

View file

@ -24,6 +24,10 @@
android:id="@+id/menu_button_copy"
android:checkable="true"
android:title="@string/title_copy_btn" />
<item
android:id="@+id/menu_button_seen"
android:checkable="true"
android:title="@string/title_unseen" />
<item
android:id="@+id/menu_button_event"
android:checkable="true"