Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1bfce9fb authored by Jae Seo's avatar Jae Seo Committed by Dongwon Kang
Browse files

TIF: Address the feedback from the API review - 3/3

- Change TvView to be a generic ViewGroup with a single SurfaceView child

Bug: 15345342
Change-Id: I86ed94b7020aabb6e093e391ab9477c1f801919a
parent acb119f0
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -15968,11 +15968,12 @@ package android.media.tv {
    method public void setOverlayViewEnabled(boolean);
    method public void setOverlayViewEnabled(boolean);
  }
  }
  public class TvView extends android.view.SurfaceView {
  public class TvView extends android.view.ViewGroup {
    ctor public TvView(android.content.Context);
    ctor public TvView(android.content.Context);
    ctor public TvView(android.content.Context, android.util.AttributeSet);
    ctor public TvView(android.content.Context, android.util.AttributeSet);
    ctor public TvView(android.content.Context, android.util.AttributeSet, int);
    ctor public TvView(android.content.Context, android.util.AttributeSet, int);
    method public boolean dispatchUnhandledInputEvent(android.view.InputEvent);
    method public boolean dispatchUnhandledInputEvent(android.view.InputEvent);
    method protected void onLayout(boolean, int, int, int, int);
    method public boolean onUnhandledInputEvent(android.view.InputEvent);
    method public boolean onUnhandledInputEvent(android.view.InputEvent);
    method public void reset();
    method public void reset();
    method public void setOnUnhandledInputEventListener(android.media.tv.TvView.OnUnhandledInputEventListener);
    method public void setOnUnhandledInputEventListener(android.media.tv.TvView.OnUnhandledInputEventListener);
+30 −6
Original line number Original line Diff line number Diff line
@@ -33,12 +33,13 @@ import android.view.MotionEvent;
import android.view.Surface;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.SurfaceView;
import android.view.ViewGroup;
import android.view.ViewRootImpl;
import android.view.ViewRootImpl;


/**
/**
 * View playing TV
 * View playing TV
 */
 */
public class TvView extends SurfaceView {
public class TvView extends ViewGroup {
    private static final String TAG = "TvView";
    private static final String TAG = "TvView";
    // STOPSHIP: Turn debugging off.
    // STOPSHIP: Turn debugging off.
    private static final boolean DEBUG = true;
    private static final boolean DEBUG = true;
@@ -57,6 +58,7 @@ public class TvView extends SurfaceView {


    private final Handler mHandler = new Handler();
    private final Handler mHandler = new Handler();
    private TvInputManager.Session mSession;
    private TvInputManager.Session mSession;
    private final SurfaceView mSurfaceView;
    private Surface mSurface;
    private Surface mSurface;
    private boolean mOverlayViewCreated;
    private boolean mOverlayViewCreated;
    private Rect mOverlayViewFrame;
    private Rect mOverlayViewFrame;
@@ -122,7 +124,14 @@ public class TvView extends SurfaceView {


    public TvView(Context context, AttributeSet attrs, int defStyleAttr) {
    public TvView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        super(context, attrs, defStyleAttr);
        getHolder().addCallback(mSurfaceHolderCallback);
        mSurfaceView = new SurfaceView(context, attrs, defStyleAttr) {
                @Override
                protected void updateWindow(boolean force, boolean redrawNeeded) {
                    super.updateWindow(force, redrawNeeded);
                    relayoutSessionOverlayView();
                }};
        mSurfaceView.getHolder().addCallback(mSurfaceHolderCallback);
        addView(mSurfaceView);
        mTvInputManager = (TvInputManager) getContext().getSystemService(Context.TV_INPUT_SERVICE);
        mTvInputManager = (TvInputManager) getContext().getSystemService(Context.TV_INPUT_SERVICE);
    }
    }


@@ -305,11 +314,26 @@ public class TvView extends SurfaceView {
        super.onDetachedFromWindow();
        super.onDetachedFromWindow();
    }
    }


    /** @hide */
    @Override
    @Override
    protected void updateWindow(boolean force, boolean redrawNeeded) {
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.updateWindow(force, redrawNeeded);
        mSurfaceView.layout(0, 0, right - left, bottom - top);
        relayoutSessionOverlayView();
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        mSurfaceView.measure(widthMeasureSpec, heightMeasureSpec);
        int width = mSurfaceView.getMeasuredWidth();
        int height = mSurfaceView.getMeasuredHeight();
        int childState = mSurfaceView.getMeasuredState();
        setMeasuredDimension(resolveSizeAndState(width, widthMeasureSpec, childState),
                resolveSizeAndState(height, heightMeasureSpec,
                        childState << MEASURED_HEIGHT_STATE_SHIFT));
    }

    @Override
    public void setVisibility(int visibility) {
        super.setVisibility(visibility);
        mSurfaceView.setVisibility(visibility);
    }
    }


    private void release() {
    private void release() {