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();

View File

@ -1,8 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="43.2dp"
android:width="24dp"
android:height="24dp"
android:viewportWidth="18"
android:viewportHeight="10">
<path android:fillColor="#000000"
android:pathData="M0,6L2,6L2,4L0,4L0,6L0,6ZM0,10L2,10L2,8L0,8L0,10L0,10ZM0,2L2,2L2,0L0,0L0,2L0,2ZM4,6L18,6L18,4L4,4L4,6L4,6ZM4,10L18,10L18,8L4,8L4,10L4,10ZM4,0L4,2L18,2L18,0L4,0L4,0Z"/>
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M3,13h2v-2L3,11v2zM3,17h2v-2L3,15v2zM3,9h2L5,7L3,7v2zM7,13h14v-2L7,11v2zM7,17h14v-2L7,15v2zM7,7v2h14L21,7L7,7z"/>
</vector>

View File

@ -1,9 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="43.2dp"
android:height="24dp"
android:viewportWidth="18"
android:viewportHeight="10">
<path
android:fillColor="#ffffff"
android:pathData="M0,6L2,6L2,4L0,4L0,6L0,6ZM0,10L2,10L2,8L0,8L0,10L0,10ZM0,2L2,2L2,0L0,0L0,2L0,2ZM4,6L18,6L18,4L4,4L4,6L4,6ZM4,10L18,10L18,8L4,8L4,10L4,10ZM4,0L4,2L18,2L18,0L4,0L4,0Z"/>
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M3,13h2v-2L3,11v2zM3,17h2v-2L3,15v2zM3,9h2L5,7L3,7v2zM7,13h14v-2L7,11v2zM7,17h14v-2L7,15v2zM7,7v2h14L21,7L7,7z"/>
</vector>

View File

@ -247,9 +247,12 @@
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/queueButton"
android:layout_width="40dp"
android:layout_width="35dp"
android:layout_height="35dp"
android:padding="10dp"
android:paddingTop="5dp"
android:paddingStart="3dp"
android:paddingEnd="3dp"
android:paddingBottom="3dp"
android:layout_marginEnd="8dp"
android:clickable="true"
android:focusable="true"
@ -477,14 +480,13 @@
android:gravity="center"
android:orientation="horizontal"
android:weightSum="5.5">
<!--tools:visibility="gone">-->
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/playPreviousButton"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_height="50dp"
android:layout_weight="1"
android:layout_marginEnd="30dp"
android:layout_marginEnd="10dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackgroundBorderless"
@ -496,7 +498,7 @@
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/playPauseButton"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_height="70dp"
android:layout_weight="1"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleType="fitCenter"
@ -506,9 +508,9 @@
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/playNextButton"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_height="50dp"
android:layout_weight="1"
android:layout_marginStart="30dp"
android:layout_marginStart="10dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackgroundBorderless"

View File

@ -1,19 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<org.schabi.newpipe.views.FocusAwareDrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<FrameLayout
<org.schabi.newpipe.views.FocusAwareCoordinator
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="org.schabi.newpipe.MainActivity">
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/fragment_holder"
android:layout_width="match_parent"
@ -21,24 +18,18 @@
android:layout_marginTop="?attr/actionBarSize" />
<include layout="@layout/toolbar_layout" />
</FrameLayout>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/fragment_player_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
app:behavior_hideable="true"
app:behavior_peekHeight="0dp"
app:layout_behavior="org.schabi.newpipe.player.event.CustomBottomSheetBehavior">
android:id="@+id/fragment_player_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
app:behavior_hideable="true"
app:behavior_peekHeight="0dp"
app:layout_behavior="org.schabi.newpipe.player.event.CustomBottomSheetBehavior">
</FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</org.schabi.newpipe.views.FocusAwareCoordinator>
<include layout="@layout/drawer_layout"/>

View File

@ -250,9 +250,12 @@
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/queueButton"
android:layout_width="40dp"
android:layout_width="35dp"
android:layout_height="35dp"
android:padding="10dp"
android:paddingTop="5dp"
android:paddingStart="3dp"
android:paddingEnd="3dp"
android:paddingBottom="3dp"
android:layout_marginEnd="8dp"
android:clickable="true"
android:focusable="true"
@ -478,14 +481,13 @@
android:gravity="center"
android:orientation="horizontal"
android:weightSum="5.5">
<!--tools:visibility="gone">-->
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/playPreviousButton"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_height="40dp"
android:layout_weight="1"
android:layout_marginEnd="30dp"
android:layout_marginEnd="10dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackgroundBorderless"
@ -497,7 +499,7 @@
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/playPauseButton"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_height="60dp"
android:layout_weight="1"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleType="fitCenter"
@ -507,9 +509,9 @@
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/playNextButton"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_height="40dp"
android:layout_weight="1"
android:layout_marginStart="30dp"
android:layout_marginStart="10dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackgroundBorderless"

View File

@ -186,8 +186,8 @@
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/control_backward"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="@+id/control_fast_rewind"
@ -265,8 +265,8 @@
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/control_forward"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:layout_toRightOf="@+id/control_fast_forward"

View File

@ -72,7 +72,7 @@
<string name="use_inexact_seek_title">Use fast inexact seek</string>
<string name="use_inexact_seek_summary">Inexact seek allows the player to seek to positions faster with reduced precision. Seeking for 5, 15 or 25 seconds doesn\'t work with this.</string>
<string name="seek_duration_title">Fast-forward/-rewind seek duration</string>
<string name="clear_queue_confirmation_title">Ask confirmation before clearing a queue</string>
<string name="clear_queue_confirmation_title">Ask for confirmation before clearing a queue</string>
<string name="clear_queue_confirmation_summary">After switching from one player to another your queue may be replaced</string>
<string name="clear_queue_confirmation_description">Queue from the active player will be replaced</string>
<string name="download_thumbnail_title">Load thumbnails</string>