Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1eee2c6d authored by Nishith  Khanna's avatar Nishith Khanna Committed by Nishith Khanna
Browse files

Merge branch '9047-main-emoji' into 'v3.7'

Enable emoji key by default for old and new users

See merge request !50
parents 49e2c71d 0825b05e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@
        android:key="pref_show_emoji_key"
        android:title="@string/show_emoji_key"
        android:summary="@string/show_emoji_key_summary"
        android:defaultValue="false"
        android:defaultValue="true"
        android:persistent="true" />
    <CheckBoxPreference
        android:key="pref_show_longpress_hints"
+12 −0
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
    public static final String PREF_SHOW_LANGUAGE_SWITCH_KEY =
            "pref_show_language_switch_key";
    public static final String PREF_SHOW_EMOJI_KEY = "pref_show_emoji_key";
    private static final String PREF_SHOW_EMOJI_KEY_MIGRATED = "pref_show_emoji_key_migrated";
    public static final String PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST =
            "pref_include_other_imes_in_language_switch_list";
    public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles";
@@ -164,6 +165,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
        mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
        mPrefs.registerOnSharedPreferenceChangeListener(this);
        upgradeAutocorrectionSettings(mPrefs, mRes);
        upgradeShowEmojiKeySettings(mPrefs);
    }

    public void onDestroy() {
@@ -472,6 +474,16 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
        return prefs.getInt(PREF_LAST_SHOWN_EMOJI_CATEGORY_ID, defValue);
    }

    private void upgradeShowEmojiKeySettings(final SharedPreferences prefs) {
        if (!prefs.getBoolean(PREF_SHOW_EMOJI_KEY_MIGRATED, false)) {
            final SharedPreferences.Editor editor = prefs.edit();
            if (!prefs.getBoolean(PREF_SHOW_EMOJI_KEY, false)) {
                editor.putBoolean(PREF_SHOW_EMOJI_KEY, true);
            }
            editor.putBoolean(PREF_SHOW_EMOJI_KEY_MIGRATED, true).apply();
        }
    }

    private void upgradeAutocorrectionSettings(final SharedPreferences prefs, final Resources res) {
        final String thresholdSetting =
                prefs.getString(PREF_AUTO_CORRECTION_THRESHOLD_OBSOLETE, null);
+1 −1
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ public class SettingsValues {
                : true /* forcibly */;
        mShowsLanguageSwitchKey = Settings.ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS
                ? Settings.readShowsLanguageSwitchKey(prefs) : true /* forcibly */;
        mShowsEmojiKey = prefs.getBoolean(Settings.PREF_SHOW_EMOJI_KEY, false);
        mShowsEmojiKey = prefs.getBoolean(Settings.PREF_SHOW_EMOJI_KEY, true);
        mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true);
        mUsePersonalizedDicts = prefs.getBoolean(Settings.PREF_KEY_USE_PERSONALIZED_DICTS, true);
        mUseDoubleSpacePeriod = prefs.getBoolean(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true)