mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
Fixed: The fileName was showing in notification instead of book name.
This commit is contained in:
parent
86658fb58e
commit
5050e4a92e
@ -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,
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user