Merge "Fix ActivityView surface can't visible for ActivityViewTest"

This commit is contained in:
TreeHugger Robot
2019-08-06 21:22:22 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 3 deletions

View File

@@ -120,8 +120,10 @@ public class ActivityView extends ViewGroup {
mActivityTaskManager = ActivityTaskManager.getService();
mSurfaceView = new SurfaceView(context);
// Since ActivityView#getAlpha has been overridden, we should use parent class's alpha
// as master to synchronize surface view's alpha value.
mSurfaceView.setAlpha(super.getAlpha());
mSurfaceView.setUseAlpha();
mSurfaceView.setAlpha(0f);
mSurfaceCallback = new SurfaceCallback();
mSurfaceView.getHolder().addCallback(mSurfaceCallback);
addView(mSurfaceView);
@@ -348,9 +350,20 @@ public class ActivityView extends ViewGroup {
mSurfaceView.layout(0 /* left */, 0 /* top */, r - l /* right */, b - t /* bottom */);
}
/**
* Sets the alpha value when the content of {@link SurfaceView} needs to show or hide.
* <p>Note: The surface view may ignore the alpha value in some cases. Refer to
* {@link SurfaceView#setAlpha} for more details.
*
* @param alpha The opacity of the view.
*/
@Override
public void setAlpha(float alpha) {
mSurfaceView.setAlpha(alpha);
super.setAlpha(alpha);
if (mSurfaceView != null) {
mSurfaceView.setAlpha(alpha);
}
}
@Override

View File

@@ -182,7 +182,7 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
mActivityView = new ActivityView(mContext, null /* attrs */, 0 /* defStyle */,
true /* singleTaskInstance */);
// Set ActivityView's alpha value as zero, since there is no view content to be shown.
setContentVisibility(false);
addView(mActivityView);