|
|
@ -2036,32 +2036,38 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putLong("id", message.id);
|
|
|
|
args.putLong("id", message.id);
|
|
|
|
|
|
|
|
|
|
|
|
new SimpleTask<List<TupleIdentityEx>>() {
|
|
|
|
new SimpleTask<ReplyData>() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected List<TupleIdentityEx> onExecute(Context context, Bundle args) {
|
|
|
|
protected ReplyData onExecute(Context context, Bundle args) {
|
|
|
|
long id = args.getLong("id");
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ReplyData result = new ReplyData();
|
|
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
|
|
|
|
EntityMessage message = db.message().getMessage(id);
|
|
|
|
EntityMessage message = db.message().getMessage(id);
|
|
|
|
if (message == null)
|
|
|
|
if (message == null)
|
|
|
|
return null;
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
|
|
args.putInt("answers", db.answer().getAnswerCount());
|
|
|
|
args.putInt("answers", db.answer().getAnswerCount());
|
|
|
|
|
|
|
|
|
|
|
|
return db.identity().getComposableIdentities(message.account);
|
|
|
|
result.identities = db.identity().getComposableIdentities(message.account);
|
|
|
|
|
|
|
|
result.answers = db.answer().getAnswersByFavorite(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onExecuted(Bundle args, List<TupleIdentityEx> identities) {
|
|
|
|
protected void onExecuted(Bundle args, ReplyData data) {
|
|
|
|
if (identities == null)
|
|
|
|
if (data.identities == null)
|
|
|
|
identities = new ArrayList<>();
|
|
|
|
data.identities = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
final Address[] to =
|
|
|
|
final Address[] to =
|
|
|
|
message.replySelf(identities, message.account)
|
|
|
|
message.replySelf(data.identities, message.account)
|
|
|
|
? message.to
|
|
|
|
? message.to
|
|
|
|
: (message.reply == null || message.reply.length == 0 ? message.from : message.reply);
|
|
|
|
: (message.reply == null || message.reply.length == 0 ? message.from : message.reply);
|
|
|
|
|
|
|
|
|
|
|
|
Address[] recipients = message.getAllRecipients(identities, message.account);
|
|
|
|
Address[] recipients = message.getAllRecipients(data.identities, message.account);
|
|
|
|
|
|
|
|
|
|
|
|
int answers = args.getInt("answers");
|
|
|
|
int answers = args.getInt("answers");
|
|
|
|
|
|
|
|
|
|
|
@ -2079,9 +2085,27 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_editasnew).setEnabled(message.content);
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_editasnew).setEnabled(message.content);
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_reply_answer).setEnabled(message.content);
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_reply_answer).setEnabled(message.content);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data.answers != null) {
|
|
|
|
|
|
|
|
int order = 100;
|
|
|
|
|
|
|
|
for (EntityAnswer answer : data.answers) {
|
|
|
|
|
|
|
|
order++;
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(1, order, order, answer.toString())
|
|
|
|
|
|
|
|
.setIntent(new Intent().putExtra("id", answer.id));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean onMenuItemClick(MenuItem target) {
|
|
|
|
public boolean onMenuItemClick(MenuItem target) {
|
|
|
|
|
|
|
|
if (target.getGroupId() == 1) {
|
|
|
|
|
|
|
|
startActivity(new Intent(getContext(), ActivityCompose.class)
|
|
|
|
|
|
|
|
.putExtra("action", "reply")
|
|
|
|
|
|
|
|
.putExtra("reference", message.id)
|
|
|
|
|
|
|
|
.putExtra("answer", target.getIntent().getLongExtra("id", -1)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (target.getItemId()) {
|
|
|
|
switch (target.getItemId()) {
|
|
|
|
case R.id.menu_reply_to_sender:
|
|
|
|
case R.id.menu_reply_to_sender:
|
|
|
|
onMenuReply(message, "reply", selected);
|
|
|
|
onMenuReply(message, "reply", selected);
|
|
|
@ -2145,7 +2169,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|
|
|
new SimpleTask<List<EntityAnswer>>() {
|
|
|
|
new SimpleTask<List<EntityAnswer>>() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected List<EntityAnswer> onExecute(Context context, Bundle args) {
|
|
|
|
protected List<EntityAnswer> onExecute(Context context, Bundle args) {
|
|
|
|
return DB.getInstance(context).answer().getAnswers(false);
|
|
|
|
return DB.getInstance(context).answer().getAnswersByFavorite(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -2164,8 +2188,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|
|
|
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(getContext(), getViewLifecycleOwner(), fabReply);
|
|
|
|
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(getContext(), getViewLifecycleOwner(), fabReply);
|
|
|
|
|
|
|
|
|
|
|
|
int order = 0;
|
|
|
|
int order = 0;
|
|
|
|
for (EntityAnswer answer : answers)
|
|
|
|
for (EntityAnswer answer : answers) {
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, answer.id.intValue(), order++, answer.toString());
|
|
|
|
order++;
|
|
|
|
|
|
|
|
popupMenu.getMenu().add(Menu.NONE, order, order++, answer.toString())
|
|
|
|
|
|
|
|
.setIntent(new Intent().putExtra("id", answer.id));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -2178,7 +2205,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|
|
|
startActivity(new Intent(getContext(), ActivityCompose.class)
|
|
|
|
startActivity(new Intent(getContext(), ActivityCompose.class)
|
|
|
|
.putExtra("action", "reply")
|
|
|
|
.putExtra("action", "reply")
|
|
|
|
.putExtra("reference", message.id)
|
|
|
|
.putExtra("reference", message.id)
|
|
|
|
.putExtra("answer", (long) target.getItemId()));
|
|
|
|
.putExtra("answer", target.getIntent().getLongExtra("id", -1)));
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -6499,6 +6526,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class ReplyData {
|
|
|
|
|
|
|
|
List<TupleIdentityEx> identities;
|
|
|
|
|
|
|
|
List<EntityAnswer> answers;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private class MoreResult {
|
|
|
|
private class MoreResult {
|
|
|
|
boolean seen;
|
|
|
|
boolean seen;
|
|
|
|
boolean unseen;
|
|
|
|
boolean unseen;
|
|
|
|