|
|
|
@ -3645,6 +3645,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_manage_keywords).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
|
|
|
|
|
|
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_share).setEnabled(message.content);
|
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_event).setEnabled(message.content);
|
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_print).setEnabled(hasWebView && message.content);
|
|
|
|
|
popupMenu.getMenu().findItem(R.id.menu_print).setVisible(Helper.canPrint(context));
|
|
|
|
|
|
|
|
|
@ -3705,7 +3706,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
onMenuManageKeywords(message);
|
|
|
|
|
return true;
|
|
|
|
|
case R.id.menu_share:
|
|
|
|
|
onMenuShare(message);
|
|
|
|
|
onMenuShare(message, false);
|
|
|
|
|
return true;
|
|
|
|
|
case R.id.menu_event:
|
|
|
|
|
onMenuShare(message, true);
|
|
|
|
|
return true;
|
|
|
|
|
case R.id.menu_print:
|
|
|
|
|
onMenuPrint(message);
|
|
|
|
@ -4185,15 +4189,17 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
fragment.show(parentFragment.getParentFragmentManager(), "keyword:manage");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onMenuShare(TupleMessageEx message) {
|
|
|
|
|
private void onMenuShare(TupleMessageEx message, final boolean event) {
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putLong("id", message.id);
|
|
|
|
|
|
|
|
|
|
new SimpleTask<String[]>() {
|
|
|
|
|
new SimpleTask<Map<String, String>>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected String[] onExecute(Context context, Bundle args) throws Throwable {
|
|
|
|
|
protected Map<String, String> onExecute(Context context, Bundle args) throws Throwable {
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
|
|
Map<String, String> result = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
EntityMessage message = db.message().getMessage(id);
|
|
|
|
|
if (message == null || !message.content)
|
|
|
|
@ -4203,39 +4209,61 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
if (!file.exists())
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
String from = null;
|
|
|
|
|
if (message.identity != null) {
|
|
|
|
|
EntityIdentity identity = db.identity().getIdentity(message.identity);
|
|
|
|
|
if (identity != null)
|
|
|
|
|
result.put("me", identity.email);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (message.from != null && message.from.length > 0)
|
|
|
|
|
from = ((InternetAddress) message.from[0]).getAddress();
|
|
|
|
|
result.put("from", ((InternetAddress) message.from[0]).getAddress());
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
|
result.put("subject", message.subject);
|
|
|
|
|
|
|
|
|
|
String html = Helper.readText(file);
|
|
|
|
|
String text = HtmlHelper.getText(context, html);
|
|
|
|
|
|
|
|
|
|
return new String[]{from, message.subject, text};
|
|
|
|
|
if (!TextUtils.isEmpty(text))
|
|
|
|
|
result.put("text", text);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onExecuted(Bundle args, String[] text) {
|
|
|
|
|
if (text == null)
|
|
|
|
|
protected void onExecuted(Bundle args, Map<String, String> data) {
|
|
|
|
|
if (data == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Intent share = new Intent();
|
|
|
|
|
share.setAction(Intent.ACTION_SEND);
|
|
|
|
|
share.setType("text/plain");
|
|
|
|
|
if (!TextUtils.isEmpty(text[0]))
|
|
|
|
|
share.putExtra(Intent.EXTRA_EMAIL, new String[]{text[0]});
|
|
|
|
|
if (!TextUtils.isEmpty(text[1]))
|
|
|
|
|
share.putExtra(Intent.EXTRA_SUBJECT, text[1]);
|
|
|
|
|
if (!TextUtils.isEmpty(text[2]))
|
|
|
|
|
share.putExtra(Intent.EXTRA_TEXT, text[2]);
|
|
|
|
|
Intent intent = new Intent();
|
|
|
|
|
if (event) {
|
|
|
|
|
intent.setAction(Intent.ACTION_INSERT);
|
|
|
|
|
intent.setData(CalendarContract.Events.CONTENT_URI);
|
|
|
|
|
if (data.containsKey("me"))
|
|
|
|
|
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{data.get("me")});
|
|
|
|
|
if (data.containsKey("subject"))
|
|
|
|
|
intent.putExtra(CalendarContract.Events.TITLE, data.get("subject"));
|
|
|
|
|
if (data.containsKey("text"))
|
|
|
|
|
intent.putExtra(CalendarContract.Events.DESCRIPTION, data.get("text"));
|
|
|
|
|
} else {
|
|
|
|
|
intent.setAction(Intent.ACTION_SEND);
|
|
|
|
|
intent.setType("text/plain");
|
|
|
|
|
if (data.containsKey("from"))
|
|
|
|
|
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{data.get("from")});
|
|
|
|
|
if (data.containsKey("subject"))
|
|
|
|
|
intent.putExtra(Intent.EXTRA_SUBJECT, data.get("subject"));
|
|
|
|
|
if (data.containsKey("text"))
|
|
|
|
|
intent.putExtra(Intent.EXTRA_TEXT, data.get("text"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PackageManager pm = context.getPackageManager();
|
|
|
|
|
if (share.resolveActivity(pm) == null)
|
|
|
|
|
if (intent.resolveActivity(pm) == null)
|
|
|
|
|
Snackbar.make(parentFragment.getView(),
|
|
|
|
|
context.getString(R.string.title_no_viewer, share.getAction()),
|
|
|
|
|
context.getString(R.string.title_no_viewer, intent.getAction()),
|
|
|
|
|
Snackbar.LENGTH_LONG).
|
|
|
|
|
show();
|
|
|
|
|
else
|
|
|
|
|
context.startActivity(Helper.getChooser(context, share));
|
|
|
|
|
context.startActivity(Helper.getChooser(context, intent));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|