Skip to content

Commit

Permalink
Change enter icon when in a command mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Linfye committed Nov 21, 2024
1 parent 3b6f35a commit edd1d8e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
21 changes: 10 additions & 11 deletions app/src/main/java/be/scri/helpers/MyKeyboard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class MyKeyboard {
/** Keyboard rows */
private val mRows = ArrayList<Row?>()

var isCommandMode = false

companion object {
private const val TAG_KEYBOARD = "Keyboard"
private const val TAG_ROW = "Row"
Expand Down Expand Up @@ -408,19 +410,16 @@ class MyKeyboard {
key = createKeyFromXml(res, currentRow!!, x, y, parser)
mKeys!!.add(key)
if (key.code == KEYCODE_ENTER) {
val enterResourceId =
val enterResourceId = if (isCommandMode) {
R.drawable.play_button
} else {
when (mEnterKeyType) {
EditorInfo.IME_ACTION_SEARCH ->
R.drawable.ic_search_vector
EditorInfo.IME_ACTION_NEXT,
EditorInfo.IME_ACTION_GO,
->
R.drawable.ic_arrow_right_vector
EditorInfo.IME_ACTION_SEND ->
R.drawable.ic_send_vector
else ->
R.drawable.ic_enter_vector
EditorInfo.IME_ACTION_SEARCH -> R.drawable.ic_search_vector
EditorInfo.IME_ACTION_NEXT, EditorInfo.IME_ACTION_GO -> R.drawable.ic_arrow_right_vector
EditorInfo.IME_ACTION_SEND -> R.drawable.ic_send_vector
else -> R.drawable.ic_enter_vector
}
}
key.icon = context.resources.getDrawable(enterResourceId, context.theme)
}
currentRow.mKeys.add(key)
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/be/scri/services/SimpleKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ abstract class SimpleKeyboardIME(
private lateinit var dbHelper: DatabaseHelper
lateinit var emojiKeywords: HashMap<String, MutableList<String>>
var isAutoSuggestEnabled: Boolean = false
var isCommandMode: Boolean = false
var lastWord: String? = null
var autosuggestEmojis: MutableList<String>? = null
// abstract var keyboardViewKeyboardBinding : KeyboardViewKeyboardBinding
Expand All @@ -87,6 +88,10 @@ abstract class SimpleKeyboardIME(
DISPLAY_INFORMATION,
}

fun updateIsCommandMode(newIsCommandMode: Boolean) {
keyboard!!.isCommandMode = newIsCommandMode
}

fun getIsAccentCharacter(): Boolean {
val sharedPref = getSharedPreferences("app_preferences", Context.MODE_PRIVATE)
val isAccentCharacter = sharedPref.getBoolean("disable_accent_character_Swedish", false)
Expand Down Expand Up @@ -150,8 +155,10 @@ abstract class SimpleKeyboardIME(
initializeEmojiButtons()
updateButtonVisibility(isAutoSuggestEnabled)
updateButtonText(isAutoSuggestEnabled, autosuggestEmojis)
updateIsCommandMode(true)
keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType)
Log.d("Debug", "isCommandMode: ${keyboard!!.isCommandMode}")
}

ScribeState.SELECT_COMMAND -> setupSelectCommandView()
else -> switchToToolBar()
}
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/play_button.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M2.883,-0.023C3.195,-0.023 3.508,-0.023 3.82,-0.023C4.293,0.094 4.746,0.273 5.18,0.516C10.617,3.641 16.055,6.766 21.492,9.891C22.098,10.262 22.512,10.785 22.734,11.461C22.895,12.18 22.738,12.82 22.266,13.383C22.035,13.645 21.777,13.871 21.492,14.063C15.883,17.305 10.258,20.523 4.617,23.719C4.348,23.813 4.082,23.898 3.82,23.977C3.508,23.977 3.195,23.977 2.883,23.977C1.938,23.684 1.383,23.043 1.219,22.055C1.164,18.695 1.141,15.336 1.148,11.977C1.141,8.617 1.164,5.258 1.219,1.898C1.383,0.91 1.938,0.27 2.883,-0.023ZM2.883,-0.023"
android:fillColor="#FFFFFFFF"/>
</vector>

0 comments on commit edd1d8e

Please sign in to comment.