aboutsummaryrefslogtreecommitdiff
path: root/library/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/main/kotlin')
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBinder.kt7
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefPlainText.kt27
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefSubItems.kt9
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefText.kt2
4 files changed, 38 insertions, 7 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBinder.kt b/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBinder.kt
index 472c538..89afaab 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBinder.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBinder.kt
@@ -45,7 +45,7 @@ class CoreAttributeBuilder : CoreAttributeContract {
}
interface KPrefActivityContract {
- fun showNextPrefs(@StringRes toolbarTitleRes:Int, builder: KPrefAdapterBuilder.() -> Unit)
+ fun showNextPrefs(@StringRes toolbarTitleRes: Int, builder: KPrefAdapterBuilder.() -> Unit)
fun showPrevPrefs()
fun reloadByTitle(@StringRes vararg title: Int)
}
@@ -94,5 +94,10 @@ class KPrefAdapterBuilder(internal val globalOptions: GlobalOptions) {
= list.add(KPrefSubItems(KPrefSubItems.KPrefSubItemsBuilder(globalOptions, title, itemBuilder)
.apply { builder() }))
+ fun plainText(@StringRes title: Int,
+ builder: KPrefItemBase.BaseContract<Unit>.() -> Unit = {})
+ = list.add(KPrefPlainText(KPrefPlainText.KPrefPlainTextBuilder(globalOptions, title)
+ .apply { builder() }))
+
internal val list: MutableList<KPrefItemCore> = mutableListOf()
} \ No newline at end of file
diff --git a/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefPlainText.kt b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefPlainText.kt
new file mode 100644
index 0000000..9732b98
--- /dev/null
+++ b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefPlainText.kt
@@ -0,0 +1,27 @@
+package ca.allanwang.kau.kpref.items
+
+import android.view.View
+import ca.allanwang.kau.R
+import ca.allanwang.kau.kpref.GlobalOptions
+
+/**
+ * Created by Allan Wang on 2017-06-14.
+ *
+ * Just text with the core options. Extends base preference but has an empty getter and setter
+ *
+ */
+class KPrefPlainText(val builder: KPrefPlainTextBuilder) : KPrefItemBase<Unit>(builder) {
+
+ override fun defaultOnClick(itemView: View, innerContent: View?): Boolean {
+ //nothing
+ return true
+ }
+
+ class KPrefPlainTextBuilder(
+ globalOptions: GlobalOptions,
+ titleRes: Int
+ ) : BaseContract<Unit> by BaseBuilder(globalOptions, titleRes, {}, {})
+
+ override fun getType(): Int = R.id.kau_item_pref_plain_text
+
+} \ No newline at end of file
diff --git a/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefSubItems.kt b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefSubItems.kt
index 8614cb6..51625ab 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefSubItems.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefSubItems.kt
@@ -8,12 +8,11 @@ import ca.allanwang.kau.kpref.KPrefAdapterBuilder
/**
* Created by Allan Wang on 2017-06-14.
*
- * Text preference
- * Holds a textview to display data on the right
- * This is still a generic preference
+ * Sub item preference
+ * When clicked, will navigate to a new set of preferences and add the old list to a stack
*
*/
-class KPrefSubItems(val builder: KPrefSubItemsBuilder) : KPrefItemCore(builder) {
+class KPrefSubItems(val builder: KPrefSubItemsContract) : KPrefItemCore(builder) {
override fun onClick(itemView: View, innerContent: View?): Boolean {
builder.globalOptions.showNextPrefs(builder.titleRes, builder.itemBuilder)
@@ -39,6 +38,6 @@ class KPrefSubItems(val builder: KPrefSubItemsBuilder) : KPrefItemCore(builder)
override val itemBuilder: KPrefAdapterBuilder.() -> Unit
) : KPrefSubItemsContract, CoreContract by CoreBuilder(globalOptions, titleRes)
- override fun getType(): Int = R.id.kau_item_pref_checkbox
+ override fun getType(): Int = R.id.kau_item_pref_sub_item
} \ No newline at end of file
diff --git a/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefText.kt b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefText.kt
index 894f024..8662b6a 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefText.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefText.kt
@@ -57,6 +57,6 @@ class KPrefText<T>(val builder: KPrefTextContract<T>) : KPrefItemBase<T>(builder
override var textGetter: (T) -> String? = { it?.toString() }
}
- override fun getType(): Int = R.id.kau_item_pref_checkbox
+ override fun getType(): Int = R.id.kau_item_pref_text
} \ No newline at end of file