From 6b3eb0047f7df8804632c1f4dae056bff649adcb Mon Sep 17 00:00:00 2001 From: LagradOst <11805592+LagradOst@users.noreply.github.com> Date: Tue, 29 Mar 2022 23:50:07 +0200 Subject: [PATCH] fixed tv autoselect --- .../cloudstream3/ui/player/GeneratorPlayer.kt | 5 +- .../cloudstream3/ui/result/ResultFragment.kt | 15 +- .../ui/settings/SettingsFragment.kt | 6 +- .../main/res/layout/fragment_player_tv.xml | 46 +- app/src/main/res/layout/fragment_result.xml | 1053 +++++++++-------- 5 files changed, 567 insertions(+), 558 deletions(-) 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 76ae2f7e..6119df89 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 @@ -608,10 +608,11 @@ class GeneratorPlayer : FullScreenPlayer() { observe(viewModel.currentLinks) { currentLinks = it val turnVisible = it.isNotEmpty() - if (turnVisible && overlay_loading_skip_button?.isGone == true) { + val wasGone = overlay_loading_skip_button?.isGone == true + overlay_loading_skip_button?.isVisible = turnVisible + if (turnVisible && wasGone) { overlay_loading_skip_button?.requestFocus() } - overlay_loading_skip_button?.isVisible = turnVisible } observe(viewModel.currentSubs) { set -> diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt index fd3a27fe..48b65a58 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt @@ -60,6 +60,7 @@ import com.lagradost.cloudstream3.ui.player.SubtitleData import com.lagradost.cloudstream3.ui.quicksearch.QuickSearchFragment import com.lagradost.cloudstream3.ui.search.SearchAdapter import com.lagradost.cloudstream3.ui.search.SearchHelper +import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.getDownloadSubsLanguageISO639_1 import com.lagradost.cloudstream3.utils.* @@ -429,8 +430,18 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio 2 -> { result_bookmark_fab?.isGone = result_bookmark_fab?.context?.isTvSettings() == true result_bookmark_fab?.extend() - if (result_bookmark_button?.context?.isTvSettings() == true) { - result_bookmark_button?.requestFocus() + if (result_bookmark_button?.context?.isTrueTvSettings() == true) { + when { + result_play_movie?.isVisible == true -> { + result_play_movie?.requestFocus() + } + result_resume_series_button?.isVisible == true -> { + result_resume_series_button?.requestFocus() + } + else -> { + result_bookmark_button?.requestFocus() + } + } } result_loading?.isVisible = false diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt index 8f81e12c..d5c4fc4e 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt @@ -72,7 +72,11 @@ class SettingsFragment : PreferenceFragmentCompat() { } fun Context.isTrueTvSettings(): Boolean { - return getLayoutInt() == 1 + var value = getLayoutInt() + if (value == -1) { + value = if (isAutoTv()) 1 else 0 + } + return value == 1 } fun Context.isEmulatorSettings(): Boolean { diff --git a/app/src/main/res/layout/fragment_player_tv.xml b/app/src/main/res/layout/fragment_player_tv.xml index dce4b88f..f4cec44c 100644 --- a/app/src/main/res/layout/fragment_player_tv.xml +++ b/app/src/main/res/layout/fragment_player_tv.xml @@ -1,18 +1,16 @@ - + app:surface_type="texture_view"> @@ -28,8 +26,7 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" - app:controller_layout_id="@layout/player_custom_layout_tv" - /> + app:controller_layout_id="@layout/player_custom_layout_tv" /> + android:backgroundTint="@android:color/black"> - + android:layout_width="wrap_content" /> - + android:id="@+id/main_load" /> + android:layout_height="wrap_content"> + - + app:tint="@android:color/white" /> + - + android:background="@drawable/video_tap_button_always_white" /> + - + tools:text="78% at 18kb/s" /> + - + app:layout_constraintTop_toBottomOf="@+id/player_video_title" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_result.xml b/app/src/main/res/layout/fragment_result.xml index 7fed424b..1ea675b3 100644 --- a/app/src/main/res/layout/fragment_result.xml +++ b/app/src/main/res/layout/fragment_result.xml @@ -1,46 +1,46 @@ - - + android:background="?attr/primaryBlackBackground" + android:clickable="true" + android:focusable="true"> + + + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_margin="@dimen/result_padding" + android:orientation="vertical"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginBottom="@dimen/loading_margin" + android:orientation="horizontal"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginStart="@dimen/loading_margin" + android:layout_marginEnd="@dimen/loading_margin" + android:orientation="vertical"> @@ -55,9 +55,9 @@ + android:layout_width="match_parent" + android:layout_height="20dp" + tools:ignore="ContentDescription" /> @@ -74,94 +74,94 @@ android:layout_width="50dp" android:layout_height="50dp"> --> - - - - - - + android:orientation="vertical" + android:visibility="gone" + tools:visibility="gone"> + + + + + + + android:id="@+id/result_finish_loading" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:visibility="gone" + tools:visibility="visible"> - - + android:layout_height="230dp" + android:visibility="visible"> + android:id="@+id/result_poster_blur" + + android:layout_width="match_parent" + android:layout_height="match_parent" + android:alpha="0" + android:background="?attr/primaryGrayBackground" + android:scaleType="centerCrop" + tools:ignore="ContentDescription" + tools:src="@drawable/example_poster" /> + + + android:layout_height="wrap_content" + android:background="?attr/primaryGrayBackground"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="?attr/primaryBlackBackground" + android:orientation="vertical"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:clipToPadding="false" + android:orientation="vertical" + android:paddingStart="@dimen/result_padding" + android:paddingEnd="@dimen/result_padding"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="10dp" + android:layout_marginBottom="15dp" + android:orientation="horizontal" + android:visibility="visible"> + android:id="@+id/result_poster_holder" + android:layout_width="100dp" + android:layout_height="140dp" + app:cardCornerRadius="@dimen/rounded_image_radius"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:contentDescription="@string/result_poster_img_des" + android:foreground="@drawable/outline_drawable" + android:scaleType="centerCrop" + tools:src="@drawable/example_poster" /> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginStart="10dp" + android:orientation="vertical"> + android:id="@+id/result_title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="5dp" + android:maxLines="2" + android:textColor="?attr/textColor" + android:textSize="20sp" + android:textStyle="bold" + tools:text="The Perfect Run The Perfect Run" /> + android:layout_width="match_parent" + android:layout_height="wrap_content" + app:itemSpacing="10dp"> + android:id="@+id/result_meta_site" + style="@style/SmallBlackButton" + android:layout_gravity="center_vertical" + tools:text="Gogoanime" /> + android:id="@+id/result_meta_type" + style="@style/ResultInfoText" + tools:text="Movie" /> + android:id="@+id/result_meta_year" + style="@style/ResultInfoText" + tools:text="2022" /> + android:id="@+id/result_meta_rating" + style="@style/ResultInfoText" + tools:text="Rated: 8.5/10.0" /> + android:id="@+id/result_meta_status" + style="@style/ResultInfoText" + tools:text="Ongoing" /> + android:id="@+id/result_meta_duration" + style="@style/ResultInfoText" + tools:text="121min" /> + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:paddingTop="5dp" + android:paddingBottom="0dp" + android:textColor="?attr/textColor" + android:textSize="15sp" + tools:text="Ryan Quicksave Romano is an eccentric adventurer with a strange power: he can create a save-point in time and redo his life whenever he dies. Arriving in New Rome, the glitzy capital of sin of a rebuilding Europe, he finds the city torn between mega-corporations, sponsored heroes, superpowered criminals, and true monsters. It's a time of chaos, where potions can grant the power to rule the world and dangers lurk everywhere. " /> + android:layout_width="match_parent" + android:layout_height="30dp" + android:layout_gravity="bottom" + android:src="@drawable/background_shadow" + tools:ignore="ContentDescription" /> - - - + android:nextFocusDown="@id/result_play_movie" + android:paddingTop="0dp" + app:cornerRadius="4dp" + app:icon="@drawable/ic_baseline_bookmark_24" + tools:text="Bookmark" + tools:visibility="visible" /> + android:id="@+id/result_cast_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="5dp" + android:ellipsize="end" + android:maxLines="2" + android:textColor="?attr/grayTextColor" + android:textSize="15sp" + tools:text="Cast: Joe Ligma" /> + android:id="@+id/result_cast_items" + android:layout_width="match_parent" + android:descendantFocusability="afterDescendants" + android:layout_height="wrap_content" + android:fadingEdge="horizontal" + android:focusableInTouchMode="false" + android:focusable="false" + android:orientation="horizontal" + android:paddingTop="5dp" + android:requiresFadingEdge="horizontal" + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" + tools:itemCount="2" + tools:listitem="@layout/cast_item" /> + android:id="@+id/result_vpn" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textColor="?attr/grayTextColor" + android:textSize="15sp" + tools:text="@string/vpn_torrent" /> + android:id="@+id/result_info" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="5dp" + android:textColor="?attr/grayTextColor" + android:textSize="15sp" + tools:text="@string/provider_info_meta" /> + android:id="@+id/result_tag_holder" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="10dp" + android:layout_marginBottom="10dp" + android:text="@string/result_tags" + android:textColor="?attr/textColor" + android:textSize="17sp" + android:textStyle="normal" + android:visibility="gone" /> + android:id="@+id/result_tag" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> - - - - - - + android:layout_gravity="center" + android:gravity="center" + android:paddingTop="50dp" + android:text="@string/coming_soon" + android:textColor="?attr/textColor" + android:textSize="20sp" + android:textStyle="bold" + android:visibility="gone" /> - + + + android:text="@string/add_sync" + android:visibility="gone" + app:icon="@drawable/ic_baseline_add_24" /> + + + + + + + + + android:layout_width="match_parent" + android:layout_height="wrap_content"> - - - - - + android:gravity="center" + android:orientation="horizontal"> + + + + + android:id="@+id/result_movie_download_text" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:gravity="center" + android:letterSpacing="0.09" + android:textAllCaps="false" + android:textColor="?attr/textColor" + android:textSize="15sp" + android:textStyle="bold" + tools:text="Downloading" /> + android:id="@+id/result_movie_download_text_precentage" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:gravity="center" + android:letterSpacing="0.09" + android:paddingStart="5dp" + android:paddingEnd="5dp" + android:textAllCaps="false" + android:textColor="?attr/textColor" + android:textSize="15sp" + android:textStyle="bold" + android:visibility="gone" + tools:text="68%" /> @@ -643,178 +644,178 @@ - - - - + tools:visibility="visible"> + + + + - - - - - - - - - - - - - - - - - - - - + android:textStyle="bold" + tools:text="S1E1 Episode 1" /> + + + + + + + + + + + + + + + + + + + + + android:id="@+id/result_episode_loading" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="center" + android:layout_marginTop="15dp" + android:orientation="vertical" + app:shimmer_auto_start="true" + app:shimmer_base_alpha="0.2" + app:shimmer_duration="@integer/loading_time" + app:shimmer_highlight_alpha="0.3" + tools:visibility="visible"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> @@ -834,14 +835,14 @@ android:layout_height="50dp" />--> + android:id="@+id/result_episodes" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="0dp" + android:clipToPadding="false" + android:descendantFocusability="afterDescendants" + android:paddingBottom="100dp" + tools:listitem="@layout/result_episode" />