From d7b8015df7306f7ed1272f7edd04b02d9f7af21f Mon Sep 17 00:00:00 2001 From: len Date: Sun, 23 Oct 2016 13:22:14 +0200 Subject: [PATCH] Drop support for reencode images --- .../tachiyomi/data/cache/ChapterCache.kt | 6 ++--- .../data/download/DownloadManager.kt | 2 +- .../data/preference/PreferenceKeys.kt | 2 -- .../data/preference/PreferencesHelper.kt | 2 -- .../data/source/online/OnlineSource.kt | 2 +- .../kanade/tachiyomi/util/OkioExtensions.kt | 23 ------------------- app/src/main/res/values-es/strings.xml | 2 -- app/src/main/res/values-pt/strings.xml | 2 -- app/src/main/res/values/keys.xml | 1 - app/src/main/res/values/strings.xml | 2 -- app/src/main/res/xml/pref_advanced.xml | 6 ----- 11 files changed, 5 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt index fa000a16d8..de36e85510 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt @@ -7,7 +7,7 @@ import com.google.gson.reflect.TypeToken import com.jakewharton.disklrucache.DiskLruCache import eu.kanade.tachiyomi.data.source.model.Page import eu.kanade.tachiyomi.util.DiskUtils -import eu.kanade.tachiyomi.util.saveImageTo +import eu.kanade.tachiyomi.util.saveTo import okhttp3.Response import okio.Okio import rx.Observable @@ -185,7 +185,7 @@ class ChapterCache(private val context: Context) { * @throws IOException image error. */ @Throws(IOException::class) - fun putImageToCache(imageUrl: String, response: Response, reencode: Boolean) { + fun putImageToCache(imageUrl: String, response: Response) { // Initialize editor (edits the values for an entry). var editor: DiskLruCache.Editor? = null @@ -195,7 +195,7 @@ class ChapterCache(private val context: Context) { editor = diskCache.edit(key) ?: throw IOException("Unable to edit key") // Get OutputStream and write image with Okio. - response.body().source().saveImageTo(editor.newOutputStream(0), reencode) + response.body().source().saveTo(editor.newOutputStream(0)) diskCache.flush() editor.commit() diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index 1661d6a444..f92d7ead83 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -264,7 +264,7 @@ class DownloadManager( val file = File(directory, filename) try { file.parentFile.mkdirs() - it.body().source().saveImageTo(file.outputStream(), preferences.reencodeImage()) + it.body().source().saveTo(file.outputStream()) } catch (e: Exception) { it.close() file.delete() diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index 76e7932b22..46b07458fe 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -44,8 +44,6 @@ class PreferenceKeys(context: Context) { val readWithVolumeKeys = context.getString(R.string.pref_read_with_volume_keys_key) - val reencodeImage = context.getString(R.string.pref_reencode_key) - val portraitColumns = context.getString(R.string.pref_library_columns_portrait_key) val landscapeColumns = context.getString(R.string.pref_library_columns_landscape_key) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index a9210fbef5..c18c1cd0a0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -70,8 +70,6 @@ class PreferencesHelper(context: Context) { fun readWithVolumeKeys() = rxPrefs.getBoolean(keys.readWithVolumeKeys, false) - fun reencodeImage() = prefs.getBoolean(keys.reencodeImage, false) - fun portraitColumns() = rxPrefs.getInteger(keys.portraitColumns, 0) fun landscapeColumns() = rxPrefs.getInteger(keys.landscapeColumns, 0) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/source/online/OnlineSource.kt b/app/src/main/java/eu/kanade/tachiyomi/data/source/online/OnlineSource.kt index 0d7cd72211..cb77baa50b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/source/online/OnlineSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/source/online/OnlineSource.kt @@ -431,7 +431,7 @@ abstract class OnlineSource() : Source { private fun cacheImage(page: Page): Observable { page.status = Page.DOWNLOAD_IMAGE return imageResponse(page) - .doOnNext { chapterCache.putImageToCache(page.imageUrl!!, it, preferences.reencodeImage()) } + .doOnNext { chapterCache.putImageToCache(page.imageUrl!!, it) } .map { page } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/OkioExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/OkioExtensions.kt index 29f31caa3b..c4fbf2c00c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/OkioExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/OkioExtensions.kt @@ -1,7 +1,5 @@ package eu.kanade.tachiyomi.util -import android.graphics.Bitmap -import android.graphics.BitmapFactory import okio.BufferedSource import okio.Okio import java.io.File @@ -39,24 +37,3 @@ fun BufferedSource.saveTo(stream: OutputStream) { } } } - -/** - * Saves the given source to an output stream and closes both resources. - * The source is expected to be an image, and it may reencode the image. - * - * @param stream the stream where the source is copied. - * @param reencode whether to reencode the image or not. - */ -fun BufferedSource.saveImageTo(stream: OutputStream, reencode: Boolean = false) { - if (reencode) { - use { - val bitmap = BitmapFactory.decodeStream(it.inputStream()) - stream.use { - bitmap.compress(Bitmap.CompressFormat.JPEG, 100, it) - } - bitmap.recycle() - } - } else { - saveTo(stream) - } -} \ No newline at end of file diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 5133f55749..553e0a232b 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -167,8 +167,6 @@ Entradas borradas Mostrar advertencias Mostrar mensajes de advertencia durante la sincronización de la librería - Recodificar imágenes - Habilitar recodificación si las imágenes no pueden ser decodificadas. Para mejores resultados, usar junto a Skia Versión diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 9c5297a46b..e4eee38cfe 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -169,8 +169,6 @@ Eliminar entradas Mostrar avisos Mostrar mensagens de avisos durante a sincronização - Recodificar imagens - Permitir recodificação se as imagens não puderam ser descodificadas. Para melhores resultados utilize Skia Versão diff --git a/app/src/main/res/values/keys.xml b/app/src/main/res/values/keys.xml index b7f135600d..ad8de7baab 100644 --- a/app/src/main/res/values/keys.xml +++ b/app/src/main/res/values/keys.xml @@ -39,7 +39,6 @@ pref_image_decoder_key reader_volume_keys reader_tap - reencode_image pref_filter_downloaded_key pref_filter_unread_key diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e8ae2e88a8..91b4af0914 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -178,8 +178,6 @@ Entries deleted Refresh library metadata Updates covers, genres, description and manga status information - Reencode images - Enable reencoding if images can\'t be decoded. Expect best results with Skia Version diff --git a/app/src/main/res/xml/pref_advanced.xml b/app/src/main/res/xml/pref_advanced.xml index 418e704dbc..9131e8154c 100644 --- a/app/src/main/res/xml/pref_advanced.xml +++ b/app/src/main/res/xml/pref_advanced.xml @@ -25,12 +25,6 @@ android:summary="@string/pref_refresh_library_metadata_summary" android:title="@string/pref_refresh_library_metadata"/> - - \ No newline at end of file