WIP prefs: clickable preference for filters
This commit is contained in:
parent
13f928f057
commit
20e9cc7d5f
|
@ -23,6 +23,7 @@ import android.widget.LinearLayout
|
|||
import android.widget.ScrollView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.keylesspalace.tusky.BaseActivity
|
||||
import com.keylesspalace.tusky.R
|
||||
import com.keylesspalace.tusky.db.AccountManager
|
||||
import com.keylesspalace.tusky.di.Injectable
|
||||
|
@ -32,6 +33,7 @@ import com.keylesspalace.tusky.settings.PrefData
|
|||
import com.keylesspalace.tusky.settings.PrefStore
|
||||
import com.keylesspalace.tusky.settings.PreferenceOption
|
||||
import com.keylesspalace.tusky.settings.PreferenceParent
|
||||
import com.keylesspalace.tusky.settings.clickPreference
|
||||
import com.keylesspalace.tusky.settings.customListPreference
|
||||
import com.keylesspalace.tusky.settings.getBlocking
|
||||
import com.keylesspalace.tusky.settings.listPreference
|
||||
|
@ -98,6 +100,7 @@ class PreferencesFragment : Fragment(), Injectable {
|
|||
this.updateTrigger = makePreferenceScreen(rootLayout) {
|
||||
appearanceCategory()
|
||||
browserCategory()
|
||||
filtersCategory()
|
||||
wellbeingCategory()
|
||||
}
|
||||
return viewRoot
|
||||
|
@ -152,6 +155,19 @@ class PreferencesFragment : Fragment(), Injectable {
|
|||
}
|
||||
}
|
||||
|
||||
private fun PreferenceParent.filtersCategory() {
|
||||
preferenceCategory(R.string.pref_title_timeline_filters) {
|
||||
clickPreference(getString(R.string.pref_title_status_tabs)) {
|
||||
val activity = activity as BaseActivity
|
||||
val intent = PreferencesActivity.newIntent(
|
||||
activity,
|
||||
PreferencesActivity.TAB_FILTER_PREFERENCES
|
||||
)
|
||||
activity.startActivityWithSlideInAnimation(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun PreferenceParent.appearanceCategory() {
|
||||
preferenceCategory(R.string.pref_title_appearance_settings) {
|
||||
val themeOptions = listOf(
|
||||
|
|
|
@ -118,11 +118,9 @@ private fun TextView.setTextColorRef(ref: Int) {
|
|||
setTextColor(ThemeUtils.getColor(context, ref))
|
||||
}
|
||||
|
||||
fun PreferenceParent.switchPreference(
|
||||
private fun PreferenceParent.baseOneLineItemLayout(
|
||||
title: String,
|
||||
isChecked: () -> Boolean,
|
||||
onSelection: (Boolean) -> Unit
|
||||
) {
|
||||
): LinearLayout {
|
||||
val layout = itemLayout(context)
|
||||
val textView = TextView(context).apply {
|
||||
text = title
|
||||
|
@ -140,6 +138,25 @@ fun PreferenceParent.switchPreference(
|
|||
}
|
||||
layout.addView(textView)
|
||||
|
||||
return layout
|
||||
}
|
||||
|
||||
fun PreferenceParent.clickPreference(
|
||||
title: String,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
val layout = baseOneLineItemLayout(title)
|
||||
layout.setOnClickListener { onClick() }
|
||||
addPref(layout)
|
||||
}
|
||||
|
||||
fun PreferenceParent.switchPreference(
|
||||
title: String,
|
||||
isChecked: () -> Boolean,
|
||||
onSelection: (Boolean) -> Unit
|
||||
) {
|
||||
val layout = baseOneLineItemLayout(title)
|
||||
|
||||
val switchLayout = LinearLayout(context).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
gravity = Gravity.CENTER_VERTICAL or Gravity.END
|
||||
|
|
Loading…
Reference in New Issue