Minor cleanup
(cherry picked from commit 42bc2b07ce1f0b4cfbfe3045cddc9c1fcca8f519) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt
This commit is contained in:
parent
843febd0ff
commit
43a920bbb9
@ -223,11 +223,6 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
6 to stringResource(R.string.scale_type_smart_fit),
|
6 to stringResource(R.string.scale_type_smart_fit),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
|
||||||
pref = readerPreferences.landscapeZoom(),
|
|
||||||
title = stringResource(R.string.pref_landscape_zoom),
|
|
||||||
enabled = imageScaleType == 1,
|
|
||||||
),
|
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
pref = readerPreferences.zoomStart(),
|
pref = readerPreferences.zoomStart(),
|
||||||
title = stringResource(R.string.pref_zoom_start),
|
title = stringResource(R.string.pref_zoom_start),
|
||||||
@ -249,6 +244,11 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
title = stringResource(R.string.pref_page_transitions),
|
title = stringResource(R.string.pref_page_transitions),
|
||||||
),
|
),
|
||||||
// SY <--
|
// SY <--
|
||||||
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
|
pref = readerPreferences.landscapeZoom(),
|
||||||
|
title = stringResource(R.string.pref_landscape_zoom),
|
||||||
|
enabled = imageScaleType == 1,
|
||||||
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
pref = readerPreferences.navigateToPan(),
|
pref = readerPreferences.navigateToPan(),
|
||||||
title = stringResource(R.string.pref_navigate_pan),
|
title = stringResource(R.string.pref_navigate_pan),
|
||||||
|
@ -10,6 +10,7 @@ import eu.kanade.tachiyomi.util.storage.saveTo
|
|||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.flow.drop
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
@ -30,21 +31,9 @@ import java.io.IOException
|
|||||||
* The files are in format *md5key*.0
|
* The files are in format *md5key*.0
|
||||||
*
|
*
|
||||||
* @param context the application context.
|
* @param context the application context.
|
||||||
* @constructor creates an instance of the chapter cache.
|
|
||||||
*/
|
*/
|
||||||
class ChapterCache(private val context: Context) {
|
class ChapterCache(private val context: Context) {
|
||||||
|
|
||||||
companion object {
|
|
||||||
/** Name of cache directory. */
|
|
||||||
const val PARAMETER_CACHE_DIRECTORY = "chapter_disk_cache"
|
|
||||||
|
|
||||||
/** Application cache version. */
|
|
||||||
const val PARAMETER_APP_VERSION = 1
|
|
||||||
|
|
||||||
/** The number of values per cache entry. Must be positive. */
|
|
||||||
const val PARAMETER_VALUE_COUNT = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
private val scope = CoroutineScope(Job() + Dispatchers.Main)
|
private val scope = CoroutineScope(Job() + Dispatchers.Main)
|
||||||
|
|
||||||
/** Google Json class used for parsing JSON files. */
|
/** Google Json class used for parsing JSON files. */
|
||||||
@ -58,6 +47,7 @@ class ChapterCache(private val context: Context) {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
readerPreferences.cacheSize().changes()
|
readerPreferences.cacheSize().changes()
|
||||||
|
.drop(1)
|
||||||
.onEach {
|
.onEach {
|
||||||
// Save old cache for destruction later
|
// Save old cache for destruction later
|
||||||
val oldCache = diskCache
|
val oldCache = diskCache
|
||||||
@ -71,8 +61,7 @@ class ChapterCache(private val context: Context) {
|
|||||||
/**
|
/**
|
||||||
* Returns directory of cache.
|
* Returns directory of cache.
|
||||||
*/
|
*/
|
||||||
private val cacheDir: File
|
private val cacheDir: File = diskCache.directory
|
||||||
get() = diskCache.directory
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns real size of directory.
|
* Returns real size of directory.
|
||||||
@ -90,7 +79,7 @@ class ChapterCache(private val context: Context) {
|
|||||||
// Cache size is in MB
|
// Cache size is in MB
|
||||||
private fun setupDiskCache(cacheSize: Long): DiskLruCache {
|
private fun setupDiskCache(cacheSize: Long): DiskLruCache {
|
||||||
return DiskLruCache.open(
|
return DiskLruCache.open(
|
||||||
File(context.cacheDir, PARAMETER_CACHE_DIRECTORY),
|
File(context.cacheDir, "chapter_disk_cache"),
|
||||||
PARAMETER_APP_VERSION,
|
PARAMETER_APP_VERSION,
|
||||||
PARAMETER_VALUE_COUNT,
|
PARAMETER_VALUE_COUNT,
|
||||||
cacheSize * 1024 * 1024,
|
cacheSize * 1024 * 1024,
|
||||||
@ -238,3 +227,12 @@ class ChapterCache(private val context: Context) {
|
|||||||
return "${chapter.mangaId}${chapter.url}"
|
return "${chapter.mangaId}${chapter.url}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Application cache version. */
|
||||||
|
private const val PARAMETER_APP_VERSION = 1
|
||||||
|
|
||||||
|
/** The number of values per cache entry. Must be positive. */
|
||||||
|
private const val PARAMETER_VALUE_COUNT = 1
|
||||||
|
|
||||||
|
/** The maximum number of bytes this cache should use to store. */
|
||||||
|
private const val PARAMETER_CACHE_SIZE = 100L * 1024 * 1024
|
||||||
|
@ -37,15 +37,6 @@
|
|||||||
android:entries="@array/image_scale_type"
|
android:entries="@array/image_scale_type"
|
||||||
app:title="@string/pref_image_scale_type" />
|
app:title="@string/pref_image_scale_type" />
|
||||||
|
|
||||||
<com.google.android.material.materialswitch.MaterialSwitch
|
|
||||||
android:id="@+id/landscape_zoom"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:paddingHorizontal="16dp"
|
|
||||||
android:paddingVertical="16dp"
|
|
||||||
android:text="@string/pref_landscape_zoom"
|
|
||||||
android:textColor="?android:attr/textColorSecondary" />
|
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
|
||||||
android:id="@+id/zoom_start"
|
android:id="@+id/zoom_start"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -69,6 +60,15 @@
|
|||||||
android:text="@string/pref_crop_borders"
|
android:text="@string/pref_crop_borders"
|
||||||
android:textColor="?android:attr/textColorSecondary" />
|
android:textColor="?android:attr/textColorSecondary" />
|
||||||
|
|
||||||
|
<com.google.android.material.materialswitch.MaterialSwitch
|
||||||
|
android:id="@+id/landscape_zoom"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingHorizontal="16dp"
|
||||||
|
android:paddingVertical="16dp"
|
||||||
|
android:text="@string/pref_landscape_zoom"
|
||||||
|
android:textColor="?android:attr/textColorSecondary" />
|
||||||
|
|
||||||
<com.google.android.material.materialswitch.MaterialSwitch
|
<com.google.android.material.materialswitch.MaterialSwitch
|
||||||
android:id="@+id/navigate_pan"
|
android:id="@+id/navigate_pan"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -408,7 +408,7 @@
|
|||||||
<string name="scale_type_original_size">Original size</string>
|
<string name="scale_type_original_size">Original size</string>
|
||||||
<string name="scale_type_smart_fit">Smart fit</string>
|
<string name="scale_type_smart_fit">Smart fit</string>
|
||||||
<string name="pref_navigate_pan">Pan wide images</string>
|
<string name="pref_navigate_pan">Pan wide images</string>
|
||||||
<string name="pref_landscape_zoom">Zoom landscape image</string>
|
<string name="pref_landscape_zoom">Automatically zoom into wide images</string>
|
||||||
<string name="pref_zoom_start">Zoom start position</string>
|
<string name="pref_zoom_start">Zoom start position</string>
|
||||||
<string name="zoom_start_automatic">Automatic</string>
|
<string name="zoom_start_automatic">Automatic</string>
|
||||||
<string name="zoom_start_left">Left</string>
|
<string name="zoom_start_left">Left</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user