mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-21 16:32:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccd62302ad | ||
|
|
2679eed629 |
No files matched your search
@@ -54,6 +54,7 @@ object GamePackageUtils {
|
||||
40L to "2.2074", // ok
|
||||
41L to "2.2081",
|
||||
42L to "2.209",
|
||||
43L to "2.2091",
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.cocos2dx.lib
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.hardware.input.InputManager
|
||||
import android.opengl.GLSurfaceView
|
||||
import android.os.Build
|
||||
@@ -43,19 +44,6 @@ fun inputTypeForFlags(i: Int): Int {
|
||||
return InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS or InputType.TYPE_CLASS_TEXT
|
||||
}
|
||||
|
||||
fun usesInlineKeyboard(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= 30
|
||||
}
|
||||
|
||||
fun imeOptionsForFlags(i: Int): Int {
|
||||
val i2 = if ((i and BaseRobTopActivity.KEYBOARD_INPUT_MULTILINE) == 0 || !usesInlineKeyboard())
|
||||
EditorInfo.IME_ACTION_DONE else EditorInfo.IME_ACTION_NONE
|
||||
|
||||
return if (usesInlineKeyboard())
|
||||
EditorInfo.IME_FLAG_NO_FULLSCREEN or EditorInfo.IME_FLAG_NO_EXTRACT_UI or i2
|
||||
else i2
|
||||
}
|
||||
|
||||
class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
companion object {
|
||||
lateinit var cocos2dxGLSurfaceView: Cocos2dxGLSurfaceView
|
||||
@@ -65,11 +53,25 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
private var keyboardVisible = false
|
||||
private var keyboardHeight = 0
|
||||
|
||||
private var textInputActive = false
|
||||
|
||||
private fun hasHardwareKeyboard(): Boolean {
|
||||
val config = cocos2dxGLSurfaceView.resources.configuration
|
||||
return config.keyboard != Configuration.KEYBOARD_NOKEYS
|
||||
&& config.hardKeyboardHidden != Configuration.HARDKEYBOARDHIDDEN_YES
|
||||
}
|
||||
|
||||
private var keyboardHideCheck = Runnable {
|
||||
if (keyboardVisible) {
|
||||
return@Runnable
|
||||
}
|
||||
|
||||
// fix for a silly 2.209 bug where the visible check forgets about the existence
|
||||
// of keyboards that aren't visible (hardware keyboards)
|
||||
if (textInputActive && hasHardwareKeyboard()) {
|
||||
return@Runnable
|
||||
}
|
||||
|
||||
cocos2dxGLSurfaceView.queueEvent {
|
||||
cocos2dxGLSurfaceView.cocos2dxRenderer.handleTextClosed()
|
||||
}
|
||||
@@ -144,6 +146,21 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
requestFocus()
|
||||
}
|
||||
|
||||
fun usesInlineKeyboard(): Boolean {
|
||||
if (!sendNewCocosEvents) return false
|
||||
|
||||
return Build.VERSION.SDK_INT >= 30
|
||||
}
|
||||
|
||||
fun imeOptionsForFlags(i: Int): Int {
|
||||
val i2 = if ((i and BaseRobTopActivity.KEYBOARD_INPUT_MULTILINE) == 0 || !usesInlineKeyboard())
|
||||
EditorInfo.IME_ACTION_DONE else EditorInfo.IME_ACTION_NONE
|
||||
|
||||
return if (usesInlineKeyboard())
|
||||
EditorInfo.IME_FLAG_NO_FULLSCREEN or EditorInfo.IME_FLAG_NO_EXTRACT_UI or i2
|
||||
else i2
|
||||
}
|
||||
|
||||
fun initView() {
|
||||
setEGLContextClientVersion(2)
|
||||
isFocusableInTouchMode = true
|
||||
@@ -171,6 +188,8 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
cocos2dxTextInputWrapper
|
||||
)
|
||||
}
|
||||
|
||||
textInputActive = true
|
||||
(context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager).showSoftInput(
|
||||
cocos2dxEditText,
|
||||
0
|
||||
@@ -180,6 +199,7 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
return
|
||||
}
|
||||
HANDLER_CLOSE_IME_KEYBOARD -> {
|
||||
textInputActive = false
|
||||
cocos2dxEditText?.apply {
|
||||
removeTextChangedListener(cocos2dxTextInputWrapper)
|
||||
(context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager).hideSoftInputFromWindow(
|
||||
|
||||
@@ -14,15 +14,21 @@ class Cocos2dxTextInputWrapper(private val cocos2dxGLSurfaceView: Cocos2dxGLSurf
|
||||
private var originText: String? = null
|
||||
private var text: String? = null
|
||||
|
||||
private val isFullScreenEdit: Boolean
|
||||
get() = (cocos2dxGLSurfaceView.cocos2dxEditText?.context?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager).isFullscreenMode
|
||||
private fun isFullScreenEdit(): Boolean {
|
||||
if (cocos2dxGLSurfaceView.usesInlineKeyboard()) {
|
||||
return false
|
||||
}
|
||||
|
||||
val inputMethodManager = cocos2dxGLSurfaceView.cocos2dxEditText?.context?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
return inputMethodManager.isFullscreenMode
|
||||
}
|
||||
|
||||
fun setOriginText(originText: String?) {
|
||||
this.originText = originText
|
||||
}
|
||||
|
||||
override fun afterTextChanged(editable: Editable) {
|
||||
if (isFullScreenEdit) {
|
||||
if (isFullScreenEdit()) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -61,7 +67,7 @@ class Cocos2dxTextInputWrapper(private val cocos2dxGLSurfaceView: Cocos2dxGLSurf
|
||||
|
||||
override fun onTextChanged(pCharSequence: CharSequence, start: Int, before: Int, count: Int) {}
|
||||
override fun onEditorAction(textView: TextView, actionID: Int, keyEvent: KeyEvent?): Boolean {
|
||||
val fullscreenIme = cocos2dxGLSurfaceView.cocos2dxEditText == textView && isFullScreenEdit
|
||||
val fullscreenIme = cocos2dxGLSurfaceView.cocos2dxEditText == textView && isFullScreenEdit()
|
||||
if (fullscreenIme) {
|
||||
var text = textView.text.toString()
|
||||
if (originText != text || !cocos2dxGLSurfaceView.sendNewCocosEvents) {
|
||||
|
||||
Reference in new issue
Block a user