android.app.PictureInPictureParams Java Examples

The following examples show how to use android.app.PictureInPictureParams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From lbry-android with MIT License 6 votes vote down vote up
protected boolean enterPIPMode() {
    if (enteringPIPMode) {
        return true;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
            appPlayer != null &&
            !startingFilePickerActivity &&
            !startingSignInFlowActivity) {
        enteringPIPMode = true;
        PictureInPictureParams params = new PictureInPictureParams.Builder().build();

        try {
            enterPictureInPictureMode(params);
            return true;
        } catch (IllegalStateException ex) {
            // pass
            enteringPIPMode = false;
        }
    }

    return false;
}
 
Example #2
Source File: MonitorActivity.java    From haven with GNU General Public License v3.0 6 votes vote down vote up
/**
 * When user closes the activity
 */
@Override
public void onBackPressed() {

    if (mIsMonitoring) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            enterPictureInPictureMode(new PictureInPictureParams.Builder().build());
        }
        else
        {
            finish();
        }
    }
    else
    {
        finish();
    }


}
 
Example #3
Source File: BrowserActivity.java    From GotoBrowser with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onUserLeaveHint() {
    boolean pipEnabled = sharedPref.getBoolean(PREF_PIP_MODE, false);
    if (supportsPiPMode() && pipEnabled) {
        PictureInPictureParams params = new PictureInPictureParams.Builder()
                .setAspectRatio(new Rational(1200, 720)).build();
        enterPictureInPictureMode(params);
    }
}
 
Example #4
Source File: RtpSessionActivity.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.O)
private void startPictureInPicture() {
    try {
        enterPictureInPictureMode(
                new PictureInPictureParams.Builder()
                        .setAspectRatio(new Rational(10, 16))
                        .build()
        );
    } catch (final IllegalStateException e) {
        //this sometimes happens on Samsung phones (possibly when Knox is enabled)
        Log.w(Config.LOGTAG, "unable to enter picture in picture mode", e);
    }
}
 
Example #5
Source File: RtpSessionActivity.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.O)
private void startPictureInPicture() {
    try {
        enterPictureInPictureMode(
                new PictureInPictureParams.Builder()
                        .setAspectRatio(new Rational(10, 16))
                        .build()
        );
    } catch (final IllegalStateException e) {
        //this sometimes happens on Samsung phones (possibly when Knox is enabled)
        Log.w(Config.LOGTAG, "unable to enter picture in picture mode", e);
    }
}
 
Example #6
Source File: VideoPlayerActivity.java    From Camera-Roll-Android-App with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPause() {
    super.onPause();
    if (player.getPlayWhenReady() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        PictureInPictureParams params = new PictureInPictureParams.Builder()
                .build();
        enterPictureInPictureMode(params);
    }
}
 
Example #7
Source File: MonitorActivity.java    From haven with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onUserLeaveHint () {
    if (mIsMonitoring) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            enterPictureInPictureMode(new PictureInPictureParams.Builder().build());
        }
    }
}
 
Example #8
Source File: WebRtcCallActivity.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onUserLeaveHint() {
  if (deviceSupportsPipMode()) {
    PictureInPictureParams params = new PictureInPictureParams.Builder()
                                                              .setAspectRatio(new Rational(16, 9))
                                                              .build();
    setPictureInPictureParams(params);

    //noinspection deprecation
    enterPictureInPictureMode();
  }
}
 
