mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-03 11:28:41 +01:00
Added setting for number of preview lines
This commit is contained in:
@@ -200,6 +200,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
private boolean flags_background;
|
||||
private boolean preview;
|
||||
private boolean preview_italic;
|
||||
private int preview_lines;
|
||||
private boolean attachments_alt;
|
||||
private boolean contrast;
|
||||
private boolean monospaced;
|
||||
@@ -828,6 +829,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
if (tvPreview.getTag() == null || (int) tvPreview.getTag() != textColor) {
|
||||
tvPreview.setTag(textColor);
|
||||
tvPreview.setTextColor(textColor);
|
||||
tvPreview.setMaxLines(preview_lines);
|
||||
}
|
||||
tvPreview.setTypeface(
|
||||
monospaced ? Typeface.MONOSPACE : Typeface.DEFAULT,
|
||||
@@ -3550,6 +3552,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
this.flags_background = prefs.getBoolean("flags_background", false);
|
||||
this.preview = prefs.getBoolean("preview", false);
|
||||
this.preview_italic = prefs.getBoolean("preview_italic", true);
|
||||
this.preview_lines = prefs.getInt("preview_lines", 2);
|
||||
this.attachments_alt = prefs.getBoolean("attachments_alt", false);
|
||||
this.contrast = prefs.getBoolean("contrast", false);
|
||||
this.monospaced = prefs.getBoolean("monospaced", false);
|
||||
|
||||
@@ -43,7 +43,7 @@ public class FragmentOptions extends FragmentBase {
|
||||
"avatars", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
|
||||
"name_email", "distinguish_contacts", "authentication",
|
||||
"subject_top", "subject_italic", "subject_ellipsize",
|
||||
"flags", "flags_background", "preview", "preview_italic",
|
||||
"flags", "flags_background", "preview", "preview_italic", "preview_lines",
|
||||
"addresses", "attachments_alt",
|
||||
"contrast", "monospaced", "text_color",
|
||||
"inline_images", "collapse_quotes", "seekbar", "actionbar",
|
||||
|
||||
@@ -76,6 +76,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
private SwitchCompat swFlagsBackground;
|
||||
private SwitchCompat swPreview;
|
||||
private SwitchCompat swPreviewItalic;
|
||||
private Spinner spPreviewLines;
|
||||
private SwitchCompat swAddresses;
|
||||
private SwitchCompat swAttachmentsAlt;
|
||||
|
||||
@@ -92,7 +93,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
"avatars", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
|
||||
"name_email", "distinguish_contacts", "authentication",
|
||||
"subject_top", "subject_italic", "subject_ellipsize",
|
||||
"flags", "flags_background", "preview", "preview_italic", "addresses", "attachments_alt",
|
||||
"flags", "flags_background", "preview", "preview_italic", "preview_lines", "addresses", "attachments_alt",
|
||||
"contrast", "monospaced", "text_color",
|
||||
"inline_images", "collapse_quotes", "seekbar", "actionbar",
|
||||
};
|
||||
@@ -135,6 +136,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
swFlagsBackground = view.findViewById(R.id.swFlagsBackground);
|
||||
swPreview = view.findViewById(R.id.swPreview);
|
||||
swPreviewItalic = view.findViewById(R.id.swPreviewItalic);
|
||||
spPreviewLines = view.findViewById(R.id.spPreviewLines);
|
||||
swAddresses = view.findViewById(R.id.swAddresses);
|
||||
swAttachmentsAlt = view.findViewById(R.id.swAttachmentsAlt);
|
||||
swContrast = view.findViewById(R.id.swContrast);
|
||||
@@ -378,6 +380,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("preview", checked).apply();
|
||||
swPreviewItalic.setEnabled(checked);
|
||||
spPreviewLines.setEnabled(checked);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -388,6 +391,18 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
}
|
||||
});
|
||||
|
||||
spPreviewLines.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
|
||||
prefs.edit().putInt("preview_lines", position + 1).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
prefs.edit().remove("preview_lines").apply();
|
||||
}
|
||||
});
|
||||
|
||||
swAddresses.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
@@ -549,6 +564,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
||||
swPreview.setChecked(prefs.getBoolean("preview", false));
|
||||
swPreviewItalic.setChecked(prefs.getBoolean("preview_italic", true));
|
||||
swPreviewItalic.setEnabled(swPreview.isChecked());
|
||||
spPreviewLines.setSelection(prefs.getInt("preview_lines", 2) - 1);
|
||||
spPreviewLines.setEnabled(swPreview.isChecked());
|
||||
swAddresses.setChecked(prefs.getBoolean("addresses", false));
|
||||
swAttachmentsAlt.setChecked(prefs.getBoolean("attachments_alt", false));
|
||||
swContrast.setChecked(prefs.getBoolean("contrast", false));
|
||||
|
||||
@@ -68,7 +68,7 @@ import static androidx.core.text.HtmlCompat.FROM_HTML_SEPARATOR_LINE_BREAK_LIST_
|
||||
import static androidx.core.text.HtmlCompat.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE;
|
||||
|
||||
public class HtmlHelper {
|
||||
private static final int PREVIEW_SIZE = 250; // characters
|
||||
private static final int PREVIEW_SIZE = 500; // characters
|
||||
|
||||
private static final float MIN_LUMINANCE = 0.5f;
|
||||
private static final int MAX_AUTO_LINK = 250;
|
||||
|
||||
Reference in New Issue
Block a user