Request embedded focus if a SurfacePackage was added to SV
If the SV was already focus when a SurfacePackage is attached, it should request focus to the embedded. This allows focus to work better for the developer perspective since they don't have to understand the timing of when a SurfacePackage is attached vs when a view gains focus. Test: SurfaceControlViewHostTests Bug: 230340812 Change-Id: If55b33e92769e37794bd258e7f41da40decbef8c
This commit is contained in:
@@ -1854,6 +1854,10 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
|
||||
applyTransactionOnVriDraw(transaction);
|
||||
}
|
||||
mSurfacePackage = p;
|
||||
|
||||
if (isFocused()) {
|
||||
requestEmbeddedFocus(true);
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@@ -1947,8 +1951,12 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
|
||||
|
||||
@Override
|
||||
protected void onFocusChanged(boolean gainFocus, @FocusDirection int direction,
|
||||
@Nullable Rect previouslyFocusedRect) {
|
||||
@Nullable Rect previouslyFocusedRect) {
|
||||
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
|
||||
requestEmbeddedFocus(gainFocus);
|
||||
}
|
||||
|
||||
private void requestEmbeddedFocus(boolean gainFocus) {
|
||||
final ViewRootImpl viewRoot = getViewRootImpl();
|
||||
if (mSurfacePackage == null || viewRoot == null) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user