fix: make Android TV setup usable on Android 9

Fixes #144
This commit is contained in:
kuekhaoyang
2026-04-07 22:23:15 +08:00
parent a380ed4133
commit e93c259e4a
3 changed files with 107 additions and 81 deletions
@@ -7,6 +7,7 @@ import android.os.Bundle
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.EditorInfo
import android.webkit.WebChromeClient
import android.webkit.WebSettings
import android.webkit.WebView
@@ -59,6 +60,24 @@ class MainActivity : ComponentActivity() {
saveButton.setOnClickListener {
openConfiguredUrl()
}
urlInput.setOnEditorActionListener { _, actionId, event ->
val isKeyboardConfirmAction = actionId == EditorInfo.IME_NULL ||
actionId == EditorInfo.IME_ACTION_DONE ||
actionId == EditorInfo.IME_ACTION_GO ||
actionId == EditorInfo.IME_ACTION_SEND ||
actionId == EditorInfo.IME_ACTION_NEXT
val isEnterKey = event?.action == KeyEvent.ACTION_DOWN && (
event.keyCode == KeyEvent.KEYCODE_ENTER ||
event.keyCode == KeyEvent.KEYCODE_NUMPAD_ENTER
)
if (isKeyboardConfirmAction || isEnterKey) {
openConfiguredUrl()
true
} else {
false
}
}
webView.apply {
setLayerType(View.LAYER_TYPE_HARDWARE, null)