Added setting to disable language detection

This commit is contained in:
M66B
2020-03-26 15:34:42 +01:00
parent 1c437a52f5
commit f6183c9aac
4 changed files with 29 additions and 4 deletions

View File

@@ -48,6 +48,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swDoubleBack;
private SwitchCompat swConversationActions;
private SwitchCompat swConversationActionsReplies;
private SwitchCompat swLanguageDetection;
private EditText etDefaultSnooze;
private SwitchCompat swPull;
private SwitchCompat swAutoScroll;
@@ -72,7 +73,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private Group grpConversationActions;
private final static String[] RESET_OPTIONS = new String[]{
"double_back", "conversation_actions", "conversation_actions_replies", "default_snooze",
"double_back", "conversation_actions", "conversation_actions_replies", "language_detection",
"default_snooze",
"pull", "autoscroll", "quick_filter", "quick_scroll",
"doubletap", "swipenav", "volumenav", "reversed",
"autoexpand", "expand_all", "expand_one", "collapse_multiple",
@@ -93,6 +95,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swDoubleBack = view.findViewById(R.id.swDoubleBack);
swConversationActions = view.findViewById(R.id.swConversationActions);
swConversationActionsReplies = view.findViewById(R.id.swConversationActionsReplies);
swLanguageDetection = view.findViewById(R.id.swLanguageDetection);
etDefaultSnooze = view.findViewById(R.id.etDefaultSnooze);
swPull = view.findViewById(R.id.swPull);
swAutoScroll = view.findViewById(R.id.swAutoScroll);
@@ -144,6 +147,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
}
});
swLanguageDetection.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("language_detection", checked).apply();
}
});
etDefaultSnooze.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -376,6 +386,9 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swConversationActions.setChecked(prefs.getBoolean("conversation_actions", true));
swConversationActionsReplies.setChecked(prefs.getBoolean("conversation_actions_replies", true));
swConversationActionsReplies.setEnabled(swConversationActions.isChecked());
swLanguageDetection.setChecked(prefs.getBoolean("language_detection", true));
swLanguageDetection.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.Q ? View.GONE : View.VISIBLE);
int default_snooze = prefs.getInt("default_snooze", 1);
etDefaultSnooze.setText(default_snooze == 1 ? null : Integer.toString(default_snooze));
etDefaultSnooze.setHint("1");

View File

@@ -1108,8 +1108,8 @@ public class HtmlHelper {
static String getLanguage(Context context, String body) {
try {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean conversation_actions = prefs.getBoolean("conversation_actions", true);
if (!conversation_actions)
boolean language_detection = prefs.getBoolean("language_detection", true);
if (!language_detection)
return null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {