Merge remote-tracking branch 'origin/master'

This commit is contained in:
Blatzar 2021-12-12 02:49:50 +01:00
commit 1943a4e66e
8 changed files with 86 additions and 51 deletions

View file

@ -52,17 +52,17 @@ class HomeChildItemAdapter(
) :
RecyclerView.ViewHolder(itemView) {
fun bind(card: SearchResponse, index: Int) {
fun bind(card: SearchResponse, position: Int) {
// TV focus fixing
val nextFocusBehavior = when (index) {
val nextFocusBehavior = when (position) {
0 -> true
itemCount - 1 -> false
else -> null
}
SearchResultBuilder.bind(clickCallback, card, itemView, nextFocusBehavior, nextFocusUp, nextFocusDown)
itemView.tag = index
SearchResultBuilder.bind(clickCallback, card, position, itemView, nextFocusBehavior, nextFocusUp, nextFocusDown)
itemView.tag = position
//val ani = ScaleAnimation(0.9f, 1.0f, 0.9f, 1f)
//ani.fillAfter = true
//ani.duration = 200

View file

@ -437,7 +437,7 @@ class HomeFragment : Fragment() {
if (itemId == 1) {
handleSearchClickCallback(
activity,
SearchClickCallback(SEARCH_ACTION_LOAD, callback.view, callback.card)
SearchClickCallback(SEARCH_ACTION_LOAD, callback.view, -1, callback.card)
)
reloadStored()
}

View file

@ -409,6 +409,9 @@ class PlayerFragment : Fragment() {
private fun onClickChange() {
isShowing = !isShowing
if(isShowing) {
autoHide()
}
activity?.hideSystemUI()
updateClick()
}
@ -1016,6 +1019,18 @@ class PlayerFragment : Fragment() {
)
}
var currentTapIndex = 0
private fun autoHide() {
currentTapIndex++
val index = currentTapIndex
player_holder?.postDelayed({
if (isShowing && index == currentTapIndex && this::exoPlayer.isInitialized && exoPlayer.isPlaying) {
onClickChange()
}
}, 2000)
}
private var receiver: BroadcastReceiver? = null
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {
isInPIPMode = isInPictureInPictureMode
@ -1056,34 +1071,10 @@ class PlayerFragment : Fragment() {
private fun handleKeyEvent(event: KeyEvent): Boolean {
event.keyCode.let { keyCode ->
when (keyCode) {
// don't allow dpad move when hidden
KeyEvent.KEYCODE_DPAD_LEFT,
KeyEvent.KEYCODE_DPAD_DOWN,
KeyEvent.KEYCODE_DPAD_UP,
KeyEvent.KEYCODE_DPAD_RIGHT,
KeyEvent.KEYCODE_DPAD_DOWN_LEFT,
KeyEvent.KEYCODE_DPAD_DOWN_RIGHT,
KeyEvent.KEYCODE_DPAD_UP_LEFT,
KeyEvent.KEYCODE_DPAD_UP_RIGHT -> {
if (!isShowing) {
return true
}
}
// netflix capture back and hide ~monke
KeyEvent.KEYCODE_BACK -> {
if (isShowing) {
onClickChange()
return true
}
}
}
when (event.action) {
KeyEvent.ACTION_DOWN -> {
when (keyCode) {
KeyEvent.KEYCODE_DPAD_CENTER -> {
KeyEvent.KEYCODE_DPAD_CENTER, KeyEvent.KEYCODE_DPAD_UP -> {
if (!isShowing) {
onClickChange()
return true
@ -1099,6 +1090,32 @@ class PlayerFragment : Fragment() {
//)
}
}
when (keyCode) {
// don't allow dpad move when hidden
KeyEvent.KEYCODE_DPAD_LEFT,
KeyEvent.KEYCODE_DPAD_DOWN,
KeyEvent.KEYCODE_DPAD_UP,
KeyEvent.KEYCODE_DPAD_RIGHT,
KeyEvent.KEYCODE_DPAD_DOWN_LEFT,
KeyEvent.KEYCODE_DPAD_DOWN_RIGHT,
KeyEvent.KEYCODE_DPAD_UP_LEFT,
KeyEvent.KEYCODE_DPAD_UP_RIGHT -> {
if (!isShowing) {
return true
} else {
autoHide()
}
}
// netflix capture back and hide ~monke
KeyEvent.KEYCODE_BACK -> {
if (isShowing) {
onClickChange()
return true
}
}
}
}
return false
@ -1214,6 +1231,7 @@ class PlayerFragment : Fragment() {
val subsSettings = sourceDialog.findViewById<View>(R.id.subs_settings)!!
subsSettings.setOnClickListener {
autoHide()
saveArguments()
SubtitlesFragment.push(activity)
sourceDialog.dismiss()
@ -1358,6 +1376,17 @@ class PlayerFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
updateLock()
exo_pause?.setOnClickListener {
autoHide()
handlePlayerEvent(PlayerEventType.Pause)
}
exo_play?.setOnClickListener {
autoHide()
handlePlayerEvent(PlayerEventType.Play)
}
context?.let { ctx ->
setPreferredSubLanguage(ctx.getAutoSelectLanguageISO639_1())
}
@ -1638,6 +1667,7 @@ class PlayerFragment : Fragment() {
}
exo_rew?.setOnClickListener {
autoHide()
rewind()
}
@ -1666,6 +1696,7 @@ class PlayerFragment : Fragment() {
}
exo_ffwd?.setOnClickListener {
autoHide()
fastForward()
}
@ -1707,7 +1738,7 @@ class PlayerFragment : Fragment() {
}
}
player_holder.setOnTouchListener(
player_holder?.setOnTouchListener(
Listener()
)
@ -1727,10 +1758,12 @@ class PlayerFragment : Fragment() {
playback_speed_btt?.isVisible = playBackSpeedEnabled
playback_speed_btt?.setOnClickListener {
autoHide()
handlePlayerEvent(PlayerEventType.ShowSpeed)
}
sources_btt.setOnClickListener {
autoHide()
handlePlayerEvent(PlayerEventType.ShowMirrors)
}
@ -1738,6 +1771,7 @@ class PlayerFragment : Fragment() {
if (playerResizeEnabled) {
resize_player?.visibility = VISIBLE
resize_player?.setOnClickListener {
autoHide()
handlePlayerEvent(PlayerEventType.Resize)
}
} else {
@ -1745,10 +1779,12 @@ class PlayerFragment : Fragment() {
}
skip_op?.setOnClickListener {
autoHide()
skipOP()
}
skip_episode?.setOnClickListener {
autoHide()
handlePlayerEvent(PlayerEventType.NextEpisode)
}

View file

@ -17,8 +17,9 @@ import kotlin.math.roundToInt
const val SEARCH_ACTION_LOAD = 0
const val SEARCH_ACTION_SHOW_METADATA = 1
const val SEARCH_ACTION_PLAY_FILE = 2
const val SEARCH_ACTION_FOCUSED = 4
class SearchClickCallback(val action: Int, val view: View, val card: SearchResponse)
class SearchClickCallback(val action: Int, val view: View, val position : Int, val card: SearchResponse)
class SearchAdapter(
var cardList: List<SearchResponse>,
@ -69,7 +70,7 @@ class SearchAdapter(
}
}
SearchResultBuilder.bind(clickCallback, card, itemView)
SearchResultBuilder.bind(clickCallback, card, position, itemView)
}
}
}

View file

@ -43,7 +43,7 @@ object SearchHelper {
} else {
handleSearchClickCallback(
activity,
SearchClickCallback(SEARCH_ACTION_LOAD, callback.view, callback.card)
SearchClickCallback(SEARCH_ACTION_LOAD, callback.view, -1, callback.card)
)
}
}

View file

@ -21,6 +21,7 @@ object SearchResultBuilder {
fun bind(
clickCallback: (SearchClickCallback) -> Unit,
card: SearchResponse,
position: Int,
itemView: View,
nextFocusBehavior: Boolean? = null,
nextFocusUp: Int? = null,
@ -54,16 +55,17 @@ object SearchResultBuilder {
SearchClickCallback(
if (card is DataStoreHelper.ResumeWatchingResult) SEARCH_ACTION_PLAY_FILE else SEARCH_ACTION_LOAD,
it,
position,
card
)
)
}
if(nextFocusUp != null) {
if (nextFocusUp != null) {
bg.nextFocusUpId = nextFocusUp
}
if(nextFocusDown != null) {
if (nextFocusDown != null) {
bg.nextFocusDownId = nextFocusDown
}
@ -83,10 +85,16 @@ object SearchResultBuilder {
}
bg.setOnLongClickListener {
clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_SHOW_METADATA, it, card))
clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_SHOW_METADATA, it, position, card))
return@setOnLongClickListener true
}
bg.setOnFocusChangeListener { view, b ->
if (b) {
clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_FOCUSED, view, position, card))
}
}
when (card) {
is DataStoreHelper.ResumeWatchingResult -> {
val pos = card.watchPos?.fixVisual()

View file

@ -11,7 +11,7 @@
<FrameLayout
android:visibility="gone"
tools:visibility="visible"
tools:visibility="gone"
android:id="@+id/home_loading"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -148,7 +148,7 @@
</LinearLayout>
<androidx.core.widget.NestedScrollView
android:background="?attr/primaryBlackBackground"
tools:visibility="gone"
tools:visibility="visible"
android:visibility="gone"
android:id="@+id/home_loaded"
android:layout_width="match_parent"
@ -417,8 +417,6 @@
<com.google.android.material.button.MaterialButton
android:nextFocusLeft="@id/nav_rail_view"
android:nextFocusRight="@id/home_plan_to_watch_btt"
android:nextFocusDown="@id/home_bookmarked_child_recyclerview"
android:nextFocusUp="@id/home_watch_child_recyclerview"
android:id="@+id/home_type_watching_btt"
android:text="@string/type_watching"
@ -426,8 +424,6 @@
<com.google.android.material.button.MaterialButton
android:nextFocusLeft="@id/home_type_watching_btt"
android:nextFocusRight="@id/home_type_on_hold_btt"
android:nextFocusDown="@id/home_bookmarked_child_recyclerview"
android:nextFocusUp="@id/home_watch_child_recyclerview"
android:id="@+id/home_plan_to_watch_btt"
android:text="@string/type_plan_to_watch"
@ -435,8 +431,6 @@
<com.google.android.material.button.MaterialButton
android:nextFocusLeft="@id/home_plan_to_watch_btt"
android:nextFocusRight="@id/home_type_dropped_btt"
android:nextFocusDown="@id/home_bookmarked_child_recyclerview"
android:nextFocusUp="@id/home_watch_child_recyclerview"
android:id="@+id/home_type_on_hold_btt"
android:text="@string/type_on_hold"
@ -444,16 +438,12 @@
<com.google.android.material.button.MaterialButton
android:nextFocusLeft="@id/home_type_on_hold_btt"
android:nextFocusRight="@id/home_type_completed_btt"
android:nextFocusDown="@id/home_bookmarked_child_recyclerview"
android:nextFocusUp="@id/home_watch_child_recyclerview"
android:id="@+id/home_type_dropped_btt"
android:text="@string/type_dropped"
style="@style/RoundedSelectableButton"/>
<com.google.android.material.button.MaterialButton
android:nextFocusLeft="@id/home_type_dropped_btt"
android:nextFocusDown="@id/home_bookmarked_child_recyclerview"
android:nextFocusUp="@id/home_watch_child_recyclerview"
android:id="@+id/home_type_completed_btt"
android:text="@string/type_completed"

View file

@ -156,7 +156,7 @@
android:layout_height="wrap_content">
<ImageView
android:nextFocusDown="@id/result_bookmark_button"
android:nextFocusRight="@id/result_bookmark_button"
android:nextFocusRight="@id/result_share"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:id="@+id/result_back"