summaryrefslogtreecommitdiffstats
path: root/src/android/jar
diff options
context:
space:
mode:
authorPiotr Mikolajczyk <piotr.mikolajczyk@qt.io>2020-12-18 10:51:30 +0100
committerVille Voutilainen <ville.voutilainen@qt.io>2021-03-05 07:57:14 +0000
commit5c6b10c3cee5737dbc041d0463220898c8120807 (patch)
treeaec06989da84711fa432899f84cd0adba9323e82 /src/android/jar
parent9fb81fc28774cd4aa01a8b29d59150e1a7de8fd8 (diff)
Android: Place cursor correctly on screen when editing
When editing text the cursor is not placed correctly. So this has been achieved by tricking Android into thinking that the input area is only the line where the cursor is, so it is forced to keep it on screen. Fixes: QTBUG-91073 Pick-to: 5.15 Change-Id: Icc2e8315deb76ca1a84819d3fdceaa7b027b1174 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'src/android/jar')
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java15
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtNative.java17
2 files changed, 27 insertions, 5 deletions
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 4cae9465ba..c473c1f78b 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java
@@ -280,7 +280,7 @@ public class QtActivityDelegate
}, 5);
}
- public void showSoftwareKeyboard(final int x, final int y, final int width, final int height, final int inputHints, final int enterKeyType)
+ public void showSoftwareKeyboard(final int x, final int y, final int width, final int height, final int editorHeight, final int inputHints, final int enterKeyType)
{
if (m_imm == null)
return;
@@ -302,7 +302,7 @@ public class QtActivityDelegate
if (softInputIsHidden)
return;
} else {
- if (height > visibleHeight)
+ if (editorHeight > visibleHeight)
m_activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
else
m_activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
@@ -419,12 +419,12 @@ public class QtActivityDelegate
if (metrics.widthPixels > metrics.heightPixels) { // landscape
if (m_landscapeKeyboardHeight != r.bottom) {
m_landscapeKeyboardHeight = r.bottom;
- showSoftwareKeyboard(x, y, width, height, inputHints, enterKeyType);
+ showSoftwareKeyboard(x, y, width, height, editorHeight, inputHints, enterKeyType);
}
} else {
if (m_portraitKeyboardHeight != r.bottom) {
m_portraitKeyboardHeight = r.bottom;
- showSoftwareKeyboard(x, y, width, height, inputHints, enterKeyType);
+ showSoftwareKeyboard(x, y, width, height, editorHeight, inputHints, enterKeyType);
}
}
} else {
@@ -575,6 +575,13 @@ public class QtActivityDelegate
}
}
+ public void updateInputItemRectangle(final int x, final int y, final int w, final int h)
+ {
+ if (m_layout == null || m_editText == null || !m_keyboardIsVisible)
+ return;
+ m_layout.setLayoutParams(m_editText, new QtLayout.LayoutParams(w, h, x, y), true);
+ }
+
public boolean loadApplication(Activity activity, ClassLoader classLoader, Bundle loaderParams)
{
/// check parameters integrity
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtNative.java b/src/android/jar/src/org/qtproject/qt/android/QtNative.java
index 001e6a7970..cb2a78b403 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtNative.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtNative.java
@@ -883,10 +883,25 @@ public class QtNative
});
}
+ private static void updateInputItemRectangle(final int x,
+ final int y,
+ final int w,
+ final int h)
+ {
+ runAction(new Runnable() {
+ @Override
+ public void run() {
+ m_activityDelegate.updateInputItemRectangle(x, y, w, h);
+ }
+ });
+ }
+
+
private static void showSoftwareKeyboard(final int x,
final int y,
final int width,
final int height,
+ final int editorHeight,
final int inputHints,
final int enterKeyType)
{
@@ -894,7 +909,7 @@ public class QtNative
@Override
public void run() {
if (m_activityDelegate != null)
- m_activityDelegate.showSoftwareKeyboard(x, y, width, height, inputHints, enterKeyType);
+ m_activityDelegate.showSoftwareKeyboard(x, y, width, height, editorHeight, inputHints, enterKeyType);
}
});
}