diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-10-23 14:01:35 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2015-10-23 14:45:03 +0200 |
commit | 790aef362fd195adf97d8c780a7cbbbade27d51f (patch) | |
tree | 8be464687ab21806cfe9f7ada27098b563aa41b2 /src/android | |
parent | 9720efbd1035c2e939b0581163e6d804c713dd96 (diff) | |
parent | 07475c662eb73c833da2d461b8ef2702ca1e2cfb (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts:
.qmake.conf
configure
src/corelib/global/qglobal.h
src/tools/qdoc/node.cpp
src/tools/qdoc/qdocdatabase.cpp
tests/auto/corelib/io/qsettings/tst_qsettings.cpp
tools/configure/configureapp.cpp
Change-Id: I66028ae5e441a06b73ee85ba72a03a3af3e8593f
Diffstat (limited to 'src/android')
-rw-r--r-- | src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java | 94 | ||||
-rw-r--r-- | src/android/jar/src/org/qtproject/qt5/android/QtNative.java | 33 |
2 files changed, 77 insertions, 50 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 15d3b136c5..f22e3d7a70 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -59,6 +59,7 @@ import android.view.KeyCharacterMap; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; +import android.view.MotionEvent; import android.view.Surface; import android.view.View; import android.view.ViewConfiguration; @@ -76,7 +77,6 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; public class QtActivityDelegate { @@ -89,6 +89,7 @@ public class QtActivityDelegate private Method m_super_onKeyUp = null; private Method m_super_onConfigurationChanged = null; private Method m_super_onActivityResult = null; + private Method m_super_dispatchGenericMotionEvent = null; private static final String NATIVE_LIBRARIES_KEY = "native.libraries"; private static final String BUNDLED_LIBRARIES_KEY = "bundled.libraries"; @@ -131,37 +132,32 @@ public class QtActivityDelegate if (m_fullScreen = enterFullScreen) { m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); - if (Build.VERSION.SDK_INT >= 19) { - try { - int ui_flag_immersive_sticky = View.class.getDeclaredField("SYSTEM_UI_FLAG_IMMERSIVE_STICKY").getInt(null); - int ui_flag_layout_stable = View.class.getDeclaredField("SYSTEM_UI_FLAG_LAYOUT_STABLE").getInt(null); - int ui_flag_layout_hide_navigation = View.class.getDeclaredField("SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION").getInt(null); - int ui_flag_layout_fullscreen = View.class.getDeclaredField("SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN").getInt(null); - int ui_flag_hide_navigation = View.class.getDeclaredField("SYSTEM_UI_FLAG_HIDE_NAVIGATION").getInt(null); - int ui_flag_fullscreen = View.class.getDeclaredField("SYSTEM_UI_FLAG_FULLSCREEN").getInt(null); - + try { + if (Build.VERSION.SDK_INT >= 14) { + int flags = View.class.getDeclaredField("SYSTEM_UI_FLAG_HIDE_NAVIGATION").getInt(null); + if (Build.VERSION.SDK_INT >= 16) { + flags |= View.class.getDeclaredField("SYSTEM_UI_FLAG_LAYOUT_STABLE").getInt(null); + flags |= View.class.getDeclaredField("SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION").getInt(null); + flags |= View.class.getDeclaredField("SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN").getInt(null); + flags |= View.class.getDeclaredField("SYSTEM_UI_FLAG_FULLSCREEN").getInt(null); + + if (Build.VERSION.SDK_INT >= 19) + flags |= View.class.getDeclaredField("SYSTEM_UI_FLAG_IMMERSIVE_STICKY").getInt(null); + } Method m = View.class.getMethod("setSystemUiVisibility", int.class); - m.invoke(m_activity.getWindow().getDecorView(), - ui_flag_layout_stable - | ui_flag_layout_hide_navigation - | ui_flag_layout_fullscreen - | ui_flag_hide_navigation - | ui_flag_fullscreen - | ui_flag_immersive_sticky - | View.INVISIBLE); - } catch (Exception e) { - e.printStackTrace(); + m.invoke(m_activity.getWindow().getDecorView(), flags | View.INVISIBLE); } + } catch (Exception e) { + e.printStackTrace(); } } else { m_activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); m_activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - if (Build.VERSION.SDK_INT >= 19) { + if (Build.VERSION.SDK_INT >= 14) { try { int ui_flag_visible = View.class.getDeclaredField("SYSTEM_UI_FLAG_VISIBLE").getInt(null); Method m = View.class.getMethod("setSystemUiVisibility", int.class); - m.invoke(m_activity.getWindow().getDecorView(), - ui_flag_visible); + m.invoke(m_activity.getWindow().getDecorView(), ui_flag_visible); } catch (Exception e) { e.printStackTrace(); } @@ -214,10 +210,10 @@ public class QtActivityDelegate private final int EnterKeyPrevious = 7; // application state - private final int ApplicationSuspended = 0x0; - private final int ApplicationHidden = 0x1; - private final int ApplicationInactive = 0x2; - private final int ApplicationActive = 0x4; + public static final int ApplicationSuspended = 0x0; + public static final int ApplicationHidden = 0x1; + public static final int ApplicationInactive = 0x2; + public static final int ApplicationActive = 0x4; public boolean setKeyboardVisibility(boolean visibility, long timeStamp) @@ -475,6 +471,13 @@ public class QtActivityDelegate m_super_onKeyUp = m_activity.getClass().getMethod("super_onKeyUp", Integer.TYPE, KeyEvent.class); m_super_onConfigurationChanged = m_activity.getClass().getMethod("super_onConfigurationChanged", Configuration.class); m_super_onActivityResult = m_activity.getClass().getMethod("super_onActivityResult", Integer.TYPE, Integer.TYPE, Intent.class); + if (Build.VERSION.SDK_INT >= 12) { + try { + m_super_dispatchGenericMotionEvent = m_activity.getClass().getMethod("super_dispatchGenericMotionEvent", MotionEvent.class); + } catch (Exception e) { + } + } + } catch (Exception e) { e.printStackTrace(); return false; @@ -915,24 +918,15 @@ public class QtActivityDelegate public void onPause() { - QtNative.updateApplicationState(ApplicationInactive); + QtNative.setApplicationState(ApplicationInactive); } public void onResume() { - // fire all lostActions - synchronized (QtNative.m_mainActivityMutex) - { - Iterator<Runnable> itr = QtNative.getLostActions().iterator(); - while (itr.hasNext()) - m_activity.runOnUiThread(itr.next()); - - QtNative.updateApplicationState(ApplicationActive); - if (m_started) { - QtNative.clearLostActions(); - QtNative.updateWindow(); - updateFullScreen(); // Suspending the app clears the immersive mode, so we need to set it again. - } + QtNative.setApplicationState(ApplicationActive); + if (m_started) { + QtNative.updateWindow(); + updateFullScreen(); // Suspending the app clears the immersive mode, so we need to set it again. } } @@ -955,7 +949,7 @@ public class QtActivityDelegate public void onStop() { - QtNative.updateApplicationState(ApplicationSuspended); + QtNative.setApplicationState(ApplicationSuspended); } public Object onRetainNonConfigurationInstance() @@ -1060,6 +1054,9 @@ public class QtActivityDelegate QtNative.keyUp(0, event.getCharacters().charAt(0), event.getMetaState(), event.getRepeatCount() > 0); } + if (QtNative.dispatchKeyEvent(event)) + return true; + try { return (Boolean) m_super_dispatchKeyEvent.invoke(m_activity, event); } catch (Exception e) { @@ -1328,4 +1325,17 @@ public class QtActivityDelegate m_layout.moveChild(view, index); } } + + public boolean dispatchGenericMotionEvent (MotionEvent ev) + { + if (m_started && QtNative.dispatchGenericMotionEvent(ev)) + return true; + + try { + return (Boolean) m_super_dispatchGenericMotionEvent.invoke(m_activity, ev); + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } } diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index 0c01e67637..07ef6d657d 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -48,12 +48,14 @@ import android.text.ClipboardManager; import android.os.Build; import android.util.Log; import android.view.ContextMenu; +import android.view.KeyEvent; import android.view.Menu; import android.view.MotionEvent; import android.view.View; import java.security.KeyStore; import java.security.cert.X509Certificate; +import java.util.Iterator; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; @@ -61,6 +63,7 @@ import javax.net.ssl.X509TrustManager; public class QtNative { private static Activity m_activity = null; + private static boolean m_activityPaused = false; private static QtActivityDelegate m_activityDelegate = null; public static Object m_mainActivityMutex = new Object(); // mutex used to synchronize runnable operations @@ -165,14 +168,23 @@ public class QtNative } } - static public ArrayList<Runnable> getLostActions() + public static void setApplicationState(int state) { - return m_lostActions; - } - - static public void clearLostActions() - { - m_lostActions.clear(); + synchronized (m_mainActivityMutex) { + switch (state) { + case QtActivityDelegate.ApplicationActive: + m_activityPaused = false; + Iterator<Runnable> itr = m_lostActions.iterator(); + while (itr.hasNext()) + runAction(itr.next()); + m_lostActions.clear(); + break; + default: + m_activityPaused = true; + break; + } + } + updateApplicationState(state); } private static void runAction(Runnable action) @@ -180,7 +192,7 @@ public class QtNative synchronized (m_mainActivityMutex) { final Looper mainLooper = Looper.getMainLooper(); final Handler handler = new Handler(mainLooper); - final boolean actionIsQueued = m_activity != null && mainLooper != null && handler.post(action); + final boolean actionIsQueued = !m_activityPaused && m_activity != null && mainLooper != null && handler.post(action); if (!actionIsQueued) m_lostActions.add(action); } @@ -633,6 +645,11 @@ public class QtNative public static native void keyboardVisibilityChanged(boolean visibility); // keyboard methods + // dispatch events methods + public static native boolean dispatchGenericMotionEvent(MotionEvent ev); + public static native boolean dispatchKeyEvent(KeyEvent event); + // dispatch events methods + // surface methods public static native void setSurface(int id, Object surface, int w, int h); // surface methods |