Loading app/src/main/java/io/heckel/ntfy/db/Database.kt +0 −3 Original line number Diff line number Diff line Loading @@ -383,9 +383,6 @@ interface NotificationDao { @Query("SELECT DISTINCT icon_contentUri FROM notification WHERE deleted != 1 AND icon_contentUri <> ''") fun listActiveIconUris(): List<String> @Query("SELECT DISTINCT icon_contentUri FROM notification WHERE deleted = 1 AND icon_contentUri <> ''") fun listDeletedIconUris(): List<String> @Query("UPDATE notification SET icon_contentUri = null WHERE icon_contentUri = :uri") fun clearIconUri(uri: String) Loading app/src/main/java/io/heckel/ntfy/db/Repository.kt +0 −4 Original line number Diff line number Diff line Loading @@ -96,10 +96,6 @@ class Repository(private val sharedPrefs: SharedPreferences, private val databas return notificationDao.listActiveIconUris().toSet() } fun getDeletedIconUris(): Set<String> { return notificationDao.listDeletedIconUris().toSet() } fun clearIconUri(uri: String) { notificationDao.clearIconUri(uri) } Loading app/src/main/java/io/heckel/ntfy/msg/DownloadIconWorker.kt +10 −7 Original line number Diff line number Diff line Loading @@ -90,14 +90,9 @@ class DownloadIconWorker(private val context: Context, params: WorkerParameters) this.uri = uri // Required for cleanup in onStopped() Log.d(TAG, "Starting download to content URI: $uri") val contentLength = response.headers["Content-Length"]?.toLongOrNull() var bytesCopied: Long = 0 val outFile = resolver.openOutputStream(uri) ?: throw Exception("Cannot open output stream") val downloadLimit = if (repository.getAutoDownloadMaxSize() != Repository.AUTO_DOWNLOAD_NEVER && repository.getAutoDownloadMaxSize() != Repository.AUTO_DOWNLOAD_ALWAYS) { repository.getAutoDownloadMaxSize() } else { MAX_ICON_DOWNLOAD_SIZE.toLong() } val downloadLimit = getDownloadLimit() outFile.use { fileOut -> val fileIn = response.body!!.byteStream() val buffer = ByteArray(BUFFER_SIZE) Loading Loading @@ -144,11 +139,19 @@ class DownloadIconWorker(private val context: Context, params: WorkerParameters) } private fun shouldAbortDownload(response: Response): Boolean { val maxAutoDownloadSize = MAX_ICON_DOWNLOAD_SIZE val maxAutoDownloadSize = getDownloadLimit() val size = response.headers["Content-Length"]?.toLongOrNull() ?: return false // Don't abort here if size unknown return size > maxAutoDownloadSize } private fun getDownloadLimit(): Long { return if (repository.getAutoDownloadMaxSize() != Repository.AUTO_DOWNLOAD_NEVER && repository.getAutoDownloadMaxSize() != Repository.AUTO_DOWNLOAD_ALWAYS) { repository.getAutoDownloadMaxSize() } else { MAX_ICON_DOWNLOAD_SIZE.toLong() } } private fun createIconFile(icon: Icon): File { val iconDir = File(context.cacheDir, ICON_CACHE_DIR) if (!iconDir.exists() && !iconDir.mkdirs()) { Loading Loading
app/src/main/java/io/heckel/ntfy/db/Database.kt +0 −3 Original line number Diff line number Diff line Loading @@ -383,9 +383,6 @@ interface NotificationDao { @Query("SELECT DISTINCT icon_contentUri FROM notification WHERE deleted != 1 AND icon_contentUri <> ''") fun listActiveIconUris(): List<String> @Query("SELECT DISTINCT icon_contentUri FROM notification WHERE deleted = 1 AND icon_contentUri <> ''") fun listDeletedIconUris(): List<String> @Query("UPDATE notification SET icon_contentUri = null WHERE icon_contentUri = :uri") fun clearIconUri(uri: String) Loading
app/src/main/java/io/heckel/ntfy/db/Repository.kt +0 −4 Original line number Diff line number Diff line Loading @@ -96,10 +96,6 @@ class Repository(private val sharedPrefs: SharedPreferences, private val databas return notificationDao.listActiveIconUris().toSet() } fun getDeletedIconUris(): Set<String> { return notificationDao.listDeletedIconUris().toSet() } fun clearIconUri(uri: String) { notificationDao.clearIconUri(uri) } Loading
app/src/main/java/io/heckel/ntfy/msg/DownloadIconWorker.kt +10 −7 Original line number Diff line number Diff line Loading @@ -90,14 +90,9 @@ class DownloadIconWorker(private val context: Context, params: WorkerParameters) this.uri = uri // Required for cleanup in onStopped() Log.d(TAG, "Starting download to content URI: $uri") val contentLength = response.headers["Content-Length"]?.toLongOrNull() var bytesCopied: Long = 0 val outFile = resolver.openOutputStream(uri) ?: throw Exception("Cannot open output stream") val downloadLimit = if (repository.getAutoDownloadMaxSize() != Repository.AUTO_DOWNLOAD_NEVER && repository.getAutoDownloadMaxSize() != Repository.AUTO_DOWNLOAD_ALWAYS) { repository.getAutoDownloadMaxSize() } else { MAX_ICON_DOWNLOAD_SIZE.toLong() } val downloadLimit = getDownloadLimit() outFile.use { fileOut -> val fileIn = response.body!!.byteStream() val buffer = ByteArray(BUFFER_SIZE) Loading Loading @@ -144,11 +139,19 @@ class DownloadIconWorker(private val context: Context, params: WorkerParameters) } private fun shouldAbortDownload(response: Response): Boolean { val maxAutoDownloadSize = MAX_ICON_DOWNLOAD_SIZE val maxAutoDownloadSize = getDownloadLimit() val size = response.headers["Content-Length"]?.toLongOrNull() ?: return false // Don't abort here if size unknown return size > maxAutoDownloadSize } private fun getDownloadLimit(): Long { return if (repository.getAutoDownloadMaxSize() != Repository.AUTO_DOWNLOAD_NEVER && repository.getAutoDownloadMaxSize() != Repository.AUTO_DOWNLOAD_ALWAYS) { repository.getAutoDownloadMaxSize() } else { MAX_ICON_DOWNLOAD_SIZE.toLong() } } private fun createIconFile(icon: Icon): File { val iconDir = File(context.cacheDir, ICON_CACHE_DIR) if (!iconDir.exists() && !iconDir.mkdirs()) { Loading