mirror of
				https://github.com/recloudstream/cloudstream.git
				synced 2024-08-15 01:53:11 +00:00 
			
		
		
		
	emulator layout
This commit is contained in:
		
							parent
							
								
									43592e64f8
								
							
						
					
					
						commit
						ddab37c08d
					
				
					 8 changed files with 42 additions and 18 deletions
				
			
		| 
						 | 
				
			
			@ -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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -100,12 +100,14 @@
 | 
			
		|||
        <item>@string/automatic</item>
 | 
			
		||||
        <item>@string/phone_layout</item>
 | 
			
		||||
        <item>@string/tv_layout</item>
 | 
			
		||||
        <item>@string/emulator_layout</item>
 | 
			
		||||
    </array>
 | 
			
		||||
 | 
			
		||||
    <array name="app_layout_values">
 | 
			
		||||
        <item>-1</item>
 | 
			
		||||
        <item>0</item>
 | 
			
		||||
        <item>1</item>
 | 
			
		||||
        <item>2</item>
 | 
			
		||||
    </array>
 | 
			
		||||
 | 
			
		||||
    <string-array name="themes_overlay_names">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -343,6 +343,7 @@
 | 
			
		|||
    <string name="automatic">Auto</string>
 | 
			
		||||
    <string name="tv_layout">TV 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="app_theme_settings">App Theme</string>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue