mirror of https://github.com/M66B/FairEmail.git
Added reply ... menu
This commit is contained in:
parent
7873712479
commit
782c786169
|
@ -1189,7 +1189,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
new SimpleTask<Void>() {
|
||||
@Override
|
||||
protected Void onExecute(Context context, Bundle args) throws Throwable {
|
||||
protected Void onExecute(Context context, Bundle args) {
|
||||
long id = args.getLong("id");
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
|
@ -1197,7 +1197,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
db.beginTransaction();
|
||||
|
||||
EntityMessage msg = db.message().getMessage(id);
|
||||
if (message != null)
|
||||
if (msg != null)
|
||||
for (EntityAttachment attachment : db.attachment().getAttachments(message.id))
|
||||
if (attachment.progress == null && !attachment.available) {
|
||||
db.attachment().setProgress(attachment.id, 0);
|
||||
|
@ -1649,7 +1649,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
onActionArchive(data);
|
||||
return true;
|
||||
case R.id.action_reply:
|
||||
onActionReply(data, false);
|
||||
onActionReplyMenu(data);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -1698,73 +1698,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}.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) {
|
||||
Bundle args = new Bundle();
|
||||
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_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_delete).setVisible(debug);
|
||||
|
@ -2264,12 +2194,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
case R.id.menu_forward:
|
||||
onMenuForward(data);
|
||||
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:
|
||||
onMenuUnseen(data);
|
||||
return true;
|
||||
|
@ -2487,7 +2411,34 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
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();
|
||||
args.putLong("id", data.message.id);
|
||||
|
||||
|
@ -2529,6 +2480,73 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}.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) {
|
||||
return new ItemDetailsMessage(this);
|
||||
}
|
||||
|
|
|
@ -4,14 +4,6 @@
|
|||
android:id="@+id/menu_forward"
|
||||
android:title="@string/title_forward" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_reply_all"
|
||||
android:title="@string/title_reply_all" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_answer"
|
||||
android:title="@string/title_answer_reply" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_unseen"
|
||||
android:title="@string/title_unseen" />
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/menu_reply_to_sender"
|
||||
android:title="@string/title_reply_to_sender" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_reply_to_all"
|
||||
android:title="@string/title_reply_to_all" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_reply_template"
|
||||
android:title="@string/title_reply_template" />
|
||||
</menu>
|
|
@ -316,7 +316,6 @@
|
|||
<string name="title_flag">Add star</string>
|
||||
<string name="title_unflag">Remove star</string>
|
||||
<string name="title_forward">Forward</string>
|
||||
<string name="title_reply_all">Reply to all</string>
|
||||
<string name="title_create_rule">Create rule …</string>
|
||||
<string name="title_share">Share</string>
|
||||
<string name="title_show_headers">Show headers</string>
|
||||
|
@ -338,6 +337,9 @@
|
|||
<string name="title_snooze">Snooze …</string>
|
||||
<string name="title_archive">Archive</string>
|
||||
<string name="title_reply">Reply</string>
|
||||
<string name="title_reply_to_sender">Sender</string>
|
||||
<string name="title_reply_to_all">All</string>
|
||||
<string name="title_reply_template">Template</string>
|
||||
<string name="title_moving">Moving to %1$s</string>
|
||||
<string name="title_open_with">Open with</string>
|
||||
|
||||
|
|
Loading…
Reference in New Issue