summaryrefslogtreecommitdiffstats
path: root/src/android/jar
diff options
context:
space:
mode:
authorBogDan Vatra <bogdan@kde.org>2014-03-22 08:08:08 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-26 07:22:35 +0100
commitf1f07eae2d40f202a709af33ca1e8d86551c9ace (patch)
tree6ace627ce63597e3c1da381b4b6ff2ba0eb579f1 /src/android/jar
parenta0dc3e608fe67ae1ec3f0ee92e1dc15ebaa0fe9e (diff)
Android: Fix software keyboard show/hide state
Task-number: QTBUG-34831 Change-Id: Ic38334d011ceef2dc75e4fb3fcea48f62aeea757 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/android/jar')
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java22
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtInputConnection.java39
2 files changed, 20 insertions, 41 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 ea8e5cd44c..e62b5dab82 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
@@ -120,7 +120,7 @@ public class QtActivityDelegate
private boolean m_keyboardIsVisible = false;
public boolean m_backKeyPressedSent = false;
-
+ private long m_showHideTimeStamp = System.nanoTime();
public void setFullScreen(boolean enterFullScreen)
{
@@ -201,12 +201,18 @@ public class QtActivityDelegate
private final int ApplicationInactive = 0x2;
private final int ApplicationActive = 0x4;
- public void setKeyboardVisibility(boolean visibility)
+
+ public boolean setKeyboardVisibility(boolean visibility, long timeStamp)
{
+ if (m_showHideTimeStamp > timeStamp)
+ return false;
+ m_showHideTimeStamp = timeStamp;
+
if (m_keyboardIsVisible == visibility)
- return;
+ return false;
m_keyboardIsVisible = visibility;
QtNative.keyboardVisibilityChanged(m_keyboardIsVisible);
+ return true;
}
public void resetSoftwareKeyboard()
{
@@ -304,11 +310,11 @@ public class QtActivityDelegate
QtNativeInputConnection.updateCursorPosition();
//FALLTHROUGH
case InputMethodManager.RESULT_UNCHANGED_SHOWN:
- setKeyboardVisibility(true);
+ setKeyboardVisibility(true, System.nanoTime());
break;
case InputMethodManager.RESULT_HIDDEN:
case InputMethodManager.RESULT_UNCHANGED_HIDDEN:
- setKeyboardVisibility(false);
+ setKeyboardVisibility(false, System.nanoTime());
break;
}
}
@@ -331,11 +337,11 @@ public class QtActivityDelegate
switch (resultCode) {
case InputMethodManager.RESULT_SHOWN:
case InputMethodManager.RESULT_UNCHANGED_SHOWN:
- setKeyboardVisibility(true);
+ setKeyboardVisibility(true, System.nanoTime());
break;
case InputMethodManager.RESULT_HIDDEN:
case InputMethodManager.RESULT_UNCHANGED_HIDDEN:
- setKeyboardVisibility(false);
+ setKeyboardVisibility(false, System.nanoTime());
break;
}
}
@@ -827,7 +833,7 @@ public class QtActivityDelegate
if (keyCode == KeyEvent.KEYCODE_BACK && !m_backKeyPressedSent) {
hideSoftwareKeyboard();
- setKeyboardVisibility(false);
+ setKeyboardVisibility(false, System.nanoTime());
return true;
}
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtInputConnection.java b/src/android/jar/src/org/qtproject/qt5/android/QtInputConnection.java
index 5e6e227c2b..655ab95dd8 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtInputConnection.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtInputConnection.java
@@ -82,18 +82,11 @@ class QtNativeInputConnection
}
class HideKeyboardRunnable implements Runnable {
- private QtInputConnection m_connection;
- HideKeyboardRunnable(QtInputConnection connection)
- {
- m_connection = connection;
- }
+ private long m_hideTimeStamp = System.nanoTime();
@Override
public void run() {
- if (m_connection.getInputState() == QtInputConnection.InputStates.Hiding) {
- QtNative.activityDelegate().setKeyboardVisibility(false);
- m_connection.reset();
- }
+ QtNative.activityDelegate().setKeyboardVisibility(false, m_hideTimeStamp);
}
}
@@ -107,34 +100,14 @@ public class QtInputConnection extends BaseInputConnection
private static final int ID_SWITCH_INPUT_METHOD = android.R.id.switchInputMethod;
private static final int ID_ADD_TO_DICTIONARY = android.R.id.addToDictionary;
-
- enum InputStates { Visible, FinishComposing, Hiding };
-
private QtEditText m_view = null;
- private InputStates m_inputState = InputStates.Visible;
-
- public void reset()
- {
- m_inputState = InputStates.Visible;
- }
-
- public InputStates getInputState()
- {
- return m_inputState;
- }
private void setClosing(boolean closing)
{
- if (closing && m_inputState == InputStates.Hiding)
- return;
-
- if (closing && m_view.getActivityDelegate().isSoftwareKeyboardVisible()) {
- m_view.postDelayed(new HideKeyboardRunnable(this), 100);
- m_inputState = InputStates.Hiding;
+ if (closing) {
+ m_view.postDelayed(new HideKeyboardRunnable(), 100);
} else {
- if (m_inputState == InputStates.Hiding)
- QtNative.activityDelegate().setKeyboardVisibility(true);
- m_inputState = closing ? InputStates.FinishComposing : InputStates.Visible;
+ QtNative.activityDelegate().setKeyboardVisibility(true, System.nanoTime());
}
}
@@ -154,7 +127,7 @@ public class QtInputConnection extends BaseInputConnection
@Override
public boolean endBatchEdit()
{
-// setClosing(false);
+ setClosing(false);
return true;
}