Cleanup EH and AZ preferences

This commit is contained in:
Jobobby04 2020-11-30 14:35:31 -05:00
parent f1a6218a4b
commit 9a2ed755b7
38 changed files with 133 additions and 168 deletions

View File

@ -142,7 +142,7 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) {
* @return list of [BackupSavedSearch] to be backed up * @return list of [BackupSavedSearch] to be backed up
*/ */
private fun backupSavedSearches(): List<BackupSavedSearch> { private fun backupSavedSearches(): List<BackupSavedSearch> {
return preferences.eh_savedSearches().get().map { return preferences.savedSearches().get().map {
val sourceId = it.substringBefore(':').toLong() val sourceId = it.substringBefore(':').toLong()
val content = Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':')) val content = Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
BackupSavedSearch( BackupSavedSearch(
@ -465,7 +465,7 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) {
// SY --> // SY -->
internal fun restoreSavedSearches(backupSavedSearches: List<BackupSavedSearch>) { internal fun restoreSavedSearches(backupSavedSearches: List<BackupSavedSearch>) {
val currentSavedSearches = preferences.eh_savedSearches().get().map { val currentSavedSearches = preferences.savedSearches().get().map {
val sourceId = it.substringBefore(':').toLong() val sourceId = it.substringBefore(':').toLong()
val content = Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':')) val content = Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
BackupSavedSearch( BackupSavedSearch(
@ -476,7 +476,7 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) {
) )
} }
preferences.eh_savedSearches() preferences.savedSearches()
.set( .set(
( (
backupSavedSearches.filter { backupSavedSearch -> currentSavedSearches.none { it.name == backupSavedSearch.name && it.source == backupSavedSearch.source } } backupSavedSearches.filter { backupSavedSearch -> currentSavedSearches.none { it.name == backupSavedSearch.name && it.source == backupSavedSearch.source } }
@ -488,7 +488,7 @@ class FullBackupManager(context: Context) : AbstractBackupManager(context) {
Json.decodeFromString(it.filterList) Json.decodeFromString(it.filterList)
) )
) )
} + preferences.eh_savedSearches().get() } + preferences.savedSearches().get()
) )
.toSet() .toSet()
) )

View File

