Bubbles icon indicating copy to clipboard operation
Bubbles copied to clipboard

Keyboard doesn't opens

Open pawanacharya1 opened this issue 2 years ago • 2 comments

Using edit text in expanded view doesn't work.

pawanacharya1 avatar May 12 '22 05:05 pawanacharya1

There is a big problem at this point, the "focus" of a floating window depends on the android version and custom system. You can make a temp solution for all devices, you must require the focus to your edit text and enable the keyboard programatically.

// Get Android's focus
 editText.requestFocus()
// Activate the keyboard on click
 editText.setOnClickListener {
    enableKeyboard()
 }

And you can put the enableKeyboard() function in your Utils or something

    private fun enableKeyboard() {
        if (params == null) {
            Log.e("error_tag", "Not params found, can't enable keyboard")
            return
        }
        if (params!!.flags and WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE != 0) {
            params!!.flags = params!!.flags and WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE.inv()
            updateView()
            Log.v("dev_tag", "Updated floating window")
        } else {
            Log.e("error_tag", "View already focusable")
        }
    }

For this solution, the user must touch 2 times until the keyboard appears, you can remove the Log lines, i write this just for debug :P

Nojipiz avatar May 15 '22 15:05 Nojipiz

Thanks @Nojipiz for the great explanation!!

I was a bit out of touch on this one. 😅

siddharthks2010 avatar Jun 17 '22 03:06 siddharthks2010