mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Cleanup
This commit is contained in:
parent
af01f4173d
commit
82173bfe06
11 changed files with 22 additions and 41 deletions
|
@ -179,7 +179,7 @@ public class ActivityEML extends ActivityBase {
|
|||
if (html != null) {
|
||||
Document parsed = JsoupEx.parse(html);
|
||||
Document document = HtmlHelper.sanitizeView(context, parsed, false);
|
||||
result.body = HtmlHelper.fromDocument(context, document, true, null, null);
|
||||
result.body = HtmlHelper.fromDocument(context, document, null, null);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -190,7 +190,7 @@ public class ActivitySignature extends ActivityBase {
|
|||
else if (etText.getRaw())
|
||||
etText.setText(html);
|
||||
else
|
||||
etText.setText(HtmlHelper.fromHtml(html, false, new Html.ImageGetter() {
|
||||
etText.setText(HtmlHelper.fromHtml(html, new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
return ImageHelper.decodeImage(ActivitySignature.this, -1, source, true, 0, 1.0f, etText);
|
||||
|
|
|
@ -2199,7 +2199,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
|
||||
// Draw images
|
||||
SpannableStringBuilder ssb = HtmlHelper.fromDocument(context, document, true, new Html.ImageGetter() {
|
||||
SpannableStringBuilder ssb = HtmlHelper.fromDocument(context, document, new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
Drawable drawable = ImageHelper.decodeImage(context, message.id, source, show_images, zoom, scale, tvBody);
|
||||
|
|
|
@ -3720,7 +3720,7 @@ class Core {
|
|||
|
||||
// Device
|
||||
builder.setStyle(new NotificationCompat.BigTextStyle()
|
||||
.bigText(HtmlHelper.fromHtml(sb.toString(), true, context))
|
||||
.bigText(HtmlHelper.fromHtml(sb.toString(), context))
|
||||
.setSummaryText(title));
|
||||
}
|
||||
|
||||
|
@ -4058,7 +4058,7 @@ class Core {
|
|||
|
||||
if (sbm.length() > 0) {
|
||||
NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle()
|
||||
.bigText(HtmlHelper.fromHtml(sbm.toString(), true, context));
|
||||
.bigText(HtmlHelper.fromHtml(sbm.toString(), context));
|
||||
if (!TextUtils.isEmpty(message.subject))
|
||||
bigText.setSummaryText(message.subject);
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ public class EditTextCompose extends FixedEditText {
|
|||
ssb = new SpannableStringBuilder(html);
|
||||
else {
|
||||
Document document = HtmlHelper.sanitizeCompose(context, html, false);
|
||||
Spanned paste = HtmlHelper.fromDocument(context, document, true, new Html.ImageGetter() {
|
||||
Spanned paste = HtmlHelper.fromDocument(context, document, new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
return ImageHelper.decodeImage(context,
|
||||
|
|
|
@ -1333,7 +1333,7 @@ public class FragmentAccount extends FragmentBase {
|
|||
btnSupport.setVisibility(View.VISIBLE);
|
||||
|
||||
if (provider != null && provider.documentation != null) {
|
||||
tvInstructions.setText(HtmlHelper.fromHtml(provider.documentation.toString(), true, getContext()));
|
||||
tvInstructions.setText(HtmlHelper.fromHtml(provider.documentation.toString(), getContext()));
|
||||
tvInstructions.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ public class FragmentAnswer extends FragmentBase {
|
|||
if (answer == null)
|
||||
etText.setText(null);
|
||||
else
|
||||
etText.setText(HtmlHelper.fromHtml(answer.text, false, new Html.ImageGetter() {
|
||||
etText.setText(HtmlHelper.fromHtml(answer.text, new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
return ImageHelper.decodeImage(getContext(), -1, source, true, 0, 1.0f, etText);
|
||||
|
@ -471,7 +471,7 @@ public class FragmentAnswer extends FragmentBase {
|
|||
getString(R.string.title_answer_template_name) +
|
||||
"<br>" +
|
||||
getString(R.string.title_answer_template_email) +
|
||||
"</p>", false, getContext());
|
||||
"</p>", getContext());
|
||||
|
||||
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_ask_again, null);
|
||||
TextView tvMessage = dview.findViewById(R.id.tvMessage);
|
||||
|
|
|
@ -1670,7 +1670,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
|
||||
String html = EntityAnswer.replacePlaceholders(answer.text, to);
|
||||
|
||||
Spanned spanned = HtmlHelper.fromHtml(html, false, new Html.ImageGetter() {
|
||||
Spanned spanned = HtmlHelper.fromHtml(html, new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
return ImageHelper.decodeImage(getContext(), working, source, true, zoom, 1.0f, etBody);
|
||||
|
@ -2248,7 +2248,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
args.putInt("start", start);
|
||||
|
||||
// TODO: double conversion
|
||||
return HtmlHelper.fromHtml(HtmlHelper.toHtml(s, context), false, new Html.ImageGetter() {
|
||||
return HtmlHelper.fromHtml(HtmlHelper.toHtml(s, context), new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
return ImageHelper.decodeImage(context, id, source, true, zoom, 1.0f, etBody);
|
||||
|
@ -5024,7 +5024,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
Elements ref = doc.select("div[fairemail=reference]");
|
||||
ref.remove();
|
||||
|
||||
Spanned spannedBody = HtmlHelper.fromDocument(context, doc, false, new Html.ImageGetter() {
|
||||
Spanned spannedBody = HtmlHelper.fromDocument(context, doc, new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
return ImageHelper.decodeImage(context, id, source, true, zoom, 1.0f, etBody);
|
||||
|
@ -5052,7 +5052,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
if (!ref.isEmpty()) {
|
||||
Document dref = JsoupEx.parse(ref.outerHtml());
|
||||
Document quote = HtmlHelper.sanitizeView(context, dref, show_images);
|
||||
spannedRef = HtmlHelper.fromDocument(context, quote, true,
|
||||
spannedRef = HtmlHelper.fromDocument(context, quote,
|
||||
new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
|
@ -5155,7 +5155,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
|
||||
Spanned signature = null;
|
||||
if (identity != null && !TextUtils.isEmpty(identity.signature))
|
||||
signature = HtmlHelper.fromHtml(identity.signature, false, new Html.ImageGetter() {
|
||||
signature = HtmlHelper.fromHtml(identity.signature, new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
return ImageHelper.decodeImage(getContext(), working, source, true, 0, 1.0f, tvSignature);
|
||||
|
|
|
@ -972,7 +972,7 @@ public class FragmentIdentity extends FragmentBase {
|
|||
btnSupport.setVisibility(View.VISIBLE);
|
||||
|
||||
if (provider != null && provider.documentation != null) {
|
||||
tvInstructions.setText(HtmlHelper.fromHtml(provider.documentation.toString(), true, getContext()));
|
||||
tvInstructions.setText(HtmlHelper.fromHtml(provider.documentation.toString(), getContext()));
|
||||
tvInstructions.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
|
|
@ -511,7 +511,7 @@ public class FragmentQuickSetup extends FragmentBase {
|
|||
btnSupport.setVisibility(View.VISIBLE);
|
||||
|
||||
if (args.containsKey("documentation")) {
|
||||
tvInstructions.setText(HtmlHelper.fromHtml(args.getString("documentation"), true, getContext()));
|
||||
tvInstructions.setText(HtmlHelper.fromHtml(args.getString("documentation"), getContext()));
|
||||
tvInstructions.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
|
|
@ -1851,7 +1851,7 @@ public class HtmlHelper {
|
|||
|
||||
truncate(d, true);
|
||||
|
||||
SpannableStringBuilder ssb = fromDocument(context, d, true, null, null);
|
||||
SpannableStringBuilder ssb = fromDocument(context, d, null, null);
|
||||
|
||||
for (URLSpan span : ssb.getSpans(0, ssb.length(), URLSpan.class)) {
|
||||
String url = span.getURL();
|
||||
|
@ -2000,7 +2000,7 @@ public class HtmlHelper {
|
|||
}
|
||||
|
||||
static SpannableStringBuilder fromDocument(
|
||||
Context context, @NonNull Document document, boolean compress,
|
||||
Context context, @NonNull Document document,
|
||||
@Nullable Html.ImageGetter imageGetter, @Nullable Html.TagHandler tagHandler) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean debug = prefs.getBoolean("debug", false);
|
||||
|
@ -2468,25 +2468,6 @@ public class HtmlHelper {
|
|||
else
|
||||
Log.e("Invalid span " + start + "..." + end + " len=" + len + " type=" + span.getClass().getName());
|
||||
}
|
||||
|
||||
private void newline(int index) {
|
||||
int count = 0;
|
||||
|
||||
if (compress) {
|
||||
int i = Math.min(index, ssb.length() - 1);
|
||||
while (i >= 0) {
|
||||
char kar = ssb.charAt(i);
|
||||
if (kar == '\n')
|
||||
count++;
|
||||
else if (kar != ' ' && kar != '\u00A0')
|
||||
break;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
if (count < 2)
|
||||
ssb.insert(index, "\n");
|
||||
}
|
||||
}, document.body());
|
||||
|
||||
if (debug)
|
||||
|
@ -2529,13 +2510,13 @@ public class HtmlHelper {
|
|||
return ssb;
|
||||
}
|
||||
|
||||
static Spanned fromHtml(@NonNull String html, boolean compress, Context context) {
|
||||
return fromHtml(html, compress, null, null, context);
|
||||
static Spanned fromHtml(@NonNull String html, Context context) {
|
||||
return fromHtml(html, null, null, context);
|
||||
}
|
||||
|
||||
static Spanned fromHtml(@NonNull String html, boolean compress, @Nullable Html.ImageGetter imageGetter, @Nullable Html.TagHandler tagHandler, Context context) {
|
||||
static Spanned fromHtml(@NonNull String html, @Nullable Html.ImageGetter imageGetter, @Nullable Html.TagHandler tagHandler, Context context) {
|
||||
Document document = JsoupEx.parse(html);
|
||||
return fromDocument(context, document, compress, imageGetter, tagHandler);
|
||||
return fromDocument(context, document, imageGetter, tagHandler);
|
||||
}
|
||||
|
||||
static String toHtml(Spanned spanned, Context context) {
|
||||
|
|
Loading…
Reference in a new issue