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 0a92d881bb.
Pick-to: 6.7
Change-Id: Ia00407d827ca9217c9f49df55b4cf7001ac9871a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
bb10
parent
296ede3aab
commit
b42f174cd5
|
|
@ -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!");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue