diff options
Diffstat (limited to 'src/com/android/tv/menu/TvOptionsRowAdapter.java')
-rw-r--r-- | src/com/android/tv/menu/TvOptionsRowAdapter.java | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/com/android/tv/menu/TvOptionsRowAdapter.java b/src/com/android/tv/menu/TvOptionsRowAdapter.java index 82525456..ba84247b 100644 --- a/src/com/android/tv/menu/TvOptionsRowAdapter.java +++ b/src/com/android/tv/menu/TvOptionsRowAdapter.java @@ -19,6 +19,7 @@ package com.android.tv.menu; import android.content.Context; import android.media.tv.TvTrackInfo; import android.support.annotation.VisibleForTesting; +import android.support.v4.os.BuildCompat; import com.android.tv.Features; import com.android.tv.R; @@ -39,10 +40,13 @@ import java.util.List; */ public class TvOptionsRowAdapter extends CustomizableOptionsRowAdapter { private int mPositionPipAction; - private boolean mHasPipAction = true; + // If mInAppPipAction is false, system-wide PIP is used. + private boolean mInAppPipAction = true; + private final Context mContext; public TvOptionsRowAdapter(Context context, List<CustomAction> customActions) { super(context, customActions); + mContext = context; } @Override @@ -52,8 +56,8 @@ public class TvOptionsRowAdapter extends CustomizableOptionsRowAdapter { setOptionChangedListener(MenuAction.SELECT_CLOSED_CAPTION_ACTION); actionList.add(MenuAction.SELECT_DISPLAY_MODE_ACTION); setOptionChangedListener(MenuAction.SELECT_DISPLAY_MODE_ACTION); - actionList.add(MenuAction.PIP_ACTION); - setOptionChangedListener(MenuAction.PIP_ACTION); + actionList.add(MenuAction.PIP_IN_APP_ACTION); + setOptionChangedListener(MenuAction.PIP_IN_APP_ACTION); mPositionPipAction = actionList.size() - 1; actionList.add(MenuAction.SELECT_AUDIO_LANGUAGE_ACTION); setOptionChangedListener(MenuAction.SELECT_AUDIO_LANGUAGE_ACTION); @@ -106,34 +110,39 @@ public class TvOptionsRowAdapter extends CustomizableOptionsRowAdapter { // Case 1 PipInputManager pipInputManager = getMainActivity().getPipInputManager(); if (pipInputManager.getPipInputSize(false) < 2) { - if (mHasPipAction) { + if (mInAppPipAction) { removeAction(mPositionPipAction); - mHasPipAction = false; + mInAppPipAction = false; + if (BuildCompat.isAtLeastN()) { + addAction(mPositionPipAction, MenuAction.SYSTEMWIDE_PIP_ACTION); + } return true; } + return false; } else { - if (!mHasPipAction) { - addAction(mPositionPipAction, MenuAction.PIP_ACTION); - mHasPipAction = true; + if (!mInAppPipAction) { + removeAction(mPositionPipAction); + addAction(mPositionPipAction, MenuAction.PIP_IN_APP_ACTION); + mInAppPipAction = true; changed = true; } } // Case 2 boolean isPipEnabled = getMainActivity().isPipEnabled(); - boolean oldEnabled = MenuAction.PIP_ACTION.isEnabled(); + boolean oldEnabled = MenuAction.PIP_IN_APP_ACTION.isEnabled(); boolean newEnabled = pipInputManager.getPipInputSize(true) > 0; if (oldEnabled != newEnabled) { // Should not disable the item if the PIP is already turned on so that the user can // force exit it. if (newEnabled || !isPipEnabled) { - MenuAction.PIP_ACTION.setEnabled(newEnabled); + MenuAction.PIP_IN_APP_ACTION.setEnabled(newEnabled); changed = true; } } // Case 3 & 4 - we just need to update the icon. - MenuAction.PIP_ACTION.setDrawableResId( + MenuAction.PIP_IN_APP_ACTION.setDrawableResId( isPipEnabled ? R.drawable.ic_tvoption_pip : R.drawable.ic_tvoption_pip_off); return changed; } @@ -173,9 +182,12 @@ public class TvOptionsRowAdapter extends CustomizableOptionsRowAdapter { getMainActivity().getOverlayManager().getSideFragmentManager().show( new DisplayModeFragment()); break; - case TvOptionsManager.OPTION_PIP: + case TvOptionsManager.OPTION_IN_APP_PIP: getMainActivity().togglePipView(); break; + case TvOptionsManager.OPTION_SYSTEMWIDE_PIP: + getMainActivity().enterPictureInPictureMode(); + break; case TvOptionsManager.OPTION_MULTI_AUDIO: getMainActivity().getOverlayManager().getSideFragmentManager().show( new MultiAudioFragment()); |