1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-10-28 05:47:39 +00:00

Better TV support, icons, activity_main refactoring

- on Android TV you'll be able to navigate with D-pad in main fragment and in the player. But not between them for now
- play/pause/next/previous buttons are smaller now
- replaced ic_list with previous version of it
- activity_main looks better which helps with Android TV support
This commit is contained in:
Avently
2020-07-22 01:20:30 +03:00
parent 77cd3182f1
commit 3ecbbea7cb
10 changed files with 53 additions and 74 deletions

View File

@@ -570,10 +570,6 @@ public class VideoDetailFragment
@Override
public void onClick(final View v) {
if (isLoading.get() || currentInfo == null) {
return;
}
switch (v.getId()) {
case R.id.detail_controls_background:
openBackgroundPlayer(false);
@@ -2168,6 +2164,7 @@ public class VideoDetailFragment
@Override
public void onStateChanged(@NonNull final View bottomSheet, final int newState) {
bottomSheetState = newState;
ViewGroup mainFragment = requireActivity().findViewById(R.id.fragment_holder);
switch (newState) {
case BottomSheetBehavior.STATE_HIDDEN:
@@ -2175,6 +2172,7 @@ public class VideoDetailFragment
cleanUp();
break;
case BottomSheetBehavior.STATE_EXPANDED:
mainFragment.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
bottomSheetBehavior.setPeekHeight(peekHeight);
// Disable click because overlay buttons located on top of buttons
// from the player
@@ -2191,6 +2189,8 @@ public class VideoDetailFragment
}
break;
case BottomSheetBehavior.STATE_COLLAPSED:
mainFragment.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
mainFragment.requestFocus();
// Re-enable clicks
setOverlayElementsClickable(true);
if (player != null) {
@@ -2236,7 +2236,7 @@ public class VideoDetailFragment
}
private void setOverlayPlayPauseImage() {
final int attr = player != null && player.getPlayer().getPlayWhenReady()
final int attr = player != null && player.isPlaying()
? R.attr.ic_pause
: R.attr.ic_play_arrow;
overlayPlayPauseButton.setImageResource(

View File

@@ -204,7 +204,7 @@ public abstract class VideoPlayer extends BasePlayer
final CaptionStyleCompat captionStyle = PlayerHelper.getCaptionStyle(context);
setupSubtitleView(subtitleView, captionScale, captionStyle);
this.resizeView = view.findViewById(R.id.resizeTextView);
this.resizeView = view.findViewById(R.id.resizeTextView);
resizeView.setText(PlayerHelper
.resizeTypeOf(context, getSurfaceView().getResizeMode()));

View File

@@ -22,8 +22,6 @@ package org.schabi.newpipe.player;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
@@ -60,7 +58,6 @@ import android.widget.SeekBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.recyclerview.widget.ItemTouchHelper;
@@ -892,7 +889,7 @@ public class VideoPlayerImpl extends VideoPlayer
if (DEBUG) {
Log.i(TAG, "Failed to start kore", e);
}
showInstallKoreDialog(getParentActivity());
KoreUtil.showInstallKoreDialog(getParentActivity());
}
}
@@ -917,16 +914,6 @@ public class VideoPlayerImpl extends VideoPlayer
? View.VISIBLE : View.GONE);
}
private static void showInstallKoreDialog(final Context context) {
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(R.string.kore_not_found)
.setPositiveButton(R.string.install, (DialogInterface dialog, int which) ->
NavigationHelper.installKore(context))
.setNegativeButton(R.string.cancel, (DialogInterface dialog, int which) -> {
});
builder.create().show();
}
private void setupScreenRotationButton() {
final boolean orientationLocked = PlayerHelper.globalScreenOrientationLocked(service);
final boolean tabletInLandscape = DeviceUtils.isTablet(service) && service.isLandscape();