mirror of
https://github.com/SimpleMobileTools/Simple-Keyboard.git
synced 2025-04-24 23:18:48 +02:00
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 androidx.core.content.res.ResourcesCompat
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
|
import com.simplemobiletools.commons.helpers.isNougatPlus
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.commons.views.MyTextView
|
import com.simplemobiletools.commons.views.MyTextView
|
||||||
import com.simplemobiletools.keyboard.R
|
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.config: Config get() = Config.newInstance(applicationContext.safeStorageContext)
|
||||||
|
|
||||||
val Context.safeStorageContext: Context
|
val Context.safeStorageContext: Context
|
||||||
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isDeviceLocked) {
|
get() = if (isNougatPlus() && isDeviceLocked) {
|
||||||
createDeviceProtectedStorageContext()
|
createDeviceProtectedStorageContext()
|
||||||
} else {
|
} else {
|
||||||
this
|
this
|
||||||
|
@ -30,9 +30,11 @@ enum class ShiftState {
|
|||||||
if (isInputTypeAllowedCapitalizing(inputTypeClassVariation)) {
|
if (isInputTypeAllowedCapitalizing(inputTypeClassVariation)) {
|
||||||
return OFF
|
return OFF
|
||||||
}
|
}
|
||||||
return when (context.config.enableSentencesCapitalization) {
|
|
||||||
true -> ON_ONE_CHAR
|
return if (context.config.enableSentencesCapitalization) {
|
||||||
else -> OFF
|
ON_ONE_CHAR
|
||||||
|
} else {
|
||||||
|
OFF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,16 +42,13 @@ enum class ShiftState {
|
|||||||
if (isInputTypeAllowedCapitalizing(inputTypeClassVariation)) {
|
if (isInputTypeAllowedCapitalizing(inputTypeClassVariation)) {
|
||||||
return OFF
|
return OFF
|
||||||
}
|
}
|
||||||
return when {
|
|
||||||
shouldCapitalize(context, text) -> {
|
|
||||||
ON_ONE_CHAR
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {
|
return if (shouldCapitalize(context, text)) {
|
||||||
|
ON_ONE_CHAR
|
||||||
|
} else {
|
||||||
OFF
|
OFF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The function is checking whether there is a need in capitalizing based on the given text
|
* The function is checking whether there is a need in capitalizing based on the given text
|
||||||
|
@ -105,10 +105,8 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
|
|||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
// try capitalizing based on the editor info like google keep or google messenger apps
|
// try capitalizing based on the editor info like google keep or google messenger apps
|
||||||
val editorInfo = currentInputEditorInfo
|
if (currentInputEditorInfo != null && currentInputEditorInfo.inputType != InputType.TYPE_NULL) {
|
||||||
|
if (currentInputConnection.getCursorCapsMode(currentInputEditorInfo.inputType) != 0) {
|
||||||
if (editorInfo != null && editorInfo.inputType != InputType.TYPE_NULL) {
|
|
||||||
if (currentInputConnection.getCursorCapsMode(editorInfo.inputType) != 0) {
|
|
||||||
keyboard?.setShifted(ShiftState.ON_ONE_CHAR)
|
keyboard?.setShifted(ShiftState.ON_ONE_CHAR)
|
||||||
keyboardView?.invalidateAllKeys()
|
keyboardView?.invalidateAllKeys()
|
||||||
return
|
return
|
||||||
@ -117,7 +115,6 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// in other cases reset shift to OFF
|
|
||||||
keyboard?.setShifted(ShiftState.OFF)
|
keyboard?.setShifted(ShiftState.OFF)
|
||||||
keyboardView?.invalidateAllKeys()
|
keyboardView?.invalidateAllKeys()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user