Added option to disable highlighting checked text

pull/214/head
M66B 1 year ago
parent dd68c57dc9
commit 2150054c63

@ -2908,7 +2908,9 @@ public class FragmentCompose extends FragmentBase {
@Override
protected void onPreExecute(Bundle args) {
if (silent) {
if (!BuildConfig.PLAY_STORE_RELEASE) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean lt_highlight = prefs.getBoolean("lt_highlight", !BuildConfig.PLAY_STORE_RELEASE);
if (lt_highlight) {
int textColorHighlight = Helper.resolveColor(getContext(), android.R.attr.textColorHighlight);
highlightSpan = new BackgroundColorSpan(textColorHighlight);
etBody.getText().setSpan(highlightSpan, start, end,

@ -147,6 +147,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swLanguageToolSentence;
private SwitchCompat swLanguageToolAuto;
private SwitchCompat swLanguageToolPicky;
private SwitchCompat swLanguageToolHighlight;
private EditText etLanguageTool;
private EditText etLanguageToolUser;
private TextInputLayout tilLanguageToolKey;
@ -286,7 +287,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"classification", "class_min_probability", "class_min_difference",
"show_filtered",
"language",
"lt_enabled", "lt_sentence", "lt_auto", "lt_picky", "lt_uri", "lt_user", "lt_key",
"lt_enabled", "lt_sentence", "lt_auto", "lt_picky", "lt_highlight", "lt_uri", "lt_user", "lt_key",
"deepl_enabled",
"vt_enabled", "vt_apikey",
"send_enabled", "send_host", "send_dlimit", "send_tlimit",
@ -403,6 +404,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swLanguageToolSentence = view.findViewById(R.id.swLanguageToolSentence);
swLanguageToolAuto = view.findViewById(R.id.swLanguageToolAuto);
swLanguageToolPicky = view.findViewById(R.id.swLanguageToolPicky);
swLanguageToolHighlight = view.findViewById(R.id.swLanguageToolHighlight);
etLanguageTool = view.findViewById(R.id.etLanguageTool);
etLanguageToolUser = view.findViewById(R.id.etLanguageToolUser);
tilLanguageToolKey = view.findViewById(R.id.tilLanguageToolKey);
@ -863,6 +865,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swLanguageToolSentence.setEnabled(checked);
swLanguageToolAuto.setEnabled(checked);
swLanguageToolPicky.setEnabled(checked);
swLanguageToolHighlight.setEnabled(checked);
}
});
@ -895,6 +898,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swLanguageToolHighlight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("lt_highlight", checked).apply();
}
});
etLanguageTool.setHint(LanguageTool.LT_URI);
etLanguageTool.addTextChangedListener(new TextWatcher() {
@Override
@ -2554,6 +2564,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swLanguageToolAuto.setEnabled(swLanguageTool.isChecked());
swLanguageToolPicky.setChecked(prefs.getBoolean("lt_picky", false));
swLanguageToolPicky.setEnabled(swLanguageTool.isChecked());
swLanguageToolHighlight.setChecked(prefs.getBoolean("lt_highlight", !BuildConfig.PLAY_STORE_RELEASE));
swLanguageToolHighlight.setEnabled(swLanguageTool.isChecked());
etLanguageTool.setText(prefs.getString("lt_uri", null));
etLanguageToolUser.setText(prefs.getString("lt_user", null));
tilLanguageToolKey.getEditText().setText(prefs.getString("lt_key", null));

@ -684,6 +684,18 @@
app:layout_constraintTop_toBottomOf="@id/swLanguageToolAuto"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swLanguageToolHighlight"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_lt_highlight"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swLanguageToolPicky"
app:switchPadding="12dp" />
<EditText
android:id="@+id/etLanguageTool"
android:layout_width="0dp"
@ -694,7 +706,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swLanguageToolPicky" />
app:layout_constraintTop_toBottomOf="@id/swLanguageToolHighlight" />
<EditText
android:id="@+id/etLanguageToolUser"

@ -826,6 +826,7 @@
<string name="title_advanced_lt">LanguageTool integration</string>
<string name="title_advanced_lt_sentence">Check every sentence</string>
<string name="title_advanced_lt_auto">Check paragraph after a new line</string>
<string name="title_advanced_lt_highlight">Highlight the text being checked</string>
<string name="title_advanced_lt_user">Username (optional)</string>
<string name="title_advanced_lt_key">API key (optional)</string>
<string name="title_advanced_deepl">DeepL integration</string>

Loading…
Cancel
Save