mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 04:37:25 +01:00
Drop support for reencode images
This commit is contained in:
parent
c1ac47e1ce
commit
d7b8015df7
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -431,7 +431,7 @@ abstract class OnlineSource() : Source {
|
||||
private fun cacheImage(page: Page): Observable<Page> {
|
||||
page.status = Page.DOWNLOAD_IMAGE
|
||||
return imageResponse(page)
|
||||
.doOnNext { chapterCache.putImageToCache(page.imageUrl!!, it, preferences.reencodeImage()) }
|
||||
.doOnNext { chapterCache.putImageToCache(page.imageUrl!!, it) }
|
||||
.map { page }
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
@ -167,8 +167,6 @@
|
||||
<string name="clear_database_completed">Entradas borradas</string>
|
||||
<string name="pref_show_warning_message">Mostrar advertencias</string>
|
||||
<string name="pref_show_warning_message_summary">Mostrar mensajes de advertencia durante la sincronización de la librería</string>
|
||||
<string name="pref_reencode"> Recodificar imágenes</string>
|
||||
<string name="pref_reencode_summary">Habilitar recodificación si las imágenes no pueden ser decodificadas. Para mejores resultados, usar junto a Skia</string>
|
||||
|
||||
<!-- About section -->
|
||||
<string name="version">Versión</string>
|
||||
|
@ -169,8 +169,6 @@
|
||||
<string name="clear_database_completed">Eliminar entradas</string>
|
||||
<string name="pref_show_warning_message">Mostrar avisos</string>
|
||||
<string name="pref_show_warning_message_summary">Mostrar mensagens de avisos durante a sincronização</string>
|
||||
<string name="pref_reencode">Recodificar imagens</string>
|
||||
<string name="pref_reencode_summary">Permitir recodificação se as imagens não puderam ser descodificadas. Para melhores resultados utilize Skia</string>
|
||||
|
||||
<!-- About section -->
|
||||
<string name="version">Versão</string>
|
||||
|
@ -39,7 +39,6 @@
|
||||
<string name="pref_image_decoder_key">pref_image_decoder_key</string>
|
||||
<string name="pref_read_with_volume_keys_key">reader_volume_keys</string>
|
||||
<string name="pref_read_with_tapping_key">reader_tap</string>
|
||||
<string name="pref_reencode_key">reencode_image</string>
|
||||
<string name="pref_filter_downloaded_key">pref_filter_downloaded_key</string>
|
||||
<string name="pref_filter_unread_key">pref_filter_unread_key</string>
|
||||
|
||||
|
@ -178,8 +178,6 @@
|
||||
<string name="clear_database_completed">Entries deleted</string>
|
||||
<string name="pref_refresh_library_metadata">Refresh library metadata</string>
|
||||
<string name="pref_refresh_library_metadata_summary">Updates covers, genres, description and manga status information</string>
|
||||
<string name="pref_reencode">Reencode images</string>
|
||||
<string name="pref_reencode_summary">Enable reencoding if images can\'t be decoded. Expect best results with Skia</string>
|
||||
|
||||
<!-- About section -->
|
||||
<string name="version">Version</string>
|
||||
|
@ -25,12 +25,6 @@
|
||||
android:summary="@string/pref_refresh_library_metadata_summary"
|
||||
android:title="@string/pref_refresh_library_metadata"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/pref_reencode_key"
|
||||
android:summary="@string/pref_reencode_summary"
|
||||
android:title="@string/pref_reencode"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user