You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Merge pull request #41550 from godotengine/revert-40671-virtual-keyboard-height-fix
Revert "Fix virtual keyboard height regression"
This commit is contained in:
@@ -70,7 +70,6 @@ import android.os.VibrationEffect;
|
|||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.provider.Settings.Secure;
|
import android.provider.Settings.Secure;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
@@ -83,7 +82,6 @@ import android.view.Window;
|
|||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.PopupWindow;
|
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@@ -165,8 +163,6 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
|
|||||||
public GodotRenderView mRenderView;
|
public GodotRenderView mRenderView;
|
||||||
private boolean godot_initialized = false;
|
private boolean godot_initialized = false;
|
||||||
|
|
||||||
private PopupWindow mKeyboardWindow;
|
|
||||||
|
|
||||||
private SensorManager mSensorManager;
|
private SensorManager mSensorManager;
|
||||||
private Sensor mAccelerometer;
|
private Sensor mAccelerometer;
|
||||||
private Sensor mGravity;
|
private Sensor mGravity;
|
||||||
@@ -223,23 +219,11 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
|
|||||||
containerLayout = new FrameLayout(activity);
|
containerLayout = new FrameLayout(activity);
|
||||||
containerLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
containerLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
||||||
|
|
||||||
// Create a popup window with an invisible layout for the virtual keyboard,
|
|
||||||
// so the view can be resized to get the vk height without resizing the main godot view.
|
|
||||||
final FrameLayout keyboardLayout = new FrameLayout(activity);
|
|
||||||
keyboardLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
|
||||||
keyboardLayout.setVisibility(View.INVISIBLE);
|
|
||||||
mKeyboardWindow = new PopupWindow(keyboardLayout, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
|
||||||
mKeyboardWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
|
||||||
mKeyboardWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
|
|
||||||
mKeyboardWindow.setFocusable(true); // for the text edit to work
|
|
||||||
mKeyboardWindow.setTouchable(false); // inputs need to go through
|
|
||||||
|
|
||||||
// GodotEditText layout
|
// GodotEditText layout
|
||||||
GodotEditText editText = new GodotEditText(activity);
|
GodotEditText editText = new GodotEditText(activity);
|
||||||
editText.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
|
editText.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
|
||||||
editText.setKeyboardView(keyboardLayout);
|
// ...add to FrameLayout
|
||||||
// ...add to keyboard layout
|
containerLayout.addView(editText);
|
||||||
keyboardLayout.addView(editText);
|
|
||||||
|
|
||||||
GodotLib.setup(command_line);
|
GodotLib.setup(command_line);
|
||||||
|
|
||||||
@@ -256,13 +240,13 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
|
|||||||
editText.setView(mRenderView);
|
editText.setView(mRenderView);
|
||||||
io.setEdit(editText);
|
io.setEdit(editText);
|
||||||
|
|
||||||
keyboardLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onGlobalLayout() {
|
public void onGlobalLayout() {
|
||||||
Point fullSize = new Point();
|
Point fullSize = new Point();
|
||||||
activity.getWindowManager().getDefaultDisplay().getSize(fullSize);
|
activity.getWindowManager().getDefaultDisplay().getSize(fullSize);
|
||||||
Rect gameSize = new Rect();
|
Rect gameSize = new Rect();
|
||||||
mKeyboardWindow.getContentView().getWindowVisibleDisplayFrame(gameSize);
|
mRenderView.getView().getWindowVisibleDisplayFrame(gameSize);
|
||||||
|
|
||||||
final int keyboardHeight = fullSize.y - gameSize.bottom;
|
final int keyboardHeight = fullSize.y - gameSize.bottom;
|
||||||
GodotLib.setVirtualKeyboardHeight(keyboardHeight);
|
GodotLib.setVirtualKeyboardHeight(keyboardHeight);
|
||||||
@@ -618,22 +602,8 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
|
|||||||
return containerLayout;
|
return containerLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
|
|
||||||
mRenderView.getView().post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
mKeyboardWindow.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.NO_GRAVITY, 0, 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
mKeyboardWindow.dismiss();
|
|
||||||
|
|
||||||
for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) {
|
for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) {
|
||||||
plugin.onMainDestroy();
|
plugin.onMainDestroy();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import android.text.InputFilter;
|
|||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@@ -57,7 +56,6 @@ public class GodotEditText extends EditText {
|
|||||||
// Fields
|
// Fields
|
||||||
// ===========================================================
|
// ===========================================================
|
||||||
private GodotRenderView mRenderView;
|
private GodotRenderView mRenderView;
|
||||||
private View mKeyboardView;
|
|
||||||
private GodotTextInputWrapper mInputWrapper;
|
private GodotTextInputWrapper mInputWrapper;
|
||||||
private EditHandler sHandler = new EditHandler(this);
|
private EditHandler sHandler = new EditHandler(this);
|
||||||
private String mOriginText;
|
private String mOriginText;
|
||||||
@@ -131,7 +129,7 @@ public class GodotEditText extends EditText {
|
|||||||
|
|
||||||
edit.mInputWrapper.setOriginText(text);
|
edit.mInputWrapper.setOriginText(text);
|
||||||
edit.addTextChangedListener(edit.mInputWrapper);
|
edit.addTextChangedListener(edit.mInputWrapper);
|
||||||
final InputMethodManager imm = (InputMethodManager)mKeyboardView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
final InputMethodManager imm = (InputMethodManager)mRenderView.getView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
imm.showSoftInput(edit, 0);
|
imm.showSoftInput(edit, 0);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@@ -140,7 +138,7 @@ public class GodotEditText extends EditText {
|
|||||||
GodotEditText edit = (GodotEditText)msg.obj;
|
GodotEditText edit = (GodotEditText)msg.obj;
|
||||||
|
|
||||||
edit.removeTextChangedListener(mInputWrapper);
|
edit.removeTextChangedListener(mInputWrapper);
|
||||||
final InputMethodManager imm = (InputMethodManager)mKeyboardView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
final InputMethodManager imm = (InputMethodManager)mRenderView.getView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
imm.hideSoftInputFromWindow(edit.getWindowToken(), 0);
|
imm.hideSoftInputFromWindow(edit.getWindowToken(), 0);
|
||||||
edit.mRenderView.getView().requestFocus();
|
edit.mRenderView.getView().requestFocus();
|
||||||
} break;
|
} break;
|
||||||
@@ -164,10 +162,6 @@ public class GodotEditText extends EditText {
|
|||||||
view.getView().requestFocus();
|
view.getView().requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeyboardView(final View keyboardView) {
|
|
||||||
mKeyboardView = keyboardView;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================================================
|
// ===========================================================
|
||||||
// Methods for/from SuperClass/Interfaces
|
// Methods for/from SuperClass/Interfaces
|
||||||
// ===========================================================
|
// ===========================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user