Added line spacing option

master
M66B 4 months ago
parent f0a7773372
commit ad8572281d

@ -309,6 +309,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean align_header;
private boolean large_buttons;
private int message_zoom;
private int line_spacing;
private boolean attachments_alt;
private boolean thumbnails;
private boolean pdf_preview;
@ -3569,6 +3570,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
public void run() {
try {
tvBody.setText((Spanned) result);
if (line_spacing != 100)
tvBody.setLineSpacing(0, line_spacing / 100.0f);
vwRipple.setVisibility(View.VISIBLE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
@ -8557,6 +8560,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.preview_lines = prefs.getInt("preview_lines", 1);
this.align_header = prefs.getBoolean("align_header", false);
this.message_zoom = prefs.getInt("message_zoom", 100);
this.line_spacing = prefs.getInt("line_spacing", 100);
this.attachments_alt = prefs.getBoolean("attachments_alt", false);
this.thumbnails = prefs.getBoolean("thumbnails", true);
this.pdf_preview = prefs.getBoolean("pdf_preview", true);

@ -157,7 +157,7 @@ public class FragmentOptions extends FragmentBase {
"font_size_sender", "sender_ellipsize",
"subject_top", "subject_italic", "highlight_subject", "font_size_subject", "subject_ellipsize",
"keywords_header", "labels_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines", "align_header",
"message_zoom", "overview_mode", "addresses", "button_extra", "attachments_alt",
"message_zoom", "overview_mode", "line_spacing", "addresses", "button_extra", "attachments_alt",
"thumbnails", "pdf_preview", "video_preview", "audio_preview", "barcode_preview",
"contrast", "hyphenation", "display_font", "monospaced_pre",
"list_count", "bundled_fonts", "narrow_fonts", "parse_classes",

@ -176,6 +176,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SeekBar sbMessageZoom;
private SwitchCompat swEditorZoom;
private SwitchCompat swOverviewMode;
private TextView tvLineSpacing;
private SeekBar sbLineSpacing;
private SwitchCompat swContrast;
private SwitchCompat swHyphenation;
@ -232,7 +234,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"keywords_header", "labels_header", "flags", "flags_background",
"preview", "preview_italic", "preview_lines", "align_header",
"addresses", "hide_attachments",
"message_zoom", "editor_zoom", "overview_mode",
"message_zoom", "editor_zoom", "overview_mode", "line_spacing",
"hyphenation", "display_font", "contrast", "monospaced_pre",
"text_separators",
"collapse_quotes", "image_placeholders", "inline_images", "button_extra",
@ -361,6 +363,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
sbMessageZoom = view.findViewById(R.id.sbMessageZoom);
swEditorZoom = view.findViewById(R.id.swEditorZoom);
swOverviewMode = view.findViewById(R.id.swOverviewMode);
tvLineSpacing = view.findViewById(R.id.tvLineSpacing);
sbLineSpacing = view.findViewById(R.id.sbLineSpacing);
swContrast = view.findViewById(R.id.swContrast);
swHyphenation = view.findViewById(R.id.swHyphenation);
tvHyphenationHint = view.findViewById(R.id.tvHyphenationHint);
@ -1311,6 +1315,28 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
sbLineSpacing.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
int line_spacing = progress + 50;
if (line_spacing == 100)
prefs.edit().remove("line_spacing").apply();
else
prefs.edit().putInt("line_spacing", line_spacing).apply();
tvLineSpacing.setText(getString(R.string.title_advanced_line_spacing, NF.format(line_spacing)));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// Do nothing
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// Do nothing
}
});
swContrast.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -1559,6 +1585,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
if ("message_zoom".equals(key))
return;
if ("line_spacing".equals(key))
return;
getMainHandler().removeCallbacks(update);
getMainHandler().postDelayed(update, FragmentOptions.DELAY_SETOPTIONS);
@ -1781,6 +1809,11 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swEditorZoom.setChecked(prefs.getBoolean("editor_zoom", true));
swOverviewMode.setChecked(prefs.getBoolean("overview_mode", false));
int line_spacing = prefs.getInt("line_spacing", 100);
tvLineSpacing.setText(getString(R.string.title_advanced_line_spacing, NF.format(line_spacing)));
if (line_spacing >= 50 && line_spacing <= 150)
sbLineSpacing.setProgress(line_spacing - 50);
swContrast.setChecked(prefs.getBoolean("contrast", false));
swHyphenation.setChecked(prefs.getBoolean("hyphenation", false));

@ -1923,6 +1923,29 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swOverviewMode" />
<TextView
android:id="@+id/tvLineSpacing"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_line_spacing"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOverViewModeHint" />
<SeekBar
android:id="@+id/sbLineSpacing"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:max="150"
android:min="0"
android:progress="50"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvLineSpacing" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swContrast"
android:layout_width="0dp"
@ -1931,7 +1954,7 @@
android:text="@string/title_advanced_contrast"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOverViewModeHint"
app:layout_constraintTop_toBottomOf="@id/sbLineSpacing"
app:switchPadding="12dp" />
<TextView

@ -687,6 +687,7 @@
<string name="title_advanced_message_text_zoom2">Default message text zoom: %1$s %%</string>
<string name="title_advanced_editor_text_zoom">Zoom message text also in the message editor</string>
<string name="title_advanced_overview_mode">Zoom original messages to fit the screen</string>
<string name="title_advanced_line_spacing">Line spacing: %1$s %%</string>
<string name="title_advanced_hyphenation">Use automatic hyphenation</string>
<string name="title_advanced_contrast">Use high contrast for message text</string>
<string name="title_advanced_monospaced">Use monospaced font for message text by default</string>

Loading…
Cancel
Save