|
|
@ -1189,7 +1189,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected Void onExecute(Context context, Bundle args) throws Throwable {
|
|
|
|
protected Void onExecute(Context context, Bundle args) {
|
|
|
|
long id = args.getLong("id");
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
@ -1197,7 +1197,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
db.beginTransaction();
|
|
|
|
db.beginTransaction();
|
|
|
|
|
|
|
|
|
|
|
|
EntityMessage msg = db.message().getMessage(id);
|
|
|
|
EntityMessage msg = db.message().getMessage(id);
|
|
|
|
if (message != null)
|
|
|
|
if (msg != null)
|
|
|
|
for (EntityAttachment attachment : db.attachment().getAttachments(message.id))
|
|
|
|
for (EntityAttachment attachment : db.attachment().getAttachments(message.id))
|
|
|
|
if (attachment.progress == null && !attachment.available) {
|
|
|
|
if (attachment.progress == null && !attachment.available) {
|
|
|
|
db.attachment().setProgress(attachment.id, 0);
|
|
|
|
db.attachment().setProgress(attachment.id, 0);
|
|
|
@ -1649,7 +1649,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
onActionArchive(data);
|
|
|
|
onActionArchive(data);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
case R.id.action_reply:
|
|
|
|
case R.id.action_reply:
|
|
|
|
onActionReply(data, false);
|
|
|
|
onActionReplyMenu(data);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -1698,73 +1698,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
}.execute(context, owner, args, "message:forward");
|
|
|
|
}.execute(context, owner, args, "message:forward");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void onMenuAnswer(final ActionData data) {
|
|
|
|
|
|
|
|
new SimpleTask<List<EntityAnswer>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected List<EntityAnswer> onExecute(Context context, Bundle args) {
|
|
|
|
|
|
|
|
return DB.getInstance(context).answer().getAnswers();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onExecuted(Bundle args, List<EntityAnswer> answers) {
|
|
|
|
|
|
|
|
if (answers == null || answers.size() == 0) {
|
|
|
|
|
|
|
|
Snackbar snackbar = Snackbar.make(
|
|
|
|
|
|
|
|
itemView,
|
|
|
|
|
|
|
|
context.getString(R.string.title_no_answers),
|
|
|
|
|
|
|
|
Snackbar.LENGTH_LONG);
|
|
|
|
|
|
|
|
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
|
|
|
|
|
|
|
lbm.sendBroadcast(new Intent(ActivityView.ACTION_EDIT_ANSWERS));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
snackbar.show();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
final Collator collator = Collator.getInstance(Locale.getDefault());
|
|
|
|
|
|
|
|
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Collections.sort(answers, new Comparator<EntityAnswer>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public int compare(EntityAnswer a1, EntityAnswer a2) {
|
|
|
|
|
|
|
|
return collator.compare(a1.name, a2.name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
View anchor = bnvActions.findViewById(R.id.action_more);
|
|
|
|
|
|
|
|
PopupMenu popupMenu = new PopupMenu(context, anchor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int order = 0;
|
|
|
|
|
|
|
|
for (EntityAnswer answer : answers)
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, answer.id.intValue(), order++, answer.name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean onMenuItemClick(MenuItem target) {
|
|
|
|
|
|
|
|
if (Helper.isPro(context))
|
|
|
|
|
|
|
|
context.startActivity(new Intent(context, ActivityCompose.class)
|
|
|
|
|
|
|
|
.putExtra("action", "reply")
|
|
|
|
|
|
|
|
.putExtra("reference", data.message.id)
|
|
|
|
|
|
|
|
.putExtra("answer", (long) target.getItemId()));
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
|
|
|
|
|
|
|
lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
|
|
|
Helper.unexpectedError(context, owner, ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.execute(context, owner, new Bundle(), "message:answer");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void onMenuUnseen(final ActionData data) {
|
|
|
|
private void onMenuUnseen(final ActionData data) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putLong("id", data.message.id);
|
|
|
|
args.putLong("id", data.message.id);
|
|
|
@ -2230,9 +2163,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_forward).setEnabled(data.message.content);
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_forward).setEnabled(data.message.content);
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_reply_all).setEnabled(data.message.content);
|
|
|
|
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_answer).setEnabled(data.message.content);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_unseen).setEnabled(data.message.uid != null);
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_unseen).setEnabled(data.message.uid != null);
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_delete).setVisible(debug);
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_delete).setVisible(debug);
|
|
|
@ -2264,12 +2194,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
case R.id.menu_forward:
|
|
|
|
case R.id.menu_forward:
|
|
|
|
onMenuForward(data);
|
|
|
|
onMenuForward(data);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
case R.id.menu_reply_all:
|
|
|
|
|
|
|
|
onActionReply(data, true);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.id.menu_answer:
|
|
|
|
|
|
|
|
onMenuAnswer(data);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.id.menu_unseen:
|
|
|
|
case R.id.menu_unseen:
|
|
|
|
onMenuUnseen(data);
|
|
|
|
onMenuUnseen(data);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -2487,7 +2411,34 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
properties.move(data.message.id, EntityFolder.ARCHIVE, true);
|
|
|
|
properties.move(data.message.id, EntityFolder.ARCHIVE, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void onActionReply(final ActionData data, final boolean all) {
|
|
|
|
private void onActionReplyMenu(final ActionData data) {
|
|
|
|
|
|
|
|
View anchor = bnvActions.findViewById(R.id.action_reply);
|
|
|
|
|
|
|
|
PopupMenu popupMenu = new PopupMenu(context, anchor);
|
|
|
|
|
|
|
|
popupMenu.inflate(R.menu.menu_reply);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean onMenuItemClick(MenuItem target) {
|
|
|
|
|
|
|
|
switch (target.getItemId()) {
|
|
|
|
|
|
|
|
case R.id.menu_reply_to_sender:
|
|
|
|
|
|
|
|
onMenuReply(data, false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.id.menu_reply_to_all:
|
|
|
|
|
|
|
|
onMenuReply(data, true);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.id.menu_reply_template:
|
|
|
|
|
|
|
|
onMenuAnswer(data);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
popupMenu.show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void onMenuReply(final ActionData data, final boolean all) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putLong("id", data.message.id);
|
|
|
|
args.putLong("id", data.message.id);
|
|
|
|
|
|
|
|
|
|
|
@ -2529,6 +2480,73 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
}.execute(context, owner, args, "message:reply");
|
|
|
|
}.execute(context, owner, args, "message:reply");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void onMenuAnswer(final ActionData data) {
|
|
|
|
|
|
|
|
new SimpleTask<List<EntityAnswer>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected List<EntityAnswer> onExecute(Context context, Bundle args) {
|
|
|
|
|
|
|
|
return DB.getInstance(context).answer().getAnswers();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onExecuted(Bundle args, List<EntityAnswer> answers) {
|
|
|
|
|
|
|
|
if (answers == null || answers.size() == 0) {
|
|
|
|
|
|
|
|
Snackbar snackbar = Snackbar.make(
|
|
|
|
|
|
|
|
itemView,
|
|
|
|
|
|
|
|
context.getString(R.string.title_no_answers),
|
|
|
|
|
|
|
|
Snackbar.LENGTH_LONG);
|
|
|
|
|
|
|
|
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
|
|
|
|
|
|
|
lbm.sendBroadcast(new Intent(ActivityView.ACTION_EDIT_ANSWERS));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
snackbar.show();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
final Collator collator = Collator.getInstance(Locale.getDefault());
|
|
|
|
|
|
|
|
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Collections.sort(answers, new Comparator<EntityAnswer>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public int compare(EntityAnswer a1, EntityAnswer a2) {
|
|
|
|
|
|
|
|
return collator.compare(a1.name, a2.name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
View anchor = bnvActions.findViewById(R.id.action_reply);
|
|
|
|
|
|
|
|
PopupMenu popupMenu = new PopupMenu(context, anchor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int order = 0;
|
|
|
|
|
|
|
|
for (EntityAnswer answer : answers)
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, answer.id.intValue(), order++, answer.name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean onMenuItemClick(MenuItem target) {
|
|
|
|
|
|
|
|
if (Helper.isPro(context))
|
|
|
|
|
|
|
|
context.startActivity(new Intent(context, ActivityCompose.class)
|
|
|
|
|
|
|
|
.putExtra("action", "reply")
|
|
|
|
|
|
|
|
.putExtra("reference", data.message.id)
|
|
|
|
|
|
|
|
.putExtra("answer", (long) target.getItemId()));
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
|
|
|
|
|
|
|
lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
|
|
|
Helper.unexpectedError(context, owner, ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.execute(context, owner, new Bundle(), "message:answer");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ItemDetailsLookup.ItemDetails<Long> getItemDetails(@NonNull MotionEvent motionEvent) {
|
|
|
|
ItemDetailsLookup.ItemDetails<Long> getItemDetails(@NonNull MotionEvent motionEvent) {
|
|
|
|
return new ItemDetailsMessage(this);
|
|
|
|
return new ItemDetailsMessage(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|