@ -158,7 +158,7 @@ class LegacyBackupManager(context: Context, version: Int = CURRENT_VERSION) : Ab
backupExtensionInfo(extensionEntries, extensions) backupExtensionInfo(extensionEntries, extensions)
// SY --> // SY -->
root[SAVEDSEARCHES] = root[SAVEDSEARCHES] =
Injekt.get<PreferencesHelper>().eh_savedSearches().get().joinToString(separator = "***") Injekt.get<PreferencesHelper>().savedSearches().get().joinToString(separator = "***")
backupMergedMangaReferences(mergedMangaReferenceEntries) backupMergedMangaReferences(mergedMangaReferenceEntries)
// SY <-- // SY <--
@ -514,7 +514,7 @@ class LegacyBackupManager(context: Context, version: Int = CURRENT_VERSION) : Ab
val currentSources = newSavedSearches.map { it.first }.toSet() val currentSources = newSavedSearches.map { it.first }.toSet()
newSavedSearches += preferences.eh_savedSearches().get().mapNotNull { newSavedSearches += preferences.savedSearches().get().mapNotNull {
try { try {
val id = it.substringBefore(':').toLong() val id = it.substringBefore(':').toLong()
val content = Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':')) val content = Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
@ -527,7 +527,7 @@ class LegacyBackupManager(context: Context, version: Int = CURRENT_VERSION) : Ab
} }
}.toMutableList() }.toMutableList()
val otherSerialized = preferences.eh_savedSearches().get().mapNotNull { val otherSerialized = preferences.savedSearches().get().mapNotNull {
val sourceId = it.split(":")[0].toLongOrNull() ?: return@mapNotNull null val sourceId = it.split(":")[0].toLongOrNull() ?: return@mapNotNull null
if (sourceId in currentSources) return@mapNotNull null if (sourceId in currentSources) return@mapNotNull null
it it
@ -536,7 +536,7 @@ class LegacyBackupManager(context: Context, version: Int = CURRENT_VERSION) : Ab
val newSerialized = newSavedSearches.map { val newSerialized = newSavedSearches.map {
"${it.first}:" + Json.encodeToString(it.second) "${it.first}:" + Json.encodeToString(it.second)
} }
preferences.eh_savedSearches().set((otherSerialized + newSerialized).toSet()) preferences.savedSearches().set((otherSerialized + newSerialized).toSet())
} }
/** /**

View File

@ -56,10 +56,10 @@ class ChapterCache(private val context: Context) {
/** Cache class used for cache management. */ /** Cache class used for cache management. */
// --> EH // --> EH
private var diskCache = setupDiskCache(prefs.eh_cacheSize().get().toLong()) private var diskCache = setupDiskCache(prefs.cacheSize().get().toLong())
init { init {
prefs.eh_cacheSize().asFlow() prefs.cacheSize().asFlow()
.onEach { .onEach {
// Save old cache for destruction later // Save old cache for destruction later
val oldCache = diskCache val oldCache = diskCache

View File

@ -195,16 +195,6 @@ object PreferenceKeys {
fun trackToken(syncId: Int) = "track_token_$syncId" fun trackToken(syncId: Int) = "track_token_$syncId"
const val eh_lock_hash = "lock_hash"
const val eh_lock_salt = "lock_salt"
const val eh_lock_length = "lock_length"
const val eh_lock_finger = "lock_finger"
const val eh_lock_manually = "eh_lock_manually"
const val eh_showSyncIntro = "eh_show_sync_intro" const val eh_showSyncIntro = "eh_show_sync_intro"
const val eh_readOnlySync = "eh_sync_read_only" const val eh_readOnlySync = "eh_sync_read_only"
@ -225,8 +215,6 @@ object PreferenceKeys {
const val eh_enableExHentai = "enable_exhentai" const val eh_enableExHentai = "enable_exhentai"
const val eh_ts_aspNetCookie = "eh_ts_aspNetCookie"
const val eh_showSettingsUploadWarning = "eh_showSettingsUploadWarning2" const val eh_showSettingsUploadWarning = "eh_showSettingsUploadWarning2"
const val eh_expandFilters = "eh_expand_filters" const val eh_expandFilters = "eh_expand_filters"

View File

@ -290,7 +290,7 @@ class PreferencesHelper(val context: Context) {
} }
} }
// --> AZ J2K CHERRYPICKING // SY -->
fun defaultMangaOrder() = flowPrefs.getString("default_manga_order", "") fun defaultMangaOrder() = flowPrefs.getString("default_manga_order", "")
@ -302,19 +302,7 @@ class PreferencesHelper(val context: Context) {
fun skipPreMigration() = flowPrefs.getBoolean(Keys.skipPreMigration, false) fun skipPreMigration() = flowPrefs.getBoolean(Keys.skipPreMigration, false)
fun upgradeFilters() { fun isHentaiEnabled() = flowPrefs.getBoolean(Keys.eh_is_hentai_enabled, true)
val filterDl = flowPrefs.getBoolean(Keys.filterDownloaded, false).get()
val filterUn = flowPrefs.getBoolean(Keys.filterUnread, false).get()
val filterCm = flowPrefs.getBoolean(Keys.filterCompleted, false).get()
filterDownloaded().set(if (filterDl) 1 else 0)
filterUnread().set(if (filterUn) 1 else 0)
filterCompleted().set(if (filterCm) 1 else 0)
}
// <--
// --> EH
fun eh_isHentaiEnabled() = flowPrefs.getBoolean(Keys.eh_is_hentai_enabled, true)
fun enableExhentai() = flowPrefs.getBoolean(Keys.eh_enableExHentai, false) fun enableExhentai() = flowPrefs.getBoolean(Keys.eh_enableExHentai, false)
@ -324,80 +312,72 @@ class PreferencesHelper(val context: Context) {
fun useJapaneseTitle() = flowPrefs.getBoolean("use_jp_title", false) fun useJapaneseTitle() = flowPrefs.getBoolean("use_jp_title", false)
fun eh_useOriginalImages() = flowPrefs.getBoolean(Keys.eh_useOrigImages, false) fun exhUseOriginalImages() = flowPrefs.getBoolean(Keys.eh_useOrigImages, false)
fun ehTagFilterValue() = flowPrefs.getInt(Keys.eh_tag_filtering_value, 0) fun ehTagFilterValue() = flowPrefs.getInt(Keys.eh_tag_filtering_value, 0)
fun ehTagWatchingValue() = flowPrefs.getInt(Keys.eh_tag_watching_value, 0) fun ehTagWatchingValue() = flowPrefs.getInt(Keys.eh_tag_watching_value, 0)
fun ehSearchSize() = flowPrefs.getString("ex_search_size", "rc_0")
fun thumbnailRows() = flowPrefs.getString("ex_thumb_rows", "tr_2")
fun hasPerformedURLMigration() = flowPrefs.getBoolean("performed_url_migration", false)
// EH Cookies // EH Cookies
fun memberIdVal() = flowPrefs.getString("eh_ipb_member_id", "") fun memberIdVal() = flowPrefs.getString("eh_ipb_member_id", "")
fun passHashVal() = flowPrefs.getString("eh_ipb_pass_hash", "") fun passHashVal() = flowPrefs.getString("eh_ipb_pass_hash", "")
fun igneousVal() = flowPrefs.getString("eh_igneous", "") fun igneousVal() = flowPrefs.getString("eh_igneous", "")
fun eh_ehSettingsProfile() = flowPrefs.getInt(Keys.eh_ehSettingsProfile, -1) fun ehSettingsProfile() = flowPrefs.getInt(Keys.eh_ehSettingsProfile, -1)
fun eh_exhSettingsProfile() = flowPrefs.getInt(Keys.eh_exhSettingsProfile, -1) fun exhSettingsProfile() = flowPrefs.getInt(Keys.eh_exhSettingsProfile, -1)
fun eh_settingsKey() = flowPrefs.getString(Keys.eh_settingsKey, "") fun exhSettingsKey() = flowPrefs.getString(Keys.eh_settingsKey, "")
fun eh_sessionCookie() = flowPrefs.getString(Keys.eh_sessionCookie, "") fun exhSessionCookie() = flowPrefs.getString(Keys.eh_sessionCookie, "")
fun eh_hathPerksCookies() = flowPrefs.getString(Keys.eh_hathPerksCookie, "") fun exhHathPerksCookies() = flowPrefs.getString(Keys.eh_hathPerksCookie, "")
fun eh_showSyncIntro() = flowPrefs.getBoolean(Keys.eh_showSyncIntro, true) fun exhShowSyncIntro() = flowPrefs.getBoolean(Keys.eh_showSyncIntro, true)
fun eh_readOnlySync() = flowPrefs.getBoolean(Keys.eh_readOnlySync, false) fun exhReadOnlySync() = flowPrefs.getBoolean(Keys.eh_readOnlySync, false)
fun eh_lenientSync() = flowPrefs.getBoolean(Keys.eh_lenientSync, false) fun exhLenientSync() = flowPrefs.getBoolean(Keys.eh_lenientSync, false)
fun eh_ts_aspNetCookie() = flowPrefs.getString(Keys.eh_ts_aspNetCookie, "") fun exhShowSettingsUploadWarning() = flowPrefs.getBoolean(Keys.eh_showSettingsUploadWarning, true)
fun eh_showSettingsUploadWarning() = flowPrefs.getBoolean(Keys.eh_showSettingsUploadWarning, true) fun expandFilters() = flowPrefs.getBoolean(Keys.eh_expandFilters, false)
fun eh_expandFilters() = flowPrefs.getBoolean(Keys.eh_expandFilters, false) fun readerThreads() = flowPrefs.getInt(Keys.eh_readerThreads, 2)
fun eh_readerThreads() = flowPrefs.getInt(Keys.eh_readerThreads, 2) fun readerInstantRetry() = flowPrefs.getBoolean(Keys.eh_readerInstantRetry, true)
fun eh_readerInstantRetry() = flowPrefs.getBoolean(Keys.eh_readerInstantRetry, true) fun autoscrollInterval() = flowPrefs.getFloat(Keys.eh_utilAutoscrollInterval, 3f)
fun eh_utilAutoscrollInterval() = flowPrefs.getFloat(Keys.eh_utilAutoscrollInterval, 3f) fun cacheSize() = flowPrefs.getString(Keys.eh_cacheSize, "75")
fun eh_cacheSize() = flowPrefs.getString(Keys.eh_cacheSize, "75") fun preserveReadingPosition() = flowPrefs.getBoolean(Keys.eh_preserveReadingPosition, false)
fun eh_preserveReadingPosition() = flowPrefs.getBoolean(Keys.eh_preserveReadingPosition, false) fun autoSolveCaptcha() = flowPrefs.getBoolean(Keys.eh_autoSolveCaptchas, false)
fun eh_autoSolveCaptchas() = flowPrefs.getBoolean(Keys.eh_autoSolveCaptchas, false) fun delegateSources() = flowPrefs.getBoolean(Keys.eh_delegateSources, true)
fun eh_delegateSources() = flowPrefs.getBoolean(Keys.eh_delegateSources, true) fun ehLastVersionCode() = flowPrefs.getInt("eh_last_version_code", 0)
fun eh_lastVersionCode() = flowPrefs.getInt("eh_last_version_code", 0) fun savedSearches() = flowPrefs.getStringSet("eh_saved_searches", emptySet())
fun eh_savedSearches() = flowPrefs.getStringSet("eh_saved_searches", emptySet()) fun logLevel() = flowPrefs.getInt(Keys.eh_logLevel, 0)
fun eh_logLevel() = flowPrefs.getInt(Keys.eh_logLevel, 0) fun enableSourceBlacklist() = flowPrefs.getBoolean(Keys.eh_enableSourceBlacklist, true)
fun eh_enableSourceBlacklist() = flowPrefs.getBoolean(Keys.eh_enableSourceBlacklist, true) fun exhAutoUpdateFrequency() = flowPrefs.getInt(Keys.eh_autoUpdateFrequency, 1)
fun eh_autoUpdateFrequency() = flowPrefs.getInt(Keys.eh_autoUpdateFrequency, 1) fun exhAutoUpdateRequirements() = flowPrefs.getStringSet(Keys.eh_autoUpdateRestrictions, emptySet())
fun eh_autoUpdateRequirements() = prefs.getStringSet(Keys.eh_autoUpdateRestrictions, emptySet()) fun exhAutoUpdateStats() = flowPrefs.getString(Keys.eh_autoUpdateStats, "")
fun eh_autoUpdateStats() = flowPrefs.getString(Keys.eh_autoUpdateStats, "") fun aggressivePageLoading() = flowPrefs.getBoolean(Keys.eh_aggressivePageLoading, false)
fun eh_aggressivePageLoading() = flowPrefs.getBoolean(Keys.eh_aggressivePageLoading, false) fun preloadSize() = flowPrefs.getInt(Keys.eh_preload_size, 10)
fun eh_preload_size() = flowPrefs.getInt(Keys.eh_preload_size, 10) fun useAutoWebtoon() = flowPrefs.getBoolean(Keys.eh_use_auto_webtoon, true)
fun eh_useAutoWebtoon() = flowPrefs.getBoolean(Keys.eh_use_auto_webtoon, true) fun exhWatchedListDefaultState() = flowPrefs.getBoolean(Keys.eh_watched_list_default_state, false)
fun eh_watchedListDefaultState() = flowPrefs.getBoolean(Keys.eh_watched_list_default_state, false) fun exhSettingsLanguages() = flowPrefs.getString(Keys.eh_settings_languages, "false*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false")
fun eh_settingsLanguages() = flowPrefs.getString(Keys.eh_settings_languages, "false*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false") fun exhEnabledCategories() = flowPrefs.getString(Keys.eh_enabled_categories, "false,false,false,false,false,false,false,false,false,false")
fun eh_EnabledCategories() = flowPrefs.getString(Keys.eh_enabled_categories, "false,false,false,false,false,false,false,false,false,false")
fun latestTabSources() = flowPrefs.getStringSet(Keys.latest_tab_sources, mutableSetOf()) fun latestTabSources() = flowPrefs.getStringSet(Keys.latest_tab_sources, mutableSetOf())

View File

@ -155,7 +155,7 @@ class ExtensionManager(
// EXH --> // EXH -->
fun <T : Extension> Iterable<T>.filterNotBlacklisted(): List<T> { fun <T : Extension> Iterable<T>.filterNotBlacklisted(): List<T> {
val blacklistEnabled = preferences.eh_enableSourceBlacklist().get() val blacklistEnabled = preferences.enableSourceBlacklist().get()
return filter { return filter {
if (it.isBlacklisted(blacklistEnabled)) { if (it.isBlacklisted(blacklistEnabled)) {
XLog.tag("ExtensionManager").d("Removing blacklisted extension: (name: %s, pkgName: %s)!", it.name, it.pkgName) XLog.tag("ExtensionManager").d("Removing blacklisted extension: (name: %s, pkgName: %s)!", it.name, it.pkgName)
@ -166,7 +166,7 @@ class ExtensionManager(
fun Extension.isBlacklisted( fun Extension.isBlacklisted(
blacklistEnabled: Boolean = blacklistEnabled: Boolean =
preferences.eh_enableSourceBlacklist().get() preferences.enableSourceBlacklist().get()
): Boolean { ): Boolean {
return pkgName in BlacklistedSources.BLACKLISTED_EXTENSIONS && blacklistEnabled return pkgName in BlacklistedSources.BLACKLISTED_EXTENSIONS && blacklistEnabled
} }

View File

@ -34,7 +34,7 @@ internal class ExtensionGithubApi {
preferences.lastExtCheck().set(Date().time) preferences.lastExtCheck().set(Date().time)
// SY --> // SY -->
val blacklistEnabled = preferences.eh_enableSourceBlacklist().get() val blacklistEnabled = preferences.enableSourceBlacklist().get()
// SY <-- // SY <--
val installedExtensions = ExtensionLoader.loadExtensions(context) val installedExtensions = ExtensionLoader.loadExtensions(context)
@ -86,7 +86,7 @@ internal class ExtensionGithubApi {
// SY --> // SY -->
fun Extension.isBlacklisted( fun Extension.isBlacklisted(
blacklistEnabled: Boolean = blacklistEnabled: Boolean =
preferences.eh_enableSourceBlacklist().get() preferences.enableSourceBlacklist().get()
): Boolean { ): Boolean {
return pkgName in BlacklistedSources.BLACKLISTED_EXTENSIONS && blacklistEnabled return pkgName in BlacklistedSources.BLACKLISTED_EXTENSIONS && blacklistEnabled
} }

View File

@ -403,7 +403,7 @@ abstract class HttpSource : CatalogueSource {
// EXH --> // EXH -->
private var delegate: DelegatedHttpSource? = null private var delegate: DelegatedHttpSource? = null
get() = if (Injekt.get<PreferencesHelper>().eh_delegateSources().get()) { get() = if (Injekt.get<PreferencesHelper>().delegateSources().get()) {
field field
} else { } else {
null null

View File

@ -681,9 +681,9 @@ class EHentai(
} }
fun spPref() = if (exh) { fun spPref() = if (exh) {
preferences.eh_exhSettingsProfile() preferences.exhSettingsProfile()
} else { } else {
preferences.eh_ehSettingsProfile() preferences.ehSettingsProfile()
} }
private fun rawCookies(sp: Int): Map<String, String> { private fun rawCookies(sp: Int): Map<String, String> {
@ -694,17 +694,17 @@ class EHentai(
cookies[LoginController.IGNEOUS_COOKIE] = preferences.igneousVal().get() cookies[LoginController.IGNEOUS_COOKIE] = preferences.igneousVal().get()
cookies["sp"] = sp.toString() cookies["sp"] = sp.toString()
val sessionKey = preferences.eh_settingsKey().get() val sessionKey = preferences.exhSettingsKey().get()
if (sessionKey.isNotBlank()) { if (sessionKey.isNotBlank()) {
cookies["sk"] = sessionKey cookies["sk"] = sessionKey
} }
val sessionCookie = preferences.eh_sessionCookie().get() val sessionCookie = preferences.exhSessionCookie().get()
if (sessionCookie.isNotBlank()) { if (sessionCookie.isNotBlank()) {
cookies["s"] = sessionCookie cookies["s"] = sessionCookie
} }
val hathPerksCookie = preferences.eh_hathPerksCookies().get() val hathPerksCookie = preferences.exhHathPerksCookies().get()
if (hathPerksCookie.isNotBlank()) { if (hathPerksCookie.isNotBlank()) {
cookies["hath_perks"] = hathPerksCookie cookies["hath_perks"] = hathPerksCookie
} }
@ -752,7 +752,7 @@ class EHentai(
EHTags.getNameSpaces().map { "$it:" }, EHTags.getNameSpaces().map { "$it:" },
excludePrefix excludePrefix
), ),
if (preferences.eh_watchedListDefaultState().get()) { if (preferences.exhWatchedListDefaultState().get()) {
Watched(isEnabled = true) Watched(isEnabled = true)
} else { } else {
Watched(isEnabled = false) Watched(isEnabled = false)

View File

@ -441,7 +441,7 @@ open class BrowseSourcePresenter(
// EXH --> // EXH -->
fun saveSearches(searches: List<EXHSavedSearch>) { fun saveSearches(searches: List<EXHSavedSearch>) {
val otherSerialized = prefs.eh_savedSearches().get().filter { val otherSerialized = prefs.savedSearches().get().filter {
!it.startsWith("${source.id}:") !it.startsWith("${source.id}:")
} }
val newSerialized = searches.map { val newSerialized = searches.map {
@ -451,11 +451,11 @@ open class BrowseSourcePresenter(
put("filters", filterSerializer.serialize(it.filterList)) put("filters", filterSerializer.serialize(it.filterList))
}.toString() }.toString()
} }
prefs.eh_savedSearches().set((otherSerialized + newSerialized).toSet()) prefs.savedSearches().set((otherSerialized + newSerialized).toSet())
} }
fun loadSearches(): List<EXHSavedSearch> { fun loadSearches(): List<EXHSavedSearch> {
val loaded = prefs.eh_savedSearches().get() val loaded = prefs.savedSearches().get()
return loaded.map { return loaded.map {
try { try {
val id = it.substringBefore(':').toLong() val id = it.substringBefore(':').toLong()

View File

@ -20,7 +20,7 @@ class GroupItem(val filter: Filter.Group<*>) : AbstractExpandableHeaderItem<Grou
init { init {
// --> EH // --> EH
isExpanded = Injekt.get<PreferencesHelper>().eh_expandFilters().get() isExpanded = Injekt.get<PreferencesHelper>().expandFilters().get()
// <-- EH // <-- EH
} }

View File

@ -226,7 +226,7 @@ open class IndexPresenter(
private val filterSerializer = FilterSerializer() private val filterSerializer = FilterSerializer()
fun loadSearches(): List<EXHSavedSearch> { fun loadSearches(): List<EXHSavedSearch> {
val loaded = preferences.eh_savedSearches().get() val loaded = preferences.savedSearches().get()
return loaded.map { return loaded.map {
try { try {
val id = it.substringBefore(':').toLong() val id = it.substringBefore(':').toLong()

View File

@ -425,7 +425,7 @@ class LibraryController(
menu.findItem(R.id.action_filter).icon.mutate() menu.findItem(R.id.action_filter).icon.mutate()
// SY --> // SY -->
menu.findItem(R.id.action_sync_favorites).isVisible = preferences.eh_isHentaiEnabled().get() menu.findItem(R.id.action_sync_favorites).isVisible = preferences.isHentaiEnabled().get()
// SY <-- // SY <--
} }
@ -483,7 +483,7 @@ class LibraryController(
router.pushController(MigrationSourcesController().withFadeTransaction()) router.pushController(MigrationSourcesController().withFadeTransaction())
} }
R.id.action_sync_favorites -> { R.id.action_sync_favorites -> {
if (preferences.eh_showSyncIntro().get()) { if (preferences.exhShowSyncIntro().get()) {
activity?.let { FavoritesIntroDialog().show(it) } activity?.let { FavoritesIntroDialog().show(it) }
} else { } else {
presenter.favoritesSync.runSync() presenter.favoritesSync.runSync()

View File

@ -201,7 +201,7 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
initWhenIdle { initWhenIdle {
// Upload settings // Upload settings
if (preferences.enableExhentai().get() && if (preferences.enableExhentai().get() &&
preferences.eh_showSettingsUploadWarning().get() preferences.exhShowSettingsUploadWarning().get()
) { ) {
WarnConfigureDialogController.uploadSettings(router) WarnConfigureDialogController.uploadSettings(router)
} }
@ -212,7 +212,7 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
// SY <-- // SY <--
} }
// SY --> // SY -->
if (!preferences.eh_isHentaiEnabled().get()) { if (!preferences.isHentaiEnabled().get()) {
if (EH_SOURCE_ID !in BlacklistedSources.HIDDEN_SOURCES) { if (EH_SOURCE_ID !in BlacklistedSources.HIDDEN_SOURCES) {
BlacklistedSources.HIDDEN_SOURCES += EH_SOURCE_ID BlacklistedSources.HIDDEN_SOURCES += EH_SOURCE_ID
} }

View File

@ -35,7 +35,7 @@ class ChaptersAdapter(
val dateFormat: DateFormat = preferences.dateFormat() val dateFormat: DateFormat = preferences.dateFormat()
// SY --> // SY -->
val preserveReadingPosition: Boolean = preferences.eh_preserveReadingPosition().get() val preserveReadingPosition: Boolean = preferences.preserveReadingPosition().get()
// SY <-- // SY <--
override fun updateDataSet(items: List<ChapterItem>?) { override fun updateDataSet(items: List<ChapterItem>?) {

View File

@ -87,7 +87,7 @@ class MoreController :
} }
} }
// SY --> // SY -->
if (preferences.eh_isHentaiEnabled().get()) { if (preferences.isHentaiEnabled().get()) {
preference { preference {
titleRes = R.string.eh_batch_add titleRes = R.string.eh_batch_add
iconRes = R.drawable.ic_playlist_add_black_24dp iconRes = R.drawable.ic_playlist_add_black_24dp

View File

@ -71,7 +71,6 @@ import exh.util.defaultReaderType
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.cancel
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.drop import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flow
@ -430,7 +429,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
.launchIn(scope) .launchIn(scope)
binding.ehAutoscrollFreq.setText( binding.ehAutoscrollFreq.setText(
preferences.eh_utilAutoscrollInterval().get().let { preferences.autoscrollInterval().get().let {
if (it == -1f) { if (it == -1f) {
"" ""
} else { } else {
@ -443,7 +442,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
.onEach { .onEach {
setupAutoscroll( setupAutoscroll(
if (it) { if (it) {
preferences.eh_utilAutoscrollInterval().get().toDouble() preferences.autoscrollInterval().get().toDouble()
} else { } else {
-1.0 -1.0
} }
@ -457,12 +456,12 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
if (parsed == null || parsed <= 0 || parsed > 9999) { if (parsed == null || parsed <= 0 || parsed > 9999) {
binding.ehAutoscrollFreq.error = "Invalid frequency" binding.ehAutoscrollFreq.error = "Invalid frequency"
preferences.eh_utilAutoscrollInterval().set(-1f) preferences.autoscrollInterval().set(-1f)
binding.ehAutoscroll.isEnabled = false binding.ehAutoscroll.isEnabled = false
setupAutoscroll(-1.0) setupAutoscroll(-1.0)
} else { } else {
binding.ehAutoscrollFreq.error = null binding.ehAutoscrollFreq.error = null
preferences.eh_utilAutoscrollInterval().set(parsed.toFloat()) preferences.autoscrollInterval().set(parsed.toFloat())
binding.ehAutoscroll.isEnabled = true binding.ehAutoscroll.isEnabled = true
setupAutoscroll(if (binding.ehAutoscroll.isChecked) parsed else -1.0) setupAutoscroll(if (binding.ehAutoscroll.isChecked) parsed else -1.0)
} }
@ -712,7 +711,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
// SY --> // SY -->
val defaultReaderType = manga.defaultReaderType() val defaultReaderType = manga.defaultReaderType()
if (preferences.eh_useAutoWebtoon().get() && manga.viewer == 0 && defaultReaderType != null && defaultReaderType == WEBTOON) { if (preferences.useAutoWebtoon().get() && manga.viewer == 0 && defaultReaderType != null && defaultReaderType == WEBTOON) {
binding.root.snack(resources.getString(R.string.eh_auto_webtoon_snack), Snackbar.LENGTH_LONG) binding.root.snack(resources.getString(R.string.eh_auto_webtoon_snack), Snackbar.LENGTH_LONG)
} else if (preferences.showReadingMode()) { } else if (preferences.showReadingMode()) {
// SY <-- // SY <--

View File

@ -597,7 +597,7 @@ class ReaderPresenter(
fun getMangaViewer(): Int { fun getMangaViewer(): Int {
val manga = manga ?: return preferences.defaultViewer() val manga = manga ?: return preferences.defaultViewer()
// SY --> // SY -->
return if (manga.viewer == 0 && preferences.eh_useAutoWebtoon().get()) { return if (manga.viewer == 0 && preferences.useAutoWebtoon().get()) {
manga.defaultReaderType() ?: if (manga.viewer == 0) preferences.defaultViewer() else manga.viewer manga.defaultReaderType() ?: if (manga.viewer == 0) preferences.defaultViewer() else manga.viewer
} else if (manga.viewer == 0) { } else if (manga.viewer == 0) {
preferences.defaultViewer() preferences.defaultViewer()

View File

@ -6,7 +6,6 @@ import android.widget.Spinner
import androidx.annotation.ArrayRes import androidx.annotation.ArrayRes
import androidx.core.view.isInvisible import androidx.core.view.isInvisible
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.core.view.plusAssign
import androidx.core.widget.NestedScrollView import androidx.core.widget.NestedScrollView
import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialog
import com.tfcporciuncula.flow.Preference import com.tfcporciuncula.flow.Preference
@ -73,7 +72,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
binding.alwaysShowChapterTransition.bindToPreference(preferences.alwaysShowChapterTransition()) binding.alwaysShowChapterTransition.bindToPreference(preferences.alwaysShowChapterTransition())
binding.pageTransitions.bindToPreference(preferences.pageTransitions()) binding.pageTransitions.bindToPreference(preferences.pageTransitions())
// SY --> // SY -->
binding.autoWebtoonMode.bindToPreference(preferences.eh_useAutoWebtoon()) binding.autoWebtoonMode.bindToPreference(preferences.useAutoWebtoon())
// SY <-- // SY <--
// If the preference is explicitly disabled, that means the setting was configured since there is a cutout // If the preference is explicitly disabled, that means the setting was configured since there is a cutout

View File

@ -66,7 +66,7 @@ class ChapterLoader(
// If the chapter is partially read, set the starting page to the last the user read // If the chapter is partially read, set the starting page to the last the user read
// otherwise use the requested page. // otherwise use the requested page.
if (!chapter.chapter.read /* --> EH */ || prefs if (!chapter.chapter.read /* --> EH */ || prefs
.eh_preserveReadingPosition() .preserveReadingPosition()
.get() /* <-- EH */ .get() /* <-- EH */
) { ) {
chapter.requestedPage = chapter.chapter.last_page_read chapter.requestedPage = chapter.chapter.last_page_read

View File

@ -21,7 +21,6 @@ import rx.subscriptions.CompositeSubscription
import timber.log.Timber import timber.log.Timber
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
import java.util.concurrent.PriorityBlockingQueue import java.util.concurrent.PriorityBlockingQueue
import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.atomic.AtomicInteger
import kotlin.math.min import kotlin.math.min
@ -32,11 +31,11 @@ import kotlin.math.min
class HttpPageLoader( class HttpPageLoader(
private val chapter: ReaderChapter, private val chapter: ReaderChapter,
private val source: HttpSource, private val source: HttpSource,
private val chapterCache: ChapterCache = Injekt.get() private val chapterCache: ChapterCache = Injekt.get(),
// SY -->
private val preferences: PreferencesHelper = Injekt.get()
// SY <--
) : PageLoader() { ) : PageLoader() {
// EXH -->
private val prefs: PreferencesHelper by injectLazy()
// EXH <--
/** /**
* A queue used to manage requests one by one while allowing priorities. * A queue used to manage requests one by one while allowing priorities.
@ -48,11 +47,11 @@ class HttpPageLoader(
*/ */
private val subscriptions = CompositeSubscription() private val subscriptions = CompositeSubscription()
private val preloadSize = /* SY --> */ prefs.eh_preload_size().get() /* SY <-- */ private val preloadSize = /* SY --> */ preferences.preloadSize().get() /* SY <-- */
init { init {
// EXH --> // EXH -->
repeat(prefs.eh_readerThreads().get()) { repeat(preferences.readerThreads().get()) {
// EXH <-- // EXH <--
subscriptions += Observable.defer { Observable.just(queue.take().page) } subscriptions += Observable.defer { Observable.just(queue.take().page) }
.filter { it.status == Page.QUEUE } .filter { it.status == Page.QUEUE }
@ -110,7 +109,7 @@ class HttpPageLoader(
// Don't trust sources and use our own indexing // Don't trust sources and use our own indexing
ReaderPage(index, page.url, page.imageUrl) ReaderPage(index, page.url, page.imageUrl)
} }
if (prefs.eh_aggressivePageLoading().get()) { if (preferences.aggressivePageLoading().get()) {
rp.mapNotNull { rp.mapNotNull {
if (it.status == Page.QUEUE) { if (it.status == Page.QUEUE) {
PriorityPage(it, 0) PriorityPage(it, 0)
@ -193,7 +192,7 @@ class HttpPageLoader(
page.imageUrl = null page.imageUrl = null
} }
if (prefs.eh_readerInstantRetry().get()) // EXH <-- if (preferences.readerInstantRetry().get()) // EXH <--
{ {
boostPage(page) boostPage(page)
} else { } else {
@ -262,16 +261,16 @@ class HttpPageLoader(
} }
.doOnNext { .doOnNext {
// SY --> // SY -->
val readerTheme = prefs.readerTheme().get() val readerTheme = preferences.readerTheme().get()
if (readerTheme >= 3) { if (readerTheme >= 3) {
val stream = chapterCache.getImageFile(imageUrl).inputStream() val stream = chapterCache.getImageFile(imageUrl).inputStream()
val image = BitmapFactory.decodeStream(stream) val image = BitmapFactory.decodeStream(stream)
page.bg = ImageUtil.autoSetBackground( page.bg = ImageUtil.autoSetBackground(
image, image,
readerTheme == 3, readerTheme == 3,
prefs.context preferences.context
) )
page.bgType = PagerPageHolder.getBGType(readerTheme, prefs.context) page.bgType = PagerPageHolder.getBGType(readerTheme, preferences.context)
stream.close() stream.close()
} }
// SY <-- // SY <--

View File

@ -263,7 +263,7 @@ class SettingsAdvancedController : SettingsController() {
defaultValue = true defaultValue = true
onChange { onChange {
if (preferences.eh_isHentaiEnabled().get()) { if (preferences.isHentaiEnabled().get()) {
if (EH_SOURCE_ID !in BlacklistedSources.HIDDEN_SOURCES) { if (EH_SOURCE_ID !in BlacklistedSources.HIDDEN_SOURCES) {
BlacklistedSources.HIDDEN_SOURCES += EH_SOURCE_ID BlacklistedSources.HIDDEN_SOURCES += EH_SOURCE_ID
} }

View File

@ -159,7 +159,7 @@ class SettingsEhController : SettingsController() {
key = PreferenceKeys.eh_useOrigImages key = PreferenceKeys.eh_useOrigImages
defaultValue = false defaultValue = false
onChange { preferences.eh_useOriginalImages().reconfigure() } onChange { preferences.exhUseOriginalImages().reconfigure() }
preferences.enableExhentai().asImmediateFlow { isVisible = it } preferences.enableExhentai().asImmediateFlow { isVisible = it }
.launchIn(scope) .launchIn(scope)
@ -297,14 +297,14 @@ class SettingsEhController : SettingsController() {
).joinToString("\n") ).joinToString("\n")
} }
preferences.eh_settingsLanguages().set(languages) preferences.exhSettingsLanguages().set(languages)
preferences.eh_settingsLanguages().reconfigure() preferences.exhSettingsLanguages().reconfigure()
} }
.show { .show {
val customView = this.view.contentLayout.customView!! val customView = this.view.contentLayout.customView!!
val binding = EhDialogLanguagesBinding.bind(customView) val binding = EhDialogLanguagesBinding.bind(customView)
val settingsLanguages = preferences.eh_settingsLanguages().get().split("\n") val settingsLanguages = preferences.exhSettingsLanguages().get().split("\n")
val japanese = settingsLanguages[0].split("*").map { it.toBoolean() } val japanese = settingsLanguages[0].split("*").map { it.toBoolean() }
val english = settingsLanguages[1].split("*").map { it.toBoolean() } val english = settingsLanguages[1].split("*").map { it.toBoolean() }
@ -420,7 +420,7 @@ class SettingsEhController : SettingsController() {
val binding = EhDialogCategoriesBinding.bind(customView) val binding = EhDialogCategoriesBinding.bind(customView)
with(binding) { with(binding) {
preferences.eh_EnabledCategories().set( preferences.exhEnabledCategories().set(
listOf( listOf(
(!doujinshiCheckbox.isChecked), (!doujinshiCheckbox.isChecked),
(!mangaCheckbox.isChecked), (!mangaCheckbox.isChecked),
@ -436,14 +436,14 @@ class SettingsEhController : SettingsController() {
) )
} }
preferences.eh_EnabledCategories().reconfigure() preferences.exhEnabledCategories().reconfigure()
} }
.show { .show {
val customView = this.view.contentLayout.customView!! val customView = this.view.contentLayout.customView!!
val binding = EhDialogCategoriesBinding.bind(customView) val binding = EhDialogCategoriesBinding.bind(customView)
with(binding) { with(binding) {
val list = preferences.eh_EnabledCategories().get().split(",").map { !it.toBoolean() } val list = preferences.exhEnabledCategories().get().split(",").map { !it.toBoolean() }
doujinshiCheckbox.isChecked = list[0] doujinshiCheckbox.isChecked = list[0]
mangaCheckbox.isChecked = list[1] mangaCheckbox.isChecked = list[1]
artistCgCheckbox.isChecked = list[2] artistCgCheckbox.isChecked = list[2]
@ -584,7 +584,7 @@ class SettingsEhController : SettingsController() {
entryValues = arrayOf("0", "1", "2", "3", "6", "12", "24", "48") entryValues = arrayOf("0", "1", "2", "3", "6", "12", "24", "48")
defaultValue = "0" defaultValue = "0"
preferences.eh_autoUpdateFrequency().asFlow() preferences.exhAutoUpdateFrequency().asFlow()
.onEach { newVal -> .onEach { newVal ->
summary = if (newVal == 0) { summary = if (newVal == 0) {
context.getString(R.string.time_between_batches_summary_1, context.getString(R.string.app_name)) context.getString(R.string.time_between_batches_summary_1, context.getString(R.string.app_name))
@ -608,7 +608,7 @@ class SettingsEhController : SettingsController() {
entryValues = arrayOf("wifi", "ac") entryValues = arrayOf("wifi", "ac")
summaryRes = R.string.pref_library_update_restriction_summary summaryRes = R.string.pref_library_update_restriction_summary
preferences.eh_autoUpdateFrequency().asFlow() preferences.exhAutoUpdateFrequency().asFlow()
.onEach { isVisible = it > 0 } .onEach { isVisible = it > 0 }
.launchIn(scope) .launchIn(scope)
@ -633,7 +633,7 @@ class SettingsEhController : SettingsController() {
scope.launch(Dispatchers.IO) { scope.launch(Dispatchers.IO) {
val updateInfo = try { val updateInfo = try {
val stats = val stats =
preferences.eh_autoUpdateStats().get().nullIfBlank()?.let { preferences.exhAutoUpdateStats().get().nullIfBlank()?.let {
Json.decodeFromString<EHentaiUpdaterStats>(it) Json.decodeFromString<EHentaiUpdaterStats>(it)
} }

View File

@ -72,7 +72,7 @@ class SettingsMainController : SettingsController() {
onClick { navigateTo(SettingsSecurityController()) } onClick { navigateTo(SettingsSecurityController()) }
} }
// SY --> // SY -->
if (preferences.eh_isHentaiEnabled().get()) { if (preferences.isHentaiEnabled().get()) {
preference { preference {
iconRes = R.drawable.eh_ic_ehlogo_red_24dp iconRes = R.drawable.eh_ic_ehlogo_red_24dp
iconTint = tintColor iconTint = tintColor

View File

@ -51,7 +51,7 @@ object SettingsSearchHelper {
if (MdUtil.getEnabledMangaDexs(preferences).isNotEmpty()) { if (MdUtil.getEnabledMangaDexs(preferences).isNotEmpty()) {
controllers += SettingsMangaDexController::class controllers += SettingsMangaDexController::class
} }
if (preferences.eh_isHentaiEnabled().get()) { if (preferences.isHentaiEnabled().get()) {
controllers += SettingsEhController::class controllers += SettingsEhController::class
} }
controllers controllers

View File

@ -48,7 +48,7 @@ object EXHMigrations {
*/ */
fun upgrade(preferences: PreferencesHelper): Boolean { fun upgrade(preferences: PreferencesHelper): Boolean {
val context = preferences.context val context = preferences.context
val oldVersion = preferences.eh_lastVersionCode().get() val oldVersion = preferences.ehLastVersionCode().get()
try { try {
if (oldVersion < BuildConfig.VERSION_CODE) { if (oldVersion < BuildConfig.VERSION_CODE) {
// Fresh install // Fresh install
@ -259,7 +259,7 @@ object EXHMigrations {
// TODO BE CAREFUL TO NOT FUCK UP MergedSources IF CHANGING URLs // TODO BE CAREFUL TO NOT FUCK UP MergedSources IF CHANGING URLs
preferences.eh_lastVersionCode().set(BuildConfig.VERSION_CODE) preferences.ehLastVersionCode().set(BuildConfig.VERSION_CODE)
return true return true
} }

View File

@ -38,12 +38,12 @@ object DebugFunctions {
val sourceManager: SourceManager by injectLazy() val sourceManager: SourceManager by injectLazy()
fun forceUpgradeMigration() { fun forceUpgradeMigration() {
prefs.eh_lastVersionCode().set(1) prefs.ehLastVersionCode().set(1)
EXHMigrations.upgrade(prefs) EXHMigrations.upgrade(prefs)
} }
fun forceSetupJobs() { fun forceSetupJobs() {
prefs.eh_lastVersionCode().set(0) prefs.ehLastVersionCode().set(0)
EXHMigrations.upgrade(prefs) EXHMigrations.upgrade(prefs)
} }
@ -168,7 +168,7 @@ object DebugFunctions {
it.favorite && db.getSearchMetadataForManga(it.id!!).executeAsBlocking() == null it.favorite && db.getSearchMetadataForManga(it.id!!).executeAsBlocking() == null
} }
fun clearSavedSearches() = prefs.eh_savedSearches().set(emptySet()) fun clearSavedSearches() = prefs.savedSearches().set(emptySet())
fun listAllSources() = sourceManager.getCatalogueSources().joinToString("\n") { fun listAllSources() = sourceManager.getCatalogueSources().joinToString("\n") {
"${it.id}: ${it.name} (${it.lang.toUpperCase()})" "${it.id}: ${it.name} (${it.lang.toUpperCase()})"
@ -233,7 +233,7 @@ object DebugFunctions {
runBlocking { runBlocking {
val source = sourceManager.get(EH_SOURCE_ID) as? CatalogueSource ?: return@runBlocking val source = sourceManager.get(EH_SOURCE_ID) as? CatalogueSource ?: return@runBlocking
val newSource = sourceManager.get(EXH_SOURCE_ID) as? CatalogueSource ?: return@runBlocking val newSource = sourceManager.get(EXH_SOURCE_ID) as? CatalogueSource ?: return@runBlocking
val savedSearches = prefs.eh_savedSearches().get().mapNotNull { val savedSearches = prefs.savedSearches().get().mapNotNull {
try { try {
val id = it.substringBefore(':').toLong() val id = it.substringBefore(':').toLong()
if (id != source.id) return@mapNotNull null if (id != source.id) return@mapNotNull null
@ -245,7 +245,7 @@ object DebugFunctions {
null null
} }
}.toMutableList() }.toMutableList()
savedSearches += prefs.eh_savedSearches().get().mapNotNull { savedSearches += prefs.savedSearches().get().mapNotNull {
try { try {
val id = it.substringBefore(':').toLong() val id = it.substringBefore(':').toLong()
if (id != newSource.id) return@mapNotNull null if (id != newSource.id) return@mapNotNull null
@ -258,13 +258,13 @@ object DebugFunctions {
} }
}.filterNot { newSavedSearch -> savedSearches.any { it.name == newSavedSearch.name } } }.filterNot { newSavedSearch -> savedSearches.any { it.name == newSavedSearch.name } }
val otherSerialized = prefs.eh_savedSearches().get().filter { val otherSerialized = prefs.savedSearches().get().filter {
!it.startsWith("${newSource.id}:") !it.startsWith("${newSource.id}:")
} }
val newSerialized = savedSearches.map { val newSerialized = savedSearches.map {
"${newSource.id}:" + Json.encodeToString(it) "${newSource.id}:" + Json.encodeToString(it)
} }
prefs.eh_savedSearches().set((otherSerialized + newSerialized).toSet()) prefs.savedSearches().set((otherSerialized + newSerialized).toSet())
} }
} }
@ -272,7 +272,7 @@ object DebugFunctions {
runBlocking { runBlocking {
val source = sourceManager.get(EXH_SOURCE_ID) as? CatalogueSource ?: return@runBlocking val source = sourceManager.get(EXH_SOURCE_ID) as? CatalogueSource ?: return@runBlocking
val newSource = sourceManager.get(EH_SOURCE_ID) as? CatalogueSource ?: return@runBlocking val newSource = sourceManager.get(EH_SOURCE_ID) as? CatalogueSource ?: return@runBlocking
val savedSearches = prefs.eh_savedSearches().get().mapNotNull { val savedSearches = prefs.savedSearches().get().mapNotNull {
try { try {
val id = it.substringBefore(':').toLong() val id = it.substringBefore(':').toLong()
if (id != source.id) return@mapNotNull null if (id != source.id) return@mapNotNull null
@ -284,7 +284,7 @@ object DebugFunctions {
null null
} }
}.toMutableList() }.toMutableList()
savedSearches += prefs.eh_savedSearches().get().mapNotNull { savedSearches += prefs.savedSearches().get().mapNotNull {
try { try {
val id = it.substringBefore(':').toLong() val id = it.substringBefore(':').toLong()
if (id != newSource.id) return@mapNotNull null if (id != newSource.id) return@mapNotNull null
@ -297,13 +297,13 @@ object DebugFunctions {
} }
}.filterNot { newSavedSearch -> savedSearches.any { it.name == newSavedSearch.name } } }.filterNot { newSavedSearch -> savedSearches.any { it.name == newSavedSearch.name } }
val otherSerialized = prefs.eh_savedSearches().get().filter { val otherSerialized = prefs.savedSearches().get().filter {
!it.startsWith("${newSource.id}:") !it.startsWith("${newSource.id}:")
} }
val newSerialized = savedSearches.map { val newSerialized = savedSearches.map {
"${newSource.id}:" + Json.encodeToString(it) "${newSource.id}:" + Json.encodeToString(it)
} }
prefs.eh_savedSearches().set((otherSerialized + newSerialized).toSet()) prefs.savedSearches().set((otherSerialized + newSerialized).toSet())
} }
} }
} }

View File

@ -239,7 +239,7 @@ class EHentaiUpdateWorker : JobService(), CoroutineScope {
updatedThisIteration++ updatedThisIteration++
} }
} finally { } finally {
prefs.eh_autoUpdateStats().set( prefs.exhAutoUpdateStats().set(
Json.encodeToString( Json.encodeToString(
EHentaiUpdaterStats( EHentaiUpdaterStats(
startTime, startTime,
@ -355,9 +355,9 @@ class EHentaiUpdateWorker : JobService(), CoroutineScope {
cancelBackground(context) cancelBackground(context)
val preferences = Injekt.get<PreferencesHelper>() val preferences = Injekt.get<PreferencesHelper>()
val duration = prefInterval ?: preferences.eh_autoUpdateFrequency().get() val duration = prefInterval ?: preferences.exhAutoUpdateFrequency().get()
if (duration > 0) { if (duration > 0) {
val restrictions = preferences.eh_autoUpdateRequirements()!! val restrictions = preferences.exhAutoUpdateRequirements().get()
val acRestriction = "ac" in restrictions val acRestriction = "ac" in restrictions
val wifiRestriction = "wifi" in restrictions val wifiRestriction = "wifi" in restrictions

View File

@ -14,7 +14,7 @@ class FavoritesIntroDialog {
.title(R.string.favorites_sync_notes) .title(R.string.favorites_sync_notes)
.message(text = HtmlCompat.fromHtml(context.getString(R.string.favorites_sync_notes_message), HtmlCompat.FROM_HTML_MODE_LEGACY)) .message(text = HtmlCompat.fromHtml(context.getString(R.string.favorites_sync_notes_message), HtmlCompat.FROM_HTML_MODE_LEGACY))
.positiveButton(android.R.string.ok) { .positiveButton(android.R.string.ok) {
prefs.eh_showSyncIntro().set(false) prefs.exhShowSyncIntro().set(false)
} }
.cancelable(false) .cancelable(false)
.show() .show()

View File

@ -138,7 +138,7 @@ class FavoritesSyncHelper(val context: Context) {
db.inTransaction { db.inTransaction {
status.onNext(FavoritesSyncStatus.Processing(context.getString(R.string.favorites_sync_calculating_remote_changes), context = context)) status.onNext(FavoritesSyncStatus.Processing(context.getString(R.string.favorites_sync_calculating_remote_changes), context = context))
val remoteChanges = storage.getChangedRemoteEntries(realm, favorites.first) val remoteChanges = storage.getChangedRemoteEntries(realm, favorites.first)
val localChanges = if (prefs.eh_readOnlySync().get()) { val localChanges = if (prefs.exhReadOnlySync().get()) {
null // Do not build local changes if they are not going to be applied null // Do not build local changes if they are not going to be applied
} else { } else {
status.onNext(FavoritesSyncStatus.Processing(context.getString(R.string.favorites_sync_calculating_local_changes), context = context)) status.onNext(FavoritesSyncStatus.Processing(context.getString(R.string.favorites_sync_calculating_local_changes), context = context))
@ -255,7 +255,7 @@ class FavoritesSyncHelper(val context: Context) {
if (!explicitlyRetryExhRequest(10, request)) { if (!explicitlyRetryExhRequest(10, request)) {
val errorString = "Unable to add gallery to remote server: '${gallery.title}' (GID: ${gallery.gid})!" val errorString = "Unable to add gallery to remote server: '${gallery.title}' (GID: ${gallery.gid})!"
if (prefs.eh_lenientSync().get()) { if (prefs.exhLenientSync().get()) {
errorList += errorString errorList += errorString
} else { } else {
status.onNext(FavoritesSyncStatus.Error(errorString)) status.onNext(FavoritesSyncStatus.Error(errorString))
@ -305,7 +305,7 @@ class FavoritesSyncHelper(val context: Context) {
if (!explicitlyRetryExhRequest(10, request)) { if (!explicitlyRetryExhRequest(10, request)) {
val errorString = context.getString(R.string.favorites_sync_unable_to_delete) val errorString = context.getString(R.string.favorites_sync_unable_to_delete)
if (prefs.eh_lenientSync().get()) { if (prefs.exhLenientSync().get()) {
errorList += errorString errorList += errorString
} else { } else {
status.onNext(FavoritesSyncStatus.Error(errorString)) status.onNext(FavoritesSyncStatus.Error(errorString))
@ -397,7 +397,7 @@ class FavoritesSyncHelper(val context: Context) {
is GalleryAddEvent.Fail.UnknownType -> context.getString(R.string.favorites_sync_failed_to_add_to_local_unknown_type, it.title, result.galleryUrl) is GalleryAddEvent.Fail.UnknownType -> context.getString(R.string.favorites_sync_failed_to_add_to_local_unknown_type, it.title, result.galleryUrl)
} }
if (prefs.eh_lenientSync().get()) { if (prefs.exhLenientSync().get()) {
errorList += errorString errorList += errorString
} else { } else {
status.onNext(FavoritesSyncStatus.Error(errorString)) status.onNext(FavoritesSyncStatus.Error(errorString))

View File

@ -59,7 +59,7 @@ class EHDebugModeOverlay(private val context: Context) : OverlayModule<String>(n
<b>Version code:</b> ${BuildConfig.VERSION_CODE}<br> <b>Version code:</b> ${BuildConfig.VERSION_CODE}<br>
<b>Commit SHA:</b> ${BuildConfig.COMMIT_SHA}<br> <b>Commit SHA:</b> ${BuildConfig.COMMIT_SHA}<br>
<b>Log level:</b> ${EHLogLevel.currentLogLevel.name.toLowerCase(Locale.getDefault())}<br> <b>Log level:</b> ${EHLogLevel.currentLogLevel.name.toLowerCase(Locale.getDefault())}<br>
<b>Source blacklist:</b> ${prefs.eh_enableSourceBlacklist().get().asEnabledString()} <b>Source blacklist:</b> ${prefs.enableSourceBlacklist().get().asEnabledString()}
""".trimIndent() """.trimIndent()
private fun Boolean.asEnabledString() = if (this) "enabled" else "disabled" private fun Boolean.asEnabledString() = if (this) "enabled" else "disabled"

View File

@ -20,7 +20,7 @@ fun OkHttpClient.Builder.injectPatches(sourceIdProducer: () -> Long): OkHttpClie
fun findAndApplyPatches(sourceId: Long): EHInterceptor { fun findAndApplyPatches(sourceId: Long): EHInterceptor {
// TODO make it so captcha doesnt auto open in manga eden while applying universal interceptors // TODO make it so captcha doesnt auto open in manga eden while applying universal interceptors
return if (Injekt.get<PreferencesHelper>().eh_autoSolveCaptchas().get()) ((EH_INTERCEPTORS[sourceId].orEmpty()) + (EH_INTERCEPTORS[EH_UNIVERSAL_INTERCEPTOR].orEmpty())).merge() return if (Injekt.get<PreferencesHelper>().autoSolveCaptcha().get()) ((EH_INTERCEPTORS[sourceId].orEmpty()) + (EH_INTERCEPTORS[EH_UNIVERSAL_INTERCEPTOR].orEmpty())).merge()
else (EH_INTERCEPTORS[sourceId].orEmpty()).merge() else (EH_INTERCEPTORS[sourceId].orEmpty()).merge()
} }

View File

@ -229,7 +229,7 @@ class EnhancedHttpSource(
override fun getFilterList() = source().getFilterList() override fun getFilterList() = source().getFilterList()
fun source(): HttpSource { fun source(): HttpSource {
return if (prefs.eh_delegateSources().get()) { return if (prefs.delegateSources().get()) {
enhancedSource enhancedSource
} else { } else {
originalSource originalSource

View File

@ -145,13 +145,13 @@ class EHConfigurator(val context: Context) {
}?.removePrefix("hath_perks=")?.substringBefore(';') }?.removePrefix("hath_perks=")?.substringBefore(';')
if (keyCookie != null) { if (keyCookie != null) {
prefs.eh_settingsKey().set(keyCookie) prefs.exhSettingsKey().set(keyCookie)
} }
if (sessionCookie != null) { if (sessionCookie != null) {
prefs.eh_sessionCookie().set(sessionCookie) prefs.exhSessionCookie().set(sessionCookie)
} }
if (hathPerksCookie != null) { if (hathPerksCookie != null) {
prefs.eh_hathPerksCookies().set(hathPerksCookie) prefs.exhHathPerksCookies().set(hathPerksCookie)
} }
} }

View File

@ -37,7 +37,7 @@ class EhUConfigBuilder {
Entry.TitleDisplayLanguage.DEFAULT Entry.TitleDisplayLanguage.DEFAULT
} }
configItems += if (preferences.eh_useOriginalImages().get()) { configItems += if (preferences.exhUseOriginalImages().get()) {
Entry.UseOriginalImages.YES Entry.UseOriginalImages.YES
} else { } else {
Entry.UseOriginalImages.NO Entry.UseOriginalImages.NO
@ -64,9 +64,9 @@ class EhUConfigBuilder {
configItems += Entry.TagFilteringThreshold(preferences.ehTagFilterValue().get()) configItems += Entry.TagFilteringThreshold(preferences.ehTagFilterValue().get())
configItems += Entry.TagWatchingThreshold(preferences.ehTagWatchingValue().get()) configItems += Entry.TagWatchingThreshold(preferences.ehTagWatchingValue().get())
configItems += Entry.LanguageSystem().getLanguages(preferences.eh_settingsLanguages().get().split("\n")) configItems += Entry.LanguageSystem().getLanguages(preferences.exhSettingsLanguages().get().split("\n"))
configItems += Entry.Categories().categoryConfigs(preferences.eh_EnabledCategories().get().split(",").map { it.toBoolean() }) configItems += Entry.Categories().categoryConfigs(preferences.exhEnabledCategories().get().split(",").map { it.toBoolean() })
// Actually build form body // Actually build form body
val formBody = FormBody.Builder() val formBody = FormBody.Builder()

View File

@ -18,7 +18,7 @@ class WarnConfigureDialogController : DialogController() {
.title(R.string.settings_profile_note) .title(R.string.settings_profile_note)
.message(R.string.settings_profile_note_message) .message(R.string.settings_profile_note_message)
.positiveButton(android.R.string.ok) { .positiveButton(android.R.string.ok) {
prefs.eh_showSettingsUploadWarning().set(false) prefs.exhShowSettingsUploadWarning().set(false)
ConfiguringDialogController().showDialog(router) ConfiguringDialogController().showDialog(router)
} }
.cancelable(false) .cancelable(false)
@ -26,7 +26,7 @@ class WarnConfigureDialogController : DialogController() {
companion object { companion object {
fun uploadSettings(router: Router) { fun uploadSettings(router: Router) {
if (Injekt.get<PreferencesHelper>().eh_showSettingsUploadWarning().get()) { if (Injekt.get<PreferencesHelper>().exhShowSettingsUploadWarning().get()) {
WarnConfigureDialogController().showDialog(router) WarnConfigureDialogController().showDialog(router)
} else { } else {
ConfiguringDialogController().showDialog(router) ConfiguringDialogController().showDialog(router)

View File

@ -131,7 +131,7 @@ class BrowserActionActivity : AppCompatActivity() {
// Wait for both inner scripts to be loaded // Wait for both inner scripts to be loaded
if (loadedInners >= 2) { if (loadedInners >= 2) {
// Attempt to autosolve captcha // Attempt to autosolve captcha
if (preferencesHelper.eh_autoSolveCaptchas().get()) { if (preferencesHelper.autoSolveCaptcha().get()) {
binding.webview.post { binding.webview.post {
// 10 seconds to auto-solve captcha // 10 seconds to auto-solve captcha
strictValidationStartTime = System.currentTimeMillis() + 1000 * 10 strictValidationStartTime = System.currentTimeMillis() + 1000 * 10
@ -150,7 +150,7 @@ class BrowserActionActivity : AppCompatActivity() {
} }
} }
binding.webview.webViewClient = if (actionName == null && preferencesHelper.eh_autoSolveCaptchas().get()) { binding.webview.webViewClient = if (actionName == null && preferencesHelper.autoSolveCaptcha().get()) {
// Fetch auto-solve credentials early for speed // Fetch auto-solve credentials early for speed
credentialsObservable = httpClient.newCall( credentialsObservable = httpClient.newCall(
Request.Builder() Request.Builder()

View File

@ -62,14 +62,14 @@ class MangadexLoginDialog(bundle: Bundle? = null) : DialogController(bundle) {
binding!!.login.setMode(ActionProcessButton.Mode.ENDLESS) binding!!.login.setMode(ActionProcessButton.Mode.ENDLESS)
binding!!.login.setOnClickListener { checkLogin() } binding!!.login.setOnClickListener { checkLogin() }
setCredentialsOnView(view) setCredentialsOnView()
binding!!.twoFactorCheck.setOnCheckedChangeListener { _, isChecked -> binding!!.twoFactorCheck.setOnCheckedChangeListener { _, isChecked ->
binding!!.twoFactorHolder.isVisible = isChecked binding!!.twoFactorHolder.isVisible = isChecked
} }
} }
private fun setCredentialsOnView(view: View) { private fun setCredentialsOnView() {
binding?.username?.setText(service.getUsername()) binding?.username?.setText(service.getUsername())
binding?.password?.setText(service.getPassword()) binding?.password?.setText(service.getPassword())
} }