mirror of https://github.com/M66B/FairEmail.git
Removed inline original view
This commit is contained in:
parent
0d7332b614
commit
65c84c7b46
|
@ -76,7 +76,6 @@ import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.widget.ToggleButton;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
@ -171,7 +170,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
private boolean preview;
|
private boolean preview;
|
||||||
private boolean attachments_alt;
|
private boolean attachments_alt;
|
||||||
private boolean monospaced;
|
private boolean monospaced;
|
||||||
private boolean autohtml;
|
|
||||||
private boolean autoimages;
|
private boolean autoimages;
|
||||||
private boolean authentication;
|
private boolean authentication;
|
||||||
private boolean debug;
|
private boolean debug;
|
||||||
|
@ -198,7 +196,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder implements
|
public class ViewHolder extends RecyclerView.ViewHolder implements
|
||||||
View.OnClickListener,
|
View.OnClickListener,
|
||||||
CompoundButton.OnCheckedChangeListener,
|
|
||||||
BottomNavigationView.OnNavigationItemSelectedListener {
|
BottomNavigationView.OnNavigationItemSelectedListener {
|
||||||
private View view;
|
private View view;
|
||||||
private View vwColor;
|
private View vwColor;
|
||||||
|
@ -267,11 +264,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
private BottomNavigationView bnvActions;
|
private BottomNavigationView bnvActions;
|
||||||
|
|
||||||
private ToggleButton tbHtml;
|
|
||||||
private ImageButton ibImages;
|
private ImageButton ibImages;
|
||||||
private ImageButton ibFull;
|
private ImageButton ibFull;
|
||||||
private TextView tvBody;
|
private TextView tvBody;
|
||||||
private View vwBody;
|
|
||||||
private ContentLoadingProgressBar pbBody;
|
private ContentLoadingProgressBar pbBody;
|
||||||
private TextView tvNoInternetBody;
|
private TextView tvNoInternetBody;
|
||||||
|
|
||||||
|
@ -404,11 +399,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
bnvActions.setLayoutParams(lparam);
|
bnvActions.setLayoutParams(lparam);
|
||||||
}
|
}
|
||||||
|
|
||||||
tbHtml = vsBody.findViewById(R.id.tbHtml);
|
|
||||||
ibImages = vsBody.findViewById(R.id.ibImages);
|
ibImages = vsBody.findViewById(R.id.ibImages);
|
||||||
ibFull = vsBody.findViewById(R.id.ibFull);
|
ibFull = vsBody.findViewById(R.id.ibFull);
|
||||||
tvBody = vsBody.findViewById(R.id.tvBody);
|
tvBody = vsBody.findViewById(R.id.tvBody);
|
||||||
vwBody = vsBody.findViewById(R.id.vwBody);
|
|
||||||
pbBody = vsBody.findViewById(R.id.pbBody);
|
pbBody = vsBody.findViewById(R.id.pbBody);
|
||||||
tvNoInternetBody = vsBody.findViewById(R.id.tvNoInternetBody);
|
tvNoInternetBody = vsBody.findViewById(R.id.tvNoInternetBody);
|
||||||
|
|
||||||
|
@ -426,6 +419,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
grpCalendarResponse = vsBody.findViewById(R.id.grpCalendarResponse);
|
grpCalendarResponse = vsBody.findViewById(R.id.grpCalendarResponse);
|
||||||
grpAttachments = attachments.findViewById(R.id.grpAttachments);
|
grpAttachments = attachments.findViewById(R.id.grpAttachments);
|
||||||
grpImages = vsBody.findViewById(R.id.grpImages);
|
grpImages = vsBody.findViewById(R.id.grpImages);
|
||||||
|
|
||||||
|
unwire();
|
||||||
|
wire();
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect getItemRect() {
|
Rect getItemRect() {
|
||||||
|
@ -463,7 +459,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
btnDownloadAttachments.setOnClickListener(this);
|
btnDownloadAttachments.setOnClickListener(this);
|
||||||
btnSaveAttachments.setOnClickListener(this);
|
btnSaveAttachments.setOnClickListener(this);
|
||||||
|
|
||||||
tbHtml.setOnCheckedChangeListener(this);
|
|
||||||
ibImages.setOnClickListener(this);
|
ibImages.setOnClickListener(this);
|
||||||
ibFull.setOnClickListener(this);
|
ibFull.setOnClickListener(this);
|
||||||
|
|
||||||
|
@ -494,7 +489,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
btnDownloadAttachments.setOnClickListener(null);
|
btnDownloadAttachments.setOnClickListener(null);
|
||||||
btnSaveAttachments.setOnClickListener(null);
|
btnSaveAttachments.setOnClickListener(null);
|
||||||
|
|
||||||
tbHtml.setOnCheckedChangeListener(null);
|
|
||||||
ibImages.setOnClickListener(null);
|
ibImages.setOnClickListener(null);
|
||||||
ibFull.setOnClickListener(null);
|
ibFull.setOnClickListener(null);
|
||||||
|
|
||||||
|
@ -748,9 +742,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
bindContactInfo(info, message);
|
bindContactInfo(info, message);
|
||||||
|
|
||||||
if (message.avatar != null) {
|
if (message.avatar != null) {
|
||||||
if (autohtml && hasWebView)
|
|
||||||
properties.setValue("html", message.id, true);
|
|
||||||
|
|
||||||
if (autoimages)
|
if (autoimages)
|
||||||
properties.setValue("images", message.id, true);
|
properties.setValue("images", message.id, true);
|
||||||
}
|
}
|
||||||
|
@ -762,7 +753,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
else {
|
else {
|
||||||
clearExpanded();
|
clearExpanded();
|
||||||
properties.setBody(message.id, null);
|
properties.setBody(message.id, null);
|
||||||
properties.setHtml(message.id, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -826,11 +816,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
bnvActions.setVisibility(View.GONE);
|
bnvActions.setVisibility(View.GONE);
|
||||||
|
|
||||||
tbHtml.setVisibility(View.GONE);
|
|
||||||
ibImages.setVisibility(View.GONE);
|
ibImages.setVisibility(View.GONE);
|
||||||
ibFull.setVisibility(View.GONE);
|
ibFull.setVisibility(View.GONE);
|
||||||
tvBody.setVisibility(View.GONE);
|
tvBody.setVisibility(View.GONE);
|
||||||
vwBody.setVisibility(View.GONE);
|
|
||||||
pbBody.setVisibility(View.GONE);
|
pbBody.setVisibility(View.GONE);
|
||||||
tvNoInternetBody.setVisibility(View.GONE);
|
tvNoInternetBody.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -858,7 +846,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
boolean show_addresses = !properties.getValue("addresses", message.id);
|
boolean show_addresses = !properties.getValue("addresses", message.id);
|
||||||
boolean show_headers = properties.getValue("headers", message.id);
|
boolean show_headers = properties.getValue("headers", message.id);
|
||||||
boolean show_html = properties.getValue("html", message.id);
|
|
||||||
|
|
||||||
if (compact) {
|
if (compact) {
|
||||||
tvFrom.setSingleLine(false);
|
tvFrom.setSingleLine(false);
|
||||||
|
@ -893,17 +880,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
for (int i = 0; i < bnvActions.getMenu().size(); i++)
|
for (int i = 0; i < bnvActions.getMenu().size(); i++)
|
||||||
bnvActions.getMenu().getItem(i).setVisible(false);
|
bnvActions.getMenu().getItem(i).setVisible(false);
|
||||||
|
|
||||||
tbHtml.setChecked(show_html);
|
|
||||||
tbHtml.setVisibility(hasWebView ? View.INVISIBLE : View.GONE);
|
|
||||||
ibImages.setVisibility(View.INVISIBLE);
|
ibImages.setVisibility(View.INVISIBLE);
|
||||||
ibFull.setVisibility(show_html ? View.INVISIBLE : View.GONE);
|
ibFull.setVisibility(hasWebView ? View.INVISIBLE : View.GONE);
|
||||||
|
|
||||||
if (textSize != 0)
|
if (textSize != 0)
|
||||||
tvBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
tvBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
||||||
|
|
||||||
tvBody.setTypeface(monospaced ? Typeface.MONOSPACE : Typeface.DEFAULT);
|
tvBody.setTypeface(monospaced ? Typeface.MONOSPACE : Typeface.DEFAULT);
|
||||||
tvBody.setVisibility(!show_html ? View.INVISIBLE : View.GONE);
|
tvBody.setVisibility(View.INVISIBLE);
|
||||||
vwBody.setVisibility(show_html ? View.INVISIBLE : View.GONE);
|
|
||||||
|
|
||||||
// Addresses
|
// Addresses
|
||||||
ivExpanderAddress.setImageLevel(show_addresses ? 0 /* less */ : 1 /* more */);
|
ivExpanderAddress.setImageLevel(show_addresses ? 0 /* less */ : 1 /* more */);
|
||||||
|
@ -1080,9 +1064,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
pbBody.setVisibility(suitable || message.content ? View.VISIBLE : View.GONE);
|
pbBody.setVisibility(suitable || message.content ? View.VISIBLE : View.GONE);
|
||||||
tvNoInternetBody.setVisibility(suitable || message.content ? View.GONE : View.VISIBLE);
|
tvNoInternetBody.setVisibility(suitable || message.content ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
if (show_html)
|
|
||||||
onShowHtmlConfirmed(message);
|
|
||||||
else {
|
|
||||||
Spanned body = properties.getBody(message.id);
|
Spanned body = properties.getBody(message.id);
|
||||||
tvBody.setText(body);
|
tvBody.setText(body);
|
||||||
tvBody.setMovementMethod(null);
|
tvBody.setMovementMethod(null);
|
||||||
|
@ -1090,7 +1071,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
showText(message);
|
showText(message);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void bindAttachments(final TupleMessageEx message, @Nullable List<EntityAttachment> attachments) {
|
private void bindAttachments(final TupleMessageEx message, @Nullable List<EntityAttachment> attachments) {
|
||||||
if (attachments == null)
|
if (attachments == null)
|
||||||
|
@ -1258,10 +1238,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
adapterImage.set(images);
|
adapterImage.set(images);
|
||||||
grpImages.setVisibility(images.size() > 0 ? View.VISIBLE : View.GONE);
|
grpImages.setVisibility(images.size() > 0 ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
boolean show_html = properties.getValue("html", message.id);
|
|
||||||
if (show_html)
|
|
||||||
onShowHtmlConfirmed(message);
|
|
||||||
else
|
|
||||||
showText(message);
|
showText(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1421,18 +1397,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
TupleMessageEx message = getMessage();
|
|
||||||
if (message == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (isChecked)
|
|
||||||
onShowHtml(message);
|
|
||||||
else
|
|
||||||
onHideHtml(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onShowSnoozed(TupleMessageEx message) {
|
private void onShowSnoozed(TupleMessageEx message) {
|
||||||
if (message.ui_snoozed != null) {
|
if (message.ui_snoozed != null) {
|
||||||
DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.MEDIUM, SimpleDateFormat.SHORT);
|
DateFormat df = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.MEDIUM, SimpleDateFormat.SHORT);
|
||||||
|
@ -1721,11 +1685,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
.putExtra("id", message.id));
|
.putExtra("id", message.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onShowHtml(final TupleMessageEx message) {
|
private void onShowFull(final TupleMessageEx message) {
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
if (properties.getValue("confirmed", message.id) ||
|
if (properties.getValue("confirmed", message.id) ||
|
||||||
prefs.getBoolean("show_html_confirmed", false)) {
|
prefs.getBoolean("show_html_confirmed", false)) {
|
||||||
onShowHtmlConfirmed(message);
|
onShowFullConfirmed(message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1743,79 +1707,24 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
properties.setValue("confirmed", message.id, true);
|
properties.setValue("confirmed", message.id, true);
|
||||||
if (cbNotAgain.isChecked())
|
if (cbNotAgain.isChecked())
|
||||||
prefs.edit().putBoolean("show_html_confirmed", true).apply();
|
prefs.edit().putBoolean("show_html_confirmed", true).apply();
|
||||||
onShowHtmlConfirmed(message);
|
onShowFullConfirmed(message);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
tbHtml.setChecked(false);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
|
||||||
@Override
|
|
||||||
public void onCancel(DialogInterface dialog) {
|
|
||||||
tbHtml.setChecked(false);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
private void onShowFullConfirmed(TupleMessageEx message) {
|
||||||
private void onShowHtmlConfirmed(final TupleMessageEx message) {
|
|
||||||
properties.setValue("html", message.id, true);
|
|
||||||
|
|
||||||
boolean show_images = properties.getValue("images", message.id);
|
|
||||||
|
|
||||||
tbHtml.setVisibility(View.VISIBLE);
|
|
||||||
ibFull.setVisibility(View.INVISIBLE);
|
|
||||||
tvBody.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
// For performance reasons the WebView is created when needed only
|
|
||||||
if (!(vwBody instanceof WebView)) {
|
|
||||||
WebView webView = new WebView(context) {
|
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
||||||
setMeasuredDimension(
|
|
||||||
getMeasuredWidth(),
|
|
||||||
Math.max(tvBody.getMinHeight(), getMeasuredHeight()));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
setupWebView(webView);
|
|
||||||
|
|
||||||
webView.setId(vwBody.getId());
|
|
||||||
webView.setVisibility(vwBody.getVisibility());
|
|
||||||
|
|
||||||
ConstraintLayout cl = (ConstraintLayout) view;
|
|
||||||
cl.removeView(vwBody);
|
|
||||||
cl.addView(webView, vwBody.getLayoutParams());
|
|
||||||
|
|
||||||
vwBody = webView;
|
|
||||||
}
|
|
||||||
|
|
||||||
final WebView webView = (WebView) vwBody;
|
|
||||||
webView.setBackgroundColor(Color.TRANSPARENT);
|
|
||||||
|
|
||||||
WebSettings settings = webView.getSettings();
|
|
||||||
settings.setDefaultFontSize(Math.round(textSize));
|
|
||||||
settings.setDefaultFixedFontSize(Math.round(textSize));
|
|
||||||
settings.setLoadsImagesAutomatically(show_images);
|
|
||||||
|
|
||||||
String html = properties.getHtml(message.id);
|
|
||||||
if (TextUtils.isEmpty(html)) {
|
|
||||||
webView.loadUrl("about:blank");
|
|
||||||
webView.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
if (!message.content)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putLong("id", message.id);
|
args.putLong("id", message.id);
|
||||||
|
|
||||||
new SimpleTask<OriginalMessage>() {
|
new SimpleTask<String>() {
|
||||||
@Override
|
@Override
|
||||||
protected OriginalMessage onExecute(Context context, Bundle args) throws IOException {
|
protected String onExecute(Context context, Bundle args) throws Throwable {
|
||||||
long id = args.getLong("id");
|
long id = args.getLong("id");
|
||||||
|
|
||||||
DB db = DB.getInstance(context);
|
DB db = DB.getInstance(context);
|
||||||
|
@ -1827,96 +1736,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
OriginalMessage original = new OriginalMessage();
|
String html = HtmlHelper.getHtmlEmbedded(context, id, Helper.readText(file));
|
||||||
original.html = Helper.readText(file);
|
|
||||||
original.html = HtmlHelper.getHtmlEmbedded(context, id, original.html);
|
|
||||||
|
|
||||||
Document doc = Jsoup.parse(original.html);
|
|
||||||
original.has_images = (doc.select("img").size() > 0);
|
|
||||||
|
|
||||||
return original;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onExecuted(Bundle args, OriginalMessage original) {
|
|
||||||
if (original == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
long id = args.getLong("id");
|
|
||||||
properties.setHtml(id, original.html);
|
|
||||||
if (!original.has_images)
|
|
||||||
properties.setValue("images", id, true);
|
|
||||||
|
|
||||||
TupleMessageEx amessage = getMessage();
|
|
||||||
if (amessage == null || !amessage.id.equals(id))
|
|
||||||
return;
|
|
||||||
|
|
||||||
boolean expanded = properties.getValue("expanded", id);
|
|
||||||
if (!expanded)
|
|
||||||
return;
|
|
||||||
|
|
||||||
boolean show_images = properties.getValue("images", id);
|
|
||||||
ibImages.setVisibility(original.has_images && !show_images ? View.VISIBLE : View.GONE);
|
|
||||||
ibFull.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
webView.loadDataWithBaseURL("", themeHtml(original.html), "text/html", "UTF-8", null);
|
|
||||||
|
|
||||||
pbBody.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onException(Bundle args, Throwable ex) {
|
|
||||||
Helper.unexpectedError(context, owner, ex);
|
|
||||||
}
|
|
||||||
}.execute(context, owner, args, "message:webview");
|
|
||||||
} else {
|
|
||||||
Document doc = Jsoup.parse(html);
|
|
||||||
boolean has_images = (doc.select("img").size() > 0);
|
|
||||||
|
|
||||||
ibImages.setVisibility(has_images && !show_images ? View.VISIBLE : View.GONE);
|
|
||||||
ibFull.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
webView.loadDataWithBaseURL("", themeHtml(html), "text/html", "UTF-8", null);
|
|
||||||
webView.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
pbBody.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onHideHtml(TupleMessageEx message) {
|
|
||||||
properties.setValue("html", message.id, false);
|
|
||||||
|
|
||||||
ibFull.setVisibility(View.GONE);
|
|
||||||
vwBody.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
Spanned body = properties.getBody(message.id);
|
|
||||||
tvBody.setText(body);
|
|
||||||
tvBody.setMovementMethod(null);
|
|
||||||
tvBody.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
showText(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String themeHtml(String html) {
|
|
||||||
if (dark) {
|
|
||||||
String color = String.format("#%06X", (textColorSecondary & 0xFFFFFF));
|
|
||||||
return "<style type=\"text/css\">" +
|
|
||||||
"* { background: black !important; color: " + color + " !important }" +
|
|
||||||
"</style>" + html;
|
|
||||||
} else
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onShowFull(TupleMessageEx message) {
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putLong("id", message.id);
|
|
||||||
|
|
||||||
new SimpleTask<String>() {
|
|
||||||
@Override
|
|
||||||
protected String onExecute(Context context, Bundle args) {
|
|
||||||
long id = args.getLong("id");
|
|
||||||
|
|
||||||
String html = properties.getHtml(id);
|
|
||||||
|
|
||||||
// Remove viewport limitations
|
// Remove viewport limitations
|
||||||
Document doc = Jsoup.parse(html);
|
Document doc = Jsoup.parse(html);
|
||||||
|
@ -2068,10 +1888,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
ibImages.setVisibility(View.GONE);
|
ibImages.setVisibility(View.GONE);
|
||||||
|
|
||||||
boolean show_html = properties.getValue("html", message.id);
|
|
||||||
if (show_html)
|
|
||||||
onShowHtmlConfirmed(message);
|
|
||||||
else
|
|
||||||
showText(message);
|
showText(message);
|
||||||
|
|
||||||
// Download inline images
|
// Download inline images
|
||||||
|
@ -2220,7 +2036,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
boolean has_images = args.getBoolean("has_images");
|
boolean has_images = args.getBoolean("has_images");
|
||||||
boolean show_images = properties.getValue("images", message.id);
|
boolean show_images = properties.getValue("images", message.id);
|
||||||
|
|
||||||
tbHtml.setVisibility(hasWebView ? View.VISIBLE : View.GONE);
|
ibFull.setVisibility(hasWebView ? View.VISIBLE : View.GONE);
|
||||||
ibImages.setVisibility(has_images && !show_images ? View.VISIBLE : View.GONE);
|
ibImages.setVisibility(has_images && !show_images ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
tvBody.setText(body);
|
tvBody.setText(body);
|
||||||
|
@ -3468,7 +3284,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
this.preview = prefs.getBoolean("preview", false);
|
this.preview = prefs.getBoolean("preview", false);
|
||||||
this.attachments_alt = prefs.getBoolean("attachments_alt", false);
|
this.attachments_alt = prefs.getBoolean("attachments_alt", false);
|
||||||
this.monospaced = prefs.getBoolean("monospaced", false);
|
this.monospaced = prefs.getBoolean("monospaced", false);
|
||||||
this.autohtml = (this.hasWebView && this.contacts && prefs.getBoolean("autohtml", false));
|
|
||||||
this.autoimages = (this.contacts && prefs.getBoolean("autoimages", false));
|
this.autoimages = (this.contacts && prefs.getBoolean("autoimages", false));
|
||||||
this.authentication = prefs.getBoolean("authentication", false);
|
this.authentication = prefs.getBoolean("authentication", false);
|
||||||
this.debug = prefs.getBoolean("debug", false);
|
this.debug = prefs.getBoolean("debug", false);
|
||||||
|
@ -3556,10 +3371,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
if (viewType == ViewType.THREAD)
|
|
||||||
return (compact ? R.layout.item_message_compact : R.layout.item_message_normal);
|
return (compact ? R.layout.item_message_compact : R.layout.item_message_normal);
|
||||||
else
|
|
||||||
return (compact ? R.layout.include_message_compact : R.layout.include_message_normal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3668,10 +3480,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
|
|
||||||
Spanned getBody(long id);
|
Spanned getBody(long id);
|
||||||
|
|
||||||
void setHtml(long id, String html);
|
|
||||||
|
|
||||||
String getHtml(long id);
|
|
||||||
|
|
||||||
void setAttchments(long id, List<EntityAttachment> attachments);
|
void setAttchments(long id, List<EntityAttachment> attachments);
|
||||||
|
|
||||||
List<EntityAttachment> getAttachments(long id);
|
List<EntityAttachment> getAttachments(long id);
|
||||||
|
|
|
@ -182,7 +182,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
private boolean autoExpanded = true;
|
private boolean autoExpanded = true;
|
||||||
private Map<String, List<Long>> values = new HashMap<>();
|
private Map<String, List<Long>> values = new HashMap<>();
|
||||||
private LongSparseArray<Spanned> bodies = new LongSparseArray<>();
|
private LongSparseArray<Spanned> bodies = new LongSparseArray<>();
|
||||||
private LongSparseArray<String> html = new LongSparseArray<>();
|
|
||||||
private LongSparseArray<List<EntityAttachment>> attachments = new LongSparseArray<>();
|
private LongSparseArray<List<EntityAttachment>> attachments = new LongSparseArray<>();
|
||||||
private LongSparseArray<TupleAccountSwipes> accountSwipes = new LongSparseArray<>();
|
private LongSparseArray<TupleAccountSwipes> accountSwipes = new LongSparseArray<>();
|
||||||
|
|
||||||
|
@ -906,19 +905,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
return bodies.get(id);
|
return bodies.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHtml(long id, String value) {
|
|
||||||
if (value == null)
|
|
||||||
html.remove(id);
|
|
||||||
else
|
|
||||||
html.put(id, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHtml(long id) {
|
|
||||||
return html.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAttchments(long id, List<EntityAttachment> list) {
|
public void setAttchments(long id, List<EntityAttachment> list) {
|
||||||
attachments.put(id, list);
|
attachments.put(id, list);
|
||||||
|
@ -2090,7 +2076,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
for (String key : values.keySet())
|
for (String key : values.keySet())
|
||||||
values.get(key).remove(id);
|
values.get(key).remove(id);
|
||||||
bodies.remove(id);
|
bodies.remove(id);
|
||||||
html.remove(id);
|
|
||||||
attachments.remove(id);
|
attachments.remove(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,13 +50,12 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||||
private SwitchCompat swAddresses;
|
private SwitchCompat swAddresses;
|
||||||
private SwitchCompat swAttachmentsAlt;
|
private SwitchCompat swAttachmentsAlt;
|
||||||
private SwitchCompat swMonospaced;
|
private SwitchCompat swMonospaced;
|
||||||
private SwitchCompat swHtml;
|
|
||||||
private SwitchCompat swImages;
|
private SwitchCompat swImages;
|
||||||
private SwitchCompat swActionbar;
|
private SwitchCompat swActionbar;
|
||||||
|
|
||||||
private final static String[] RESET_OPTIONS = new String[]{
|
private final static String[] RESET_OPTIONS = new String[]{
|
||||||
"startup", "date", "threading", "avatars", "identicons", "circular", "name_email", "subject_italic",
|
"startup", "date", "threading", "avatars", "identicons", "circular", "name_email", "subject_italic",
|
||||||
"flags", "preview", "addresses", "attachments_alt", "monospaced", "autohtml", "autoimages", "actionbar",
|
"flags", "preview", "addresses", "attachments_alt", "monospaced", "autoimages", "actionbar",
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,7 +81,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||||
swAddresses = view.findViewById(R.id.swAddresses);
|
swAddresses = view.findViewById(R.id.swAddresses);
|
||||||
swAttachmentsAlt = view.findViewById(R.id.swAttachmentsAlt);
|
swAttachmentsAlt = view.findViewById(R.id.swAttachmentsAlt);
|
||||||
swMonospaced = view.findViewById(R.id.swMonospaced);
|
swMonospaced = view.findViewById(R.id.swMonospaced);
|
||||||
swHtml = view.findViewById(R.id.swHtml);
|
|
||||||
swImages = view.findViewById(R.id.swImages);
|
swImages = view.findViewById(R.id.swImages);
|
||||||
swActionbar = view.findViewById(R.id.swActionbar);
|
swActionbar = view.findViewById(R.id.swActionbar);
|
||||||
|
|
||||||
|
@ -192,13 +190,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
swHtml.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
|
||||||
prefs.edit().putBoolean("autohtml", checked).apply();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
swImages.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
swImages.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
|
@ -279,7 +270,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||||
swAddresses.setChecked(prefs.getBoolean("addresses", false));
|
swAddresses.setChecked(prefs.getBoolean("addresses", false));
|
||||||
swAttachmentsAlt.setChecked(prefs.getBoolean("attachments_alt", false));
|
swAttachmentsAlt.setChecked(prefs.getBoolean("attachments_alt", false));
|
||||||
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));
|
swMonospaced.setChecked(prefs.getBoolean("monospaced", false));
|
||||||
swHtml.setChecked(prefs.getBoolean("autohtml", false));
|
|
||||||
swImages.setChecked(prefs.getBoolean("autoimages", false));
|
swImages.setChecked(prefs.getBoolean("autoimages", false));
|
||||||
swActionbar.setChecked(prefs.getBoolean("actionbar", true));
|
swActionbar.setChecked(prefs.getBoolean("actionbar", true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,28 +194,6 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/swAttachmentsAlt"
|
app:layout_constraintTop_toBottomOf="@id/swAttachmentsAlt"
|
||||||
app:switchPadding="12dp" />
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
|
||||||
android:id="@+id/swHtml"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="12dp"
|
|
||||||
android:text="@string/title_advanced_html"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/swMonospaced"
|
|
||||||
app:switchPadding="12dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvHtmlHint"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginEnd="48dp"
|
|
||||||
android:text="@string/title_ask_show_html"
|
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
|
||||||
android:textStyle="italic"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/swHtml" />
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
android:id="@+id/swImages"
|
android:id="@+id/swImages"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -223,7 +201,7 @@
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:text="@string/title_advanced_images"
|
android:text="@string/title_advanced_images"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvHtmlHint"
|
app:layout_constraintTop_toBottomOf="@id/swMonospaced"
|
||||||
app:switchPadding="12dp" />
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -75,22 +75,13 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvNoInternetBody" />
|
app:layout_constraintTop_toBottomOf="@id/tvNoInternetBody" />
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/vwBody"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="3dp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvBody" />
|
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/InCalendar"
|
android:id="@+id/InCalendar"
|
||||||
layout="@layout/include_message_calendar"
|
layout="@layout/include_message_calendar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/vwBody" />
|
app:layout_constraintTop_toBottomOf="@id/tvBody" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/inAttachmentsAlt"
|
android:id="@+id/inAttachmentsAlt"
|
||||||
|
|
|
@ -18,20 +18,6 @@
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:menu="@menu/action_message" />
|
app:menu="@menu/action_message" />
|
||||||
|
|
||||||
<ToggleButton
|
|
||||||
android:id="@+id/tbHtml"
|
|
||||||
style="?android:attr/buttonStyleSmall"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="6dp"
|
|
||||||
android:layout_marginTop="3dp"
|
|
||||||
android:minWidth="0dp"
|
|
||||||
android:minHeight="0dp"
|
|
||||||
android:textOff="@string/title_show_html"
|
|
||||||
android:textOn="@string/title_show_formatted"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/bnvActions" />
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/ibImages"
|
android:id="@+id/ibImages"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
Loading…
Reference in New Issue