parent
0deb6f6b8d
commit
90253f3bd4
@ -288,4 +288,20 @@ object PreferenceKeys {
|
||||
const val useNewSourceNavigation = "use_new_source_navigation"
|
||||
|
||||
const val mangaDexLowQualityCovers = "manga_dex_low_quality_covers"
|
||||
|
||||
const val experimentalFeatures = "experimental_features"
|
||||
|
||||
const val dataSaver = "data_saver"
|
||||
|
||||
const val ignoreJpeg = "ignore_jpeg"
|
||||
|
||||
const val ignoreGif = "ignore_gif"
|
||||
|
||||
const val dataSaverImageQuality = "data_saver_image_quality"
|
||||
|
||||
const val dataSaverImageFormatJpeg = "data_saver_image_format_jpeg"
|
||||
|
||||
const val dataSaverServer = "data_saver_server"
|
||||
|
||||
const val dataSaverColorBW = "data_saver_color_bw"
|
||||
}
|
||||
|
@ -393,4 +393,20 @@ class PreferencesHelper(val context: Context) {
|
||||
fun useNewSourceNavigation() = flowPrefs.getBoolean(Keys.useNewSourceNavigation, false)
|
||||
|
||||
fun mangaDexLowQualityCovers() = flowPrefs.getBoolean(Keys.mangaDexLowQualityCovers, false)
|
||||
|
||||
fun experimentalFeatures() = flowPrefs.getBoolean(Keys.experimentalFeatures, false)
|
||||
|
||||
fun dataSaver() = flowPrefs.getBoolean(Keys.dataSaver, false)
|
||||
|
||||
fun ignoreJpeg() = flowPrefs.getBoolean(Keys.ignoreJpeg, false)
|
||||
|
||||
fun ignoreGif() = flowPrefs.getBoolean(Keys.ignoreGif, true)
|
||||
|
||||
fun dataSaverImageQuality() = flowPrefs.getInt(Keys.dataSaverImageQuality, 80)
|
||||
|
||||
fun dataSaverImageFormatJpeg() = flowPrefs.getBoolean(Keys.dataSaverImageFormatJpeg, false)
|
||||
|
||||
fun dataSaverServer() = flowPrefs.getString(Keys.dataSaverServer, "")
|
||||
|
||||
fun dataSaverColorBW() = flowPrefs.getBoolean(Keys.dataSaverColorBW, false)
|
||||
}
|
||||
|
@ -2,16 +2,23 @@ package eu.kanade.tachiyomi.source.model
|
||||
|
||||
import android.net.Uri
|
||||
import eu.kanade.tachiyomi.network.ProgressListener
|
||||
import eu.kanade.tachiyomi.util.DataSaver
|
||||
import rx.subjects.Subject
|
||||
|
||||
open class Page(
|
||||
val index: Int,
|
||||
/* SY --> */
|
||||
var /* SY <-- */ url: String = "",
|
||||
var imageUrl: String? = null,
|
||||
imageUrl: String? = null,
|
||||
@Transient var uri: Uri? = null // Deprecated but can't be deleted due to extensions
|
||||
) : ProgressListener {
|
||||
|
||||
var imageUrl = imageUrl
|
||||
get() {
|
||||
if (field == null) return null
|
||||
return DataSaver().compress(field!!)
|
||||
}
|
||||
|
||||
val number: Int
|
||||
get() = index + 1
|
||||
|
||||
|
@ -195,6 +195,13 @@ class SettingsAdvancedController : SettingsController() {
|
||||
summary = context.getString(R.string.toggle_delegated_sources_summary, context.getString(R.string.app_name), DELEGATED_SOURCES.values.map { it.sourceName }.distinct().joinToString())
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
titleRes = R.string.toggle_experimental_features
|
||||
key = Keys.experimentalFeatures
|
||||
defaultValue = false
|
||||
summary = context.getString(R.string.toggle_experimental_features_summary)
|
||||
}
|
||||
|
||||
intListPreference {
|
||||
key = Keys.eh_logLevel
|
||||
titleRes = R.string.log_level
|
||||
|
@ -0,0 +1,70 @@
|
||||
package eu.kanade.tachiyomi.ui.setting
|
||||
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.editTextPreference
|
||||
import eu.kanade.tachiyomi.util.preference.intListPreference
|
||||
import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
||||
import eu.kanade.tachiyomi.util.preference.summaryRes
|
||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||
|
||||
class SettingsExperimentalFeatures : SettingsController() {
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
|
||||
titleRes = R.string.expermental_feature_sttings
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.data_saver
|
||||
summaryRes = R.string.data_saver_summary
|
||||
|
||||
switchPreference {
|
||||
titleRes = R.string.enable_data_saver
|
||||
key = Keys.dataSaver
|
||||
defaultValue = false
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
titleRes = R.string.ignore_jpeg
|
||||
key = Keys.ignoreJpeg
|
||||
defaultValue = false
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
titleRes = R.string.ignore_gif
|
||||
key = Keys.ignoreGif
|
||||
defaultValue = true
|
||||
}
|
||||
|
||||
intListPreference {
|
||||
titleRes = R.string.data_saver_image_quality
|
||||
key = Keys.dataSaverImageQuality
|
||||
entries = arrayOf("10", "20", "40", "50", "70", "80", "90", "95")
|
||||
entryValues = entries
|
||||
defaultValue = "80"
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
titleRes = R.string.data_saver_image_format
|
||||
key = Keys.dataSaverImageFormatJpeg
|
||||
defaultValue = false
|
||||
summaryRes = R.string.data_saver_image_format_summary
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
titleRes = R.string.data_saver_color_bw
|
||||
key = Keys.dataSaverColorBW
|
||||
defaultValue = false
|
||||
}
|
||||
|
||||
editTextPreference {
|
||||
titleRes = R.string.data_saver_server
|
||||
key = Keys.dataSaverServer
|
||||
defaultValue = ""
|
||||
summaryRes = R.string.data_saver_server_summary
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -80,6 +80,7 @@ class SettingsMainController : SettingsController() {
|
||||
onClick { navigateTo(SettingsEhController()) }
|
||||
}
|
||||
}
|
||||
|
||||
// SY <--
|
||||
preference {
|
||||
iconRes = R.drawable.ic_code_24dp
|
||||
@ -87,6 +88,15 @@ class SettingsMainController : SettingsController() {
|
||||
titleRes = R.string.pref_category_advanced
|
||||
onClick { navigateTo(SettingsAdvancedController()) }
|
||||
}
|
||||
|
||||
if (preferences.experimentalFeatures().get()) {
|
||||
preference {
|
||||
iconRes = R.drawable.ic_code_24dp
|
||||
iconTint = tintColor
|
||||
titleRes = R.string.expermental_feature_sttings
|
||||
onClick { navigateTo(SettingsExperimentalFeatures()) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun navigateTo(controller: SettingsController) {
|
||||
|
34
app/src/main/java/eu/kanade/tachiyomi/util/DataSaver.kt
Normal file
34
app/src/main/java/eu/kanade/tachiyomi/util/DataSaver.kt
Normal file
@ -0,0 +1,34 @@
|
||||
package eu.kanade.tachiyomi.util
|
||||
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class DataSaver() {
|
||||
|
||||
private val prefs: PreferencesHelper by injectLazy()
|
||||
|
||||
fun compress(imageUrl: String): String {
|
||||
val server = prefs.dataSaverServer().get() + "/?"
|
||||
val format = "jpeg=${if (prefs.dataSaverImageFormatJpeg().get()) "1" else "0"}"
|
||||
val quality = "&l=${prefs.dataSaverImageQuality().get()}"
|
||||
val colorBW = "&bw=${if (prefs.dataSaverColorBW().get()) "1" else "0"}"
|
||||
val url = "$server$format$quality$colorBW&url="
|
||||
val ignoreJpeg: Boolean = prefs.ignoreJpeg().get()
|
||||
val ignoreGif: Boolean = prefs.ignoreGif().get()
|
||||
val dataSaverStatus: Boolean = prefs.dataSaver().get()
|
||||
var process = false
|
||||
var processedUrl = imageUrl
|
||||
|
||||
if (dataSaverStatus) process = true
|
||||
if (imageUrl.contains(server)) process = false
|
||||
if (ignoreJpeg) {
|
||||
if (imageUrl.contains(".jpeg", true) || imageUrl.contains(".jpg", true)) process = false
|
||||
}
|
||||
if (ignoreGif) {
|
||||
if (imageUrl.contains(".gif", true)) process = false
|
||||
}
|
||||
if (process) processedUrl = url + imageUrl
|
||||
|
||||
return processedUrl
|
||||
}
|
||||
}
|
@ -32,6 +32,8 @@
|
||||
<string name="pref_category_all_sources">All Sources</string>
|
||||
<string name="pref_category_eh">E-Hentai</string>
|
||||
<string name="pref_category_fork">Fork Settings</string>
|
||||
<string name="expermental_feature_sttings">Experimental Features</string>
|
||||
|
||||
|
||||
<!-- EH Settings -->
|
||||
<string name="ehentai_prefs_account_settings">E-Hentai Website Account Settings</string>
|
||||
@ -119,6 +121,8 @@
|
||||
<string name="toggle_hentai_features_summary">This is a experimental feature that will disable all hentai features if toggled off</string>
|
||||
<string name="toggle_delegated_sources">Enable delegated sources</string>
|
||||
<string name="toggle_delegated_sources_summary">Apply %1$s enhancements to the following sources if they are installed: %2$s</string>
|
||||
<string name="toggle_experimental_features">Show Experimental Features</string>
|
||||
<string name="toggle_experimental_features_summary">Show features that are experimental and not for normal users</string>
|
||||
<string name="log_level">Log level</string>
|
||||
<string name="log_level_summary">Changing this can impact app performance. Force-restart app after changing. Current value: %s</string>
|
||||
<string name="enable_source_blacklist">Enable source blacklist</string>
|
||||
@ -465,5 +469,18 @@
|
||||
<item quantity="other">%2$s, %1$d pages</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Experimental Features -->
|
||||
<string name="data_saver">Data Saver</string>
|
||||
<string name="data_saver_summary">Compress images before downloading or loading in reader</string>
|
||||
<string name="enable_data_saver">Enable Data Saver</string>
|
||||
<string name="ignore_jpeg">Ignore Jpeg Images</string>
|
||||
<string name="ignore_gif">Ignore Gif Animation</string>
|
||||
<string name="data_saver_image_quality">Image Quality</string>
|
||||
<string name="data_saver_image_format">Compress to Jpeg</string>
|
||||
<string name="data_saver_color_bw">Convert to Black And White</string>
|
||||
<string name="data_saver_image_format_summary">Compresses to webp if this option is turned off</string>
|
||||
<string name="data_saver_server">Data Saver Server</string>
|
||||
<string name="data_saver_server_summary">It uses Bandwidth Hero Proxy as Server.To use it you need to create a Bandwidth Hero server and give the server URL</string>
|
||||
|
||||
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user