Revert "Long press to mark thread (un)seen"

This reverts commit 3da36bcbb6.
This commit is contained in:
M66B 2018-11-22 18:43:28 +01:00
parent 4c4689a840
commit aa14da143f
2 changed files with 9 additions and 94 deletions

View File

@ -190,27 +190,25 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
switch (target.getItemId()) { switch (target.getItemId()) {
case action_synchronize_now: case action_synchronize_now:
onActionSynchronizeNow(); onActionSynchronizeNow();
return true; break;
case action_delete_local: case action_delete_local:
OnActionDeleteLocal(); OnActionDeleteLocal();
return true; break;
case action_empty_trash: case action_empty_trash:
onActionEmptyTrash(); onActionEmptyTrash();
return true; break;
case action_edit_properties: case action_edit_properties:
onActionEditProperties(); onActionEditProperties();
return true; break;
case action_legend: case action_legend:
onActionLegend(); onActionLegend();
return true; break;
default:
return false;
} }
return true;
} }
private void onActionSynchronizeNow() { private void onActionSynchronizeNow() {

View File

@ -132,7 +132,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
private static final long CACHE_IMAGE_DURATION = 3 * 24 * 3600 * 1000L; private static final long CACHE_IMAGE_DURATION = 3 * 24 * 3600 * 1000L;
public class ViewHolder extends RecyclerView.ViewHolder implements public class ViewHolder extends RecyclerView.ViewHolder implements
View.OnClickListener, View.OnLongClickListener, BottomNavigationView.OnNavigationItemSelectedListener { View.OnClickListener, BottomNavigationView.OnNavigationItemSelectedListener {
private View itemView; private View itemView;
private View vwColor; private View vwColor;
private ImageView ivExpander; private ImageView ivExpander;
@ -181,9 +181,6 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
private ItemDetailsMessage itemDetails = null; private ItemDetailsMessage itemDetails = null;
private final static int action_seen = 1;
private final static int action_unseen = 2;
ViewHolder(View itemView) { ViewHolder(View itemView) {
super(itemView); super(itemView);
@ -247,28 +244,20 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
private void wire() { private void wire() {
itemView.setOnClickListener(this); itemView.setOnClickListener(this);
if (viewType != ViewType.THREAD)
itemView.setOnLongClickListener(this);
ivExpanderAddress.setOnClickListener(this); ivExpanderAddress.setOnClickListener(this);
ivAddContact.setOnClickListener(this); ivAddContact.setOnClickListener(this);
bnvActions.setOnNavigationItemSelectedListener(this);
btnHtml.setOnClickListener(this); btnHtml.setOnClickListener(this);
btnImages.setOnClickListener(this); btnImages.setOnClickListener(this);
bnvActions.setOnNavigationItemSelectedListener(this);
} }
private void unwire() { private void unwire() {
itemView.setOnClickListener(null); itemView.setOnClickListener(null);
if (viewType != ViewType.THREAD)
itemView.setOnLongClickListener(null);
ivExpanderAddress.setOnClickListener(null); ivExpanderAddress.setOnClickListener(null);
ivAddContact.setOnClickListener(null); ivAddContact.setOnClickListener(null);
bnvActions.setOnNavigationItemSelectedListener(null);
btnHtml.setOnClickListener(null); btnHtml.setOnClickListener(null);
btnImages.setOnClickListener(null); btnImages.setOnClickListener(null);
bnvActions.setOnNavigationItemSelectedListener(null);
} }
private void clear() { private void clear() {
@ -558,77 +547,6 @@ 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) { private void onAddContact(TupleMessageEx message) {
for (Address address : message.from) { for (Address address : message.from) {
InternetAddress ia = (InternetAddress) address; InternetAddress ia = (InternetAddress) address;
@ -1157,7 +1075,6 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
EntityMessage message = db.message().getMessage(id); EntityMessage message = db.message().getMessage(id);
db.message().setMessageUiSeen(message.id, false); db.message().setMessageUiSeen(message.id, false);
db.message().setMessageUiIgnored(message.id, true);
EntityOperation.queue(db, message, EntityOperation.SEEN, false); EntityOperation.queue(db, message, EntityOperation.SEEN, false);
db.setTransactionSuccessful(); db.setTransactionSuccessful();