mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-07 23:27:45 +00:00
use context.prefs() instead of the long DeviceProtected...
This commit is contained in:
parent
deb9dda7e7
commit
125a483591
29 changed files with 112 additions and 113 deletions
|
@ -44,7 +44,7 @@ import helium314.keyboard.latin.settings.SettingsValues;
|
||||||
import helium314.keyboard.latin.suggestions.SuggestionStripView;
|
import helium314.keyboard.latin.suggestions.SuggestionStripView;
|
||||||
import helium314.keyboard.latin.utils.AdditionalSubtypeUtils;
|
import helium314.keyboard.latin.utils.AdditionalSubtypeUtils;
|
||||||
import helium314.keyboard.latin.utils.CapsModeUtils;
|
import helium314.keyboard.latin.utils.CapsModeUtils;
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils;
|
import helium314.keyboard.latin.utils.KtxKt;
|
||||||
import helium314.keyboard.latin.utils.LanguageOnSpacebarUtils;
|
import helium314.keyboard.latin.utils.LanguageOnSpacebarUtils;
|
||||||
import helium314.keyboard.latin.utils.Log;
|
import helium314.keyboard.latin.utils.Log;
|
||||||
import helium314.keyboard.latin.utils.RecapitalizeStatus;
|
import helium314.keyboard.latin.utils.RecapitalizeStatus;
|
||||||
|
@ -651,7 +651,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
mKeyboardView.closing();
|
mKeyboardView.closing();
|
||||||
}
|
}
|
||||||
PointerTracker.clearOldViewData();
|
PointerTracker.clearOldViewData();
|
||||||
final SharedPreferences prefs = DeviceProtectedUtils.getSharedPreferences(displayContext);
|
final SharedPreferences prefs = KtxKt.prefs(displayContext);
|
||||||
if (mSuggestionStripView != null)
|
if (mSuggestionStripView != null)
|
||||||
prefs.unregisterOnSharedPreferenceChangeListener(mSuggestionStripView);
|
prefs.unregisterOnSharedPreferenceChangeListener(mSuggestionStripView);
|
||||||
if (mClipboardHistoryView != null)
|
if (mClipboardHistoryView != null)
|
||||||
|
|
|
@ -18,7 +18,7 @@ import helium314.keyboard.latin.common.DefaultColors
|
||||||
import helium314.keyboard.latin.common.DynamicColors
|
import helium314.keyboard.latin.common.DynamicColors
|
||||||
import helium314.keyboard.latin.common.readAllColorsMap
|
import helium314.keyboard.latin.common.readAllColorsMap
|
||||||
import helium314.keyboard.latin.settings.Settings
|
import helium314.keyboard.latin.settings.Settings
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
import helium314.keyboard.latin.utils.prefs
|
||||||
|
|
||||||
class KeyboardTheme // Note: The themeId should be aligned with "themeId" attribute of Keyboard style in values/themes-<style>.xml.
|
class KeyboardTheme // Note: The themeId should be aligned with "themeId" attribute of Keyboard style in values/themes-<style>.xml.
|
||||||
private constructor(val themeId: Int, @JvmField val mStyleId: Int) {
|
private constructor(val themeId: Int, @JvmField val mStyleId: Int) {
|
||||||
|
@ -84,7 +84,7 @@ private constructor(val themeId: Int, @JvmField val mStyleId: Int) {
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getKeyboardTheme(context: Context): KeyboardTheme {
|
fun getKeyboardTheme(context: Context): KeyboardTheme {
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
val prefs = context.prefs()
|
||||||
val style = prefs.getString(Settings.PREF_THEME_STYLE, STYLE_MATERIAL)
|
val style = prefs.getString(Settings.PREF_THEME_STYLE, STYLE_MATERIAL)
|
||||||
val borders = prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, false)
|
val borders = prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, false)
|
||||||
val matchingId = when (style) {
|
val matchingId = when (style) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ import helium314.keyboard.latin.common.CoordinateUtils;
|
||||||
import helium314.keyboard.latin.define.DebugFlags;
|
import helium314.keyboard.latin.define.DebugFlags;
|
||||||
import helium314.keyboard.latin.settings.DebugSettings;
|
import helium314.keyboard.latin.settings.DebugSettings;
|
||||||
import helium314.keyboard.latin.settings.Settings;
|
import helium314.keyboard.latin.settings.Settings;
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils;
|
import helium314.keyboard.latin.utils.KtxKt;
|
||||||
import helium314.keyboard.latin.utils.LanguageOnSpacebarUtils;
|
import helium314.keyboard.latin.utils.LanguageOnSpacebarUtils;
|
||||||
import helium314.keyboard.latin.utils.Log;
|
import helium314.keyboard.latin.utils.Log;
|
||||||
import helium314.keyboard.latin.utils.TypefaceUtils;
|
import helium314.keyboard.latin.utils.TypefaceUtils;
|
||||||
|
@ -151,7 +151,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
|
||||||
|
|
||||||
PointerTracker.init(mainKeyboardViewAttr, mTimerHandler, this /* DrawingProxy */);
|
PointerTracker.init(mainKeyboardViewAttr, mTimerHandler, this /* DrawingProxy */);
|
||||||
|
|
||||||
final SharedPreferences prefs = DeviceProtectedUtils.getSharedPreferences(context);
|
final SharedPreferences prefs = KtxKt.prefs(context);
|
||||||
final boolean forceNonDistinctMultitouch = prefs.getBoolean(
|
final boolean forceNonDistinctMultitouch = prefs.getBoolean(
|
||||||
DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH, false);
|
DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH, false);
|
||||||
final boolean hasDistinctMultitouch = context.getPackageManager()
|
final boolean hasDistinctMultitouch = context.getPackageManager()
|
||||||
|
|
|
@ -28,13 +28,13 @@ import helium314.keyboard.latin.R
|
||||||
import helium314.keyboard.latin.common.ColorType
|
import helium314.keyboard.latin.common.ColorType
|
||||||
import helium314.keyboard.latin.common.Constants
|
import helium314.keyboard.latin.common.Constants
|
||||||
import helium314.keyboard.latin.settings.Settings
|
import helium314.keyboard.latin.settings.Settings
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
|
||||||
import helium314.keyboard.latin.utils.ResourceUtils
|
import helium314.keyboard.latin.utils.ResourceUtils
|
||||||
import helium314.keyboard.latin.utils.ToolbarKey
|
import helium314.keyboard.latin.utils.ToolbarKey
|
||||||
import helium314.keyboard.latin.utils.createToolbarKey
|
import helium314.keyboard.latin.utils.createToolbarKey
|
||||||
import helium314.keyboard.latin.utils.getCodeForToolbarKey
|
import helium314.keyboard.latin.utils.getCodeForToolbarKey
|
||||||
import helium314.keyboard.latin.utils.getCodeForToolbarKeyLongClick
|
import helium314.keyboard.latin.utils.getCodeForToolbarKeyLongClick
|
||||||
import helium314.keyboard.latin.utils.getEnabledClipboardToolbarKeys
|
import helium314.keyboard.latin.utils.getEnabledClipboardToolbarKeys
|
||||||
|
import helium314.keyboard.latin.utils.prefs
|
||||||
import helium314.keyboard.latin.utils.setToolbarButtonsActivatedStateOnPrefChange
|
import helium314.keyboard.latin.utils.setToolbarButtonsActivatedStateOnPrefChange
|
||||||
|
|
||||||
@SuppressLint("CustomViewStyleable")
|
@SuppressLint("CustomViewStyleable")
|
||||||
|
@ -68,7 +68,7 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
||||||
keyBackgroundId = keyboardViewAttr.getResourceId(R.styleable.KeyboardView_keyBackground, 0)
|
keyBackgroundId = keyboardViewAttr.getResourceId(R.styleable.KeyboardView_keyBackground, 0)
|
||||||
keyboardViewAttr.recycle()
|
keyboardViewAttr.recycle()
|
||||||
val keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle, R.style.SuggestionStripView)
|
val keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle, R.style.SuggestionStripView)
|
||||||
getEnabledClipboardToolbarKeys(DeviceProtectedUtils.getSharedPreferences(context))
|
getEnabledClipboardToolbarKeys(context.prefs())
|
||||||
.forEach { toolbarKeys.add(createToolbarKey(context, KeyboardIconsSet.instance, it)) }
|
.forEach { toolbarKeys.add(createToolbarKey(context, KeyboardIconsSet.instance, it)) }
|
||||||
keyboardAttr.recycle()
|
keyboardAttr.recycle()
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import android.content.res.TypedArray;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils;
|
import helium314.keyboard.latin.utils.KtxKt;
|
||||||
import helium314.keyboard.latin.utils.Log;
|
import helium314.keyboard.latin.utils.Log;
|
||||||
|
|
||||||
import androidx.core.graphics.PaintCompat;
|
import androidx.core.graphics.PaintCompat;
|
||||||
|
@ -129,7 +129,7 @@ final class EmojiCategory {
|
||||||
private int mCurrentCategoryPageId = 0;
|
private int mCurrentCategoryPageId = 0;
|
||||||
|
|
||||||
public EmojiCategory(final Context ctx, final KeyboardLayoutSet layoutSet, final TypedArray emojiPaletteViewAttr) {
|
public EmojiCategory(final Context ctx, final KeyboardLayoutSet layoutSet, final TypedArray emojiPaletteViewAttr) {
|
||||||
mPrefs = DeviceProtectedUtils.getSharedPreferences(ctx);
|
mPrefs = KtxKt.prefs(ctx);
|
||||||
mRes = ctx.getResources();
|
mRes = ctx.getResources();
|
||||||
mContext = ctx;
|
mContext = ctx;
|
||||||
mMaxRecentsKeyCount = mRes.getInteger(R.integer.config_emoji_keyboard_max_recents_key_count);
|
mMaxRecentsKeyCount = mRes.getInteger(R.integer.config_emoji_keyboard_max_recents_key_count);
|
||||||
|
|
|
@ -8,9 +8,9 @@ import helium314.keyboard.keyboard.KeyboardTheme
|
||||||
import helium314.keyboard.latin.R
|
import helium314.keyboard.latin.R
|
||||||
import helium314.keyboard.latin.customIconIds
|
import helium314.keyboard.latin.customIconIds
|
||||||
import helium314.keyboard.latin.settings.Settings
|
import helium314.keyboard.latin.settings.Settings
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
|
||||||
import helium314.keyboard.latin.utils.Log
|
import helium314.keyboard.latin.utils.Log
|
||||||
import helium314.keyboard.latin.utils.ToolbarKey
|
import helium314.keyboard.latin.utils.ToolbarKey
|
||||||
|
import helium314.keyboard.latin.utils.prefs
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
class KeyboardIconsSet private constructor() {
|
class KeyboardIconsSet private constructor() {
|
||||||
|
@ -19,7 +19,7 @@ class KeyboardIconsSet private constructor() {
|
||||||
private val iconsByName = HashMap<String, Drawable>(80)
|
private val iconsByName = HashMap<String, Drawable>(80)
|
||||||
|
|
||||||
fun loadIcons(context: Context) {
|
fun loadIcons(context: Context) {
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
val prefs = context.prefs()
|
||||||
val iconStyle = prefs.getString(Settings.PREF_ICON_STYLE, KeyboardTheme.STYLE_MATERIAL)
|
val iconStyle = prefs.getString(Settings.PREF_ICON_STYLE, KeyboardTheme.STYLE_MATERIAL)
|
||||||
val defaultIds = when (iconStyle) {
|
val defaultIds = when (iconStyle) {
|
||||||
KeyboardTheme.STYLE_HOLO -> keyboardIconsHolo
|
KeyboardTheme.STYLE_HOLO -> keyboardIconsHolo
|
||||||
|
@ -281,8 +281,7 @@ class KeyboardIconsSet private constructor() {
|
||||||
|
|
||||||
fun getAllIcons(context: Context): Map<String, List<Int>> {
|
fun getAllIcons(context: Context): Map<String, List<Int>> {
|
||||||
// currently active style first
|
// currently active style first
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
val iconStyle = context.prefs().getString(Settings.PREF_ICON_STYLE, KeyboardTheme.STYLE_MATERIAL)
|
||||||
val iconStyle = prefs.getString(Settings.PREF_ICON_STYLE, KeyboardTheme.STYLE_MATERIAL)
|
|
||||||
return keyboardIconsMaterial.entries.associate { (name, id) ->
|
return keyboardIconsMaterial.entries.associate { (name, id) ->
|
||||||
name to when (iconStyle) {
|
name to when (iconStyle) {
|
||||||
KeyboardTheme.STYLE_HOLO -> listOfNotNull(keyboardIconsHolo[name], keyboardIconsRounded[name], id)
|
KeyboardTheme.STYLE_HOLO -> listOfNotNull(keyboardIconsHolo[name], keyboardIconsRounded[name], id)
|
||||||
|
|
|
@ -9,14 +9,13 @@ import helium314.keyboard.latin.common.LocaleUtils.constructLocale
|
||||||
import helium314.keyboard.latin.settings.Settings
|
import helium314.keyboard.latin.settings.Settings
|
||||||
import helium314.keyboard.latin.settings.USER_DICTIONARY_SUFFIX
|
import helium314.keyboard.latin.settings.USER_DICTIONARY_SUFFIX
|
||||||
import helium314.keyboard.latin.utils.CUSTOM_LAYOUT_PREFIX
|
import helium314.keyboard.latin.utils.CUSTOM_LAYOUT_PREFIX
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
|
||||||
import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
||||||
import helium314.keyboard.latin.utils.Log
|
|
||||||
import helium314.keyboard.latin.utils.ToolbarKey
|
import helium314.keyboard.latin.utils.ToolbarKey
|
||||||
import helium314.keyboard.latin.utils.defaultPinnedToolbarPref
|
import helium314.keyboard.latin.utils.defaultPinnedToolbarPref
|
||||||
import helium314.keyboard.latin.utils.getCustomLayoutFile
|
import helium314.keyboard.latin.utils.getCustomLayoutFile
|
||||||
import helium314.keyboard.latin.utils.getCustomLayoutFiles
|
import helium314.keyboard.latin.utils.getCustomLayoutFiles
|
||||||
import helium314.keyboard.latin.utils.onCustomLayoutFileListChanged
|
import helium314.keyboard.latin.utils.onCustomLayoutFileListChanged
|
||||||
|
import helium314.keyboard.latin.utils.prefs
|
||||||
import helium314.keyboard.latin.utils.upgradeToolbarPrefs
|
import helium314.keyboard.latin.utils.upgradeToolbarPrefs
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
@ -39,7 +38,7 @@ class App : Application() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkVersionUpgrade(context: Context) {
|
fun checkVersionUpgrade(context: Context) {
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
val prefs = context.prefs()
|
||||||
val oldVersion = prefs.getInt(Settings.PREF_VERSION_CODE, 0)
|
val oldVersion = prefs.getInt(Settings.PREF_VERSION_CODE, 0)
|
||||||
if (oldVersion == BuildConfig.VERSION_CODE)
|
if (oldVersion == BuildConfig.VERSION_CODE)
|
||||||
return
|
return
|
||||||
|
@ -171,7 +170,7 @@ private fun upgradesWhenComingFromOldAppName(context: Context) {
|
||||||
}
|
}
|
||||||
} catch (_: Exception) {}
|
} catch (_: Exception) {}
|
||||||
// upgrade prefs
|
// upgrade prefs
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
val prefs = context.prefs()
|
||||||
if (prefs.all.containsKey("theme_variant")) {
|
if (prefs.all.containsKey("theme_variant")) {
|
||||||
prefs.edit().putString(Settings.PREF_THEME_COLORS, prefs.getString("theme_variant", "")).apply()
|
prefs.edit().putString(Settings.PREF_THEME_COLORS, prefs.getString("theme_variant", "")).apply()
|
||||||
prefs.edit().remove("theme_variant").apply()
|
prefs.edit().remove("theme_variant").apply()
|
||||||
|
|
|
@ -11,7 +11,6 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import kotlinx.serialization.encodeToString
|
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import helium314.keyboard.compat.ClipboardManagerCompat
|
import helium314.keyboard.compat.ClipboardManagerCompat
|
||||||
import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyCode
|
import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyCode
|
||||||
|
@ -19,9 +18,9 @@ import helium314.keyboard.latin.common.ColorType
|
||||||
import helium314.keyboard.latin.common.isValidNumber
|
import helium314.keyboard.latin.common.isValidNumber
|
||||||
import helium314.keyboard.latin.databinding.ClipboardSuggestionBinding
|
import helium314.keyboard.latin.databinding.ClipboardSuggestionBinding
|
||||||
import helium314.keyboard.latin.settings.Settings
|
import helium314.keyboard.latin.settings.Settings
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
|
||||||
import helium314.keyboard.latin.utils.InputTypeUtils
|
import helium314.keyboard.latin.utils.InputTypeUtils
|
||||||
import helium314.keyboard.latin.utils.ToolbarKey
|
import helium314.keyboard.latin.utils.ToolbarKey
|
||||||
|
import helium314.keyboard.latin.utils.prefs
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
class ClipboardHistoryManager(
|
class ClipboardHistoryManager(
|
||||||
|
@ -37,7 +36,7 @@ class ClipboardHistoryManager(
|
||||||
clipboardManager.addPrimaryClipChangedListener(this)
|
clipboardManager.addPrimaryClipChangedListener(this)
|
||||||
if (historyEntries.isEmpty())
|
if (historyEntries.isEmpty())
|
||||||
loadPinnedClips()
|
loadPinnedClips()
|
||||||
if (Settings.readClipboardHistoryEnabled(DeviceProtectedUtils.getSharedPreferences(latinIME)))
|
if (Settings.readClipboardHistoryEnabled(latinIME.prefs()))
|
||||||
fetchPrimaryClip()
|
fetchPrimaryClip()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import android.text.TextUtils;
|
||||||
|
|
||||||
import helium314.keyboard.latin.common.StringUtilsKt;
|
import helium314.keyboard.latin.common.StringUtilsKt;
|
||||||
import helium314.keyboard.latin.settings.SettingsValues;
|
import helium314.keyboard.latin.settings.SettingsValues;
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils;
|
import helium314.keyboard.latin.utils.KtxKt;
|
||||||
import helium314.keyboard.latin.utils.Log;
|
import helium314.keyboard.latin.utils.Log;
|
||||||
import android.util.LruCache;
|
import android.util.LruCache;
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
|
||||||
Log.i(TAG, "resetDictionaries, force reloading main dictionary: " + forceReloadMainDictionary);
|
Log.i(TAG, "resetDictionaries, force reloading main dictionary: " + forceReloadMainDictionary);
|
||||||
final List<Locale> allLocales = new ArrayList<>() {{
|
final List<Locale> allLocales = new ArrayList<>() {{
|
||||||
add(newLocale);
|
add(newLocale);
|
||||||
addAll(Settings.getSecondaryLocales(DeviceProtectedUtils.getSharedPreferences(context), newLocale));
|
addAll(Settings.getSecondaryLocales(KtxKt.prefs(context), newLocale));
|
||||||
}};
|
}};
|
||||||
|
|
||||||
// Do not use contacts dictionary if we do not have permissions to read contacts.
|
// Do not use contacts dictionary if we do not have permissions to read contacts.
|
||||||
|
|
|
@ -18,7 +18,7 @@ import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyCode
|
||||||
import helium314.keyboard.latin.common.ColorType
|
import helium314.keyboard.latin.common.ColorType
|
||||||
import helium314.keyboard.latin.common.Constants
|
import helium314.keyboard.latin.common.Constants
|
||||||
import helium314.keyboard.latin.settings.Settings
|
import helium314.keyboard.latin.settings.Settings
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
import helium314.keyboard.latin.utils.prefs
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
class KeyboardWrapperView @JvmOverloads constructor(
|
class KeyboardWrapperView @JvmOverloads constructor(
|
||||||
|
@ -78,8 +78,7 @@ class KeyboardWrapperView @JvmOverloads constructor(
|
||||||
val changePercent = 2 * sign * (x - motionEvent.rawX) / context.resources.displayMetrics.density
|
val changePercent = 2 * sign * (x - motionEvent.rawX) / context.resources.displayMetrics.density
|
||||||
if (abs(changePercent) < 1) return@setOnTouchListener true
|
if (abs(changePercent) < 1) return@setOnTouchListener true
|
||||||
x = motionEvent.rawX
|
x = motionEvent.rawX
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
val oldScale = Settings.readOneHandedModeScale(context.prefs(), Settings.getInstance().current.mDisplayOrientation == Configuration.ORIENTATION_PORTRAIT)
|
||||||
val oldScale = Settings.readOneHandedModeScale(prefs, Settings.getInstance().current.mDisplayOrientation == Configuration.ORIENTATION_PORTRAIT)
|
|
||||||
val newScale = (oldScale + changePercent / 100f).coerceAtMost(2.5f).coerceAtLeast(0.5f)
|
val newScale = (oldScale + changePercent / 100f).coerceAtMost(2.5f).coerceAtLeast(0.5f)
|
||||||
if (newScale == oldScale) return@setOnTouchListener true
|
if (newScale == oldScale) return@setOnTouchListener true
|
||||||
Settings.getInstance().writeOneHandedModeScale(newScale)
|
Settings.getInstance().writeOneHandedModeScale(newScale)
|
||||||
|
|
|
@ -18,7 +18,7 @@ import android.view.inputmethod.InputMethodSubtype;
|
||||||
import helium314.keyboard.compat.ConfigurationCompatKt;
|
import helium314.keyboard.compat.ConfigurationCompatKt;
|
||||||
import helium314.keyboard.latin.common.LocaleUtils;
|
import helium314.keyboard.latin.common.LocaleUtils;
|
||||||
import helium314.keyboard.latin.settings.Settings;
|
import helium314.keyboard.latin.settings.Settings;
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils;
|
import helium314.keyboard.latin.utils.KtxKt;
|
||||||
import helium314.keyboard.latin.utils.LanguageOnSpacebarUtils;
|
import helium314.keyboard.latin.utils.LanguageOnSpacebarUtils;
|
||||||
import helium314.keyboard.latin.utils.Log;
|
import helium314.keyboard.latin.utils.Log;
|
||||||
import helium314.keyboard.latin.utils.ScriptUtils;
|
import helium314.keyboard.latin.utils.ScriptUtils;
|
||||||
|
@ -171,7 +171,7 @@ public class RichInputMethodManager {
|
||||||
if (imi == getInputMethodOfThisIme()) {
|
if (imi == getInputMethodOfThisIme()) {
|
||||||
// allowsImplicitlySelectedSubtypes means system should choose if nothing is enabled,
|
// allowsImplicitlySelectedSubtypes means system should choose if nothing is enabled,
|
||||||
// use it to fall back to system locales or en_US to avoid returning an empty list
|
// use it to fall back to system locales or en_US to avoid returning an empty list
|
||||||
result = SubtypeSettingsKt.getEnabledSubtypes(DeviceProtectedUtils.getSharedPreferences(sInstance.mContext), allowsImplicitlySelectedSubtypes);
|
result = SubtypeSettingsKt.getEnabledSubtypes(KtxKt.prefs(sInstance.mContext), allowsImplicitlySelectedSubtypes);
|
||||||
} else {
|
} else {
|
||||||
result = mImm.getEnabledInputMethodSubtypeList(imi, allowsImplicitlySelectedSubtypes);
|
result = mImm.getEnabledInputMethodSubtypeList(imi, allowsImplicitlySelectedSubtypes);
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,7 @@ public class RichInputMethodManager {
|
||||||
|
|
||||||
// search for first secondary language & script match
|
// search for first secondary language & script match
|
||||||
final int count = subtypes.size();
|
final int count = subtypes.size();
|
||||||
final SharedPreferences prefs = DeviceProtectedUtils.getSharedPreferences(mContext);
|
final SharedPreferences prefs = KtxKt.prefs(mContext);
|
||||||
final String language = locale.getLanguage();
|
final String language = locale.getLanguage();
|
||||||
final String script = ScriptUtils.script(locale);
|
final String script = ScriptUtils.script(locale);
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
|
@ -350,13 +350,13 @@ public class RichInputMethodManager {
|
||||||
|
|
||||||
public void refreshSubtypeCaches() {
|
public void refreshSubtypeCaches() {
|
||||||
mInputMethodInfoCache.clear();
|
mInputMethodInfoCache.clear();
|
||||||
SharedPreferences prefs = DeviceProtectedUtils.getSharedPreferences(mContext);
|
SharedPreferences prefs = KtxKt.prefs(mContext);
|
||||||
updateCurrentSubtype(SubtypeSettingsKt.getSelectedSubtype(prefs));
|
updateCurrentSubtype(SubtypeSettingsKt.getSelectedSubtype(prefs));
|
||||||
updateShortcutIme();
|
updateShortcutIme();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCurrentSubtype(final InputMethodSubtype subtype) {
|
private void updateCurrentSubtype(final InputMethodSubtype subtype) {
|
||||||
SubtypeSettingsKt.setSelectedSubtype(DeviceProtectedUtils.getSharedPreferences(mContext), subtype);
|
SubtypeSettingsKt.setSelectedSubtype(KtxKt.prefs(mContext), subtype);
|
||||||
mCurrentRichInputMethodSubtype = RichInputMethodSubtype.getRichInputMethodSubtype(subtype);
|
mCurrentRichInputMethodSubtype = RichInputMethodSubtype.getRichInputMethodSubtype(subtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,36 +14,37 @@ import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
|
|
||||||
|
import helium314.keyboard.latin.utils.KtxKt;
|
||||||
import helium314.keyboard.latin.utils.Log;
|
import helium314.keyboard.latin.utils.Log;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
import helium314.keyboard.keyboard.KeyboardLayoutSet;
|
import helium314.keyboard.keyboard.KeyboardLayoutSet;
|
||||||
import helium314.keyboard.latin.settings.Settings;
|
import helium314.keyboard.latin.settings.Settings;
|
||||||
import helium314.keyboard.latin.setup.SetupActivity;
|
import helium314.keyboard.latin.setup.SetupActivity;
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils;
|
|
||||||
import helium314.keyboard.latin.utils.UncachedInputMethodManagerUtils;
|
import helium314.keyboard.latin.utils.UncachedInputMethodManagerUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class detects the {@link Intent#ACTION_MY_PACKAGE_REPLACED} broadcast intent when this IME
|
* This class detects the {@link Intent#ACTION_MY_PACKAGE_REPLACED} broadcast intent when this IME
|
||||||
* package has been replaced by a newer version of the same package. This class also detects
|
* package has been replaced by a newer version of the same package. This class also detects
|
||||||
* {@link Intent#ACTION_BOOT_COMPLETED} and {@link Intent#ACTION_USER_INITIALIZE} broadcast intent.
|
* {@link Intent#ACTION_BOOT_COMPLETED} and {@link Intent#ACTION_USER_INITIALIZE} broadcast intent.
|
||||||
*
|
* <p>
|
||||||
* If this IME has already been installed in the system image and a new version of this IME has
|
* If this IME has already been installed in the system image and a new version of this IME has
|
||||||
* been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is received by this receiver and it
|
* been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is received by this receiver and it
|
||||||
* will hide the setup wizard's icon.
|
* will hide the setup wizard's icon.
|
||||||
*
|
* <p>
|
||||||
* If this IME has already been installed in the data partition and a new version of this IME has
|
* If this IME has already been installed in the data partition and a new version of this IME has
|
||||||
* been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is received by this receiver but it
|
* been installed, {@link Intent#ACTION_MY_PACKAGE_REPLACED} is received by this receiver but it
|
||||||
* will not hide the setup wizard's icon, and the icon will appear on the launcher.
|
* will not hide the setup wizard's icon, and the icon will appear on the launcher.
|
||||||
*
|
* <p>
|
||||||
* If this IME hasn't been installed yet and has been newly installed, no
|
* If this IME hasn't been installed yet and has been newly installed, no
|
||||||
* {@link Intent#ACTION_MY_PACKAGE_REPLACED} will be sent and the setup wizard's icon will appear
|
* {@link Intent#ACTION_MY_PACKAGE_REPLACED} will be sent and the setup wizard's icon will appear
|
||||||
* on the launcher.
|
* on the launcher.
|
||||||
*
|
* <p>
|
||||||
* When the device has been booted, {@link Intent#ACTION_BOOT_COMPLETED} is received by this
|
* When the device has been booted, {@link Intent#ACTION_BOOT_COMPLETED} is received by this
|
||||||
* receiver and it checks whether the setup wizard's icon should be appeared or not on the launcher
|
* receiver and it checks whether the setup wizard's icon should be appeared or not on the launcher
|
||||||
* depending on which partition this IME is installed.
|
* depending on which partition this IME is installed.
|
||||||
*
|
* <p>
|
||||||
* When the system locale has been changed, {@link Intent#ACTION_LOCALE_CHANGED} is received by
|
* When the system locale has been changed, {@link Intent#ACTION_LOCALE_CHANGED} is received by
|
||||||
* this receiver and the {@link KeyboardLayoutSet}'s cache is cleared.
|
* this receiver and the {@link KeyboardLayoutSet}'s cache is cleared.
|
||||||
*/
|
*/
|
||||||
|
@ -86,7 +87,7 @@ public final class SystemBroadcastReceiver extends BroadcastReceiver {
|
||||||
public static void toggleAppIcon(final Context context) {
|
public static void toggleAppIcon(final Context context) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
||||||
return; // can't change visibility in Android 10 and above
|
return; // can't change visibility in Android 10 and above
|
||||||
final SharedPreferences prefs = DeviceProtectedUtils.getSharedPreferences(context);
|
final SharedPreferences prefs = KtxKt.prefs(context);
|
||||||
context.getPackageManager().setComponentEnabledSetting(
|
context.getPackageManager().setComponentEnabledSetting(
|
||||||
new ComponentName(context, SetupActivity.class),
|
new ComponentName(context, SetupActivity.class),
|
||||||
Settings.readShowSetupWizardIcon(prefs, context)
|
Settings.readShowSetupWizardIcon(prefs, context)
|
||||||
|
|
|
@ -10,8 +10,8 @@ import android.content.Context
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import helium314.keyboard.latin.BuildConfig
|
import helium314.keyboard.latin.BuildConfig
|
||||||
import helium314.keyboard.latin.settings.DebugSettings
|
import helium314.keyboard.latin.settings.DebugSettings
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
|
||||||
import helium314.keyboard.latin.utils.Log
|
import helium314.keyboard.latin.utils.Log
|
||||||
|
import helium314.keyboard.latin.utils.prefs
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.PrintWriter
|
import java.io.PrintWriter
|
||||||
|
@ -24,8 +24,7 @@ object DebugFlags {
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun init(context: Context) {
|
fun init(context: Context) {
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
DEBUG_ENABLED = context.prefs().getBoolean(DebugSettings.PREF_DEBUG_MODE, false)
|
||||||
DEBUG_ENABLED = prefs.getBoolean(DebugSettings.PREF_DEBUG_MODE, false)
|
|
||||||
if (DEBUG_ENABLED || BuildConfig.DEBUG)
|
if (DEBUG_ENABLED || BuildConfig.DEBUG)
|
||||||
CrashReportExceptionHandler(context.applicationContext).install()
|
CrashReportExceptionHandler(context.applicationContext).install()
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
||||||
import helium314.keyboard.latin.utils.ExecutorUtils
|
import helium314.keyboard.latin.utils.ExecutorUtils
|
||||||
import helium314.keyboard.latin.utils.ResourceUtils
|
import helium314.keyboard.latin.utils.ResourceUtils
|
||||||
import helium314.keyboard.latin.utils.infoDialog
|
import helium314.keyboard.latin.utils.infoDialog
|
||||||
|
import helium314.keyboard.latin.utils.prefs
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.SerializationException
|
import kotlinx.serialization.SerializationException
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
|
@ -62,7 +63,7 @@ open class ColorsSettingsFragment : Fragment(R.layout.color_settings), MenuProvi
|
||||||
get() = prefs.getInt(Settings.getColorPref(Settings.PREF_SHOW_MORE_COLORS, isNight), 0)
|
get() = prefs.getInt(Settings.getColorPref(Settings.PREF_SHOW_MORE_COLORS, isNight), 0)
|
||||||
set(value) { prefs.edit().putInt(Settings.getColorPref(Settings.PREF_SHOW_MORE_COLORS, isNight), value).apply() }
|
set(value) { prefs.edit().putInt(Settings.getColorPref(Settings.PREF_SHOW_MORE_COLORS, isNight), value).apply() }
|
||||||
|
|
||||||
private val prefs by lazy { DeviceProtectedUtils.getSharedPreferences(requireContext()) }
|
private val prefs by lazy { requireContext().prefs() }
|
||||||
|
|
||||||
private val colorPrefsAndNames by lazy {
|
private val colorPrefsAndNames by lazy {
|
||||||
listOf(
|
listOf(
|
||||||
|
|
|
@ -21,12 +21,12 @@ import androidx.core.widget.doAfterTextChanged
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import helium314.keyboard.latin.R
|
import helium314.keyboard.latin.R
|
||||||
import helium314.keyboard.latin.common.LocaleUtils
|
import helium314.keyboard.latin.common.LocaleUtils
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
|
||||||
import helium314.keyboard.latin.utils.SubtypeLocaleUtils
|
import helium314.keyboard.latin.utils.SubtypeLocaleUtils
|
||||||
import helium314.keyboard.latin.utils.addEnabledSubtype
|
import helium314.keyboard.latin.utils.addEnabledSubtype
|
||||||
import helium314.keyboard.latin.utils.displayName
|
import helium314.keyboard.latin.utils.displayName
|
||||||
import helium314.keyboard.latin.utils.isAdditionalSubtype
|
import helium314.keyboard.latin.utils.isAdditionalSubtype
|
||||||
import helium314.keyboard.latin.utils.locale
|
import helium314.keyboard.latin.utils.locale
|
||||||
|
import helium314.keyboard.latin.utils.prefs
|
||||||
import helium314.keyboard.latin.utils.removeEnabledSubtype
|
import helium314.keyboard.latin.utils.removeEnabledSubtype
|
||||||
import helium314.keyboard.latin.utils.showMissingDictionaryDialog
|
import helium314.keyboard.latin.utils.showMissingDictionaryDialog
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class LanguageFilterList(searchField: EditText, recyclerView: RecyclerView) {
|
||||||
private class LanguageAdapter(list: List<MutableList<SubtypeInfo>> = listOf(), context: Context) :
|
private class LanguageAdapter(list: List<MutableList<SubtypeInfo>> = listOf(), context: Context) :
|
||||||
RecyclerView.Adapter<LanguageAdapter.ViewHolder>() {
|
RecyclerView.Adapter<LanguageAdapter.ViewHolder>() {
|
||||||
var onlySystemLocales = false
|
var onlySystemLocales = false
|
||||||
private val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
private val prefs = context.prefs()
|
||||||
var fragment: LanguageSettingsFragment? = null
|
var fragment: LanguageSettingsFragment? = null
|
||||||
|
|
||||||
var list: List<MutableList<SubtypeInfo>> = list
|
var list: List<MutableList<SubtypeInfo>> = list
|
||||||
|
|
|
@ -39,7 +39,7 @@ class LanguageSettingsDialog(
|
||||||
private val onlySystemLocales: Boolean,
|
private val onlySystemLocales: Boolean,
|
||||||
private val reloadSetting: () -> Unit
|
private val reloadSetting: () -> Unit
|
||||||
) : AlertDialog(context), LanguageSettingsFragment.Listener {
|
) : AlertDialog(context), LanguageSettingsFragment.Listener {
|
||||||
private val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
private val prefs = context.prefs()
|
||||||
private val binding = LocaleSettingsDialogBinding.inflate(LayoutInflater.from(context))
|
private val binding = LocaleSettingsDialogBinding.inflate(LayoutInflater.from(context))
|
||||||
private val mainLocale = infos.first().subtype.locale()
|
private val mainLocale = infos.first().subtype.locale()
|
||||||
private var hasInternalDictForLanguage = false
|
private var hasInternalDictForLanguage = false
|
||||||
|
|
|
@ -20,7 +20,6 @@ import androidx.fragment.app.Fragment
|
||||||
import helium314.keyboard.latin.R
|
import helium314.keyboard.latin.R
|
||||||
import helium314.keyboard.latin.common.LocaleUtils
|
import helium314.keyboard.latin.common.LocaleUtils
|
||||||
import helium314.keyboard.latin.common.LocaleUtils.constructLocale
|
import helium314.keyboard.latin.common.LocaleUtils.constructLocale
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
|
||||||
import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
||||||
import helium314.keyboard.latin.utils.ScriptUtils.script
|
import helium314.keyboard.latin.utils.ScriptUtils.script
|
||||||
import helium314.keyboard.latin.utils.SubtypeLocaleUtils
|
import helium314.keyboard.latin.utils.SubtypeLocaleUtils
|
||||||
|
@ -29,6 +28,7 @@ import helium314.keyboard.latin.utils.getDictionaryLocales
|
||||||
import helium314.keyboard.latin.utils.getEnabledSubtypes
|
import helium314.keyboard.latin.utils.getEnabledSubtypes
|
||||||
import helium314.keyboard.latin.utils.getSystemLocales
|
import helium314.keyboard.latin.utils.getSystemLocales
|
||||||
import helium314.keyboard.latin.utils.locale
|
import helium314.keyboard.latin.utils.locale
|
||||||
|
import helium314.keyboard.latin.utils.prefs
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
// not a SettingsFragment, because with androidx.preferences it's very complicated or
|
// not a SettingsFragment, because with androidx.preferences it's very complicated or
|
||||||
|
@ -38,7 +38,7 @@ class LanguageSettingsFragment : Fragment(R.layout.language_settings) {
|
||||||
private val enabledSubtypes = mutableListOf<InputMethodSubtype>()
|
private val enabledSubtypes = mutableListOf<InputMethodSubtype>()
|
||||||
private val systemLocales = mutableListOf<Locale>()
|
private val systemLocales = mutableListOf<Locale>()
|
||||||
private lateinit var languageFilterList: LanguageFilterList
|
private lateinit var languageFilterList: LanguageFilterList
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var prefs: SharedPreferences
|
||||||
private lateinit var systemOnlySwitch: Switch
|
private lateinit var systemOnlySwitch: Switch
|
||||||
private val dictionaryLocales by lazy { getDictionaryLocales(requireContext()) }
|
private val dictionaryLocales by lazy { getDictionaryLocales(requireContext()) }
|
||||||
|
|
||||||
|
@ -56,22 +56,22 @@ class LanguageSettingsFragment : Fragment(R.layout.language_settings) {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
sharedPreferences = DeviceProtectedUtils.getSharedPreferences(requireContext())
|
prefs = requireContext().prefs()
|
||||||
|
|
||||||
SubtypeLocaleUtils.init(requireContext())
|
SubtypeLocaleUtils.init(requireContext())
|
||||||
|
|
||||||
enabledSubtypes.addAll(getEnabledSubtypes(sharedPreferences))
|
enabledSubtypes.addAll(getEnabledSubtypes(prefs))
|
||||||
systemLocales.addAll(getSystemLocales())
|
systemLocales.addAll(getSystemLocales())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
val view = super.onCreateView(inflater, container, savedInstanceState) ?: return null
|
val view = super.onCreateView(inflater, container, savedInstanceState) ?: return null
|
||||||
systemOnlySwitch = view.findViewById(R.id.language_switch)
|
systemOnlySwitch = view.findViewById(R.id.language_switch)
|
||||||
systemOnlySwitch.isChecked = sharedPreferences.getBoolean(Settings.PREF_USE_SYSTEM_LOCALES, true)
|
systemOnlySwitch.isChecked = prefs.getBoolean(Settings.PREF_USE_SYSTEM_LOCALES, true)
|
||||||
systemOnlySwitch.setOnCheckedChangeListener { _, b ->
|
systemOnlySwitch.setOnCheckedChangeListener { _, b ->
|
||||||
sharedPreferences.edit { putBoolean(Settings.PREF_USE_SYSTEM_LOCALES, b) }
|
prefs.edit { putBoolean(Settings.PREF_USE_SYSTEM_LOCALES, b) }
|
||||||
enabledSubtypes.clear()
|
enabledSubtypes.clear()
|
||||||
enabledSubtypes.addAll(getEnabledSubtypes(sharedPreferences))
|
enabledSubtypes.addAll(getEnabledSubtypes(prefs))
|
||||||
loadSubtypes(b)
|
loadSubtypes(b)
|
||||||
}
|
}
|
||||||
languageFilterList = LanguageFilterList(view.findViewById(R.id.search_field), view.findViewById(R.id.language_list))
|
languageFilterList = LanguageFilterList(view.findViewById(R.id.search_field), view.findViewById(R.id.language_list))
|
||||||
|
|
|
@ -40,6 +40,7 @@ import helium314.keyboard.latin.utils.AdditionalSubtypeUtils;
|
||||||
import helium314.keyboard.latin.utils.ColorUtilKt;
|
import helium314.keyboard.latin.utils.ColorUtilKt;
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils;
|
import helium314.keyboard.latin.utils.DeviceProtectedUtils;
|
||||||
import helium314.keyboard.latin.utils.JniUtils;
|
import helium314.keyboard.latin.utils.JniUtils;
|
||||||
|
import helium314.keyboard.latin.utils.KtxKt;
|
||||||
import helium314.keyboard.latin.utils.Log;
|
import helium314.keyboard.latin.utils.Log;
|
||||||
import helium314.keyboard.latin.utils.ResourceUtils;
|
import helium314.keyboard.latin.utils.ResourceUtils;
|
||||||
import helium314.keyboard.latin.utils.RunInLocaleKt;
|
import helium314.keyboard.latin.utils.RunInLocaleKt;
|
||||||
|
@ -237,7 +238,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
|
|
||||||
private void onCreate(final Context context) {
|
private void onCreate(final Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mPrefs = DeviceProtectedUtils.getSharedPreferences(context);
|
mPrefs = KtxKt.prefs(context);
|
||||||
mPrefs.registerOnSharedPreferenceChangeListener(this);
|
mPrefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,10 @@ import helium314.keyboard.latin.BuildConfig;
|
||||||
import helium314.keyboard.latin.R;
|
import helium314.keyboard.latin.R;
|
||||||
import helium314.keyboard.latin.common.FileUtils;
|
import helium314.keyboard.latin.common.FileUtils;
|
||||||
import helium314.keyboard.latin.define.DebugFlags;
|
import helium314.keyboard.latin.define.DebugFlags;
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils;
|
|
||||||
import helium314.keyboard.latin.utils.DictionaryUtilsKt;
|
import helium314.keyboard.latin.utils.DictionaryUtilsKt;
|
||||||
import helium314.keyboard.latin.utils.ExecutorUtils;
|
import helium314.keyboard.latin.utils.ExecutorUtils;
|
||||||
import helium314.keyboard.latin.utils.JniUtils;
|
import helium314.keyboard.latin.utils.JniUtils;
|
||||||
|
import helium314.keyboard.latin.utils.KtxKt;
|
||||||
import helium314.keyboard.latin.utils.SubtypeSettingsKt;
|
import helium314.keyboard.latin.utils.SubtypeSettingsKt;
|
||||||
import helium314.keyboard.latin.utils.SubtypeUtilsKt;
|
import helium314.keyboard.latin.utils.SubtypeUtilsKt;
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public final class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getEnabledSubtypesLabel() {
|
private String getEnabledSubtypesLabel() {
|
||||||
final List<InputMethodSubtype> subtypes = SubtypeSettingsKt.getEnabledSubtypes(DeviceProtectedUtils.getSharedPreferences(getActivity()), true);
|
final List<InputMethodSubtype> subtypes = SubtypeSettingsKt.getEnabledSubtypes(KtxKt.prefs(getActivity()), true);
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
for (final InputMethodSubtype subtype : subtypes) {
|
for (final InputMethodSubtype subtype : subtypes) {
|
||||||
if (sb.length() > 0)
|
if (sb.length() > 0)
|
||||||
|
|
|
@ -24,7 +24,7 @@ import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceGroup;
|
import androidx.preference.PreferenceGroup;
|
||||||
|
|
||||||
import helium314.keyboard.latin.R;
|
import helium314.keyboard.latin.R;
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils;
|
import helium314.keyboard.latin.utils.KtxKt;
|
||||||
import helium314.keyboard.latin.utils.SubtypeLocaleUtils;
|
import helium314.keyboard.latin.utils.SubtypeLocaleUtils;
|
||||||
import helium314.keyboard.latin.utils.SubtypeSettingsKt;
|
import helium314.keyboard.latin.utils.SubtypeSettingsKt;
|
||||||
import helium314.keyboard.latin.utils.SubtypeUtilsKt;
|
import helium314.keyboard.latin.utils.SubtypeUtilsKt;
|
||||||
|
@ -105,7 +105,7 @@ public class UserDictionaryListFragment extends SubScreenFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
static TreeSet<Locale> getSortedDictionaryLocales(final Context context) {
|
static TreeSet<Locale> getSortedDictionaryLocales(final Context context) {
|
||||||
final SharedPreferences prefs = DeviceProtectedUtils.getSharedPreferences(context);
|
final SharedPreferences prefs = KtxKt.prefs(context);
|
||||||
final boolean localeSystemOnly = prefs.getBoolean(Settings.PREF_USE_SYSTEM_LOCALES, true);
|
final boolean localeSystemOnly = prefs.getBoolean(Settings.PREF_USE_SYSTEM_LOCALES, true);
|
||||||
final TreeSet<Locale> sortedLocales = new TreeSet<>(new LocaleComparator());
|
final TreeSet<Locale> sortedLocales = new TreeSet<>(new LocaleComparator());
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import helium314.keyboard.latin.common.ComposedData;
|
||||||
import helium314.keyboard.latin.settings.Settings;
|
import helium314.keyboard.latin.settings.Settings;
|
||||||
import helium314.keyboard.latin.settings.SettingsValuesForSuggestion;
|
import helium314.keyboard.latin.settings.SettingsValuesForSuggestion;
|
||||||
import helium314.keyboard.latin.utils.AdditionalSubtypeUtils;
|
import helium314.keyboard.latin.utils.AdditionalSubtypeUtils;
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils;
|
import helium314.keyboard.latin.utils.KtxKt;
|
||||||
import helium314.keyboard.latin.utils.SubtypeSettingsKt;
|
import helium314.keyboard.latin.utils.SubtypeSettingsKt;
|
||||||
import helium314.keyboard.latin.utils.SuggestionResults;
|
import helium314.keyboard.latin.utils.SuggestionResults;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
mRecommendedThreshold = Float.parseFloat(getString(R.string.spellchecker_recommended_threshold_value));
|
mRecommendedThreshold = Float.parseFloat(getString(R.string.spellchecker_recommended_threshold_value));
|
||||||
final SharedPreferences prefs = DeviceProtectedUtils.getSharedPreferences(this);
|
final SharedPreferences prefs = KtxKt.prefs(this);
|
||||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
onSharedPreferenceChanged(prefs, Settings.PREF_USE_CONTACTS);
|
onSharedPreferenceChanged(prefs, Settings.PREF_USE_CONTACTS);
|
||||||
final boolean blockOffensive = Settings.readBlockPotentiallyOffensive(prefs, getResources());
|
final boolean blockOffensive = Settings.readBlockPotentiallyOffensive(prefs, getResources());
|
||||||
|
|
|
@ -13,6 +13,8 @@ import android.os.Binder;
|
||||||
import android.provider.UserDictionary.Words;
|
import android.provider.UserDictionary.Words;
|
||||||
import android.service.textservice.SpellCheckerService.Session;
|
import android.service.textservice.SpellCheckerService.Session;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import helium314.keyboard.latin.utils.KtxKt;
|
||||||
import helium314.keyboard.latin.utils.Log;
|
import helium314.keyboard.latin.utils.Log;
|
||||||
import android.util.LruCache;
|
import android.util.LruCache;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
@ -30,7 +32,6 @@ import helium314.keyboard.latin.common.StringUtils;
|
||||||
import helium314.keyboard.latin.define.DebugFlags;
|
import helium314.keyboard.latin.define.DebugFlags;
|
||||||
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
|
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
|
||||||
|
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils;
|
|
||||||
import helium314.keyboard.latin.utils.ScriptUtils;
|
import helium314.keyboard.latin.utils.ScriptUtils;
|
||||||
import helium314.keyboard.latin.utils.StatsUtils;
|
import helium314.keyboard.latin.utils.StatsUtils;
|
||||||
import helium314.keyboard.latin.utils.SubtypeSettingsKt;
|
import helium314.keyboard.latin.utils.SubtypeSettingsKt;
|
||||||
|
@ -153,7 +154,7 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
|
||||||
// localeString for this app is always empty, get it from settings if possible
|
// localeString for this app is always empty, get it from settings if possible
|
||||||
// and we're sure this app is used
|
// and we're sure this app is used
|
||||||
if (SubtypeSettingsKt.getInitialized() && "dummy".equals(currentInputMethodSubtype.getExtraValue())) {
|
if (SubtypeSettingsKt.getInitialized() && "dummy".equals(currentInputMethodSubtype.getExtraValue())) {
|
||||||
final SharedPreferences prefs = DeviceProtectedUtils.getSharedPreferences(mService);
|
final SharedPreferences prefs = KtxKt.prefs(mService);
|
||||||
return SubtypeSettingsKt.getSelectedSubtype(prefs).getLocale();
|
return SubtypeSettingsKt.getSelectedSubtype(prefs).getLocale();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ import helium314.keyboard.latin.settings.DebugSettings;
|
||||||
import helium314.keyboard.latin.settings.Settings;
|
import helium314.keyboard.latin.settings.Settings;
|
||||||
import helium314.keyboard.latin.settings.SettingsValues;
|
import helium314.keyboard.latin.settings.SettingsValues;
|
||||||
import helium314.keyboard.latin.suggestions.PopupSuggestionsView.MoreSuggestionsListener;
|
import helium314.keyboard.latin.suggestions.PopupSuggestionsView.MoreSuggestionsListener;
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils;
|
import helium314.keyboard.latin.utils.KtxKt;
|
||||||
import helium314.keyboard.latin.utils.Log;
|
import helium314.keyboard.latin.utils.Log;
|
||||||
import helium314.keyboard.latin.utils.ToolbarKey;
|
import helium314.keyboard.latin.utils.ToolbarKey;
|
||||||
import helium314.keyboard.latin.utils.ToolbarUtilsKt;
|
import helium314.keyboard.latin.utils.ToolbarUtilsKt;
|
||||||
|
@ -143,7 +143,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
public SuggestionStripView(final Context context, final AttributeSet attrs, final int defStyle) {
|
public SuggestionStripView(final Context context, final AttributeSet attrs, final int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
final Colors colors = Settings.getInstance().getCurrent().mColors;
|
||||||
final SharedPreferences prefs = DeviceProtectedUtils.getSharedPreferences(context);
|
final SharedPreferences prefs = KtxKt.prefs(context);
|
||||||
DEBUG_SUGGESTIONS = prefs.getBoolean(DebugSettings.PREF_SHOW_SUGGESTION_INFOS, false);
|
DEBUG_SUGGESTIONS = prefs.getBoolean(DebugSettings.PREF_SHOW_SUGGESTION_INFOS, false);
|
||||||
|
|
||||||
final LayoutInflater inflater = LayoutInflater.from(context);
|
final LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
|
@ -392,9 +392,9 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
if (pinnedKeyView == null) {
|
if (pinnedKeyView == null) {
|
||||||
addKeyToPinnedKeys(tag);
|
addKeyToPinnedKeys(tag);
|
||||||
mToolbar.findViewWithTag(tag).setBackground(mEnabledToolKeyBackground);
|
mToolbar.findViewWithTag(tag).setBackground(mEnabledToolKeyBackground);
|
||||||
ToolbarUtilsKt.addPinnedKey(DeviceProtectedUtils.getSharedPreferences(getContext()), tag);
|
ToolbarUtilsKt.addPinnedKey(KtxKt.prefs(getContext()), tag);
|
||||||
} else {
|
} else {
|
||||||
ToolbarUtilsKt.removePinnedKey(DeviceProtectedUtils.getSharedPreferences(getContext()), tag);
|
ToolbarUtilsKt.removePinnedKey(KtxKt.prefs(getContext()), tag);
|
||||||
mToolbar.findViewWithTag(tag).setBackground(mDefaultBackground.getConstantState().newDrawable(getResources()));
|
mToolbar.findViewWithTag(tag).setBackground(mDefaultBackground.getConstantState().newDrawable(getResources()));
|
||||||
mPinnedKeys.removeView(pinnedKeyView);
|
mPinnedKeys.removeView(pinnedKeyView);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ fun reorderDialog(
|
||||||
@StringRes dialogTitleId: Int,
|
@StringRes dialogTitleId: Int,
|
||||||
getIcon: (String) -> Drawable? = { null }
|
getIcon: (String) -> Drawable? = { null }
|
||||||
) {
|
) {
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
val prefs = context.prefs()
|
||||||
val orderedItems = prefs.getString(key, defaultSetting)!!.split(";").mapTo(ArrayList()) {
|
val orderedItems = prefs.getString(key, defaultSetting)!!.split(";").mapTo(ArrayList()) {
|
||||||
val both = it.split(",")
|
val both = it.split(",")
|
||||||
both.first() to both.last().toBoolean()
|
both.first() to both.last().toBoolean()
|
||||||
|
|
|
@ -39,7 +39,7 @@ fun getDictionaryLocales(context: Context): MutableSet<Locale> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showMissingDictionaryDialog(context: Context, locale: Locale) {
|
fun showMissingDictionaryDialog(context: Context, locale: Locale) {
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
val prefs = context.prefs()
|
||||||
if (prefs.getBoolean(Settings.PREF_DONT_SHOW_MISSING_DICTIONARY_DIALOG, false) || locale.toString() == "zz")
|
if (prefs.getBoolean(Settings.PREF_DONT_SHOW_MISSING_DICTIONARY_DIALOG, false) || locale.toString() == "zz")
|
||||||
return
|
return
|
||||||
val repositoryLink = "<a href='$DICTIONARY_URL'>" + context.getString(R.string.dictionary_link_text) + "</a>"
|
val repositoryLink = "<a href='$DICTIONARY_URL'>" + context.getString(R.string.dictionary_link_text) + "</a>"
|
||||||
|
@ -99,7 +99,7 @@ fun createDictionaryTextHtml(message: String, locale: Locale, context: Context):
|
||||||
fun cleanUnusedMainDicts(context: Context) {
|
fun cleanUnusedMainDicts(context: Context) {
|
||||||
val dictionaryDir = File(DictionaryInfoUtils.getWordListCacheDirectory(context))
|
val dictionaryDir = File(DictionaryInfoUtils.getWordListCacheDirectory(context))
|
||||||
val dirs = dictionaryDir.listFiles() ?: return
|
val dirs = dictionaryDir.listFiles() ?: return
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
val prefs = context.prefs()
|
||||||
val usedLocaleLanguageTags = hashSetOf<String>()
|
val usedLocaleLanguageTags = hashSetOf<String>()
|
||||||
getEnabledSubtypes(prefs).forEach { subtype ->
|
getEnabledSubtypes(prefs).forEach { subtype ->
|
||||||
val locale = subtype.locale()
|
val locale = subtype.locale()
|
||||||
|
|
|
@ -243,7 +243,7 @@ private fun loadResourceSubtypes(resources: Resources) {
|
||||||
|
|
||||||
// remove custom subtypes without a layout file
|
// remove custom subtypes without a layout file
|
||||||
private fun removeInvalidCustomSubtypes(context: Context) {
|
private fun removeInvalidCustomSubtypes(context: Context) {
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
val prefs = context.prefs()
|
||||||
val additionalSubtypes = Settings.readPrefAdditionalSubtypes(prefs, context.resources).split(";")
|
val additionalSubtypes = Settings.readPrefAdditionalSubtypes(prefs, context.resources).split(";")
|
||||||
val customSubtypeFiles by lazy { getCustomLayoutFiles(context).map { it.name } }
|
val customSubtypeFiles by lazy { getCustomLayoutFiles(context).map { it.name } }
|
||||||
val subtypesToRemove = mutableListOf<String>()
|
val subtypesToRemove = mutableListOf<String>()
|
||||||
|
@ -259,15 +259,14 @@ private fun removeInvalidCustomSubtypes(context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadAdditionalSubtypes(context: Context) {
|
private fun loadAdditionalSubtypes(context: Context) {
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
val additionalSubtypeString = Settings.readPrefAdditionalSubtypes(context.prefs(), context.resources)
|
||||||
val additionalSubtypeString = Settings.readPrefAdditionalSubtypes(prefs, context.resources)
|
|
||||||
val subtypes = AdditionalSubtypeUtils.createAdditionalSubtypesArray(additionalSubtypeString)
|
val subtypes = AdditionalSubtypeUtils.createAdditionalSubtypesArray(additionalSubtypeString)
|
||||||
additionalSubtypes.addAll(subtypes)
|
additionalSubtypes.addAll(subtypes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// requires loadResourceSubtypes to be called before
|
// requires loadResourceSubtypes to be called before
|
||||||
private fun loadEnabledSubtypes(context: Context) {
|
private fun loadEnabledSubtypes(context: Context) {
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
val prefs = context.prefs()
|
||||||
val subtypeStrings = prefs.getString(Settings.PREF_ENABLED_SUBTYPES, "")!!
|
val subtypeStrings = prefs.getString(Settings.PREF_ENABLED_SUBTYPES, "")!!
|
||||||
.split(SUBTYPE_SEPARATOR).filter { it.isNotEmpty() }.map { it.toLocaleAndLayout() }
|
.split(SUBTYPE_SEPARATOR).filter { it.isNotEmpty() }.map { it.toLocaleAndLayout() }
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ fun setToolbarButtonsActivatedStateOnPrefChange(buttonsGroup: ViewGroup, key: St
|
||||||
|
|
||||||
private fun setToolbarButtonActivatedState(button: ImageButton) {
|
private fun setToolbarButtonActivatedState(button: ImageButton) {
|
||||||
button.isActivated = when (button.tag) {
|
button.isActivated = when (button.tag) {
|
||||||
INCOGNITO -> Settings.readAlwaysIncognitoMode(DeviceProtectedUtils.getSharedPreferences(button.context))
|
INCOGNITO -> Settings.readAlwaysIncognitoMode(button.context.prefs())
|
||||||
ONE_HANDED -> Settings.getInstance().current.mOneHandedModeEnabled
|
ONE_HANDED -> Settings.getInstance().current.mOneHandedModeEnabled
|
||||||
SPLIT -> Settings.getInstance().current.mIsSplitKeyboardEnabled
|
SPLIT -> Settings.getInstance().current.mIsSplitKeyboardEnabled
|
||||||
AUTOCORRECT -> Settings.getInstance().current.mAutoCorrectionEnabledPerUserSettings
|
AUTOCORRECT -> Settings.getInstance().current.mAutoCorrectionEnabledPerUserSettings
|
||||||
|
@ -226,7 +226,7 @@ fun toolbarKeysCustomizer(context: Context) {
|
||||||
.setTitle(R.string.customize_toolbar_key_codes)
|
.setTitle(R.string.customize_toolbar_key_codes)
|
||||||
.setView(ScrollView(context).apply { addView(ll) })
|
.setView(ScrollView(context).apply { addView(ll) })
|
||||||
.setPositiveButton(R.string.dialog_close, null)
|
.setPositiveButton(R.string.dialog_close, null)
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
val prefs = context.prefs()
|
||||||
if (readCustomKeyCodes(prefs).isNotEmpty() || readCustomLongpressCodes(prefs).isNotEmpty())
|
if (readCustomKeyCodes(prefs).isNotEmpty() || readCustomLongpressCodes(prefs).isNotEmpty())
|
||||||
builder.setNeutralButton(R.string.button_default) { _, _ ->
|
builder.setNeutralButton(R.string.button_default) { _, _ ->
|
||||||
confirmDialog(context, context.getString(R.string.customize_toolbar_key_code_reset_message), context.getString(android.R.string.ok)) {
|
confirmDialog(context, context.getString(R.string.customize_toolbar_key_code_reset_message), context.getString(android.R.string.ok)) {
|
||||||
|
@ -257,7 +257,7 @@ fun toolbarKeysCustomizer(context: Context) {
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
private fun toolbarKeyCustomizer(context: Context, key: ToolbarKey) {
|
private fun toolbarKeyCustomizer(context: Context, key: ToolbarKey) {
|
||||||
val layout = LayoutInflater.from(context).inflate(R.layout.toolbar_key_customizer, null)
|
val layout = LayoutInflater.from(context).inflate(R.layout.toolbar_key_customizer, null)
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(context)
|
val prefs = context.prefs()
|
||||||
var keyCode: String? = null
|
var keyCode: String? = null
|
||||||
var longpressCode: String? = null
|
var longpressCode: String? = null
|
||||||
val builder = AlertDialog.Builder(context)
|
val builder = AlertDialog.Builder(context)
|
||||||
|
|
|
@ -22,8 +22,8 @@ import helium314.keyboard.latin.common.StringUtils
|
||||||
import helium314.keyboard.latin.inputlogic.InputLogic
|
import helium314.keyboard.latin.inputlogic.InputLogic
|
||||||
import helium314.keyboard.latin.inputlogic.SpaceState
|
import helium314.keyboard.latin.inputlogic.SpaceState
|
||||||
import helium314.keyboard.latin.settings.Settings
|
import helium314.keyboard.latin.settings.Settings
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
|
||||||
import helium314.keyboard.latin.utils.ScriptUtils
|
import helium314.keyboard.latin.utils.ScriptUtils
|
||||||
|
import helium314.keyboard.latin.utils.prefs
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
import org.robolectric.Robolectric
|
import org.robolectric.Robolectric
|
||||||
|
@ -165,7 +165,7 @@ class InputLogicTest {
|
||||||
input('.')
|
input('.')
|
||||||
input('a')
|
input('a')
|
||||||
assertEquals("hello.a", textBeforeCursor)
|
assertEquals("hello.a", textBeforeCursor)
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
||||||
setText("hello")
|
setText("hello")
|
||||||
input('.')
|
input('.')
|
||||||
input('a')
|
input('a')
|
||||||
|
@ -180,7 +180,7 @@ class InputLogicTest {
|
||||||
input('a')
|
input('a')
|
||||||
assertEquals("hello.a", textBeforeCursor)
|
assertEquals("hello.a", textBeforeCursor)
|
||||||
assertEquals("hello.a there", text)
|
assertEquals("hello.a there", text)
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
||||||
setText("hello there")
|
setText("hello there")
|
||||||
setCursorPosition(5) // after hello
|
setCursorPosition(5) // after hello
|
||||||
input('.')
|
input('.')
|
||||||
|
@ -191,7 +191,7 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun noAutospaceInUrlField() {
|
@Test fun noAutospaceInUrlField() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
||||||
chainInput("example.net")
|
chainInput("example.net")
|
||||||
assertEquals("example. net", text)
|
assertEquals("example. net", text)
|
||||||
lastAddedWord = ""
|
lastAddedWord = ""
|
||||||
|
@ -221,7 +221,7 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun noAutospaceForDetectedUrl() { // "light" version, should work without url detection
|
@Test fun noAutospaceForDetectedUrl() { // "light" version, should work without url detection
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
||||||
chainInput("http://example.net")
|
chainInput("http://example.net")
|
||||||
assertEquals("http://example.net", text)
|
assertEquals("http://example.net", text)
|
||||||
assertEquals("http", lastAddedWord)
|
assertEquals("http", lastAddedWord)
|
||||||
|
@ -230,14 +230,14 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun noAutospaceForDetectedEmail() {
|
@Test fun noAutospaceForDetectedEmail() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
||||||
chainInput("mail@example.com")
|
chainInput("mail@example.com")
|
||||||
assertEquals("mail@example.com", text)
|
assertEquals("mail@example.com", text)
|
||||||
assertEquals("mail@example", lastAddedWord) // todo: do we want this? not really nice, but don't want to be too aggressive with URL detection disabled
|
assertEquals("mail@example", lastAddedWord) // todo: do we want this? not really nice, but don't want to be too aggressive with URL detection disabled
|
||||||
assertEquals("com", composingText) // todo: maybe this should still see the whole address as a single word? or don't be too aggressive?
|
assertEquals("com", composingText) // todo: maybe this should still see the whole address as a single word? or don't be too aggressive?
|
||||||
setText("")
|
setText("")
|
||||||
lastAddedWord = ""
|
lastAddedWord = ""
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
chainInput("mail@example.com")
|
chainInput("mail@example.com")
|
||||||
assertEquals("", lastAddedWord)
|
assertEquals("", lastAddedWord)
|
||||||
assertEquals("mail@example.com", composingText)
|
assertEquals("mail@example.com", composingText)
|
||||||
|
@ -245,23 +245,23 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun urlDetectionThings() {
|
@Test fun urlDetectionThings() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
chainInput("...h")
|
chainInput("...h")
|
||||||
assertEquals("...h", text)
|
assertEquals("...h", text)
|
||||||
assertEquals("h", composingText)
|
assertEquals("h", composingText)
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
chainInput("bla..")
|
chainInput("bla..")
|
||||||
assertEquals("bla..", text)
|
assertEquals("bla..", text)
|
||||||
assertEquals("", composingText)
|
assertEquals("", composingText)
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
chainInput("bla.c")
|
chainInput("bla.c")
|
||||||
assertEquals("bla.c", text)
|
assertEquals("bla.c", text)
|
||||||
assertEquals("bla.c", composingText)
|
assertEquals("bla.c", composingText)
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
||||||
input("bla")
|
input("bla")
|
||||||
input('.')
|
input('.')
|
||||||
functionalKeyPress(KeyCode.SHIFT) // should remove the phantom space (in addition to normal effect)
|
functionalKeyPress(KeyCode.SHIFT) // should remove the phantom space (in addition to normal effect)
|
||||||
|
@ -272,7 +272,7 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun stripSeparatorsBeforeAddingToHistoryWithURLDetection() {
|
@Test fun stripSeparatorsBeforeAddingToHistoryWithURLDetection() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
chainInput("example.com.")
|
chainInput("example.com.")
|
||||||
assertEquals("example.com.", composingText)
|
assertEquals("example.com.", composingText)
|
||||||
input(' ')
|
input(' ')
|
||||||
|
@ -281,7 +281,7 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun dontSelectConsecutiveSeparatorsWithURLDetection() {
|
@Test fun dontSelectConsecutiveSeparatorsWithURLDetection() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
chainInput("bla..")
|
chainInput("bla..")
|
||||||
assertEquals("", composingText)
|
assertEquals("", composingText)
|
||||||
assertEquals("bla..", text)
|
assertEquals("bla..", text)
|
||||||
|
@ -300,7 +300,7 @@ class InputLogicTest {
|
||||||
input('a')
|
input('a')
|
||||||
input('b')
|
input('b')
|
||||||
assertEquals("", composingText)
|
assertEquals("", composingText)
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
input('.')
|
input('.')
|
||||||
input('c')
|
input('c')
|
||||||
assertEquals("", composingText)
|
assertEquals("", composingText)
|
||||||
|
@ -315,7 +315,7 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun `select whole thing except http(s) as composing word if URL detection enabled and selecting`() {
|
@Test fun `select whole thing except http(s) as composing word if URL detection enabled and selecting`() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
setText("http://example.com")
|
setText("http://example.com")
|
||||||
setCursorPosition(13) // between l and e
|
setCursorPosition(13) // between l and e
|
||||||
assertEquals("example.com", composingText)
|
assertEquals("example.com", composingText)
|
||||||
|
@ -326,14 +326,14 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun `select whole thing except http(s) as composing word if URL detection enabled and typing`() {
|
@Test fun `select whole thing except http(s) as composing word if URL detection enabled and typing`() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
chainInput("http://example.com")
|
chainInput("http://example.com")
|
||||||
assertEquals("example.com", composingText)
|
assertEquals("example.com", composingText)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun `don't add partial URL to history`() {
|
@Test fun `don't add partial URL to history`() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
setText("http:/") // just so lastAddedWord isn't set to http
|
setText("http:/") // just so lastAddedWord isn't set to http
|
||||||
chainInput("/bla.com")
|
chainInput("/bla.com")
|
||||||
assertEquals("", lastAddedWord)
|
assertEquals("", lastAddedWord)
|
||||||
|
@ -341,7 +341,7 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun urlProperlySelected() {
|
@Test fun urlProperlySelected() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
|
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
|
||||||
setText("http://example.com/here")
|
setText("http://example.com/here")
|
||||||
setCursorPosition(18) // after .com
|
setCursorPosition(18) // after .com
|
||||||
|
@ -357,7 +357,7 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun urlProperlySelectedWhenNotDeletingFullTld() {
|
@Test fun urlProperlySelectedWhenNotDeletingFullTld() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
setText("http://example.com/here")
|
setText("http://example.com/here")
|
||||||
setCursorPosition(18) // after .com
|
setCursorPosition(18) // after .com
|
||||||
functionalKeyPress(KeyCode.DELETE)
|
functionalKeyPress(KeyCode.DELETE)
|
||||||
|
@ -372,7 +372,7 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun dontCommitPartialUrlBeforeFirstPeriod() {
|
@Test fun dontCommitPartialUrlBeforeFirstPeriod() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
// type http://bla. -> bla not selected, but clearly url, also means http://bla is committed which we probably don't want
|
// type http://bla. -> bla not selected, but clearly url, also means http://bla is committed which we probably don't want
|
||||||
chainInput("http://bla.")
|
chainInput("http://bla.")
|
||||||
assertEquals("bla.", composingText)
|
assertEquals("bla.", composingText)
|
||||||
|
@ -391,7 +391,7 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun `intermediate commit in text field without protocol and with URL detection`() {
|
@Test fun `intermediate commit in text field without protocol and with URL detection`() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
chainInput("bla.com/img.jpg")
|
chainInput("bla.com/img.jpg")
|
||||||
assertEquals("bla", lastAddedWord)
|
assertEquals("bla", lastAddedWord)
|
||||||
assertEquals("bla.com/img.jpg", composingText)
|
assertEquals("bla.com/img.jpg", composingText)
|
||||||
|
@ -399,7 +399,7 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun `only protocol commit in text field with protocol and URL detection`() {
|
@Test fun `only protocol commit in text field with protocol and URL detection`() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
chainInput("http://bla.com/img.jpg")
|
chainInput("http://bla.com/img.jpg")
|
||||||
assertEquals("http", lastAddedWord)
|
assertEquals("http", lastAddedWord)
|
||||||
assertEquals("bla.com/img.jpg", composingText)
|
assertEquals("bla.com/img.jpg", composingText)
|
||||||
|
@ -416,7 +416,7 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun `no intermediate commit in URL field with protocol and URL detection`() {
|
@Test fun `no intermediate commit in URL field with protocol and URL detection`() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
|
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
|
||||||
chainInput("http://bla.com/img.jpg")
|
chainInput("http://bla.com/img.jpg")
|
||||||
assertEquals("http", lastAddedWord) // todo: somehow avoid?
|
assertEquals("http", lastAddedWord) // todo: somehow avoid?
|
||||||
|
@ -435,7 +435,7 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun `no intermediate commit in URL field without protocol and with URL detection`() {
|
@Test fun `no intermediate commit in URL field without protocol and with URL detection`() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
|
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
|
||||||
chainInput("bla.com/img.jpg")
|
chainInput("bla.com/img.jpg")
|
||||||
assertEquals("", lastAddedWord)
|
assertEquals("", lastAddedWord)
|
||||||
|
@ -446,7 +446,7 @@ class InputLogicTest {
|
||||||
@Test fun `don't accidentally detect some other text fields as URI`() {
|
@Test fun `don't accidentally detect some other text fields as URI`() {
|
||||||
// see comment in InputLogic.textBeforeCursorMayBeUrlOrSimilar
|
// see comment in InputLogic.textBeforeCursorMayBeUrlOrSimilar
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
||||||
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE)
|
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE)
|
||||||
chainInput("Hey,why")
|
chainInput("Hey,why")
|
||||||
assertEquals("Hey, why", text)
|
assertEquals("Hey, why", text)
|
||||||
|
@ -460,7 +460,7 @@ class InputLogicTest {
|
||||||
assertEquals("", composingText)
|
assertEquals("", composingText)
|
||||||
// then with URL detection
|
// then with URL detection
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
chainInput("15:50-17")
|
chainInput("15:50-17")
|
||||||
assertEquals("15:50-17", text)
|
assertEquals("15:50-17", text)
|
||||||
assertEquals("", composingText)
|
assertEquals("", composingText)
|
||||||
|
@ -476,7 +476,7 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun `autospace works in URL field when input isn't URL`() {
|
@Test fun `autospace works in URL field when input isn't URL`() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
|
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
|
||||||
pickSuggestion("this")
|
pickSuggestion("this")
|
||||||
input('b')
|
input('b')
|
||||||
|
@ -488,7 +488,7 @@ class InputLogicTest {
|
||||||
// https://github.com/Helium314/HeliBoard/issues/229
|
// https://github.com/Helium314/HeliBoard/issues/229
|
||||||
@Test fun `autospace works in URL field when input isn't URL, also for multiple suggestions`() {
|
@Test fun `autospace works in URL field when input isn't URL, also for multiple suggestions`() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
|
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
|
||||||
pickSuggestion("this")
|
pickSuggestion("this")
|
||||||
pickSuggestion("is")
|
pickSuggestion("is")
|
||||||
|
@ -545,7 +545,7 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun `autospace works in URL field when starting with quotes`() {
|
@Test fun `autospace works in URL field when starting with quotes`() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_URL_DETECTION, true) }
|
||||||
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
|
setInputType(InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_URI)
|
||||||
input("\"")
|
input("\"")
|
||||||
pickSuggestion("this")
|
pickSuggestion("this")
|
||||||
|
@ -569,21 +569,21 @@ class InputLogicTest {
|
||||||
assertEquals("\"\"\"", text)
|
assertEquals("\"\"\"", text)
|
||||||
|
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
||||||
chainInput("\"\"\"")
|
chainInput("\"\"\"")
|
||||||
assertEquals("\"\"\"", text)
|
assertEquals("\"\"\"", text)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun `autospace still happens after "`() {
|
@Test fun `autospace still happens after "`() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
||||||
chainInput("\"hello\"you")
|
chainInput("\"hello\"you")
|
||||||
assertEquals("\"hello\" you", text)
|
assertEquals("\"hello\" you", text)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun `autospace still happens after " if next word is in quotes`() {
|
@Test fun `autospace still happens after " if next word is in quotes`() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
||||||
chainInput("\"hello\"\"you\"")
|
chainInput("\"hello\"\"you\"")
|
||||||
assertEquals("\"hello\" \"you\"", text)
|
assertEquals("\"hello\" \"you\"", text)
|
||||||
}
|
}
|
||||||
|
@ -599,14 +599,14 @@ class InputLogicTest {
|
||||||
|
|
||||||
@Test fun `autospace still happens after " if nex word is in " and after comma`() {
|
@Test fun `autospace still happens after " if nex word is in " and after comma`() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
||||||
chainInput("\"hello\",\"you\"")
|
chainInput("\"hello\",\"you\"")
|
||||||
assertEquals("\"hello\", \"you\"", text)
|
assertEquals("\"hello\", \"you\"", text)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun `autospace in json editor`() {
|
@Test fun `autospace in json editor`() {
|
||||||
reset()
|
reset()
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
latinIME.prefs().edit { putBoolean(Settings.PREF_AUTOSPACE_AFTER_PUNCTUATION, true) }
|
||||||
chainInput("{\"label\":\"")
|
chainInput("{\"label\":\"")
|
||||||
assertEquals("{\"label\": \"", text)
|
assertEquals("{\"label\": \"", text)
|
||||||
input('c')
|
input('c')
|
||||||
|
@ -676,7 +676,7 @@ class InputLogicTest {
|
||||||
lastAddedWord = ""
|
lastAddedWord = ""
|
||||||
|
|
||||||
// reset settings
|
// reset settings
|
||||||
DeviceProtectedUtils.getSharedPreferences(latinIME).edit { clear() }
|
latinIME.prefs().edit { clear() }
|
||||||
|
|
||||||
setText("") // (re)sets selection and composing word
|
setText("") // (re)sets selection and composing word
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import helium314.keyboard.latin.settings.Settings
|
||||||
import helium314.keyboard.latin.settings.SettingsValuesForSuggestion
|
import helium314.keyboard.latin.settings.SettingsValuesForSuggestion
|
||||||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
||||||
import helium314.keyboard.latin.utils.SuggestionResults
|
import helium314.keyboard.latin.utils.SuggestionResults
|
||||||
|
import helium314.keyboard.latin.utils.prefs
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.robolectric.Robolectric
|
import org.robolectric.Robolectric
|
||||||
import org.robolectric.RobolectricTestRunner
|
import org.robolectric.RobolectricTestRunner
|
||||||
|
@ -253,7 +254,7 @@ class SuggestTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun `shortcuts are not autocorrected when setting is off`() {
|
@Test fun `shortcuts are not autocorrected when setting is off`() {
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(latinIME)
|
val prefs = latinIME.prefs()
|
||||||
prefs.edit { putBoolean(Settings.PREF_AUTOCORRECT_SHORTCUTS, false) }
|
prefs.edit { putBoolean(Settings.PREF_AUTOCORRECT_SHORTCUTS, false) }
|
||||||
val locale = Locale.ENGLISH
|
val locale = Locale.ENGLISH
|
||||||
val result = shouldBeAutoCorrected(
|
val result = shouldBeAutoCorrected(
|
||||||
|
@ -268,7 +269,7 @@ class SuggestTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setAutCorrectThreshold(threshold: String) {
|
private fun setAutCorrectThreshold(threshold: String) {
|
||||||
val prefs = DeviceProtectedUtils.getSharedPreferences(latinIME)
|
val prefs = latinIME.prefs()
|
||||||
prefs.edit { putString(Settings.PREF_AUTO_CORRECTION_CONFIDENCE, threshold) }
|
prefs.edit { putString(Settings.PREF_AUTO_CORRECTION_CONFIDENCE, threshold) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue