Fixes descriptive notification message for errors (#6413)

* Fixes descriptive notification message for errors
Fixes #6401

* Fixes descriptive notification message for errors
Fixes #6401
This commit is contained in:
Mohit Mandalia 2022-01-01 23:43:44 +05:30 committed by GitHub
parent bdf4b4b679
commit 22615f5981
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -209,12 +209,11 @@ internal class DownloadNotifier(private val context: Context) {
* @param error string containing error information. * @param error string containing error information.
* @param chapter string containing chapter title. * @param chapter string containing chapter title.
*/ */
fun onError(error: String? = null, chapter: String? = null) { fun onError(error: String? = null, chapter: String? = null, mangaTitle: String? = null) {
// Create notification // Create notification
with(errorNotificationBuilder) { with(errorNotificationBuilder) {
setContentTitle( setContentTitle(
chapter mangaTitle?.plus(": $chapter") ?: context.getString(R.string.download_notifier_downloader_title)
?: context.getString(R.string.download_notifier_downloader_title)
) )
setContentText(error ?: context.getString(R.string.download_notifier_unknown_error)) setContentText(error ?: context.getString(R.string.download_notifier_unknown_error))
setSmallIcon(R.drawable.ic_warning_white_24dp) setSmallIcon(R.drawable.ic_warning_white_24dp)

View File

@ -292,7 +292,7 @@ class Downloader(
val availSpace = DiskUtil.getAvailableStorageSpace(mangaDir) val availSpace = DiskUtil.getAvailableStorageSpace(mangaDir)
if (availSpace != -1L && availSpace < MIN_DISK_SPACE) { if (availSpace != -1L && availSpace < MIN_DISK_SPACE) {
download.status = Download.State.ERROR download.status = Download.State.ERROR
notifier.onError(context.getString(R.string.download_insufficient_space), download.chapter.name) notifier.onError(context.getString(R.string.download_insufficient_space), download.chapter.name, download.manga.title)
return@defer Observable.just(download) return@defer Observable.just(download)
} }
@ -338,7 +338,7 @@ class Downloader(
// If the page list threw, it will resume here // If the page list threw, it will resume here
.onErrorReturn { error -> .onErrorReturn { error ->
download.status = Download.State.ERROR download.status = Download.State.ERROR
notifier.onError(error.message, download.chapter.name) notifier.onError(error.message, download.chapter.name, download.manga.title)
download download
} }
} }