Skip to content
Snippets Groups Projects
Commit ed9c0089 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Duncan McNamara
Browse files

Display favorites first on TV with a badge icon

Fixes #1375
parent 243d71dc
No related branches found
No related tags found
1 merge request!1277Display favorites first on TV with a badge icon
Pipeline #197541 passed with stage
in 7 minutes and 54 seconds
<!--
~ *************************************************************************
~ ic_favorite_tv_badge.xml
~ **************************************************************************
~ Copyright © 2022 VLC authors and VideoLAN
~ Author: Nicolas POMEPUY
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation; either version 2 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
~ ***************************************************************************
~
~
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="36dp"
android:height="36dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:pathData="m24,8 l3.9375,12H40L30.3318,27.2968 34.5,40 24,32.0755 13.5,40 17.6682,27.2968 8,20h12.0625z"
android:strokeLineJoin="miter"
android:strokeWidth="1"
android:fillColor="@color/white"
android:strokeColor="#00000000"
android:fillType="evenOdd"
android:strokeLineCap="butt"/>
</vector>
......@@ -27,6 +27,7 @@ import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Build
import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
......@@ -50,6 +51,8 @@ import org.videolan.tools.getLocaleLanguages
import org.videolan.vlc.R
import org.videolan.vlc.gui.helpers.*
public const val FAVORITE_FLAG = 1000
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
......@@ -76,6 +79,8 @@ class CardPresenter(private val context: Activity, private val isPoster: Boolean
fun updateCardViewImage(item: MediaLibraryItem) {
val noArt = item.artworkMrl.isNullOrEmpty()
if (item is MediaWrapper) {
if (BuildConfig.DEBUG) Log.d("CardPresenter", "ITEM: ${item.title} // meta = ${item.hasFlag(FAVORITE_FLAG)}")
if (item.hasFlag(FAVORITE_FLAG)) cardView.badgeImage = ContextCompat.getDrawable(cardView.context, R.drawable.ic_favorite_tv_badge)
val group = item.type == MediaWrapper.TYPE_GROUP
val folder = item.type == MediaWrapper.TYPE_DIR
val video = item.type == MediaWrapper.TYPE_VIDEO
......
......@@ -40,6 +40,7 @@ import org.videolan.moviepedia.database.models.MediaMetadataWithImages
import org.videolan.moviepedia.repository.MediaMetadataRepository
import org.videolan.resources.*
import org.videolan.resources.util.getFromMl
import org.videolan.television.ui.FAVORITE_FLAG
import org.videolan.television.ui.MainTvActivity
import org.videolan.television.ui.NowPlayingDelegate
import org.videolan.television.ui.audioplayer.AudioPlayerActivity
......@@ -61,7 +62,6 @@ import org.videolan.vlc.repository.BrowserFavRepository
import org.videolan.vlc.repository.DirectoryRepository
import org.videolan.vlc.util.Permissions
import org.videolan.vlc.util.convertFavorites
import org.videolan.vlc.util.isSchemeFile
import org.videolan.vlc.util.scanAllowed
private const val NUM_ITEMS_PREVIEW = 5
......@@ -229,6 +229,11 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
private suspend fun updateBrowsers() {
val list = mutableListOf<MediaLibraryItem>()
updatedFavoriteList.forEach {
it.description = it.uri.scheme
it.addFlags(FAVORITE_FLAG)
list.add(it)
}
val directories = DirectoryRepository.getInstance(context).getMediaDirectoriesList(context).toMutableList()
if (!showInternalStorage && directories.isNotEmpty()) directories.removeAt(0)
directories.forEach { if (it.location.scanAllowed()) list.add(it) }
......@@ -237,15 +242,6 @@ class MainTvModel(app: Application) : AndroidViewModel(app), Medialibrary.OnMedi
list.add(DummyItem(HEADER_NETWORK, context.getString(R.string.network_browsing), null))
list.add(DummyItem(HEADER_STREAM, context.getString(R.string.streams), null))
list.add(DummyItem(HEADER_SERVER, context.getString(R.string.server_add_title), null))
updatedFavoriteList.forEach {
it.description = it.uri.scheme
list.add(it)
}
} else {
updatedFavoriteList.filter { it.uri.scheme.isSchemeFile() }.forEach {
it.description = it.uri.scheme
list.add(it)
}
}
(browsers as MutableLiveData).value = list
delay(500L)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment