forked from geode-sdk/android-launcher
some text input changes
This commit is contained in:
4 files changed
+16
-32
No files matched your search
@@ -14,9 +14,10 @@ import android.util.Log
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.widget.FrameLayout
|
||||
import android.window.OnBackInvokedDispatcher
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.AppCompatEditText
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
@@ -32,7 +33,6 @@ import com.geode.launcher.utils.GamePackageUtils
|
||||
import com.geode.launcher.utils.GeodeUtils
|
||||
import com.geode.launcher.utils.LaunchUtils
|
||||
import com.geode.launcher.utils.PreferenceUtils
|
||||
import org.cocos2dx.lib.Cocos2dxEditText
|
||||
import org.cocos2dx.lib.Cocos2dxGLSurfaceView
|
||||
import org.cocos2dx.lib.Cocos2dxHelper
|
||||
import org.cocos2dx.lib.Cocos2dxRenderer
|
||||
@@ -123,12 +123,12 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
||||
return
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
onBackInvokedDispatcher.registerOnBackInvokedCallback(OnBackInvokedDispatcher.PRIORITY_DEFAULT) {
|
||||
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
mGLSurfaceView?.sendKeyBack()
|
||||
}
|
||||
mGLSurfaceView?.manualBackEvents = true
|
||||
}
|
||||
})
|
||||
mGLSurfaceView?.manualBackEvents = true
|
||||
}
|
||||
|
||||
private fun createVersionFile() {
|
||||
@@ -406,7 +406,7 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
val editText = Cocos2dxEditText(this)
|
||||
val editText = AppCompatEditText(this)
|
||||
editText.layoutParams = editTextLayoutParams
|
||||
frameLayout.addView(editText)
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.cocos2dx.lib
|
||||
|
||||
import android.content.Context
|
||||
import android.view.KeyEvent
|
||||
import androidx.appcompat.widget.AppCompatEditText
|
||||
|
||||
class Cocos2dxEditText(context: Context) : AppCompatEditText(context) {
|
||||
var cocos2dxGLSurfaceView: Cocos2dxGLSurfaceView? = null
|
||||
|
||||
override fun onKeyDown(keyCode: Int, keyEvent: KeyEvent): Boolean {
|
||||
super.onKeyDown(keyCode, keyEvent)
|
||||
if (keyCode != KeyEvent.KEYCODE_BACK) {
|
||||
return true
|
||||
}
|
||||
cocos2dxGLSurfaceView?.requestFocus()
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import android.view.MotionEvent
|
||||
import android.view.Surface
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.widget.AppCompatEditText
|
||||
import com.customRobTop.BaseRobTopActivity
|
||||
import com.geode.launcher.utils.GeodeUtils
|
||||
|
||||
@@ -57,12 +58,11 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
var sendTimestampEvents = false
|
||||
var manualBackEvents = false
|
||||
|
||||
var cocos2dxEditText: Cocos2dxEditText? = null
|
||||
var cocos2dxEditText: AppCompatEditText? = null
|
||||
set(value) {
|
||||
field = value
|
||||
|
||||
field?.setOnEditorActionListener(cocos2dxTextInputWrapper)
|
||||
field?.cocos2dxGLSurfaceView = this
|
||||
requestFocus()
|
||||
}
|
||||
|
||||
@@ -261,6 +261,10 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
}
|
||||
|
||||
fun sendKeyBack() {
|
||||
if (cocos2dxEditText?.isFocused == true) {
|
||||
requestFocus()
|
||||
}
|
||||
|
||||
if (BaseRobTopActivity.blockBackButton) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -52,12 +52,10 @@ class Cocos2dxTextInputWrapper(private val cocos2dxGLSurfaceView: Cocos2dxGLSurf
|
||||
cocos2dxGLSurfaceView.deleteBackward()
|
||||
}
|
||||
var text = textView.text.toString()
|
||||
if (text.compareTo("") == 0) {
|
||||
text = "\n"
|
||||
}
|
||||
if (10 != text[text.length - 1].code) {
|
||||
text += 10.toChar()
|
||||
if (!text.endsWith('\n')) {
|
||||
text += '\n'
|
||||
}
|
||||
|
||||
cocos2dxGLSurfaceView.insertText(text)
|
||||
}
|
||||
if (actionID != 6) {
|
||||
|
||||
Reference in new issue
Block a user