Make sure that created surfaces are stacked on top of previous ones.

The old code would stack the new surface just below the topmost surface.
It also did not consider if the m_editText was added to the layout or
not (thus, m_layout.getChildCount() - m_nativeViews.size() - 1) was only
correct if the editText was added.

Spotted by plain code reading while investigating some accessiblity
issues.

Change-Id: I12c9f373a471c0a7ee624a47232e8952d69c9067
Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
This commit is contained in:
Jan Arve Saether 2014-11-13 14:41:03 +01:00 committed by Jan Arve Sæther
parent afae4ee0b1
commit 438b65bada

View File

@ -1179,8 +1179,8 @@ public class QtActivityDelegate
// 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);
final int index = getSurfaceCount();
m_layout.addView(surface, index);
m_surfaces.put(id, surface);
}
@ -1221,12 +1221,19 @@ public class QtActivityDelegate
}
}
public int getSurfaceCount()
{
return m_surfaces.size();
}
public void bringChildToFront(int id)
{
View view = m_surfaces.get(id);
if (view != null) {
final int index = m_layout.getChildCount() - m_nativeViews.size() - 1;
m_layout.moveChild(view, index < 0 ? 0 : index);
final int surfaceCount = getSurfaceCount();
if (surfaceCount > 0)
m_layout.moveChild(view, surfaceCount - 1);
return;
}
@ -1245,7 +1252,7 @@ public class QtActivityDelegate
view = m_nativeViews.get(id);
if (view != null) {
final int index = m_layout.getChildCount() - m_nativeViews.size();
final int index = getSurfaceCount();
m_layout.moveChild(view, index);
}
}