Skip to content

Commit

Permalink
fix:Linting issues due to Complex Method
Browse files Browse the repository at this point in the history
  • Loading branch information
angrezichatterbox committed Dec 5, 2024
1 parent 14a05a5 commit 7ec48c4
Show file tree
Hide file tree
Showing 11 changed files with 171 additions and 115 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/be/scri/helpers/MyKeyboard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.io.IOException
* @attr ref android.R.styleable#Keyboard_keyWidth
* @attr ref android.R.styleable#Keyboard_horizontalGap
*/
@Suppress("LongMethod", "NestedBlockDepth")
@Suppress("LongMethod", "NestedBlockDepth", "CyclomaticComplexMethod")
class MyKeyboard {
/** Horizontal gap default for all rows */
private var mDefaultHorizontalGap = 0
Expand Down
35 changes: 21 additions & 14 deletions app/src/main/java/be/scri/services/EnglishKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,21 @@ class EnglishKeyboardIME : SimpleKeyboardIME("English") {
if (keyboard == null || inputConnection == null) {
return
}

if (code != MyKeyboard.KEYCODE_SHIFT) {
lastShiftPressTS = 0
}

when (code) {
MyKeyboard.KEYCODE_DELETE -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleDelete(false, binding = null)
} else {
handleDelete(true, keyboardBinding)
}
handleKeycodeDelete()
keyboardView!!.invalidateAllKeys()
}
MyKeyboard.KEYCODE_SHIFT -> {
super.handleKeyboardLetters(keyboardMode, keyboardView)
keyboardView!!.invalidateAllKeys()
}
MyKeyboard.KEYCODE_ENTER -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleKeycodeEnter(binding = null, false)
} else {
handleKeycodeEnter(keyboardBinding, true)
currentState = ScribeState.IDLE
switchToCommandToolBar()
updateUI()
}
handleKeycodeEnter()
}
MyKeyboard.KEYCODE_MODE_CHANGE -> {
handleModeChange(keyboardMode, keyboardView, this)
Expand All @@ -99,6 +87,25 @@ class EnglishKeyboardIME : SimpleKeyboardIME("English") {
}
}

fun handleKeycodeDelete() {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleDelete(false, keyboardBinding)
} else {
handleDelete(true, keyboardBinding)
}
}

fun handleKeycodeEnter() {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleKeycodeEnter(keyboardBinding, false)
} else {
handleKeycodeEnter(keyboardBinding, true)
currentState = ScribeState.IDLE
switchToCommandToolBar()
updateUI()
}
}

override fun onCreate() {
super.onCreate()
keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType)
Expand Down
35 changes: 21 additions & 14 deletions app/src/main/java/be/scri/services/FrenchKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,33 +44,21 @@ class FrenchKeyboardIME : SimpleKeyboardIME("French") {
if (keyboard == null || inputConnection == null) {
return
}

if (code != MyKeyboard.KEYCODE_SHIFT) {
lastShiftPressTS = 0
}

when (code) {
MyKeyboard.KEYCODE_DELETE -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleDelete(false, keyboardBinding)
} else {
handleDelete(true, keyboardBinding)
}
handleKeycodeDelete()
keyboardView!!.invalidateAllKeys()
}
MyKeyboard.KEYCODE_SHIFT -> {
super.handleKeyboardLetters(keyboardMode, keyboardView)
keyboardView!!.invalidateAllKeys()
}
MyKeyboard.KEYCODE_ENTER -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleKeycodeEnter(keyboardBinding, false)
} else {
handleKeycodeEnter(keyboardBinding, true)
currentState = ScribeState.IDLE
switchToCommandToolBar()
updateUI()
}
handleKeycodeEnter()
}
MyKeyboard.KEYCODE_MODE_CHANGE -> {
handleModeChange(keyboardMode, keyboardView, this)
Expand All @@ -95,6 +83,25 @@ class FrenchKeyboardIME : SimpleKeyboardIME("French") {
}
}

