Refactoring
This commit is contained in:
parent
f46bc3652d
commit
999c19cb74
|
@ -12,6 +12,7 @@ import androidx.appcompat.app.AlertDialog
|
|||
import androidx.core.content.res.ResourcesCompat
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.isNougatPlus
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.commons.views.MyTextView
|
||||
import com.simplemobiletools.keyboard.R
|
||||
|
@ -22,7 +23,7 @@ import com.simplemobiletools.keyboard.interfaces.ClipsDao
|
|||
val Context.config: Config get() = Config.newInstance(applicationContext.safeStorageContext)
|
||||
|
||||
val Context.safeStorageContext: Context
|
||||
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isDeviceLocked) {
|
||||
get() = if (isNougatPlus() && isDeviceLocked) {
|
||||
createDeviceProtectedStorageContext()
|
||||
} else {
|
||||
this
|
||||
|
|
|
@ -30,9 +30,11 @@ enum class ShiftState {
|
|||
if (isInputTypeAllowedCapitalizing(inputTypeClassVariation)) {
|
||||
return OFF
|
||||
}
|
||||
return when (context.config.enableSentencesCapitalization) {
|
||||
true -> ON_ONE_CHAR
|
||||
else -> OFF
|
||||
|
||||
return if (context.config.enableSentencesCapitalization) {
|
||||
ON_ONE_CHAR
|
||||
} else {
|
||||
OFF
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,14 +42,11 @@ enum class ShiftState {
|
|||
if (isInputTypeAllowedCapitalizing(inputTypeClassVariation)) {
|
||||
return OFF
|
||||
}
|
||||
return when {
|
||||
shouldCapitalize(context, text) -> {
|
||||
ON_ONE_CHAR
|
||||
}
|
||||
|
||||
else -> {
|
||||
OFF
|
||||
}
|
||||
return if (shouldCapitalize(context, text)) {
|
||||
ON_ONE_CHAR
|
||||
} else {
|
||||
OFF
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,10 +105,8 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
|
|||
return
|
||||
} else {
|
||||
// try capitalizing based on the editor info like google keep or google messenger apps
|
||||
val editorInfo = currentInputEditorInfo
|
||||
|
||||
if (editorInfo != null && editorInfo.inputType != InputType.TYPE_NULL) {
|
||||
if (currentInputConnection.getCursorCapsMode(editorInfo.inputType) != 0) {
|
||||
if (currentInputEditorInfo != null && currentInputEditorInfo.inputType != InputType.TYPE_NULL) {
|
||||
if (currentInputConnection.getCursorCapsMode(currentInputEditorInfo.inputType) != 0) {
|
||||
keyboard?.setShifted(ShiftState.ON_ONE_CHAR)
|
||||
keyboardView?.invalidateAllKeys()
|
||||
return
|
||||
|
@ -117,7 +115,6 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
|
|||
}
|
||||
}
|
||||
|
||||
// in other cases reset shift to OFF
|
||||
keyboard?.setShifted(ShiftState.OFF)
|
||||
keyboardView?.invalidateAllKeys()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue