mirror of https://github.com/M66B/FairEmail.git
Long press to mark thread (un)seen
This commit is contained in:
parent
a01c33b80b
commit
3da36bcbb6
|
@ -190,25 +190,27 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
switch (target.getItemId()) {
|
||||
case action_synchronize_now:
|
||||
onActionSynchronizeNow();
|
||||
break;
|
||||
return true;
|
||||
|
||||
case action_delete_local:
|
||||
OnActionDeleteLocal();
|
||||
break;
|
||||
return true;
|
||||
|
||||
case action_empty_trash:
|
||||
onActionEmptyTrash();
|
||||
break;
|
||||
return true;
|
||||
|
||||
case action_edit_properties:
|
||||
onActionEditProperties();
|
||||
break;
|
||||
return true;
|
||||
|
||||
case action_legend:
|
||||
onActionLegend();
|
||||
break;
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void onActionSynchronizeNow() {
|
||||
|
|
|
@ -132,7 +132,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
private static final long CACHE_IMAGE_DURATION = 3 * 24 * 3600 * 1000L;
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements
|
||||
View.OnClickListener, BottomNavigationView.OnNavigationItemSelectedListener {
|
||||
View.OnClickListener, View.OnLongClickListener, BottomNavigationView.OnNavigationItemSelectedListener {
|
||||
private View itemView;
|
||||
private View vwColor;
|
||||
private ImageView ivExpander;
|
||||
|
@ -181,6 +181,9 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
|
||||
private ItemDetailsMessage itemDetails = null;
|
||||
|
||||
private final static int action_seen = 1;
|
||||
private final static int action_unseen = 2;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
|
@ -244,20 +247,28 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
|
||||
private void wire() {
|
||||
itemView.setOnClickListener(this);
|
||||
if (viewType != ViewType.THREAD)
|
||||
itemView.setOnLongClickListener(this);
|
||||
|
||||
ivExpanderAddress.setOnClickListener(this);
|
||||
ivAddContact.setOnClickListener(this);
|
||||
bnvActions.setOnNavigationItemSelectedListener(this);
|
||||
btnHtml.setOnClickListener(this);
|
||||
btnImages.setOnClickListener(this);
|
||||
|
||||
bnvActions.setOnNavigationItemSelectedListener(this);
|
||||
}
|
||||
|
||||
private void unwire() {
|
||||
itemView.setOnClickListener(null);
|
||||
if (viewType != ViewType.THREAD)
|
||||
itemView.setOnLongClickListener(null);
|
||||
|
||||
ivExpanderAddress.setOnClickListener(null);
|
||||
ivAddContact.setOnClickListener(null);
|
||||
bnvActions.setOnNavigationItemSelectedListener(null);
|
||||
btnHtml.setOnClickListener(null);
|
||||
btnImages.setOnClickListener(null);
|
||||
|
||||
bnvActions.setOnNavigationItemSelectedListener(null);
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
|
@ -547,6 +558,77 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
int pos = getAdapterPosition();
|
||||
if (pos == RecyclerView.NO_POSITION)
|
||||
return false;
|
||||
|
||||
final TupleMessageEx message = getItem(pos);
|
||||
|
||||
PopupMenu popupMenu = new PopupMenu(context, itemView);
|
||||
|
||||
if (message.ui_seen)
|
||||
popupMenu.getMenu().add(Menu.NONE, action_unseen, 1, R.string.title_unseen);
|
||||
else
|
||||
popupMenu.getMenu().add(Menu.NONE, action_seen, 1, R.string.title_seen);
|
||||
|
||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem target) {
|
||||
switch (target.getItemId()) {
|
||||
case action_seen:
|
||||
onActionSeen(true);
|
||||
return true;
|
||||
case action_unseen:
|
||||
onActionSeen(false);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void onActionSeen(boolean seen) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("account", message.account);
|
||||
args.putString("thread", message.thread);
|
||||
args.putBoolean("seen", seen);
|
||||
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
protected Void onLoad(Context context, Bundle args) throws Throwable {
|
||||
long account = args.getLong("account");
|
||||
String thread = args.getString("thread");
|
||||
boolean seen = args.getBoolean("seen");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
try {
|
||||
db.beginTransaction();
|
||||
|
||||
List<EntityMessage> messages = db.message().getMessageByThread(account, thread);
|
||||
for (EntityMessage message : messages) {
|
||||
db.message().setMessageUiSeen(message.id, seen);
|
||||
db.message().setMessageUiIgnored(message.id, true);
|
||||
EntityOperation.queue(db, message, EntityOperation.SEEN, seen);
|
||||
}
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
|
||||
EntityOperation.process(context);
|
||||
|
||||
return null;
|
||||
}
|
||||
}.load(context, owner, args);
|
||||
}
|
||||
});
|
||||
|
||||
popupMenu.show();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void onAddContact(TupleMessageEx message) {
|
||||
for (Address address : message.from) {
|
||||
InternetAddress ia = (InternetAddress) address;
|
||||
|
@ -1075,6 +1157,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
|
||||
EntityMessage message = db.message().getMessage(id);
|
||||
db.message().setMessageUiSeen(message.id, false);
|
||||
db.message().setMessageUiIgnored(message.id, true);
|
||||
EntityOperation.queue(db, message, EntityOperation.SEEN, false);
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
|
|
Loading…
Reference in New Issue