Skip to content

Commit

Permalink
Merge pull request #52 from rafifrabbani/master
Browse files Browse the repository at this point in the history
fix: edit text focus behaviour
  • Loading branch information
amirisback authored Sep 19, 2023
2 parents 2017102 + 671da15 commit 3d5fa1f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions app/src/main/java/com/frogobox/appkeyboard/services/KeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package com.frogobox.appkeyboard.services
import android.content.Intent
import android.os.Build
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import androidx.annotation.RequiresApi
Expand Down Expand Up @@ -293,6 +295,38 @@ class KeyboardIME : BaseKeyboardIME<KeyboardImeBinding>() {
}
}

@RequiresApi(Build.VERSION_CODES.M)
override fun onKey(code: Int) {
val formView = binding?.keyboardForm
var inputConnection = currentInputConnection

if (formView?.visibility == View.VISIBLE) {
val et1 = formView.binding?.etText
val et1Connection = et1?.onCreateInputConnection(EditorInfo())

val et2 = formView.binding?.etText2
val et2Connection = et2?.onCreateInputConnection(EditorInfo())

val et3 = formView.binding?.etText3
val et3Connection = et3?.onCreateInputConnection(EditorInfo())

if (et1?.isFocused == true) {
inputConnection = et1Connection
} else if (et2?.isFocused == true) {
inputConnection = et2Connection
} else if (et3?.isFocused == true) {
inputConnection = et3Connection
}

} else if (binding?.keyboardWebview?.visibility == View.VISIBLE) {
inputConnection =
binding?.keyboardWebview?.binding?.webview?.onCreateInputConnection(EditorInfo())
} else {
inputConnection = currentInputConnection
}
onKeyExt(code, inputConnection)
}

override fun initView() {
setupFeatureKeyboard()
initBackToMainKeyboard()
Expand Down

0 comments on commit 3d5fa1f

Please sign in to comment.