Remove preferences keys from resources
This commit is contained in:
@@ -20,5 +20,5 @@ abstract class RemoteMangaRepository(protected val loaderContext: MangaLoaderCon
|
||||
|
||||
override suspend fun getTags(): Set<MangaTag> = emptySet()
|
||||
|
||||
abstract fun onCreatePreferences(): Set<Int>
|
||||
abstract fun onCreatePreferences(): Set<String>
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.koitharu.kotatsu.core.parser.site
|
||||
|
||||
import androidx.collection.arraySetOf
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.exceptions.ParseException
|
||||
import org.koitharu.kotatsu.core.model.*
|
||||
import org.koitharu.kotatsu.core.parser.RemoteMangaRepository
|
||||
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
||||
import org.koitharu.kotatsu.domain.MangaLoaderContext
|
||||
import org.koitharu.kotatsu.utils.ext.*
|
||||
|
||||
@@ -133,7 +133,7 @@ abstract class ChanRepository(loaderContext: MangaLoaderContext) : RemoteMangaRe
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreatePreferences() = arraySetOf(R.string.key_parser_domain)
|
||||
override fun onCreatePreferences() = arraySetOf(SourceSettings.KEY_DOMAIN)
|
||||
|
||||
private fun getSortKey(sortOrder: SortOrder?) =
|
||||
when (sortOrder ?: sortOrders.minByOrNull { it.ordinal }) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.koitharu.kotatsu.core.parser.site
|
||||
|
||||
import androidx.collection.arraySetOf
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.exceptions.ParseException
|
||||
import org.koitharu.kotatsu.core.model.*
|
||||
import org.koitharu.kotatsu.core.parser.RemoteMangaRepository
|
||||
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
||||
import org.koitharu.kotatsu.domain.MangaLoaderContext
|
||||
import org.koitharu.kotatsu.utils.ext.*
|
||||
|
||||
@@ -120,7 +120,7 @@ class DesuMeRepository(loaderContext: MangaLoaderContext) : RemoteMangaRepositor
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreatePreferences() = arraySetOf(R.string.key_parser_domain)
|
||||
override fun onCreatePreferences() = arraySetOf(SourceSettings.KEY_DOMAIN)
|
||||
|
||||
private fun getSortKey(sortOrder: SortOrder?) =
|
||||
when (sortOrder) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.koitharu.kotatsu.core.parser.site
|
||||
|
||||
import androidx.collection.arraySetOf
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.exceptions.ParseException
|
||||
import org.koitharu.kotatsu.core.model.*
|
||||
import org.koitharu.kotatsu.core.parser.RemoteMangaRepository
|
||||
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
||||
import org.koitharu.kotatsu.domain.MangaLoaderContext
|
||||
import org.koitharu.kotatsu.utils.ext.*
|
||||
|
||||
@@ -167,7 +167,7 @@ abstract class GroupleRepository(loaderContext: MangaLoaderContext) :
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreatePreferences() = arraySetOf(R.string.key_parser_domain)
|
||||
override fun onCreatePreferences() = arraySetOf(SourceSettings.KEY_DOMAIN)
|
||||
|
||||
private fun getSortKey(sortOrder: SortOrder?) =
|
||||
when (sortOrder ?: sortOrders.minByOrNull { it.ordinal }) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.exceptions.ParseException
|
||||
import org.koitharu.kotatsu.core.model.*
|
||||
import org.koitharu.kotatsu.core.parser.RemoteMangaRepository
|
||||
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
||||
import org.koitharu.kotatsu.domain.MangaLoaderContext
|
||||
import org.koitharu.kotatsu.utils.ext.*
|
||||
|
||||
@@ -70,7 +71,7 @@ open class MangaLibRepository(loaderContext: MangaLoaderContext) :
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreatePreferences() = arraySetOf(R.string.key_parser_domain)
|
||||
override fun onCreatePreferences() = arraySetOf(SourceSettings.KEY_DOMAIN)
|
||||
|
||||
override suspend fun getDetails(manga: Manga): Manga {
|
||||
val doc = loaderContext.httpGet(manga.url + "?section=info").parseHtml()
|
||||
|
||||
@@ -2,10 +2,10 @@ package org.koitharu.kotatsu.core.parser.site
|
||||
|
||||
import androidx.collection.arraySetOf
|
||||
import org.intellij.lang.annotations.Language
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.exceptions.ParseException
|
||||
import org.koitharu.kotatsu.core.model.*
|
||||
import org.koitharu.kotatsu.core.parser.RemoteMangaRepository
|
||||
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
||||
import org.koitharu.kotatsu.domain.MangaLoaderContext
|
||||
import org.koitharu.kotatsu.utils.ext.*
|
||||
import java.util.*
|
||||
@@ -168,8 +168,10 @@ class MangaTownRepository(loaderContext: MangaLoaderContext) :
|
||||
}
|
||||
|
||||
|
||||
override fun onCreatePreferences() =
|
||||
arraySetOf(R.string.key_parser_domain, R.string.key_parser_ssl)
|
||||
override fun onCreatePreferences() = arraySetOf(
|
||||
SourceSettings.KEY_DOMAIN,
|
||||
SourceSettings.KEY_USE_SSL
|
||||
)
|
||||
|
||||
private fun String.parseTagKey() = split('/').findLast { TAG_REGEX matches it }
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.koitharu.kotatsu.core.parser.site
|
||||
|
||||
import androidx.collection.arraySetOf
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.exceptions.ParseException
|
||||
import org.koitharu.kotatsu.core.model.*
|
||||
import org.koitharu.kotatsu.core.parser.RemoteMangaRepository
|
||||
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
||||
import org.koitharu.kotatsu.domain.MangaLoaderContext
|
||||
import org.koitharu.kotatsu.utils.ext.*
|
||||
|
||||
@@ -147,7 +147,7 @@ class MangareadRepository(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreatePreferences() = arraySetOf(R.string.key_parser_domain)
|
||||
override fun onCreatePreferences() = arraySetOf(SourceSettings.KEY_DOMAIN)
|
||||
|
||||
private companion object {
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.koitharu.kotatsu.core.parser.site
|
||||
|
||||
import androidx.collection.arraySetOf
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.exceptions.ParseException
|
||||
import org.koitharu.kotatsu.core.model.*
|
||||
import org.koitharu.kotatsu.core.parser.RemoteMangaRepository
|
||||
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
||||
import org.koitharu.kotatsu.domain.MangaLoaderContext
|
||||
import org.koitharu.kotatsu.utils.ext.*
|
||||
import java.util.regex.Pattern
|
||||
@@ -134,7 +134,7 @@ class NudeMoonRepository(loaderContext: MangaLoaderContext) : RemoteMangaReposit
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreatePreferences() = arraySetOf(R.string.key_parser_domain)
|
||||
override fun onCreatePreferences() = arraySetOf(SourceSettings.KEY_DOMAIN)
|
||||
|
||||
private fun getSortKey(sortOrder: SortOrder?) =
|
||||
when (sortOrder ?: sortOrders.minByOrNull { it.ordinal }) {
|
||||
|
||||
@@ -2,109 +2,78 @@ package org.koitharu.kotatsu.core.prefs
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.content.res.Resources
|
||||
import android.provider.Settings
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.collection.arraySetOf
|
||||
import androidx.core.content.edit
|
||||
import androidx.preference.PreferenceManager
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.parser.LocalMangaRepository
|
||||
import org.koitharu.kotatsu.utils.delegates.prefs.*
|
||||
import java.io.File
|
||||
|
||||
class AppSettings private constructor(resources: Resources, private val prefs: SharedPreferences) :
|
||||
class AppSettings private constructor(private val prefs: SharedPreferences) :
|
||||
SharedPreferences by prefs {
|
||||
|
||||
constructor(context: Context) : this(
|
||||
context.resources,
|
||||
PreferenceManager.getDefaultSharedPreferences(context)
|
||||
)
|
||||
|
||||
var listMode by EnumPreferenceDelegate(
|
||||
ListMode::class.java,
|
||||
resources.getString(R.string.key_list_mode),
|
||||
KEY_LIST_MODE,
|
||||
ListMode.DETAILED_LIST
|
||||
)
|
||||
|
||||
var defaultSection by EnumPreferenceDelegate(
|
||||
AppSection::class.java,
|
||||
resources.getString(R.string.key_app_section),
|
||||
KEY_APP_SECTION,
|
||||
AppSection.HISTORY
|
||||
)
|
||||
|
||||
val theme by StringIntPreferenceDelegate(
|
||||
resources.getString(R.string.key_theme),
|
||||
KEY_THEME,
|
||||
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||
)
|
||||
|
||||
val gridSize by IntPreferenceDelegate(
|
||||
resources.getString(R.string.key_grid_size),
|
||||
100
|
||||
)
|
||||
val gridSize by IntPreferenceDelegate(KEY_GRID_SIZE, defaultValue = 100)
|
||||
|
||||
val readerPageSwitch by StringSetPreferenceDelegate(
|
||||
resources.getString(R.string.key_reader_switchers),
|
||||
KEY_READER_SWITCHERS,
|
||||
arraySetOf(PAGE_SWITCH_TAPS)
|
||||
)
|
||||
|
||||
var isTrafficWarningEnabled by BoolPreferenceDelegate(
|
||||
resources.getString(R.string.key_traffic_warning),
|
||||
true
|
||||
)
|
||||
var isTrafficWarningEnabled by BoolPreferenceDelegate(KEY_TRAFFIC_WARNING, defaultValue = true)
|
||||
|
||||
val appUpdateAuto by BoolPreferenceDelegate(
|
||||
resources.getString(R.string.key_app_update_auto),
|
||||
true
|
||||
)
|
||||
val appUpdateAuto by BoolPreferenceDelegate(KEY_APP_UPDATE_AUTO, defaultValue = true)
|
||||
|
||||
var appUpdate by LongPreferenceDelegate(
|
||||
resources.getString(R.string.key_app_update),
|
||||
0L
|
||||
)
|
||||
var appUpdate by LongPreferenceDelegate(KEY_APP_UPDATE, defaultValue = 0L)
|
||||
|
||||
val trackerNotifications by BoolPreferenceDelegate(
|
||||
resources.getString(R.string.key_tracker_notifications),
|
||||
true
|
||||
KEY_TRACKER_NOTIFICATIONS,
|
||||
defaultValue = true
|
||||
)
|
||||
|
||||
var notificationSound by StringPreferenceDelegate(
|
||||
resources.getString(R.string.key_notifications_sound),
|
||||
KEY_NOTIFICATIONS_SOUND,
|
||||
Settings.System.DEFAULT_NOTIFICATION_URI.toString()
|
||||
)
|
||||
|
||||
val notificationVibrate by BoolPreferenceDelegate(
|
||||
resources.getString(R.string.key_notifications_vibrate),
|
||||
false
|
||||
)
|
||||
val notificationVibrate by BoolPreferenceDelegate(KEY_NOTIFICATIONS_VIBRATE, false)
|
||||
|
||||
val notificationLight by BoolPreferenceDelegate(
|
||||
resources.getString(R.string.key_notifications_light),
|
||||
true
|
||||
)
|
||||
val notificationLight by BoolPreferenceDelegate(KEY_NOTIFICATIONS_LIGHT, true)
|
||||
|
||||
val readerAnimation by BoolPreferenceDelegate(
|
||||
resources.getString(R.string.key_reader_animation),
|
||||
false
|
||||
)
|
||||
val readerAnimation by BoolPreferenceDelegate(KEY_READER_ANIMATION, false)
|
||||
|
||||
val isPreferRtlReader by BoolPreferenceDelegate(
|
||||
resources.getString(R.string.key_reader_prefer_rtl),
|
||||
false
|
||||
)
|
||||
val isPreferRtlReader by BoolPreferenceDelegate(KEY_READER_PREFER_RTL, false)
|
||||
|
||||
val trackSources by StringSetPreferenceDelegate(
|
||||
resources.getString(R.string.key_track_sources),
|
||||
KEY_TRACK_SOURCES,
|
||||
arraySetOf(TRACK_FAVOURITES, TRACK_HISTORY)
|
||||
)
|
||||
|
||||
var appPassword by NullableStringPreferenceDelegate(
|
||||
resources.getString(R.string.key_app_password)
|
||||
)
|
||||
var appPassword by NullableStringPreferenceDelegate(KEY_APP_PASSWORD)
|
||||
|
||||
private var sourcesOrderStr by NullableStringPreferenceDelegate(
|
||||
resources.getString(R.string.key_sources_order)
|
||||
)
|
||||
private var sourcesOrderStr by NullableStringPreferenceDelegate(KEY_SOURCES_ORDER)
|
||||
|
||||
var sourcesOrder: List<Int>
|
||||
get() = sourcesOrderStr?.split('|')?.mapNotNull(String::toIntOrNull).orEmpty()
|
||||
@@ -112,22 +81,21 @@ class AppSettings private constructor(resources: Resources, private val prefs: S
|
||||
sourcesOrderStr = value.joinToString("|")
|
||||
}
|
||||
|
||||
var hiddenSources by StringSetPreferenceDelegate(resources.getString(R.string.key_sources_hidden))
|
||||
var hiddenSources by StringSetPreferenceDelegate(KEY_SOURCES_HIDDEN)
|
||||
|
||||
fun getStorageDir(context: Context): File? {
|
||||
val value = prefs.getString(context.getString(R.string.key_local_storage), null)?.let {
|
||||
val value = prefs.getString(KEY_LOCAL_STORAGE, null)?.let {
|
||||
File(it)
|
||||
}?.takeIf { it.exists() && it.canWrite() }
|
||||
return value ?: LocalMangaRepository.getFallbackStorageDir(context)
|
||||
}
|
||||
|
||||
fun setStorageDir(context: Context, file: File?) {
|
||||
val key = context.getString(R.string.key_local_storage)
|
||||
prefs.edit {
|
||||
if (file == null) {
|
||||
remove(key)
|
||||
remove(KEY_LOCAL_STORAGE)
|
||||
} else {
|
||||
putString(key, file.path)
|
||||
putString(KEY_LOCAL_STORAGE, file.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,5 +115,33 @@ class AppSettings private constructor(resources: Resources, private val prefs: S
|
||||
|
||||
const val TRACK_HISTORY = "history"
|
||||
const val TRACK_FAVOURITES = "favourites"
|
||||
|
||||
const val KEY_LIST_MODE = "list_mode"
|
||||
const val KEY_APP_SECTION = "app_section"
|
||||
const val KEY_THEME = "theme"
|
||||
const val KEY_SOURCES_ORDER = "sources_order"
|
||||
const val KEY_SOURCES_HIDDEN = "sources_hidden"
|
||||
const val KEY_TRAFFIC_WARNING = "traffic_warning"
|
||||
const val KEY_PAGES_CACHE_CLEAR = "pages_cache_clear"
|
||||
const val KEY_THUMBS_CACHE_CLEAR = "thumbs_cache_clear"
|
||||
const val KEY_SEARCH_HISTORY_CLEAR = "search_history_clear"
|
||||
const val KEY_UPDATES_FEED_CLEAR = "updates_feed_clear"
|
||||
const val KEY_GRID_SIZE = "grid_size"
|
||||
const val KEY_REMOTE_SOURCES = "remote_sources"
|
||||
const val KEY_LOCAL_STORAGE = "local_storage"
|
||||
const val KEY_READER_SWITCHERS = "reader_switchers"
|
||||
const val KEY_TRACK_SOURCES = "track_sources"
|
||||
const val KEY_APP_UPDATE = "app_update"
|
||||
const val KEY_APP_UPDATE_AUTO = "app_update_auto"
|
||||
const val KEY_TRACKER_NOTIFICATIONS = "tracker_notifications"
|
||||
const val KEY_NOTIFICATIONS_SETTINGS = "notifications_settings"
|
||||
const val KEY_NOTIFICATIONS_SOUND = "notifications_sound"
|
||||
const val KEY_NOTIFICATIONS_VIBRATE = "notifications_vibrate"
|
||||
const val KEY_NOTIFICATIONS_LIGHT = "notifications_light"
|
||||
const val KEY_READER_ANIMATION = "reader_animation"
|
||||
const val KEY_READER_PREFER_RTL = "reader_prefer_rtl"
|
||||
const val KEY_APP_PASSWORD = "app_password"
|
||||
const val KEY_PROTECT_APP = "protect_app"
|
||||
const val KEY_APP_VERSION = "app_version"
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,32 @@
|
||||
package org.koitharu.kotatsu.core.prefs
|
||||
|
||||
import android.content.Context
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.model.MangaSource
|
||||
|
||||
interface SourceConfig {
|
||||
interface SourceSettings {
|
||||
|
||||
fun getDomain(defaultValue: String): String
|
||||
|
||||
fun isUseSsl(defaultValue: Boolean): Boolean
|
||||
|
||||
private class PrefSourceConfig(context: Context, source: MangaSource) : SourceConfig {
|
||||
private class PrefSourceSettings(context: Context, source: MangaSource) : SourceSettings {
|
||||
|
||||
private val prefs = context.getSharedPreferences(source.name, Context.MODE_PRIVATE)
|
||||
|
||||
private val keyDomain = context.getString(R.string.key_parser_domain)
|
||||
private val keySsl = context.getString(R.string.key_parser_ssl)
|
||||
|
||||
override fun getDomain(defaultValue: String) = prefs.getString(keyDomain, defaultValue)
|
||||
override fun getDomain(defaultValue: String) = prefs.getString(KEY_DOMAIN, defaultValue)
|
||||
?.takeUnless(String::isBlank)
|
||||
?: defaultValue
|
||||
|
||||
override fun isUseSsl(defaultValue: Boolean) = prefs.getBoolean(keySsl, defaultValue)
|
||||
override fun isUseSsl(defaultValue: Boolean) = prefs.getBoolean(KEY_USE_SSL, defaultValue)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@JvmStatic
|
||||
operator fun invoke(context: Context, source: MangaSource): SourceConfig =
|
||||
PrefSourceConfig(context, source)
|
||||
operator fun invoke(context: Context, source: MangaSource): SourceSettings =
|
||||
PrefSourceSettings(context, source)
|
||||
|
||||
const val KEY_DOMAIN = "domain"
|
||||
const val KEY_USE_SSL = "ssl"
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.get
|
||||
import org.koin.core.component.inject
|
||||
import org.koitharu.kotatsu.core.model.MangaSource
|
||||
import org.koitharu.kotatsu.core.prefs.SourceConfig
|
||||
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
||||
import org.koitharu.kotatsu.utils.ext.await
|
||||
|
||||
open class MangaLoaderContext : KoinComponent {
|
||||
@@ -64,7 +64,7 @@ open class MangaLoaderContext : KoinComponent {
|
||||
return okHttp.newCall(request.build()).await()
|
||||
}
|
||||
|
||||
open fun getSettings(source: MangaSource) = SourceConfig(get(), source)
|
||||
open fun getSettings(source: MangaSource) = SourceSettings(get(), source)
|
||||
|
||||
fun insertCookies(domain: String, vararg cookies: String) {
|
||||
val url = HttpUrl.Builder()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.koitharu.kotatsu.ui.base
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import org.koin.android.ext.android.inject
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
@@ -15,8 +14,4 @@ abstract class BasePreferenceFragment(@StringRes private val titleId: Int) :
|
||||
super.onResume()
|
||||
activity?.setTitle(titleId)
|
||||
}
|
||||
|
||||
fun <T : Preference> findPreference(@StringRes keyId: Int): T? =
|
||||
findPreference(getString(keyId))
|
||||
|
||||
}
|
||||
@@ -197,8 +197,8 @@ class MainActivity : BaseActivity(), NavigationView.OnNavigationItemSelectedList
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
when (key) {
|
||||
getString(R.string.key_sources_hidden),
|
||||
getString(R.string.key_sources_order) -> {
|
||||
AppSettings.KEY_SOURCES_HIDDEN,
|
||||
AppSettings.KEY_SOURCES_ORDER -> {
|
||||
initSideMenu(MangaProviderFactory.getSources(includeHidden = false))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,8 +203,8 @@ abstract class MangaListFragment<E> : BaseFragment(R.layout.fragment_list),
|
||||
return
|
||||
}
|
||||
when (key) {
|
||||
getString(R.string.key_list_mode) -> initListMode(settings.listMode)
|
||||
getString(R.string.key_grid_size) -> UiUtils.SpanCountResolver.update(recyclerView)
|
||||
AppSettings.KEY_LIST_MODE -> initListMode(settings.listMode)
|
||||
AppSettings.KEY_GRID_SIZE -> UiUtils.SpanCountResolver.update(recyclerView)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,8 +116,8 @@ abstract class MangaListSheet<E> : BaseBottomSheet(R.layout.sheet_list),
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
when (key) {
|
||||
getString(R.string.key_list_mode) -> initListMode(settings.listMode)
|
||||
getString(R.string.key_grid_size) -> UiUtils.SpanCountResolver.update(recyclerView)
|
||||
AppSettings.KEY_LIST_MODE -> initListMode(settings.listMode)
|
||||
AppSettings.KEY_GRID_SIZE -> UiUtils.SpanCountResolver.update(recyclerView)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class ReversedReaderFragment : AbstractReader(R.layout.fragment_reader_standard)
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
when (key) {
|
||||
getString(R.string.key_reader_animation) -> {
|
||||
AppSettings.KEY_READER_ANIMATION -> {
|
||||
if (settings.readerAnimation) {
|
||||
pager.setPageTransformer(PageAnimTransformer())
|
||||
} else {
|
||||
|
||||
@@ -64,7 +64,7 @@ class PagerReaderFragment : AbstractReader(R.layout.fragment_reader_standard),
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
when (key) {
|
||||
getString(R.string.key_reader_animation) -> {
|
||||
AppSettings.KEY_READER_ANIMATION -> {
|
||||
if (settings.readerAnimation) {
|
||||
pager.setPageTransformer(PageAnimTransformer())
|
||||
} else {
|
||||
|
||||
@@ -9,6 +9,7 @@ import kotlinx.coroutines.withContext
|
||||
import org.koin.android.ext.android.inject
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.local.Cache
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.domain.tracking.TrackingRepository
|
||||
import org.koitharu.kotatsu.ui.base.BasePreferenceFragment
|
||||
import org.koitharu.kotatsu.ui.search.MangaSuggestionsProvider
|
||||
@@ -23,7 +24,7 @@ class HistorySettingsFragment : BasePreferenceFragment(R.string.history_and_cach
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
addPreferencesFromResource(R.xml.pref_history)
|
||||
findPreference<Preference>(R.string.key_pages_cache_clear)?.let { pref ->
|
||||
findPreference<Preference>(AppSettings.KEY_PAGES_CACHE_CLEAR)?.let { pref ->
|
||||
viewLifecycleScope.launchWhenResumed {
|
||||
val size = withContext(Dispatchers.IO) {
|
||||
CacheUtils.computeCacheSize(pref.context, Cache.PAGES.dir)
|
||||
@@ -31,7 +32,7 @@ class HistorySettingsFragment : BasePreferenceFragment(R.string.history_and_cach
|
||||
pref.summary = FileSizeUtils.formatBytes(pref.context, size)
|
||||
}
|
||||
}
|
||||
findPreference<Preference>(R.string.key_thumbs_cache_clear)?.let { pref ->
|
||||
findPreference<Preference>(AppSettings.KEY_THUMBS_CACHE_CLEAR)?.let { pref ->
|
||||
viewLifecycleScope.launchWhenResumed {
|
||||
val size = withContext(Dispatchers.IO) {
|
||||
CacheUtils.computeCacheSize(pref.context, Cache.THUMBS.dir)
|
||||
@@ -39,11 +40,11 @@ class HistorySettingsFragment : BasePreferenceFragment(R.string.history_and_cach
|
||||
pref.summary = FileSizeUtils.formatBytes(pref.context, size)
|
||||
}
|
||||
}
|
||||
findPreference<Preference>(R.string.key_search_history_clear)?.let { p ->
|
||||
findPreference<Preference>(AppSettings.KEY_SEARCH_HISTORY_CLEAR)?.let { p ->
|
||||
val items = MangaSuggestionsProvider.getItemsCount(p.context)
|
||||
p.summary = p.context.resources.getQuantityString(R.plurals.items, items, items)
|
||||
}
|
||||
findPreference<Preference>(R.string.key_updates_feed_clear)?.let { p ->
|
||||
findPreference<Preference>(AppSettings.KEY_UPDATES_FEED_CLEAR)?.let { p ->
|
||||
viewLifecycleScope.launchWhenResumed {
|
||||
val items = trackerRepo.count()
|
||||
p.summary = p.context.resources.getQuantityString(R.plurals.items, items, items)
|
||||
@@ -53,15 +54,15 @@ class HistorySettingsFragment : BasePreferenceFragment(R.string.history_and_cach
|
||||
|
||||
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||
return when (preference.key) {
|
||||
getString(R.string.key_pages_cache_clear) -> {
|
||||
AppSettings.KEY_PAGES_CACHE_CLEAR -> {
|
||||
clearCache(preference, Cache.PAGES)
|
||||
true
|
||||
}
|
||||
getString(R.string.key_thumbs_cache_clear) -> {
|
||||
AppSettings.KEY_THUMBS_CACHE_CLEAR -> {
|
||||
clearCache(preference, Cache.THUMBS)
|
||||
true
|
||||
}
|
||||
getString(R.string.key_search_history_clear) -> {
|
||||
AppSettings.KEY_SEARCH_HISTORY_CLEAR -> {
|
||||
MangaSuggestionsProvider.clearHistory(preference.context)
|
||||
preference.summary = preference.context.resources
|
||||
.getQuantityString(R.plurals.items, 0, 0)
|
||||
@@ -72,7 +73,7 @@ class HistorySettingsFragment : BasePreferenceFragment(R.string.history_and_cach
|
||||
).show()
|
||||
true
|
||||
}
|
||||
getString(R.string.key_updates_feed_clear) -> {
|
||||
AppSettings.KEY_UPDATES_FEED_CLEAR -> {
|
||||
viewLifecycleScope.launch {
|
||||
trackerRepo.clearLogs()
|
||||
preference.summary = preference.context.resources
|
||||
|
||||
@@ -16,6 +16,7 @@ import kotlinx.coroutines.launch
|
||||
import org.koitharu.kotatsu.BuildConfig
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.model.MangaSource
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.core.prefs.ListMode
|
||||
import org.koitharu.kotatsu.ui.base.BasePreferenceFragment
|
||||
import org.koitharu.kotatsu.ui.base.dialog.StorageSelectDialog
|
||||
@@ -35,29 +36,29 @@ class MainSettingsFragment : BasePreferenceFragment(R.string.settings),
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
addPreferencesFromResource(R.xml.pref_main)
|
||||
findPreference<Preference>(R.string.key_list_mode)?.summary =
|
||||
findPreference<Preference>(AppSettings.KEY_LIST_MODE)?.summary =
|
||||
LIST_MODES[settings.listMode]?.let(::getString)
|
||||
findPreference<SeekBarPreference>(R.string.key_grid_size)?.run {
|
||||
findPreference<SeekBarPreference>(AppSettings.KEY_GRID_SIZE)?.run {
|
||||
summary = "%d%%".format(value)
|
||||
setOnPreferenceChangeListener { preference, newValue ->
|
||||
preference.summary = "%d%%".format(newValue)
|
||||
true
|
||||
}
|
||||
}
|
||||
findPreference<MultiSelectListPreference>(R.string.key_reader_switchers)?.summaryProvider =
|
||||
findPreference<MultiSelectListPreference>(AppSettings.KEY_READER_SWITCHERS)?.summaryProvider =
|
||||
MultiSummaryProvider(R.string.gestures_only)
|
||||
findPreference<MultiSelectListPreference>(R.string.key_track_sources)?.summaryProvider =
|
||||
findPreference<MultiSelectListPreference>(AppSettings.KEY_TRACK_SOURCES)?.summaryProvider =
|
||||
MultiSummaryProvider(R.string.dont_check)
|
||||
findPreference<Preference>(R.string.key_app_update_auto)?.run {
|
||||
findPreference<Preference>(AppSettings.KEY_APP_UPDATE_AUTO)?.run {
|
||||
isVisible = AppUpdateChecker.isUpdateSupported(context)
|
||||
}
|
||||
findPreference<Preference>(R.string.key_local_storage)?.run {
|
||||
findPreference<Preference>(AppSettings.KEY_LOCAL_STORAGE)?.run {
|
||||
summary = settings.getStorageDir(context)?.getStorageName(context)
|
||||
?: getString(R.string.not_available)
|
||||
}
|
||||
findPreference<SwitchPreference>(R.string.key_protect_app)?.isChecked =
|
||||
findPreference<SwitchPreference>(AppSettings.KEY_PROTECT_APP)?.isChecked =
|
||||
!settings.appPassword.isNullOrEmpty()
|
||||
findPreference<Preference>(R.string.key_app_version)?.run {
|
||||
findPreference<Preference>(AppSettings.KEY_APP_VERSION)?.run {
|
||||
title = getString(R.string.app_version, BuildConfig.VERSION_NAME)
|
||||
isEnabled = AppUpdateChecker.isUpdateSupported(context)
|
||||
}
|
||||
@@ -65,13 +66,13 @@ class MainSettingsFragment : BasePreferenceFragment(R.string.settings),
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String?) {
|
||||
when (key) {
|
||||
getString(R.string.key_list_mode) -> findPreference<Preference>(R.string.key_list_mode)?.summary =
|
||||
AppSettings.KEY_LIST_MODE -> findPreference<Preference>(key)?.summary =
|
||||
LIST_MODES[settings.listMode]?.let(::getString)
|
||||
getString(R.string.key_theme) -> {
|
||||
AppSettings.KEY_THEME -> {
|
||||
AppCompatDelegate.setDefaultNightMode(settings.theme)
|
||||
}
|
||||
getString(R.string.key_local_storage) -> {
|
||||
findPreference<Preference>(R.string.key_local_storage)?.run {
|
||||
AppSettings.KEY_LOCAL_STORAGE -> {
|
||||
findPreference<Preference>(key)?.run {
|
||||
summary = settings.getStorageDir(context)?.getStorageName(context)
|
||||
?: getString(R.string.not_available)
|
||||
}
|
||||
@@ -91,7 +92,7 @@ class MainSettingsFragment : BasePreferenceFragment(R.string.settings),
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
findPreference<PreferenceScreen>(R.string.key_remote_sources)?.run {
|
||||
findPreference<PreferenceScreen>(AppSettings.KEY_REMOTE_SOURCES)?.run {
|
||||
val total = MangaSource.values().size - 1
|
||||
summary = getString(
|
||||
R.string.enabled_d_from_d, total - settings.hiddenSources.size, total
|
||||
@@ -101,11 +102,11 @@ class MainSettingsFragment : BasePreferenceFragment(R.string.settings),
|
||||
|
||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
||||
return when (preference?.key) {
|
||||
getString(R.string.key_list_mode) -> {
|
||||
AppSettings.KEY_LIST_MODE -> {
|
||||
ListModeSelectDialog.show(childFragmentManager)
|
||||
true
|
||||
}
|
||||
getString(R.string.key_notifications_settings) -> {
|
||||
AppSettings.KEY_NOTIFICATIONS_SETTINGS -> {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
||||
.putExtra(Settings.EXTRA_APP_PACKAGE, requireContext().packageName)
|
||||
@@ -116,7 +117,7 @@ class MainSettingsFragment : BasePreferenceFragment(R.string.settings),
|
||||
}
|
||||
true
|
||||
}
|
||||
getString(R.string.key_local_storage) -> {
|
||||
AppSettings.KEY_LOCAL_STORAGE -> {
|
||||
val ctx = context ?: return false
|
||||
StorageSelectDialog.Builder(ctx, settings.getStorageDir(ctx), this)
|
||||
.setTitle(preference.title)
|
||||
@@ -125,7 +126,7 @@ class MainSettingsFragment : BasePreferenceFragment(R.string.settings),
|
||||
.show()
|
||||
true
|
||||
}
|
||||
getString(R.string.key_protect_app) -> {
|
||||
AppSettings.KEY_PROTECT_APP -> {
|
||||
if ((preference as? SwitchPreference ?: return false).isChecked) {
|
||||
enableAppProtection(preference)
|
||||
} else {
|
||||
@@ -133,7 +134,7 @@ class MainSettingsFragment : BasePreferenceFragment(R.string.settings),
|
||||
}
|
||||
true
|
||||
}
|
||||
getString(R.string.key_app_version) -> {
|
||||
AppSettings.KEY_APP_VERSION -> {
|
||||
checkForUpdates()
|
||||
true
|
||||
}
|
||||
@@ -197,12 +198,12 @@ class MainSettingsFragment : BasePreferenceFragment(R.string.settings),
|
||||
|
||||
private fun checkForUpdates() {
|
||||
viewLifecycleScope.launch {
|
||||
findPreference<Preference>(R.string.key_app_version)?.run {
|
||||
findPreference<Preference>(AppSettings.KEY_APP_VERSION)?.run {
|
||||
setSummary(R.string.checking_for_updates)
|
||||
isSelectable = false
|
||||
}
|
||||
val result = AppUpdateChecker(activity ?: return@launch).checkNow()
|
||||
findPreference<Preference>(R.string.key_app_version)?.run {
|
||||
findPreference<Preference>(AppSettings.KEY_APP_VERSION)?.run {
|
||||
setSummary(
|
||||
when (result) {
|
||||
true -> R.string.check_for_updates
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.media.RingtoneManager
|
||||
import android.os.Bundle
|
||||
import androidx.preference.Preference
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.ui.base.BasePreferenceFragment
|
||||
import org.koitharu.kotatsu.ui.settings.utils.RingtonePickContract
|
||||
import org.koitharu.kotatsu.utils.ext.toUriOrNull
|
||||
@@ -12,7 +13,7 @@ class NotificationSettingsLegacyFragment : BasePreferenceFragment(R.string.notif
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
addPreferencesFromResource(R.xml.pref_notifications)
|
||||
findPreference<Preference>(R.string.key_notifications_sound)?.run {
|
||||
findPreference<Preference>(AppSettings.KEY_NOTIFICATIONS_SOUND)?.run {
|
||||
val uri = settings.notificationSound.toUriOrNull()
|
||||
summary = RingtoneManager.getRingtone(context, uri).getTitle(context)
|
||||
}
|
||||
@@ -20,10 +21,10 @@ class NotificationSettingsLegacyFragment : BasePreferenceFragment(R.string.notif
|
||||
|
||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
||||
return when (preference?.key) {
|
||||
getString(R.string.key_notifications_sound) -> {
|
||||
AppSettings.KEY_NOTIFICATIONS_SOUND -> {
|
||||
registerForActivityResult(RingtonePickContract(preference.title.toString())) { uri ->
|
||||
settings.notificationSound = uri?.toString().orEmpty()
|
||||
findPreference<Preference>(R.string.key_notifications_sound)?.run {
|
||||
findPreference<Preference>(AppSettings.KEY_NOTIFICATIONS_SOUND)?.run {
|
||||
summary = RingtoneManager.getRingtone(context, uri).getTitle(context)
|
||||
}
|
||||
}.launch(settings.notificationSound.toUriOrNull())
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.koitharu.kotatsu.ui.settings
|
||||
import android.os.Bundle
|
||||
import androidx.preference.MultiSelectListPreference
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.ui.base.BasePreferenceFragment
|
||||
import org.koitharu.kotatsu.ui.settings.utils.MultiSummaryProvider
|
||||
|
||||
@@ -10,7 +11,7 @@ class ReaderSettingsFragment : BasePreferenceFragment(R.string.reader_settings)
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
addPreferencesFromResource(R.xml.pref_reader)
|
||||
findPreference<MultiSelectListPreference>(R.string.key_reader_switchers)?.let {
|
||||
findPreference<MultiSelectListPreference>(AppSettings.KEY_READER_SWITCHERS)?.let {
|
||||
it.summaryProvider = MultiSummaryProvider(R.string.gestures_only)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.preference.PreferenceFragmentCompat
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.model.MangaSource
|
||||
import org.koitharu.kotatsu.core.parser.RemoteMangaRepository
|
||||
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
||||
import org.koitharu.kotatsu.ui.settings.utils.EditTextSummaryProvider
|
||||
import org.koitharu.kotatsu.utils.ext.withArgs
|
||||
|
||||
@@ -23,13 +24,13 @@ class SourceSettingsFragment : PreferenceFragmentCompat() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
preferenceManager.sharedPreferencesName = source.name
|
||||
val repo = source.repository as? RemoteMangaRepository ?: return
|
||||
val keys = repo.onCreatePreferences().map(::getString)
|
||||
val keys = repo.onCreatePreferences()
|
||||
addPreferencesFromResource(R.xml.pref_source)
|
||||
for (i in 0 until preferenceScreen.preferenceCount) {
|
||||
val pref = preferenceScreen.getPreference(i)
|
||||
pref.isVisible = pref.key in keys
|
||||
}
|
||||
findPreference<EditTextPreference>(getString(R.string.key_parser_domain))?.summaryProvider =
|
||||
findPreference<EditTextPreference>(SourceSettings.KEY_DOMAIN)?.summaryProvider =
|
||||
EditTextSummaryProvider(R.string._default)
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ import androidx.core.content.edit
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class BoolPreferenceDelegate(private val key: String, private val defValue: Boolean) :
|
||||
class BoolPreferenceDelegate(private val key: String, private val defaultValue: Boolean) :
|
||||
ReadWriteProperty<SharedPreferences, Boolean> {
|
||||
|
||||
override fun getValue(thisRef: SharedPreferences, property: KProperty<*>): Boolean {
|
||||
return thisRef.getBoolean(key, defValue)
|
||||
return thisRef.getBoolean(key, defaultValue)
|
||||
}
|
||||
|
||||
override fun setValue(thisRef: SharedPreferences, property: KProperty<*>, value: Boolean) {
|
||||
|
||||
@@ -5,11 +5,11 @@ import androidx.core.content.edit
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class IntPreferenceDelegate(private val key: String, private val defValue: Int) :
|
||||
class IntPreferenceDelegate(private val key: String, private val defaultValue: Int) :
|
||||
ReadWriteProperty<SharedPreferences, Int> {
|
||||
|
||||
override fun getValue(thisRef: SharedPreferences, property: KProperty<*>): Int {
|
||||
return thisRef.getInt(key, defValue)
|
||||
return thisRef.getInt(key, defaultValue)
|
||||
}
|
||||
|
||||
override fun setValue(thisRef: SharedPreferences, property: KProperty<*>, value: Int) {
|
||||
|
||||
@@ -5,11 +5,11 @@ import androidx.core.content.edit
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class LongPreferenceDelegate(private val key: String, private val defValue: Long) :
|
||||
class LongPreferenceDelegate(private val key: String, private val defaultValue: Long) :
|
||||
ReadWriteProperty<SharedPreferences, Long> {
|
||||
|
||||
override fun getValue(thisRef: SharedPreferences, property: KProperty<*>): Long {
|
||||
return thisRef.getLong(key, defValue)
|
||||
return thisRef.getLong(key, defaultValue)
|
||||
}
|
||||
|
||||
override fun setValue(thisRef: SharedPreferences, property: KProperty<*>, value: Long) {
|
||||
|
||||
@@ -1,35 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="key_list_mode">list_mode</string>
|
||||
<string name="key_app_section">app_section</string>
|
||||
<string name="key_theme">theme</string>
|
||||
<string name="key_sources_order">sources_order</string>
|
||||
<string name="key_sources_hidden">sources_hidden</string>
|
||||
<string name="key_traffic_warning">traffic_warning</string>
|
||||
<string name="key_pages_cache_clear">pages_cache_clear</string>
|
||||
<string name="key_thumbs_cache_clear">thumbs_cache_clear</string>
|
||||
<string name="key_search_history_clear">search_history_clear</string>
|
||||
<string name="key_updates_feed_clear">updates_feed_clear</string>
|
||||
<string name="key_grid_size">grid_size</string>
|
||||
<string name="key_remote_sources">remote_sources</string>
|
||||
<string name="key_local_storage">local_storage</string>
|
||||
<string name="key_reader_switchers">reader_switchers</string>
|
||||
<string name="key_track_sources">track_sources</string>
|
||||
<string name="key_app_update">app_update</string>
|
||||
<string name="key_app_update_auto">app_update_auto</string>
|
||||
<string name="key_tracker_notifications">tracker_notifications</string>
|
||||
<string name="key_notifications_settings">notifications_settings</string>
|
||||
<string name="key_notifications_sound">notifications_sound</string>
|
||||
<string name="key_notifications_vibrate">notifications_vibrate</string>
|
||||
<string name="key_notifications_light">notifications_light</string>
|
||||
<string name="key_reader_animation">reader_animation</string>
|
||||
<string name="key_reader_prefer_rtl">reader_prefer_rtl</string>
|
||||
<string name="key_app_password">app_password</string>
|
||||
<string name="key_protect_app">protect_app</string>
|
||||
<string name="key_app_version">app_version</string>
|
||||
|
||||
<string name="key_parser_domain">domain</string>
|
||||
<string name="key_parser_ssl">ssl</string>
|
||||
<string-array name="values_theme">
|
||||
<item>-1</item>
|
||||
<item>1</item>
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<Preference
|
||||
android:key="@string/key_search_history_clear"
|
||||
android:key="search_history_clear"
|
||||
android:persistent="false"
|
||||
android:title="@string/clear_search_history"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<Preference
|
||||
android:key="@string/key_updates_feed_clear"
|
||||
android:key="updates_feed_clear"
|
||||
android:persistent="false"
|
||||
android:title="@string/clear_updates_feed"
|
||||
app:iconSpaceReserved="false" />
|
||||
@@ -20,13 +20,13 @@
|
||||
android:title="@string/cache">
|
||||
|
||||
<Preference
|
||||
android:key="@string/key_thumbs_cache_clear"
|
||||
android:key="thumbs_cache_clear"
|
||||
android:persistent="false"
|
||||
android:title="@string/clear_thumbs_cache"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<Preference
|
||||
android:key="@string/key_pages_cache_clear"
|
||||
android:key="pages_cache_clear"
|
||||
android:persistent="false"
|
||||
android:title="@string/clear_pages_cache"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
@@ -8,20 +8,20 @@
|
||||
android:defaultValue="-1"
|
||||
android:entries="@array/themes"
|
||||
android:entryValues="@array/values_theme"
|
||||
android:key="@string/key_theme"
|
||||
android:key="theme"
|
||||
android:title="@string/theme"
|
||||
app:iconSpaceReserved="false"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<Preference
|
||||
android:key="@string/key_list_mode"
|
||||
android:key="list_mode"
|
||||
android:persistent="false"
|
||||
android:title="@string/list_mode"
|
||||
app:allowDividerAbove="true"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SeekBarPreference
|
||||
android:key="@string/key_grid_size"
|
||||
android:key="grid_size"
|
||||
android:max="150"
|
||||
android:title="@string/grid_size"
|
||||
app:defaultValue="100"
|
||||
@@ -33,13 +33,13 @@
|
||||
|
||||
<PreferenceScreen
|
||||
android:fragment="org.koitharu.kotatsu.ui.settings.sources.SourcesSettingsFragment"
|
||||
android:key="@string/key_remote_sources"
|
||||
android:key="remote_sources"
|
||||
android:title="@string/remote_sources"
|
||||
app:allowDividerAbove="true"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<Preference
|
||||
android:key="@string/key_local_storage"
|
||||
android:key="local_storage"
|
||||
android:title="@string/manga_save_location"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="@string/key_protect_app"
|
||||
android:key="protect_app"
|
||||
android:persistent="false"
|
||||
android:summary="@string/protect_application_summary"
|
||||
android:title="@string/protect_application"
|
||||
@@ -59,20 +59,20 @@
|
||||
android:defaultValue="@array/values_reader_switchers_default"
|
||||
android:entries="@array/reader_switchers"
|
||||
android:entryValues="@array/values_reader_switchers"
|
||||
android:key="@string/key_reader_switchers"
|
||||
android:key="reader_switchers"
|
||||
android:title="@string/switch_pages"
|
||||
app:allowDividerAbove="true"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_reader_animation"
|
||||
android:key="reader_animation"
|
||||
android:title="@string/pages_animation"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_reader_prefer_rtl"
|
||||
android:key="reader_prefer_rtl"
|
||||
android:summary="@string/prefer_rtl_reader_summary"
|
||||
android:title="@string/prefer_rtl_reader"
|
||||
app:iconSpaceReserved="false" />
|
||||
@@ -86,20 +86,20 @@
|
||||
android:defaultValue="@array/values_track_sources_default"
|
||||
android:entries="@array/track_sources"
|
||||
android:entryValues="@array/values_track_sources"
|
||||
android:key="@string/key_track_sources"
|
||||
android:key="track_sources"
|
||||
android:title="@string/track_sources"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_tracker_notifications"
|
||||
android:key="tracker_notifications"
|
||||
android:summary="@string/show_notification_new_chapters"
|
||||
android:title="@string/notifications"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<Preference
|
||||
android:dependency="@string/key_tracker_notifications"
|
||||
android:key="@string/key_notifications_settings"
|
||||
android:dependency="tracker_notifications"
|
||||
android:key="notifications_settings"
|
||||
android:title="@string/notifications_settings"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_app_update_auto"
|
||||
android:key="app_update_auto"
|
||||
android:summary="@string/show_notification_app_update"
|
||||
android:title="@string/application_update"
|
||||
app:iconSpaceReserved="false"
|
||||
@@ -119,7 +119,7 @@
|
||||
tools:isPreferenceVisible="true" />
|
||||
|
||||
<Preference
|
||||
android:key="@string/key_app_version"
|
||||
android:key="app_version"
|
||||
android:persistent="false"
|
||||
android:summary="@string/check_for_updates"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
@@ -4,19 +4,19 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<Preference
|
||||
android:key="@string/key_notifications_sound"
|
||||
android:key="notifications_sound"
|
||||
android:title="@string/notification_sound"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_notifications_vibrate"
|
||||
android:key="notifications_vibrate"
|
||||
android:title="@string/vibration"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_notifications_light"
|
||||
android:key="notifications_light"
|
||||
android:title="@string/light_indicator"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
android:defaultValue="@array/values_reader_switchers_default"
|
||||
android:entries="@array/reader_switchers"
|
||||
android:entryValues="@array/values_reader_switchers"
|
||||
android:key="@string/key_reader_switchers"
|
||||
android:key="reader_switchers"
|
||||
android:title="@string/switch_pages"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_reader_animation"
|
||||
android:key="reader_animation"
|
||||
android:title="@string/pages_animation"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_reader_prefer_rtl"
|
||||
android:key="reader_prefer_rtl"
|
||||
android:summary="@string/prefer_rtl_reader_summary"
|
||||
android:title="@string/prefer_rtl_reader"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<EditTextPreference
|
||||
android:key="@string/key_parser_domain"
|
||||
android:key="domain"
|
||||
android:title="@string/domain"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="@string/key_parser_ssl"
|
||||
android:key="ssl"
|
||||
android:title="@string/use_ssl"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.koin.test.KoinTest
|
||||
import org.koin.test.get
|
||||
import org.koitharu.kotatsu.core.model.MangaSource
|
||||
import org.koitharu.kotatsu.core.parser.UserAgentInterceptor
|
||||
import org.koitharu.kotatsu.core.prefs.SourceConfig
|
||||
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
||||
import org.koitharu.kotatsu.domain.MangaLoaderContext
|
||||
import org.koitharu.kotatsu.utils.AssertX
|
||||
import java.util.concurrent.TimeUnit
|
||||
@@ -106,8 +106,8 @@ class RemoteRepositoryTest(source: MangaSource) : KoinTest {
|
||||
module {
|
||||
single<MangaLoaderContext> {
|
||||
object : MangaLoaderContext() {
|
||||
override fun getSettings(source: MangaSource): SourceConfig {
|
||||
return SourceConfigMock()
|
||||
override fun getSettings(source: MangaSource): SourceSettings {
|
||||
return SourceSettingsMock()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.koitharu.kotatsu.parsers
|
||||
|
||||
import org.koitharu.kotatsu.core.prefs.SourceConfig
|
||||
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
||||
|
||||
class SourceConfigMock : SourceConfig {
|
||||
class SourceSettingsMock : SourceSettings {
|
||||
|
||||
override fun getDomain(defaultValue: String) = defaultValue
|
||||
|
||||
Reference in New Issue
Block a user