mirror of
https://github.com/SimpleMobileTools/Simple-Keyboard.git
synced 2025-06-05 21:49:26 +02:00
Added safeStorageContext
This commit is contained in:
@ -22,11 +22,12 @@ import com.simplemobiletools.keyboard.databases.ClipsDatabase
|
||||
import com.simplemobiletools.keyboard.helpers.*
|
||||
import com.simplemobiletools.keyboard.interfaces.ClipsDao
|
||||
|
||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||
val Context.config: Config get() = Config.newInstance(applicationContext.safeStorageContext)
|
||||
|
||||
val Context.safeStorageContext: Context
|
||||
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
createDeviceProtectedStorageContext()
|
||||
val deviceContext = createDeviceProtectedStorageContext()
|
||||
deviceContext
|
||||
} else {
|
||||
this
|
||||
}
|
||||
|
@ -13,8 +13,10 @@ import android.view.inputmethod.EditorInfo.IME_FLAG_NO_ENTER_ACTION
|
||||
import android.view.inputmethod.EditorInfo.IME_MASK_ACTION
|
||||
import android.view.inputmethod.ExtractedTextRequest
|
||||
import com.simplemobiletools.commons.extensions.getSharedPrefs
|
||||
import com.simplemobiletools.commons.extensions.isDeviceLocked
|
||||
import com.simplemobiletools.keyboard.R
|
||||
import com.simplemobiletools.keyboard.extensions.config
|
||||
import com.simplemobiletools.keyboard.extensions.safeStorageContext
|
||||
import com.simplemobiletools.keyboard.helpers.*
|
||||
import com.simplemobiletools.keyboard.views.MyKeyboardView
|
||||
import kotlinx.android.synthetic.main.keyboard_view_keyboard.view.keyboard_holder
|
||||
@ -40,7 +42,7 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
|
||||
|
||||
override fun onInitializeInterface() {
|
||||
super.onInitializeInterface()
|
||||
getSharedPrefs().registerOnSharedPreferenceChangeListener(this)
|
||||
safeStorageContext.getSharedPrefs().registerOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
|
||||
override fun onCreateInputView(): View {
|
||||
@ -63,7 +65,6 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
|
||||
super.onStartInput(attribute, restarting)
|
||||
inputTypeClass = attribute!!.inputType and TYPE_MASK_CLASS
|
||||
inputTypeClassVariation = attribute!!.inputType and TYPE_MASK_VARIATION
|
||||
|
||||
enterKeyType = attribute.imeOptions and (IME_MASK_ACTION or IME_FLAG_NO_ENTER_ACTION)
|
||||
keyboard = createNewKeyboard()
|
||||
keyboardView?.setKeyboard(keyboard!!)
|
||||
|
@ -225,9 +225,9 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
mLabelTextSize = resources.getDimension(R.dimen.label_text_size).toInt()
|
||||
mPreviewHeight = resources.getDimension(R.dimen.key_height).toInt()
|
||||
mSpaceMoveThreshold = resources.getDimension(R.dimen.medium_margin).toInt()
|
||||
mTextColor = context.getProperTextColor()
|
||||
mBackgroundColor = context.getProperBackgroundColor()
|
||||
mPrimaryColor = context.getProperPrimaryColor()
|
||||
mTextColor = context.safeStorageContext.getProperTextColor()
|
||||
mBackgroundColor = context.safeStorageContext.getProperBackgroundColor()
|
||||
mPrimaryColor = context.safeStorageContext.getProperPrimaryColor()
|
||||
|
||||
mPreviewPopup = PopupWindow(context)
|
||||
mPreviewText = inflater.inflate(resources.getLayout(R.layout.keyboard_key_preview), null) as TextView
|
||||
@ -374,12 +374,15 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
}
|
||||
|
||||
fun setupKeyboard(changedView: View? = null) {
|
||||
mTextColor = context.getProperTextColor()
|
||||
mBackgroundColor = context.getProperBackgroundColor()
|
||||
mPrimaryColor = context.getProperPrimaryColor()
|
||||
with(context.safeStorageContext) {
|
||||
mTextColor = getProperTextColor()
|
||||
mBackgroundColor = getProperBackgroundColor()
|
||||
mPrimaryColor = getProperPrimaryColor()
|
||||
|
||||
mShowKeyBorders = config.showKeyBorders
|
||||
mUsingSystemTheme = config.isUsingSystemTheme
|
||||
}
|
||||
|
||||
mShowKeyBorders = context.config.showKeyBorders
|
||||
mUsingSystemTheme = context.config.isUsingSystemTheme
|
||||
|
||||
val isMainKeyboard = changedView == null || changedView != mini_keyboard_view
|
||||
mKeyBackground = if (mShowKeyBorders && isMainKeyboard) {
|
||||
|
Reference in New Issue
Block a user