Share as HTML (debug only)

pull/199/head
M66B 3 years ago
parent 5aed62a256
commit 382d4b85b7

@ -4291,6 +4291,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
popupMenu.getMenu().findItem(R.id.menu_show_headers).setEnabled(message.uid != null ||
(message.accountProtocol == EntityAccount.TYPE_POP && message.headers != null));
popupMenu.getMenu().findItem(R.id.menu_share_as_html).setEnabled(message.content && BuildConfig.DEBUG);
popupMenu.getMenu().findItem(R.id.menu_raw_save).setEnabled(message.uid != null);
popupMenu.getMenu().findItem(R.id.menu_raw_send).setEnabled(message.uid != null);
@ -4371,6 +4373,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} else if (itemId == R.id.menu_show_headers) {
onMenuShowHeaders(message);
return true;
} else if (itemId == R.id.menu_share_as_html) {
onMenuShareHtml(message);
return true;
} else if (itemId == R.id.menu_raw_save) {
onMenuRawSave(message);
return true;
@ -5114,6 +5119,36 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
}
private void onMenuShareHtml(TupleMessageEx message) {
Bundle args = new Bundle();
args.putLong("id", message.id);
new SimpleTask<String>() {
@Override
protected String onExecute(Context context, Bundle args) throws IOException {
Long id = args.getLong("id");
File file = EntityMessage.getFile(context, id);
Document d = JsoupEx.parse(file);
return d.html();
}
@Override
protected void onExecuted(Bundle args, String html) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, html);
context.startActivity(intent);
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}
}.execute(context, owner, args, "message:headers");
}
private void onMenuRawSave(TupleMessageEx message) {
if (message.raw == null || !message.raw) {
properties.setValue("raw_save", message.id, true);

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M9.17,6H4v12l16,0V8h-8.83L9.17,6z"
android:strokeAlpha="0.3"
android:fillAlpha="0.3"/>
<path
android:fillColor="@android:color/white"
android:pathData="M20,6h-8l-2,-2H4C2.9,4 2.01,4.9 2.01,6L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V8C22,6.9 21.1,6 20,6zM20,18L4,18V6h5.17l2,2H20V18zM18,12H6v-2h12V12zM14,16H6v-2h8V16z"/>
</vector>

@ -109,6 +109,11 @@
android:icon="@drawable/twotone_info_24"
android:title="@string/title_show_headers" />
<item
android:id="@+id/menu_share_as_html"
android:icon="@drawable/twotone_source_24"
android:title="@string/title_share_as_html" />
<item
android:id="@+id/menu_raw_save"
android:enabled="false"

@ -913,6 +913,7 @@
<string name="title_print_images">Print images</string>
<string name="title_print_images_remark">Downloading images might take some time</string>
<string name="title_show_headers">Show headers</string>
<string name="title_share_as_html">Share as HTML</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