mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-17 07:22:45 +00:00
show warning that disabling persinalized suggestions will clear learned words
This commit is contained in:
parent
92815c6af6
commit
a31b408351
2 changed files with 13 additions and 6 deletions
|
@ -14,10 +14,11 @@ import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.SwitchPreferenceCompat;
|
import androidx.preference.SwitchPreferenceCompat;
|
||||||
|
import androidx.preference.TwoStatePreference;
|
||||||
|
|
||||||
import org.dslul.openboard.inputmethod.latin.R;
|
import org.dslul.openboard.inputmethod.latin.R;
|
||||||
import org.dslul.openboard.inputmethod.latin.permissions.PermissionsManager;
|
import org.dslul.openboard.inputmethod.latin.permissions.PermissionsManager;
|
||||||
|
@ -73,13 +74,17 @@ public final class CorrectionSettingsFragment extends SubScreenFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
|
public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
|
||||||
if (TextUtils.equals(key, AndroidSpellCheckerService.PREF_USE_CONTACTS_KEY)
|
if (AndroidSpellCheckerService.PREF_USE_CONTACTS_KEY.equals(key)
|
||||||
&& prefs.getBoolean(key, false)
|
&& prefs.getBoolean(key, false)
|
||||||
&& !PermissionsUtil.checkAllPermissionsGranted(
|
&& !PermissionsUtil.checkAllPermissionsGranted(getActivity(), Manifest.permission.READ_CONTACTS)
|
||||||
getActivity() /* context */, Manifest.permission.READ_CONTACTS)
|
|
||||||
) {
|
) {
|
||||||
get(requireContext()).requestPermissions(this /* PermissionsResultCallback */,
|
get(requireContext()).requestPermissions(this, getActivity(), Manifest.permission.READ_CONTACTS);
|
||||||
getActivity() /* activity */, Manifest.permission.READ_CONTACTS);
|
} else if (Settings.PREF_KEY_USE_PERSONALIZED_DICTS.equals(key) && !prefs.getBoolean(key, true)) {
|
||||||
|
new AlertDialog.Builder(requireContext())
|
||||||
|
.setMessage(R.string.disable_personalized_dicts_message)
|
||||||
|
.setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> ((TwoStatePreference) findPreference(key)).setChecked(true))
|
||||||
|
.setPositiveButton(android.R.string.ok, null)
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
refreshEnabledSettings();
|
refreshEnabledSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,8 @@
|
||||||
<string name="use_contacts_dict_summary">Use names from Contacts for suggestions and corrections</string>
|
<string name="use_contacts_dict_summary">Use names from Contacts for suggestions and corrections</string>
|
||||||
<!-- Option name for enabling the use by the keyboards of sent/received messages, e-mail and typing history to improve suggestion accuracy [CHAR LIMIT=25] -->
|
<!-- Option name for enabling the use by the keyboards of sent/received messages, e-mail and typing history to improve suggestion accuracy [CHAR LIMIT=25] -->
|
||||||
<string name="use_personalized_dicts">Personalized suggestions</string>
|
<string name="use_personalized_dicts">Personalized suggestions</string>
|
||||||
|
<!-- Dialog message informing that dictionaries will be deleted on changing the setting -->
|
||||||
|
<string name="disable_personalized_dicts_message">Warning: Disabling this setting will clear learned data</string>
|
||||||
<!-- Option name for adding learned words to personal dictionary -->
|
<!-- Option name for adding learned words to personal dictionary -->
|
||||||
<string name="add_to_personal_dictionary">Add words to personal dictionary</string>
|
<string name="add_to_personal_dictionary">Add words to personal dictionary</string>
|
||||||
<!-- Description for option to add learned words to system-wide user dictionary -->
|
<!-- Description for option to add learned words to system-wide user dictionary -->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue