ブックマークボタンの表示をデフォルトONにする。デフォルト値の変化に追従しやすくするため、設定画面を開いた時や保存する時にスイッチの値がデフォルトと同じなら設定を削除する。
This commit is contained in:
parent
20d7f8dbfe
commit
3844f7247b
|
@ -704,9 +704,13 @@ class ActAppSettingChild : AppCompatActivity()
|
||||||
private fun loadUIFromData() {
|
private fun loadUIFromData() {
|
||||||
load_busy = true
|
load_busy = true
|
||||||
|
|
||||||
for(si in booleanViewList) {
|
pref.edit().also{ e->
|
||||||
si.view.isChecked = si.info(pref)
|
for(si in booleanViewList) {
|
||||||
}
|
val curVal = si.info(pref)
|
||||||
|
si.view.isChecked = curVal
|
||||||
|
if( curVal == si.info.defVal) si.info.remove(e)
|
||||||
|
}
|
||||||
|
}.apply()
|
||||||
|
|
||||||
spBackButtonAction?.setSelection(Pref.ipBackButtonAction(pref))
|
spBackButtonAction?.setSelection(Pref.ipBackButtonAction(pref))
|
||||||
spRepliesCount?.setSelection(Pref.ipRepliesCount(pref))
|
spRepliesCount?.setSelection(Pref.ipRepliesCount(pref))
|
||||||
|
@ -834,7 +838,7 @@ class ActAppSettingChild : AppCompatActivity()
|
||||||
val e = pref.edit()
|
val e = pref.edit()
|
||||||
|
|
||||||
for(si in booleanViewList) {
|
for(si in booleanViewList) {
|
||||||
e.putBoolean(si.info.key, si.view.isChecked)
|
si.info.putOrRemove(e,si.view.isChecked)
|
||||||
}
|
}
|
||||||
|
|
||||||
spDefaultAccount?.let {
|
spDefaultAccount?.let {
|
||||||
|
|
|
@ -40,7 +40,7 @@ fun SharedPreferences.Editor.remove(item : BasePref<*>) : SharedPreferences.Edit
|
||||||
|
|
||||||
class BooleanPref(
|
class BooleanPref(
|
||||||
key : String,
|
key : String,
|
||||||
private val defVal : Boolean,
|
val defVal : Boolean,
|
||||||
val id : Int =0
|
val id : Int =0
|
||||||
) : BasePref<Boolean>(key) {
|
) : BasePref<Boolean>(key) {
|
||||||
|
|
||||||
|
@ -51,6 +51,15 @@ class BooleanPref(
|
||||||
override fun put(editor : SharedPreferences.Editor, v : Boolean) {
|
override fun put(editor : SharedPreferences.Editor, v : Boolean) {
|
||||||
editor.putBoolean(key, v)
|
editor.putBoolean(key, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// put if value is not default, remove if value is same to default
|
||||||
|
fun putOrRemove(editor : SharedPreferences.Editor, v : Boolean) {
|
||||||
|
if( v != defVal) {
|
||||||
|
editor.putBoolean(key, v)
|
||||||
|
}else{
|
||||||
|
editor.remove(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class IntPref(key : String, val defVal : Int) : BasePref<Int>(key) {
|
class IntPref(key : String, val defVal : Int) : BasePref<Int>(key) {
|
||||||
|
@ -460,7 +469,7 @@ object Pref {
|
||||||
|
|
||||||
val bpShowBookmarkButton = BooleanPref(
|
val bpShowBookmarkButton = BooleanPref(
|
||||||
"ShowBookmarkButton",
|
"ShowBookmarkButton",
|
||||||
false,
|
true,
|
||||||
R.id.swShowBookmarkButton
|
R.id.swShowBookmarkButton
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue