From ddab37c08dd48225f52ae2e7fad44463e6e9b888 Mon Sep 17 00:00:00 2001 From: LagradOst <11805592+LagradOst@users.noreply.github.com> Date: Fri, 18 Feb 2022 20:29:48 +0100 Subject: [PATCH] emulator layout --- .../cloudstream3/ui/home/HomeFragment.kt | 13 ++++++++----- .../cloudstream3/ui/result/EpisodeAdapter.kt | 4 ++-- .../cloudstream3/ui/search/SearchFragment.kt | 3 ++- .../ui/search/SearchResultBuilder.kt | 17 +++++++++++++---- .../ui/settings/SettingsFragment.kt | 14 +++++++++++--- .../ui/subtitles/SubtitlesFragment.kt | 6 +++--- app/src/main/res/values/array.xml | 2 ++ app/src/main/res/values/strings.xml | 1 + 8 files changed, 42 insertions(+), 18 deletions(-) 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 488a9015..c0bf5ed3 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 @@ -39,6 +39,7 @@ import com.lagradost.cloudstream3.ui.result.START_ACTION_RESUME_LATEST import com.lagradost.cloudstream3.ui.search.* import com.lagradost.cloudstream3.ui.search.SearchFragment.Companion.filterSearchResponse import com.lagradost.cloudstream3.ui.search.SearchHelper.handleSearchClickCallback +import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings import com.lagradost.cloudstream3.utils.AppUtils.loadSearchResult import com.lagradost.cloudstream3.utils.DataStore.getKey @@ -800,11 +801,13 @@ class HomeFragment : Fragment() { if (ctx.isTvSettings()) { home_api_fab?.isVisible = false home_change_api?.isVisible = true - home_change_api_loading?.isVisible = true - home_change_api_loading?.isFocusable = true - home_change_api_loading?.isFocusableInTouchMode = true - home_change_api?.isFocusable = true - home_change_api?.isFocusableInTouchMode = true + if(ctx.isTrueTvSettings()) { + home_change_api_loading?.isVisible = true + home_change_api_loading?.isFocusable = true + home_change_api_loading?.isFocusableInTouchMode = true + home_change_api?.isFocusable = true + home_change_api?.isFocusableInTouchMode = true + } // home_bookmark_select?.isFocusable = true // home_bookmark_select?.isFocusableInTouchMode = true } else { diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt index c567bc16..122a27c4 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt @@ -16,7 +16,7 @@ import com.lagradost.cloudstream3.ui.download.DOWNLOAD_ACTION_DOWNLOAD import com.lagradost.cloudstream3.ui.download.DownloadButtonViewHolder import com.lagradost.cloudstream3.ui.download.DownloadClickEvent import com.lagradost.cloudstream3.ui.download.EasyDownloadButton -import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings +import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings import com.lagradost.cloudstream3.utils.UIHelper.setImage import com.lagradost.cloudstream3.utils.VideoDownloadHelper import com.lagradost.cloudstream3.utils.VideoDownloadManager @@ -193,7 +193,7 @@ class EpisodeAdapter( clickCallback.invoke(EpisodeClickEvent(ACTION_CLICK_DEFAULT, card)) } - if (episodeHolder.context.isTvSettings()) { + if (episodeHolder.context.isTrueTvSettings()) { episodeHolder.isFocusable = true episodeHolder.isFocusableInTouchMode = true episodeHolder.touchscreenBlocksFocus = false 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 ebc1cdbf..d0c80579 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 @@ -31,6 +31,7 @@ import com.lagradost.cloudstream3.ui.home.HomeFragment import com.lagradost.cloudstream3.ui.home.HomeFragment.Companion.currentSpan import com.lagradost.cloudstream3.ui.home.HomeFragment.Companion.loadHomepageList import com.lagradost.cloudstream3.ui.home.ParentItemAdapter +import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings import com.lagradost.cloudstream3.utils.DataStore.getKey import com.lagradost.cloudstream3.utils.DataStore.setKey @@ -319,7 +320,7 @@ class SearchFragment : Fragment() { } } - if (context?.isTvSettings() == true) { + if (context?.isTrueTvSettings() == true) { search_filter.isFocusable = true search_filter.isFocusableInTouchMode = true } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt index 7f601663..10d94ed8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt @@ -7,7 +7,7 @@ import android.widget.TextView import androidx.cardview.widget.CardView import androidx.core.view.isVisible import com.lagradost.cloudstream3.* -import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings +import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings import com.lagradost.cloudstream3.utils.AppUtils.getNameFull import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.utils.DataStoreHelper.fixVisual @@ -81,23 +81,32 @@ object SearchResultBuilder { } } - if (bg.context.isTvSettings()) { + if (bg.context.isTrueTvSettings()) { bg.isFocusable = true bg.isFocusableInTouchMode = true bg.touchscreenBlocksFocus = false + itemView.isFocusableInTouchMode = true + itemView.isFocusable = true } bg.setOnLongClickListener { clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_SHOW_METADATA, it, position, card)) return@setOnLongClickListener true } - + itemView.setOnLongClickListener { + clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_SHOW_METADATA, it, position, card)) + return@setOnLongClickListener true + } bg.setOnFocusChangeListener { view, b -> if (b) { clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_FOCUSED, view, position, card)) } } - + itemView.setOnFocusChangeListener { view, b -> + if (b) { + clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_FOCUSED, view, position, card)) + } + } when (card) { is DataStoreHelper.ResumeWatchingResult -> { val pos = card.watchPos?.fixVisual() 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 965470b9..812afb20 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 @@ -57,13 +57,21 @@ import kotlin.concurrent.thread class SettingsFragment : PreferenceFragmentCompat() { companion object { - fun Context.isTvSettings(): Boolean { + private fun Context.getLayoutInt() : Int { val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) - var value = settingsManager.getInt(this.getString(R.string.app_layout_key), -1) + return settingsManager.getInt(this.getString(R.string.app_layout_key), -1) + } + + fun Context.isTvSettings(): Boolean { + var value = getLayoutInt() if (value == -1) { value = if (isAutoTv()) 1 else 0 } - return value == 1 + return value == 1 || value == 2 + } + + fun Context.isTrueTvSettings() : Boolean { + return getLayoutInt() == 1 } private fun Context.isAutoTv(): Boolean { diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt index de18861b..53bea3cb 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt @@ -26,7 +26,7 @@ import com.lagradost.cloudstream3.CommonActivity.onColorSelectedEvent import com.lagradost.cloudstream3.CommonActivity.onDialogDismissedEvent import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.R -import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings +import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings import com.lagradost.cloudstream3.utils.DataStore.setKey import com.lagradost.cloudstream3.utils.Event import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog @@ -197,10 +197,10 @@ class SubtitlesFragment : Fragment() { state = getCurrentSavedStyle() context?.updateState() - val isTvSettings = context?.isTvSettings() == true + val isTvTrueSettings = context?.isTrueTvSettings() == true fun View.setFocusableInTv() { - this.isFocusableInTouchMode = isTvSettings + this.isFocusableInTouchMode = isTvTrueSettings } fun View.setup(id: Int) { diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml index 7995b44e..cd73e2a8 100644 --- a/app/src/main/res/values/array.xml +++ b/app/src/main/res/values/array.xml @@ -100,12 +100,14 @@ @string/automatic @string/phone_layout @string/tv_layout + @string/emulator_layout -1 0 1 + 2 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a606935d..9ba76b63 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -343,6 +343,7 @@ Auto TV Layout Phone Layout + Emulator Layout Primary Color App Theme