feat: show content title in download notification

Store the movie/episode title as UTF-8 bytes in DownloadRequest.data
when building each download request. PurefinDownloadService reads it
back in getForegroundNotification() so the notification shows the
actual title (e.g. "Inception") instead of the generic "Downloading".

For multiple simultaneous downloads the existing "Downloading N files"
text is kept. The title is persisted by Media3 alongside the request,
so it survives app restarts.
This commit is contained in:
2026-03-03 15:24:08 +01:00
parent b4b500d5dd
commit 28c2c0b25d
2 changed files with 10 additions and 3 deletions

View File

@@ -164,7 +164,9 @@ class MediaDownloadManager @Inject constructor(
offlineDataSource.saveMovies(listOf(movie))
Log.d(TAG, "Starting download for '${movie.title}' from: $url")
val request = DownloadRequest.Builder(movieId.toString(), url.toUri()).build()
val request = DownloadRequest.Builder(movieId.toString(), url.toUri())
.setData(movie.title.toByteArray(Charsets.UTF_8))
.build()
PurefinDownloadService.sendAddDownload(context, request)
Log.d(TAG, "Download request sent for $movieId")
} catch (e: Exception) {
@@ -226,7 +228,9 @@ class MediaDownloadManager @Inject constructor(
offlineDataSource.saveEpisode(episode)
Log.d(TAG, "Starting download for episode '${episode.title}' from: $url")
val request = DownloadRequest.Builder(episodeId.toString(), url.toUri()).build()
val request = DownloadRequest.Builder(episodeId.toString(), url.toUri())
.setData(episode.title.toByteArray(Charsets.UTF_8))
.build()
PurefinDownloadService.sendAddDownload(context, request)
Log.d(TAG, "Download request sent for episode $episodeId")
} catch (e: Exception) {

View File

@@ -79,7 +79,10 @@ class PurefinDownloadService : DownloadService(
}
val title = if (activeDownloads.size == 1) {
"Downloading"
activeDownloads[0].request.data
?.toString(Charsets.UTF_8)
?.takeIf { it.isNotBlank() }
?: "Downloading"
} else {
"Downloading ${activeDownloads.size} files"
}