Added quick seen

pull/207/head
M66B 3 years ago
parent 25babe4f41
commit 0c40bacbd1

@ -291,6 +291,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private FloatingActionButton fabMore; private FloatingActionButton fabMore;
private TextView tvSelectedCount; private TextView tvSelectedCount;
private CardView cardMore; private CardView cardMore;
private ImageButton ibBatchSeen;
private ImageButton ibInbox; private ImageButton ibInbox;
private ImageButton ibArchive; private ImageButton ibArchive;
private ImageButton ibJunk; private ImageButton ibJunk;
@ -559,6 +560,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
fabMore = view.findViewById(R.id.fabMore); fabMore = view.findViewById(R.id.fabMore);
tvSelectedCount = view.findViewById(R.id.tvSelectedCount); tvSelectedCount = view.findViewById(R.id.tvSelectedCount);
cardMore = view.findViewById(R.id.cardMore); cardMore = view.findViewById(R.id.cardMore);
ibBatchSeen = view.findViewById(R.id.ibBatchSeen);
ibInbox = view.findViewById(R.id.ibInbox); ibInbox = view.findViewById(R.id.ibInbox);
ibArchive = view.findViewById(R.id.ibArchive); ibArchive = view.findViewById(R.id.ibArchive);
ibJunk = view.findViewById(R.id.ibJunk); ibJunk = view.findViewById(R.id.ibJunk);
@ -1288,6 +1290,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
} }
}); });
ibBatchSeen.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onActionSeenSelection(true, null, true);
}
});
ibInbox.setOnClickListener(new View.OnClickListener() { ibInbox.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -2596,7 +2605,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
adapter.notifyItemChanged(pos); adapter.notifyItemChanged(pos);
onSwipeAsk(message, viewHolder); onSwipeAsk(message, viewHolder);
} else if (EntityMessage.SWIPE_ACTION_SEEN.equals(action)) } else if (EntityMessage.SWIPE_ACTION_SEEN.equals(action))
onActionSeenSelection(!message.ui_seen, message.id); onActionSeenSelection(!message.ui_seen, message.id, false);
else if (EntityMessage.SWIPE_ACTION_FLAG.equals(action)) else if (EntityMessage.SWIPE_ACTION_FLAG.equals(action))
onActionFlagSelection(!message.ui_flagged, Color.TRANSPARENT, message.id); onActionFlagSelection(!message.ui_flagged, Color.TRANSPARENT, message.id);
else if (EntityMessage.SWIPE_ACTION_SNOOZE.equals(action)) else if (EntityMessage.SWIPE_ACTION_SNOOZE.equals(action))
@ -2683,10 +2692,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
public boolean onMenuItemClick(MenuItem target) { public boolean onMenuItemClick(MenuItem target) {
int itemId = target.getItemId(); int itemId = target.getItemId();
if (itemId == R.string.title_seen) { if (itemId == R.string.title_seen) {
onActionSeenSelection(true, message.id); onActionSeenSelection(true, message.id, false);
return true; return true;
} else if (itemId == R.string.title_unseen) { } else if (itemId == R.string.title_unseen) {
onActionSeenSelection(false, message.id); onActionSeenSelection(false, message.id, false);
return true; return true;
} else if (itemId == R.string.title_flag) { } else if (itemId == R.string.title_flag) {
onActionFlagSelection(true, Color.TRANSPARENT, message.id); onActionFlagSelection(true, Color.TRANSPARENT, message.id);
@ -3511,10 +3520,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
public boolean onMenuItemClick(MenuItem target) { public boolean onMenuItemClick(MenuItem target) {
int itemId = target.getItemId(); int itemId = target.getItemId();
if (itemId == R.string.title_seen) { if (itemId == R.string.title_seen) {
onActionSeenSelection(true, null); onActionSeenSelection(true, null, false);
return true; return true;
} else if (itemId == R.string.title_unseen) { } else if (itemId == R.string.title_unseen) {
onActionSeenSelection(false, null); onActionSeenSelection(false, null, false);
return true; return true;
} else if (itemId == R.string.title_snooze) { } else if (itemId == R.string.title_snooze) {
onActionSnoozeSelection(); onActionSnoozeSelection();
@ -3607,15 +3616,15 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return ids; return ids;
} }
private void onActionSeenSelection(boolean seen, Long id) { private void onActionSeenSelection(boolean seen, Long id, boolean clear) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLongArray("ids", id == null ? getSelection() : new long[]{id}); args.putLongArray("ids", id == null ? getSelection() : new long[]{id});
args.putBoolean("seen", seen); args.putBoolean("seen", seen);
args.putBoolean("threading", threading && args.putBoolean("threading", threading &&
(id == null || viewType != AdapterMessage.ViewType.THREAD)); (id == null || viewType != AdapterMessage.ViewType.THREAD));
//if (selectionTracker != null) if (clear && selectionTracker != null)
// selectionTracker.clearSelection(); selectionTracker.clearSelection();
new SimpleTask<Void>() { new SimpleTask<Void>() {
@Override @Override
@ -5875,11 +5884,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
protected Boolean[] onExecute(Context context, Bundle args) { protected Boolean[] onExecute(Context context, Bundle args) {
long[] ids = args.getLongArray("ids"); long[] ids = args.getLongArray("ids");
Boolean[] result = new Boolean[4]; Boolean[] result = new Boolean[5];
result[0] = false; result[0] = false;
result[1] = false; result[1] = false;
result[2] = false; result[2] = false;
result[3] = false; result[3] = false;
result[4] = false;
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
@ -5896,35 +5906,38 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (folder == null) if (folder == null)
continue; continue;
if (!result[0] && if (!result[0] && !message.ui_seen)
result[0] = true;
if (!result[1] &&
(EntityFolder.ARCHIVE.equals(folder.type) || (EntityFolder.ARCHIVE.equals(folder.type) ||
EntityFolder.JUNK.equals(folder.type) || EntityFolder.JUNK.equals(folder.type) ||
EntityFolder.TRASH.equals(folder.type))) { EntityFolder.TRASH.equals(folder.type))) {
EntityFolder inbox = db.folder().getFolderByType(message.account, EntityFolder.INBOX); EntityFolder inbox = db.folder().getFolderByType(message.account, EntityFolder.INBOX);
result[0] = (inbox != null && inbox.selectable); result[1] = (inbox != null && inbox.selectable);
} }
if (!result[1] && if (!result[2] &&
!EntityFolder.ARCHIVE.equals(folder.type)) { !EntityFolder.ARCHIVE.equals(folder.type)) {
EntityFolder archive = db.folder().getFolderByType(message.account, EntityFolder.ARCHIVE); EntityFolder archive = db.folder().getFolderByType(message.account, EntityFolder.ARCHIVE);
result[1] = (archive != null && archive.selectable); result[2] = (archive != null && archive.selectable);
} }
if (!result[2] && if (!result[3] &&
!EntityFolder.JUNK.equals(folder.type) && !EntityFolder.JUNK.equals(folder.type) &&
!EntityFolder.DRAFTS.equals(folder.type)) { !EntityFolder.DRAFTS.equals(folder.type)) {
EntityFolder junk = db.folder().getFolderByType(message.account, EntityFolder.JUNK); EntityFolder junk = db.folder().getFolderByType(message.account, EntityFolder.JUNK);
result[2] = (junk != null && junk.selectable); result[3] = (junk != null && junk.selectable);
} }
if (!result[3] && if (!result[4] &&
!EntityFolder.TRASH.equals(folder.type) && !EntityFolder.TRASH.equals(folder.type) &&
!EntityFolder.JUNK.equals(folder.type)) { !EntityFolder.JUNK.equals(folder.type)) {
EntityFolder trash = db.folder().getFolderByType(message.account, EntityFolder.TRASH); EntityFolder trash = db.folder().getFolderByType(message.account, EntityFolder.TRASH);
result[3] = (trash != null && trash.selectable); result[4] = (trash != null && trash.selectable);
} }
if (result[0] && result[1] && result[2] || result[3]) if (result[0] && result[1] && result[2] && result[3] && result[4])
break; break;
} }
@ -5933,12 +5946,13 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
@Override @Override
protected void onExecuted(Bundle args, Boolean[] result) { protected void onExecuted(Bundle args, Boolean[] result) {
ibInbox.setVisibility(result[0] ? View.VISIBLE : View.GONE); ibBatchSeen.setVisibility(result[0] ? View.VISIBLE : View.GONE);
ibArchive.setVisibility(result[1] ? View.VISIBLE : View.GONE); ibInbox.setVisibility(result[1] ? View.VISIBLE : View.GONE);
ibJunk.setVisibility(result[2] ? View.VISIBLE : View.GONE); ibArchive.setVisibility(result[2] ? View.VISIBLE : View.GONE);
ibTrash.setVisibility(result[3] ? View.VISIBLE : View.GONE); ibJunk.setVisibility(result[3] ? View.VISIBLE : View.GONE);
ibTrash.setVisibility(result[4] ? View.VISIBLE : View.GONE);
cardMore.setVisibility(fabMore.isOrWillBeShown() && cardMore.setVisibility(fabMore.isOrWillBeShown() &&
(result[0] || result[1] || result[2] || result[3]) (result[0] || result[1] || result[2] || result[3] || result[4])
? View.VISIBLE : View.GONE); ? View.VISIBLE : View.GONE);
} }

@ -516,6 +516,20 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingHorizontal="6dp"> android:paddingHorizontal="6dp">
<eu.faircode.email.FixedImageButton
android:id="@+id/ibBatchSeen"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_toggle_seen"
android:padding="6dp"
android:scaleType="fitCenter"
android:tint="@color/action_foreground"
android:tooltipText="@string/title_toggle_seen"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_drafts_24" />
<eu.faircode.email.FixedImageButton <eu.faircode.email.FixedImageButton
android:id="@+id/ibInbox" android:id="@+id/ibInbox"
android:layout_width="48dp" android:layout_width="48dp"
@ -526,7 +540,7 @@
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:tint="@color/action_foreground" android:tint="@color/action_foreground"
android:tooltipText="@string/title_folder_inbox" android:tooltipText="@string/title_folder_inbox"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toStartOf="@id/ibBatchSeen"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_inbox_24" /> app:srcCompat="@drawable/twotone_inbox_24" />

Loading…
Cancel
Save