diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TrailersToProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TrailersToProvider.kt index 691bdf41..d90c5de9 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TrailersToProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/TrailersToProvider.kt @@ -200,6 +200,8 @@ class TrailersToProvider : MainAPI() { override fun load(url: String): LoadResponse { val response = khttp.get(url) val document = Jsoup.parse(response.text) + var title = document?.selectFirst("h2.breadcrumbs-custom-title > a")?.text() ?: throw ErrorLoadingException("Service might be unavailable") + val metaInfo = document.select("div.post-info-meta > ul.post-info-meta-list > li") val year = metaInfo?.get(0)?.selectFirst("> span.small-text")?.text()?.takeLast(4)?.toIntOrNull() val rating = parseRating(metaInfo?.get(1)?.selectFirst("> span.small-text")?.text()?.replace("/ 10", "")) @@ -208,7 +210,6 @@ class TrailersToProvider : MainAPI() { val trailer = metaInfo?.get(4)?.selectFirst("> a")?.attr("href") val poster = document.selectFirst("div.slider-image > a > img").attr("src") val descriptHeader = document.selectFirst("article.post-info") - var title = document.selectFirst("h2.breadcrumbs-custom-title > a").text() title = title.substring(0, title.length - 6) // REMOVE YEAR val descript = descriptHeader.select("> div > p").text() diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt index c0430f38..64e176fe 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt @@ -11,6 +11,7 @@ import android.view.View import android.view.ViewGroup import android.widget.FrameLayout import android.widget.TextView +import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.GridLayoutManager @@ -106,7 +107,7 @@ class HomeFragment : Fragment() { var currentMainList: ArrayList = ArrayList() private fun toggleMainVisibility(visible: Boolean) { - home_main_holder.visibility = if (visible) View.VISIBLE else View.GONE + home_main_holder.isVisible = visible } @SuppressLint("SetTextI18n") @@ -314,7 +315,7 @@ class HomeFragment : Fragment() { } observe(homeViewModel.bookmarks) { bookmarks -> - home_bookmarked_holder.visibility = if (bookmarks.isNotEmpty()) View.VISIBLE else View.GONE + home_bookmarked_holder.isVisible = bookmarks.isNotEmpty() (home_bookmarked_child_recyclerview?.adapter as HomeChildItemAdapter?)?.cardList = bookmarks home_bookmarked_child_recyclerview?.adapter?.notifyDataSetChanged() @@ -329,11 +330,11 @@ class HomeFragment : Fragment() { } observe(homeViewModel.resumeWatching) { resumeWatching -> - home_watch_holder.visibility = if (resumeWatching.isNotEmpty()) View.VISIBLE else View.GONE + home_watch_holder?.isVisible = resumeWatching.isNotEmpty() (home_watch_child_recyclerview?.adapter as HomeChildItemAdapter?)?.cardList = resumeWatching home_watch_child_recyclerview?.adapter?.notifyDataSetChanged() - home_watch_child_more_info.setOnClickListener { + home_watch_child_more_info?.setOnClickListener { activity?.loadHomepageList( HomePageList( home_watch_parent_item_title?.text?.toString() ?: getString(R.string.continue_watching), diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt index 7591efe5..08bbb8ba 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt @@ -21,6 +21,7 @@ import android.view.MotionEvent import android.view.View import android.view.View.* import android.view.ViewGroup +import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.animation.AccelerateInterpolator import android.view.animation.AlphaAnimation import android.view.animation.Animation @@ -30,6 +31,7 @@ import android.widget.Toast.LENGTH_SHORT import androidx.appcompat.app.AlertDialog import androidx.core.content.ContextCompat import androidx.core.net.toUri +import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModelProvider import androidx.preference.PreferenceManager @@ -304,11 +306,11 @@ class PlayerFragment : Fragment() { if (event.rawX >= ctx.width / 2) { clicksRight++ if (!ctx.isLocked && ctx.doubleTapEnabled) onDoubleClickRight(clicksRight) - if (!ctx.isShowing) onSingleClick() + //if (!ctx.isShowing) onSingleClick() } else { clicksLeft++ if (!ctx.isLocked && ctx.doubleTapEnabled) onDoubleClickLeft(clicksLeft) - if (!ctx.isShowing) onSingleClick() + //if (!ctx.isShowing) onSingleClick() } } else if (clicksLeft == 0 && clicksRight == 0 && fingerLeftScreen) { // onSingleClick() @@ -325,8 +327,8 @@ class PlayerFragment : Fragment() { onSingleClick() } } - - if (ctx.isShowing && !ctx.isLocked && ctx.doubleTapEnabled) { +//ctx.isShowing && + if (!ctx.isLocked && ctx.doubleTapEnabled) { uiScope.launch { delay(doubleClickQualificationSpanInMillis + 1) check() @@ -346,7 +348,7 @@ class PlayerFragment : Fragment() { private fun onClickChange() { isShowing = !isShowing - click_overlay?.visibility = if (isShowing) GONE else VISIBLE + click_overlay?.isVisible = !isShowing val titleMove = if (isShowing) 0f else -50.toPx.toFloat() ObjectAnimator.ofFloat(video_title, "translationY", titleMove).apply { @@ -382,10 +384,24 @@ class PlayerFragment : Fragment() { } if (!isLocked) { + player_ffwd_holder?.alpha = 1f + player_rew_holder?.alpha = 1f + player_pause_holder?.alpha = 1f + shadow_overlay?.startAnimation(fadeAnimation) + player_ffwd_holder?.startAnimation(fadeAnimation) + player_rew_holder?.startAnimation(fadeAnimation) + player_pause_holder?.startAnimation(fadeAnimation) + } else { + //player_ffwd_holder?.alpha = 0f + //player_ffwd_holder?.alpha = 0f + //player_pause_holder?.alpha = 0f } - video_holder?.startAnimation(fadeAnimation) - player_torrent_info?.visibility = if (isTorrent && isShowing) VISIBLE else GONE + + bottom_player_bar.startAnimation(fadeAnimation) + player_top_holder.startAnimation(fadeAnimation) + // video_holder?.startAnimation(fadeAnimation) + player_torrent_info?.isVisible = (isTorrent && isShowing) // player_torrent_info?.startAnimation(fadeAnimation) //video_lock_holder?.startAnimation(fadeAnimation) } @@ -614,10 +630,6 @@ class PlayerFragment : Fragment() { } } - private fun View.setVis(visible: Boolean) { - this.visibility = if (visible) VISIBLE else GONE - } - fun changeSkip(position: Long? = null) { val data = localData @@ -639,17 +651,17 @@ class PlayerFragment : Fragment() { val isAnime = data.isAnimeBased()//(data is AnimeLoadResponse && (data.type == TvType.Anime || data.type == TvType.ONA)) - skip_op?.setVis(isAnime && !nextEp) - skip_episode?.setVis((!isAnime || nextEp) && hasNext) + skip_op?.isVisible = (isAnime && !nextEp) + skip_episode?.isVisible = ((!isAnime || nextEp) && hasNext) } else { val isAnime = data.isAnimeBased() if (isAnime) { - skip_op?.setVis(true) - skip_episode?.setVis(false) + skip_op?.isVisible = true + skip_episode?.isVisible = false } else { - skip_episode?.setVis(data.isEpisodeBased()) - skip_op?.setVis(false) + skip_episode?.isVisible = data.isEpisodeBased() + skip_op?.isVisible = false } } } @@ -690,7 +702,7 @@ class PlayerFragment : Fragment() { val alphaAnimation = AlphaAnimation(0f, 1f) alphaAnimation.duration = 100 alphaAnimation.fillAfter = true - video_go_back_holder?.visibility = VISIBLE + video_go_back_holder_holder?.visibility = VISIBLE overlay_loading_skip_button?.visibility = VISIBLE loading_overlay?.startAnimation(alphaAnimation) @@ -798,6 +810,12 @@ class PlayerFragment : Fragment() { resize_player.isClickable = isClick exo_progress.isEnabled = isClick player_media_route_button.isEnabled = isClick + if (isClick) { + player_pause_holder.alpha = 1f + player_rew_holder.alpha = 1f + player_ffwd_holder.alpha = 1f + } + //video_go_back_holder2.isEnabled = isClick // Clickable doesn't seem to work on com.google.android.exoplayer2.ui.DefaultTimeBar @@ -973,6 +991,15 @@ class PlayerFragment : Fragment() { navigationBarHeight = requireContext().getNavigationBarHeight() statusBarHeight = requireContext().getStatusBarHeight() + /*player_pause_holder?.setOnClickListener { + if (this::exoPlayer.isInitialized) { + if (exoPlayer.isPlaying) + exoPlayer.pause() + else + exoPlayer.play() + } + }*/ + if (activity?.isCastApiAvailable() == true && !isDownloadedFile) { CastButtonFactory.setUpMediaRouteButton(activity, player_media_route_button) val castContext = CastContext.getSharedInstance(requireContext()) @@ -980,9 +1007,8 @@ class PlayerFragment : Fragment() { if (castContext.castState != CastState.NO_DEVICES_AVAILABLE) player_media_route_button.visibility = VISIBLE castContext.addCastStateListener { state -> if (player_media_route_button != null) { - if (state == CastState.NO_DEVICES_AVAILABLE) player_media_route_button.visibility = GONE else { - if (player_media_route_button.visibility == GONE) player_media_route_button.visibility = VISIBLE - } + player_media_route_button.isVisible = state != CastState.NO_DEVICES_AVAILABLE + if (state == CastState.CONNECTED) { if (!this::exoPlayer.isInitialized) return@addCastStateListener val links = sortUrls(getUrls() ?: return@addCastStateListener) @@ -1071,9 +1097,7 @@ class PlayerFragment : Fragment() { GONE else VISIBLE else VISIBLE - - player_media_route_button.visibility = - if (isDownloadedFile) GONE else VISIBLE + player_media_route_button.isVisible = !isDownloadedFile if (savedInstanceState != null) { currentWindow = savedInstanceState.getInt(STATE_RESUME_WINDOW) playbackPosition = savedInstanceState.getLong(STATE_RESUME_POSITION) @@ -1155,6 +1179,8 @@ class PlayerFragment : Fragment() { exo_rew_text.text = getString(R.string.rew_text_regular_format).format(fastForwardTime) exo_ffwd_text.text = getString(R.string.ffw_text_regular_format).format(fastForwardTime) fun rewind() { + player_rew_holder.alpha = 1f + val rotateLeft = AnimationUtils.loadAnimation(context, R.anim.rotate_left) exo_rew.startAnimation(rotateLeft) @@ -1167,6 +1193,7 @@ class PlayerFragment : Fragment() { override fun onAnimationEnd(animation: Animation?) { exo_rew_text.post { exo_rew_text.text = getString(R.string.rew_text_regular_format).format(fastForwardTime) + player_rew_holder.alpha = if (isShowing) 1f else 0f } } }) @@ -1180,6 +1207,7 @@ class PlayerFragment : Fragment() { } fun fastForward() { + player_ffwd_holder.alpha = 1f val rotateRight = AnimationUtils.loadAnimation(context, R.anim.rotate_right) exo_ffwd.startAnimation(rotateRight) @@ -1192,6 +1220,7 @@ class PlayerFragment : Fragment() { override fun onAnimationEnd(animation: Animation?) { exo_ffwd_text.post { exo_ffwd_text.text = getString(R.string.ffw_text_regular_format).format(fastForwardTime) + player_ffwd_holder.alpha = if (isShowing) 1f else 0f } } }) @@ -1224,7 +1253,10 @@ class PlayerFragment : Fragment() { fadeAnimation.fillAfter = true // MENUS - centerMenu.startAnimation(fadeAnimation) + //centerMenu.startAnimation(fadeAnimation) + player_pause_holder.startAnimation(fadeAnimation) + player_ffwd_holder.startAnimation(fadeAnimation) + player_rew_holder.startAnimation(fadeAnimation) player_media_route_button.startAnimation(fadeAnimation) //video_bar.startAnimation(fadeAnimation) @@ -1245,13 +1277,13 @@ class PlayerFragment : Fragment() { override fun onDoubleClickRight(clicks: Int) { if (!isLocked) { fastForward() - } + } else onSingleClick() } override fun onDoubleClickLeft(clicks: Int) { if (!isLocked) { rewind() - } + } else onSingleClick() } override fun onSingleClick() { @@ -1282,7 +1314,7 @@ class PlayerFragment : Fragment() { activity?.popCurrentPage() } - playback_speed_btt.visibility = if (playBackSpeedEnabled) VISIBLE else GONE + playback_speed_btt.isVisible = playBackSpeedEnabled playback_speed_btt.setOnClickListener { val speedsText = listOf("0.5x", "0.75x", "1x", "1.25x", "1.5x", "1.75x", "2x") val speedsNumbers = listOf(0.5f, 0.75f, 1f, 1.25f, 1.5f, 1.75f, 2f) @@ -1565,6 +1597,7 @@ class PlayerFragment : Fragment() { } override fun onDestroy() { + loading_overlay?.isVisible = false savePos() SubtitlesFragment.applyStyleEvent -= ::onSubStyleChanged @@ -1665,8 +1698,8 @@ class PlayerFragment : Fragment() { } // player_torrent_info?.visibility = if(isTorrent) VISIBLE else GONE // - isShowing = false - player_torrent_info?.visibility = GONE + isShowing = true + player_torrent_info?.isVisible = false //player_torrent_info?.alpha = 0f println("LOADED: ${uri} or ${currentUrl}") isCurrentlyPlaying = true @@ -1810,7 +1843,7 @@ class PlayerFragment : Fragment() { override fun onAnimationRepeat(animation: Animation?) {} override fun onAnimationEnd(animation: Animation?) { - loading_overlay.post { video_go_back_holder.visibility = GONE; } + loading_overlay.post { video_go_back_holder_holder.visibility = GONE; } } }) overlay_loading_skip_button.visibility = GONE @@ -1850,6 +1883,8 @@ class PlayerFragment : Fragment() { } } + player_view.performClick() + //TODO FIX video_title?.text = hName + if (isEpisodeBased) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel.kt index 72667198..3f212c64 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel.kt @@ -224,6 +224,15 @@ class ResultViewModel : ViewModel() { } } + private fun filterName(name : String?) : String? { + if(name == null) return null + Regex("[eE]pisode [0-9]*(.*)").find(name)?.groupValues?.get(1)?.let { + if(it.isEmpty()) + return null + } + return name + } + fun load(context: Context, url: String, apiName: String) = viewModelScope.launch { _resultResponse.postValue(Resource.Loading(url)) @@ -269,7 +278,7 @@ class ResultViewModel : ViewModel() { for ((index, i) in dataList.withIndex()) { episodes.add( context.buildResultEpisode( - i.name, + filterName(i.name), i.posterUrl, index + 1, //TODO MAKE ABLE TO NOT HAVE SOME EPISODE null, // TODO FIX SEASON @@ -291,7 +300,7 @@ class ResultViewModel : ViewModel() { for ((index, i) in d.episodes.withIndex()) { episodes.add( context.buildResultEpisode( - i.name, + filterName(i.name), i.posterUrl, i.episode ?: (index + 1), i.season, diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/DataStoreHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/DataStoreHelper.kt index 02a4d46c..70057f01 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/DataStoreHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/DataStoreHelper.kt @@ -118,6 +118,7 @@ object DataStoreHelper { fun Context.setViewPos(id: Int?, pos: Long, dur: Long) { if (id == null) return + if(dur < 10_000) return // too short setKey("$currentAccount/$VIDEO_POS_DUR", id.toString(), PosDur(pos, dur)) } diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt index 439ee7db..f97ec618 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt @@ -5,6 +5,7 @@ import android.content.Context import android.view.View import android.widget.* import androidx.appcompat.app.AlertDialog +import androidx.core.view.isVisible import androidx.core.view.marginLeft import androidx.core.view.marginRight import androidx.core.view.marginTop @@ -31,7 +32,7 @@ object SingleSelectionHelper { val cancelButton = dialog.findViewById(R.id.cancel_btt)!! val applyHolder = dialog.findViewById(R.id.apply_btt_holder)!! - applyHolder.visibility = if (realShowApply) View.VISIBLE else View.GONE + applyHolder.isVisible = realShowApply if (!realShowApply) { val params = listView.layoutParams as LinearLayout.LayoutParams params.setMargins(listView.marginLeft, listView.marginTop, listView.marginRight, 0) diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index 4cd85b4f..67dc28c2 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -3,7 +3,8 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" - android:layout_height="match_parent" xmlns:tools="http://schemas.android.com/tools" + android:layout_height="match_parent" + xmlns:tools="http://schemas.android.com/tools" android:orientation="horizontal" android:keepScreenOn="true" app:backgroundTint="@android:color/black" @@ -71,6 +72,7 @@ - - - - - - - - - + - - + + + + + + - + android:mediaRouteTypes="user" + android:visibility="visible" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toTopOf="parent" + /> + + + + + + - - + - - + android:layout_height="100dp"> + + + - - + - + - - - - + - - - - - - - - - - @@ -514,221 +500,276 @@ - - + - + - - + + + + + + + - + - - - + - + + + + + - - - - - + - - - + - + + + + + - - - + - - - - - + + + + + + - - - - - - + + + + + + + - - + - - - - - + />