diff options
author | Jan Arve Saether <jan-arve.saether@theqtcompany.com> | 2014-12-05 10:24:09 +0100 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@theqtcompany.com> | 2014-12-09 16:59:03 +0100 |
commit | 5a6735316aad213f9156eb32d56eb65271b16910 (patch) | |
tree | 96328b68504990db5a3c8a8f05818650874cafea /src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java | |
parent | a6436ff5592332d5d06c6ee1806dc132306d5f3e (diff) |
Do not initialize accessibility code by default on startup.
Instead listen for if the accessibility service is running or not by
implementing AccessibilityStateChangeListener.
This seems to work smoothly when turning on or off TalkBack.
This should also improve startup time.
Change-Id: I3eb7d6cb9c9c1618afbb59675e4e089c9159019c
Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.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.java | 55 |
1 files changed, 16 insertions, 39 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 97a632972b..4d16d7e13f 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -127,7 +127,6 @@ public class QtActivityDelegate private boolean m_quitApp = true; private Process m_debuggerProcess = null; // debugger process private View m_dummyView = null; - private View m_accView = null; private boolean m_keyboardIsVisible = false; public boolean m_backKeyPressedSent = false; private long m_showHideTimeStamp = System.nanoTime(); @@ -804,6 +803,22 @@ public class QtActivityDelegate m_nativeViews = new HashMap<Integer, View>(); m_activity.registerForContextMenu(m_layout); + // Initialize accessibility + try { + final String a11yDelegateClassName = "org.qtproject.qt5.android.accessibility.QtAccessibilityDelegate"; + Class<?> qtDelegateClass = Class.forName(a11yDelegateClassName); + Constructor constructor = qtDelegateClass.getConstructor(android.app.Activity.class, + android.view.ViewGroup.class, + this.getClass()); + Object accessibilityDelegate = constructor.newInstance(m_activity, m_layout, this); + } catch (ClassNotFoundException e) { + // Class not found is fine since we are compatible with Android API < 16, but the function will + // only be available with that API level. + } catch (Exception e) { + // Unknown exception means something went wrong. + Log.w("Qt A11y", "Unknown exception: " + e.toString()); + } + m_activity.setContentView(m_layout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); @@ -1184,44 +1199,6 @@ public class QtActivityDelegate m_layout.addView(surface, surfaceCount); m_surfaces.put(id, surface); - - // Initialize Accessibility - // The accessibility code depends on android API level 16, so dynamically resolve it - if (android.os.Build.VERSION.SDK_INT >= 16) { - if (m_accView == null) { - try { - View accView = new View(m_activity); - accView.setId(View.NO_ID); - - // ### Keep this for debugging for a while. It allows us to visually see that our View - // ### is on top of the surface(s) - // ColorDrawable color = new ColorDrawable(0x80ff8080); //0xAARRGGBB - // accView.setBackground(color); - - final String a11yDelegateClassName = "org.qtproject.qt5.android.accessibility.QtAccessibilityDelegate"; - Class<?> qtDelegateClass = Class.forName(a11yDelegateClassName); - Constructor constructor = qtDelegateClass.getConstructor(Class.forName("android.view.View")); - Object accessibilityDelegate = constructor.newInstance(accView); - - Class a11yDelegateClass = Class.forName("android.view.View$AccessibilityDelegate"); - Method setDelegateMethod = accView.getClass().getMethod("setAccessibilityDelegate", a11yDelegateClass); - setDelegateMethod.invoke(accView, accessibilityDelegate); - - // if all is fine, add it to the layout - m_layout.addView(accView, surfaceCount + 1, - new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - - m_accView = accView; - } catch (ClassNotFoundException e) { - // Class not found is fine since we are compatible with Android API < 16, but the function will - // only be available with that API level. - } catch (Exception e) { - // Unknown exception means something went wrong. - Log.w("Qt A11y", "Unknown exception: " + e.toString()); - } - } - } - } public void setSurfaceGeometry(int id, int x, int y, int w, int h) { |