Merge "TvPiP: Move focus changes to pip controller" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b031e08104
@@ -33,6 +33,7 @@ import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceControl;
|
||||
import android.view.SyncRtSurfaceTransactionApplier;
|
||||
import android.view.WindowManagerGlobal;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@@ -143,7 +144,6 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis
|
||||
mSystemWindows.addView(mPipMenuView,
|
||||
getPipMenuLayoutParams(MENU_WINDOW_TITLE, 0 /* width */, 0 /* height */),
|
||||
0, SHELL_ROOT_LAYER_PIP);
|
||||
mPipMenuView.setFocusGrantToken(mSystemWindows.getFocusGrantToken(mPipMenuView));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,6 +164,7 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis
|
||||
t.setPosition(menuSurfaceControl, menuBounds.left, menuBounds.top);
|
||||
t.apply();
|
||||
}
|
||||
grantPipMenuFocus(true);
|
||||
mPipMenuView.show(mInMoveMode, mDelegate.getPipGravity());
|
||||
}
|
||||
}
|
||||
@@ -194,8 +195,9 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis
|
||||
if (DEBUG) Log.d(TAG, "hideMenu()");
|
||||
}
|
||||
|
||||
mPipMenuView.hide(mInMoveMode);
|
||||
mPipMenuView.hide();
|
||||
if (!mInMoveMode) {
|
||||
grantPipMenuFocus(false);
|
||||
mDelegate.closeMenu();
|
||||
}
|
||||
}
|
||||
@@ -453,4 +455,15 @@ public class TvPipMenuController implements PipMenuController, TvPipMenuView.Lis
|
||||
|
||||
void closePip();
|
||||
}
|
||||
|
||||
private void grantPipMenuFocus(boolean grantFocus) {
|
||||
if (DEBUG) Log.d(TAG, "grantWindowFocus(" + grantFocus + ")");
|
||||
|
||||
try {
|
||||
WindowManagerGlobal.getWindowSession().grantEmbeddedWindowFocus(null /* window */,
|
||||
mSystemWindows.getFocusGrantToken(mPipMenuView), grantFocus);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Unable to update focus", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.app.RemoteAction;
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
@@ -39,7 +38,6 @@ import android.view.SurfaceControl;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewRootImpl;
|
||||
import android.view.WindowManagerGlobal;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
@@ -72,7 +70,6 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener {
|
||||
private final ImageView mArrowRight;
|
||||
private final ImageView mArrowDown;
|
||||
private final ImageView mArrowLeft;
|
||||
private IBinder mFocusGrantToken = null;
|
||||
|
||||
private final ViewGroup mScrollView;
|
||||
private final ViewGroup mHorizontalScrollView;
|
||||
@@ -152,10 +149,6 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
void setFocusGrantToken(IBinder token) {
|
||||
mFocusGrantToken = token;
|
||||
}
|
||||
|
||||
void setExpandedModeEnabled(boolean enabled) {
|
||||
mExpandButton.setVisibility(enabled ? VISIBLE : GONE);
|
||||
}
|
||||
@@ -170,8 +163,6 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener {
|
||||
|
||||
void show(boolean inMoveMode, int gravity) {
|
||||
if (DEBUG) Log.d(TAG, "show(), inMoveMode: " + inMoveMode);
|
||||
grantWindowFocus(true);
|
||||
|
||||
if (inMoveMode) {
|
||||
showMovementHints(gravity);
|
||||
} else {
|
||||
@@ -180,15 +171,11 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener {
|
||||
animateAlphaTo(1, mMenuFrameView);
|
||||
}
|
||||
|
||||
void hide(boolean isInMoveMode) {
|
||||
void hide() {
|
||||
if (DEBUG) Log.d(TAG, "hide()");
|
||||
animateAlphaTo(0, mActionButtonsContainer);
|
||||
animateAlphaTo(0, mMenuFrameView);
|
||||
hideMovementHints();
|
||||
|
||||
if (!isInMoveMode) {
|
||||
grantWindowFocus(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void animateAlphaTo(float alpha, View view) {
|
||||
@@ -217,17 +204,6 @@ public class TvPipMenuView extends FrameLayout implements View.OnClickListener {
|
||||
|| mArrowLeft.getAlpha() != 0f;
|
||||
}
|
||||
|
||||
private void grantWindowFocus(boolean grantFocus) {
|
||||
if (DEBUG) Log.d(TAG, "grantWindowFocus(" + grantFocus + ")");
|
||||
|
||||
try {
|
||||
WindowManagerGlobal.getWindowSession().grantEmbeddedWindowFocus(null /* window */,
|
||||
mFocusGrantToken, grantFocus);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Unable to update focus", e);
|
||||
}
|
||||
}
|
||||
|
||||
void setAdditionalActions(List<RemoteAction> actions, Handler mainHandler) {
|
||||
if (DEBUG) Log.d(TAG, "setAdditionalActions()");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user