Cotton code
36 lines · 1.3 KB · KotlinRaw
package com.cottondb.android.keyboardimport android.app.Activityimport android.os.Bundleimport android.view.inputmethod.InputMethodManagerimport android.widget.Buttonimport android.widget.EditTextimport android.widget.LinearLayout/** Debug-only synthetic native editor used to drive the production IME process. */class ExternalEditorHarnessActivity : Activity() {    override fun onCreate(savedInstanceState: Bundle?) {        super.onCreate(savedInstanceState)        val editor = EditText(this).apply {            contentDescription = "External keyboard editor"            setText("External ")            isSingleLine = false        }        fun showKeyboard() {            editor.requestFocus()            editor.setSelection(editor.text.length)            editor.post { getSystemService(InputMethodManager::class.java).showSoftInput(editor, InputMethodManager.SHOW_IMPLICIT) }        }        setContentView(LinearLayout(this).apply {            orientation = LinearLayout.VERTICAL            setPadding(24, 100, 24, 0)            addView(editor)            addView(Button(this@ExternalEditorHarnessActivity).apply {                text = "Show keyboard"                isAllCaps = false                setOnClickListener { showKeyboard() }            })        })        showKeyboard()    }}