Example #9
Source File: PreviewActivity.java    From EnhancedScreenshotNotification with GNU General Public License v3.0 4 votes vote down vote up
private synchronized void updatePictureInPictureParams(@Nullable Rational aspect) {
    if (aspect == null) {
        aspect = ScreenUtils.getDefaultDisplayRational(this);
    }

    final List<RemoteAction> remoteActions = new ArrayList<>();

    if (mShareIntent != null) {
        final RemoteAction shareAction = new RemoteAction(
                Icon.createWithResource(this, R.drawable.ic_share_white_24dp),
                getString(R.string.action_share_screenshot),
                getString(R.string.action_share_screenshot),
                PendingIntent.getBroadcast(this, 0,
                        new Intent(ACTION_SHARE), PendingIntent.FLAG_UPDATE_CURRENT)
        );
        remoteActions.add(shareAction);
    }

    if (mDeleteIntent != null) {
        final RemoteAction deleteAction = new RemoteAction(
                Icon.createWithResource(this, R.drawable.ic_delete_white_24dp),
                getString(R.string.action_delete_screenshot),
                getString(R.string.action_delete_screenshot),
                PendingIntent.getBroadcast(this, 0,
                        new Intent(ACTION_DELETE), PendingIntent.FLAG_UPDATE_CURRENT)
        );
        remoteActions.add(deleteAction);
    }

    if (mEditIntent != null) {
        final RemoteAction editAction = new RemoteAction(
                Icon.createWithResource(this, R.drawable.ic_edit_white_24dp),
                getString(R.string.action_edit),
                getString(R.string.action_edit),
                PendingIntent.getBroadcast(this, 0,
                        new Intent(ACTION_EDIT), PendingIntent.FLAG_UPDATE_CURRENT)
        );
        remoteActions.add(editAction);
    }

    mPIPParams = new PictureInPictureParams.Builder()
            .setAspectRatio(aspect)
            .setActions(remoteActions)
            .build();

    if (isInPictureInPictureMode()) {
        setPictureInPictureParams(mPIPParams);
    }
}
 
Example #10
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean enterPictureInPictureMode(@NonNull PictureInPictureParams params) {
    return super.enterPictureInPictureMode(params);
}
 
Example #11
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 4 votes vote down vote up
private void openPicInPicMode() {
    this.enterPictureInPictureMode(new PictureInPictureParams.Builder().build());
}
 
Example #12
Source File: MissingClassTest.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unused")
public void newApiMethod(PictureInPictureParams params) {}
 
Example #13
Source File: MainActivity.java    From opentok-android-sdk-samples with MIT License 4 votes vote down vote up
public void pipActivity(View view) {
    PictureInPictureParams params = new PictureInPictureParams.Builder()
            .setAspectRatio(new Rational(9,16)) // Portrait Aspect Ratio
            .build();
    enterPictureInPictureMode(params);
}
 
Example #14
Source File: BlueprintActivity.java    From CompositeAndroid with Apache License 2.0 2 votes vote down vote up
/**
 * Puts the activity in picture-in-picture mode if possible in the current system state. The
 * set parameters in {@param params} will be combined with the parameters from prior calls to
 * {@link #setPictureInPictureParams(PictureInPictureParams)}.
 * <p>
 * The system may disallow entering picture-in-picture in various cases, including when the
 * activity is not visible, if the screen is locked or if the user has an activity pinned.
 *
 * @param params non-null parameters to be combined with previously set parameters when entering
 *               picture-in-picture.
 * @return true if the system successfully put this activity into picture-in-picture mode or was
 * already in picture-in-picture mode (@see {@link #isInPictureInPictureMode()). If the device
 * does not support picture-in-picture, return false.
 * @see android.R.attr#supportsPictureInPicture
 * @see PictureInPictureParams
 */
@Override
public boolean enterPictureInPictureMode(@NonNull PictureInPictureParams params) {
    return super.enterPictureInPictureMode(params);
}
 
Example #15
Source File: BlueprintActivity.java    From CompositeAndroid with Apache License 2.0 2 votes vote down vote up
/**
 * Updates the properties of the picture-in-picture activity, or sets it to be used later when
 * {@link #enterPictureInPictureMode()} is called.
 *
 * @param params the new parameters for the picture-in-picture.
 */
@Override
public void setPictureInPictureParams(@NonNull PictureInPictureParams params) {
    super.setPictureInPictureParams(params);
}
 
Example #16
Source File: ICompositeActivity.java    From CompositeAndroid with Apache License 2.0 votes vote down vote up
boolean enterPictureInPictureMode(@NonNull PictureInPictureParams params); 
Example #17
Source File: ICompositeActivity.java    From CompositeAndroid with Apache License 2.0 votes vote down vote up
void setPictureInPictureParams(@NonNull PictureInPictureParams params); 
Example #18
Source File: ICompositeActivity.java    From CompositeAndroid with Apache License 2.0 votes vote down vote up
boolean super_enterPictureInPictureMode(@NonNull PictureInPictureParams params); 
Example #19
Source File: ICompositeActivity.java    From CompositeAndroid with Apache License 2.0 votes vote down vote up
void super_setPictureInPictureParams(@NonNull PictureInPictureParams params);