mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-20 08:50:25 +00:00
copy use-contacts setting to correction settings
This commit is contained in:
parent
bc159f5e3c
commit
b184fe19ea
3 changed files with 54 additions and 12 deletions
|
@ -45,18 +45,18 @@ Plan / to do:
|
|||
* test whether it works reasonably well in non-latin scripts
|
||||
* ~suggestion fixes, https://github.com/openboard-team/openboard/pull/694, https://github.com/openboard-team/openboard/issues/795, https://github.com/openboard-team/openboard/issues/660~
|
||||
* ~improve auto-space insertion, https://github.com/openboard-team/openboard/pull/576~
|
||||
* emoji prediction/search, either https://github.com/openboard-team/openboard/pull/749 (using emoji dictionaries already possible)
|
||||
* ~emoji prediction/search, https://github.com/openboard-team/openboard/pull/749 (better use emoji dictionaries, this is more flexible)~
|
||||
* ~theming, https://github.com/openboard-team/openboard/issues/124~
|
||||
* ~fix emoji view not themed properly~
|
||||
* ~fix ABC buttons in emoji and clipboard view have wrong text color~
|
||||
* fix buttons on long-press action key not themed
|
||||
* allow adjusting colors without requiring manual reload of keyboard
|
||||
* ~delete suggestions, https://github.com/openboard-team/openboard/issues/106~
|
||||
* make functionality more discoverable, e.g. add a button to the more suggestions menu
|
||||
* make functionality more discoverable, e.g. add a button to the _more suggestions_ menu
|
||||
* ~gesture typing, https://github.com/openboard-team/openboard/issues/3~
|
||||
* ~license issues, require using an external library~
|
||||
* re-consider preferring lowercase word for typed history in some cases (DictionaryFacilitatorImpl.addWordToUserHistory)
|
||||
* move _use contacts_ setting from well hidden spell checker settings to _text correction_ settings
|
||||
* ~move/copy _use contacts_ setting from well hidden spell checker settings to _text correction_ settings~
|
||||
|
||||
-----
|
||||
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.latin.settings;
|
||||
|
||||
import static org.dslul.openboard.inputmethod.latin.permissions.PermissionsManager.get;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -24,8 +27,13 @@ import android.content.pm.PackageManager;
|
|||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.SwitchPreference;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.R;
|
||||
import org.dslul.openboard.inputmethod.latin.permissions.PermissionsManager;
|
||||
import org.dslul.openboard.inputmethod.latin.permissions.PermissionsUtil;
|
||||
import org.dslul.openboard.inputmethod.latin.spellcheck.AndroidSpellCheckerService;
|
||||
import org.dslul.openboard.inputmethod.latin.userdictionary.UserDictionaryList;
|
||||
import org.dslul.openboard.inputmethod.latin.userdictionary.UserDictionarySettings;
|
||||
|
||||
|
@ -46,11 +54,13 @@ import java.util.TreeSet;
|
|||
* - Next-word suggestions
|
||||
*/
|
||||
public final class CorrectionSettingsFragment extends SubScreenFragment
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener,
|
||||
PermissionsManager.PermissionsResultCallback {
|
||||
|
||||
private static final boolean DBG_USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS = false;
|
||||
private static final boolean USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS =
|
||||
DBG_USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS;
|
||||
private SwitchPreference mLookupContactsPreference;
|
||||
|
||||
@Override
|
||||
public void onCreate(final Bundle icicle) {
|
||||
|
@ -69,19 +79,45 @@ public final class CorrectionSettingsFragment extends SubScreenFragment
|
|||
if (ri == null) {
|
||||
overwriteUserDictionaryPreference(editPersonalDictionary);
|
||||
}
|
||||
mLookupContactsPreference = (SwitchPreference) findPreference(
|
||||
AndroidSpellCheckerService.PREF_USE_CONTACTS_KEY);
|
||||
|
||||
refreshEnabledSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
|
||||
if (TextUtils.equals(key, AndroidSpellCheckerService.PREF_USE_CONTACTS_KEY)
|
||||
&& prefs.getBoolean(key, false)
|
||||
&& !PermissionsUtil.checkAllPermissionsGranted(
|
||||
getActivity() /* context */, Manifest.permission.READ_CONTACTS)
|
||||
) {
|
||||
get(getActivity() /* context */).requestPermissions(this /* PermissionsResultCallback */,
|
||||
getActivity() /* activity */, Manifest.permission.READ_CONTACTS);
|
||||
}
|
||||
refreshEnabledSettings();
|
||||
}
|
||||
|
||||
// contacts and permission stuff from SpellCheckerSettingsFragment
|
||||
@Override
|
||||
public void onRequestPermissionsResult(boolean allGranted) {
|
||||
turnOffLookupContactsIfNoPermission();
|
||||
if (allGranted)
|
||||
mLookupContactsPreference.setChecked(true);
|
||||
}
|
||||
|
||||
private void turnOffLookupContactsIfNoPermission() {
|
||||
if (!PermissionsUtil.checkAllPermissionsGranted(
|
||||
getActivity(), Manifest.permission.READ_CONTACTS)) {
|
||||
mLookupContactsPreference.setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshEnabledSettings() {
|
||||
setPreferenceEnabled(Settings.PREF_AUTO_CORRECTION_CONFIDENCE,
|
||||
Settings.readAutoCorrectEnabled(getSharedPreferences(), getResources()));
|
||||
setPreferenceEnabled(Settings.PREF_ADD_TO_PERSONAL_DICTIONARY, getSharedPreferences().getBoolean(Settings.PREF_KEY_USE_PERSONALIZED_DICTS, true));
|
||||
turnOffLookupContactsIfNoPermission();
|
||||
}
|
||||
|
||||
private void overwriteUserDictionaryPreference(final Preference userDictionaryPreference) {
|
||||
|
|
|
@ -82,13 +82,6 @@
|
|||
android:defaultValue="true"
|
||||
android:persistent="true" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="add_to_personal_dictionary"
|
||||
android:title="@string/add_to_personal_dictionary"
|
||||
android:summary="@string/add_to_personal_dictionary_summary"
|
||||
android:defaultValue="false"
|
||||
android:persistent="true" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="next_word_prediction"
|
||||
android:title="@string/bigram_prediction"
|
||||
|
@ -96,6 +89,19 @@
|
|||
android:defaultValue="true"
|
||||
android:persistent="true" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="pref_spellcheck_use_contacts"
|
||||
android:title="@string/use_contacts_for_spellchecking_option_title"
|
||||
android:defaultValue="true"
|
||||
android:persistent="true" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="add_to_personal_dictionary"
|
||||
android:title="@string/add_to_personal_dictionary"
|
||||
android:summary="@string/add_to_personal_dictionary_summary"
|
||||
android:defaultValue="false"
|
||||
android:persistent="true" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue