Skip to content

Commit

Permalink
Disable PiP for Android versions below 8.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne committed Feb 4, 2023
1 parent 55eea5a commit ef4c594
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro

updateSeekOptions();

final boolean isPipUnavailable = Build.VERSION.SDK_INT < Build.VERSION_CODES.N
final boolean isPipUnavailable = Build.VERSION.SDK_INT < Build.VERSION_CODES.O
|| !requireContext().getPackageManager()
.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);

// Disable PiP configuration if the device is running Android < 7.0 or Android Go.
// Disable PiP configuration if the device is running Android < 8.0 or Android Go.
if (isPipUnavailable) {
final ListPreference popupConfig =
findPreference(getString(R.string.popup_configuration_key));
if (popupConfig != null) {
popupConfig.setEnabled(false);
// If the Android version is >= 7.0, then PiP is disabled when this point is
// If the Android version is >= 8.0, then PiP is disabled when this point is
// reached.
popupConfig.setSummary(Build.VERSION.SDK_INT < Build.VERSION_CODES.N
popupConfig.setSummary(Build.VERSION.SDK_INT < Build.VERSION_CODES.O
? R.string.pip_unavailable : R.string.pip_disabled);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ public static boolean isAndroidPictureInPictureEnabled(@NonNull final Context co
return popupMode.equals(context.getString(R.string.popup_mode_pip));
}

@SuppressWarnings("deprecation")
public static void enterPictureInPictureMode(@NonNull final Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
activity.enterPictureInPictureMode(new PictureInPictureParams.Builder().build());
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
activity.enterPictureInPictureMode();
}
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@
<string name="popup_mode">Popup mode</string>
<string name="pip">Android picture-in-picture</string>
<string name="legacy">NewPipe popup</string>
<string name="pip_unavailable">Not configurable on Android versions below 7.0</string>
<string name="pip_unavailable">Not configurable on Android versions below 8.0</string>
<string name="pip_disabled">Not configurable on Android Go devices</string>
<!-- Seekbar Preview Thumbnail-->
<string name="seekbar_preview_thumbnail_title">Seekbar thumbnail preview</string>
Expand Down

0 comments on commit ef4c594

Please sign in to comment.