3 Commits

Author SHA1 Message Date
09ddbe6bae 1.0.6 2026-10-05 20:40:56 -07:00
494d8e6835 fixed watch history 2026-10-05 20:38:56 -07:00
1c3ffacccd 1.0.5 2026-10-05 15:50:17 -07:00
7 changed files with 37 additions and 8 deletions

View File

@@ -48,6 +48,7 @@ class MainActivity : ComponentActivity() {
val watchLaterItems by libraryManager.watchLater.collectAsState() val watchLaterItems by libraryManager.watchLater.collectAsState()
val favoriteItems by libraryManager.favorites.collectAsState() val favoriteItems by libraryManager.favorites.collectAsState()
val historyItems by libraryManager.history.collectAsState()
val sidebarFocusRequester = remember { FocusRequester() } val sidebarFocusRequester = remember { FocusRequester() }
val contentFocusRequester = remember { FocusRequester() } val contentFocusRequester = remember { FocusRequester() }
@@ -64,6 +65,7 @@ class MainActivity : ComponentActivity() {
if (playingItem == null) { if (playingItem == null) {
Sidebar( Sidebar(
currentDestination = currentDestination, currentDestination = currentDestination,
hasHistory = historyItems.isNotEmpty(),
hasWatchLater = watchLaterItems.isNotEmpty(), hasWatchLater = watchLaterItems.isNotEmpty(),
hasFavorites = favoriteItems.isNotEmpty(), hasFavorites = favoriteItems.isNotEmpty(),
onNavigate = { dest -> onNavigate = { dest ->
@@ -98,6 +100,7 @@ class MainActivity : ComponentActivity() {
mode = currentDestination, mode = currentDestination,
onOpenDetail = { item -> activeDetailItem = item }, onOpenDetail = { item -> activeDetailItem = item },
onPlay = { item -> onPlay = { item ->
libraryManager.addHistory(item)
playingItem = item playingItem = item
playingEpisode = null playingEpisode = null
}, },
@@ -118,6 +121,14 @@ class MainActivity : ComponentActivity() {
} }
) )
} }
NavDestination.HISTORY -> {
LibraryScreen(
title = "Watch History",
items = historyItems,
onOpenDetail = { item -> activeDetailItem = item },
emptyMessage = "Nothing watched yet. Press play on a title and it shows up here."
)
}
NavDestination.WATCH_LATER -> { NavDestination.WATCH_LATER -> {
LibraryScreen( LibraryScreen(
title = "Watch Later", title = "Watch Later",
@@ -147,6 +158,7 @@ class MainActivity : ComponentActivity() {
onToggleWatchLater = { libraryManager.toggle("wl", it) }, onToggleWatchLater = { libraryManager.toggle("wl", it) },
onToggleFavorite = { libraryManager.toggle("fav", it) }, onToggleFavorite = { libraryManager.toggle("fav", it) },
onPlay = { itm, ep -> onPlay = { itm, ep ->
libraryManager.addHistory(itm)
playingItem = itm playingItem = itm
playingEpisode = ep playingEpisode = ep
}, },

View File

@@ -30,10 +30,21 @@ class LibraryManager private constructor(context: Context) {
private val _favorites = MutableStateFlow<List<MediaItem>>(emptyList()) private val _favorites = MutableStateFlow<List<MediaItem>>(emptyList())
val favorites: StateFlow<List<MediaItem>> = _favorites.asStateFlow() val favorites: StateFlow<List<MediaItem>> = _favorites.asStateFlow()
private val _history = MutableStateFlow<List<MediaItem>>(emptyList())
val history: StateFlow<List<MediaItem>> = _history.asStateFlow()
init { init {
load() load()
} }
fun addHistory(item: MediaItem) {
val current = _history.value.toMutableList()
current.removeAll { it.id == item.id && it.mediaType == item.mediaType }
current.add(0, item)
_history.value = current.take(100)
save()
}
private fun load() { private fun load() {
val raw = prefs.getString("vyla.lib", null) val raw = prefs.getString("vyla.lib", null)
if (raw.isNullOrEmpty()) return if (raw.isNullOrEmpty()) return
@@ -41,6 +52,7 @@ class LibraryManager private constructor(context: Context) {
val root = JSONObject(raw) val root = JSONObject(raw)
_watchLater.value = parseList(root.optJSONArray("wl")) _watchLater.value = parseList(root.optJSONArray("wl"))
_favorites.value = parseList(root.optJSONArray("fav")) _favorites.value = parseList(root.optJSONArray("fav"))
_history.value = parseList(root.optJSONArray("hist"))
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }
@@ -51,6 +63,7 @@ class LibraryManager private constructor(context: Context) {
val root = JSONObject() val root = JSONObject()
root.put("wl", serializeList(_watchLater.value)) root.put("wl", serializeList(_watchLater.value))
root.put("fav", serializeList(_favorites.value)) root.put("fav", serializeList(_favorites.value))
root.put("hist", serializeList(_history.value))
prefs.edit().putString("vyla.lib", root.toString()).apply() prefs.edit().putString("vyla.lib", root.toString()).apply()
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()

View File

@@ -51,6 +51,7 @@ enum class NavDestination(val key: String, val title: String, val icon: ImageVec
MOVIES("movie", "Movies", Icons.Default.Movie), MOVIES("movie", "Movies", Icons.Default.Movie),
TV_SHOWS("tv", "TV Shows", Icons.Default.Tv), TV_SHOWS("tv", "TV Shows", Icons.Default.Tv),
ANIME("anime", "Anime", Icons.Default.AutoAwesome), ANIME("anime", "Anime", Icons.Default.AutoAwesome),
HISTORY("history", "History", Icons.Default.History),
WATCH_LATER("wl", "Watch Later", Icons.Default.Schedule), WATCH_LATER("wl", "Watch Later", Icons.Default.Schedule),
FAVORITES("fav", "Favorites", Icons.Default.Favorite) FAVORITES("fav", "Favorites", Icons.Default.Favorite)
} }
@@ -59,6 +60,7 @@ enum class NavDestination(val key: String, val title: String, val icon: ImageVec
@OptIn(ExperimentalComposeUiApi::class) @OptIn(ExperimentalComposeUiApi::class)
fun Sidebar( fun Sidebar(
currentDestination: NavDestination, currentDestination: NavDestination,
hasHistory: Boolean,
hasWatchLater: Boolean, hasWatchLater: Boolean,
hasFavorites: Boolean, hasFavorites: Boolean,
onNavigate: (NavDestination) -> Unit, onNavigate: (NavDestination) -> Unit,
@@ -148,6 +150,7 @@ fun Sidebar(
) { ) {
NavDestination.values().forEach { destination -> NavDestination.values().forEach { destination ->
val shouldShow = when (destination) { val shouldShow = when (destination) {
NavDestination.HISTORY -> hasHistory || currentDestination == NavDestination.HISTORY
NavDestination.WATCH_LATER -> hasWatchLater || currentDestination == NavDestination.WATCH_LATER NavDestination.WATCH_LATER -> hasWatchLater || currentDestination == NavDestination.WATCH_LATER
NavDestination.FAVORITES -> hasFavorites || currentDestination == NavDestination.FAVORITES NavDestination.FAVORITES -> hasFavorites || currentDestination == NavDestination.FAVORITES
else -> true else -> true

View File

@@ -34,7 +34,8 @@ fun LibraryScreen(
title: String, title: String,
items: List<MediaItem>, items: List<MediaItem>,
onOpenDetail: (MediaItem) -> Unit, onOpenDetail: (MediaItem) -> Unit,
modifier: Modifier = Modifier modifier: Modifier = Modifier,
emptyMessage: String = "Nothing here yet. Open a title, press the ⋮ button and add it."
) { ) {
var ambientUrl by remember(items) { mutableStateOf(items.firstOrNull()?.ambientBackdropUrl) } var ambientUrl by remember(items) { mutableStateOf(items.firstOrNull()?.ambientBackdropUrl) }
Box(modifier = modifier.fillMaxSize().background(VylaBackground)) { Box(modifier = modifier.fillMaxSize().background(VylaBackground)) {
@@ -86,7 +87,7 @@ fun LibraryScreen(
contentAlignment = androidx.compose.ui.Alignment.TopStart contentAlignment = androidx.compose.ui.Alignment.TopStart
) { ) {
Text( Text(
text = "Nothing here yet. Open a title, press the ⋮ button and add it.", text = emptyMessage,
color = VylaTextMuted, color = VylaTextMuted,
fontSize = 17.sp fontSize = 17.sp
) )

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "tv", "name": "tv",
"version": "1.0.5", "version": "1.0.6",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "tv", "name": "tv",
"version": "1.0.5", "version": "1.0.6",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@vyla-entertainment/sdk": "^1.14.0", "@vyla-entertainment/sdk": "^1.14.0",

View File

@@ -1,6 +1,6 @@
{ {
"name": "tv", "name": "tv",
"version": "1.0.5", "version": "1.0.6",
"description": "", "description": "",
"type": "module", "type": "module",
"scripts": { "scripts": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "Vyla TV", "name": "Vyla TV",
"version": "1.0.4", "version": "1.0.5",
"package": "Vyla-TV_1.0.4.apk", "package": "Vyla-TV_1.0.5.apk",
"releaseDate": "2026-10-05T20:22:35.051Z" "releaseDate": "2026-10-05T22:49:51.172Z"
} }