Skip to content

Commit

Permalink
add option to hide last used source
Browse files Browse the repository at this point in the history
  • Loading branch information
az4521 committed Mar 15, 2024
1 parent 1d97531 commit 99b5659
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ object PreferenceKeys {

const val enableDoh = "enable_doh"

const val hideLastUsedSource = "hide_last_used_source"
fun trackUsername(syncId: Int) = "pref_mangasync_username_$syncId"

fun trackPassword(syncId: Int) = "pref_mangasync_password_$syncId"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ class PreferencesHelper(val context: Context) {

fun enableDoh() = prefs.getBoolean(Keys.enableDoh, false)

fun hideLastUsedSource() = flowPrefs.getBoolean(Keys.hideLastUsedSource, false)
fun extensionInstaller() = flowPrefs.getEnum(
Keys.extensionInstaller,
if (MiuiUtil.isMiui()) Values.ExtensionInstaller.LEGACY else Values.ExtensionInstaller.PACKAGEINSTALLER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,33 +69,22 @@ class SettingsBrowseController : SettingsController() {
}

preferenceCategory {
titleRes = R.string.action_global_search
titleRes = R.string.label_sources

switchPreference {
key = Keys.searchPinnedSourcesOnly
titleRes = R.string.pref_search_pinned_sources_only
key = Keys.hideLastUsedSource
titleRes = R.string.pref_hide_last_used_source
defaultValue = false
}
}

preferenceCategory {
titleRes = R.string.pref_category_nsfw_content
titleRes = R.string.action_global_search

listPreference {
key = Keys.allowNsfwSource
titleRes = R.string.pref_allow_nsfw_sources
entriesRes = arrayOf(
R.string.pref_allow_nsfw_sources_allowed,
R.string.pref_allow_nsfw_sources_allowed_multisource,
R.string.pref_allow_nsfw_sources_blocked
)
entryValues = arrayOf(
Values.NsfwAllowance.ALLOWED.name,
Values.NsfwAllowance.PARTIAL.name,
Values.NsfwAllowance.BLOCKED.name
)
defaultValue = Values.NsfwAllowance.ALLOWED.name
summary = "%s"
switchPreference {
key = Keys.searchPinnedSourcesOnly
titleRes = R.string.pref_search_pinned_sources_only
defaultValue = false
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ class SourcePresenter(
}

private fun updateLastUsedSource(sourceId: Long) {
val source = (sourceManager.get(sourceId) as? CatalogueSource)?.let { SourceItem(it, showButtons = controllerMode == SourceController.Mode.CATALOGUE) }
source?.let {
view().subscribe { view -> view?.setLastUsedSource(it) }
if (preferences.hideLastUsedSource().get()) {
view().subscribe { view -> view?.setLastUsedSource(null) }
} else {
val source = (sourceManager.get(sourceId) as? CatalogueSource)?.let { SourceItem(it, showButtons = controllerMode == SourceController.Mode.CATALOGUE) }
source?.let {
view().subscribe { view -> view?.setLastUsedSource(it) }
}
}
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@
<string name="pref_allow_nsfw_sources_allowed_multisource">Block source but show in extensions list</string>
<string name="pref_allow_nsfw_sources_blocked">Blocked</string>
<string name="pref_search_pinned_sources_only">Only include pinned sources</string>
<string name="pref_hide_last_used_source">Hide Last Used Source</string>

<!-- Backup section -->
<string name="backup">Backup</string>
Expand Down

0 comments on commit 99b5659

Please sign in to comment.