Merge "PIP: Fix regressions caused by previous commit a0d4d25" into nyc-dev
This commit is contained in:
@@ -366,7 +366,6 @@
|
|||||||
android:name="com.android.systemui.tv.pip.PipOverlayActivity"
|
android:name="com.android.systemui.tv.pip.PipOverlayActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:theme="@style/PipTheme"
|
android:theme="@style/PipTheme"
|
||||||
android:launchMode="singleTop"
|
|
||||||
android:taskAffinity=""
|
android:taskAffinity=""
|
||||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||||
android:resizeableActivity="true"
|
android:resizeableActivity="true"
|
||||||
|
|||||||
@@ -265,11 +265,7 @@ public class PipManager {
|
|||||||
*/
|
*/
|
||||||
private void showPipOverlay() {
|
private void showPipOverlay() {
|
||||||
if (DEBUG) Log.d(TAG, "showPipOverlay()");
|
if (DEBUG) Log.d(TAG, "showPipOverlay()");
|
||||||
Intent intent = new Intent(mContext, PipOverlayActivity.class);
|
PipOverlayActivity.showPipOverlay(mContext);
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
final ActivityOptions options = ActivityOptions.makeBasic();
|
|
||||||
options.setLaunchStackId(PINNED_STACK_ID);
|
|
||||||
mContext.startActivity(intent, options.toBundle());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -635,7 +631,7 @@ public class PipManager {
|
|||||||
void onPipActivityClosed();
|
void onPipActivityClosed();
|
||||||
/** Invoked when the PIP menu gets shown. */
|
/** Invoked when the PIP menu gets shown. */
|
||||||
void onShowPipMenu();
|
void onShowPipMenu();
|
||||||
/** Invoked when the PIPed activity is returned back to the fullscreen. */
|
/** Invoked when the PIPed activity is about to return back to the fullscreen. */
|
||||||
void onMoveToFullscreen();
|
void onMoveToFullscreen();
|
||||||
/** Invoked when we are above to start resizing the Pip. */
|
/** Invoked when we are above to start resizing the Pip. */
|
||||||
void onPipResizeAboutToStart();
|
void onPipResizeAboutToStart();
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
|
|||||||
private final PipManager mPipManager = PipManager.getInstance();
|
private final PipManager mPipManager = PipManager.getInstance();
|
||||||
|
|
||||||
private PipControlsView mPipControlsView;
|
private PipControlsView mPipControlsView;
|
||||||
|
private boolean mRestorePipSizeWhenClose;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle bundle) {
|
protected void onCreate(Bundle bundle) {
|
||||||
@@ -38,12 +39,21 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
|
|||||||
mPipManager.addListener(this);
|
mPipManager.addListener(this);
|
||||||
|
|
||||||
mPipControlsView = (PipControlsView) findViewById(R.id.pip_controls);
|
mPipControlsView = (PipControlsView) findViewById(R.id.pip_controls);
|
||||||
|
mRestorePipSizeWhenClose = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restorePipAndFinish() {
|
||||||
|
if (mRestorePipSizeWhenClose) {
|
||||||
|
// When PIP menu activity is closed, restore to the default position.
|
||||||
|
mPipManager.resizePinnedStack(PipManager.STATE_PIP_OVERLAY);
|
||||||
|
}
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
finish();
|
restorePipAndFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -54,6 +64,11 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
|
|||||||
PipManager.SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_MENU_ACTIVITY_FINISH);
|
PipManager.SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_MENU_ACTIVITY_FINISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
restorePipAndFinish();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPipEntered() { }
|
public void onPipEntered() { }
|
||||||
|
|
||||||
@@ -67,6 +82,9 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMoveToFullscreen() {
|
public void onMoveToFullscreen() {
|
||||||
|
// Moving PIP to fullscreen is implemented by resizing PINNED_STACK with null bounds.
|
||||||
|
// This conflicts with restoring PIP position, so disable it.
|
||||||
|
mRestorePipSizeWhenClose = false;
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,14 @@ import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
|
|||||||
public class PipOverlayActivity extends Activity implements PipManager.Listener {
|
public class PipOverlayActivity extends Activity implements PipManager.Listener {
|
||||||
private static final long SHOW_GUIDE_OVERLAY_VIEW_DURATION_MS = 4000;
|
private static final long SHOW_GUIDE_OVERLAY_VIEW_DURATION_MS = 4000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A flag to ensure the single instance of PipOverlayActivity to prevent it from restarting.
|
||||||
|
* Note that {@link PipManager} moves the PIPed activity to fullscreen if the activity is
|
||||||
|
* restarted. It's because the activity may be started by the Launcher or an intent again,
|
||||||
|
* but we don't want do so for the PipOverlayActivity.
|
||||||
|
*/
|
||||||
|
private static boolean sActivityCreated;
|
||||||
|
|
||||||
private final PipManager mPipManager = PipManager.getInstance();
|
private final PipManager mPipManager = PipManager.getInstance();
|
||||||
private final Handler mHandler = new Handler();
|
private final Handler mHandler = new Handler();
|
||||||
private View mGuideOverlayView;
|
private View mGuideOverlayView;
|
||||||
@@ -46,9 +54,23 @@ public class PipOverlayActivity extends Activity implements PipManager.Listener
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows PIP overlay UI only if it's not there.
|
||||||
|
*/
|
||||||
|
static void showPipOverlay(Context context) {
|
||||||
|
if (!sActivityCreated) {
|
||||||
|
Intent intent = new Intent(context, PipOverlayActivity.class);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
final ActivityOptions options = ActivityOptions.makeBasic();
|
||||||
|
options.setLaunchStackId(PINNED_STACK_ID);
|
||||||
|
context.startActivity(intent, options.toBundle());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle bundle) {
|
protected void onCreate(Bundle bundle) {
|
||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
|
sActivityCreated = true;
|
||||||
setContentView(R.layout.tv_pip_overlay);
|
setContentView(R.layout.tv_pip_overlay);
|
||||||
mGuideOverlayView = findViewById(R.id.guide_overlay);
|
mGuideOverlayView = findViewById(R.id.guide_overlay);
|
||||||
mPipManager.addListener(this);
|
mPipManager.addListener(this);
|
||||||
@@ -71,6 +93,7 @@ public class PipOverlayActivity extends Activity implements PipManager.Listener
|
|||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
sActivityCreated = false;
|
||||||
mHandler.removeCallbacksAndMessages(null);
|
mHandler.removeCallbacksAndMessages(null);
|
||||||
mPipManager.removeListener(this);
|
mPipManager.removeListener(this);
|
||||||
mPipManager.resumePipResizing(
|
mPipManager.resumePipResizing(
|
||||||
|
|||||||
Reference in New Issue
Block a user