Added send as attachment

pull/162/head
M66B 5 years ago
parent 81f22c6055
commit d9488e12e5

@ -57,9 +57,9 @@ For authorizing:
* ~~Pinch zoom text size~~
* ~~Display GIFs~~
* ~~Themes~~ (a grey light and dark theme were added because this is what most people seems to want)
* Send as attachment
* ~~Any day time condition~~ (any day doesn't really fit into the from/to date/time condition)
* ~~Send as attachment~~
* Search for settings
* Select any day for time conditions
* Widget for selected account
Anything on this list is in random order and *might* be added in the near future.

@ -94,6 +94,7 @@ import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Group;
import androidx.core.content.FileProvider;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
@ -2393,10 +2394,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
popupMenu.getMenu().findItem(R.id.menu_show_headers).setChecked(show_headers);
popupMenu.getMenu().findItem(R.id.menu_show_headers).setEnabled(message.uid != null);
popupMenu.getMenu().findItem(R.id.menu_raw).setEnabled(
message.uid != null && (message.raw == null || message.raw));
popupMenu.getMenu().findItem(R.id.menu_raw).setTitle(
message.raw == null || !message.raw ? R.string.title_raw_download : R.string.title_raw_save);
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_manage_keywords).setEnabled(message.uid != null && !message.folderReadOnly);
@ -2449,8 +2452,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
case R.id.menu_show_headers:
onMenuShowHeaders(message);
return true;
case R.id.menu_raw:
onMenuRaw(message);
case R.id.menu_raw_download:
onMenuRawDownload(message);
return true;
case R.id.menu_raw_save:
onMenuRawSave(message);
return true;
case R.id.menu_raw_send:
onMenuRawSend(message);
return true;
default:
return false;
@ -3041,46 +3050,56 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
notifyDataSetChanged();
}
private void onMenuRaw(TupleMessageEx message) {
if (message.raw == null) {
Bundle args = new Bundle();
args.putLong("id", message.id);
private void onMenuRawDownload(TupleMessageEx message) {
Bundle args = new Bundle();
args.putLong("id", message.id);
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
Long id = args.getLong("id");
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
Long id = args.getLong("id");
DB db = DB.getInstance(context);
try {
db.beginTransaction();
DB db = DB.getInstance(context);
try {
db.beginTransaction();
EntityMessage message = db.message().getMessage(id);
if (message == null)
return null;
EntityMessage message = db.message().getMessage(id);
if (message == null)
return null;
EntityOperation.queue(context, message, EntityOperation.RAW);
EntityOperation.queue(context, message, EntityOperation.RAW);
db.message().setMessageRaw(message.id, false);
db.message().setMessageRaw(message.id, false);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
return null;
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(parentFragment.getFragmentManager(), ex);
}
}.execute(context, owner, args, "message:raw");
} else {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(FragmentMessages.ACTION_STORE_RAW)
.putExtra("id", message.id));
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(parentFragment.getFragmentManager(), ex);
}
}.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");
context.startActivity(send);
}
ItemDetailsLookup.ItemDetails<Long> getItemDetails(@NonNull MotionEvent motionEvent) {

@ -54,6 +54,16 @@
android:title="@string/title_show_headers" />
<item
android:id="@+id/menu_raw"
android:id="@+id/menu_raw_download"
android:title="@string/title_raw_download" />
<item
android:id="@+id/menu_raw_save"
android:enabled="false"
android:title="@string/title_raw_save" />
<item
android:id="@+id/menu_raw_send"
android:enabled="false"
android:title="@string/title_raw_send" />
</menu>

@ -478,6 +478,7 @@
<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>
<string name="title_add_keyword">Add keyword</string>
<string name="title_show_inline">Show inline attachments</string>

Loading…
Cancel
Save