summaryrefslogtreecommitdiffstats
path: root/src/android/jar/src/org/qtproject
diff options
context:
space:
mode:
authorSoheil Armin <soheil.armin@qt.io>2024-02-20 18:35:34 +0200
committerSoheil Armin <soheil.armin@qt.io>2024-02-28 15:05:02 +0200
commitb42f174cd5be2014ae74453ab2d09742cc83fc36 (patch)
tree2a42f85b3e489664ef803a064cb85919f4723772 /src/android/jar/src/org/qtproject
parent296ede3aab2c0cc1acd28a2adb3017ac74d7ed6b (diff)
Android: Bring back QtActivityDelegate.insertNativeView()
Temporarily bring back the QtActivityDelegate.insertNativeView() and QtActivityDelegate.setNativeViewGeometry() (replacement for setSurfaceGeometry()) as they are still in use by the ActivityView module of QtAndroidAutomotive. They have been removed by 0a92d881bb91d3ff14187e7838af1cad9ad1070c. Pick-to: 6.7 Change-Id: Ia00407d827ca9217c9f49df55b4cf7001ac9871a Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/android/jar/src/org/qtproject')
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java
index 482ad2abd5..717cd079a4 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java
@@ -42,6 +42,7 @@ class QtActivityDelegate extends QtActivityDelegateBase
private boolean m_splashScreenSticky = false;
private View m_dummyView = null;
+ private HashMap<Integer, View> m_nativeViews = new HashMap<Integer, View>();
QtActivityDelegate(Activity activity)
@@ -400,4 +401,44 @@ class QtActivityDelegate extends QtActivityDelegateBase
m_activity.getWindow().setBackgroundDrawable(backgroundDrawable);
}
+
+ // TODO: QTBUG-122761 To be removed after QtAndroidAutomotive does not depend on it.
+ @UsedFromNativeCode
+ public void insertNativeView(int id, View view, int x, int y, int w, int h)
+ {
+ QtNative.runAction(()-> {
+ if (m_dummyView != null) {
+ m_layout.removeView(m_dummyView);
+ m_dummyView = null;
+ }
+
+ if (m_nativeViews.containsKey(id))
+ m_layout.removeView(m_nativeViews.remove(id));
+
+ if (w < 0 || h < 0) {
+ view.setLayoutParams(new ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+ } else {
+ view.setLayoutParams(new QtLayout.LayoutParams(w, h, x, y));
+ }
+
+ view.setId(id);
+ m_layout.addView(view);
+ m_nativeViews.put(id, view);
+ });
+ }
+
+ // TODO: QTBUG-122761 To be removed after QtAndroidAutomotive does not depend on it.
+ @UsedFromNativeCode
+ public void setNativeViewGeometry(int id, int x, int y, int w, int h)
+ {
+ QtNative.runAction(() -> {
+ if (m_nativeViews.containsKey(id)) {
+ View view = m_nativeViews.get(id);
+ view.setLayoutParams(new QtLayout.LayoutParams(w, h, x, y));
+ } else {
+ Log.e(QtTAG, "View " + id + " not found!");
+ }
+ });
+ }
}