Commit d730a916 authored by Geoffrey Métais's avatar Geoffrey Métais Committed by Geoffrey Métais
Browse files

TV Browser: Hide favorite button on root level

parent 9c0b9389
......@@ -252,8 +252,8 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
requireActivity().reloadLibrary()
}
}
ID_ABOUT_TV -> activity.startActivity(Intent(activity, org.videolan.vlc.gui.tv.AboutActivity::class.java))
ID_LICENCE -> startActivity(Intent(activity, org.videolan.vlc.gui.tv.LicenceActivity::class.java))
ID_ABOUT_TV -> activity.startActivity(Intent(activity, AboutActivity::class.java))
ID_LICENCE -> startActivity(Intent(activity, LicenceActivity::class.java))
}
}
else -> {
......
......@@ -56,6 +56,7 @@ class FileBrowserTvFragment : BaseBrowserTvFragment(), PathAdapterListener {
override fun showRoot(): Boolean = true
private var favExists: Boolean = false
private var isRootLevel = false
private lateinit var browserFavRepository: BrowserFavRepository
private var item: MediaLibraryItem? = null
override lateinit var adapter: TvItemAdapter
......@@ -71,11 +72,12 @@ class FileBrowserTvFragment : BaseBrowserTvFragment(), PathAdapterListener {
override fun getColumnNumber() = resources.getInteger(R.integer.tv_songs_col_count)
companion object {
fun newInstance(type: Long, item: MediaLibraryItem?) =
fun newInstance(type: Long, item: MediaLibraryItem?, root : Boolean = false) =
FileBrowserTvFragment().apply {
arguments = Bundle().apply {
this.putLong(CATEGORY, type)
this.putParcelable(ITEM, item)
this.putBoolean("rootLevel", root)
}
}
}
......@@ -90,6 +92,7 @@ class FileBrowserTvFragment : BaseBrowserTvFragment(), PathAdapterListener {
else arguments?.getParcelable(ITEM) as? MediaLibraryItem
viewModel = getBrowserModel(getCategory(), (item as? AbstractMediaWrapper)?.location, true, false)
isRootLevel = arguments?.getBoolean("rootLevel") ?: false
(item as? MediaWrapper)?.run { mrl = location }
viewModel.currentItem = item
......@@ -178,7 +181,7 @@ class FileBrowserTvFragment : BaseBrowserTvFragment(), PathAdapterListener {
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
launch {
animationDelegate.setVisibility(binding.favoriteButton, View.VISIBLE)
animationDelegate.setVisibility(binding.favoriteButton, if (isRootLevel) View.GONE else View.VISIBLE)
animationDelegate.setVisibility(binding.imageButtonFavorite, View.VISIBLE)
animationDelegate.setVisibility(binding.favoriteDescription, View.VISIBLE)
favExists = withContext(Dispatchers.IO) {
......@@ -198,20 +201,17 @@ class FileBrowserTvFragment : BaseBrowserTvFragment(), PathAdapterListener {
else -> browserFavRepository.addNetworkFavItem(mw.uri, mw.title, mw.artworkURL)
}
favExists = !favExists
launch {
binding.favoriteButton.setImageResource(if (favExists) R.drawable.ic_menu_fav_tv else R.drawable.ic_menu_not_fav_tv)
binding.imageButtonFavorite.setImageResource(if (favExists) R.drawable.ic_menu_fav_tv_normal else R.drawable.ic_menu_not_fav_tv_normal)
}
}
if (!isRootLevel) binding.favoriteButton.setImageResource(if (favExists) R.drawable.ic_menu_fav_tv else R.drawable.ic_menu_not_fav_tv)
binding.imageButtonFavorite.setImageResource(if (favExists) R.drawable.ic_menu_fav_tv_normal else R.drawable.ic_menu_not_fav_tv_normal)
}
}
binding.favoriteButton.setOnClickListener(favoriteClickListener)
if (!isRootLevel) binding.favoriteButton.setOnClickListener(favoriteClickListener)
binding.imageButtonFavorite.setOnClickListener(favoriteClickListener)
}
override fun onResume() {
super.onResume()
if (item == null) (viewModel.provider as BrowserProvider).browseRoot()
else refresh()
}
......
......@@ -71,9 +71,9 @@ class VerticalGridActivity : BaseTvActivity(), BrowserActivityInterface {
val item = if (uri == null) null else MLServiceLocator.getAbstractMediaWrapper(uri)
if (item != null && intent.hasExtra(FAVORITE_TITLE)) item.title = intent.getStringExtra(FAVORITE_TITLE)
fragment = FileBrowserTvFragment.newInstance(TYPE_NETWORK, item)
fragment = FileBrowserTvFragment.newInstance(TYPE_NETWORK, item, true)
} else if (type == HEADER_DIRECTORIES) {
fragment = FileBrowserTvFragment.newInstance(TYPE_FILE, intent.data?.let { MLServiceLocator.getAbstractMediaWrapper(it) })
fragment = FileBrowserTvFragment.newInstance(TYPE_FILE, intent.data?.let { MLServiceLocator.getAbstractMediaWrapper(it) }, true)
} else {
finish()
return
......@@ -101,7 +101,6 @@ class VerticalGridActivity : BaseTvActivity(), BrowserActivityInterface {
return super.onKeyDown(keyCode, event)
}
override fun showProgress(show: Boolean) {
runOnUiThread {
tv_fragment_empty.visibility = View.GONE
......@@ -118,14 +117,11 @@ class VerticalGridActivity : BaseTvActivity(), BrowserActivityInterface {
}
interface OnKeyPressedListener {
/**
* a key has been pressed
* @param keyCode the pressed key
* @return true if the event has been intercepted
*/
fun onKeyPressed(keyCode: Int): Boolean
}
}
......@@ -73,7 +73,6 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
mediabrowser = null
}
}
}
private val browserActor = actor<BrowserAction>(capacity = Channel.UNLIMITED, onCompletion = completionHandler) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment