summaryrefslogtreecommitdiffstats
path: root/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2016-08-04 15:46:20 +0200
committerOlivier Goffart (Woboq GmbH) <ogoffart@woboq.com>2016-08-18 13:23:26 +0000
commit3c6220c4f8893b58af5e68ffaeff5951efe1f331 (patch)
tree31cf3b462e5c45f888a1646d12e3a818b71801bf /src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
parentbc2cee35c3034b4428dd72a1c228aecba0a6b280 (diff)
Android selection handles
This commits implement the cursor and selection handle in the platform plugin. Task-number: QTBUG-34867 Change-Id: Icb3fd9ddfd9f4152e2004078a92a3d9502e9113c Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Diffstat (limited to 'src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java')
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
index 656dbdda45..55de75e991 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
@@ -2,6 +2,7 @@
**
** Copyright (C) 2014 BogDan Vatra <bogdan@kde.org>
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Android port of the Qt Toolkit.
@@ -143,6 +144,9 @@ public class QtActivityDelegate
private int m_portraitKeyboardHeight = 0;
private int m_landscapeKeyboardHeight = 0;
private int m_probeKeyboardHeightDelay = 50; // ms
+ private CursorHandle m_cursorHandle;
+ private CursorHandle m_leftSelectionHandle;
+ private CursorHandle m_rightSelectionHandle;
public void setFullScreen(boolean enterFullScreen)
{
@@ -470,6 +474,49 @@ public class QtActivityDelegate
m_imm.updateSelection(m_editText, selStart, selEnd, candidatesStart, candidatesEnd);
}
+ // Values coming from QAndroidInputContext::CursorHandleShowMode
+ private static final int CursorHandleNotShown = 0;
+ private static final int CursorHandleShowNormal = 1;
+ private static final int CursorHandleShowSelection = 2;
+
+ /* called from the C++ code when the position of the cursor or selection handles needs to
+ be adjusted
+
+ mode is one of QAndroidInputContext::CursorHandleShowMode)
+ */
+ public void updateHandles(int mode, int x1, int y1, int x2, int y2)
+ {
+ if (mode == CursorHandleNotShown) {
+ if (m_cursorHandle != null)
+ m_cursorHandle.hide();
+ if (m_rightSelectionHandle != null) {
+ m_rightSelectionHandle.hide();
+ m_leftSelectionHandle.hide();
+ }
+ } else if (mode == CursorHandleShowNormal) {
+ if (m_cursorHandle == null) {
+ m_cursorHandle = new CursorHandle(m_activity, m_layout, QtNative.IdCursorHandle,
+ android.R.attr.textSelectHandle);
+ }
+ m_cursorHandle.setPosition(x1, y1);
+ if (m_rightSelectionHandle != null) {
+ m_rightSelectionHandle.hide();
+ m_leftSelectionHandle.hide();
+ }
+ } else if (mode == CursorHandleShowSelection) {
+ if (m_rightSelectionHandle == null) {
+ m_leftSelectionHandle = new CursorHandle(m_activity, m_layout, QtNative.IdLeftHandle,
+ android.R.attr.textSelectHandleLeft);
+ m_rightSelectionHandle = new CursorHandle(m_activity, m_layout, QtNative.IdRightHandle,
+ android.R.attr.textSelectHandleRight);
+ }
+ m_leftSelectionHandle.setPosition(x1,y1);
+ m_rightSelectionHandle.setPosition(x2,y2);
+ if (m_cursorHandle != null)
+ m_cursorHandle.hide();
+ }
+ }
+
public boolean loadApplication(Activity activity, ClassLoader classLoader, Bundle loaderParams)
{
/// check parameters integrity