mirror of https://github.com/M66B/FairEmail.git
Added setting to enable easy correct for suggestions
This commit is contained in:
parent
866774b9bf
commit
8079a14fd3
|
@ -240,6 +240,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
private SwitchCompat swNativeDkim;
|
||||
private SwitchCompat swNativeArc;
|
||||
private EditText etNativeArcWhitelist;
|
||||
private SwitchCompat swEasyCorrect;
|
||||
private SwitchCompat swInfra;
|
||||
private SwitchCompat swTldFlags;
|
||||
private SwitchCompat swDupMsgId;
|
||||
|
@ -310,7 +311,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
"max_backoff_power", "logarithmic_backoff",
|
||||
"exact_alarms",
|
||||
"native_dkim", "native_arc", "native_arc_whitelist",
|
||||
"infra", "tld_flags", "dup_msgids", "thread_byref", "mdn", "app_chooser", "delete_confirmation", "global_keywords", "test_iab"
|
||||
"easy_correct", "infra", "tld_flags", "dup_msgids", "thread_byref", "mdn", "app_chooser", "delete_confirmation", "global_keywords", "test_iab"
|
||||
};
|
||||
|
||||
private final static String[] RESET_QUESTIONS = new String[]{
|
||||
|
@ -499,6 +500,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
swNativeDkim = view.findViewById(R.id.swNativeDkim);
|
||||
swNativeArc = view.findViewById(R.id.swNativeArc);
|
||||
etNativeArcWhitelist = view.findViewById(R.id.etNativeArcWhitelist);
|
||||
swEasyCorrect = view.findViewById(R.id.swEasyCorrect);
|
||||
swInfra = view.findViewById(R.id.swInfra);
|
||||
swTldFlags = view.findViewById(R.id.swTldFlags);
|
||||
swDupMsgId = view.findViewById(R.id.swDupMsgId);
|
||||
|
@ -1881,6 +1883,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
}
|
||||
});
|
||||
|
||||
swEasyCorrect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("easy_correct", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swInfra.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
|
@ -2697,6 +2706,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
swNativeArc.setChecked(prefs.getBoolean("native_arc", true));
|
||||
etNativeArcWhitelist.setEnabled(swNativeDkim.isEnabled() && swNativeDkim.isChecked());
|
||||
etNativeArcWhitelist.setText(prefs.getString("native_arc_whitelist", null));
|
||||
swEasyCorrect.setChecked(prefs.getBoolean("easy_correct", false));
|
||||
swInfra.setChecked(prefs.getBoolean("infra", false));
|
||||
swTldFlags.setChecked(prefs.getBoolean("tld_flags", false));
|
||||
swDupMsgId.setChecked(prefs.getBoolean("dup_msgids", false));
|
||||
|
|
|
@ -20,11 +20,14 @@ package eu.faircode.email;
|
|||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.text.TextPaint;
|
||||
import android.text.style.SuggestionSpan;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class SuggestionSpanEx extends SuggestionSpan {
|
||||
|
@ -34,14 +37,23 @@ public class SuggestionSpanEx extends SuggestionSpan {
|
|||
private final int underlineThickness;
|
||||
|
||||
public SuggestionSpanEx(Context context, String description, String[] suggestions, boolean misspelled) {
|
||||
super(context, suggestions,
|
||||
misspelled || Build.VERSION.SDK_INT < Build.VERSION_CODES.S
|
||||
? SuggestionSpan.FLAG_MISSPELLED
|
||||
: SuggestionSpan.FLAG_GRAMMAR_ERROR);
|
||||
super(context, suggestions, 0);
|
||||
|
||||
int flags = (misspelled || Build.VERSION.SDK_INT < Build.VERSION_CODES.S
|
||||
? SuggestionSpan.FLAG_MISSPELLED
|
||||
: SuggestionSpan.FLAG_GRAMMAR_ERROR);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean easy_correct = prefs.getBoolean("easy_correct", false);
|
||||
if (easy_correct)
|
||||
flags |= SuggestionSpan.FLAG_EASY_CORRECT;
|
||||
|
||||
this.setFlags(flags);
|
||||
|
||||
this.description = description;
|
||||
highlightColor = Helper.resolveColor(context, android.R.attr.textColorHighlight);
|
||||
underlineColor = (misspelled ? Color.RED : highlightColor);
|
||||
underlineThickness = Helper.dp2pixels(context, misspelled ? 2 : 2);
|
||||
underlineColor = (BuildConfig.DEBUG ? Color.MAGENTA : (misspelled ? Color.RED : highlightColor));
|
||||
underlineThickness = Helper.dp2pixels(context, misspelled ? 2 : (BuildConfig.DEBUG ? 1 : 2));
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
|
|
|
@ -2066,6 +2066,17 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swNativeArc" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swEasyCorrect"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_easy_correct"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/etNativeArcWhitelist"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swInfra"
|
||||
android:layout_width="0dp"
|
||||
|
@ -2074,7 +2085,7 @@
|
|||
android:text="@string/title_advanced_infra"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/etNativeArcWhitelist"
|
||||
app:layout_constraintTop_toBottomOf="@id/swEasyCorrect"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.constraintlayout.helper.widget.Flow
|
||||
|
|
|
@ -907,6 +907,7 @@
|
|||
<string name="title_advanced_exact_alarms" translatable="false">Use exact timers</string>
|
||||
<string name="title_advanced_native_dkim" translatable="false">Native DKIM verification</string>
|
||||
<string name="title_advanced_native_arc" translatable="false">Native ARC verification</string>
|
||||
<string name="title_advanced_easy_correct" translatable="false">Easy correct</string>
|
||||
<string name="title_advanced_infra" translatable="false">Show infrastructure</string>
|
||||
<string name="title_advanced_tld_flags" translatable="false">Show TLD flags</string>
|
||||
<string name="title_advanced_dup_msgid" translatable="false">Duplicates by message ID</string>
|
||||
|
|
Loading…
Reference in New Issue