diff options
author | Tinja Paavoseppä <[email protected]> | 2024-07-26 12:04:27 +0300 |
---|---|---|
committer | Tinja Paavoseppä <[email protected]> | 2024-08-23 12:40:53 +0300 |
commit | 9ed29c73674939c772cc6b407881935e7fa19bcd (patch) | |
tree | e7964fe0320d0153f7d07021736c6200ee32fc40 /src | |
parent | 9e167af3f6a4b2ac192aedd83f5066808d719415 (diff) |
Android: Remove getQtLayout() method
After refactoring the various keyboard input
related Java classes so that they are more contained
inside their respective windows, this method becomes
unnecessary.
Task-number: QTBUG-126180
Pick-to: 6.8
Change-Id: I608399e98892752182039b8ece60005670da8224
Reviewed-by: Assam Boudjelthia <[email protected]>
Diffstat (limited to 'src')
7 files changed, 17 insertions, 52 deletions
diff --git a/src/android/jar/CMakeLists.txt b/src/android/jar/CMakeLists.txt index 98240fabefc..4966cac4abf 100644 --- a/src/android/jar/CMakeLists.txt +++ b/src/android/jar/CMakeLists.txt @@ -44,7 +44,6 @@ set(java_sources src/org/qtproject/qt/android/QtWindowInterface.java src/org/qtproject/qt/android/QtAccessibilityInterface.java src/org/qtproject/qt/android/QtMenuInterface.java - src/org/qtproject/qt/android/QtLayoutInterface.java src/org/qtproject/qt/android/QtInputInterface.java src/org/qtproject/qt/android/QtAbstractItemModel.java src/org/qtproject/qt/android/QtAbstractItemModelProxy.java diff --git a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java index bdcde4be4f6..7491dc5c90d 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java @@ -31,7 +31,7 @@ import android.widget.PopupMenu; import java.util.HashMap; class QtActivityDelegate extends QtActivityDelegateBase - implements QtWindowInterface, QtAccessibilityInterface, QtMenuInterface, QtLayoutInterface + implements QtWindowInterface, QtAccessibilityInterface, QtMenuInterface { private static final String QtTAG = "QtActivityDelegate"; @@ -62,8 +62,6 @@ class QtActivityDelegate extends QtActivityDelegateBase (QtAccessibilityInterface)QtActivityDelegate.this); BackendRegister.registerBackend(QtMenuInterface.class, (QtMenuInterface)QtActivityDelegate.this); - BackendRegister.registerBackend(QtLayoutInterface.class, - (QtLayoutInterface)QtActivityDelegate.this); BackendRegister.registerBackend(QtInputInterface.class, (QtInputInterface)m_inputDelegate); } @@ -76,18 +74,11 @@ class QtActivityDelegate extends QtActivityDelegateBase BackendRegister.unregisterBackend(QtWindowInterface.class); BackendRegister.unregisterBackend(QtAccessibilityInterface.class); BackendRegister.unregisterBackend(QtMenuInterface.class); - BackendRegister.unregisterBackend(QtLayoutInterface.class); BackendRegister.unregisterBackend(QtInputInterface.class); } } @Override - public QtLayout getQtLayout() - { - return m_layout; - } - - @Override public void setSystemUiVisibility(int systemUiVisibility) { QtNative.runAction(() -> { diff --git a/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedDelegate.java b/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedDelegate.java index 4b91f96483a..3da520c31b3 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedDelegate.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtEmbeddedDelegate.java @@ -25,7 +25,7 @@ import java.util.HashMap; class QtEmbeddedDelegate extends QtActivityDelegateBase implements QtNative.AppStateDetailsListener, QtEmbeddedViewInterface, QtWindowInterface, - QtMenuInterface, QtLayoutInterface + QtMenuInterface { private static final String QtTAG = "QtEmbeddedDelegate"; // TODO simplistic implementation with one QtView, expand to support multiple views QTBUG-117649 @@ -98,13 +98,11 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase m_backendsRegistered = true; BackendRegister.registerBackend(QtWindowInterface.class, (QtWindowInterface)this); BackendRegister.registerBackend(QtMenuInterface.class, (QtMenuInterface)this); - BackendRegister.registerBackend(QtLayoutInterface.class, (QtLayoutInterface)this); BackendRegister.registerBackend(QtInputInterface.class, m_inputDelegate); } else if (!details.isStarted && m_backendsRegistered) { m_backendsRegistered = false; BackendRegister.unregisterBackend(QtWindowInterface.class); BackendRegister.unregisterBackend(QtMenuInterface.class); - BackendRegister.unregisterBackend(QtLayoutInterface.class); BackendRegister.unregisterBackend(QtInputInterface.class); } } @@ -132,17 +130,6 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase QtNative.startApplication(appParams, mainLib); } - @Override - public QtLayout getQtLayout() - { - // TODO verify if returning m_view here works, this is used by the androidjniinput - // when e.g. showing a keyboard, so depends on getting the keyboard focus working - // QTBUG-118873 - if (m_view == null) - return null; - return m_view.getQtWindow(); - } - // QtEmbeddedViewInterface implementation begin @Override public void startQtApplication(String appParams, String mainLib) @@ -187,14 +174,12 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase @Override public void openContextMenu(final int x, final int y, final int w, final int h) { - QtLayout layout = getQtLayout(); - layout.postDelayed(() -> { + m_view.postDelayed(() -> { final QtEditText focusedEditText = m_inputDelegate.getCurrentQtEditText(); if (focusedEditText == null) { Log.w(QtTAG, "No focused view when trying to open context menu"); return; } - layout.setLayoutParams(focusedEditText, new QtLayout.LayoutParams(w, h, x, y), false); PopupMenu popup = new PopupMenu(m_activity, focusedEditText); QtNative.fillContextMenu(popup.getMenu()); popup.setOnMenuItemClickListener(menuItem -> diff --git a/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java b/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java index 6d0f690144b..3075d49ee03 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtInputDelegate.java @@ -11,6 +11,7 @@ import android.os.Handler; import android.os.ResultReceiver; import android.text.method.MetaKeyKeyListener; import android.util.DisplayMetrics; +import android.util.Log; import android.view.InputDevice; import android.view.KeyCharacterMap; import android.view.KeyEvent; @@ -24,6 +25,7 @@ import org.qtproject.qt.android.QtInputConnection.QtInputConnectionListener; class QtInputDelegate implements QtInputConnection.QtInputConnectionListener, QtInputInterface { + private static final String TAG = "QtInputDelegate"; // keyboard methods static native void keyDown(int key, int unicode, int modifier, boolean autoRepeat); static native void keyUp(int key, int unicode, int modifier, boolean autoRepeat); @@ -90,7 +92,7 @@ class QtInputDelegate implements QtInputConnection.QtInputConnectionListener, Qt } @Override - public void showSoftwareKeyboard(Activity activity, QtLayout layout, + public void showSoftwareKeyboard(Activity activity, final int x, final int y, final int width, final int height, final int inputHints, final int enterKeyType) { @@ -115,7 +117,7 @@ class QtInputDelegate implements QtInputConnection.QtInputConnectionListener, Qt case InputMethodManager.RESULT_UNCHANGED_SHOWN: setKeyboardVisibility(true, System.nanoTime()); if (m_softInputMode == 0) { - probeForKeyboardHeight(layout, activity, + probeForKeyboardHeight(activity, x, y, width, height, inputHints, enterKeyType); } break; @@ -307,10 +309,14 @@ class QtInputDelegate implements QtInputConnection.QtInputConnectionListener, Qt return false; } - private void probeForKeyboardHeight(QtLayout layout, Activity activity, int x, int y, + private void probeForKeyboardHeight(Activity activity, int x, int y, int width, int height, int inputHints, int enterKeyType) { - layout.postDelayed(() -> { + if (m_currentEditText == null) { + Log.w(TAG, "probeForKeyboardHeight: null QtEditText"); + return; + } + m_currentEditText.postDelayed(() -> { if (!m_keyboardIsVisible) return; DisplayMetrics metrics = new DisplayMetrics(); @@ -321,13 +327,13 @@ class QtInputDelegate implements QtInputConnection.QtInputConnectionListener, Qt if (metrics.widthPixels > metrics.heightPixels) { // landscape if (m_landscapeKeyboardHeight != r.bottom) { m_landscapeKeyboardHeight = r.bottom; - showSoftwareKeyboard(activity, layout, x, y, width, height, + showSoftwareKeyboard(activity, x, y, width, height, inputHints, enterKeyType); } } else { if (m_portraitKeyboardHeight != r.bottom) { m_portraitKeyboardHeight = r.bottom; - showSoftwareKeyboard(activity, layout, x, y, width, height, + showSoftwareKeyboard(activity, x, y, width, height, inputHints, enterKeyType); } } diff --git a/src/android/jar/src/org/qtproject/qt/android/QtInputInterface.java b/src/android/jar/src/org/qtproject/qt/android/QtInputInterface.java index 681ca1f7b61..afe57e51e77 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtInputInterface.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtInputInterface.java @@ -8,7 +8,7 @@ import android.app.Activity; interface QtInputInterface { void updateSelection(final int selStart, final int selEnd, final int candidatesStart, final int candidatesEnd); - void showSoftwareKeyboard(Activity activity, QtLayout layout, final int x, final int y, + void showSoftwareKeyboard(Activity activity, final int x, final int y, final int width, final int height, final int inputHints, final int enterKeyType); void resetSoftwareKeyboard(); diff --git a/src/android/jar/src/org/qtproject/qt/android/QtLayoutInterface.java b/src/android/jar/src/org/qtproject/qt/android/QtLayoutInterface.java deleted file mode 100644 index 8444266893e..00000000000 --- a/src/android/jar/src/org/qtproject/qt/android/QtLayoutInterface.java +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (C) 2024 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -package org.qtproject.qt.android; - -@UsedFromNativeCode -interface QtLayoutInterface { - QtLayout getQtLayout(); -} diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index 2d832a0209e..a0faedcc5b2 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -23,8 +23,6 @@ Q_LOGGING_CATEGORY(lcQpaInputMethods, "qt.qpa.input.methods"); using namespace QtAndroid; -Q_DECLARE_JNI_CLASS(QtLayout, "org/qtproject/qt/android/QtLayout") -Q_DECLARE_JNI_CLASS(QtLayoutInterface, "org/qtproject/qt/android/QtLayoutInterface") Q_DECLARE_JNI_CLASS(QtInputInterface, "org/qtproject/qt/android/QtInputInterface") namespace QtAndroidInput @@ -38,12 +36,6 @@ namespace QtAndroidInput static QPointer<QWindow> m_mouseGrabber; - QJniObject qtLayout() - { - AndroidBackendRegister *reg = QtAndroid::backendRegister(); - return reg->callInterface<QtJniTypes::QtLayoutInterface, QtJniTypes::QtLayout>( - "getQtLayout"); - } void updateSelection(int selStart, int selEnd, int candidatesStart, int candidatesEnd) { @@ -58,7 +50,7 @@ namespace QtAndroidInput AndroidBackendRegister *reg = QtAndroid::backendRegister(); reg->callInterface<QtJniTypes::QtInputInterface, void>( "showSoftwareKeyboard", QtAndroidPrivate::activity(), - qtLayout().object<QtJniTypes::QtLayout>(), left, top, width, height, inputHints, + left, top, width, height, inputHints, enterKeyType); qCDebug(lcQpaInputMethods) << "@@@ SHOWSOFTWAREKEYBOARD" << left << top << width << height << inputHints << enterKeyType; } |