Move some property to delegate
This commit is contained in:
1 parent
034a5c2071
commit
e9cb083672
5 files changed
+19
-60
No files matched your search
@@ -506,54 +506,16 @@ object Settings : DefaultPreferences() {
|
||||
.apply()
|
||||
}
|
||||
|
||||
val favLocalCount: Int
|
||||
get() = sSettingsPre.getInt(KEY_FAV_LOCAL, DEFAULT_FAV_COUNT)
|
||||
var favLocalCount by intPref(KEY_FAV_LOCAL, DEFAULT_FAV_COUNT)
|
||||
var favCloudCount by intPref(KEY_FAV_CLOUD, DEFAULT_FAV_COUNT)
|
||||
var recentFavCat by intPref(KEY_RECENT_FAV_CAT, DEFAULT_RECENT_FAV_CAT)
|
||||
var defaultFavSlot by intPref(KEY_DEFAULT_FAV_SLOT, DEFAULT_DEFAULT_FAV_SLOT)
|
||||
var qSSaveProgress by boolPref(KEY_QS_SAVE_PROGRESS, DEFAULT_QS_SAVE_PROGRESS)
|
||||
val saveParseErrorBody by boolPref(KEY_SAVE_PARSE_ERROR_BODY, DEFAULT_SAVE_PARSE_ERROR_BODY)
|
||||
val saveCrashLog by boolPref(KEY_SAVE_CRASH_LOG, DEFAULT_SAVE_CRASH_LOG)
|
||||
var security by boolPref(KEY_SECURITY, false)
|
||||
val securityDelay by intPref(KEY_SECURITY_DELAY, 0)
|
||||
|
||||
fun putFavLocalCount(count: Int) {
|
||||
sSettingsPre.edit().putInt(KEY_FAV_LOCAL, count).apply()
|
||||
}
|
||||
|
||||
val favCloudCount: Int
|
||||
get() = sSettingsPre.getInt(KEY_FAV_CLOUD, DEFAULT_FAV_COUNT)
|
||||
|
||||
fun putFavCloudCount(count: Int) {
|
||||
sSettingsPre.edit().putInt(KEY_FAV_CLOUD, count).apply()
|
||||
}
|
||||
|
||||
val recentFavCat: Int
|
||||
get() = getInt(KEY_RECENT_FAV_CAT, DEFAULT_RECENT_FAV_CAT)
|
||||
|
||||
fun putRecentFavCat(value: Int) {
|
||||
putInt(KEY_RECENT_FAV_CAT, value)
|
||||
}
|
||||
|
||||
val defaultFavSlot: Int
|
||||
get() = getInt(KEY_DEFAULT_FAV_SLOT, DEFAULT_DEFAULT_FAV_SLOT)
|
||||
|
||||
fun putDefaultFavSlot(value: Int) {
|
||||
putInt(KEY_DEFAULT_FAV_SLOT, value)
|
||||
}
|
||||
|
||||
val qSSaveProgress: Boolean
|
||||
get() = getBoolean(KEY_QS_SAVE_PROGRESS, DEFAULT_QS_SAVE_PROGRESS)
|
||||
|
||||
fun putQSSaveProgress(value: Boolean) {
|
||||
putBoolean(KEY_QS_SAVE_PROGRESS, value)
|
||||
}
|
||||
|
||||
val saveParseErrorBody: Boolean
|
||||
get() = getBoolean(KEY_SAVE_PARSE_ERROR_BODY, DEFAULT_SAVE_PARSE_ERROR_BODY)
|
||||
val saveCrashLog: Boolean
|
||||
get() = getBoolean(KEY_SAVE_CRASH_LOG, DEFAULT_SAVE_CRASH_LOG)
|
||||
val security: Boolean
|
||||
get() = getBoolean(KEY_SECURITY, false)
|
||||
|
||||
fun putSecurity(value: Boolean) {
|
||||
putBoolean(KEY_SECURITY, value)
|
||||
}
|
||||
|
||||
val securityDelay: Int
|
||||
get() = getInt(KEY_SECURITY_DELAY, 0)
|
||||
val readCacheSize: Int
|
||||
get() = getIntFromStr(KEY_READ_CACHE_SIZE, DEFAULT_READ_CACHE_SIZE)
|
||||
|
||||
|
||||
@@ -233,9 +233,9 @@ suspend fun Context.addToFavorites(galleryInfo: GalleryInfo, select: Boolean = f
|
||||
val newFavoriteName = if (slot1 in 0..9) items[slot1 + 1] else null
|
||||
doAddToFavorites(slot1, newFavoriteName)
|
||||
if (checked) {
|
||||
Settings.putDefaultFavSlot(slot1)
|
||||
Settings.defaultFavSlot = slot1
|
||||
} else {
|
||||
Settings.putDefaultFavSlot(Settings.INVALID_DEFAULT_FAV_SLOT)
|
||||
Settings.defaultFavSlot = Settings.INVALID_DEFAULT_FAV_SLOT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class PrivacyFragment : BasePreferenceFragment() {
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
if (!requireContext().isAuthenticationSupported()) {
|
||||
Settings.putSecurity(false)
|
||||
Settings.security = false
|
||||
requireUnlock.isEnabled = false
|
||||
requireUnlock.isChecked = false
|
||||
unlockDelay.isEnabled = false
|
||||
|
||||
@@ -214,7 +214,7 @@ class FavoritesScene :
|
||||
mContentLayout.setHelper(mHelper!!)
|
||||
mContentLayout.fastScroller.setOnDragHandlerListener(this)
|
||||
mContentLayout.setFitPaddingTop(paddingTopSB)
|
||||
mAdapter = FavoritesAdapter(inflater, resources, mRecyclerView!!, Settings.listMode)
|
||||
mAdapter = FavoritesAdapter(resources, mRecyclerView!!, Settings.listMode)
|
||||
mRecyclerView!!.clipToPadding = false
|
||||
mRecyclerView!!.clipChildren = false
|
||||
mRecyclerView!!.setChoiceMode(EasyRecyclerView.CHOICE_MODE_MULTIPLE_CUSTOM)
|
||||
@@ -292,7 +292,7 @@ class FavoritesScene :
|
||||
mOldKeyword = keyword
|
||||
|
||||
// Save recent fav cat
|
||||
Settings.putRecentFavCat(mUrlBuilder!!.favCat)
|
||||
Settings.recentFavCat = mUrlBuilder!!.favCat
|
||||
}
|
||||
|
||||
// Hide jump fab on local fav cat
|
||||
@@ -351,9 +351,7 @@ class FavoritesScene :
|
||||
BaseDialogBuilder(requireContext())
|
||||
.setTitle(R.string.default_favorites_collection)
|
||||
.setItems(items) { _: DialogInterface?, which: Int ->
|
||||
Settings.putDefaultFavSlot(
|
||||
which - 2,
|
||||
)
|
||||
Settings.defaultFavSlot = which - 2
|
||||
}
|
||||
.show()
|
||||
return@setOnMenuItemClickListener true
|
||||
@@ -641,7 +639,7 @@ class FavoritesScene :
|
||||
for (i in 0..9) {
|
||||
mFavCountSum += mFavCountArray!![i]
|
||||
}
|
||||
Settings.putFavCloudCount(mFavCountSum)
|
||||
Settings.favCloudCount = mFavCountSum
|
||||
updateSearchBar()
|
||||
mHelper!!.onGetPageData(taskId, 0, 0, result.prev, result.next, result.galleryInfoList)
|
||||
if (mDrawerAdapter != null) {
|
||||
@@ -670,7 +668,7 @@ class FavoritesScene :
|
||||
}
|
||||
if (TextUtils.isEmpty(keyword)) {
|
||||
mFavLocalCount = list.size
|
||||
Settings.putFavLocalCount(mFavLocalCount)
|
||||
Settings.favLocalCount = mFavLocalCount
|
||||
if (mDrawerAdapter != null) {
|
||||
mDrawerAdapter!!.notifyDataSetChanged()
|
||||
}
|
||||
@@ -819,7 +817,6 @@ class FavoritesScene :
|
||||
}
|
||||
|
||||
private inner class FavoritesAdapter(
|
||||
inflater: LayoutInflater,
|
||||
resources: Resources,
|
||||
recyclerView: RecyclerView,
|
||||
type: Int,
|
||||
|
||||
@@ -504,9 +504,9 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
|
||||
}
|
||||
if (checked[0] && next != null) {
|
||||
text += next
|
||||
Settings.putQSSaveProgress(true)
|
||||
Settings.qSSaveProgress = true
|
||||
} else {
|
||||
Settings.putQSSaveProgress(false)
|
||||
Settings.qSSaveProgress = false
|
||||
}
|
||||
|
||||
// Check name duplicate
|
||||
|
||||
Reference in new issue
Block a user