|
|
@ -784,54 +784,49 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void onMore(final ActionData data) { |
|
|
|
boolean inOutbox = EntityFolder.OUTBOX.equals(data.message.folderType); |
|
|
|
boolean show_headers = properties.showHeaders(data.message.id); |
|
|
|
private void onJunk(final ActionData data) { |
|
|
|
new DialogBuilderLifecycle(context, owner) |
|
|
|
.setMessage(R.string.title_ask_spam) |
|
|
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
Bundle args = new Bundle(); |
|
|
|
args.putLong("id", data.message.id); |
|
|
|
|
|
|
|
View anchor = bnvActions.findViewById(R.id.action_more); |
|
|
|
PopupMenu popupMenu = new PopupMenu(context, anchor); |
|
|
|
popupMenu.inflate(R.menu.menu_message); |
|
|
|
popupMenu.getMenu().findItem(R.id.menu_forward).setVisible(data.message.content && !inOutbox); |
|
|
|
popupMenu.getMenu().findItem(R.id.menu_show_headers).setChecked(show_headers); |
|
|
|
popupMenu.getMenu().findItem(R.id.menu_show_headers).setEnabled(data.message.uid != null); |
|
|
|
popupMenu.getMenu().findItem(R.id.menu_show_html).setEnabled(data.message.content && Helper.classExists("android.webkit.WebView")); |
|
|
|
popupMenu.getMenu().findItem(R.id.menu_flag).setChecked(data.message.uid != null && data.message.unflagged != 1); |
|
|
|
popupMenu.getMenu().findItem(R.id.menu_reply_all).setVisible(data.message.content && !inOutbox); |
|
|
|
new SimpleTask<Void>() { |
|
|
|
@Override |
|
|
|
protected Void onLoad(Context context, Bundle args) { |
|
|
|
long id = args.getLong("id"); |
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { |
|
|
|
@Override |
|
|
|
public boolean onMenuItemClick(MenuItem target) { |
|
|
|
switch (target.getItemId()) { |
|
|
|
case R.id.menu_junk: |
|
|
|
onJunk(data); |
|
|
|
return true; |
|
|
|
case R.id.menu_forward: |
|
|
|
onForward(data); |
|
|
|
return true; |
|
|
|
case R.id.menu_reply_all: |
|
|
|
onReplyAll(data); |
|
|
|
return true; |
|
|
|
case R.id.menu_show_headers: |
|
|
|
onShowHeaders(data); |
|
|
|
return true; |
|
|
|
case R.id.menu_show_html: |
|
|
|
onShowHtml(data); |
|
|
|
return true; |
|
|
|
case R.id.menu_flag: |
|
|
|
onFlag(data); |
|
|
|
return true; |
|
|
|
case R.id.menu_unseen: |
|
|
|
onUnseen(data); |
|
|
|
return true; |
|
|
|
case R.id.menu_answer: |
|
|
|
onAnswer(data); |
|
|
|
return true; |
|
|
|
default: |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
popupMenu.show(); |
|
|
|
DB db = DB.getInstance(context); |
|
|
|
try { |
|
|
|
db.beginTransaction(); |
|
|
|
|
|
|
|
db.message().setMessageUiHide(id, true); |
|
|
|
|
|
|
|
EntityMessage message = db.message().getMessage(id); |
|
|
|
EntityFolder spam = db.folder().getFolderByType(message.account, EntityFolder.JUNK); |
|
|
|
EntityOperation.queue(db, message, EntityOperation.MOVE, spam.id); |
|
|
|
|
|
|
|
db.setTransactionSuccessful(); |
|
|
|
} finally { |
|
|
|
db.endTransaction(); |
|
|
|
} |
|
|
|
|
|
|
|
EntityOperation.process(context); |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onException(Bundle args, Throwable ex) { |
|
|
|
Helper.unexpectedError(context, ex); |
|
|
|
} |
|
|
|
}.load(context, owner, args); |
|
|
|
} |
|
|
|
}) |
|
|
|
.setNegativeButton(android.R.string.cancel, null) |
|
|
|
.show(); |
|
|
|
} |
|
|
|
|
|
|
|
private void onForward(final ActionData data) { |
|
|
@ -882,68 +877,49 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess |
|
|
|
.putExtra("reference", data.message.id)); |
|
|
|
} |
|
|
|
|
|
|
|
private void onShowHeaders(ActionData data) { |
|
|
|
boolean show_headers = !properties.showHeaders(data.message.id); |
|
|
|
properties.setHeaders(data.message.id, show_headers); |
|
|
|
if (show_headers) { |
|
|
|
grpHeaders.setVisibility(View.VISIBLE); |
|
|
|
pbHeaders.setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
Bundle args = new Bundle(); |
|
|
|
args.putLong("id", data.message.id); |
|
|
|
private void onAnswer(final ActionData data) { |
|
|
|
final DB db = DB.getInstance(context); |
|
|
|
db.answer().liveAnswers().observe(owner, new Observer<List<EntityAnswer>>() { |
|
|
|
@Override |
|
|
|
public void onChanged(List<EntityAnswer> answers) { |
|
|
|
final Collator collator = Collator.getInstance(Locale.getDefault()); |
|
|
|
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc |
|
|
|
|
|
|
|
new SimpleTask<Void>() { |
|
|
|
@Override |
|
|
|
protected Void onLoad(Context context, Bundle args) { |
|
|
|
Long id = args.getLong("id"); |
|
|
|
DB db = DB.getInstance(context); |
|
|
|
EntityMessage message = db.message().getMessage(id); |
|
|
|
EntityOperation.queue(db, message, EntityOperation.HEADERS); |
|
|
|
EntityOperation.process(context); |
|
|
|
return null; |
|
|
|
} |
|
|
|
Collections.sort(answers, new Comparator<EntityAnswer>() { |
|
|
|
@Override |
|
|
|
public int compare(EntityAnswer a1, EntityAnswer a2) { |
|
|
|
return collator.compare(a1.name, a2.name); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onException(Bundle args, Throwable ex) { |
|
|
|
Helper.unexpectedError(context, ex); |
|
|
|
} |
|
|
|
}.load(context, owner, args); |
|
|
|
} else |
|
|
|
notifyDataSetChanged(); |
|
|
|
} |
|
|
|
View anchor = bnvActions.findViewById(R.id.action_more); |
|
|
|
PopupMenu popupMenu = new PopupMenu(context, anchor); |
|
|
|
|
|
|
|
private void onShowHtml(ActionData data) { |
|
|
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context); |
|
|
|
lbm.sendBroadcast( |
|
|
|
new Intent(ActivityView.ACTION_VIEW_FULL) |
|
|
|
.putExtra("id", data.message.id) |
|
|
|
.putExtra("from", MessageHelper.getFormattedAddresses(data.message.from, true))); |
|
|
|
} |
|
|
|
int order = 0; |
|
|
|
for (EntityAnswer answer : answers) |
|
|
|
popupMenu.getMenu().add(Menu.NONE, answer.id.intValue(), order++, answer.name); |
|
|
|
|
|
|
|
private void onFlag(ActionData data) { |
|
|
|
Bundle args = new Bundle(); |
|
|
|
args.putLong("id", data.message.id); |
|
|
|
args.putBoolean("flagged", !data.message.ui_flagged); |
|
|
|
Log.i(Helper.TAG, "Set message id=" + data.message.id + " flagged=" + !data.message.ui_flagged); |
|
|
|
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; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
new SimpleTask<Void>() { |
|
|
|
@Override |
|
|
|
protected Void onLoad(Context context, Bundle args) throws Throwable { |
|
|
|
long id = args.getLong("id"); |
|
|
|
boolean flagged = args.getBoolean("flagged"); |
|
|
|
DB db = DB.getInstance(context); |
|
|
|
EntityMessage message = db.message().getMessage(id); |
|
|
|
db.message().setMessageUiFlagged(message.id, flagged); |
|
|
|
EntityOperation.queue(db, message, EntityOperation.FLAG, flagged); |
|
|
|
EntityOperation.process(context); |
|
|
|
return null; |
|
|
|
} |
|
|
|
popupMenu.show(); |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onException(Bundle args, Throwable ex) { |
|
|
|
Helper.unexpectedError(context, ex); |
|
|
|
db.answer().liveAnswers().removeObservers(owner); |
|
|
|
} |
|
|
|
}.load(context, owner, args); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private void onUnseen(final ActionData data) { |
|
|
@ -981,94 +957,118 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess |
|
|
|
}.load(context, owner, args); |
|
|
|
} |
|
|
|
|
|
|
|
private void onAnswer(final ActionData data) { |
|
|
|
final DB db = DB.getInstance(context); |
|
|
|
db.answer().liveAnswers().observe(owner, new Observer<List<EntityAnswer>>() { |
|
|
|
@Override |
|
|
|
public void onChanged(List<EntityAnswer> answers) { |
|
|
|
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; |
|
|
|
} |
|
|
|
}); |
|
|
|
private void onFlag(ActionData data) { |
|
|
|
Bundle args = new Bundle(); |
|
|
|
args.putLong("id", data.message.id); |
|
|
|
args.putBoolean("flagged", !data.message.ui_flagged); |
|
|
|
Log.i(Helper.TAG, "Set message id=" + data.message.id + " flagged=" + !data.message.ui_flagged); |
|
|
|
|
|
|
|
popupMenu.show(); |
|
|
|
new SimpleTask<Void>() { |
|
|
|
@Override |
|
|
|
protected Void onLoad(Context context, Bundle args) throws Throwable { |
|
|
|
long id = args.getLong("id"); |
|
|
|
boolean flagged = args.getBoolean("flagged"); |
|
|
|
DB db = DB.getInstance(context); |
|
|
|
EntityMessage message = db.message().getMessage(id); |
|
|
|
db.message().setMessageUiFlagged(message.id, flagged); |
|
|
|
EntityOperation.queue(db, message, EntityOperation.FLAG, flagged); |
|
|
|
EntityOperation.process(context); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
db.answer().liveAnswers().removeObservers(owner); |
|
|
|
@Override |
|
|
|
protected void onException(Bundle args, Throwable ex) { |
|
|
|
Helper.unexpectedError(context, ex); |
|
|
|
} |
|
|
|
}); |
|
|
|
}.load(context, owner, args); |
|
|
|
} |
|
|
|
|
|
|
|
private void onJunk(final ActionData data) { |
|
|
|
new DialogBuilderLifecycle(context, owner) |
|
|
|
.setMessage(R.string.title_ask_spam) |
|
|
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
Bundle args = new Bundle(); |
|
|
|
args.putLong("id", data.message.id); |
|
|
|
|
|
|
|
new SimpleTask<Void>() { |
|
|
|
@Override |
|
|
|
protected Void onLoad(Context context, Bundle args) { |
|
|
|
long id = args.getLong("id"); |
|
|
|
private void onShowHeaders(ActionData data) { |
|
|
|
boolean show_headers = !properties.showHeaders(data.message.id); |
|
|
|
properties.setHeaders(data.message.id, show_headers); |
|
|
|
if (show_headers) { |
|
|
|
grpHeaders.setVisibility(View.VISIBLE); |
|
|
|
pbHeaders.setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
DB db = DB.getInstance(context); |
|
|
|
try { |
|
|
|
db.beginTransaction(); |
|
|
|
Bundle args = new Bundle(); |
|
|
|
args.putLong("id", data.message.id); |
|
|
|
|
|
|
|
db.message().setMessageUiHide(id, true); |
|
|
|
new SimpleTask<Void>() { |
|
|
|
@Override |
|
|
|
protected Void onLoad(Context context, Bundle args) { |
|
|
|
Long id = args.getLong("id"); |
|
|
|
DB db = DB.getInstance(context); |
|
|
|
EntityMessage message = db.message().getMessage(id); |
|
|
|
EntityOperation.queue(db, message, EntityOperation.HEADERS); |
|
|
|
EntityOperation.process(context); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
EntityMessage message = db.message().getMessage(id); |
|
|
|
EntityFolder spam = db.folder().getFolderByType(message.account, EntityFolder.JUNK); |
|
|
|
EntityOperation.queue(db, message, EntityOperation.MOVE, spam.id); |
|
|
|
@Override |
|
|
|
protected void onException(Bundle args, Throwable ex) { |
|
|
|
Helper.unexpectedError(context, ex); |
|
|
|
} |
|
|
|
}.load(context, owner, args); |
|
|
|
} else |
|
|
|
notifyDataSetChanged(); |
|
|
|
} |
|
|
|
|
|
|
|
db.setTransactionSuccessful(); |
|
|
|
} finally { |
|
|
|
db.endTransaction(); |
|
|
|
} |
|
|
|
private void onShowHtml(ActionData data) { |
|
|
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context); |
|
|
|
lbm.sendBroadcast( |
|
|
|
new Intent(ActivityView.ACTION_VIEW_FULL) |
|
|
|
.putExtra("id", data.message.id) |
|
|
|
.putExtra("from", MessageHelper.getFormattedAddresses(data.message.from, true))); |
|
|
|
} |
|
|
|
|
|
|
|
EntityOperation.process(context); |
|
|
|
private void onMore(final ActionData data) { |
|
|
|
boolean inOutbox = EntityFolder.OUTBOX.equals(data.message.folderType); |
|
|
|
boolean show_headers = properties.showHeaders(data.message.id); |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
View anchor = bnvActions.findViewById(R.id.action_more); |
|
|
|
PopupMenu popupMenu = new PopupMenu(context, anchor); |
|
|
|
popupMenu.inflate(R.menu.menu_message); |
|
|
|
popupMenu.getMenu().findItem(R.id.menu_forward).setVisible(data.message.content && !inOutbox); |
|
|
|
popupMenu.getMenu().findItem(R.id.menu_show_headers).setChecked(show_headers); |
|
|
|
popupMenu.getMenu().findItem(R.id.menu_show_headers).setEnabled(data.message.uid != null); |
|
|
|
popupMenu.getMenu().findItem(R.id.menu_show_html).setEnabled(data.message.content && Helper.classExists("android.webkit.WebView")); |
|
|
|
popupMenu.getMenu().findItem(R.id.menu_flag).setChecked(data.message.uid != null && data.message.unflagged != 1); |
|
|
|
popupMenu.getMenu().findItem(R.id.menu_reply_all).setVisible(data.message.content && !inOutbox); |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onException(Bundle args, Throwable ex) { |
|
|
|
Helper.unexpectedError(context, ex); |
|
|
|
} |
|
|
|
}.load(context, owner, args); |
|
|
|
} |
|
|
|
}) |
|
|
|
.setNegativeButton(android.R.string.cancel, null) |
|
|
|
.show(); |
|
|
|
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { |
|
|
|
@Override |
|
|
|
public boolean onMenuItemClick(MenuItem target) { |
|
|
|
switch (target.getItemId()) { |
|
|
|
case R.id.menu_junk: |
|
|
|
onJunk(data); |
|
|
|
return true; |
|
|
|
case R.id.menu_forward: |
|
|
|
onForward(data); |
|
|
|
return true; |
|
|
|
case R.id.menu_reply_all: |
|
|
|
onReplyAll(data); |
|
|
|
return true; |
|
|
|
case R.id.menu_show_headers: |
|
|
|
onShowHeaders(data); |
|
|
|
return true; |
|
|
|
case R.id.menu_show_html: |
|
|
|
onShowHtml(data); |
|
|
|
return true; |
|
|
|
case R.id.menu_flag: |
|
|
|
onFlag(data); |
|
|
|
return true; |
|
|
|
case R.id.menu_unseen: |
|
|
|
onUnseen(data); |
|
|
|
return true; |
|
|
|
case R.id.menu_answer: |
|
|
|
onAnswer(data); |
|
|
|
return true; |
|
|
|
default: |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
popupMenu.show(); |
|
|
|
} |
|
|
|
|
|
|
|
private void onDelete(final ActionData data) { |
|
|
|