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 c88a7471..ed5ed49c 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 @@ -15,6 +15,7 @@ import androidx.core.view.isVisible import androidx.core.widget.NestedScrollView import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels +import androidx.preference.PreferenceManager import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearSnapHelper @@ -97,6 +98,7 @@ class HomeFragment : Fragment() { companion object { val configEvent = Event() var currentSpan = 1 + val listHomepageItems = mutableListOf() fun Activity.loadHomepageList(item: HomePageList) { val context = this @@ -358,6 +360,7 @@ class HomeFragment : Fragment() { } private var currentApiName: String? = null + private var toggleRandomButton = false @SuppressLint("SetTextI18n") override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -367,6 +370,21 @@ class HomeFragment : Fragment() { home_change_api?.setOnClickListener(apiChangeClickListener) home_change_api_loading?.setOnClickListener(apiChangeClickListener) home_api_fab?.setOnClickListener(apiChangeClickListener) + home_random?.setOnClickListener { + if (listHomepageItems.isNotEmpty()) { + activity.loadSearchResult(listHomepageItems.random()) + } + } + + //Disable Random button, if its toggled off on settings + context?.let { + val settingsManager = PreferenceManager.getDefaultSharedPreferences(it) + toggleRandomButton = settingsManager.getBoolean(getString(R.string.random_button_key), false) + home_random?.isVisible = toggleRandomButton + if (!toggleRandomButton) { + home_random?.visibility = View.GONE + } + } observe(homeViewModel.apiName) { apiName -> currentApiName = apiName @@ -441,11 +459,13 @@ class HomeFragment : Fragment() { home_loading_shimmer?.stopShimmer() val d = data.value + listHomepageItems.clear() currentHomePage = d (home_master_recycler?.adapter as? ParentItemAdapter?)?.updateList( d?.items?.mapNotNull { try { + listHomepageItems.addAll(it.list.filterSearchResponse()) HomePageList(it.name, it.list.filterSearchResponse()) } catch (e: Exception) { logError(e) @@ -456,6 +476,9 @@ class HomeFragment : Fragment() { home_loading?.isVisible = false home_loading_error?.isVisible = false home_loaded?.isVisible = true + if (toggleRandomButton) { + home_random?.isVisible = listHomepageItems.isNotEmpty() + } } is Resource.Failure -> { home_loading_shimmer?.stopShimmer() @@ -791,9 +814,11 @@ class HomeFragment : Fragment() { val dy = scrollY - oldScrollY if (dy > 0) { //check for scroll down home_api_fab?.shrink() // hide + home_random?.shrink() } else if (dy < -5) { if (view?.context?.isTvSettings() == false) { home_api_fab?.extend() // show + home_random?.extend() } } }) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt index b3fad151..5e31e912 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt @@ -499,13 +499,21 @@ open class FullScreenPlayer : AbstractPlayerFragment() { private fun updateUIVisibility() { val isGone = isLocked || !isShowing + var togglePlayerTitleGone = isGone + context?.let { + val settingsManager = PreferenceManager.getDefaultSharedPreferences(it) + val limitTitle = settingsManager.getInt(getString(R.string.prefer_limit_title_key), 0) + if (limitTitle < 0) { + togglePlayerTitleGone = true + } + } 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 - player_video_title?.isGone = isGone + player_video_title?.isGone = togglePlayerTitleGone player_video_title_rez?.isGone = isGone player_episode_filler?.isGone = isGone player_center_menu?.isGone = isGone diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt index 32586b43..116e0830 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt @@ -569,11 +569,17 @@ class GeneratorPlayer : FullScreenPlayer() { } else { "" } - //Truncate video title if it exceeds limit - val differenceInLength = playerVideoTitle.length - limitTitle - val margin = 3 //If the difference is smaller than or equal to this value, ignore it - if (limitTitle > 0 && differenceInLength > margin) { - playerVideoTitle = playerVideoTitle.substring(0, limitTitle - 1) + "..." + + //Hide title, if set in setting + if (limitTitle < 0) { + player_video_title?.visibility = View.GONE + } else { + //Truncate video title if it exceeds limit + val differenceInLength = playerVideoTitle.length - limitTitle + val margin = 3 //If the difference is smaller than or equal to this value, ignore it + if (limitTitle > 0 && differenceInLength > margin) { + playerVideoTitle = playerVideoTitle.substring(0, limitTitle-1) + "..." + } } player_episode_filler_holder?.isVisible = isFiller ?: false diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 246fdb95..9e8a302c 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -512,4 +512,14 @@ style="@style/ExtendedFloatingActionButton" android:textColor="?attr/textColor" tools:ignore="ContentDescription" /> + \ No newline at end of file diff --git a/app/src/main/res/layout/player_custom_layout.xml b/app/src/main/res/layout/player_custom_layout.xml index ce22c3e3..6a60d2e2 100644 --- a/app/src/main/res/layout/player_custom_layout.xml +++ b/app/src/main/res/layout/player_custom_layout.xml @@ -133,6 +133,7 @@ android:gravity="center" android:textColor="@color/white" android:textStyle="bold" + android:visibility="visible" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" tools:text="Hello world" /> diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml index ff244c9d..e7a11105 100644 --- a/app/src/main/res/values/array.xml +++ b/app/src/main/res/values/array.xml @@ -65,6 +65,7 @@ 32 characters 64 characters 128 characters + Hide Title 0 @@ -72,6 +73,7 @@ 32 64 128 + -1 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6baeefa8..eebbf0dd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -30,6 +30,7 @@ swipe_vertical_enabled_key display_sub_key show_fillers_key + random_button_key provider_lang_key dns_key download_path_key @@ -352,7 +353,7 @@ Skip this Update Update Preferred watch quality - Limit title characters on player + Video player title max chars. Video buffer size Video buffer length Video cache on disk @@ -393,6 +394,8 @@ CloudStream 3 at your own risk. General + Random Button + Show random button on Homepage Provider Languages App Layout Preferred Media @@ -467,6 +470,7 @@ Background Source + Random Coming soon… diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index e70d7ad9..a28efef5 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -111,6 +111,12 @@ android:key="general" android:title="@string/general" app:isPreferenceVisible="true"> +