From 83d0d5ff7882ba6004ec2475780ae4d2e75d9682 Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Tue, 11 Jan 2022 22:31:18 -0500 Subject: [PATCH] Bump version --- app/build.gradle | 4 ++-- app/src/main/java/io/heckel/ntfy/msg/DownloadWorker.kt | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4b4163b..af62db1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,8 +12,8 @@ android { minSdkVersion 21 targetSdkVersion 30 - versionCode 15 - versionName "1.5.2" + versionCode 16 + versionName "1.6.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/io/heckel/ntfy/msg/DownloadWorker.kt b/app/src/main/java/io/heckel/ntfy/msg/DownloadWorker.kt index 9dac141..72b63f5 100644 --- a/app/src/main/java/io/heckel/ntfy/msg/DownloadWorker.kt +++ b/app/src/main/java/io/heckel/ntfy/msg/DownloadWorker.kt @@ -89,11 +89,11 @@ class DownloadWorker(private val context: Context, params: WorkerParameters) : W val out = resolver.openOutputStream(uri) ?: throw Exception("Cannot open output stream") out.use { fileOut -> val fileIn = response.body!!.byteStream() - val buffer = ByteArray(8 * 1024) + val buffer = ByteArray(BUFFER_SIZE) var bytes = fileIn.read(buffer) var lastProgress = 0L while (bytes >= 0) { - if (System.currentTimeMillis() - lastProgress > 500) { + if (System.currentTimeMillis() - lastProgress > NOTIFICATION_UPDATE_INTERVAL_MILLIS) { if (isStopped) { Log.d(TAG, "Attachment download was canceled") val newAttachment = attachment.copy(progress = PROGRESS_NONE) @@ -167,5 +167,7 @@ class DownloadWorker(private val context: Context, params: WorkerParameters) : W companion object { private const val TAG = "NtfyAttachDownload" private const val FILE_PROVIDER_AUTHORITY = BuildConfig.APPLICATION_ID + ".provider" // See AndroidManifest.xml + private const val BUFFER_SIZE = 8 * 1024 + private const val NOTIFICATION_UPDATE_INTERVAL_MILLIS = 800 } }