Merge pull request #7963 from Stypox/android-tv-player

Improve player UI and navigability for Android TV
This commit is contained in:
litetex 2022-03-15 21:41:48 +01:00 committed by GitHub
commit 00e4631b3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 17 deletions

View File

@ -73,7 +73,6 @@ import android.provider.Settings;
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;
@ -89,7 +88,6 @@ import android.widget.FrameLayout;
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;
@ -99,7 +97,9 @@ import androidx.annotation.NonNull;
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;
@ -3249,6 +3249,9 @@ public final class Player implements
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();
}
}
@ -3855,8 +3858,9 @@ public final class Player implements
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;
}
@ -3864,15 +3868,13 @@ public final class Player implements
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;
}

View File

@ -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"

View File

@ -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>