forked from recloudstream/cloudstream
		
	Fix TV layout bugs
This commit is contained in:
		
							parent
							
								
									a273be6d89
								
							
						
					
					
						commit
						cc38cf4264
					
				
					 12 changed files with 47 additions and 13 deletions
				
			
		|  | @ -125,7 +125,7 @@ object PluginManager { | |||
|         Environment.getExternalStorageDirectory().absolutePath + "/Cloudstream3/plugins" | ||||
| 
 | ||||
|     // Maps filepath to plugin | ||||
|     private val plugins: MutableMap<String, Plugin> = | ||||
|     val plugins: MutableMap<String, Plugin> = | ||||
|         LinkedHashMap<String, Plugin>() | ||||
| 
 | ||||
|     // Maps urls to plugin | ||||
|  |  | |||
|  | @ -26,6 +26,7 @@ import com.lagradost.cloudstream3.syncproviders.InAppAuthAPI | |||
| import com.lagradost.cloudstream3.syncproviders.OAuth2API | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setPaddingBottom | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar | ||||
| import com.lagradost.cloudstream3.utils.Coroutines.ioSafe | ||||
| import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe | ||||
|  | @ -208,6 +209,7 @@ class SettingsAccount : PreferenceFragmentCompat() { | |||
|     override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||||
|         super.onViewCreated(view, savedInstanceState) | ||||
|         setUpToolbar(R.string.category_account) | ||||
|         setPaddingBottom() | ||||
|     } | ||||
| 
 | ||||
|     override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { | ||||
|  |  | |||
|  | @ -21,6 +21,7 @@ import com.lagradost.cloudstream3.ui.home.HomeFragment | |||
| import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar | ||||
| import com.lagradost.cloudstream3.utils.UIHelper.navigate | ||||
| import com.lagradost.cloudstream3.utils.UIHelper.setImage | ||||
| import com.lagradost.cloudstream3.utils.UIHelper.toPx | ||||
| import kotlinx.android.synthetic.main.main_settings.* | ||||
| import kotlinx.android.synthetic.main.standard_toolbar.* | ||||
| import java.io.File | ||||
|  | @ -40,6 +41,15 @@ class SettingsFragment : Fragment() { | |||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /** | ||||
|          * On TV you cannot properly scroll to the bottom of settings, this fixes that. | ||||
|          * */ | ||||
|         fun PreferenceFragmentCompat.setPaddingBottom() { | ||||
|             if (this.context?.isTvSettings() == true) { | ||||
|                 listView?.setPadding(0, 0, 0, 100.toPx) | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         fun Fragment?.setUpToolbar(title: String) { | ||||
|             if (this == null) return | ||||
|             settings_toolbar?.apply { | ||||
|  |  | |||
|  | @ -25,6 +25,7 @@ import com.lagradost.cloudstream3.mvvm.normalSafeApiCall | |||
| import com.lagradost.cloudstream3.network.initClient | ||||
| import com.lagradost.cloudstream3.ui.EasterEggMonke | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setPaddingBottom | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar | ||||
| import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog | ||||
| import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog | ||||
|  | @ -42,6 +43,7 @@ class SettingsGeneral : PreferenceFragmentCompat() { | |||
|     override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||||
|         super.onViewCreated(view, savedInstanceState) | ||||
|         setUpToolbar(R.string.category_general) | ||||
|         setPaddingBottom() | ||||
|     } | ||||
| 
 | ||||
|     data class CustomSite( | ||||
|  |  | |||
|  | @ -12,6 +12,7 @@ import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey | |||
| import com.lagradost.cloudstream3.mvvm.logError | ||||
| import com.lagradost.cloudstream3.ui.APIRepository | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setPaddingBottom | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar | ||||
| import com.lagradost.cloudstream3.utils.USER_SELECTED_HOMEPAGE_API | ||||
| import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog | ||||
|  | @ -61,6 +62,7 @@ class SettingsLang : PreferenceFragmentCompat() { | |||
|     override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||||
|         super.onViewCreated(view, savedInstanceState) | ||||
|         setUpToolbar(R.string.category_preferred_media_and_lang) | ||||
|         setPaddingBottom() | ||||
|     } | ||||
| 
 | ||||
|     override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { | ||||
|  |  | |||
|  | @ -9,6 +9,7 @@ import com.lagradost.cloudstream3.R | |||
| import com.lagradost.cloudstream3.mvvm.logError | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getFolderSize | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setPaddingBottom | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar | ||||
| import com.lagradost.cloudstream3.ui.subtitles.ChromecastSubtitlesFragment | ||||
| import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment | ||||
|  | @ -21,6 +22,7 @@ class SettingsPlayer : PreferenceFragmentCompat() { | |||
|     override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||||
|         super.onViewCreated(view, savedInstanceState) | ||||
|         setUpToolbar(R.string.category_player) | ||||
|         setPaddingBottom() | ||||
|     } | ||||
|     override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { | ||||
|         hideKeyboard() | ||||
|  |  | |||
|  | @ -9,6 +9,7 @@ import com.lagradost.cloudstream3.SearchQuality | |||
| import com.lagradost.cloudstream3.mvvm.logError | ||||
| import com.lagradost.cloudstream3.ui.search.SearchResultBuilder | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setPaddingBottom | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar | ||||
| import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog | ||||
| import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog | ||||
|  | @ -19,6 +20,7 @@ class SettingsUI : PreferenceFragmentCompat() { | |||
|     override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||||
|         super.onViewCreated(view, savedInstanceState) | ||||
|         setUpToolbar(R.string.category_ui) | ||||
|         setPaddingBottom() | ||||
|     } | ||||
|     override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { | ||||
|         hideKeyboard() | ||||
|  |  | |||
|  | @ -13,6 +13,7 @@ import com.lagradost.cloudstream3.CommonActivity | |||
| import com.lagradost.cloudstream3.R | ||||
| import com.lagradost.cloudstream3.mvvm.logError | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setPaddingBottom | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar | ||||
| import com.lagradost.cloudstream3.utils.BackupUtils.backup | ||||
| import com.lagradost.cloudstream3.utils.BackupUtils.restorePrompt | ||||
|  | @ -31,6 +32,7 @@ class SettingsUpdates : PreferenceFragmentCompat() { | |||
|     override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||||
|         super.onViewCreated(view, savedInstanceState) | ||||
|         setUpToolbar(R.string.category_updates) | ||||
|         setPaddingBottom() | ||||
|     } | ||||
| 
 | ||||
|     override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { | ||||
|  |  | |||
|  | @ -134,7 +134,8 @@ class PluginAdapter( | |||
|             //} | ||||
| 
 | ||||
|             if (data.isDownloaded) { | ||||
|                 val plugin = PluginManager.urlPlugins[metadata.url] | ||||
|                 // On local plugins page the filepath is provided instead of url. | ||||
|                 val plugin = PluginManager.urlPlugins[metadata.url] ?: PluginManager.plugins[metadata.url] | ||||
|                 if (plugin?.openSettings != null) { | ||||
|                     itemView.action_settings?.isVisible = true | ||||
|                     itemView.action_settings.setOnClickListener { | ||||
|  |  | |||
|  | @ -13,12 +13,14 @@ import com.lagradost.cloudstream3.R | |||
| import com.lagradost.cloudstream3.mvvm.logError | ||||
| import com.lagradost.cloudstream3.mvvm.observe | ||||
| import com.lagradost.cloudstream3.ui.home.HomeFragment.Companion.getPairList | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings | ||||
| import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar | ||||
| import com.lagradost.cloudstream3.ui.settings.appLanguages | ||||
| import com.lagradost.cloudstream3.ui.settings.getCurrentLocale | ||||
| import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog | ||||
| import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showMultiDialog | ||||
| import com.lagradost.cloudstream3.utils.SubtitleHelper | ||||
| import com.lagradost.cloudstream3.utils.UIHelper.toPx | ||||
| import com.lagradost.cloudstream3.utils.USER_SELECTED_HOMEPAGE_API | ||||
| import kotlinx.android.synthetic.main.fragment_plugins.* | ||||
| 
 | ||||
|  | @ -64,11 +66,14 @@ class PluginsFragment : Fragment() { | |||
|                 R.id.lang_filter -> { | ||||
|                     val tempLangs = appLanguages.toMutableList() | ||||
|                     val languageCodes = mutableListOf("none") + tempLangs.map { (_, _, iso) -> iso } | ||||
|                     val languageNames = mutableListOf(getString(R.string.no_data)) + tempLangs.map { (emoji, name, iso) -> | ||||
|                         val flag = emoji.ifBlank { SubtitleHelper.getFlagFromIso(iso) ?: "ERROR" } | ||||
|                     val languageNames = | ||||
|                         mutableListOf(getString(R.string.no_data)) + tempLangs.map { (emoji, name, iso) -> | ||||
|                             val flag = | ||||
|                                 emoji.ifBlank { SubtitleHelper.getFlagFromIso(iso) ?: "ERROR" } | ||||
|                             "$flag $name" | ||||
|                         } | ||||
|                     val selectedList = pluginViewModel.languages.map { it -> languageCodes.indexOf(it) } | ||||
|                     val selectedList = | ||||
|                         pluginViewModel.languages.map { it -> languageCodes.indexOf(it) } | ||||
| 
 | ||||
|                     activity?.showMultiDialog( | ||||
|                         languageNames, | ||||
|  | @ -123,6 +128,11 @@ class PluginsFragment : Fragment() { | |||
|                 pluginViewModel.handlePluginAction(activity, url, it, isLocal) | ||||
|             } | ||||
| 
 | ||||
|         if (context?.isTvSettings() == true) { | ||||
|             // Scrolling down does not reveal the whole RecyclerView on TV, add to bypass that. | ||||
|             plugin_recycler_view?.setPadding(0, 0, 0, 200.toPx) | ||||
|         } | ||||
| 
 | ||||
|         observe(pluginViewModel.filteredPlugins) { (scrollToTop, list) -> | ||||
|             (plugin_recycler_view?.adapter as? PluginAdapter?)?.updateList(list) | ||||
| 
 | ||||
|  |  | |||
|  | @ -176,7 +176,7 @@ class PluginsViewModel : ViewModel() { | |||
|         } | ||||
| 
 | ||||
|         this.plugins = list | ||||
|         _filteredPlugins.postValue(false to list.filterTvTypes().sortByQuery(currentQuery)) | ||||
|         _filteredPlugins.postValue(false to list.filterTvTypes().filterLang().sortByQuery(currentQuery)) | ||||
|     } | ||||
| 
 | ||||
|     // Perhaps can be optimized? | ||||
|  | @ -234,6 +234,6 @@ class PluginsViewModel : ViewModel() { | |||
|             } | ||||
| 
 | ||||
|         plugins = downloadedPlugins | ||||
|         _filteredPlugins.postValue(false to downloadedPlugins.filterTvTypes().sortByQuery(currentQuery)) | ||||
|         _filteredPlugins.postValue(false to downloadedPlugins.filterTvTypes().filterLang().sortByQuery(currentQuery)) | ||||
|     } | ||||
| } | ||||
|  | @ -127,6 +127,7 @@ | |||
|     </com.google.android.material.appbar.AppBarLayout> | ||||
| 
 | ||||
|     <androidx.recyclerview.widget.RecyclerView | ||||
|         android:clipToPadding="false" | ||||
|         android:id="@+id/plugin_recycler_view" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="match_parent" | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue