From 017020fb03311800a2acb932758ba5098ea956f7 Mon Sep 17 00:00:00 2001 From: C10udburst <18114966+C10udburst@users.noreply.github.com> Date: Sun, 14 Aug 2022 13:49:14 +0200 Subject: [PATCH] add "Others" category --- app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt | 1 + .../com/lagradost/cloudstream3/ui/home/HomeFragment.kt | 5 ++++- .../lagradost/cloudstream3/ui/result/ResultViewModel2.kt | 2 ++ .../com/lagradost/cloudstream3/ui/search/SearchFragment.kt | 7 +++++-- .../cloudstream3/ui/settings/extensions/PluginsFragment.kt | 3 ++- .../ui/settings/extensions/PluginsViewModel.kt | 5 ++++- app/src/main/res/layout/fragment_plugins.xml | 6 ++++++ app/src/main/res/layout/fragment_search.xml | 6 ++++++ app/src/main/res/layout/home_select_mainpage.xml | 6 ++++++ app/src/main/res/values-pl/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 11 files changed, 40 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt index 80f42ac8..b5ab4769 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt @@ -555,6 +555,7 @@ enum class TvType { Documentary, AsianDrama, Live, + Others } // IN CASE OF FUTURE ANIME MOVIE OR SMTH 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 dd96cc96..3a5d99da 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 @@ -252,6 +252,7 @@ class HomeFragment : Fragment() { movies: MaterialButton?, asian: MaterialButton?, livestream: MaterialButton?, + others: MaterialButton?, ): List>> { return listOf( Pair(anime, listOf(TvType.Anime, TvType.OVA, TvType.AnimeMovie)), @@ -261,6 +262,7 @@ class HomeFragment : Fragment() { Pair(movies, listOf(TvType.Movie, TvType.Torrent)), Pair(asian, listOf(TvType.AsianDrama)), Pair(livestream, listOf(TvType.Live)), + Pair(others, listOf(TvType.Others)), ) } @@ -295,10 +297,11 @@ class HomeFragment : Fragment() { val movies = dialog.findViewById(R.id.home_select_movies) val asian = dialog.findViewById(R.id.home_select_asian) val livestream = dialog.findViewById(R.id.home_select_livestreams) + val others = dialog.findViewById(R.id.home_select_others) val cancelBtt = dialog.findViewById(R.id.cancel_btt) val applyBtt = dialog.findViewById(R.id.apply_btt) - val pairList = getPairList(anime, cartoons, tvs, docs, movies, asian, livestream) + val pairList = getPairList(anime, cartoons, tvs, docs, movies, asian, livestream, others) cancelBtt?.setOnClickListener { dialog.dismissSafe() diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt index cf12fab0..eed7a65c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt @@ -197,6 +197,7 @@ fun LoadResponse.toResultData(repo: APIRepository): ResultData { TvType.Torrent -> R.string.torrent_singular TvType.AsianDrama -> R.string.asian_drama_singular TvType.Live -> R.string.live_singular + TvType.Others -> R.string.other_singular } ), yearText = txt(year?.toString()), @@ -549,6 +550,7 @@ class ResultViewModel2 : ViewModel() { TvType.Documentary -> "Documentaries" TvType.AsianDrama -> "AsianDrama" TvType.Live -> "LiveStreams" + TvType.Others -> "Others" } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt index d05d8807..7616cb97 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt @@ -169,6 +169,7 @@ class SearchFragment : Fragment() { val asian = dialog.findViewById(R.id.home_select_asian) val livestream = dialog.findViewById(R.id.home_select_livestreams) + val other = dialog.findViewById(R.id.home_select_others) val cancelBtt = dialog.findViewById(R.id.cancel_btt) val applyBtt = dialog.findViewById(R.id.apply_btt) @@ -180,7 +181,8 @@ class SearchFragment : Fragment() { docs, movies, asian, - livestream + livestream, + other ) cancelBtt?.setOnClickListener { @@ -297,7 +299,8 @@ class SearchFragment : Fragment() { search_select_documentaries, search_select_movies, search_select_asian, - search_select_livestreams + search_select_livestreams, + search_select_others ) val settingsManager = context?.let { PreferenceManager.getDefaultSharedPreferences(it) } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsFragment.kt index 4d053606..8bc980ed 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsFragment.kt @@ -112,7 +112,8 @@ class PluginsFragment : Fragment() { home_select_documentaries, home_select_movies, home_select_asian, - home_select_livestreams + home_select_livestreams, + home_select_others ) // Copy pasted code diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsViewModel.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsViewModel.kt index c4bdfb3e..605ba328 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsViewModel.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsViewModel.kt @@ -175,7 +175,10 @@ class PluginsViewModel : ViewModel() { // Perhaps can be optimized? private fun List.filterTvTypes(): List { if (tvTypes.isEmpty()) return this - return this.filter { it.plugin.second.tvTypes?.any { type -> tvTypes.contains(type) } == true } + return this.filter { + (it.plugin.second.tvTypes?.any { type -> tvTypes.contains(type) } == true) || + (tvTypes.contains("Others") && (it.plugin.second.tvTypes ?: emptyList()).isEmpty()) + } } private fun List.sortByQuery(query: String?): List { diff --git a/app/src/main/res/layout/fragment_plugins.xml b/app/src/main/res/layout/fragment_plugins.xml index 43576ca9..45255d6d 100644 --- a/app/src/main/res/layout/fragment_plugins.xml +++ b/app/src/main/res/layout/fragment_plugins.xml @@ -110,6 +110,12 @@ android:nextFocusLeft="@id/home_select_documentaries" android:text="@string/livestreams" /> + + diff --git a/app/src/main/res/layout/fragment_search.xml b/app/src/main/res/layout/fragment_search.xml index fb1d6e41..cb816083 100644 --- a/app/src/main/res/layout/fragment_search.xml +++ b/app/src/main/res/layout/fragment_search.xml @@ -146,6 +146,12 @@ style="@style/RoundedSelectableButton" android:nextFocusLeft="@id/search_select_documentaries" android:text="@string/livestreams" /> + + diff --git a/app/src/main/res/layout/home_select_mainpage.xml b/app/src/main/res/layout/home_select_mainpage.xml index 99ee4fe2..d03234c1 100644 --- a/app/src/main/res/layout/home_select_mainpage.xml +++ b/app/src/main/res/layout/home_select_mainpage.xml @@ -104,6 +104,12 @@ android:nextFocusLeft="@id/home_select_documentaries" android:text="@string/livestreams" /> + + diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 6334a932..90aa8699 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -427,4 +427,6 @@ Dodaj repozytorium aby zainstalować rozszerzenia Ocenione %d na 10 + Inne + Wideo diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c5b830ed..3e739e69 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -333,6 +333,7 @@ OVA Asian Dramas Livestreams + Others Movie @@ -344,6 +345,7 @@ Documentary Asian Drama Livestream + Video Source error Remote error