Skip to content

Commit

Permalink
Merge pull request #7963 from Stypox/android-tv-player
Browse files Browse the repository at this point in the history
Improve player UI and navigability for Android TV
  • Loading branch information
litetex authored Mar 15, 2022
2 parents 02fa5aa + 146062d commit 00e4631
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
22 changes: 12 additions & 10 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
Expand All @@ -89,7 +88,6 @@
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
Expand All @@ -99,7 +97,9 @@
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.appcompat.widget.AppCompatImageButton;
import androidx.appcompat.widget.PopupMenu;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets;
import androidx.core.view.GestureDetectorCompat;
Expand Down Expand Up @@ -3249,6 +3249,9 @@ public void closeItemsList() {
binding.itemsListPanel.setTranslationY(
-binding.itemsListPanel.getHeight() * 5);
});

// clear focus, otherwise a white rectangle remains on top of the player
binding.itemsListClose.clearFocus();
binding.playPauseButton.requestFocus();
}
}
Expand Down Expand Up @@ -3855,24 +3858,23 @@ public boolean onKeyDown(final int keyCode) {
case KeyEvent.KEYCODE_DPAD_DOWN:
case KeyEvent.KEYCODE_DPAD_RIGHT:
case KeyEvent.KEYCODE_DPAD_CENTER:
if (binding.getRoot().hasFocus() && !binding.playbackControlRoot.hasFocus()) {
// do not interfere with focus in playlist etc.
if ((binding.getRoot().hasFocus() && !binding.playbackControlRoot.hasFocus())
|| isQueueVisible) {
// do not interfere with focus in playlist and play queue etc.
return false;
}

if (currentState == Player.STATE_BLOCKED) {
return true;
}

if (!isControlsVisible()) {
if (!isQueueVisible) {
binding.playPauseButton.requestFocus();
}
if (isControlsVisible()) {
hideControls(DEFAULT_CONTROLS_DURATION, DPAD_CONTROLS_HIDE_TIME);
} else {
binding.playPauseButton.requestFocus();
showControlsThenHide();
showSystemUIPartially();
return true;
} else {
hideControls(DEFAULT_CONTROLS_DURATION, DPAD_CONTROLS_HIDE_TIME);
}
break;
}
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/res/layout/player.xml
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,7 @@
<RelativeLayout
android:id="@+id/itemsListControl"
android:layout_width="match_parent"
android:layout_height="60dp"
android:clickable="true"
android:focusable="true">
android:layout_height="60dp">

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/itemsListHeaderTitle"
Expand Down
5 changes: 1 addition & 4 deletions app/src/main/res/values/styles_misc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@
<item name="tint">?attr/actionColor</item>
</style>

<style name="DarkPopupMenu" parent="Widget.AppCompat.PopupMenu">
<item name="android:itemBackground">#2E2E2E</item>
<item name="android:textColor">@color/white</item>
</style>
<style name="DarkPopupMenu" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="popupTheme">@style/ThemeOverlay.AppCompat.DayNight.ActionBar</item>
Expand Down

0 comments on commit 00e4631

Please sign in to comment.