Android: get rid of getInputDialogState
* backported b7c470ae92
* let workaround of getInputDialogState
This commit is contained in:
parent
e21a1a6e62
commit
284a473584
@ -52,7 +52,6 @@ class GameActivity : SDLActivity() {
|
|||||||
external fun keyboardEvent(keyboard: Boolean)
|
external fun keyboardEvent(keyboard: Boolean)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var messageReturnCode = -1
|
|
||||||
private var messageReturnValue = ""
|
private var messageReturnValue = ""
|
||||||
private var hasKeyboard = false
|
private var hasKeyboard = false
|
||||||
|
|
||||||
@ -106,8 +105,8 @@ class GameActivity : SDLActivity() {
|
|||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
fun showDialog(hint: String?, current: String?, editType: Int) {
|
fun showDialog(hint: String?, current: String?, editType: Int) {
|
||||||
|
isInputActive = true
|
||||||
messageReturnValue = ""
|
messageReturnValue = ""
|
||||||
messageReturnCode = -1
|
|
||||||
if (editType == 1)
|
if (editType == 1)
|
||||||
runOnUiThread { showMultiLineDialog(hint, current) }
|
runOnUiThread { showMultiLineDialog(hint, current) }
|
||||||
else
|
else
|
||||||
@ -115,7 +114,6 @@ class GameActivity : SDLActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun showSingleDialog(hint: String?, current: String?, editType: Int) {
|
private fun showSingleDialog(hint: String?, current: String?, editType: Int) {
|
||||||
isInputActive = true
|
|
||||||
val builder = AlertDialog.Builder(this, R.style.FullScreenDialogStyle)
|
val builder = AlertDialog.Builder(this, R.style.FullScreenDialogStyle)
|
||||||
val binding = InputTextBinding.inflate(layoutInflater)
|
val binding = InputTextBinding.inflate(layoutInflater)
|
||||||
var hintText: String = hint?.ifEmpty {
|
var hintText: String = hint?.ifEmpty {
|
||||||
@ -143,7 +141,6 @@ class GameActivity : SDLActivity() {
|
|||||||
if (KeyCode == KeyEvent.KEYCODE_ENTER || KeyCode == KeyEvent.KEYCODE_ENDCALL) {
|
if (KeyCode == KeyEvent.KEYCODE_ENTER || KeyCode == KeyEvent.KEYCODE_ENDCALL) {
|
||||||
imm.hideSoftInputFromWindow(editText.windowToken, 0)
|
imm.hideSoftInputFromWindow(editText.windowToken, 0)
|
||||||
messageReturnValue = editText.text.toString()
|
messageReturnValue = editText.text.toString()
|
||||||
messageReturnCode = 0
|
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
isInputActive = false
|
isInputActive = false
|
||||||
return@setOnEditorActionListener true
|
return@setOnEditorActionListener true
|
||||||
@ -155,7 +152,6 @@ class GameActivity : SDLActivity() {
|
|||||||
if (KeyCode == KeyEvent.KEYCODE_ENTER || KeyCode == KeyEvent.KEYCODE_ENDCALL) {
|
if (KeyCode == KeyEvent.KEYCODE_ENTER || KeyCode == KeyEvent.KEYCODE_ENDCALL) {
|
||||||
imm.hideSoftInputFromWindow(editText.windowToken, 0)
|
imm.hideSoftInputFromWindow(editText.windowToken, 0)
|
||||||
messageReturnValue = editText.text.toString()
|
messageReturnValue = editText.text.toString()
|
||||||
messageReturnCode = 0
|
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
isInputActive = false
|
isInputActive = false
|
||||||
return@setOnKeyListener true
|
return@setOnKeyListener true
|
||||||
@ -165,14 +161,12 @@ class GameActivity : SDLActivity() {
|
|||||||
binding.input.setEndIconOnClickListener {
|
binding.input.setEndIconOnClickListener {
|
||||||
imm.hideSoftInputFromWindow(editText.windowToken, 0)
|
imm.hideSoftInputFromWindow(editText.windowToken, 0)
|
||||||
messageReturnValue = editText.text.toString()
|
messageReturnValue = editText.text.toString()
|
||||||
messageReturnCode = 0
|
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
isInputActive = false
|
isInputActive = false
|
||||||
}
|
}
|
||||||
binding.rl.setOnClickListener {
|
binding.rl.setOnClickListener {
|
||||||
window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN)
|
window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN)
|
||||||
messageReturnValue = current.toString()
|
messageReturnValue = current.toString()
|
||||||
messageReturnCode = 0
|
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
isInputActive = false
|
isInputActive = false
|
||||||
}
|
}
|
||||||
@ -185,13 +179,11 @@ class GameActivity : SDLActivity() {
|
|||||||
alertDialog.setOnCancelListener {
|
alertDialog.setOnCancelListener {
|
||||||
window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN)
|
window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN)
|
||||||
messageReturnValue = current.toString()
|
messageReturnValue = current.toString()
|
||||||
messageReturnCode = 0
|
|
||||||
isInputActive = false
|
isInputActive = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showMultiLineDialog(hint: String?, current: String?) {
|
private fun showMultiLineDialog(hint: String?, current: String?) {
|
||||||
isInputActive = true
|
|
||||||
val builder = AlertDialog.Builder(this, R.style.FullScreenDialogStyle)
|
val builder = AlertDialog.Builder(this, R.style.FullScreenDialogStyle)
|
||||||
val binding = MultilineInputBinding.inflate(layoutInflater)
|
val binding = MultilineInputBinding.inflate(layoutInflater)
|
||||||
var hintText: String = hint?.ifEmpty {
|
var hintText: String = hint?.ifEmpty {
|
||||||
@ -212,7 +204,6 @@ class GameActivity : SDLActivity() {
|
|||||||
if (KeyCode == KeyEvent.KEYCODE_ENTER || KeyCode == KeyEvent.KEYCODE_ENDCALL) {
|
if (KeyCode == KeyEvent.KEYCODE_ENTER || KeyCode == KeyEvent.KEYCODE_ENDCALL) {
|
||||||
imm.hideSoftInputFromWindow(editText.windowToken, 0)
|
imm.hideSoftInputFromWindow(editText.windowToken, 0)
|
||||||
messageReturnValue = editText.text.toString()
|
messageReturnValue = editText.text.toString()
|
||||||
messageReturnCode = 0
|
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
isInputActive = false
|
isInputActive = false
|
||||||
return@setOnEditorActionListener true
|
return@setOnEditorActionListener true
|
||||||
@ -224,7 +215,6 @@ class GameActivity : SDLActivity() {
|
|||||||
if (KeyCode == KeyEvent.KEYCODE_ENTER || KeyCode == KeyEvent.KEYCODE_ENDCALL) {
|
if (KeyCode == KeyEvent.KEYCODE_ENTER || KeyCode == KeyEvent.KEYCODE_ENDCALL) {
|
||||||
imm.hideSoftInputFromWindow(editText.windowToken, 0)
|
imm.hideSoftInputFromWindow(editText.windowToken, 0)
|
||||||
messageReturnValue = editText.text.toString()
|
messageReturnValue = editText.text.toString()
|
||||||
messageReturnCode = 0
|
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
isInputActive = false
|
isInputActive = false
|
||||||
return@setOnKeyListener true
|
return@setOnKeyListener true
|
||||||
@ -234,14 +224,12 @@ class GameActivity : SDLActivity() {
|
|||||||
binding.multiInput.setEndIconOnClickListener {
|
binding.multiInput.setEndIconOnClickListener {
|
||||||
imm.hideSoftInputFromWindow(editText.windowToken, 0)
|
imm.hideSoftInputFromWindow(editText.windowToken, 0)
|
||||||
messageReturnValue = editText.text.toString()
|
messageReturnValue = editText.text.toString()
|
||||||
messageReturnCode = 0
|
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
isInputActive = false
|
isInputActive = false
|
||||||
}
|
}
|
||||||
binding.multiRl.setOnClickListener {
|
binding.multiRl.setOnClickListener {
|
||||||
window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN)
|
window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN)
|
||||||
messageReturnValue = current.toString()
|
messageReturnValue = current.toString()
|
||||||
messageReturnCode = -1
|
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
isInputActive = false
|
isInputActive = false
|
||||||
}
|
}
|
||||||
@ -254,7 +242,6 @@ class GameActivity : SDLActivity() {
|
|||||||
alertDialog.setOnCancelListener {
|
alertDialog.setOnCancelListener {
|
||||||
window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN)
|
window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN)
|
||||||
messageReturnValue = current.toString()
|
messageReturnValue = current.toString()
|
||||||
messageReturnCode = -1
|
|
||||||
isInputActive = false
|
isInputActive = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,13 +249,11 @@ class GameActivity : SDLActivity() {
|
|||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
fun isDialogActive() = isInputActive
|
fun isDialogActive() = isInputActive
|
||||||
|
|
||||||
@Suppress("unused")
|
|
||||||
fun getDialogState() = messageReturnCode
|
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
fun getDialogValue(): String {
|
fun getDialogValue(): String {
|
||||||
messageReturnCode = -1
|
val value = messageReturnValue
|
||||||
return messageReturnValue
|
messageReturnValue = ""
|
||||||
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
|
@ -2166,7 +2166,7 @@ void Game::openConsole(float scale, const wchar_t *line)
|
|||||||
void Game::handleTouchChatInput()
|
void Game::handleTouchChatInput()
|
||||||
{
|
{
|
||||||
if (porting::getInputDialogOwner() == "chat" &&
|
if (porting::getInputDialogOwner() == "chat" &&
|
||||||
porting::getInputDialogState() == 0) {
|
!porting::isInputDialogActive()) {
|
||||||
std::string text = porting::getInputDialogValue();
|
std::string text = porting::getInputDialogValue();
|
||||||
client->typeChatMessage(utf8_to_wide(text));
|
client->typeChatMessage(utf8_to_wide(text));
|
||||||
if (!text.empty() && gui_chat_console->isOpen()) {
|
if (!text.empty() && gui_chat_console->isOpen()) {
|
||||||
|
@ -317,7 +317,7 @@ bool GUIConfirmRegistration::getTouchUIInput()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// still waiting
|
// still waiting
|
||||||
if (porting::getInputDialogState() == -1)
|
if (porting::isInputDialogActive())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
m_jni_field_name.clear();
|
m_jni_field_name.clear();
|
||||||
|
@ -3611,7 +3611,7 @@ bool GUIFormSpecMenu::getTouchUIInput()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// still waiting
|
// still waiting
|
||||||
if (porting::getInputDialogState() == -1)
|
if (porting::isInputDialogActive())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
std::string fieldname = m_jni_field_name;
|
std::string fieldname = m_jni_field_name;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
Minetest
|
Minetest
|
||||||
Copyright (C) 2014 celeron55, Perttu Ahola <celeron55@gmail.com>
|
Copyright (C) 2014 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||||
Copyright (C) 2014-2022 Maksim Gamarnik [MoNTE48] <Maksym48@pm.me>
|
Copyright (C) 2014-2023 Maksim Gamarnik [MoNTE48] <Maksym48@pm.me>
|
||||||
Copyright (C) 2022 Dawid Gan <deveee@gmail.com>
|
Copyright (C) 2023 Dawid Gan <deveee@gmail.com>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
Minetest
|
Minetest
|
||||||
Copyright (C) 2014 celeron55, Perttu Ahola <celeron55@gmail.com>
|
Copyright (C) 2014 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||||
Copyright (C) 2014-2022 Maksim Gamarnik [MoNTE48] <Maksym48@pm.me>
|
Copyright (C) 2014-2023 Maksim Gamarnik [MoNTE48] <Maksym48@pm.me>
|
||||||
Copyright (C) 2022 Dawid Gan <deveee@gmail.com>
|
Copyright (C) 2023 Dawid Gan <deveee@gmail.com>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
@ -68,7 +68,6 @@ void openURIAndroid(const std::string &url);
|
|||||||
int getInputDialogState();
|
int getInputDialogState();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WORKAROUND for not working callbacks from java -> c++
|
|
||||||
* get text in current input dialog
|
* get text in current input dialog
|
||||||
*/
|
*/
|
||||||
std::string getInputDialogValue();
|
std::string getInputDialogValue();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user