Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
.findFragmentById(R.id.rows_area);
}

mPopupRowPresenter = new PositionableListRowPresenter();
mPopupRowPresenter = new PositionableListRowPresenter(null, true);
mPopupRowAdapter = new ArrayObjectAdapter(mPopupRowPresenter);
mPopupRowsFragment.setAdapter(mPopupRowAdapter);
mPopupRowsFragment.setOnItemViewClickedListener(itemViewClickedListener);
Expand Down Expand Up @@ -475,7 +475,7 @@ public void refreshFavorite(UUID channelId) {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (!mGuideVisible)
if (!mGuideVisible && !mPopupPanelVisible)
leanbackOverlayFragment.setShouldShowOverlay(true);
else {
leanbackOverlayFragment.setShouldShowOverlay(false);
Expand Down Expand Up @@ -527,11 +527,6 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
}
}

if (mPopupPanelVisible && !mGuideVisible && keyCode == KeyEvent.KEYCODE_DPAD_LEFT && mPopupRowPresenter.getPosition() == 0) {
mPopupRowsFragment.requireView().requestFocus();
mPopupRowPresenter.setPosition(0);
return true;
}
if (mGuideVisible) {
if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_BUTTON_B || keyCode == KeyEvent.KEYCODE_ESCAPE) {
// go back to normal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package org.jellyfin.androidtv.ui.presentation

import android.view.KeyEvent
import androidx.leanback.widget.RowPresenter
import timber.log.Timber

class PositionableListRowPresenter : CustomListRowPresenter {
private var viewHolder: ViewHolder? = null
private val trapFocusAtStart: Boolean

constructor() : super()
constructor(padding: Int?) : super(padding)
constructor() : this(padding = null, trapFocusAtStart = false)
constructor(padding: Int?) : this(padding, trapFocusAtStart = false)
constructor(padding: Int? = null, trapFocusAtStart: Boolean = false) : super(padding) {
this.trapFocusAtStart = trapFocusAtStart
}

init {
shadowEnabled = false
Expand All @@ -22,6 +27,14 @@ class PositionableListRowPresenter : CustomListRowPresenter {
if (holder !is ViewHolder) return

viewHolder = holder
if (trapFocusAtStart) {
// Prevent focus from escaping the grid at the left boundary so the user
// stays inside the popup (channel changer / chapter selector).
holder.gridView?.setOnKeyInterceptListener { event ->
event.keyCode == KeyEvent.KEYCODE_DPAD_LEFT &&
(holder.gridView?.selectedPosition ?: -1) <= 0
}
}
}

var position: Int
Expand Down