mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-14 05:52:47 +00:00
rename some prefs and add upgrade function when coming from old app name
This commit is contained in:
parent
b3a56bec10
commit
2020db2e63
15 changed files with 156 additions and 120 deletions
|
@ -2,6 +2,7 @@ package org.dslul.openboard.inputmethod.latin
|
|||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
import org.dslul.openboard.inputmethod.latin.settings.Settings
|
||||
import org.dslul.openboard.inputmethod.latin.settings.USER_DICTIONARY_SUFFIX
|
||||
|
@ -18,7 +19,8 @@ class App : Application() {
|
|||
|
||||
fun checkVersionUpgrade(context: Context) {
|
||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
||||
if (prefs.getInt(Settings.PREF_VERSION_CODE, 0) == BuildConfig.VERSION_CODE)
|
||||
val oldVersion = prefs.getInt(Settings.PREF_VERSION_CODE, 0)
|
||||
if (oldVersion == BuildConfig.VERSION_CODE)
|
||||
return
|
||||
upgradeToolbarPref(prefs)
|
||||
// clear extracted dictionaries, in case updated version contains newer ones
|
||||
|
@ -30,5 +32,38 @@ fun checkVersionUpgrade(context: Context) {
|
|||
file.delete()
|
||||
}
|
||||
}
|
||||
if (oldVersion == 0) // new install or restoring settings from old app name
|
||||
prefUpgradesWhenComingFromOldAppName(prefs)
|
||||
prefs.edit { putInt(Settings.PREF_VERSION_CODE, BuildConfig.VERSION_CODE) }
|
||||
}
|
||||
|
||||
// todo (later): remove it when most users probably have upgraded
|
||||
private fun prefUpgradesWhenComingFromOldAppName(prefs: SharedPreferences) {
|
||||
if (prefs.all.containsKey("theme_variant")) {
|
||||
prefs.edit().putString(Settings.PREF_THEME_COLORS, prefs.getString("theme_variant", "")).apply()
|
||||
prefs.edit().remove("theme_variant").apply()
|
||||
}
|
||||
if (prefs.all.containsKey("theme_variant_night")) {
|
||||
prefs.edit().putString(Settings.PREF_THEME_COLORS_NIGHT, prefs.getString("theme_variant_night", "")).apply()
|
||||
prefs.edit().remove("theme_variant_night").apply()
|
||||
}
|
||||
prefs.all.toMap().forEach {
|
||||
if (it.key.startsWith("pref_key_") && it.key != "pref_key_longpress_timeout") {
|
||||
when (val value = it.value) {
|
||||
is Boolean -> prefs.edit().putBoolean(it.key.substringAfter("pref_key_"), value).apply()
|
||||
is Int -> prefs.edit().putInt(it.key.substringAfter("pref_key_"), value).apply()
|
||||
is Long -> prefs.edit().putLong(it.key.substringAfter("pref_key_"), value).apply()
|
||||
is String -> prefs.edit().putString(it.key.substringAfter("pref_key_"), value).apply()
|
||||
is Float -> prefs.edit().putFloat(it.key.substringAfter("pref_key_"), value).apply()
|
||||
}
|
||||
} else if (it.key.startsWith("pref_")) {
|
||||
when (val value = it.value) {
|
||||
is Boolean -> prefs.edit().putBoolean(it.key.substringAfter("pref_"), value).apply()
|
||||
is Int -> prefs.edit().putInt(it.key.substringAfter("pref_"), value).apply()
|
||||
is Long -> prefs.edit().putLong(it.key.substringAfter("pref_"), value).apply()
|
||||
is String -> prefs.edit().putString(it.key.substringAfter("pref_"), value).apply()
|
||||
is Float -> prefs.edit().putFloat(it.key.substringAfter("pref_"), value).apply()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ class AboutFragment : SubScreenFragment() {
|
|||
}
|
||||
|
||||
private fun setupVersionPref() {
|
||||
val versionPreference = findPreference<Preference>("pref_key_version") ?: return
|
||||
val versionPreference = findPreference<Preference>("version") ?: return
|
||||
versionPreference.summary = BuildConfig.VERSION_NAME
|
||||
if (BuildConfig.DEBUG) return
|
||||
var count = 0
|
||||
|
|
|
@ -111,7 +111,7 @@ class AdvancedSettingsFragment : SubScreenFragment() {
|
|||
}
|
||||
setupKeyLongpressTimeoutSettings()
|
||||
findPreference<Preference>("load_gesture_library")?.setOnPreferenceClickListener { onClickLoadLibrary() }
|
||||
findPreference<Preference>("pref_backup_restore")?.setOnPreferenceClickListener { showBackupRestoreDialog() }
|
||||
findPreference<Preference>("backup_restore")?.setOnPreferenceClickListener { showBackupRestoreDialog() }
|
||||
findPreference<Preference>("custom_background_image")?.setOnPreferenceClickListener { onClickLoadImage() }
|
||||
|
||||
findPreference<Preference>("custom_symbols_layout")?.setOnPreferenceClickListener {
|
||||
|
|
|
@ -12,10 +12,10 @@ package org.dslul.openboard.inputmethod.latin.settings;
|
|||
public final class DebugSettings {
|
||||
public static final String PREF_DEBUG_MODE = "debug_mode";
|
||||
public static final String PREF_FORCE_NON_DISTINCT_MULTITOUCH = "force_non_distinct_multitouch";
|
||||
public static final String PREF_SLIDING_KEY_INPUT_PREVIEW = "pref_sliding_key_input_preview";
|
||||
public static final String PREF_SHOW_DEBUG_SETTINGS = "pref_show_debug_settings";
|
||||
public static final String PREF_SLIDING_KEY_INPUT_PREVIEW = "sliding_key_input_preview";
|
||||
public static final String PREF_SHOW_DEBUG_SETTINGS = "show_debug_settings";
|
||||
|
||||
public static final String PREF_SHOW_SUGGESTION_INFOS = "pref_show_suggestion_infos";
|
||||
public static final String PREF_SHOW_SUGGESTION_INFOS = "show_suggestion_infos";
|
||||
private DebugSettings() {
|
||||
// This class is not publicly instantiable.
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ import org.dslul.openboard.inputmethod.latin.R;
|
|||
*/
|
||||
public final class DebugSettingsFragment extends SubScreenFragment
|
||||
implements Preference.OnPreferenceClickListener {
|
||||
private static final String PREF_KEY_DUMP_DICTS = "pref_key_dump_dictionaries";
|
||||
private static final String PREF_KEY_DUMP_DICT_PREFIX = "pref_key_dump_dictionaries";
|
||||
private static final String PREF_KEY_DUMP_DICTS = "dump_dictionaries";
|
||||
private static final String PREF_KEY_DUMP_DICT_PREFIX = "dump_dictionaries";
|
||||
|
||||
private boolean mServiceNeedsRestart = false;
|
||||
private TwoStatePreference mDebugMode;
|
||||
|
|
|
@ -17,10 +17,6 @@ import android.graphics.Color;
|
|||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
|
||||
import org.dslul.openboard.inputmethod.latin.utils.CustomLayoutUtilsKt;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.Log;
|
||||
|
||||
import android.util.TypedValue;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.Gravity;
|
||||
|
@ -38,8 +34,10 @@ import org.dslul.openboard.inputmethod.latin.common.Colors;
|
|||
import org.dslul.openboard.inputmethod.latin.common.LocaleUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.AdditionalSubtypeUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.ColorUtilKt;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.CustomLayoutUtilsKt;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.DeviceProtectedUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.JniUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.Log;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.ResourceUtils;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.RunInLocaleKt;
|
||||
import org.dslul.openboard.inputmethod.latin.utils.ScriptUtils;
|
||||
|
@ -61,13 +59,10 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
public static final String SCREEN_DEBUG = "screen_debug";
|
||||
public static final String SCREEN_GESTURE = "screen_gesture";
|
||||
|
||||
public static final String PREF_AUTO_CAP = "auto_cap";
|
||||
public static final String PREF_VIBRATE_ON = "vibrate_on";
|
||||
public static final String PREF_SOUND_ON = "sound_on";
|
||||
public static final String PREF_POPUP_ON = "popup_on";
|
||||
// theme-related stuff
|
||||
public static final String PREF_THEME_STYLE = "theme_style";
|
||||
public static final String PREF_THEME_COLORS = "theme_variant";
|
||||
public static final String PREF_THEME_COLORS_NIGHT = "theme_variant_night";
|
||||
public static final String PREF_THEME_COLORS = "theme_colors";
|
||||
public static final String PREF_THEME_COLORS_NIGHT = "theme_colors_night";
|
||||
public static final String PREF_THEME_KEY_BORDERS = "theme_key_borders";
|
||||
public static final String PREF_THEME_DAY_NIGHT = "theme_auto_day_night";
|
||||
public static final String PREF_THEME_USER_COLOR_PREFIX = "theme_color_";
|
||||
|
@ -83,66 +78,72 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
public static final String PREF_COLOR_HINT_TEXT_SUFFIX = "hint_text";
|
||||
public static final String PREF_COLOR_BACKGROUND_SUFFIX = "background";
|
||||
public static final String PREF_AUTO_USER_COLOR_SUFFIX = "_auto";
|
||||
public static final String PREF_AUTO_CORRECTION = "pref_key_auto_correction";
|
||||
public static final String PREF_MORE_AUTO_CORRECTION = "pref_more_auto_correction";
|
||||
public static final String PREF_AUTO_CORRECTION_CONFIDENCE = "pref_key_auto_correction_confidence";
|
||||
|
||||
public static final String PREF_AUTO_CAP = "auto_cap";
|
||||
public static final String PREF_VIBRATE_ON = "vibrate_on";
|
||||
public static final String PREF_SOUND_ON = "sound_on";
|
||||
public static final String PREF_POPUP_ON = "popup_on";
|
||||
public static final String PREF_AUTO_CORRECTION = "auto_correction";
|
||||
public static final String PREF_MORE_AUTO_CORRECTION = "more_auto_correction";
|
||||
public static final String PREF_AUTO_CORRECTION_CONFIDENCE = "auto_correction_confidence";
|
||||
public static final String PREF_SHOW_SUGGESTIONS = "show_suggestions";
|
||||
public static final String PREF_ALWAYS_SHOW_SUGGESTIONS = "pref_always_show_suggestions";
|
||||
public static final String PREF_KEY_USE_PERSONALIZED_DICTS = "pref_key_use_personalized_dicts";
|
||||
public static final String PREF_KEY_USE_DOUBLE_SPACE_PERIOD = "pref_key_use_double_space_period";
|
||||
public static final String PREF_BLOCK_POTENTIALLY_OFFENSIVE = "pref_key_block_potentially_offensive";
|
||||
public static final String PREF_LANGUAGE_SWITCH_KEY = "pref_language_switch_key";
|
||||
public static final String PREF_SHOW_EMOJI_KEY = "pref_show_emoji_key";
|
||||
public static final String PREF_ADDITIONAL_SUBTYPES = "pref_additional_subtypes";
|
||||
public static final String PREF_ENABLE_SPLIT_KEYBOARD = "pref_split_keyboard";
|
||||
public static final String PREF_SPLIT_SPACER_SCALE = "pref_split_spacer_scale";
|
||||
public static final String PREF_KEYBOARD_HEIGHT_SCALE = "pref_keyboard_height_scale";
|
||||
public static final String PREF_BOTTOM_PADDING_SCALE = "pref_bottom_padding_scale";
|
||||
public static final String PREF_SPACE_TRACKPAD = "pref_space_trackpad";
|
||||
public static final String PREF_DELETE_SWIPE = "pref_delete_swipe";
|
||||
public static final String PREF_AUTOSPACE_AFTER_PUNCTUATION = "pref_autospace_after_punctuation";
|
||||
public static final String PREF_ALWAYS_INCOGNITO_MODE = "pref_always_incognito_mode";
|
||||
public static final String PREF_ALWAYS_SHOW_SUGGESTIONS = "always_show_suggestions";
|
||||
public static final String PREF_KEY_USE_PERSONALIZED_DICTS = "use_personalized_dicts";
|
||||
public static final String PREF_KEY_USE_DOUBLE_SPACE_PERIOD = "use_double_space_period";
|
||||
public static final String PREF_BLOCK_POTENTIALLY_OFFENSIVE = "block_potentially_offensive";
|
||||
public static final String PREF_LANGUAGE_SWITCH_KEY = "language_switch_key";
|
||||
public static final String PREF_SHOW_EMOJI_KEY = "show_emoji_key";
|
||||
public static final String PREF_ADDITIONAL_SUBTYPES = "additional_subtypes";
|
||||
public static final String PREF_ENABLE_SPLIT_KEYBOARD = "split_keyboard";
|
||||
public static final String PREF_SPLIT_SPACER_SCALE = "split_spacer_scale";
|
||||
public static final String PREF_KEYBOARD_HEIGHT_SCALE = "keyboard_height_scale";
|
||||
public static final String PREF_BOTTOM_PADDING_SCALE = "bottom_padding_scale";
|
||||
public static final String PREF_SPACE_TRACKPAD = "space_trackpad";
|
||||
public static final String PREF_DELETE_SWIPE = "delete_swipe";
|
||||
public static final String PREF_AUTOSPACE_AFTER_PUNCTUATION = "autospace_after_punctuation";
|
||||
public static final String PREF_ALWAYS_INCOGNITO_MODE = "always_incognito_mode";
|
||||
public static final String PREF_BIGRAM_PREDICTIONS = "next_word_prediction";
|
||||
public static final String PREF_GESTURE_INPUT = "gesture_input";
|
||||
public static final String PREF_VIBRATION_DURATION_SETTINGS = "pref_vibration_duration_settings";
|
||||
public static final String PREF_KEYPRESS_SOUND_VOLUME = "pref_keypress_sound_volume";
|
||||
public static final String PREF_KEY_LONGPRESS_TIMEOUT = "pref_key_longpress_timeout";
|
||||
public static final String PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY = "pref_enable_emoji_alt_physical_key";
|
||||
public static final String PREF_GESTURE_PREVIEW_TRAIL = "pref_gesture_preview_trail";
|
||||
public static final String PREF_GESTURE_FLOATING_PREVIEW_TEXT = "pref_gesture_floating_preview_text";
|
||||
public static final String PREF_GESTURE_SPACE_AWARE = "pref_gesture_space_aware";
|
||||
public static final String PREF_SHOW_SETUP_WIZARD_ICON = "pref_show_setup_wizard_icon";
|
||||
public static final String PREF_VIBRATION_DURATION_SETTINGS = "vibration_duration_settings";
|
||||
public static final String PREF_KEYPRESS_SOUND_VOLUME = "keypress_sound_volume";
|
||||
public static final String PREF_KEY_LONGPRESS_TIMEOUT = "key_longpress_timeout";
|
||||
public static final String PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY = "enable_emoji_alt_physical_key";
|
||||
public static final String PREF_GESTURE_PREVIEW_TRAIL = "gesture_preview_trail";
|
||||
public static final String PREF_GESTURE_FLOATING_PREVIEW_TEXT = "gesture_floating_preview_text";
|
||||
public static final String PREF_GESTURE_SPACE_AWARE = "gesture_space_aware";
|
||||
public static final String PREF_SHOW_SETUP_WIZARD_ICON = "show_setup_wizard_icon";
|
||||
|
||||
public static final String PREF_ONE_HANDED_MODE_PREFIX = "pref_one_handed_mode_enabled_p_";
|
||||
public static final String PREF_ONE_HANDED_GRAVITY_PREFIX = "pref_one_handed_mode_gravity_p_";
|
||||
public static final String PREF_ONE_HANDED_SCALE_PREFIX = "pref_one_handed_mode_scale_p_";
|
||||
// one-handed mode gravity, enablement and scale, stored separately per orientation
|
||||
public static final String PREF_ONE_HANDED_MODE_PREFIX = "one_handed_mode_enabled_p_";
|
||||
public static final String PREF_ONE_HANDED_GRAVITY_PREFIX = "one_handed_mode_gravity_p_";
|
||||
public static final String PREF_ONE_HANDED_SCALE_PREFIX = "one_handed_mode_scale_p_";
|
||||
|
||||
public static final String PREF_SHOW_NUMBER_ROW = "pref_show_number_row";
|
||||
public static final String PREF_LOCALIZED_NUMBER_ROW = "pref_localized_number_row";
|
||||
public static final String PREF_SHOW_NUMBER_ROW = "show_number_row";
|
||||
public static final String PREF_LOCALIZED_NUMBER_ROW = "localized_number_row";
|
||||
|
||||
public static final String PREF_SHOW_HINTS = "pref_show_hints";
|
||||
public static final String PREF_MORE_KEYS_ORDER = "pref_more_keys_order";
|
||||
public static final String PREF_MORE_KEYS_LABELS_ORDER = "pref_more_keys_labels_order";
|
||||
public static final String PREF_SHOW_POPUP_HINTS = "pref_show_popup_hints";
|
||||
public static final String PREF_MORE_MORE_KEYS = "pref_more_more_keys";
|
||||
public static final String PREF_SHOW_HINTS = "show_hints";
|
||||
public static final String PREF_MORE_KEYS_ORDER = "more_keys_order";
|
||||
public static final String PREF_MORE_KEYS_LABELS_ORDER = "more_keys_labels_order";
|
||||
public static final String PREF_SHOW_POPUP_HINTS = "show_popup_hints";
|
||||
public static final String PREF_MORE_MORE_KEYS = "more_more_keys";
|
||||
|
||||
public static final String PREF_SPACE_TO_CHANGE_LANG = "prefs_long_press_keyboard_to_change_lang";
|
||||
public static final String PREF_SPACE_LANGUAGE_SLIDE = "pref_space_language_slide";
|
||||
public static final String PREF_SPACE_LANGUAGE_SLIDE = "space_language_slide";
|
||||
|
||||
public static final String PREF_ENABLE_CLIPBOARD_HISTORY = "pref_enable_clipboard_history";
|
||||
public static final String PREF_CLIPBOARD_HISTORY_RETENTION_TIME = "pref_clipboard_history_retention_time";
|
||||
public static final String PREF_ENABLE_CLIPBOARD_HISTORY = "enable_clipboard_history";
|
||||
public static final String PREF_CLIPBOARD_HISTORY_RETENTION_TIME = "clipboard_history_retention_time";
|
||||
|
||||
public static final String PREF_SECONDARY_LOCALES_PREFIX = "pref_secondary_locales_";
|
||||
public static final String PREF_ADD_TO_PERSONAL_DICTIONARY = "pref_add_to_personal_dictionary";
|
||||
public static final String PREF_NAVBAR_COLOR = "pref_navbar_color";
|
||||
public static final String PREF_NARROW_KEY_GAPS = "pref_narrow_key_gaps";
|
||||
public static final String PREF_ENABLED_INPUT_STYLES = "pref_enabled_input_styles";
|
||||
public static final String PREF_SELECTED_INPUT_STYLE = "pref_selected_input_style";
|
||||
public static final String PREF_USE_SYSTEM_LOCALES = "pref_use_system_locales";
|
||||
public static final String PREF_URL_DETECTION = "pref_url_detection";
|
||||
public static final String PREF_DONT_SHOW_MISSING_DICTIONARY_DIALOG = "pref_dont_show_missing_dict_dialog";
|
||||
public static final String PREF_PINNED_TOOLBAR_KEYS = "pref_pinned_toolbar_keys";
|
||||
public static final String PREF_TOOLBAR_KEYS = "pref_toolbar_keys";
|
||||
public static final String PREF_SECONDARY_LOCALES_PREFIX = "secondary_locales_";
|
||||
public static final String PREF_ADD_TO_PERSONAL_DICTIONARY = "add_to_personal_dictionary";
|
||||
public static final String PREF_NAVBAR_COLOR = "navbar_color";
|
||||
public static final String PREF_NARROW_KEY_GAPS = "narrow_key_gaps";
|
||||
public static final String PREF_ENABLED_INPUT_STYLES = "enabled_input_styles";
|
||||
public static final String PREF_SELECTED_INPUT_STYLE = "selected_input_style";
|
||||
public static final String PREF_USE_SYSTEM_LOCALES = "use_system_locales";
|
||||
public static final String PREF_URL_DETECTION = "url_detection";
|
||||
public static final String PREF_DONT_SHOW_MISSING_DICTIONARY_DIALOG = "dont_show_missing_dict_dialog";
|
||||
public static final String PREF_PINNED_TOOLBAR_KEYS = "pinned_toolbar_keys";
|
||||
public static final String PREF_TOOLBAR_KEYS = "toolbar_keys";
|
||||
|
||||
// Emoji
|
||||
public static final String PREF_EMOJI_RECENT_KEYS = "emoji_recent_keys";
|
||||
|
@ -153,7 +154,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
public static final String PREF_VERSION_CODE = "version_code";
|
||||
// used as a workaround against keyboard not showing edited theme in ColorsSettingsFragment
|
||||
public static final String PREF_FORCE_OPPOSITE_THEME = "force_opposite_theme";
|
||||
public static final String PREF_SHOW_ALL_COLORS = "pref_show_all_colors";
|
||||
public static final String PREF_SHOW_ALL_COLORS = "show_all_colors";
|
||||
|
||||
private static final float UNDEFINED_PREFERENCE_VALUE_FLOAT = -1.0f;
|
||||
private static final int UNDEFINED_PREFERENCE_VALUE_INT = -1;
|
||||
|
|
|
@ -43,7 +43,7 @@ import java.util.concurrent.Semaphore;
|
|||
public final class AndroidSpellCheckerService extends SpellCheckerService
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
public static final String PREF_USE_CONTACTS_KEY = "pref_spellcheck_use_contacts";
|
||||
public static final String PREF_USE_CONTACTS_KEY = "spellcheck_use_contacts";
|
||||
|
||||
public static final int SPELLCHECKER_DUMMY_KEYBOARD_WIDTH = 480;
|
||||
public static final int SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT = 301;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue