mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-08 10:03:51 +02:00
Added forward raw
This commit is contained in:
@@ -973,7 +973,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
||||
.show();
|
||||
}
|
||||
|
||||
private void onForward(final ActionData data) {
|
||||
private void onForward(final ActionData data, final boolean raw) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", data.message.id);
|
||||
|
||||
@@ -992,7 +992,8 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
||||
protected void onLoaded(Bundle args, Boolean available) {
|
||||
final Intent forward = new Intent(context, ActivityCompose.class)
|
||||
.putExtra("action", "forward")
|
||||
.putExtra("reference", data.message.id);
|
||||
.putExtra("reference", data.message.id)
|
||||
.putExtra("raw", raw);
|
||||
if (available)
|
||||
context.startActivity(forward);
|
||||
else
|
||||
@@ -1193,6 +1194,9 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
||||
popupMenu.getMenu().findItem(R.id.menu_forward).setEnabled(data.message.content);
|
||||
popupMenu.getMenu().findItem(R.id.menu_forward).setVisible(!inOutbox);
|
||||
|
||||
popupMenu.getMenu().findItem(R.id.menu_forward_raw).setVisible(
|
||||
data.message.content && data.message.headers != null && !inOutbox);
|
||||
|
||||
popupMenu.getMenu().findItem(R.id.menu_reply_all).setEnabled(data.message.content);
|
||||
popupMenu.getMenu().findItem(R.id.menu_reply_all).setVisible(!inOutbox);
|
||||
|
||||
@@ -1217,7 +1221,10 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
||||
onJunk(data);
|
||||
return true;
|
||||
case R.id.menu_forward:
|
||||
onForward(data);
|
||||
onForward(data, false);
|
||||
return true;
|
||||
case R.id.menu_forward_raw:
|
||||
onForward(data, true);
|
||||
return true;
|
||||
case R.id.menu_reply_all:
|
||||
onReplyAll(data);
|
||||
|
||||
@@ -23,8 +23,10 @@ import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -81,6 +83,22 @@ public class EntityAttachment {
|
||||
return new File(dir, Long.toString(id));
|
||||
}
|
||||
|
||||
void write(Context context, String body) throws IOException {
|
||||
File file = getFile(context, id);
|
||||
BufferedWriter out = null;
|
||||
try {
|
||||
out = new BufferedWriter(new FileWriter(file));
|
||||
out.write(body == null ? "" : body);
|
||||
} finally {
|
||||
if (out != null)
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(Helper.TAG, e + "\n" + Log.getStackTraceString(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void download(Context context, DB db) throws MessagingException, IOException {
|
||||
// Build filename
|
||||
File file = EntityAttachment.getFile(context, this.id);
|
||||
|
||||
@@ -388,6 +388,7 @@ public class FragmentCompose extends FragmentEx {
|
||||
args.putLong("id", getArguments().getLong("id", -1));
|
||||
args.putLong("account", getArguments().getLong("account", -1));
|
||||
args.putLong("reference", getArguments().getLong("reference", -1));
|
||||
args.putBoolean("raw", getArguments().getBoolean("raw", false));
|
||||
args.putLong("answer", getArguments().getLong("answer", -1));
|
||||
args.putString("to", getArguments().getString("to"));
|
||||
args.putString("cc", getArguments().getString("cc"));
|
||||
@@ -1002,6 +1003,7 @@ public class FragmentCompose extends FragmentEx {
|
||||
String action = args.getString("action");
|
||||
long id = args.getLong("id", -1);
|
||||
long reference = args.getLong("reference", -1);
|
||||
boolean raw = args.getBoolean("raw", false);
|
||||
long answer = args.getLong("answer", -1);
|
||||
boolean pro = Helper.isPro(getContext());
|
||||
|
||||
@@ -1225,6 +1227,30 @@ public class FragmentCompose extends FragmentEx {
|
||||
File target = EntityAttachment.getFile(context, copy.id);
|
||||
Helper.copy(source, target);
|
||||
}
|
||||
|
||||
if (raw) {
|
||||
EntityAttachment headers = new EntityAttachment();
|
||||
headers.message = result.draft.id;
|
||||
headers.sequence = ++sequence;
|
||||
headers.name = "headers.txt";
|
||||
headers.type = "text/plan";
|
||||
headers.available = true;
|
||||
headers.id = db.attachment().insertAttachment(headers);
|
||||
|
||||
headers.write(context, ref.headers);
|
||||
|
||||
EntityAttachment content = new EntityAttachment();
|
||||
content.message = result.draft.id;
|
||||
content.sequence = ++sequence;
|
||||
content.name = "content.html";
|
||||
content.type = "text/html";
|
||||
content.available = true;
|
||||
content.id = db.attachment().insertAttachment(content);
|
||||
|
||||
File csource = EntityMessage.getFile(context, ref.id);
|
||||
File ctarget = EntityAttachment.getFile(context, content.id);
|
||||
Helper.copy(csource, ctarget);
|
||||
}
|
||||
}
|
||||
|
||||
EntityOperation.queue(db, result.draft, EntityOperation.ADD);
|
||||
|
||||
Reference in New Issue
Block a user