Skip to content

Commit

Permalink
Fixed: The fileName was showing in notification instead of book name.
Browse files Browse the repository at this point in the history
  • Loading branch information
MohitMaliDeveloper committed Dec 16, 2024
1 parent 8f5f6cb commit 068508d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 63 in core/src/main/java/org/kiwix/kiwixmobile/core/downloader/downloadManager/DownloadManagerRequester.kt

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/kiwix/kiwixmobile/core/downloader/downloadManager/DownloadManagerRequester.kt#L63

Added line #L63 was not covered by tests
val newDownloadEntity =
downloadRoomEntity.copy(downloadId = enqueue(downloadRequest), id = 0)
// cancel the previous download and its data from database and fileSystem.
Expand Down Expand Up @@ -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)

Check warning on line 100 in core/src/main/java/org/kiwix/kiwixmobile/core/downloader/downloadManager/DownloadManagerRequester.kt

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/kiwix/kiwixmobile/core/downloader/downloadManager/DownloadManagerRequester.kt#L100

Added line #L100 was not covered by tests
setDestinationUri(Uri.fromFile(getDestinationFile(sharedPreferenceUtil)))
setAllowedNetworkTypes(
if (sharedPreferenceUtil.prefWifiOnly)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 068508d

Please sign in to comment.