Skip to content

Commit

Permalink
Adding an IME switcher button. Fixes #380 (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines committed Sep 8, 2023
1 parent 151b4ba commit 2cdc6d0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.compose.material.icons.outlined.ArrowDropDown
import androidx.compose.material.icons.outlined.ArrowDropUp
import androidx.compose.material.icons.outlined.ContentPaste
import androidx.compose.material.icons.outlined.Copyright
import androidx.compose.material.icons.outlined.Keyboard
import androidx.compose.material.icons.outlined.KeyboardBackspace
import androidx.compose.material.icons.outlined.KeyboardCapslock
import androidx.compose.material.icons.outlined.KeyboardReturn
Expand Down Expand Up @@ -42,13 +43,18 @@ val NUMERIC_KEY_ITEM =
size = FontSizeVariant.LARGE,
color = ColorVariant.SECONDARY,
),
swipeType = SwipeNWay.FOUR_WAY_CROSS,
swipeType = SwipeNWay.EIGHT_WAY,
swipes = mapOf(
SwipeDirection.TOP to KeyC(
display = KeyDisplay.IconDisplay(Icons.Outlined.SelectAll),
action = KeyAction.SelectAndCopyAll,
color = ColorVariant.MUTED,
),
SwipeDirection.TOP_LEFT to KeyC(
display = KeyDisplay.IconDisplay(Icons.Outlined.Keyboard),
action = KeyAction.SwitchIME,
color = ColorVariant.MUTED,
),
SwipeDirection.BOTTOM to KeyC(
display = KeyDisplay.IconDisplay(Icons.Outlined.ContentPaste),
action = KeyAction.Paste,
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/dessalines/thumbkey/utils/Types.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ sealed class KeyAction {
object Paste : KeyAction()
object SwitchLanguage : KeyAction()
object SwitchPosition : KeyAction()
object SwitchIME : KeyAction()
}

enum class KeyboardMode {
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/dessalines/thumbkey/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.text.InputType
import android.util.Log
import android.view.KeyEvent
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.Toast
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.ArrowBack
Expand Down Expand Up @@ -355,6 +356,10 @@ fun performKeyAction(
}
KeyAction.SwitchLanguage -> onSwitchLanguage()
KeyAction.SwitchPosition -> onSwitchPosition()
KeyAction.SwitchIME -> {
val imeManager = ime.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imeManager.showInputMethodPicker()
}
}
}

Expand Down

0 comments on commit 2cdc6d0

Please sign in to comment.