Fixed: The fileName was showing in notification instead of book name.

This commit is contained in:
MohitMaliFtechiz 2024-12-16 15:40:53 +05:30 committed by Kelson
parent 86658fb58e
commit 5050e4a92e
4 changed files with 13 additions and 4 deletions

View File

@ -113,7 +113,7 @@ abstract class DownloadRoomDao {
sharedPreferenceUtil: SharedPreferenceUtil
) {
if (doesNotAlreadyExist(book)) {
val downloadRequest = DownloadRequest(url)
val downloadRequest = DownloadRequest(url, book.title)
saveDownload(
DownloadRoomEntity(
url,

View File

@ -351,7 +351,14 @@ class DownloadManagerMonitor @Inject constructor(
) {
synchronized(lock) {
updater.onNext {
Log.e("DOWNLOAD_MONITOR", "updateDownloadStatus: $status \n $error \n $progress")
Log.e(
"DOWNLOAD_MONITOR",
"updateDownloadStatus: " +
"\n Status = $status" +
"\n Error = $error" +
"\n Progress = $progress" +
"\n DownloadId = $downloadId"
)
downloadRoomDao.getEntityForDownloadId(downloadId)?.let { downloadEntity ->
if (shouldUpdateDownloadStatus(downloadEntity)) {
val downloadModel = DownloadModel(downloadEntity).apply {

View File

@ -60,7 +60,7 @@ class DownloadManagerRequester @Inject constructor(
.downloadRoomDao
.getEntityForDownloadId(downloadId)?.let { downloadRoomEntity ->
downloadRoomEntity.url?.let {
val downloadRequest = DownloadRequest(urlString = it)
val downloadRequest = DownloadRequest(urlString = it, downloadRoomEntity.title)
val newDownloadEntity =
downloadRoomEntity.copy(downloadId = enqueue(downloadRequest), id = 0)
// cancel the previous download and its data from database and fileSystem.
@ -97,6 +97,7 @@ fun DownloadRequest.toDownloadManagerRequest(
return if (urlString.isAuthenticationUrl) {
// return the request with "Authorization" header if the url is a Authentication url.
DownloadManager.Request(urlString.removeAuthenticationFromUrl.toUri()).apply {
setTitle(bookTitle)
setDestinationUri(Uri.fromFile(getDestinationFile(sharedPreferenceUtil)))
setAllowedNetworkTypes(
if (sharedPreferenceUtil.prefWifiOnly)
@ -115,6 +116,7 @@ fun DownloadRequest.toDownloadManagerRequest(
} else {
// return the request for normal urls.
DownloadManager.Request(uri).apply {
setTitle(bookTitle)
setDestinationUri(Uri.fromFile(getDestinationFile(sharedPreferenceUtil)))
setAllowedNetworkTypes(
if (sharedPreferenceUtil.prefWifiOnly)

View File

@ -22,7 +22,7 @@ import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
import org.kiwix.kiwixmobile.core.utils.StorageUtils
import java.io.File
data class DownloadRequest(val urlString: String) {
data class DownloadRequest(val urlString: String, val bookTitle: String) {
val uri: Uri get() = Uri.parse(urlString)