emulator layout

This commit is contained in:
LagradOst 2022-02-18 20:29:48 +01:00
parent 43592e64f8
commit ddab37c08d
8 changed files with 42 additions and 18 deletions

View file

@ -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.*
import com.lagradost.cloudstream3.ui.search.SearchFragment.Companion.filterSearchResponse import com.lagradost.cloudstream3.ui.search.SearchFragment.Companion.filterSearchResponse
import com.lagradost.cloudstream3.ui.search.SearchHelper.handleSearchClickCallback 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.ui.settings.SettingsFragment.Companion.isTvSettings
import com.lagradost.cloudstream3.utils.AppUtils.loadSearchResult import com.lagradost.cloudstream3.utils.AppUtils.loadSearchResult
import com.lagradost.cloudstream3.utils.DataStore.getKey import com.lagradost.cloudstream3.utils.DataStore.getKey
@ -800,11 +801,13 @@ class HomeFragment : Fragment() {
if (ctx.isTvSettings()) { if (ctx.isTvSettings()) {
home_api_fab?.isVisible = false home_api_fab?.isVisible = false
home_change_api?.isVisible = true home_change_api?.isVisible = true
if(ctx.isTrueTvSettings()) {
home_change_api_loading?.isVisible = true home_change_api_loading?.isVisible = true
home_change_api_loading?.isFocusable = true home_change_api_loading?.isFocusable = true
home_change_api_loading?.isFocusableInTouchMode = true home_change_api_loading?.isFocusableInTouchMode = true
home_change_api?.isFocusable = true home_change_api?.isFocusable = true
home_change_api?.isFocusableInTouchMode = true home_change_api?.isFocusableInTouchMode = true
}
// home_bookmark_select?.isFocusable = true // home_bookmark_select?.isFocusable = true
// home_bookmark_select?.isFocusableInTouchMode = true // home_bookmark_select?.isFocusableInTouchMode = true
} else { } else {

View file

@ -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.DownloadButtonViewHolder
import com.lagradost.cloudstream3.ui.download.DownloadClickEvent import com.lagradost.cloudstream3.ui.download.DownloadClickEvent
import com.lagradost.cloudstream3.ui.download.EasyDownloadButton 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.UIHelper.setImage
import com.lagradost.cloudstream3.utils.VideoDownloadHelper import com.lagradost.cloudstream3.utils.VideoDownloadHelper
import com.lagradost.cloudstream3.utils.VideoDownloadManager import com.lagradost.cloudstream3.utils.VideoDownloadManager
@ -193,7 +193,7 @@ class EpisodeAdapter(
clickCallback.invoke(EpisodeClickEvent(ACTION_CLICK_DEFAULT, card)) clickCallback.invoke(EpisodeClickEvent(ACTION_CLICK_DEFAULT, card))
} }
if (episodeHolder.context.isTvSettings()) { if (episodeHolder.context.isTrueTvSettings()) {
episodeHolder.isFocusable = true episodeHolder.isFocusable = true
episodeHolder.isFocusableInTouchMode = true episodeHolder.isFocusableInTouchMode = true
episodeHolder.touchscreenBlocksFocus = false episodeHolder.touchscreenBlocksFocus = false

View file

@ -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.currentSpan
import com.lagradost.cloudstream3.ui.home.HomeFragment.Companion.loadHomepageList import com.lagradost.cloudstream3.ui.home.HomeFragment.Companion.loadHomepageList
import com.lagradost.cloudstream3.ui.home.ParentItemAdapter 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.ui.settings.SettingsFragment.Companion.isTvSettings
import com.lagradost.cloudstream3.utils.DataStore.getKey import com.lagradost.cloudstream3.utils.DataStore.getKey
import com.lagradost.cloudstream3.utils.DataStore.setKey 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.isFocusable = true
search_filter.isFocusableInTouchMode = true search_filter.isFocusableInTouchMode = true
} }

View file

@ -7,7 +7,7 @@ import android.widget.TextView
import androidx.cardview.widget.CardView import androidx.cardview.widget.CardView
import androidx.core.view.isVisible import androidx.core.view.isVisible
import com.lagradost.cloudstream3.* 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.AppUtils.getNameFull
import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.utils.DataStoreHelper
import com.lagradost.cloudstream3.utils.DataStoreHelper.fixVisual 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.isFocusable = true
bg.isFocusableInTouchMode = true bg.isFocusableInTouchMode = true
bg.touchscreenBlocksFocus = false bg.touchscreenBlocksFocus = false
itemView.isFocusableInTouchMode = true
itemView.isFocusable = true
} }
bg.setOnLongClickListener { bg.setOnLongClickListener {
clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_SHOW_METADATA, it, position, card)) clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_SHOW_METADATA, it, position, card))
return@setOnLongClickListener true return@setOnLongClickListener true
} }
itemView.setOnLongClickListener {
clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_SHOW_METADATA, it, position, card))
return@setOnLongClickListener true
}
bg.setOnFocusChangeListener { view, b -> bg.setOnFocusChangeListener { view, b ->
if (b) { if (b) {
clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_FOCUSED, view, position, card)) 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) { when (card) {
is DataStoreHelper.ResumeWatchingResult -> { is DataStoreHelper.ResumeWatchingResult -> {
val pos = card.watchPos?.fixVisual() val pos = card.watchPos?.fixVisual()

View file

@ -57,13 +57,21 @@ import kotlin.concurrent.thread
class SettingsFragment : PreferenceFragmentCompat() { class SettingsFragment : PreferenceFragmentCompat() {
companion object { companion object {
fun Context.isTvSettings(): Boolean { private fun Context.getLayoutInt() : Int {
val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) 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) { if (value == -1) {
value = if (isAutoTv()) 1 else 0 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 { private fun Context.isAutoTv(): Boolean {

View file

@ -26,7 +26,7 @@ import com.lagradost.cloudstream3.CommonActivity.onColorSelectedEvent
import com.lagradost.cloudstream3.CommonActivity.onDialogDismissedEvent import com.lagradost.cloudstream3.CommonActivity.onDialogDismissedEvent
import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.CommonActivity.showToast
import com.lagradost.cloudstream3.R 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.DataStore.setKey
import com.lagradost.cloudstream3.utils.Event import com.lagradost.cloudstream3.utils.Event
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog
@ -197,10 +197,10 @@ class SubtitlesFragment : Fragment() {
state = getCurrentSavedStyle() state = getCurrentSavedStyle()
context?.updateState() context?.updateState()
val isTvSettings = context?.isTvSettings() == true val isTvTrueSettings = context?.isTrueTvSettings() == true
fun View.setFocusableInTv() { fun View.setFocusableInTv() {
this.isFocusableInTouchMode = isTvSettings this.isFocusableInTouchMode = isTvTrueSettings
} }
fun View.setup(id: Int) { fun View.setup(id: Int) {

View file

@ -100,12 +100,14 @@
<item>@string/automatic</item> <item>@string/automatic</item>
<item>@string/phone_layout</item> <item>@string/phone_layout</item>
<item>@string/tv_layout</item> <item>@string/tv_layout</item>
<item>@string/emulator_layout</item>
</array> </array>
<array name="app_layout_values"> <array name="app_layout_values">
<item>-1</item> <item>-1</item>
<item>0</item> <item>0</item>
<item>1</item> <item>1</item>
<item>2</item>
</array> </array>
<string-array name="themes_overlay_names"> <string-array name="themes_overlay_names">

View file

@ -343,6 +343,7 @@
<string name="automatic">Auto</string> <string name="automatic">Auto</string>
<string name="tv_layout">TV Layout</string> <string name="tv_layout">TV Layout</string>
<string name="phone_layout">Phone Layout</string> <string name="phone_layout">Phone Layout</string>
<string name="emulator_layout">Emulator Layout</string>
<string name="primary_color_settings">Primary Color</string> <string name="primary_color_settings">Primary Color</string>
<string name="app_theme_settings">App Theme</string> <string name="app_theme_settings">App Theme</string>