Fixed shared spanned text

This commit is contained in:
M66B 2019-01-25 14:40:46 +00:00
parent 2d98588800
commit ad9c675fa4
2 changed files with 39 additions and 2 deletions

View File

@ -22,6 +22,8 @@ package eu.faircode.email;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.Html;
import android.text.Spanned;
import android.text.TextUtils;
import android.view.MenuItem;
@ -62,6 +64,8 @@ public class ActivityCompose extends ActivityBilling implements FragmentManager.
Intent.ACTION_SENDTO.equals(action) ||
Intent.ACTION_SEND.equals(action) ||
Intent.ACTION_SEND_MULTIPLE.equals(action)) {
Log.logExtras(intent);
args = new Bundle();
args.putString("action", "new");
args.putLong("account", -1);
@ -122,9 +126,13 @@ public class ActivityCompose extends ActivityBilling implements FragmentManager.
if (html != null)
args.putString("body", Jsoup.clean(html, Whitelist.relaxed()));
} else if (intent.hasExtra(Intent.EXTRA_TEXT)) {
String body = intent.getStringExtra(Intent.EXTRA_TEXT);
CharSequence body = intent.getCharSequenceExtra(Intent.EXTRA_TEXT);
if (body != null)
args.putString("body", body);
if (body instanceof Spanned)
args.putString("body",
Jsoup.clean(Html.toHtml((Spanned) body), Whitelist.relaxed()));
else
args.putString("body", body.toString()); // TODO: clean?
}
if (intent.hasExtra(Intent.EXTRA_STREAM))

View File

@ -19,6 +19,12 @@ package eu.faircode.email;
Copyright 2018-2019 by Marcel Bokhorst (M66B)
*/
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import java.util.Set;
public class Log {
static final String TAG = "fairemail";
@ -52,4 +58,27 @@ public class Log {
public static int e(String prefix, Throwable ex) {
return android.util.Log.e(TAG, prefix + " " + ex + "\n" + android.util.Log.getStackTraceString(ex));
}
public static void logExtras(Intent intent) {
if (intent != null)
logBundle(intent.getExtras());
}
public static void logBundle(Bundle data) {
if (data != null) {
Set<String> keys = data.keySet();
StringBuilder stringBuilder = new StringBuilder();
for (String key : keys) {
Object value = data.get(key);
if (value instanceof String[])
value = TextUtils.join(", ", (String[]) value);
stringBuilder.append(key)
.append("=")
.append(value)
.append(value == null ? "" : " (" + value.getClass().getSimpleName() + ")")
.append("\r\n");
}
i(stringBuilder.toString());
}
}
}