mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-29 03:05:31 +00:00
Added setting for number of preview lines
This commit is contained in:
parent
bcafefc1df
commit
bfa7bcdb85
6 changed files with 53 additions and 4 deletions
|
@ -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;
|
||||
|
|
|
@ -460,6 +460,27 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/tvPreviewHint"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPreviewLines"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_preview_lines"
|
||||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Small"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swPreviewItalic" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spPreviewLines"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:entries="@array/linesNames"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvPreviewLines" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swAddresses"
|
||||
android:layout_width="0dp"
|
||||
|
@ -468,7 +489,7 @@
|
|||
android:text="@string/title_advanced_addresses"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swPreviewItalic"
|
||||
app:layout_constraintTop_toBottomOf="@id/spPreviewLines"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
|
|
|
@ -266,6 +266,7 @@
|
|||
<string name="title_advanced_flags_background">Show colored background instead of colored stars</string>
|
||||
<string name="title_advanced_preview">Show message preview</string>
|
||||
<string name="title_advanced_preview_italic">Show message preview in italics</string>
|
||||
<string name="title_advanced_preview_lines">Number of preview lines</string>
|
||||
<string name="title_advanced_addresses">Show address details by default</string>
|
||||
<string name="title_advanced_attachments_alt">Show attachments after the message text</string>
|
||||
<string name="title_advanced_contrast">Use high contrast for message text</string>
|
||||
|
@ -1076,6 +1077,13 @@
|
|||
<item>High</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="linesNames">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
</string-array>
|
||||
|
||||
<string name="fingerprint" translatable="false">17BA15C1AF55D925F98B99CEA4375D4CDF4C174B</string>
|
||||
<string name="public_key" translatable="false">MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtFbxEbzL8u5accPGgBw/XdyiSS5BBE6ZQ9ELpKyJ/OQN+kdYniCAOw3lsQ/GuJScy4Y2HobqbBgLL8GLHG+Yu2EHC9dLjA3v2Mc25vvnfn86BsrpQvz1poN2n+roTBdq09FWbtebJ8m0hDBVmtfRi7RhTKIL4No3kodLhksdnucKjcFheubebWKgpmvbmw7NwuELhaZmyhw8WTtnQ4rZPMhjY1JJZgzwNExXgD7zzg4pJPkuQlfkuRkkvBpHpi3C7VDnYjrBlLHngI4wv3wxQBVwJqlvAT9PmX8dOVnTsWWdJdLQBZVWphuqVY54kjBIovN+o8w03WjsV9QiOQq+XwIDAQAB</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue