diff options
Diffstat (limited to 'src/android/jar')
6 files changed, 244 insertions, 97 deletions
diff --git a/src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java b/src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java index feb47c8f90..bba114767d 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java +++ b/src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java @@ -162,12 +162,14 @@ public class CursorHandle implements ViewTreeObserver.OnPreDrawListener final int[] layoutLocation = new int[2]; m_layout.getLocationOnScreen(layoutLocation); - // This value is used for handling split screen case + // These values are used for handling split screen case final int[] activityLocation = new int[2]; + final int[] activityLocationInWindow = new int[2]; m_activity.getWindow().getDecorView().getLocationOnScreen(activityLocation); + m_activity.getWindow().getDecorView().getLocationInWindow(activityLocationInWindow); int x2 = x + layoutLocation[0] - activityLocation[0]; - int y2 = y + layoutLocation[1] + m_yShift - activityLocation[1]; + int y2 = y + layoutLocation[1] + m_yShift + (activityLocationInWindow[1] - activityLocation[1]); if (m_id == QtNative.IdCursorHandle) { x2 -= m_popup.getWidth() / 2 ; @@ -202,6 +204,10 @@ public class CursorHandle implements ViewTreeObserver.OnPreDrawListener } } + public int width() { + return m_cursorView.getDrawable().getIntrinsicWidth(); + } + // The handle was dragged by a given relative position public void updatePosition(int x, int y) { y -= m_yShift; diff --git a/src/android/jar/src/org/qtproject/qt5/android/EditPopupMenu.java b/src/android/jar/src/org/qtproject/qt5/android/EditPopupMenu.java index 18a8b36273..eab7fe646f 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/EditPopupMenu.java +++ b/src/android/jar/src/org/qtproject/qt5/android/EditPopupMenu.java @@ -65,6 +65,7 @@ public class EditPopupMenu implements ViewTreeObserver.OnPreDrawListener, View.O private View m_layout = null; private EditContextView m_view = null; private PopupWindow m_popup = null; + private Activity m_activity; private int m_posX; private int m_posY; private int m_buttons; @@ -74,6 +75,7 @@ public class EditPopupMenu implements ViewTreeObserver.OnPreDrawListener, View.O public EditPopupMenu(Activity activity, View layout) { + m_activity = activity; m_view = new EditContextView(activity, this); m_view.addOnLayoutChangeListener(this); @@ -103,11 +105,17 @@ public class EditPopupMenu implements ViewTreeObserver.OnPreDrawListener, View.O initOverlay(); m_view.updateButtons(buttons); - final int[] location = new int[2]; - m_layout.getLocationOnScreen(location); + final int[] layoutLocation = new int[2]; + m_layout.getLocationOnScreen(layoutLocation); - int x2 = x + location[0]; - int y2 = y + location[1]; + // These values are used for handling split screen case + final int[] activityLocation = new int[2]; + final int[] activityLocationInWindow = new int[2]; + m_activity.getWindow().getDecorView().getLocationOnScreen(activityLocation); + m_activity.getWindow().getDecorView().getLocationInWindow(activityLocationInWindow); + + int x2 = x + layoutLocation[0] - activityLocation[0]; + int y2 = y + layoutLocation[1] + (activityLocationInWindow[1] - activityLocation[1]); x2 -= m_view.getWidth() / 2 ; 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 184956d8ef..33f4f77360 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -496,6 +496,17 @@ public class QtActivityDelegate private static final int CursorHandleShowSelection = 2; private static final int CursorHandleShowEdit = 0x100; + public int getSelectHandleWidth() + { + int width = 0; + if (m_leftSelectionHandle != null && m_rightSelectionHandle != null) + width = Math.max(m_leftSelectionHandle.width(), m_rightSelectionHandle.width()); + else if (m_cursorHandle != null) + width = m_cursorHandle.width(); + + return width; + } + /* called from the C++ code when the position of the cursor or selection handles needs to be adjusted. mode is one of QAndroidInputContext::CursorHandleShowMode @@ -568,6 +579,100 @@ public class QtActivityDelegate } } + private final DisplayManager.DisplayListener displayListener = new DisplayManager.DisplayListener() + { + @Override + public void onDisplayAdded(int displayId) { } + + private boolean isSimilarRotation(int r1, int r2) + { + return (r1 == r2) + || (r1 == Surface.ROTATION_0 && r2 == Surface.ROTATION_180) + || (r1 == Surface.ROTATION_180 && r2 == Surface.ROTATION_0) + || (r1 == Surface.ROTATION_90 && r2 == Surface.ROTATION_270) + || (r1 == Surface.ROTATION_270 && r2 == Surface.ROTATION_90); + } + + @Override + public void onDisplayChanged(int displayId) + { + Display display = (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) + ? m_activity.getWindowManager().getDefaultDisplay() + : m_activity.getDisplay(); + m_currentRotation = display.getRotation(); + m_layout.setActivityDisplayRotation(m_currentRotation); + // Process orientation change only if it comes after the size + // change, or if the screen is rotated by 180 degrees. + // Otherwise it will be processed in QtLayout. + if (isSimilarRotation(m_currentRotation, m_layout.displayRotation())) + QtNative.handleOrientationChanged(m_currentRotation, m_nativeOrientation); + + float refreshRate = display.getRefreshRate(); + QtNative.handleRefreshRateChanged(refreshRate); + } + + @Override + public void onDisplayRemoved(int displayId) { } + }; + + public boolean updateActivity(Activity activity) + { + try { + // set new activity + loadActivity(activity); + + // update the new activity content view to old layout + ViewGroup layoutParent = (ViewGroup)m_layout.getParent(); + if (layoutParent != null) + layoutParent.removeView(m_layout); + + m_activity.setContentView(m_layout); + + // force c++ native activity object to update + return QtNative.updateNativeActivity(); + } catch (Exception e) { + Log.w(QtNative.QtTAG, "Failed to update the activity."); + e.printStackTrace(); + return false; + } + } + + private void loadActivity(Activity activity) + throws NoSuchMethodException, PackageManager.NameNotFoundException + { + m_activity = activity; + + QtNative.setActivity(m_activity, this); + setActionBarVisibility(false); + + Class<?> activityClass = m_activity.getClass(); + m_super_dispatchKeyEvent = + activityClass.getMethod("super_dispatchKeyEvent", KeyEvent.class); + m_super_onRestoreInstanceState = + activityClass.getMethod("super_onRestoreInstanceState", Bundle.class); + m_super_onRetainNonConfigurationInstance = + activityClass.getMethod("super_onRetainNonConfigurationInstance"); + m_super_onSaveInstanceState = + activityClass.getMethod("super_onSaveInstanceState", Bundle.class); + m_super_onKeyDown = + activityClass.getMethod("super_onKeyDown", Integer.TYPE, KeyEvent.class); + m_super_onKeyUp = + activityClass.getMethod("super_onKeyUp", Integer.TYPE, KeyEvent.class); + m_super_onConfigurationChanged = + activityClass.getMethod("super_onConfigurationChanged", Configuration.class); + m_super_onActivityResult = + activityClass.getMethod("super_onActivityResult", Integer.TYPE, Integer.TYPE, Intent.class); + m_super_onWindowFocusChanged = + activityClass.getMethod("super_onWindowFocusChanged", Boolean.TYPE); + m_super_dispatchGenericMotionEvent = + activityClass.getMethod("super_dispatchGenericMotionEvent", MotionEvent.class); + + m_softInputMode = m_activity.getPackageManager().getActivityInfo(m_activity.getComponentName(), 0).softInputMode; + + DisplayManager displayManager = (DisplayManager)m_activity.getSystemService(Context.DISPLAY_SERVICE); + displayManager.registerDisplayListener(displayListener, null); + } + public boolean loadApplication(Activity activity, ClassLoader classLoader, Bundle loaderParams) { /// check parameters integrity @@ -577,10 +682,14 @@ public class QtActivityDelegate return false; } - m_activity = activity; - setActionBarVisibility(false); - QtNative.setActivity(m_activity, this); - QtNative.setClassLoader(classLoader); + try { + loadActivity(activity); + QtNative.setClassLoader(classLoader); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + if (loaderParams.containsKey(STATIC_INIT_CLASSES_KEY)) { for (String className: Objects.requireNonNull(loaderParams.getStringArray(STATIC_INIT_CLASSES_KEY))) { if (className.length() == 0) @@ -625,22 +734,6 @@ public class QtActivityDelegate loaderParams.getBoolean(EXTRACT_STYLE_MINIMAL_KEY)); } - try { - m_super_dispatchKeyEvent = m_activity.getClass().getMethod("super_dispatchKeyEvent", KeyEvent.class); - m_super_onRestoreInstanceState = m_activity.getClass().getMethod("super_onRestoreInstanceState", Bundle.class); - m_super_onRetainNonConfigurationInstance = m_activity.getClass().getMethod("super_onRetainNonConfigurationInstance"); - m_super_onSaveInstanceState = m_activity.getClass().getMethod("super_onSaveInstanceState", Bundle.class); - m_super_onKeyDown = m_activity.getClass().getMethod("super_onKeyDown", Integer.TYPE, KeyEvent.class); - 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); - m_super_onWindowFocusChanged = m_activity.getClass().getMethod("super_onWindowFocusChanged", Boolean.TYPE); - m_super_dispatchGenericMotionEvent = m_activity.getClass().getMethod("super_dispatchGenericMotionEvent", MotionEvent.class); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - int necessitasApiLevel = 1; if (loaderParams.containsKey(NECESSITAS_API_LEVEL_KEY)) necessitasApiLevel = loaderParams.getInt(NECESSITAS_API_LEVEL_KEY); @@ -666,52 +759,6 @@ public class QtActivityDelegate else m_applicationParameters = ""; - try { - m_softInputMode = m_activity.getPackageManager().getActivityInfo(m_activity.getComponentName(), 0).softInputMode; - } catch (Exception e) { - e.printStackTrace(); - } - - DisplayManager.DisplayListener displayListener = new DisplayManager.DisplayListener() { - @Override - public void onDisplayAdded(int displayId) { } - - private boolean isSimilarRotation(int r1, int r2) - { - return (r1 == r2) - || (r1 == Surface.ROTATION_0 && r2 == Surface.ROTATION_180) - || (r1 == Surface.ROTATION_180 && r2 == Surface.ROTATION_0) - || (r1 == Surface.ROTATION_90 && r2 == Surface.ROTATION_270) - || (r1 == Surface.ROTATION_270 && r2 == Surface.ROTATION_90); - } - - @Override - public void onDisplayChanged(int displayId) { - Display display = (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) - ? m_activity.getWindowManager().getDefaultDisplay() - : m_activity.getDisplay(); - m_currentRotation = display.getRotation(); - m_layout.setActivityDisplayRotation(m_currentRotation); - // Process orientation change only if it comes after the size - // change, or if the screen is rotated by 180 degrees. - // Otherwise it will be processed in QtLayout. - if (isSimilarRotation(m_currentRotation, m_layout.displayRotation())) - QtNative.handleOrientationChanged(m_currentRotation, m_nativeOrientation); - float refreshRate = display.getRefreshRate(); - QtNative.handleRefreshRateChanged(refreshRate); - } - - @Override - public void onDisplayRemoved(int displayId) { } - }; - - try { - DisplayManager displayManager = (DisplayManager) m_activity.getSystemService(Context.DISPLAY_SERVICE); - displayManager.registerDisplayListener(displayListener, null); - } catch (Exception e) { - e.printStackTrace(); - } - m_mainLib = QtNative.loadMainLibrary(m_mainLib, nativeLibsDir); return m_mainLib != null; } @@ -800,7 +847,7 @@ public class QtActivityDelegate m_splashScreenSticky = info.metaData.containsKey("android.app.splash_screen_sticky") && info.metaData.getBoolean("android.app.splash_screen_sticky"); int id = info.metaData.getInt(splashScreenKey); m_splashScreen = new ImageView(m_activity); - m_splashScreen.setImageDrawable(m_activity.getResources().getDrawable(id)); + m_splashScreen.setImageDrawable(m_activity.getResources().getDrawable(id, m_activity.getTheme())); m_splashScreen.setScaleType(ImageView.ScaleType.FIT_XY); m_splashScreen.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); m_layout.addView(m_splashScreen); @@ -922,6 +969,13 @@ public class QtActivityDelegate m_accessibilityDelegate.notifyValueChanged(viewId, value); } + public void notifyScrolledEvent(int viewId) + { + if (m_accessibilityDelegate == null) + return; + m_accessibilityDelegate.notifyScrolledEvent(viewId); + } + public void notifyQtAndroidPluginRunning(boolean running) { m_isPluginRunning = running; @@ -1239,7 +1293,7 @@ public class QtActivityDelegate if (attr.type >= TypedValue.TYPE_FIRST_COLOR_INT && attr.type <= TypedValue.TYPE_LAST_COLOR_INT) { m_activity.getWindow().setBackgroundDrawable(new ColorDrawable(attr.data)); } else { - m_activity.getWindow().setBackgroundDrawable(m_activity.getResources().getDrawable(attr.resourceId)); + m_activity.getWindow().setBackgroundDrawable(m_activity.getResources().getDrawable(attr.resourceId, m_activity.getTheme())); } if (m_dummyView != null) { m_layout.removeView(m_dummyView); diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java b/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java index 123c5bc248..c4864f91c1 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java @@ -48,6 +48,7 @@ import android.util.DisplayMetrics; import android.view.Display; import android.view.View; import android.view.ViewGroup; +import android.view.WindowManager; public class QtLayout extends ViewGroup { @@ -91,16 +92,23 @@ public class QtLayout extends ViewGroup @Override protected void onSizeChanged (int w, int h, int oldw, int oldh) { - DisplayMetrics metrics = new DisplayMetrics(); + Activity activity = (Activity)getContext(); + if (activity == null) + return; + Display display = (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) - ? ((Activity)getContext()).getWindowManager().getDefaultDisplay() - : ((Activity)getContext()).getDisplay(); - display.getMetrics(metrics); + ? activity.getWindowManager().getDefaultDisplay() + : activity.getDisplay(); - if ((metrics.widthPixels > metrics.heightPixels) != (w > h)) { + DisplayMetrics realMetrics = new DisplayMetrics(); + display.getRealMetrics(realMetrics); + DisplayMetrics appMetrics = new DisplayMetrics(); + display.getMetrics(appMetrics); + + if ((realMetrics.widthPixels > realMetrics.heightPixels) != (w > h)) { // This is an intermediate state during display rotation. // The new size is still reported for old orientation, while - // metrics contain sizes for new orientation. Setting + // realMetrics contain sizes for new orientation. Setting // such parameters will produce inconsistent results, so // we just skip them. // We will have another onSizeChanged() with normal values @@ -108,9 +116,21 @@ public class QtLayout extends ViewGroup return; } - QtNative.setApplicationDisplayMetrics(metrics.widthPixels, metrics.heightPixels, w, h, - metrics.xdpi, metrics.ydpi, metrics.scaledDensity, - metrics.density, display.getRefreshRate()); + int appWidthPixels = appMetrics.widthPixels; + int appHeightPixels = appMetrics.heightPixels; + + final int flag = + activity.getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN; + if (flag == WindowManager.LayoutParams.FLAG_FULLSCREEN) { + // immersive mode uses the whole screen + appWidthPixels = realMetrics.widthPixels; + appHeightPixels = realMetrics.heightPixels; + } + + QtNative.setApplicationDisplayMetrics( + realMetrics.widthPixels, realMetrics.heightPixels, + appWidthPixels, appHeightPixels, appMetrics.xdpi, appMetrics.ydpi, + appMetrics.scaledDensity, appMetrics.density, display.getRefreshRate()); int newRotation = display.getRotation(); if (m_ownDisplayRotation != m_activityDisplayRotation @@ -121,8 +141,8 @@ public class QtLayout extends ViewGroup // orientation change now. QtNative.handleOrientationChanged(newRotation, m_nativeOrientation); } - m_ownDisplayRotation = newRotation; + m_ownDisplayRotation = newRotation; if (m_startApplicationRunnable != null) { m_startApplicationRunnable.run(); m_startApplicationRunnable = null; 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 e019797cf6..6cd091aab6 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -126,6 +126,13 @@ public class QtNative } }; + public static boolean isStarted() + { + boolean hasActivity = m_activity != null && m_activityDelegate != null; + boolean hasService = m_service != null && m_serviceDelegate != null; + return m_started && (hasActivity || hasService); + } + private static ClassLoader m_classLoader = null; public static ClassLoader classLoader() { @@ -678,9 +685,10 @@ public class QtNative public static native void quitQtCoreApplication(); public static native void quitQtAndroidPlugin(); public static native void terminateQt(); + public static native boolean updateNativeActivity(); // application methods - private static void quitApp() + public static void quitApp() { runAction(new Runnable() { @Override @@ -690,6 +698,8 @@ public class QtNative m_activity.finish(); if (m_service != null) m_service.stopSelf(); + + m_started = false; } }); } @@ -871,6 +881,11 @@ public class QtNative }); } + private static int getSelectHandleWidth() + { + return m_activityDelegate.getSelectHandleWidth(); + } + private static void updateHandles(final int mode, final int editX, final int editY, @@ -996,6 +1011,18 @@ public class QtNative }); } + private static void notifyScrolledEvent(final int viewId) + { + runAction(new Runnable() { + @Override + public void run() { + if (m_activityDelegate != null) { + m_activityDelegate.notifyScrolledEvent(viewId); + } + } + }); + } + public static void notifyQtAndroidPluginRunning(final boolean running) { m_activityDelegate.notifyQtAndroidPluginRunning(running); diff --git a/src/android/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java index 3b910e288d..68ae9806ab 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java @@ -43,6 +43,7 @@ package org.qtproject.qt5.android.accessibility; import android.accessibilityservice.AccessibilityService; import android.app.Activity; import android.graphics.Rect; +import android.os.Build; import android.os.Bundle; import android.util.Log; import android.view.View; @@ -51,6 +52,7 @@ import android.view.ViewParent; import android.text.TextUtils; import android.view.accessibility.*; +import android.view.accessibility.AccessibilityNodeInfo.CollectionInfo; import android.view.MotionEvent; import android.view.View.OnHoverListener; @@ -193,6 +195,11 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate return true; } + public void notifyScrolledEvent(int viewId) + { + sendEventForVirtualViewId(viewId, AccessibilityEvent.TYPE_VIEW_SCROLLED); + } + public void notifyLocationChange(int viewId) { if (m_focusedVirtualViewId == viewId) @@ -255,10 +262,14 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate public boolean sendEventForVirtualViewId(int virtualViewId, int eventType) { - if ((virtualViewId == INVALID_ID) || !m_manager.isEnabled()) { - Log.w(TAG, "sendEventForVirtualViewId for invalid view"); + final AccessibilityEvent event = getEventForVirtualViewId(virtualViewId, eventType); + return sendAccessibilityEvent(event); + } + + public boolean sendAccessibilityEvent(AccessibilityEvent event) + { + if (event == null) return false; - } final ViewGroup group = (ViewGroup) m_view.getParent(); if (group == null) { @@ -266,15 +277,18 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate return false; } - final AccessibilityEvent event; - event = getEventForVirtualViewId(virtualViewId, eventType); return group.requestSendAccessibilityEvent(m_view, event); } public void invalidateVirtualViewId(int virtualViewId) { - if (virtualViewId != INVALID_ID) - sendEventForVirtualViewId(virtualViewId, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); + final AccessibilityEvent event = getEventForVirtualViewId(virtualViewId, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); + + if (event == null) + return; + + event.setContentChangeTypes(AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE); + sendAccessibilityEvent(event); } private void setHoveredVirtualViewId(int virtualViewId) @@ -291,6 +305,14 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate private AccessibilityEvent getEventForVirtualViewId(int virtualViewId, int eventType) { + if ((virtualViewId == INVALID_ID) || !m_manager.isEnabled()) { + Log.w(TAG, "getEventForVirtualViewId for invalid view"); + return null; + } + + if (m_activityDelegate.getSurfaceCount() == 0) + return null; + final AccessibilityEvent event = AccessibilityEvent.obtain(eventType); event.setEnabled(true); @@ -353,9 +375,11 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate // Spit out the entire hierarchy for debugging purposes // dumpNodes(-1); - int[] ids = QtNativeAccessibility.childIdListForAccessibleObject(-1); - for (int i = 0; i < ids.length; ++i) - result.addChild(m_view, ids[i]); + if (m_activityDelegate.getSurfaceCount() != 0) { + int[] ids = QtNativeAccessibility.childIdListForAccessibleObject(-1); + for (int i = 0; i < ids.length; ++i) + result.addChild(m_view, ids[i]); + } // The offset values have changed, so we need to re-focus the // currently focused item, otherwise it will have an incorrect @@ -383,8 +407,9 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate node.setClassName(m_view.getClass().getName() + DEFAULT_CLASS_NAME); node.setPackageName(m_view.getContext().getPackageName()); - if (!QtNativeAccessibility.populateNode(virtualViewId, node)) + if (m_activityDelegate.getSurfaceCount() == 0 || !QtNativeAccessibility.populateNode(virtualViewId, node)) { return node; + } // set only if valid, otherwise we return a node that is invalid and will crash when accessed node.setSource(m_view, virtualViewId); @@ -418,6 +443,13 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate int[] ids = QtNativeAccessibility.childIdListForAccessibleObject(virtualViewId); for (int i = 0; i < ids.length; ++i) node.addChild(m_view, ids[i]); + if (node.isScrollable()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + node.setCollectionInfo(new CollectionInfo(ids.length, 1, false)); + } else { + node.setCollectionInfo(CollectionInfo.obtain(ids.length, 1, false)); + } + } return node; } @@ -427,7 +459,7 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate @Override public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) { - if (virtualViewId == View.NO_ID) { + if (virtualViewId == View.NO_ID || m_activityDelegate.getSurfaceCount() == 0) { return getNodeForView(); } return getNodeForVirtualViewId(virtualViewId); |