Added forward raw

pull/146/head
M66B 7 years ago
parent e209df30c6
commit b968dacf15

@ -973,7 +973,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
.show(); .show();
} }
private void onForward(final ActionData data) { private void onForward(final ActionData data, final boolean raw) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", data.message.id); args.putLong("id", data.message.id);
@ -992,7 +992,8 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
protected void onLoaded(Bundle args, Boolean available) { protected void onLoaded(Bundle args, Boolean available) {
final Intent forward = new Intent(context, ActivityCompose.class) final Intent forward = new Intent(context, ActivityCompose.class)
.putExtra("action", "forward") .putExtra("action", "forward")
.putExtra("reference", data.message.id); .putExtra("reference", data.message.id)
.putExtra("raw", raw);
if (available) if (available)
context.startActivity(forward); context.startActivity(forward);
else 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).setEnabled(data.message.content);
popupMenu.getMenu().findItem(R.id.menu_forward).setVisible(!inOutbox); 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).setEnabled(data.message.content);
popupMenu.getMenu().findItem(R.id.menu_reply_all).setVisible(!inOutbox); popupMenu.getMenu().findItem(R.id.menu_reply_all).setVisible(!inOutbox);
@ -1217,7 +1221,10 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
onJunk(data); onJunk(data);
return true; return true;
case R.id.menu_forward: case R.id.menu_forward:
onForward(data); onForward(data, false);
return true;
case R.id.menu_forward_raw:
onForward(data, true);
return true; return true;
case R.id.menu_reply_all: case R.id.menu_reply_all:
onReplyAll(data); onReplyAll(data);

@ -23,8 +23,10 @@ import android.content.Context;
import android.util.Log; import android.util.Log;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -81,6 +83,22 @@ public class EntityAttachment {
return new File(dir, Long.toString(id)); 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 { void download(Context context, DB db) throws MessagingException, IOException {
// Build filename // Build filename
File file = EntityAttachment.getFile(context, this.id); 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("id", getArguments().getLong("id", -1));
args.putLong("account", getArguments().getLong("account", -1)); args.putLong("account", getArguments().getLong("account", -1));
args.putLong("reference", getArguments().getLong("reference", -1)); args.putLong("reference", getArguments().getLong("reference", -1));
args.putBoolean("raw", getArguments().getBoolean("raw", false));
args.putLong("answer", getArguments().getLong("answer", -1)); args.putLong("answer", getArguments().getLong("answer", -1));
args.putString("to", getArguments().getString("to")); args.putString("to", getArguments().getString("to"));
args.putString("cc", getArguments().getString("cc")); args.putString("cc", getArguments().getString("cc"));
@ -1002,6 +1003,7 @@ public class FragmentCompose extends FragmentEx {
String action = args.getString("action"); String action = args.getString("action");
long id = args.getLong("id", -1); long id = args.getLong("id", -1);
long reference = args.getLong("reference", -1); long reference = args.getLong("reference", -1);
boolean raw = args.getBoolean("raw", false);
long answer = args.getLong("answer", -1); long answer = args.getLong("answer", -1);
boolean pro = Helper.isPro(getContext()); boolean pro = Helper.isPro(getContext());
@ -1225,6 +1227,30 @@ public class FragmentCompose extends FragmentEx {
File target = EntityAttachment.getFile(context, copy.id); File target = EntityAttachment.getFile(context, copy.id);
Helper.copy(source, target); 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); EntityOperation.queue(db, result.draft, EntityOperation.ADD);

@ -8,6 +8,10 @@
android:id="@+id/menu_forward" android:id="@+id/menu_forward"
android:title="@string/title_forward" /> android:title="@string/title_forward" />
<item
android:id="@+id/menu_forward_raw"
android:title="@string/title_forward_raw" />
<item <item
android:id="@+id/menu_reply_all" android:id="@+id/menu_reply_all"
android:title="@string/title_reply_all" /> android:title="@string/title_reply_all" />

@ -201,6 +201,7 @@
<string name="title_flag">Add star</string> <string name="title_flag">Add star</string>
<string name="title_unflag">Remove star</string> <string name="title_unflag">Remove star</string>
<string name="title_forward">Forward</string> <string name="title_forward">Forward</string>
<string name="title_forward_raw">Forward raw</string>
<string name="title_reply_all">Reply to all</string> <string name="title_reply_all">Reply to all</string>
<string name="title_show_headers">Show headers</string> <string name="title_show_headers">Show headers</string>
<string name="title_show_html">Show original</string> <string name="title_show_html">Show original</string>

Loading…
Cancel
Save