mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-31 20:25:38 +00:00
Improved sharing
This commit is contained in:
parent
600b664388
commit
9c2e8526fd
2 changed files with 18 additions and 13 deletions
|
@ -315,8 +315,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
|
||||
private static final int MAX_RECIPIENTS_COMPACT = 3;
|
||||
private static final int MAX_RECIPIENTS_NORMAL = 7;
|
||||
private static final int MAX_QUOTE_LEVEL = 3;
|
||||
private static final int MAX_TRANSLATABLE_TEXT_SIZE = 50 * 1024;
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements
|
||||
View.OnClickListener,
|
||||
|
@ -5249,7 +5247,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
String link = "message://email.faircode.eu/link/#" + message.id;
|
||||
|
||||
Document document = JsoupEx.parse(file);
|
||||
HtmlHelper.truncate(document, HtmlHelper.MAX_FULL_TEXT_SIZE / 2);
|
||||
HtmlHelper.truncate(document, HtmlHelper.MAX_SHARE_TEXT_SIZE);
|
||||
|
||||
Element a = document.createElement("a");
|
||||
a.text(context.getString(R.string.app_name));
|
||||
|
@ -5442,9 +5440,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
Bundle args = new Bundle();
|
||||
args.putLong("id", message.id);
|
||||
|
||||
new SimpleTask<String>() {
|
||||
new SimpleTask<File>() {
|
||||
@Override
|
||||
protected String onExecute(Context context, Bundle args) throws IOException {
|
||||
protected File onExecute(Context context, Bundle args) throws IOException {
|
||||
Long id = args.getLong("id");
|
||||
|
||||
File file = EntityMessage.getFile(context, id);
|
||||
|
@ -5462,15 +5460,19 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
element.attr("computed", computed);
|
||||
}
|
||||
|
||||
return d.html();
|
||||
File dir = new File(context.getCacheDir(), "shared");
|
||||
if (!dir.exists())
|
||||
dir.mkdir();
|
||||
|
||||
File share = new File(dir, message.id + ".txt");
|
||||
Helper.writeText(share, d.html());
|
||||
|
||||
return share;
|
||||
}
|
||||
|
||||
@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);
|
||||
protected void onExecuted(Bundle args, File share) {
|
||||
Helper.share(context, share, "text/plain", share.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7017,7 +7019,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
String html = Helper.readText(file);
|
||||
Document d = HtmlHelper.sanitizeCompose(context, html, false);
|
||||
d.select("blockquote").remove();
|
||||
HtmlHelper.truncate(d, MAX_TRANSLATABLE_TEXT_SIZE);
|
||||
HtmlHelper.truncate(d, HtmlHelper.MAX_TRANSLATABLE_TEXT_SIZE);
|
||||
SpannableStringBuilder ssb = HtmlHelper.fromDocument(context, d, null, null);
|
||||
return ssb.toString()
|
||||
.replace("\uFFFC", "") // Object replacement character
|
||||
|
|
|
@ -131,6 +131,10 @@ public class HtmlHelper {
|
|||
static final float FONT_SMALL = 0.8f;
|
||||
static final float FONT_LARGE = 1.25f;
|
||||
|
||||
static final int MAX_FULL_TEXT_SIZE = 1024 * 1024; // characters
|
||||
static final int MAX_SHARE_TEXT_SIZE = 50 * 1024; // characters
|
||||
static final int MAX_TRANSLATABLE_TEXT_SIZE = 50 * 1024; // characters
|
||||
|
||||
private static final int DEFAULT_FONT_SIZE = 16; // pixels
|
||||
private static final int DEFAULT_FONT_SIZE_PT = 12; // points
|
||||
private static final int GRAY_THRESHOLD = Math.round(255 * 0.2f);
|
||||
|
@ -140,7 +144,6 @@ public class HtmlHelper {
|
|||
private static final int MAX_ALT = 250;
|
||||
private static final int MAX_AUTO_LINK = 250;
|
||||
private static final int MAX_FORMAT_TEXT_SIZE = 200 * 1024; // characters
|
||||
static final int MAX_FULL_TEXT_SIZE = 1024 * 1024; // characters
|
||||
private static final int SMALL_IMAGE_SIZE = 5; // pixels
|
||||
private static final int TRACKING_PIXEL_SURFACE = 25; // pixels
|
||||
private static final float[] HEADING_SIZES = {1.5f, 1.4f, 1.3f, 1.2f, 1.1f, 1f};
|
||||
|
|
Loading…
Reference in a new issue