Added option for automatic hyphenation

pull/208/head
M66B 2 years ago
parent 7a21be0d80
commit 4785dad757

@ -284,6 +284,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean attachments_alt;
private boolean thumbnails;
private boolean contrast;
private boolean hyphenation;
private String display_font;
private boolean inline;
private boolean collapse_quotes;
@ -880,10 +881,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvSignedData = vsBody.findViewById(R.id.tvSignedData);
tvBody = vsBody.findViewById(R.id.tvBody);
if (BuildConfig.DEBUG &&
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
tvBody.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL_FAST);
tvBody.setBreakStrategy(LineBreaker.BREAK_STRATEGY_HIGH_QUALITY);
if (hyphenation &&
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU)
tvBody.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL); // Default before Q
else
tvBody.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
tvBody.setBreakStrategy(LineBreaker.BREAK_STRATEGY_HIGH_QUALITY);
}
wvBody = vsBody.findViewById(R.id.wvBody);
pbBody = vsBody.findViewById(R.id.pbBody);
@ -7036,6 +7041,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.attachments_alt = prefs.getBoolean("attachments_alt", false);
this.thumbnails = prefs.getBoolean("thumbnails", true);
this.contrast = prefs.getBoolean("contrast", false);
this.hyphenation = prefs.getBoolean("hyphenation", false);
this.display_font = prefs.getString("display_font", "");
this.inline = prefs.getBoolean("inline_images", false);
this.collapse_quotes = prefs.getBoolean("collapse_quotes", false);

@ -144,7 +144,7 @@ public class FragmentOptions extends FragmentBase {
"subject_top", "subject_italic", "highlight_subject", "font_size_subject", "subject_ellipsize",
"keywords_header", "labels_header", "flags", "flags_background", "preview", "preview_italic", "preview_lines",
"message_zoom", "overview_mode", "override_width", "addresses", "button_extra", "attachments_alt", "thumbnails",
"contrast", "display_font", "monospaced_pre",
"contrast", "hyphenation", "display_font", "monospaced_pre",
"background_color", "text_color", "text_size", "text_font", "text_align", "text_separators",
"collapse_quotes", "image_placeholders", "inline_images",
"seekbar", "actionbar", "actionbar_color", "group_category",

@ -158,6 +158,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swOverrideWidth;
private SwitchCompat swContrast;
private SwitchCompat swHyphenation;
private Spinner spDisplayFont;
private SwitchCompat swMonospacedPre;
private SwitchCompat swTextSeparators;
@ -202,7 +203,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"preview", "preview_italic", "preview_lines",
"addresses",
"message_zoom", "overview_mode", "override_width",
"display_font", "contrast", "monospaced_pre",
"hyphenation", "display_font", "contrast", "monospaced_pre",
"text_separators",
"collapse_quotes", "image_placeholders", "inline_images", "button_extra",
"unzip", "attachments_alt", "thumbnails",
@ -313,6 +314,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swOverviewMode = view.findViewById(R.id.swOverviewMode);
swOverrideWidth = view.findViewById(R.id.swOverrideWidth);
swContrast = view.findViewById(R.id.swContrast);
swHyphenation = view.findViewById(R.id.swHyphenation);
spDisplayFont = view.findViewById(R.id.spDisplayFont);
swMonospacedPre = view.findViewById(R.id.swMonospacedPre);
swTextSeparators = view.findViewById(R.id.swTextSeparators);
@ -1103,6 +1105,14 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swHyphenation.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.M ? View.GONE : View.VISIBLE);
swHyphenation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("hyphenation", checked).apply();
}
});
spDisplayFont.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
@ -1457,6 +1467,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swOverrideWidth.setChecked(prefs.getBoolean("override_width", false));
swContrast.setChecked(prefs.getBoolean("contrast", false));
swHyphenation.setChecked(prefs.getBoolean("hyphenation", false));
String display_font = prefs.getString("display_font", "");
List<StyleHelper.FontDescriptor> fonts = StyleHelper.getFonts(getContext());

@ -1656,6 +1656,17 @@
app:layout_constraintTop_toBottomOf="@id/tvOverrideWidthHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swHyphenation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_hyphenation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swContrast"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvDisplayFont"
android:layout_width="0dp"
@ -1667,7 +1678,7 @@
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swContrast" />
app:layout_constraintTop_toBottomOf="@id/swHyphenation" />
<Spinner
android:id="@+id/spDisplayFont"

@ -546,6 +546,7 @@
<string name="title_advanced_message_text_zoom2">Default message text zoom: %1$s %%</string>
<string name="title_advanced_overview_mode">Zoom original messages to fit the screen</string>
<string name="title_advanced_override_width">Disable fixed widths in original messages</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>
<string name="title_advanced_monospaced_pre">Use monospaced font for preformatted text</string>

Loading…
Cancel
Save