summaryrefslogtreecommitdiffstats
path: root/src/android/jar
diff options
context:
space:
mode:
authorTinja Paavoseppä <tinja.paavoseppa@qt.io>2024-02-07 10:53:36 +0200
committerTinja Paavoseppä <tinja.paavoseppa@qt.io>2024-02-12 08:50:53 +0200
commit3dad99a43ed3ae936d5f47ff0cf4db78260e91d2 (patch)
tree4cee79a93f2c1706c6e972dae0733317c77552ff /src/android/jar
parent84537e6dc22030004c2aec7285641e721da627cf (diff)
Revert "Android: Make QtWindow wrap the QtLayout instead of inherit it"
This reverts commit 2bc7d38bd63843c4598ed501e3adbf0e39162c61. The real cause for the problems was the missing runAction() in bringChildToFront(), creating the QtLayout could still be done in Qt thread without problems, just as long as its hierarchy is not changed outside of Android UI thread. Let QtWindow extend QtLayout again - the missing runAction() causing problems is added back in a follow up commit. Task-number: QTBUG-116187 Pick-to: 6.7 Change-Id: Ib4211c40adf573f9f6dd6300b275cff0ce718fba Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/android/jar')
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java12
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtView.java8
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/QtWindow.java69
3 files changed, 38 insertions, 51 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 513207e4a0..fb2770bfe7 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java
@@ -317,11 +317,11 @@ class QtActivityDelegate extends QtActivityDelegateBase
}
}
- window.getLayout().setLayoutParams(new ViewGroup.LayoutParams(
+ window.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
- m_layout.addView(window.getLayout(), m_topLevelWindows.size());
+ m_layout.addView(window, m_topLevelWindows.size());
m_topLevelWindows.put(window.getId(), window);
if (!m_splashScreenSticky)
hideSplashScreen();
@@ -338,9 +338,9 @@ class QtActivityDelegate extends QtActivityDelegateBase
if (m_topLevelWindows.isEmpty()) {
// Keep last frame in stack until it is replaced to get correct
// shutdown transition
- m_dummyView = window.getLayout();
+ m_dummyView = window;
} else {
- m_layout.removeView(window.getLayout());
+ m_layout.removeView(window);
}
}
});
@@ -353,7 +353,7 @@ class QtActivityDelegate extends QtActivityDelegateBase
QtNative.runAction(() -> {
QtWindow window = m_topLevelWindows.get(id);
if (window != null)
- m_layout.moveChild(window.getLayout(), m_topLevelWindows.size() - 1);
+ m_layout.moveChild(window, m_topLevelWindows.size() - 1);
});
}
@@ -364,7 +364,7 @@ class QtActivityDelegate extends QtActivityDelegateBase
QtNative.runAction(() -> {
QtWindow window = m_topLevelWindows.get(id);
if (window != null)
- m_layout.moveChild(window.getLayout(), 0);
+ m_layout.moveChild(window, 0);
});
}
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtView.java b/src/android/jar/src/org/qtproject/qt/android/QtView.java
index a140bfa606..9a43b8aa74 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtView.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtView.java
@@ -109,10 +109,10 @@ abstract class QtView extends QtLayout {
@Override
public void run() {
m_window = window;
- m_window.getLayout().setLayoutParams(new QtLayout.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT));
- addView(m_window.getLayout(), 0);
+ m_window.setLayoutParams(new QtLayout.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT));
+ addView(m_window, 0);
// Call show window + parent
setWindowVisible(true);
if (m_windowListener != null)
diff --git a/src/android/jar/src/org/qtproject/qt/android/QtWindow.java b/src/android/jar/src/org/qtproject/qt/android/QtWindow.java
index 4f27532c0d..43dd094a7d 100644
--- a/src/android/jar/src/org/qtproject/qt/android/QtWindow.java
+++ b/src/android/jar/src/org/qtproject/qt/android/QtWindow.java
@@ -13,24 +13,23 @@ import android.view.ViewGroup;
import java.util.HashMap;
-public class QtWindow implements QtSurfaceInterface, QtLayout.QtTouchListener {
+public class QtWindow extends QtLayout implements QtSurfaceInterface {
private final static String TAG = "QtWindow";
private View m_surfaceContainer;
- private QtLayout m_layout;
private View m_nativeView;
private HashMap<Integer, QtWindow> m_childWindows = new HashMap<Integer, QtWindow>();
private QtWindow m_parentWindow;
- private int m_id;
private GestureDetector m_gestureDetector;
private static native void setSurface(int windowId, Surface surface);
public QtWindow(Context context, QtWindow parentWindow)
{
- m_id = View.generateViewId();
- m_layout = new QtLayout(context, this);
+ super(context);
+ setId(View.generateViewId());
setParent(parentWindow);
+
QtNative.runAction(() -> {
m_gestureDetector =
new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@@ -45,22 +44,12 @@ public class QtWindow implements QtSurfaceInterface, QtLayout.QtTouchListener {
void setVisible(boolean visible) {
QtNative.runAction(() -> {
if (visible)
- m_layout.setVisibility(View.VISIBLE);
+ setVisibility(View.VISIBLE);
else
- m_layout.setVisibility(View.INVISIBLE);
+ setVisibility(View.INVISIBLE);
});
}
- public int getId()
- {
- return m_id;
- }
-
- public QtLayout getLayout()
- {
- return m_layout;
- }
-
@Override
public void onSurfaceChanged(Surface surface)
{
@@ -103,21 +92,21 @@ public class QtWindow implements QtSurfaceInterface, QtLayout.QtTouchListener {
@Override
public void run() {
if (m_surfaceContainer != null)
- m_layout.removeView(m_surfaceContainer);
+ removeView(m_surfaceContainer);
- m_layout.setLayoutParams(new QtLayout.LayoutParams(w, h, x, y));
+ setLayoutParams(new QtLayout.LayoutParams(w, h, x, y));
if (surfaceContainerType == 0) {
- m_surfaceContainer = new QtSurface(m_layout.getContext(), QtWindow.this,
+ m_surfaceContainer = new QtSurface(getContext(), QtWindow.this,
onTop, imageDepth);
} else {
- m_surfaceContainer = new QtTextureView(m_layout.getContext(), QtWindow.this, isOpaque);
+ m_surfaceContainer = new QtTextureView(getContext(), QtWindow.this, isOpaque);
}
m_surfaceContainer.setLayoutParams(new QtLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
// The surface container of this window will be added as the first of the stack.
// All other views are stacked based on the order they are created.
- m_layout.addView(m_surfaceContainer, 0);
+ addView(m_surfaceContainer, 0);
}
});
}
@@ -128,7 +117,7 @@ public class QtWindow implements QtSurfaceInterface, QtLayout.QtTouchListener {
@Override
public void run() {
if (m_surfaceContainer != null) {
- m_layout.removeView(m_surfaceContainer);
+ removeView(m_surfaceContainer);
m_surfaceContainer = null;
}
}
@@ -140,8 +129,8 @@ public class QtWindow implements QtSurfaceInterface, QtLayout.QtTouchListener {
QtNative.runAction(new Runnable() {
@Override
public void run() {
- if (m_layout.getContext() instanceof QtActivityBase)
- m_layout.setLayoutParams(new QtLayout.LayoutParams(w, h, x, y));
+ if (getContext() instanceof QtActivityBase)
+ setLayoutParams(new QtLayout.LayoutParams(w, h, x, y));
}
});
}
@@ -152,7 +141,7 @@ public class QtWindow implements QtSurfaceInterface, QtLayout.QtTouchListener {
@Override
public void run() {
m_childWindows.put(window.getId(), window);
- m_layout.addView(window.getLayout(), m_layout.getChildCount());
+ addView(window, getChildCount());
}
});
}
@@ -163,7 +152,7 @@ public class QtWindow implements QtSurfaceInterface, QtLayout.QtTouchListener {
@Override
public void run() {
if (m_childWindows.containsKey(id))
- m_layout.removeView(m_childWindows.remove(id).getLayout());
+ removeView(m_childWindows.remove(id));
}
});
}
@@ -175,35 +164,33 @@ public class QtWindow implements QtSurfaceInterface, QtLayout.QtTouchListener {
@Override
public void run() {
if (m_nativeView != null)
- m_layout.removeView(m_nativeView);
+ removeView(m_nativeView);
m_nativeView = view;
- m_layout.setLayoutParams(new QtLayout.LayoutParams(w, h, x, y));
+ QtWindow.this.setLayoutParams(new QtLayout.LayoutParams(w, h, x, y));
m_nativeView.setLayoutParams(new QtLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
- m_layout.addView(m_nativeView);
+ addView(m_nativeView);
}
});
}
public void bringChildToFront(int id)
{
- QtNative.runAction(()-> {
- QtWindow window = m_childWindows.get(id);
- if (window != null) {
- if (m_layout.getChildCount() > 0)
- m_layout.moveChild(window.getLayout(), m_layout.getChildCount() - 1);
- }
- });
+ View view = m_childWindows.get(id);
+ if (view != null) {
+ if (getChildCount() > 0)
+ moveChild(view, getChildCount() - 1);
+ }
}
public void bringChildToBack(int id) {
QtNative.runAction(new Runnable() {
@Override
public void run() {
- QtWindow window = m_childWindows.get(id);
- if (window != null) {
- m_layout.moveChild(window.getLayout(), 0);
+ View view = m_childWindows.get(id);
+ if (view != null) {
+ moveChild(view, 0);
}
}
});
@@ -215,7 +202,7 @@ public class QtWindow implements QtSurfaceInterface, QtLayout.QtTouchListener {
@Override
public void run() {
if (m_nativeView != null) {
- m_layout.removeView(m_nativeView);
+ removeView(m_nativeView);
m_nativeView = null;
}
}