From aa06466863edf27a006bff902ef3e51626b49890 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Fri, 28 Jan 2022 13:29:32 +0100 Subject: [Android]: Handle the screen name, modes and refreshRate properly Fixes: QTBUG-87136 Fixes: QTBUG-93823 Fixes: QTBUG-94959 Change-Id: Id480e22611ec949b5e3ee780fc695fb502a5950c Reviewed-by: Assam Boudjelthia (cherry picked from commit c1a93b20ff1fec370b2483276b74f07eb54486ef) --- .../src/org/qtproject/qt5/android/QtActivityDelegate.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java') 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 16f3ea0c4d..0bb66b8a2d 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -69,6 +69,7 @@ import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; +import android.view.Display; import android.view.KeyCharacterMap; import android.view.KeyEvent; import android.view.Menu; @@ -677,8 +678,13 @@ public class QtActivityDelegate @Override public void onDisplayChanged(int displayId) { - m_currentRotation = m_activity.getWindowManager().getDefaultDisplay().getRotation(); + Display display = (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) + ? m_activity.getWindowManager().getDefaultDisplay() + : m_activity.getDisplay(); + m_currentRotation = display.getRotation(); QtNative.handleOrientationChanged(m_currentRotation, m_nativeOrientation); + float refreshRate = display.getRefreshRate(); + QtNative.handleRefreshRateChanged(refreshRate); } @Override @@ -809,6 +815,11 @@ public class QtActivityDelegate QtNative.handleOrientationChanged(rotation, m_nativeOrientation); m_currentRotation = rotation; + float refreshRate = (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) + ? m_activity.getWindowManager().getDefaultDisplay().getRefreshRate() + : m_activity.getDisplay().getRefreshRate(); + QtNative.handleRefreshRateChanged(refreshRate); + m_layout.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { -- cgit v1.2.3 From 73792bceef721e890c8655249412f9e26db94691 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Thu, 10 Feb 2022 10:33:48 +0100 Subject: Android: extract parentId for hidden object in advance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit amends 850a7f1238e84b6960a84e12687e40cf939a44d9. We can't extract the parentId for the hidden object on Java side, because the Java call is executed in a separate thread, so the original hidden object can be destroyed somewhere in the middle of parentId() call. As a workaround, we get the parentId in advance, on C++ side, and pass it as a parameter to JNI function. Task-number: QTBUG-95764 Change-Id: Ied2ab4ab39b947f3f582575cf77cc76fbac9e274 Reviewed-by: Jarkko Koivikko Reviewed-by: Jan Arve Sæther Reviewed-by: Rami Potinkara Reviewed-by: Assam Boudjelthia (cherry picked from commit 6d00aac1092d813446a44fbb234995733233f003) --- src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java') 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 0bb66b8a2d..21b6f8f0e4 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -886,11 +886,11 @@ public class QtActivityDelegate m_accessibilityDelegate.notifyLocationChange(); } - public void notifyObjectHide(int viewId) + public void notifyObjectHide(int viewId, int parentId) { if (m_accessibilityDelegate == null) return; - m_accessibilityDelegate.notifyObjectHide(viewId); + m_accessibilityDelegate.notifyObjectHide(viewId, parentId); } public void notifyObjectFocus(int viewId) -- cgit v1.2.3 From f546e3e7c98f1aced03ebf1f467ac1a04c579824 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Thu, 10 Feb 2022 11:53:24 +0100 Subject: Android A11Y: handle valueChanged events Before this patch Android A11Y implementation was missing ValueChanged event handling. As a result, no update was given when the element's value was changed. Handling these events allows us to announce value changes on such objects like Slider, SpinBox, etc... This is a universal method of value-change announcement, so it supports all sorts of A11Y gestures. On the Java side a new function was introduced to announce the values, because we need to use the actual element's *value*, not its accessible name or description. Task-number: QTBUG-93396 Change-Id: Ic44abd5f01b9b6f5468962131466edaf6a49d498 Reviewed-by: Assam Boudjelthia Reviewed-by: Rami Potinkara (cherry picked from commit b238f83380dcaa2830999a8f413f4b648db80beb) --- .../jar/src/org/qtproject/qt5/android/QtActivityDelegate.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java') 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 21b6f8f0e4..f7e97930ae 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -900,6 +900,13 @@ public class QtActivityDelegate m_accessibilityDelegate.notifyObjectFocus(viewId); } + public void notifyValueChanged(int viewId, String value) + { + if (m_accessibilityDelegate == null) + return; + m_accessibilityDelegate.notifyValueChanged(viewId, value); + } + public void notifyQtAndroidPluginRunning(boolean running) { m_isPluginRunning = running; -- cgit v1.2.3 From a9c5dd09215e5806a57b01c7c4fab366860f15f2 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Wed, 23 Feb 2022 18:26:09 +0100 Subject: Android: make sure that orientationChange is reported after resize On Android orientation changes are reported from the DisplayListener.onDisplayChanged() method, while the screen size changes are reported from QtLayout.onSizeChanged(). In practice these callbacks come in random order, so rotating the screen multiple times might result in inconsistent order of signals and events. This patch makes sure that size change events always happen before orientation changes. This is done by caching the new orientation values and reporting them only when needed. At this point we also need to use QMetaObject::invokeMethod() for orientation change, like it is done for geometry change. Otherwise the orientation update can still be processed earlier than the geometry change. Also note that at some point we might get an orientation change without a size change (for example Qt::LandscapeOrientation -> Qt::InvertedLandscapeOrientation). That is the reason for isSimilarRotation() helper function. As a drive-by: ignore size changes with inconsistent values when window size is reported to have old orientation, while the screen has already been rotated. In such cases a new size change will be triggered shortly with normal value. Task-number: QTBUG-94459 Change-Id: I5c98e526d0370d380344b2297169d5e0c0ee8ea7 Reviewed-by: Assam Boudjelthia (cherry picked from commit 79fb80152ff29a30faa3f0cce79a602e36cadbeb) --- .../org/qtproject/qt5/android/QtActivityDelegate.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java') 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 f7e97930ae..9f7c040c17 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2017 BogDan Vatra -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Copyright (C) 2016 Olivier Goffart ** Contact: https://www.qt.io/licensing/ ** @@ -676,13 +676,27 @@ public class QtActivityDelegate @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(); - QtNative.handleOrientationChanged(m_currentRotation, m_nativeOrientation); + 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); } @@ -812,6 +826,7 @@ public class QtActivityDelegate else m_nativeOrientation = Configuration.ORIENTATION_PORTRAIT; + m_layout.setNativeOrientation(m_nativeOrientation); QtNative.handleOrientationChanged(rotation, m_nativeOrientation); m_currentRotation = rotation; -- cgit v1.2.3