summaryrefslogtreecommitdiffstats
path: root/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
diff options
context:
space:
mode:
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.java130
1 files changed, 70 insertions, 60 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 fa7508921d..aeb5515a01 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
@@ -151,7 +151,6 @@ public class QtActivityDelegate
private CursorHandle m_cursorHandle;
private CursorHandle m_leftSelectionHandle;
private CursorHandle m_rightSelectionHandle;
- private EditMenu m_editMenu;
private EditPopupMenu m_editPopupMenu;
public void setFullScreen(boolean enterFullScreen)
@@ -484,77 +483,87 @@ public class QtActivityDelegate
}
// Values coming from QAndroidInputContext::CursorHandleShowMode
- private static final int CursorHandleNotShown = 0;
- private static final int CursorHandleShowNormal = 1;
- private static final int CursorHandleShowSelection = 2;
- private static final int CursorHandleShowPopup = 3;
+ private static final int CursorHandleNotShown = 0;
+ private static final int CursorHandleShowNormal = 1;
+ private static final int CursorHandleShowSelection = 2;
+ private static final int CursorHandleShowEdit = 0x100;
/* 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, boolean rtl)
+ public void updateHandles(int mode, int editX, int editY, int editButtons, int x1, int y1, int x2, int y2, boolean rtl)
{
- if (mode == CursorHandleNotShown) {
- if (m_cursorHandle != null)
- m_cursorHandle.hide();
- if (m_rightSelectionHandle != null) {
- m_rightSelectionHandle.hide();
- m_leftSelectionHandle.hide();
- m_rightSelectionHandle = null;
- m_leftSelectionHandle = null;
- }
- if (m_editMenu != null)
- m_editMenu.hide();
- if (m_editPopupMenu != null)
+ switch (mode & 0xff)
+ {
+ case CursorHandleNotShown:
+ if (m_cursorHandle != null) {
+ m_cursorHandle.hide();
+ m_cursorHandle = null;
+ }
+ if (m_rightSelectionHandle != null) {
+ m_rightSelectionHandle.hide();
+ m_leftSelectionHandle.hide();
+ m_rightSelectionHandle = null;
+ m_leftSelectionHandle = null;
+ }
m_editPopupMenu.hide();
- } else if (mode == CursorHandleShowNormal || mode == CursorHandleShowPopup) {
- if (m_cursorHandle == null) {
- m_cursorHandle = new CursorHandle(m_activity, m_layout, QtNative.IdCursorHandle,
- android.R.attr.textSelectHandle, false);
- }
- m_cursorHandle.setPosition(x1, y1);
- if (m_rightSelectionHandle != null) {
- m_rightSelectionHandle.hide();
- m_leftSelectionHandle.hide();
- m_rightSelectionHandle = null;
- m_leftSelectionHandle = null;
- }
- } else if (mode == CursorHandleShowSelection) {
- if (m_rightSelectionHandle == null) {
- m_leftSelectionHandle = new CursorHandle(m_activity, m_layout, QtNative.IdLeftHandle,
- !rtl ? android.R.attr.textSelectHandleLeft :
- android.R.attr.textSelectHandleRight,
- rtl);
- m_rightSelectionHandle = new CursorHandle(m_activity, m_layout, QtNative.IdRightHandle,
- !rtl ? android.R.attr.textSelectHandleRight :
- android.R.attr.textSelectHandleLeft,
- rtl);
- }
- m_leftSelectionHandle.setPosition(x1,y1);
- m_rightSelectionHandle.setPosition(x2,y2);
- if (m_cursorHandle != null)
- m_cursorHandle.hide();
-
- if (m_editMenu == null)
- m_editMenu = new EditMenu(m_activity);
- m_editMenu.show();
+ break;
+
+ case CursorHandleShowNormal:
+ if (m_cursorHandle == null) {
+ m_cursorHandle = new CursorHandle(m_activity, m_layout, QtNative.IdCursorHandle,
+ android.R.attr.textSelectHandle, false);
+ }
+ m_cursorHandle.setPosition(x1, y1);
+ if (m_rightSelectionHandle != null) {
+ m_rightSelectionHandle.hide();
+ m_leftSelectionHandle.hide();
+ m_rightSelectionHandle = null;
+ m_leftSelectionHandle = null;
+ }
+ break;
+
+ case CursorHandleShowSelection:
+ if (m_rightSelectionHandle == null) {
+ m_leftSelectionHandle = new CursorHandle(m_activity, m_layout, QtNative.IdLeftHandle,
+ !rtl ? android.R.attr.textSelectHandleLeft :
+ android.R.attr.textSelectHandleRight,
+ rtl);
+ m_rightSelectionHandle = new CursorHandle(m_activity, m_layout, QtNative.IdRightHandle,
+ !rtl ? android.R.attr.textSelectHandleRight :
+ android.R.attr.textSelectHandleLeft,
+ rtl);
+ }
+ m_leftSelectionHandle.setPosition(x1,y1);
+ m_rightSelectionHandle.setPosition(x2,y2);
+ if (m_cursorHandle != null) {
+ m_cursorHandle.hide();
+ m_cursorHandle = null;
+ }
+ mode |= CursorHandleShowEdit;
+ break;
}
- // show the edit popup menu
- if (mode == CursorHandleShowPopup && (m_editMenu == null || !m_editMenu.isShown())
- && QtNative.hasClipboardText()) {
- if (m_editPopupMenu == null)
- m_editPopupMenu = new EditPopupMenu(m_activity, m_layout);
- if (y2 < m_editPopupMenu.getHeight()) {
- // If the popup cannot be shown over the text, it must be shown under the anchors
- y2 = y1 + 2 * m_editPopupMenu.getHeight();
+ if (QtNative.hasClipboardText())
+ editButtons |= EditContextView.PASTE_BUTTON;
+ else
+ editButtons &= ~EditContextView.PASTE_BUTTON;
+
+ if ((mode & CursorHandleShowEdit) == CursorHandleShowEdit && editButtons != 0) {
+ editY -= m_editPopupMenu.getHeight();
+ if (editY < 0) {
+ if (m_cursorHandle != null)
+ editY = m_cursorHandle.bottom();
+ else if (m_leftSelectionHandle != null && m_rightSelectionHandle != null)
+ editY = Math.max(m_leftSelectionHandle.bottom(), m_rightSelectionHandle.bottom());
+ else
+ return;
}
- m_editPopupMenu.setPosition(x2, y2);
- } else if (m_editPopupMenu != null) {
+ m_editPopupMenu.setPosition(editX, editY, editButtons);
+ } else {
m_editPopupMenu.hide();
}
-
}
public boolean loadApplication(Activity activity, ClassLoader classLoader, Bundle loaderParams)
@@ -1008,6 +1017,7 @@ public class QtActivityDelegate
return true;
}
});
+ m_editPopupMenu = new EditPopupMenu(m_activity, m_layout);
}
public void hideSplashScreen()