mirror of
https://github.com/bbara04/Purefin.git
synced 2026-03-31 17:10:08 +02:00
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:
@@ -164,7 +164,9 @@ class MediaDownloadManager @Inject constructor(
|
|||||||
offlineDataSource.saveMovies(listOf(movie))
|
offlineDataSource.saveMovies(listOf(movie))
|
||||||
|
|
||||||
Log.d(TAG, "Starting download for '${movie.title}' from: $url")
|
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)
|
PurefinDownloadService.sendAddDownload(context, request)
|
||||||
Log.d(TAG, "Download request sent for $movieId")
|
Log.d(TAG, "Download request sent for $movieId")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -226,7 +228,9 @@ class MediaDownloadManager @Inject constructor(
|
|||||||
offlineDataSource.saveEpisode(episode)
|
offlineDataSource.saveEpisode(episode)
|
||||||
|
|
||||||
Log.d(TAG, "Starting download for episode '${episode.title}' from: $url")
|
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)
|
PurefinDownloadService.sendAddDownload(context, request)
|
||||||
Log.d(TAG, "Download request sent for episode $episodeId")
|
Log.d(TAG, "Download request sent for episode $episodeId")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|||||||
@@ -79,7 +79,10 @@ class PurefinDownloadService : DownloadService(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val title = if (activeDownloads.size == 1) {
|
val title = if (activeDownloads.size == 1) {
|
||||||
"Downloading"
|
activeDownloads[0].request.data
|
||||||
|
?.toString(Charsets.UTF_8)
|
||||||
|
?.takeIf { it.isNotBlank() }
|
||||||
|
?: "Downloading"
|
||||||
} else {
|
} else {
|
||||||
"Downloading ${activeDownloads.size} files"
|
"Downloading ${activeDownloads.size} files"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user