1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

Quality selector for external playback and better fullscreen mode for old devices

This commit is contained in:
Avently 2020-07-24 00:43:09 +03:00
parent 91a0257c8f
commit 7c79d421e8
2 changed files with 30 additions and 15 deletions

View File

@ -370,7 +370,7 @@ public class VideoDetailFragment
/*////////////////////////////////////////////////////////////////////////*/
public static VideoDetailFragment getInstance(final int serviceId, final String videoUrl,
final String name, final PlayQueue playQueue) {
final String name, final PlayQueue playQueue) {
VideoDetailFragment instance = new VideoDetailFragment();
instance.setInitialData(serviceId, videoUrl, name, playQueue);
return instance;
@ -1142,11 +1142,7 @@ public class VideoDetailFragment
private void openVideoPlayer() {
if (PreferenceManager.getDefaultSharedPreferences(activity)
.getBoolean(this.getString(R.string.use_external_video_player_key), false)) {
final VideoStream selectedVideoStream = getSelectedVideoStream();
if (selectedVideoStream == null) {
return;
}
startOnExternalPlayer(activity, currentInfo, selectedVideoStream);
showExternalPlaybackDialog();
} else {
replaceQueueIfUserConfirms(this::openMainPlayer);
}
@ -1302,12 +1298,6 @@ public class VideoDetailFragment
viewHolder.requestLayout();
}
@Nullable
private VideoStream getSelectedVideoStream() {
return sortedVideoStreams != null ? sortedVideoStreams.get(selectedVideoStreamIndex) : null;
}
private void prepareDescription(final Description description) {
if (description == null || TextUtils.isEmpty(description.getContent())
|| description == Description.emptyDescription) {
@ -2113,8 +2103,7 @@ public class VideoDetailFragment
private void showClearingQueueConfirmation(final Runnable onAllow) {
new AlertDialog.Builder(activity)
.setTitle(R.string.confirm_prompt)
.setMessage(R.string.clear_queue_confirmation_description)
.setTitle(R.string.clear_queue_confirmation_description)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
onAllow.run();
@ -2122,6 +2111,30 @@ public class VideoDetailFragment
}).show();
}
private void showExternalPlaybackDialog() {
if (sortedVideoStreams == null) {
return;
}
CharSequence[] resolutions = new CharSequence[sortedVideoStreams.size()];
for (int i = 0; i < sortedVideoStreams.size(); i++) {
resolutions[i] = sortedVideoStreams.get(i).getResolution();
}
AlertDialog.Builder builder = new AlertDialog.Builder(activity)
.setNegativeButton(android.R.string.cancel, null)
.setNeutralButton(R.string.open_in_browser, (dialog, i) ->
ShareUtils.openUrlInBrowser(requireActivity(), url)
);
// Maybe there are no video streams available, show just `open in browser` button
if (resolutions.length > 0) {
builder.setSingleChoiceItems(resolutions, selectedVideoStreamIndex, (dialog, i) -> {
dialog.dismiss();
startOnExternalPlayer(activity, currentInfo, sortedVideoStreams.get(i));
}
);
}
builder.show();
}
/*
* Remove unneeded information while waiting for a next task
* */

View File

@ -1463,7 +1463,9 @@ public class VideoPlayerImpl extends VideoPlayer
private void showSystemUIPartially() {
if (isFullscreen() && getParentActivity() != null) {
final int visibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
final int visibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
getParentActivity().getWindow().getDecorView().setSystemUiVisibility(visibility);
}
}