From 8b0d9a16db7bcfb5d6439b8863aded5c583f9ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Thu, 28 Aug 2014 12:18:14 +0200 Subject: Android: Improve the foreign-window implementation Adds: - Improved geometry calculations (e.g, inside a parent) - Change visibility - proper stacking order. Native views now reserve the top of the stack to ensure that they stay visible. - React to application state changes. Change-Id: I35de0396937fff37ffcd272c9a7d8e9873a91dfb Reviewed-by: Paul Olav Tvete --- .../jar/src/org/qtproject/qt5/android/QtActivityDelegate.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/android') 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 db970b6656..9507d7eb3b 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -1025,8 +1025,8 @@ public class QtActivityDelegate view.setLayoutParams(new QtLayout.LayoutParams(w, h, x, y)); } + view.setId(id); m_layout.addView(view); - m_layout.bringChildToFront(view); m_nativeViews.put(id, view); } @@ -1057,9 +1057,11 @@ public class QtActivityDelegate surface.setLayoutParams( new QtLayout.LayoutParams(w, h, x, y)); } - m_layout.addView(surface); - if (onTop) - m_layout.bringChildToFront(surface); + // Native views are always inserted in the end of the stack (i.e., on top). + // All other views are stacked based on the order they are created. + final int index = m_layout.getChildCount() - m_nativeViews.size() - 1; + m_layout.addView(surface, index < 0 ? 0 : index); + m_surfaces.put(id, surface); } @@ -1070,7 +1072,6 @@ public class QtActivityDelegate } else if (m_nativeViews.containsKey(id)) { View view = m_nativeViews.get(id); view.setLayoutParams(new QtLayout.LayoutParams(w, h, x, y)); - m_layout.bringChildToFront(view); } else { Log.e(QtNative.QtTAG, "Surface " + id +" not found!"); return; -- cgit v1.2.3