Fix manga downloading
This commit is contained in:
@@ -16,7 +16,7 @@ android {
|
|||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode gitCommits
|
versionCode gitCommits
|
||||||
versionName '0.5.3'
|
versionName '0.5.4'
|
||||||
|
|
||||||
kapt {
|
kapt {
|
||||||
arguments {
|
arguments {
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ class WritableCbzFile(private val file: File) {
|
|||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
dir.mkdir()
|
dir.mkdir()
|
||||||
}
|
}
|
||||||
|
if (!file.exists()) {
|
||||||
|
return@withContext
|
||||||
|
}
|
||||||
ZipInputStream(FileInputStream(file)).use { zip ->
|
ZipInputStream(FileInputStream(file)).use { zip ->
|
||||||
var entry = zip.nextEntry
|
var entry = zip.nextEntry
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class DownloadNotification(private val context: Context) {
|
|||||||
builder.setSmallIcon(android.R.drawable.stat_sys_download)
|
builder.setSmallIcon(android.R.drawable.stat_sys_download)
|
||||||
builder.setLargeIcon(null)
|
builder.setLargeIcon(null)
|
||||||
builder.setContentIntent(null)
|
builder.setContentIntent(null)
|
||||||
|
builder.setStyle(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setCancelId(startId: Int) {
|
fun setCancelId(startId: Int) {
|
||||||
@@ -68,13 +69,15 @@ class DownloadNotification(private val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setError(e: Throwable) {
|
fun setError(e: Throwable) {
|
||||||
|
val message = e.getDisplayMessage(context.resources)
|
||||||
builder.setProgress(0, 0, false)
|
builder.setProgress(0, 0, false)
|
||||||
builder.setSmallIcon(android.R.drawable.stat_notify_error)
|
builder.setSmallIcon(android.R.drawable.stat_notify_error)
|
||||||
builder.setSubText(context.getString(R.string.error))
|
builder.setSubText(context.getString(R.string.error))
|
||||||
builder.setContentText(e.getDisplayMessage(context.resources))
|
builder.setContentText(message)
|
||||||
builder.setAutoCancel(true)
|
builder.setAutoCancel(true)
|
||||||
builder.setContentIntent(null)
|
builder.setContentIntent(null)
|
||||||
builder.setCategory(NotificationCompat.CATEGORY_ERROR)
|
builder.setCategory(NotificationCompat.CATEGORY_ERROR)
|
||||||
|
builder.setStyle(NotificationCompat.BigTextStyle().bigText(message))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setLargeIcon(icon: Drawable?) {
|
fun setLargeIcon(icon: Drawable?) {
|
||||||
@@ -89,16 +92,19 @@ class DownloadNotification(private val context: Context) {
|
|||||||
builder.setProgress(max, progress, false)
|
builder.setProgress(max, progress, false)
|
||||||
builder.setContentText("%d%%".format(percent))
|
builder.setContentText("%d%%".format(percent))
|
||||||
builder.setCategory(NotificationCompat.CATEGORY_PROGRESS)
|
builder.setCategory(NotificationCompat.CATEGORY_PROGRESS)
|
||||||
|
builder.setStyle(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setWaitingForNetwork() {
|
fun setWaitingForNetwork() {
|
||||||
builder.setProgress(0, 0, false)
|
builder.setProgress(0, 0, false)
|
||||||
builder.setContentText(context.getString(R.string.waiting_for_network))
|
builder.setContentText(context.getString(R.string.waiting_for_network))
|
||||||
|
builder.setStyle(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setPostProcessing() {
|
fun setPostProcessing() {
|
||||||
builder.setProgress(1, 0, true)
|
builder.setProgress(1, 0, true)
|
||||||
builder.setContentText(context.getString(R.string.processing_))
|
builder.setContentText(context.getString(R.string.processing_))
|
||||||
|
builder.setStyle(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setDone(manga: Manga) {
|
fun setDone(manga: Manga) {
|
||||||
@@ -108,12 +114,14 @@ class DownloadNotification(private val context: Context) {
|
|||||||
builder.setAutoCancel(true)
|
builder.setAutoCancel(true)
|
||||||
builder.setSmallIcon(android.R.drawable.stat_sys_download_done)
|
builder.setSmallIcon(android.R.drawable.stat_sys_download_done)
|
||||||
builder.setCategory(null)
|
builder.setCategory(null)
|
||||||
|
builder.setStyle(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setCancelling() {
|
fun setCancelling() {
|
||||||
builder.setProgress(1, 0, true)
|
builder.setProgress(1, 0, true)
|
||||||
builder.setContentText(context.getString(R.string.cancelling_))
|
builder.setContentText(context.getString(R.string.cancelling_))
|
||||||
builder.setContentIntent(null)
|
builder.setContentIntent(null)
|
||||||
|
builder.setStyle(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update(id: Int = NOTIFICATION_ID) {
|
fun update(id: Int = NOTIFICATION_ID) {
|
||||||
|
|||||||
@@ -156,6 +156,9 @@ class DownloadService : BaseService() {
|
|||||||
notification.update()
|
notification.update()
|
||||||
}
|
}
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
|
if (BuildConfig.DEBUG) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
notification.setError(e)
|
notification.setError(e)
|
||||||
notification.setCancelId(0)
|
notification.setCancelId(0)
|
||||||
notification.dismiss()
|
notification.dismiss()
|
||||||
|
|||||||
Reference in New Issue
Block a user