From 3c7a14c82b1faf1a188ddcbf828b5332fe750c49 Mon Sep 17 00:00:00 2001 From: KingLucius Date: Wed, 6 Mar 2024 21:19:06 +0200 Subject: [PATCH] Marquee Result Buttons & Bookmark icon --- .../ui/result/ResultFragmentTv.kt | 99 +++++++++++++++++-- .../res/drawable/outline_bookmark_add_24.xml | 5 + .../main/res/layout/fragment_result_tv.xml | 47 +++++++-- 3 files changed, 133 insertions(+), 18 deletions(-) create mode 100644 app/src/main/res/drawable/outline_bookmark_add_24.xml diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt index f48b0e26..3f6b3343 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt @@ -327,6 +327,78 @@ class ResultFragmentTv : Fragment() { } } + resultPlayMovieButton.setOnFocusChangeListener { _, hasFocus -> + if (!hasFocus) { + resultPlayMovieText.isSelected = false + return@setOnFocusChangeListener + } + resultPlayMovieText.isSelected = true + } + + resultPlaySeriesButton.setOnFocusChangeListener { _, hasFocus -> + if (!hasFocus) { + resultPlaySeriesText.isSelected = false + return@setOnFocusChangeListener + } + resultPlaySeriesText.isSelected = true + } + + resultResumeSeriesButton.setOnFocusChangeListener { _, hasFocus -> + if (!hasFocus) { + resultResumeSeriesText.isSelected = false + return@setOnFocusChangeListener + } + resultResumeSeriesText.isSelected = true + } + + resultPlayTrailerButton.setOnFocusChangeListener { _, hasFocus -> + if (!hasFocus) { + resultPlayTrailerText.isSelected = false + return@setOnFocusChangeListener + } + resultPlayTrailerText.isSelected = true + } + + resultBookmarkButton.setOnFocusChangeListener { _, hasFocus -> + if (!hasFocus) { + resultBookmarkText.isSelected = false + return@setOnFocusChangeListener + } + resultBookmarkText.isSelected = true + } + + resultFavoriteButton.setOnFocusChangeListener { _, hasFocus -> + if (!hasFocus) { + resultFavoriteText.isSelected = false + return@setOnFocusChangeListener + } + resultFavoriteText.isSelected = true + } + + resultSubscribeButton.setOnFocusChangeListener { _, hasFocus -> + if (!hasFocus) { + resultSubscribeText.isSelected = false + return@setOnFocusChangeListener + } + resultSubscribeText.isSelected = true + } + + resultSearchButton.setOnFocusChangeListener { _, hasFocus -> + if (!hasFocus) { + resultSearchText.isSelected = false + return@setOnFocusChangeListener + } + resultSearchText.isSelected = true + } + + resultEpisodesShowButton.setOnFocusChangeListener { _, hasFocus -> + if (!hasFocus) { + resultEpisodesShowText.isSelected = false + return@setOnFocusChangeListener + } + resultEpisodesShowText.isSelected = true + } + resultEpisodes.setLinearListLayout( isHorizontal = false, nextUp = FOCUS_SELF, @@ -527,14 +599,25 @@ class ResultFragmentTv : Fragment() { observe(viewModel.watchStatus) { watchType -> binding?.apply { resultBookmarkText.setText(watchType.stringRes) - resultBookmarkButton.setOnClickListener { view -> - activity?.showBottomDialog( - WatchType.entries.map { view.context.getString(it.stringRes) }.toList(), - watchType.ordinal, - view.context.getString(R.string.action_add_to_bookmarks), - showApply = false, - {}) { - viewModel.updateWatchStatus(WatchType.entries[it], context) + + resultBookmarkButton.apply { + + val drawable = if (watchType.stringRes == R.string.type_none) { + R.drawable.outline_bookmark_add_24 + } else { + R.drawable.ic_baseline_bookmark_24 + } + setIconResource(drawable) + + setOnClickListener { view -> + activity?.showBottomDialog( + WatchType.entries.map { view.context.getString(it.stringRes) }.toList(), + watchType.ordinal, + view.context.getString(R.string.action_add_to_bookmarks), + showApply = false, + {}) { + viewModel.updateWatchStatus(WatchType.entries[it], context) + } } } } diff --git a/app/src/main/res/drawable/outline_bookmark_add_24.xml b/app/src/main/res/drawable/outline_bookmark_add_24.xml new file mode 100644 index 00000000..a4e18af3 --- /dev/null +++ b/app/src/main/res/drawable/outline_bookmark_add_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/fragment_result_tv.xml b/app/src/main/res/layout/fragment_result_tv.xml index 2c0c7140..63dc7de2 100644 --- a/app/src/main/res/layout/fragment_result_tv.xml +++ b/app/src/main/res/layout/fragment_result_tv.xml @@ -289,7 +289,10 @@ https://developer.android.com/design/ui/tv/samples/jet-fit android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top|center_horizontal" - android:minLines="2" + android:singleLine="true" + android:scrollHorizontally="true" + android:marqueeRepeatLimit="marquee_forever" + android:ellipsize="marquee" android:text="@string/movie" /> @@ -319,7 +322,10 @@ https://developer.android.com/design/ui/tv/samples/jet-fit android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top|center_horizontal" - android:minLines="2" + android:singleLine="true" + android:scrollHorizontally="true" + android:marqueeRepeatLimit="marquee_forever" + android:ellipsize="marquee" android:text="@string/episode" /> @@ -347,7 +353,10 @@ https://developer.android.com/design/ui/tv/samples/jet-fit android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top|center_horizontal" - android:minLines="2" + android:singleLine="true" + android:scrollHorizontally="true" + android:marqueeRepeatLimit="marquee_forever" + android:ellipsize="marquee" android:text="@string/resume" /> @@ -375,7 +384,10 @@ https://developer.android.com/design/ui/tv/samples/jet-fit android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top|center_horizontal" - android:minLines="2" + android:singleLine="true" + android:scrollHorizontally="true" + android:marqueeRepeatLimit="marquee_forever" + android:ellipsize="marquee" android:text="@string/play_trailer_button" /> @@ -392,7 +404,7 @@ https://developer.android.com/design/ui/tv/samples/jet-fit android:focusable="true" style="@style/ResultSmallButtonTV" app:iconPadding="0dp" - app:icon="@drawable/ic_baseline_bookmark_24" + app:icon="@drawable/outline_bookmark_add_24" android:nextFocusUp="@id/result_bookmark_Button" android:nextFocusDown="@id/result_description" android:tag="@string/tv_no_focus_tag"> @@ -403,7 +415,10 @@ https://developer.android.com/design/ui/tv/samples/jet-fit android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top|center_horizontal" - android:minLines="2" + android:singleLine="true" + android:scrollHorizontally="true" + android:marqueeRepeatLimit="marquee_forever" + android:ellipsize="marquee" android:text="@string/type_none" /> @@ -431,7 +446,10 @@ https://developer.android.com/design/ui/tv/samples/jet-fit android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top|center_horizontal" - android:minLines="2" + android:singleLine="true" + android:scrollHorizontally="true" + android:marqueeRepeatLimit="marquee_forever" + android:ellipsize="marquee" android:text="@string/favorite" /> @@ -459,7 +477,10 @@ https://developer.android.com/design/ui/tv/samples/jet-fit android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top|center_horizontal" - android:minLines="2" + android:singleLine="true" + android:scrollHorizontally="true" + android:marqueeRepeatLimit="marquee_forever" + android:ellipsize="marquee" android:text="@string/action_subscribe" /> @@ -487,7 +508,10 @@ https://developer.android.com/design/ui/tv/samples/jet-fit android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top|center_horizontal" - android:minLines="2" + android:singleLine="true" + android:scrollHorizontally="true" + android:marqueeRepeatLimit="marquee_forever" + android:ellipsize="marquee" android:text="@string/result_search" /> @@ -518,7 +542,10 @@ https://developer.android.com/design/ui/tv/samples/jet-fit android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top|center_horizontal" - android:minLines="2" + android:singleLine="true" + android:scrollHorizontally="true" + android:marqueeRepeatLimit="marquee_forever" + android:ellipsize="marquee" android:text="@string/episodes" />