Loading app/build.gradle +2 −2 Original line number Diff line number Diff line Loading @@ -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" Loading app/src/main/java/io/heckel/ntfy/msg/DownloadWorker.kt +4 −2 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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 } } Loading
app/build.gradle +2 −2 Original line number Diff line number Diff line Loading @@ -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" Loading
app/src/main/java/io/heckel/ntfy/msg/DownloadWorker.kt +4 −2 Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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 } }