fun handleKeycodeDelete() {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleDelete(false, keyboardBinding)
} else {
handleDelete(true, keyboardBinding)
}
}

fun handleKeycodeEnter() {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleKeycodeEnter(keyboardBinding, false)
} else {
handleKeycodeEnter(keyboardBinding, true)
currentState = ScribeState.IDLE
switchToCommandToolBar()
updateUI()
}
}

override fun onCreate() {
super.onCreate()
keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType)
Expand Down
35 changes: 21 additions & 14 deletions app/src/main/java/be/scri/services/GermanKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,21 @@ class GermanKeyboardIME : SimpleKeyboardIME("German") {
if (keyboard == null || inputConnection == null) {
return
}

if (code != MyKeyboard.KEYCODE_SHIFT) {
lastShiftPressTS = 0
}

when (code) {
MyKeyboard.KEYCODE_DELETE -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleDelete(false, binding = null)
} else {
handleDelete(true, keyboardBinding)
}
handleKeycodeDelete()
keyboardView!!.invalidateAllKeys()
}
MyKeyboard.KEYCODE_SHIFT -> {
super.handleKeyboardLetters(keyboardMode, keyboardView)
keyboardView!!.invalidateAllKeys()
}
MyKeyboard.KEYCODE_ENTER -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleKeycodeEnter(binding = null, false)
} else {
handleKeycodeEnter(keyboardBinding, true)
currentState = ScribeState.IDLE
switchToCommandToolBar()
updateUI()
}
handleKeycodeEnter()
}
MyKeyboard.KEYCODE_MODE_CHANGE -> {
handleModeChange(keyboardMode, keyboardView, this)
Expand All @@ -104,6 +92,25 @@ class GermanKeyboardIME : SimpleKeyboardIME("German") {
}
}

fun handleKeycodeDelete() {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleDelete(false, keyboardBinding)
} else {
handleDelete(true, keyboardBinding)
}
}

fun handleKeycodeEnter() {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleKeycodeEnter(keyboardBinding, false)
} else {
handleKeycodeEnter(keyboardBinding, true)
currentState = ScribeState.IDLE
switchToCommandToolBar()
updateUI()
}
}

override fun onCreate() {
super.onCreate()
keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType)
Expand Down
35 changes: 21 additions & 14 deletions app/src/main/java/be/scri/services/ItalianKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,33 +44,21 @@ class ItalianKeyboardIME : SimpleKeyboardIME("Italian") {
if (keyboard == null || inputConnection == null) {
return
}

if (code != MyKeyboard.KEYCODE_SHIFT) {
lastShiftPressTS = 0
}

when (code) {
MyKeyboard.KEYCODE_DELETE -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleDelete(false, keyboardBinding)
} else {
handleDelete(true, keyboardBinding)
}
handleKeycodeDelete()
keyboardView!!.invalidateAllKeys()
}
MyKeyboard.KEYCODE_SHIFT -> {
super.handleKeyboardLetters(keyboardMode, keyboardView)
keyboardView!!.invalidateAllKeys()
}
MyKeyboard.KEYCODE_ENTER -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleKeycodeEnter(keyboardBinding, false)
} else {
handleKeycodeEnter(keyboardBinding, true)
currentState = ScribeState.IDLE
switchToCommandToolBar()
updateUI()
}
handleKeycodeEnter()
}
MyKeyboard.KEYCODE_MODE_CHANGE -> {
handleModeChange(keyboardMode, keyboardView, this)
Expand All @@ -95,6 +83,25 @@ class ItalianKeyboardIME : SimpleKeyboardIME("Italian") {
}
}

fun handleKeycodeDelete() {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleDelete(false, keyboardBinding)
} else {
handleDelete(true, keyboardBinding)
}
}

fun handleKeycodeEnter() {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleKeycodeEnter(keyboardBinding, false)
} else {
handleKeycodeEnter(keyboardBinding, true)
currentState = ScribeState.IDLE
switchToCommandToolBar()
updateUI()
}
}

