diff options
author | Allan Wang <allanwang@google.com> | 2019-07-27 18:59:14 -0700 |
---|---|---|
committer | Allan Wang <allanwang@google.com> | 2019-07-27 18:59:14 -0700 |
commit | 63f6b70cc81ec9dc6e92b6521dfd78fa72fe70a5 (patch) | |
tree | a7fdc9cd1ec78a6bd43c80fec33896a3d427d2b6 /kpref-activity | |
parent | 99f1e76a4d8d35d4d3ca1aadf68bbc227a70ba01 (diff) | |
download | kau-63f6b70cc81ec9dc6e92b6521dfd78fa72fe70a5.tar.gz kau-63f6b70cc81ec9dc6e92b6521dfd78fa72fe70a5.tar.bz2 kau-63f6b70cc81ec9dc6e92b6521dfd78fa72fe70a5.zip |
Fix compile errors
Diffstat (limited to 'kpref-activity')
11 files changed, 62 insertions, 31 deletions
diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt index b701a07..f11afde 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt @@ -32,6 +32,7 @@ import ca.allanwang.kau.utils.resolveColor import ca.allanwang.kau.utils.statusBarColor import ca.allanwang.kau.utils.withLinearAdapter import com.mikepenz.fastadapter.adapters.FastItemAdapter +import com.mikepenz.fastadapter.select.getSelectExtension import kotlinx.android.synthetic.main.kau_pref_activity.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -82,7 +83,8 @@ abstract class KPrefActivity : KauBaseActivity(), KPrefActivityContract { toolbar.setNavigationOnClickListener { onBackPressed() } setDisplayShowTitleEnabled(false) } - window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + window.decorView.systemUiVisibility = + View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN statusBarColor = 0x30000000 kau_toolbar_ripple.set(resolveColor(R.attr.colorPrimary)) kau_ripple.set(resolveColor(android.R.attr.colorBackground)) @@ -92,8 +94,13 @@ abstract class KPrefActivity : KauBaseActivity(), KPrefActivityContract { core.builder() globalOptions = GlobalOptions(core, this) kau_recycler.withLinearAdapter(adapter) - adapter.withSelectable(false) - .withOnClickListener { v, _, item, _ -> item.onClick(v!!); true } + adapter.apply { + getSelectExtension().isSelectable = true + onClickListener = { v, _, item, _ -> + item.onClick(v!!) + true + } + } showNextPrefs(R.string.kau_settings, onCreateKPrefs(savedInstanceState), true) } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt index 0f025a6..f4f4a65 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt @@ -34,7 +34,7 @@ open class KPrefCheckbox(builder: BaseContract<Boolean>) : KPrefItemBase<Boolean (innerView as AppCompatCheckBox).isChecked = pref } - override fun bindView(holder: ViewHolder, payloads: List<Any>) { + override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) { super.bindView(holder, payloads) val checkbox = holder.bindInnerView<CheckBox>(R.layout.kau_pref_checkbox) withAccentColor(checkbox::tint) @@ -42,5 +42,6 @@ open class KPrefCheckbox(builder: BaseContract<Boolean>) : KPrefItemBase<Boolean checkbox.jumpDrawablesToCurrentState() //Cancel the animation } - override fun getType(): Int = R.id.kau_item_pref_checkbox + override val type: Int + get() = R.id.kau_item_pref_checkbox } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt index 8b051c5..76cfbab 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefColorPicker.kt @@ -33,7 +33,7 @@ import com.afollestad.materialdialogs.MaterialDialog */ open class KPrefColorPicker(open val builder: KPrefColorContract) : KPrefItemBase<Int>(builder) { - override fun bindView(holder: ViewHolder, payloads: List<Any>) { + override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) { super.bindView(holder, payloads) if (builder.showPreview) { val preview = holder.bindInnerView<CircleView>(R.layout.kau_pref_color) @@ -63,7 +63,7 @@ open class KPrefColorPicker(open val builder: KPrefColorContract) : KPrefItemBas /** * Extension of the base contract and [ColorContract] along with a showPreview option */ - interface KPrefColorContract : KPrefItemBase.BaseContract<Int>, ColorContract { + interface KPrefColorContract : BaseContract<Int>, ColorContract { var showPreview: Boolean var dialogBuilder: MaterialDialog.() -> Unit } @@ -76,11 +76,13 @@ open class KPrefColorPicker(open val builder: KPrefColorContract) : KPrefItemBas titleId: Int, getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit - ) : KPrefColorContract, KPrefItemBase.BaseContract<Int> by BaseBuilder(globalOptions, titleId, getter, setter), + ) : KPrefColorContract, + BaseContract<Int> by BaseBuilder(globalOptions, titleId, getter, setter), ColorContract by ColorBuilder() { override var showPreview: Boolean = true override var dialogBuilder: MaterialDialog.() -> Unit = {} } - override fun getType(): Int = R.id.kau_item_pref_color_picker + override val type: Int + get() = R.id.kau_item_pref_color_picker } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt index 7d73322..ca70b61 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt @@ -25,12 +25,14 @@ import ca.allanwang.kau.kpref.activity.R */ open class KPrefHeader(builder: CoreContract) : KPrefItemCore(builder) { - override fun getLayoutRes(): Int = R.layout.kau_pref_header + override val layoutRes: Int + get() = R.layout.kau_pref_header - override fun bindView(holder: ViewHolder, payloads: List<Any>) { + override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) { super.bindView(holder, payloads) withAccentColor(holder.title::setTextColor) } - override fun getType() = R.id.kau_item_pref_header + override val type: Int + get() = R.id.kau_item_pref_header } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt index c597b63..9197057 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt @@ -46,7 +46,7 @@ abstract class KPrefItemBase<T>(protected val base: BaseContract<T>) : KPrefItem } @CallSuper - override fun bindView(holder: ViewHolder, payloads: List<Any>) { + override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) { super.bindView(holder, payloads) _enabled = base.enabler() with(holder) { @@ -77,12 +77,14 @@ abstract class KPrefItemBase<T>(protected val base: BaseContract<T>) : KPrefItem super.unbindView(holder) holder.container?.apply { isEnabled = true - background = holder.itemView.context.resolveDrawable(android.R.attr.selectableItemBackground) + background = + holder.itemView.context.resolveDrawable(android.R.attr.selectableItemBackground) alpha = 1.0f } } - final override fun getLayoutRes(): Int = R.layout.kau_pref_core + final override val layoutRes: Int + get() = R.layout.kau_pref_core /** * Extension of the core contract diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt index 36bf670..79b7e82 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt @@ -48,7 +48,7 @@ import com.mikepenz.iconics.typeface.IIcon * Core class containing nothing but the view items */ -abstract class KPrefItemCore(val core: CoreContract) : AbstractItem<KPrefItemCore, KPrefItemCore.ViewHolder>(), KPrefItemActions by core, +abstract class KPrefItemCore(val core: CoreContract) : AbstractItem<KPrefItemCore.ViewHolder>(), KPrefItemActions by core, ThemableIItem by ThemableIItemDelegate() { final override fun getViewHolder(v: View) = ViewHolder(v) @@ -70,7 +70,7 @@ abstract class KPrefItemCore(val core: CoreContract) : AbstractItem<KPrefItemCor */ @SuppressLint("NewApi") @CallSuper - override fun bindView(holder: ViewHolder, payloads: List<Any>) { + override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) { super.bindView(holder, payloads) with(holder) { updateTitle() diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt index 6a0aaf5..7381a07 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt @@ -36,5 +36,6 @@ open class KPrefPlainText(open val builder: KPrefPlainTextBuilder) : KPrefItemBa titleId: Int ) : BaseContract<Unit> by BaseBuilder(globalOptions, titleId, {}, {}) - override fun getType(): Int = R.id.kau_item_pref_plain_text + override val type: Int + get() = R.id.kau_item_pref_plain_text } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt index a582ec4..5de1f83 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt @@ -37,7 +37,7 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase<Int>( override fun KClick<Int>.defaultOnClick() = Unit - override fun bindView(holder: ViewHolder, payloads: List<Any>) { + override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) { super.bindView(holder, payloads) val text = holder.bindInnerView<TextView>(R.layout.kau_pref_seekbar_text) withTextColor(text::setTextColor) @@ -60,7 +60,8 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase<Int>( }) } withAccentColor(seekbar::tint) - text.text = builder.toText(seekbar.progress.fromProgress) //set initial text in case no change occurs + text.text = + builder.toText(seekbar.progress.fromProgress) //set initial text in case no change occurs seekbar.progress = pref.toProgress seekbar.isEnabled = builder.enabler() } @@ -87,7 +88,8 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase<Int>( titleId: Int, getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit - ) : KPrefSeekbarContract, BaseContract<Int> by BaseBuilder(globalOptions, titleId, getter, setter) { + ) : KPrefSeekbarContract, + BaseContract<Int> by BaseBuilder(globalOptions, titleId, getter, setter) { override var min: Int = 0 @@ -118,5 +120,6 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase<Int>( protected inline val Int.fromProgress: Int get() = this * increment + min - override fun getType(): Int = R.id.kau_item_pref_seekbar + override val type: Int + get() = R.id.kau_item_pref_seekbar } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt index 1fa528b..8474627 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt @@ -33,7 +33,8 @@ open class KPrefSubItems(open val builder: KPrefSubItemsContract) : KPrefItemCor builder.globalOptions.showNextPrefs(builder.titleFun(), builder.itemBuilder) } - override fun getLayoutRes(): Int = R.layout.kau_pref_core + override val layoutRes: Int + get() = R.layout.kau_pref_core /** * Extension of the base contract with an optional text getter @@ -51,5 +52,6 @@ open class KPrefSubItems(open val builder: KPrefSubItemsContract) : KPrefItemCor override val itemBuilder: KPrefAdapterBuilder.() -> Unit ) : KPrefSubItemsContract, CoreContract by CoreBuilder(globalOptions, titleId) - override fun getType(): Int = R.id.kau_item_pref_sub_item + override val type: Int + get() = R.id.kau_item_pref_sub_item } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt index 76c9e20..50f0c62 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt @@ -46,7 +46,7 @@ open class KPrefText<T>(open val builder: KPrefTextContract<T>) : KPrefItemBase< context.toast("No click function set") } - override fun bindView(holder: ViewHolder, payloads: List<Any>) { + override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) { super.bindView(holder, payloads) val textView = holder.bindInnerView<TextView>(R.layout.kau_pref_text) withTextColor(textView::setTextColor) @@ -68,9 +68,11 @@ open class KPrefText<T>(open val builder: KPrefTextContract<T>) : KPrefItemBase< titleId: Int, getter: () -> T, setter: KPrefItemActions.(value: T) -> Unit - ) : KPrefTextContract<T>, BaseContract<T> by BaseBuilder<T>(globalOptions, titleId, getter, setter) { + ) : KPrefTextContract<T>, + BaseContract<T> by BaseBuilder<T>(globalOptions, titleId, getter, setter) { override var textGetter: (T) -> String? = { it?.toString() } } - override fun getType(): Int = R.id.kau_item_pref_text + override val type: Int + get() = R.id.kau_item_pref_text } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt index f50397c..318b630 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt @@ -33,7 +33,8 @@ import java.util.Locale */ open class KPrefTimePicker(override val builder: KPrefTimeContract) : KPrefText<Int>(builder) { - interface KPrefTimeContract : KPrefText.KPrefTextContract<Int>, TimePickerDialog.OnTimeSetListener { + interface KPrefTimeContract : KPrefText.KPrefTextContract<Int>, + TimePickerDialog.OnTimeSetListener { var use24HourFormat: Boolean } @@ -50,7 +51,8 @@ open class KPrefTimePicker(override val builder: KPrefTimeContract) : KPrefText< titleId: Int, getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit - ) : KPrefTimeContract, BaseContract<Int> by BaseBuilder(globalOptions, titleId, getter, setter) { + ) : KPrefTimeContract, + BaseContract<Int> by BaseBuilder(globalOptions, titleId, getter, setter) { override var use24HourFormat: Boolean = false @@ -64,11 +66,18 @@ open class KPrefTimePicker(override val builder: KPrefTimeContract) : KPrefText< if (use24HourFormat) String.format(Locale.CANADA, "%d:%02d", hour, min) else - String.format(Locale.CANADA, "%d:%02d %s", hour % 12, min, if (hour >= 12) "PM" else "AM") + String.format( + Locale.CANADA, + "%d:%02d %s", + hour % 12, + min, + if (hour >= 12) "PM" else "AM" + ) } } - override fun getType(): Int = R.id.kau_item_pref_time_picker + override val type: Int + get() = R.id.kau_item_pref_time_picker } private val Int.splitTime: Pair<Int, Int> |