mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-30 21:58:52 +02:00
Improved header highlighting
This commit is contained in:
@@ -87,7 +87,7 @@ public class ActivityDSN extends ActivityBase {
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable("uri", uri);
|
||||
|
||||
new SimpleTask<Result>() {
|
||||
new SimpleTask<Spanned>() {
|
||||
@Override
|
||||
protected void onPreExecute(Bundle args) {
|
||||
pbWait.setVisibility(View.VISIBLE);
|
||||
@@ -99,35 +99,29 @@ public class ActivityDSN extends ActivityBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Result onExecute(Context context, Bundle args) throws Throwable {
|
||||
protected Spanned onExecute(Context context, Bundle args) throws Throwable {
|
||||
Uri uri = args.getParcelable("uri");
|
||||
|
||||
NoStreamException.check(uri, context);
|
||||
|
||||
Result result = new Result();
|
||||
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
try (InputStream is = resolver.openInputStream(uri)) {
|
||||
if (is == null)
|
||||
throw new FileNotFoundException(uri.toString());
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[Helper.BUFFER_SIZE];
|
||||
int length;
|
||||
while ((length = is.read(buffer)) != -1)
|
||||
bos.write(buffer, 0, length);
|
||||
Helper.copy(is, bos);
|
||||
|
||||
String headers = MessageHelper.decodeMime(bos.toString(StandardCharsets.UTF_8.name()));
|
||||
result.headers = HtmlHelper.highlightHeaders(context,
|
||||
null, null, null, headers, false);
|
||||
String headers = bos.toString(StandardCharsets.UTF_8.name());
|
||||
headers = MessageHelper.decodeMime(headers);
|
||||
return HtmlHelper.highlightHeaders(context,
|
||||
null, null, null, headers, false, false);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, Result result) {
|
||||
tvHeaders.setText(result.headers);
|
||||
protected void onExecuted(Bundle args, Spanned result) {
|
||||
tvHeaders.setText(result);
|
||||
grpReady.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@@ -140,8 +134,4 @@ public class ActivityDSN extends ActivityBase {
|
||||
}
|
||||
}.execute(this, args, "disposition:decode");
|
||||
}
|
||||
|
||||
private class Result {
|
||||
Spanned headers;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user