GeneratorPlayer -> viewbinding, AbstractPlayerFragment -> findViewById,

parity between player_custom_layout_tv, player_custom_layout and  fragment_player, fragment_player_tv
This commit is contained in:
LagradOst 2023-07-17 21:47:27 +02:00
parent f30506a394
commit 4f28aef8f2
7 changed files with 441 additions and 149 deletions

View file

@ -9,13 +9,15 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.viewbinding.ViewBinding
import com.lagradost.cloudstream3.databinding.FragmentHomeBinding
import com.lagradost.cloudstream3.databinding.FragmentHomeTvBinding
import com.lagradost.cloudstream3.databinding.FragmentPlayerBinding
import com.lagradost.cloudstream3.databinding.FragmentPlayerTvBinding
import com.lagradost.cloudstream3.databinding.FragmentSearchBinding
import com.lagradost.cloudstream3.databinding.FragmentSearchTvBinding
import com.lagradost.cloudstream3.databinding.HomeResultGridBinding
import com.lagradost.cloudstream3.databinding.HomeScrollViewBinding
import com.lagradost.cloudstream3.databinding.HomeScrollViewTvBinding
import com.lagradost.cloudstream3.databinding.HomepageParentBinding
import com.lagradost.cloudstream3.databinding.HomepageParentTvBinding
import com.lagradost.cloudstream3.databinding.PlayerCustomLayoutBinding
import com.lagradost.cloudstream3.databinding.PlayerCustomLayoutTvBinding
import com.lagradost.cloudstream3.databinding.RepositoryItemBinding
import com.lagradost.cloudstream3.databinding.RepositoryItemTvBinding
import com.lagradost.cloudstream3.databinding.SearchResultGridBinding
@ -80,6 +82,15 @@ class ExampleInstrumentedTest {
// testAllLayouts<ActivityMainBinding>(activity,R.layout.activity_main, R.layout.activity_main_tv)
//testAllLayouts<ActivityMainBinding>(activity, R.layout.activity_main_tv)
testAllLayouts<FragmentPlayerBinding>(activity, R.layout.fragment_player,R.layout.fragment_player_tv)
testAllLayouts<FragmentPlayerTvBinding>(activity, R.layout.fragment_player,R.layout.fragment_player_tv)
testAllLayouts<PlayerCustomLayoutBinding>(activity, R.layout.player_custom_layout,R.layout.player_custom_layout_tv)
testAllLayouts<PlayerCustomLayoutTvBinding>(activity, R.layout.player_custom_layout,R.layout.player_custom_layout_tv)
testAllLayouts<RepositoryItemBinding>(activity, R.layout.repository_item_tv, R.layout.repository_item)
testAllLayouts<RepositoryItemTvBinding>(activity, R.layout.repository_item_tv, R.layout.repository_item)
testAllLayouts<RepositoryItemBinding>(activity, R.layout.repository_item_tv, R.layout.repository_item)
testAllLayouts<RepositoryItemTvBinding>(activity, R.layout.repository_item_tv, R.layout.repository_item)

View file

@ -12,6 +12,9 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.Toast
import androidx.annotation.LayoutRes
import androidx.annotation.StringRes
@ -24,6 +27,7 @@ import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.PlaybackException
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout
import com.google.android.exoplayer2.ui.PlayerView
import com.google.android.exoplayer2.ui.SubtitleView
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
import com.lagradost.cloudstream3.AcraApplication.Companion.setKey
@ -42,8 +46,6 @@ import com.lagradost.cloudstream3.utils.EpisodeSkip
import com.lagradost.cloudstream3.utils.UIHelper
import com.lagradost.cloudstream3.utils.UIHelper.hideSystemUI
import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage
import kotlinx.android.synthetic.main.fragment_player.*
import kotlinx.android.synthetic.main.player_custom_layout.*
enum class PlayerResize(@StringRes val nameRes: Int) {
Fit(R.string.resize_fit),
@ -72,6 +74,12 @@ abstract class AbstractPlayerFragment(
var isBuffering = true
protected open var hasPipModeSupport = true
lateinit var playerPausePlayHolderHolder : FrameLayout
lateinit var playerPausePlay : ImageView
lateinit var playerBuffering : ProgressBar
var playerView : PlayerView? = null
var piphide : FrameLayout? = null
var subtitleHolder : FrameLayout? = null
@LayoutRes
protected var layout: Int = R.layout.fragment_player
@ -133,15 +141,15 @@ abstract class AbstractPlayerFragment(
isBuffering = CSPlayerLoading.IsBuffering == isPlaying
if (isBuffering) {
player_pause_play_holder_holder?.isVisible = false
player_buffering?.isVisible = true
playerPausePlayHolderHolder.isVisible = false
playerBuffering.isVisible = true
} else {
player_pause_play_holder_holder?.isVisible = true
player_buffering?.isVisible = false
playerPausePlayHolderHolder.isVisible = true
playerBuffering.isVisible = false
if (wasPlaying != isPlaying) {
player_pause_play?.setImageResource(if (isPlayingRightNow) R.drawable.play_to_pause else R.drawable.pause_to_play)
val drawable = player_pause_play?.drawable
playerPausePlay.setImageResource(if (isPlayingRightNow) R.drawable.play_to_pause else R.drawable.pause_to_play)
val drawable = playerPausePlay.drawable
var startedAnimation = false
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
@ -163,10 +171,10 @@ abstract class AbstractPlayerFragment(
// somehow the phone is wacked
if (!startedAnimation) {
player_pause_play?.setImageResource(if (isPlayingRightNow) R.drawable.netflix_pause else R.drawable.netflix_play)
playerPausePlay.setImageResource(if (isPlayingRightNow) R.drawable.netflix_pause else R.drawable.netflix_play)
}
} else {
player_pause_play?.setImageResource(if (isPlayingRightNow) R.drawable.netflix_pause else R.drawable.netflix_play)
playerPausePlay.setImageResource(if (isPlayingRightNow) R.drawable.netflix_pause else R.drawable.netflix_play)
}
}
@ -326,9 +334,9 @@ abstract class AbstractPlayerFragment(
}
// Necessary for multiple combined videos
player_view?.setShowMultiWindowTimeBar(true)
player_view?.player = player
player_view?.performClick()
playerView?.setShowMultiWindowTimeBar(true)
playerView?.player = player
playerView?.performClick()
}
}
@ -386,9 +394,9 @@ abstract class AbstractPlayerFragment(
)
if (player is CS3IPlayer) {
subView = player_view?.findViewById(R.id.exo_subtitles)
subView = playerView?.findViewById(R.id.exo_subtitles)
subStyle = SubtitlesFragment.getCurrentSavedStyle()
player.initSubtitles(subView, subtitle_holder, subStyle)
player.initSubtitles(subView, subtitleHolder, subStyle)
SubtitlesFragment.applyStyleEvent += ::onSubStyleChanged
@ -456,7 +464,7 @@ abstract class AbstractPlayerFragment(
PlayerResize.Fit -> AspectRatioFrameLayout.RESIZE_MODE_FIT
PlayerResize.Zoom -> AspectRatioFrameLayout.RESIZE_MODE_ZOOM
}
player_view?.resizeMode = type
playerView?.resizeMode = type
if (showToast)
showToast(resize.nameRes, Toast.LENGTH_SHORT)
@ -480,6 +488,13 @@ abstract class AbstractPlayerFragment(
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(layout, container, false)
val root = inflater.inflate(layout, container, false)
playerPausePlayHolderHolder = root.findViewById(R.id.player_pause_play_holder_holder)
playerPausePlay = root.findViewById(R.id.player_pause_play)
playerBuffering = root.findViewById(R.id.player_buffering)
playerView = root.findViewById(R.id.player_view)
piphide = root.findViewById(R.id.piphide)
subtitleHolder = root.findViewById(R.id.subtitle_holder)
return root
}
}

View file

@ -63,7 +63,6 @@ import kotlinx.android.synthetic.main.player_custom_layout.player_center_menu
import kotlinx.android.synthetic.main.player_custom_layout.player_ffwd_holder
import kotlinx.android.synthetic.main.player_custom_layout.player_holder
import kotlinx.android.synthetic.main.player_custom_layout.player_pause_play
import kotlinx.android.synthetic.main.player_custom_layout.player_pause_play_holder
import kotlinx.android.synthetic.main.player_custom_layout.player_progressbar_left
import kotlinx.android.synthetic.main.player_custom_layout.player_progressbar_left_holder
import kotlinx.android.synthetic.main.player_custom_layout.player_progressbar_left_icon
@ -605,7 +604,7 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
}
player_lock_holder?.isGone = isGone
player_video_bar?.isGone = isGone
player_pause_play_holder?.isGone = isGone
player_pause_play?.isGone = isGone
//player_buffering?.isGone = isGone
player_top_holder?.isGone = isGone

View file

@ -25,6 +25,11 @@ import com.hippo.unifile.UniFile
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.APIHolder.getApiFromNameNull
import com.lagradost.cloudstream3.CommonActivity.showToast
import com.lagradost.cloudstream3.databinding.DialogOnlineSubtitlesBinding
import com.lagradost.cloudstream3.databinding.FragmentPlayerBinding
import com.lagradost.cloudstream3.databinding.PlayerCustomLayoutBinding
import com.lagradost.cloudstream3.databinding.PlayerSelectSourceAndSubsBinding
import com.lagradost.cloudstream3.databinding.PlayerSelectTracksBinding
import com.lagradost.cloudstream3.mvvm.*
import com.lagradost.cloudstream3.subtitles.AbstractSubtitleEntities
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.subtitleProviders
@ -33,8 +38,6 @@ import com.lagradost.cloudstream3.ui.player.CustomDecoder.Companion.updateForced
import com.lagradost.cloudstream3.ui.player.PlayerSubtitleHelper.Companion.toSubtitleMimeType
import com.lagradost.cloudstream3.ui.player.source_priority.QualityDataHelper
import com.lagradost.cloudstream3.ui.player.source_priority.QualityProfileDialog
import com.lagradost.cloudstream3.ui.player.source_priority.SourcePriority
import com.lagradost.cloudstream3.ui.player.source_priority.SourcePriorityDialog
import com.lagradost.cloudstream3.ui.result.*
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.getAutoSelectLanguageISO639_1
@ -49,18 +52,8 @@ import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
import com.lagradost.cloudstream3.utils.UIHelper.hideSystemUI
import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage
import com.lagradost.cloudstream3.utils.UIHelper.toPx
import kotlinx.android.synthetic.main.dialog_online_subtitles.*
import kotlinx.android.synthetic.main.dialog_online_subtitles.apply_btt
import kotlinx.android.synthetic.main.dialog_online_subtitles.cancel_btt
import kotlinx.android.synthetic.main.fragment_player.*
import kotlinx.android.synthetic.main.player_custom_layout.*
import kotlinx.android.synthetic.main.player_select_source_and_subs.*
import kotlinx.android.synthetic.main.player_select_source_and_subs.subtitles_click_settings
import kotlinx.android.synthetic.main.player_select_tracks.*
import kotlinx.coroutines.Job
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.abs
class GeneratorPlayer : FullScreenPlayer() {
@ -98,12 +91,15 @@ class GeneratorPlayer : FullScreenPlayer() {
private var preferredAutoSelectSubtitles: String? = null // null means do nothing, "" means none
private var binding: FragmentPlayerBinding? = null
private var playerBinding: PlayerCustomLayoutBinding? = null
private fun startLoading() {
player.release()
currentSelectedSubtitles = null
isActive = false
overlay_loading_skip_button?.isVisible = false
player_loading_overlay?.isVisible = true
binding?.overlayLoadingSkipButton?.isVisible = false
binding?.playerLoadingOverlay?.isVisible = true
}
private fun setSubtitles(sub: SubtitleData?): Boolean {
@ -118,7 +114,7 @@ class GeneratorPlayer : FullScreenPlayer() {
override fun onTracksInfoChanged() {
val tracks = player.getVideoTracks()
player_tracks_btt?.isVisible =
playerBinding?.playerTracksBtt?.isVisible =
tracks.allVideoTracks.size > 1 || tracks.allAudioTracks.size > 1
// Only set the preferred language if it is available.
// Otherwise it may give some users audio track init failed!
@ -158,7 +154,7 @@ class GeneratorPlayer : FullScreenPlayer() {
if (link == null) return
// manage UI
player_loading_overlay?.isVisible = false
binding?.playerLoadingOverlay?.isVisible = false
uiReset()
currentSelectedLink = link
currentMeta = viewModel.getMeta()
@ -257,7 +253,9 @@ class GeneratorPlayer : FullScreenPlayer() {
val isSingleProvider = subsProviders.size == 1
val dialog = Dialog(context, R.style.AlertDialogCustomBlack)
dialog.setContentView(R.layout.dialog_online_subtitles)
val binding =
DialogOnlineSubtitlesBinding.inflate(LayoutInflater.from(context), null, false)
dialog.setContentView(binding.root)
var currentSubtitles: List<AbstractSubtitleEntities.SubtitleEntity> = emptyList()
var currentSubtitle: AbstractSubtitleEntities.SubtitleEntity? = null
@ -295,6 +293,7 @@ class GeneratorPlayer : FullScreenPlayer() {
imageViewEnd.setImageDrawable(drawableEnd)
}
@SuppressLint("SetTextI18n")
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
val view = convertView ?: LayoutInflater.from(context).inflate(layout, null)
@ -318,16 +317,16 @@ class GeneratorPlayer : FullScreenPlayer() {
}
dialog.show()
dialog.cancel_btt.setOnClickListener {
binding.cancelBtt.setOnClickListener {
dialog.dismissSafe()
}
dialog.subtitle_adapter.choiceMode = AbsListView.CHOICE_MODE_SINGLE
dialog.subtitle_adapter.adapter = arrayAdapter
binding.subtitleAdapter.choiceMode = AbsListView.CHOICE_MODE_SINGLE
binding.subtitleAdapter.adapter = arrayAdapter
val adapter =
dialog.subtitle_adapter.adapter as? ArrayAdapter<AbstractSubtitleEntities.SubtitleEntity>
binding.subtitleAdapter.adapter as? ArrayAdapter<AbstractSubtitleEntities.SubtitleEntity>
dialog.subtitle_adapter.setOnItemClickListener { _, _, position, _ ->
binding.subtitleAdapter.setOnItemClickListener { _, _, position, _ ->
currentSubtitle = currentSubtitles.getOrNull(position) ?: return@setOnItemClickListener
}
@ -343,16 +342,16 @@ class GeneratorPlayer : FullScreenPlayer() {
val currentTempMeta = getMetaData()
// bruh idk why it is not correct
val color = ColorStateList.valueOf(context.colorFromAttribute(R.attr.colorAccent))
dialog.search_loading_bar.progressTintList = color
dialog.search_loading_bar.indeterminateTintList = color
binding.searchLoadingBar.progressTintList = color
binding.searchLoadingBar.indeterminateTintList = color
observeNullable(viewModel.currentSubtitleYear) {
// When year is changed search again
dialog.subtitles_search.setQuery(dialog.subtitles_search.query, true)
dialog.year_btt.text = it?.toString() ?: txt(R.string.none).asString(context)
binding.subtitlesSearch.setQuery(binding.subtitlesSearch.query, true)
binding.yearBtt.text = it?.toString() ?: txt(R.string.none).asString(context)
}
dialog.year_btt?.setOnClickListener {
binding.yearBtt.setOnClickListener {
val none = txt(R.string.none).asString(context)
val currentYear = Calendar.getInstance().get(Calendar.YEAR)
val earliestYear = 1900
@ -380,10 +379,10 @@ class GeneratorPlayer : FullScreenPlayer() {
)
}
dialog.subtitles_search.setOnQueryTextListener(object :
binding.subtitlesSearch.setOnQueryTextListener(object :
androidx.appcompat.widget.SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean {
dialog.search_loading_bar?.show()
binding.searchLoadingBar.show()
ioSafe {
val search =
AbstractSubtitleEntities.SubtitleSearch(
@ -415,7 +414,7 @@ class GeneratorPlayer : FullScreenPlayer() {
// ugly ik
activity?.runOnUiThread {
setSubtitlesList(items)
dialog.search_loading_bar?.hide()
binding.searchLoadingBar.hide()
}
}
@ -427,7 +426,7 @@ class GeneratorPlayer : FullScreenPlayer() {
}
})
dialog.search_filter.setOnClickListener { view ->
binding.searchFilter.setOnClickListener { view ->
val lang639_1 = languages.map { it.ISO_639_1 }
activity?.showDialog(languages.map { it.languageName },
lang639_1.indexOf(currentLanguageTwoLetters),
@ -436,11 +435,11 @@ class GeneratorPlayer : FullScreenPlayer() {
true,
{ }) { index ->
currentLanguageTwoLetters = lang639_1[index]
dialog.subtitles_search.setQuery(dialog.subtitles_search.query, true)
binding.subtitlesSearch.setQuery(binding.subtitlesSearch.query, true)
}
}
dialog.apply_btt.setOnClickListener {
binding.applyBtt.setOnClickListener {
currentSubtitle?.let { currentSubtitle ->
providers.firstOrNull { it.idPrefix == currentSubtitle.idPrefix }?.let { api ->
ioSafe {
@ -466,7 +465,7 @@ class GeneratorPlayer : FullScreenPlayer() {
}
dialog.show()
dialog.subtitles_search.setQuery(currentTempMeta.name, true)
binding.subtitlesSearch.setQuery(currentTempMeta.name, true)
//TODO: Set year text from currently loaded movie on Player
//dialog.subtitles_search_year?.setText(currentTempMeta.year)
}
@ -557,13 +556,15 @@ class GeneratorPlayer : FullScreenPlayer() {
val currentSubtitles = sortSubs(currentSubs)
val sourceDialog = Dialog(ctx, R.style.AlertDialogCustomBlack)
sourceDialog.setContentView(R.layout.player_select_source_and_subs)
val binding =
PlayerSelectSourceAndSubsBinding.inflate(LayoutInflater.from(ctx), null, false)
sourceDialog.setContentView(binding.root)
selectSourceDialog = sourceDialog
sourceDialog.show()
val providerList = sourceDialog.sort_providers
val subtitleList = sourceDialog.sort_subtitles
val providerList = binding.sortProviders
val subtitleList = binding.sortSubtitles
val loadFromFileFooter: TextView =
layoutInflater.inflate(R.layout.sort_bottom_footer_add_choice, null) as TextView
@ -671,12 +672,12 @@ class GeneratorPlayer : FullScreenPlayer() {
}
}
sourceDialog.cancel_btt?.setOnClickListener {
binding.cancelBtt.setOnClickListener {
sourceDialog.dismissSafe(activity)
}
fun setProfileName(profile: Int) {
sourceDialog.source_settings_btt.setText(
binding.sourceSettingsBtt.setText(
QualityDataHelper.getProfileName(
profile
)
@ -684,7 +685,7 @@ class GeneratorPlayer : FullScreenPlayer() {
}
setProfileName(currentQualityProfile)
sourceDialog.profiles_click_settings.setOnClickListener {
binding.profilesClickSettings.setOnClickListener {
val activity = activity ?: return@setOnClickListener
QualityProfileDialog(
activity,
@ -698,7 +699,7 @@ class GeneratorPlayer : FullScreenPlayer() {
}.show()
}
sourceDialog.subtitles_encoding_format?.apply {
binding.subtitlesEncodingFormat.apply {
val settingsManager = PreferenceManager.getDefaultSharedPreferences(ctx)
val prefNames = ctx.resources.getStringArray(R.array.subtitles_encoding_list)
@ -711,7 +712,7 @@ class GeneratorPlayer : FullScreenPlayer() {
text = prefNames[if (index == -1) 0 else index]
}
sourceDialog.subtitles_click_settings?.setOnClickListener {
binding.subtitlesClickSettings.setOnClickListener {
val settingsManager = PreferenceManager.getDefaultSharedPreferences(ctx)
val prefNames = ctx.resources.getStringArray(R.array.subtitles_encoding_list)
@ -740,7 +741,7 @@ class GeneratorPlayer : FullScreenPlayer() {
}
}
sourceDialog.apply_btt?.setOnClickListener {
binding.applyBtt.setOnClickListener {
var init = false
if (sourceIndex != startSource) {
init = true
@ -780,18 +781,19 @@ class GeneratorPlayer : FullScreenPlayer() {
it.height?.times(-1)
}
val currentAudioTracks = tracks.allAudioTracks
val binding: PlayerSelectTracksBinding =
PlayerSelectTracksBinding.inflate(LayoutInflater.from(ctx), null, false)
val trackDialog = Dialog(ctx, R.style.AlertDialogCustomBlack)
trackDialog.setContentView(R.layout.player_select_tracks)
trackDialog.setContentView(binding.root)
trackDialog.show()
// selectTracksDialog = tracksDialog
val videosList = trackDialog.video_tracks_list
val audioList = trackDialog.auto_tracks_list
val videosList = binding.videoTracksList
val audioList = binding.autoTracksList
trackDialog.video_tracks_holder.isVisible = currentVideoTracks.size > 1
trackDialog.audio_tracks_holder.isVisible = currentAudioTracks.size > 1
binding.videoTracksHolder.isVisible = currentVideoTracks.size > 1
binding.audioTracksHolder.isVisible = currentAudioTracks.size > 1
fun dismiss() {
if (isPlaying) {
@ -856,11 +858,11 @@ class GeneratorPlayer : FullScreenPlayer() {
audioList.setItemChecked(which, true)
}
trackDialog.cancel_btt?.setOnClickListener {
binding.cancelBtt.setOnClickListener {
trackDialog.dismissSafe(activity)
}
trackDialog.apply_btt?.setOnClickListener {
binding.applyBtt.setOnClickListener {
val currentTrack = currentAudioTracks.getOrNull(audioIndexStart)
player.setPreferredAudioTrack(
currentTrack?.language, currentTrack?.id
@ -1029,8 +1031,10 @@ class GeneratorPlayer : FullScreenPlayer() {
if (meta.tvType.isAnimeOp()) isOpVisible = percentage < SKIP_OP_VIDEO_PERCENTAGE
}
}
player_skip_op?.isVisible = isOpVisible
player_skip_episode?.isVisible = !isOpVisible && viewModel.hasNextEpisode() == true
playerBinding?.playerSkipOp?.isVisible = isOpVisible
playerBinding?.playerSkipEpisode?.isVisible =
!isOpVisible && viewModel.hasNextEpisode() == true
if (percentage >= PRELOAD_NEXT_EPISODE_PERCENTAGE) {
viewModel.preLoadNextLinks()
@ -1167,7 +1171,7 @@ class GeneratorPlayer : FullScreenPlayer() {
//Hide title, if set in setting
if (limitTitle < 0) {
player_video_title?.visibility = View.GONE
playerBinding?.playerVideoTitle?.visibility = View.GONE
} else {
//Truncate video title if it exceeds limit
val differenceInLength = playerVideoTitle.length - limitTitle
@ -1178,8 +1182,8 @@ class GeneratorPlayer : FullScreenPlayer() {
}
val isFiller: Boolean? = (currentMeta as? ResultEpisode)?.isFiller
player_episode_filler_holder?.isVisible = isFiller ?: false
player_video_title?.text = playerVideoTitle
playerBinding?.playerEpisodeFillerHolder?.isVisible = isFiller ?: false
playerBinding?.playerVideoTitle?.text = playerVideoTitle
}
@SuppressLint("SetTextI18n")
@ -1200,8 +1204,10 @@ class GeneratorPlayer : FullScreenPlayer() {
3 -> "$source - $extra"
else -> ""
}
player_video_title_rez?.text = title
player_video_title_rez?.isVisible = title.isNotBlank()
playerBinding?.playerVideoTitleRez?.apply {
text = title
isVisible = title.isNotBlank()
}
}
override fun playerDimensionsLoaded(widthHeight: Pair<Int, Int>) {
@ -1229,7 +1235,18 @@ class GeneratorPlayer : FullScreenPlayer() {
unwrapBundle(savedInstanceState)
unwrapBundle(arguments)
return super.onCreateView(inflater, container, savedInstanceState)
val root = super.onCreateView(inflater, container, savedInstanceState) ?: return null
binding = FragmentPlayerBinding.bind(root).also { b ->
playerBinding = PlayerCustomLayoutBinding.bind(b.playerView.findViewById(R.id.player_holder))
}
return root
}
override fun onDestroyView() {
playerBinding = null
binding = null
super.onDestroyView()
}
var timestampShowState = false
@ -1242,7 +1259,7 @@ class GeneratorPlayer : FullScreenPlayer() {
skipIndex++
println("displayTimeStamp = $show")
timestampShowState = show
skip_chapter_button?.apply {
playerBinding?.skipChapterButton?.apply {
val showWidth = 170.toPx
val noShowWidth = 10.toPx
//if((show && width == showWidth) || (!show && width == noShowWidth)) {
@ -1262,7 +1279,7 @@ class GeneratorPlayer : FullScreenPlayer() {
from, to
).apply {
addListener(onEnd = {
if (!show) skip_chapter_button?.isVisible = false
if (!show) playerBinding?.skipChapterButton?.isVisible = false
})
addUpdateListener { valueAnimator ->
val value = valueAnimator.animatedValue as Int
@ -1282,10 +1299,10 @@ class GeneratorPlayer : FullScreenPlayer() {
override fun onTimestamp(timestamp: EpisodeSkip.SkipStamp?) {
if (timestamp != null) {
skip_chapter_button.setText(timestamp.uiText)
playerBinding?.skipChapterButton?.setText(timestamp.uiText)
displayTimeStamp(true)
val currentIndex = skipIndex
skip_chapter_button?.handler?.postDelayed({
playerBinding?.skipChapterButton?.handler?.postDelayed({
if (skipIndex == currentIndex)
displayTimeStamp(false)
}, 6000)
@ -1328,11 +1345,11 @@ class GeneratorPlayer : FullScreenPlayer() {
viewModel.loadLinks()
}
overlay_loading_skip_button?.setOnClickListener {
binding?.overlayLoadingSkipButton?.setOnClickListener {
startPlayer()
}
player_loading_go_back?.setOnClickListener {
binding?.playerLoadingGoBack?.setOnClickListener {
player.release()
activity?.popCurrentPage()
}
@ -1365,8 +1382,8 @@ class GeneratorPlayer : FullScreenPlayer() {
observe(viewModel.currentLinks) {
currentLinks = it
val turnVisible = it.isNotEmpty()
val wasGone = overlay_loading_skip_button?.isGone == true
overlay_loading_skip_button?.isVisible = turnVisible
val wasGone = binding?.overlayLoadingSkipButton?.isGone == true
binding?.overlayLoadingSkipButton?.isVisible = turnVisible
normalSafeApiCall {
if (currentLinks.any { link ->
@ -1379,7 +1396,7 @@ class GeneratorPlayer : FullScreenPlayer() {
}
if (turnVisible && wasGone) {
overlay_loading_skip_button?.requestFocus()
binding?.overlayLoadingSkipButton?.requestFocus()
}
}

View file

@ -54,7 +54,6 @@
android:background="@color/black_overlay" />
<RelativeLayout
android:id="@+id/player_time_menu"
android:layout_width="match_parent"
android:layout_height="200dp"
android:orientation="horizontal"
@ -199,12 +198,6 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:id="@+id/player_pause_play_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="uselessParent">
<ImageView
android:id="@+id/player_pause_play"
android:layout_width="70dp"
@ -222,7 +215,6 @@
app:tint="@color/white"
tools:ignore="ContentDescription" />
</FrameLayout>
</FrameLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/player_center_menu"

View file

@ -54,6 +54,118 @@
</LinearLayout>
-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="ltr"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/player_progressbar_left_holder"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="start"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/centerMenuView"
app:layout_constraintTop_toTopOf="parent"
tools:alpha="1"
tools:visibility="visible">
<!--VERY hacky layout -->
<ImageView
android:id="@+id/player_progressbar_left_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="220dp"
android:src="@drawable/ic_baseline_volume_up_24"
app:tint="@android:color/white"
tools:ignore="ContentDescription">
</ImageView>
<ProgressBar
android:id="@+id/player_progressbar_left"
style="@android:style/Widget.Material.ProgressBar.Horizontal"
android:layout_width="5dp"
android:layout_height="150dp"
android:layout_centerInParent="true"
android:layout_gravity="end|center_vertical"
android:layout_marginStart="40dp"
android:indeterminate="false"
android:max="100"
android:progress="100"
android:progressDrawable="@drawable/progress_drawable_vertical"
tools:progress="30" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/player_progressbar_right_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="right"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/centerMenuView"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:alpha="1"
tools:ignore="RtlHardcoded"
tools:visibility="visible">
<ImageView
android:id="@+id/player_progressbar_right_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="220dp"
android:src="@drawable/ic_baseline_brightness_7_24"
app:tint="@android:color/white"
tools:ignore="ContentDescription">
</ImageView>
<ProgressBar
android:id="@+id/player_progressbar_right"
style="@android:style/Widget.Material.ProgressBar.Horizontal"
android:layout_width="5dp"
android:layout_height="150dp"
android:layout_centerInParent="true"
android:layout_gravity="end|center_vertical"
android:layout_marginEnd="40dp"
android:indeterminate="false"
android:max="100"
android:progress="100"
android:progressDrawable="@drawable/progress_drawable_vertical" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="@+id/player_time_text"
android:layout_width="match_parent"
android:layout_height="200dp"
android:gravity="center"
android:shadowColor="@android:color/black"
android:shadowRadius="10.0"
android:textColor="@android:color/white"
android:textSize="30sp"
android:visibility="gone"
tools:text="+100"
tools:visibility="visible" />
<FrameLayout
android:id="@+id/player_pause_play_holder_holder"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/player_video_holder"
@ -61,18 +173,42 @@
android:layout_height="match_parent"
android:padding="16dp">
<com.google.android.material.button.MaterialButton
android:id="@+id/skip_chapter_button"
style="@style/NiceButton"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_marginEnd="100dp"
android:backgroundTint="@color/skipOpTransparent"
android:maxLines="1"
android:padding="10dp"
android:textColor="@color/white"
android:visibility="gone"
app:cornerRadius="@dimen/rounded_button_radius"
app:layout_constraintBottom_toTopOf="@+id/bottom_player_bar"
app:layout_constraintEnd_toEndOf="parent"
app:strokeColor="@color/white"
app:strokeWidth="1dp"
tools:text="Skip Opening"
tools:visibility="visible" />
<FrameLayout
android:id="@+id/player_top_holder"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/player_video_title"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="80dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="32dp"
android:orientation="vertical">
<TextView
android:id="@+id/player_video_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/white"
android:textSize="16sp"
@ -83,14 +219,25 @@
android:id="@+id/player_video_title_rez"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="80dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="32dp"
android:gravity="end"
android:textColor="@color/white"
android:textSize="16sp"
tools:text="1920x1080" />
<FrameLayout
android:id="@+id/player_episode_filler_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="2dp">
<com.google.android.material.button.MaterialButton
android:id="@+id/player_episode_filler"
style="@style/SmallBlackButton"
android:text="@string/filler" />
</FrameLayout>
</LinearLayout>
<!-- Removed as it has no use anymore-->
<!--<androidx.mediarouter.app.MediaRouteButton
android:id="@+id/player_media_route_button"
@ -131,6 +278,108 @@
</FrameLayout>
</FrameLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/player_center_menu"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_gravity="center"
android:gravity="center"
android:layoutDirection="ltr"
android:orientation="horizontal"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible">
<FrameLayout
android:visibility="gone"
android:id="@+id/player_rew_holder"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|start"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/player_ffwd_holder"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.5">
<TextView
android:id="@+id/exo_rew_text"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:gravity="center"
android:textColor="@color/white"
android:textSize="19sp"
android:textStyle="bold"
tools:text="10" />
<ImageButton
android:id="@id/exo_rew"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_gravity="center"
android:background="@drawable/video_tap_button_skip"
android:nextFocusLeft="@id/exo_rew"
android:nextFocusUp="@id/player_go_back"
android:nextFocusDown="@id/player_lock"
android:padding="10dp"
android:scaleType="fitCenter"
android:scaleX="-1"
android:src="@drawable/netflix_skip_forward"
android:tintMode="src_in"
app:tint="@color/white"
tools:ignore="ContentDescription" />
</FrameLayout>
<FrameLayout
android:visibility="gone"
android:id="@+id/player_ffwd_holder"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/player_rew_holder"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.5">
<TextView
android:id="@+id/exo_ffwd_text"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:gravity="center"
android:textColor="@color/white"
android:textSize="19sp"
android:textStyle="bold"
tools:text="10" />
<ImageButton
android:id="@id/exo_ffwd"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_gravity="center"
android:background="@drawable/video_tap_button_skip"
android:nextFocusRight="@id/exo_rew"
android:nextFocusUp="@id/player_go_back"
android:nextFocusDown="@id/player_lock"
android:padding="10dp"
android:scaleType="fitCenter"
android:src="@drawable/netflix_skip_forward"
android:tintMode="src_in"
app:tint="@color/white"
tools:ignore="ContentDescription" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<!--use for thinner app:trackThickness="3dp" com.google.android.material.progressindicator.CircularProgressIndicator-->
<ProgressBar
android:id="@+id/player_buffering"
@ -304,6 +553,22 @@
android:layout_height="match_parent"
android:orientation="horizontal">
<FrameLayout
android:visibility="gone"
android:layout_width="0dp"
android:layout_height="0dp">
<com.google.android.material.button.MaterialButton
android:id="@+id/player_lock"
style="@style/VideoButtonTV"
android:nextFocusLeft="@id/player_skip_episode"
android:nextFocusRight="@id/player_resize_btt"
android:nextFocusUp="@id/player_pause_play"
android:text="@string/video_lock"
android:visibility="gone"
app:icon="@drawable/video_locked" />
</FrameLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/player_resize_btt"
style="@style/VideoButtonTV"

View file

@ -109,12 +109,6 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:id="@+id/player_pause_play_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="uselessParent">
<ImageView
android:id="@+id/player_pause_play"
android:layout_width="70dp"
@ -132,7 +126,6 @@
app:tint="@color/white"
tools:ignore="ContentDescription" />
</FrameLayout>
</FrameLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/player_center_menu"