Minor cleanup

(cherry picked from commit 42bc2b07ce1f0b4cfbfe3045cddc9c1fcca8f519)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/data/cache/ChapterCache.kt
This commit is contained in:
arkon 2023-06-23 22:39:59 -04:00 committed by Jobobby04
parent 843febd0ff
commit 43a920bbb9
4 changed files with 28 additions and 30 deletions

View File

@ -223,11 +223,6 @@ object SettingsReaderScreen : SearchableSettings {
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(
pref = readerPreferences.zoomStart(),
title = stringResource(R.string.pref_zoom_start),
@ -249,6 +244,11 @@ object SettingsReaderScreen : SearchableSettings {
title = stringResource(R.string.pref_page_transitions),
),
// SY <--
Preference.PreferenceItem.SwitchPreference(
pref = readerPreferences.landscapeZoom(),
title = stringResource(R.string.pref_landscape_zoom),
enabled = imageScaleType == 1,
),
Preference.PreferenceItem.SwitchPreference(
pref = readerPreferences.navigateToPan(),
title = stringResource(R.string.pref_navigate_pan),

View File

@ -10,6 +10,7 @@ import eu.kanade.tachiyomi.util.storage.saveTo
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.serialization.decodeFromString
@ -30,21 +31,9 @@ import java.io.IOException
* The files are in format *md5key*.0
*
* @param context the application context.
* @constructor creates an instance of the chapter cache.
*/
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)
/** Google Json class used for parsing JSON files. */
@ -58,6 +47,7 @@ class ChapterCache(private val context: Context) {
init {
readerPreferences.cacheSize().changes()
.drop(1)
.onEach {
// Save old cache for destruction later
val oldCache = diskCache
@ -71,8 +61,7 @@ class ChapterCache(private val context: Context) {
/**
* Returns directory of cache.
*/
private val cacheDir: File
get() = diskCache.directory
private val cacheDir: File = diskCache.directory
/**
* Returns real size of directory.
@ -90,7 +79,7 @@ class ChapterCache(private val context: Context) {
// Cache size is in MB
private fun setupDiskCache(cacheSize: Long): DiskLruCache {
return DiskLruCache.open(
File(context.cacheDir, PARAMETER_CACHE_DIRECTORY),
File(context.cacheDir, "chapter_disk_cache"),
PARAMETER_APP_VERSION,
PARAMETER_VALUE_COUNT,
cacheSize * 1024 * 1024,
@ -238,3 +227,12 @@ class ChapterCache(private val context: Context) {
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

View File

@ -37,15 +37,6 @@
android:entries="@array/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
android:id="@+id/zoom_start"
android:layout_width="match_parent"
@ -69,6 +60,15 @@
android:text="@string/pref_crop_borders"
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
android:id="@+id/navigate_pan"
android:layout_width="match_parent"

View File

@ -408,7 +408,7 @@
<string name="scale_type_original_size">Original size</string>
<string name="scale_type_smart_fit">Smart fit</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="zoom_start_automatic">Automatic</string>
<string name="zoom_start_left">Left</string>