Auto raw message save/send

pull/172/head
M66B 5 years ago
parent e134122169
commit 1688ba2252

@ -970,6 +970,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
bindExpanded(message, false);
else
clearExpanded(message);
if (properties.getValue("raw_save", message.id)) {
properties.setValue("raw_save", message.id, false);
onMenuRawSave(message);
}
if (properties.getValue("raw_send", message.id)) {
properties.setValue("raw_send", message.id, false);
onMenuRawSend(message);
}
}
private void clearExpanded(TupleMessageEx message) {
@ -3129,14 +3139,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
popupMenu.getMenu().findItem(R.id.menu_show_headers).setEnabled(message.uid != null);
popupMenu.getMenu().findItem(R.id.menu_show_headers).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
popupMenu.getMenu().findItem(R.id.menu_raw_download).setEnabled(
message.uid != null && (message.raw == null || !message.raw));
popupMenu.getMenu().findItem(R.id.menu_raw_save).setEnabled(
message.uid != null && (message.raw != null && message.raw));
popupMenu.getMenu().findItem(R.id.menu_raw_send).setEnabled(
message.uid != null && (message.raw != null && message.raw));
popupMenu.getMenu().findItem(R.id.menu_raw_save).setEnabled(message.uid != null);
popupMenu.getMenu().findItem(R.id.menu_raw_send).setEnabled(message.uid != null);
popupMenu.getMenu().findItem(R.id.menu_raw_download).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
popupMenu.getMenu().findItem(R.id.menu_raw_save).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
popupMenu.getMenu().findItem(R.id.menu_raw_send).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
@ -3183,9 +3188,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
case R.id.menu_show_headers:
onMenuShowHeaders(message);
return true;
case R.id.menu_raw_download:
onMenuRawDownload(message);
return true;
case R.id.menu_raw_save:
onMenuRawSave(message);
return true;
@ -3668,7 +3670,35 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
bindExpanded(message, false);
}
private void onMenuRawDownload(TupleMessageEx message) {
private void onMenuRawSave(TupleMessageEx message) {
if (message.raw == null || !message.raw) {
properties.setValue("raw_save", message.id, true);
rawDownload(message);
} else {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(FragmentMessages.ACTION_STORE_RAW)
.putExtra("id", message.id));
}
}
private void onMenuRawSend(TupleMessageEx message) {
if (message.raw == null || !message.raw) {
properties.setValue("raw_send", message.id, true);
rawDownload(message);
} else {
File file = message.getRawFile(context);
Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file);
Intent send = new Intent(Intent.ACTION_SEND);
send.putExtra(Intent.EXTRA_STREAM, uri);
send.setType("message/rfc822");
send.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
context.startActivity(send);
}
}
private void rawDownload(TupleMessageEx message) {
Bundle args = new Bundle();
args.putLong("id", message.id);
@ -3701,7 +3731,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
protected void onExecuted(Bundle args, Void data) {
ToastEx.makeText(context, R.string.title_executing, Toast.LENGTH_LONG).show();
ToastEx.makeText(context, R.string.title_download_message, Toast.LENGTH_LONG).show();
}
@Override
@ -3711,24 +3741,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}.execute(context, owner, args, "message:raw");
}
private void onMenuRawSave(TupleMessageEx message) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(FragmentMessages.ACTION_STORE_RAW)
.putExtra("id", message.id));
}
private void onMenuRawSend(TupleMessageEx message) {
File file = message.getRawFile(context);
Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file);
Intent send = new Intent(Intent.ACTION_SEND);
send.putExtra(Intent.EXTRA_STREAM, uri);
send.setType("message/rfc822");
send.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
context.startActivity(send);
}
ItemDetailsLookup.ItemDetails<Long> getItemDetails(@NonNull MotionEvent motionEvent) {
return new ItemDetailsMessage(this);
}

@ -53,10 +53,6 @@
android:checkable="true"
android:title="@string/title_show_headers" />
<item
android:id="@+id/menu_raw_download"
android:title="@string/title_raw_download" />
<item
android:id="@+id/menu_raw_save"
android:enabled="false"

@ -613,7 +613,6 @@
<string name="title_share">Share</string>
<string name="title_print">Print</string>
<string name="title_show_headers">Show headers</string>
<string name="title_raw_download">Download raw message</string>
<string name="title_raw_save">Save raw message</string>
<string name="title_raw_send">Send as attachment</string>
<string name="title_manage_keywords">Manage keywords</string>

Loading…
Cancel
Save