[Android] TV Browser: Hide favorite button on root level
Geoffrey Métais
git at videolan.org
Mon Sep 23 18:10:51 CEST 2019
vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Sep 17 14:51:31 2019 +0200| [a0fa87302282e81f1feba3a570c4505b36716d63] | committer: Geoffrey Métais
TV Browser: Hide favorite button on root level
(cherry picked from commit d730a916a7bf86878fa3a92b3cfb5ac20d5bfb13)
> https://code.videolan.org/videolan/vlc-android/commit/a0fa87302282e81f1feba3a570c4505b36716d63
---
.../src/org/videolan/vlc/gui/tv/MainTvFragment.kt | 4 ++--
.../videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt | 16 ++++++++--------
.../videolan/vlc/gui/tv/browser/VerticalGridActivity.kt | 8 ++------
.../src/org/videolan/vlc/providers/BrowserProvider.kt | 1 -
4 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt
index 81aa88fb4..cb2177ecd 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt
@@ -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 -> {
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
index 3f584312b..46b55b118 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
@@ -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()
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.kt
index 483e2af82..cf49828d9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.kt
@@ -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
-
-
}
}
diff --git a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
index 6fb60bdcc..b0289fb57 100644
--- a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
@@ -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) {
More information about the Android
mailing list