Added option to disable highlighting translated text

pull/214/head
M66B 12 months ago
parent 2150054c63
commit 0394b14a62

@ -379,6 +379,7 @@ public class DeepL {
boolean formal = prefs.getBoolean("deepl_formal", true);
boolean small = prefs.getBoolean("deepl_small", false);
boolean replace = prefs.getBoolean("deepl_replace", false);
boolean highlight = prefs.getBoolean("deepl_highlight", true);
boolean html = prefs.getBoolean("deepl_html", false);
int subscription = prefs.getInt("deepl_subscription", BuildConfig.DEBUG ? 17 : 0);
@ -389,6 +390,7 @@ public class DeepL {
final TextView tvFormal = view.findViewById(R.id.tvFormal);
final CheckBox cbSmall = view.findViewById(R.id.cbSmall);
final CheckBox cbReplace = view.findViewById(R.id.cbReplace);
final CheckBox cbHighlight = view.findViewById(R.id.cbHighlight);
final CheckBox cbHtml = view.findViewById(R.id.cbHtml);
final TextView tvUsage = view.findViewById(R.id.tvUsage);
final TextView tvPrivacy = view.findViewById(R.id.tvPrivacy);
@ -439,6 +441,7 @@ public class DeepL {
cbSmall.setChecked(small);
cbReplace.setChecked(replace);
cbReplace.setEnabled(!small);
cbHighlight.setChecked(highlight);
cbHtml.setChecked(html);
tvUsage.setVisibility(View.GONE);
@ -502,6 +505,7 @@ public class DeepL {
editor.putBoolean("deepl_formal", cbFormal.isChecked());
editor.putBoolean("deepl_small", cbSmall.isChecked());
editor.putBoolean("deepl_replace", cbReplace.isChecked());
editor.putBoolean("deepl_highlight", cbHighlight.isChecked());
editor.putBoolean("deepl_html", cbHtml.isChecked());
editor.apply();
}

@ -2783,10 +2783,14 @@ public class FragmentCompose extends FragmentBase {
@Override
protected void onPreExecute(Bundle args) {
int textColorHighlight = Helper.resolveColor(getContext(), android.R.attr.textColorHighlight);
highlightSpan = new BackgroundColorSpan(textColorHighlight);
etBody.getText().setSpan(highlightSpan, paragraph.first, paragraph.second,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean deepl_highlight = prefs.getBoolean("deepl_highlight", true);
if (deepl_highlight) {
int textColorHighlight = Helper.resolveColor(getContext(), android.R.attr.textColorHighlight);
highlightSpan = new BackgroundColorSpan(textColorHighlight);
etBody.getText().setSpan(highlightSpan, paragraph.first, paragraph.second,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING);
}
toast = ToastEx.makeText(context, R.string.title_translating, Toast.LENGTH_SHORT);
toast.show();
}

@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fadeScrollbars="false"
android:padding="24dp"
android:scrollbarStyle="outsideOverlay">
@ -99,6 +100,15 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbSmall" />
<CheckBox
android:id="@+id/cbHighlight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_translate_highlight"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbReplace" />
<CheckBox
android:id="@+id/cbHtml"
android:layout_width="wrap_content"
@ -106,7 +116,7 @@
android:layout_marginTop="12dp"
android:text="@string/title_translate_html"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbReplace" />
app:layout_constraintTop_toBottomOf="@id/cbHighlight" />
<TextView
android:id="@+id/tvHtml"

@ -1681,6 +1681,7 @@
<string name="title_translate_formal">Use formal form</string>
<string name="title_translate_small">Use a small font for the source text</string>
<string name="title_translate_replace">Replace source text by translated text</string>
<string name="title_translate_highlight">Highlight the text being translated</string>
<string name="title_translate_html">Preserve formatting</string>
<string name="title_translate_html_hint">This will consume more characters</string>
<string name="title_translate_usage">Usage: %1$s / %2$s (%3$d %%)</string>

Loading…
Cancel
Save