override fun onCreate() {
super.onCreate()
keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType)
Expand Down
35 changes: 21 additions & 14 deletions app/src/main/java/be/scri/services/PortugueseKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,33 +44,21 @@ class PortugueseKeyboardIME : SimpleKeyboardIME("Portuguese") {
if (keyboard == null || inputConnection == null) {
return
}

if (code != MyKeyboard.KEYCODE_SHIFT) {
lastShiftPressTS = 0
}

when (code) {
MyKeyboard.KEYCODE_DELETE -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleDelete(false, keyboardBinding)
} else {
handleDelete(true, keyboardBinding)
}
handleKeycodeDelete()
keyboardView!!.invalidateAllKeys()
}
MyKeyboard.KEYCODE_SHIFT -> {
super.handleKeyboardLetters(keyboardMode, keyboardView)
keyboardView!!.invalidateAllKeys()
}
MyKeyboard.KEYCODE_ENTER -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleKeycodeEnter(keyboardBinding, false)
} else {
handleKeycodeEnter(keyboardBinding, true)
currentState = ScribeState.IDLE
switchToCommandToolBar()
updateUI()
}
handleKeycodeEnter()
}
MyKeyboard.KEYCODE_MODE_CHANGE -> {
handleModeChange(keyboardMode, keyboardView, this)
Expand All @@ -95,6 +83,25 @@ class PortugueseKeyboardIME : SimpleKeyboardIME("Portuguese") {
}
}

fun handleKeycodeDelete() {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleDelete(false, keyboardBinding)
} else {
handleDelete(true, keyboardBinding)
}
}

fun handleKeycodeEnter() {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleKeycodeEnter(keyboardBinding, false)
} else {
handleKeycodeEnter(keyboardBinding, true)
currentState = ScribeState.IDLE
switchToCommandToolBar()
updateUI()
}
}

override fun onCreate() {
super.onCreate()
keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType)
Expand Down
35 changes: 21 additions & 14 deletions app/src/main/java/be/scri/services/RussianKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,33 +44,21 @@ class RussianKeyboardIME : SimpleKeyboardIME("Russian") {
if (keyboard == null || inputConnection == null) {
return
}

if (code != MyKeyboard.KEYCODE_SHIFT) {
lastShiftPressTS = 0
}

when (code) {
MyKeyboard.KEYCODE_DELETE -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleDelete(false, keyboardBinding)
} else {
handleDelete(true, keyboardBinding)
}
handleKeycodeDelete()
keyboardView!!.invalidateAllKeys()
}
MyKeyboard.KEYCODE_SHIFT -> {
super.handleKeyboardLetters(keyboardMode, keyboardView)
keyboardView!!.invalidateAllKeys()
}
MyKeyboard.KEYCODE_ENTER -> {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleKeycodeEnter(keyboardBinding, false)
} else {
handleKeycodeEnter(keyboardBinding, true)
currentState = ScribeState.IDLE
switchToCommandToolBar()
updateUI()
}
handleKeycodeEnter()
}
MyKeyboard.KEYCODE_MODE_CHANGE -> {
handleModeChange(keyboardMode, keyboardView, this)
Expand All @@ -95,6 +83,25 @@ class RussianKeyboardIME : SimpleKeyboardIME("Russian") {
}
}

fun handleKeycodeDelete() {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleDelete(false, keyboardBinding)
} else {
handleDelete(true, keyboardBinding)
}
}

fun handleKeycodeEnter() {
if (currentState == ScribeState.IDLE || currentState == ScribeState.SELECT_COMMAND) {
handleKeycodeEnter(keyboardBinding, false)
} else {
handleKeycodeEnter(keyboardBinding, true)
currentState = ScribeState.IDLE
switchToCommandToolBar()
updateUI()
}
}

override fun onCreate() {
super.onCreate()
keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType)
Expand Down
Loading

0 comments on commit 7ec48c4

Please sign in to comment.