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) { RecyclerView.ViewHolder(itemView) {
fun bind(card: SearchResponse, index: Int) { fun bind(card: SearchResponse, position: Int) {
// TV focus fixing // TV focus fixing
val nextFocusBehavior = when (index) { val nextFocusBehavior = when (position) {
0 -> true 0 -> true
itemCount - 1 -> false itemCount - 1 -> false
else -> null else -> null
} }
SearchResultBuilder.bind(clickCallback, card, itemView, nextFocusBehavior, nextFocusUp, nextFocusDown) SearchResultBuilder.bind(clickCallback, card, position, itemView, nextFocusBehavior, nextFocusUp, nextFocusDown)
itemView.tag = index itemView.tag = position
//val ani = ScaleAnimation(0.9f, 1.0f, 0.9f, 1f) //val ani = ScaleAnimation(0.9f, 1.0f, 0.9f, 1f)
//ani.fillAfter = true //ani.fillAfter = true
//ani.duration = 200 //ani.duration = 200

View file

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

View file

@ -409,6 +409,9 @@ class PlayerFragment : Fragment() {
private fun onClickChange() { private fun onClickChange() {
isShowing = !isShowing isShowing = !isShowing
if(isShowing) {
autoHide()
}
activity?.hideSystemUI() activity?.hideSystemUI()
updateClick() 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 private var receiver: BroadcastReceiver? = null
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) { override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {
isInPIPMode = isInPictureInPictureMode isInPIPMode = isInPictureInPictureMode
@ -1056,34 +1071,10 @@ class PlayerFragment : Fragment() {
private fun handleKeyEvent(event: KeyEvent): Boolean { private fun handleKeyEvent(event: KeyEvent): Boolean {
event.keyCode.let { keyCode -> 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) { when (event.action) {
KeyEvent.ACTION_DOWN -> { KeyEvent.ACTION_DOWN -> {
when (keyCode) { when (keyCode) {
KeyEvent.KEYCODE_DPAD_CENTER -> { KeyEvent.KEYCODE_DPAD_CENTER, KeyEvent.KEYCODE_DPAD_UP -> {
if (!isShowing) { if (!isShowing) {
onClickChange() onClickChange()
return true 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 return false
@ -1214,6 +1231,7 @@ class PlayerFragment : Fragment() {
val subsSettings = sourceDialog.findViewById<View>(R.id.subs_settings)!! val subsSettings = sourceDialog.findViewById<View>(R.id.subs_settings)!!
subsSettings.setOnClickListener { subsSettings.setOnClickListener {
autoHide()
saveArguments() saveArguments()
SubtitlesFragment.push(activity) SubtitlesFragment.push(activity)
sourceDialog.dismiss() sourceDialog.dismiss()
@ -1358,6 +1376,17 @@ class PlayerFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
updateLock() updateLock()
exo_pause?.setOnClickListener {
autoHide()
handlePlayerEvent(PlayerEventType.Pause)
}
exo_play?.setOnClickListener {
autoHide()
handlePlayerEvent(PlayerEventType.Play)
}
context?.let { ctx -> context?.let { ctx ->
setPreferredSubLanguage(ctx.getAutoSelectLanguageISO639_1()) setPreferredSubLanguage(ctx.getAutoSelectLanguageISO639_1())
} }
@ -1638,6 +1667,7 @@ class PlayerFragment : Fragment() {
} }
exo_rew?.setOnClickListener { exo_rew?.setOnClickListener {
autoHide()
rewind() rewind()
} }
@ -1666,6 +1696,7 @@ class PlayerFragment : Fragment() {
} }
exo_ffwd?.setOnClickListener { exo_ffwd?.setOnClickListener {
autoHide()
fastForward() fastForward()
} }
@ -1707,7 +1738,7 @@ class PlayerFragment : Fragment() {
} }
} }
player_holder.setOnTouchListener( player_holder?.setOnTouchListener(
Listener() Listener()
) )
@ -1727,10 +1758,12 @@ class PlayerFragment : Fragment() {
playback_speed_btt?.isVisible = playBackSpeedEnabled playback_speed_btt?.isVisible = playBackSpeedEnabled
playback_speed_btt?.setOnClickListener { playback_speed_btt?.setOnClickListener {
autoHide()
handlePlayerEvent(PlayerEventType.ShowSpeed) handlePlayerEvent(PlayerEventType.ShowSpeed)
} }
sources_btt.setOnClickListener { sources_btt.setOnClickListener {
autoHide()
handlePlayerEvent(PlayerEventType.ShowMirrors) handlePlayerEvent(PlayerEventType.ShowMirrors)
} }
@ -1738,6 +1771,7 @@ class PlayerFragment : Fragment() {
if (playerResizeEnabled) { if (playerResizeEnabled) {
resize_player?.visibility = VISIBLE resize_player?.visibility = VISIBLE
resize_player?.setOnClickListener { resize_player?.setOnClickListener {
autoHide()
handlePlayerEvent(PlayerEventType.Resize) handlePlayerEvent(PlayerEventType.Resize)
} }
} else { } else {
@ -1745,10 +1779,12 @@ class PlayerFragment : Fragment() {
} }
skip_op?.setOnClickListener { skip_op?.setOnClickListener {
autoHide()
skipOP() skipOP()
} }
skip_episode?.setOnClickListener { skip_episode?.setOnClickListener {
autoHide()
handlePlayerEvent(PlayerEventType.NextEpisode) handlePlayerEvent(PlayerEventType.NextEpisode)
} }

View file

@ -17,8 +17,9 @@ import kotlin.math.roundToInt
const val SEARCH_ACTION_LOAD = 0 const val SEARCH_ACTION_LOAD = 0
const val SEARCH_ACTION_SHOW_METADATA = 1 const val SEARCH_ACTION_SHOW_METADATA = 1
const val SEARCH_ACTION_PLAY_FILE = 2 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( class SearchAdapter(
var cardList: List<SearchResponse>, 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 { } else {
handleSearchClickCallback( handleSearchClickCallback(
activity, 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( fun bind(
clickCallback: (SearchClickCallback) -> Unit, clickCallback: (SearchClickCallback) -> Unit,
card: SearchResponse, card: SearchResponse,
position: Int,
itemView: View, itemView: View,
nextFocusBehavior: Boolean? = null, nextFocusBehavior: Boolean? = null,
nextFocusUp: Int? = null, nextFocusUp: Int? = null,
@ -54,6 +55,7 @@ object SearchResultBuilder {
SearchClickCallback( SearchClickCallback(
if (card is DataStoreHelper.ResumeWatchingResult) SEARCH_ACTION_PLAY_FILE else SEARCH_ACTION_LOAD, if (card is DataStoreHelper.ResumeWatchingResult) SEARCH_ACTION_PLAY_FILE else SEARCH_ACTION_LOAD,
it, it,
position,
card card
) )
) )
@ -83,10 +85,16 @@ object SearchResultBuilder {
} }
bg.setOnLongClickListener { bg.setOnLongClickListener {
clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_SHOW_METADATA, it, card)) clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_SHOW_METADATA, it, position, card))
return@setOnLongClickListener true return@setOnLongClickListener true
} }
bg.setOnFocusChangeListener { view, b ->
if (b) {
clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_FOCUSED, view, position, card))
}
}
when (card) { when (card) {
is DataStoreHelper.ResumeWatchingResult -> { is DataStoreHelper.ResumeWatchingResult -> {
val pos = card.watchPos?.fixVisual() val pos = card.watchPos?.fixVisual()

View file

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

View file

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