aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-07-07 13:48:15 -0700
committerAllan Wang <me@allanwang.ca>2017-07-07 13:48:15 -0700
commitdfda38f585f609a4a0df4b5f21948d6222965b56 (patch)
treea42982ee38c8d6fad83bc927b3055aef789bd987
parent0a635fd19a1673d534d57e76f270981766cf6a2b (diff)
downloadkau-dfda38f585f609a4a0df4b5f21948d6222965b56.tar.gz
kau-dfda38f585f609a4a0df4b5f21948d6222965b56.tar.bz2
kau-dfda38f585f609a4a0df4b5f21948d6222965b56.zip
Create seekbar prefs
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBinder.kt8
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefCheckbox.kt2
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt2
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefHeader.kt2
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt23
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefPlainText.kt2
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefSeekbar.kt110
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefSubItems.kt2
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefText.kt2
-rw-r--r--core/src/main/res/layout/kau_preference.xml25
-rw-r--r--core/src/main/res/layout/kau_preference_checkbox.xml2
-rw-r--r--core/src/main/res/layout/kau_preference_color_preview.xml2
-rw-r--r--core/src/main/res/layout/kau_preference_seekbar.xml8
-rw-r--r--core/src/main/res/layout/kau_preference_seekbar_text.xml12
-rw-r--r--core/src/main/res/layout/kau_preference_text.xml2
-rw-r--r--core/src/main/res/values/ids.xml3
-rw-r--r--docs/Changelog.md44
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt1
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt9
-rw-r--r--sample/src/main/res/values/strings.xml1
-rw-r--r--sample/src/main/res/xml/changelog.xml9
21 files changed, 230 insertions, 41 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBinder.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBinder.kt
index 7f42d2a..974e6cf 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBinder.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBinder.kt
@@ -116,5 +116,13 @@ class KPrefAdapterBuilder(internal val globalOptions: GlobalOptions) {
.apply { builder() }))
@KPrefMarker
+ fun seekbar(@StringRes title: Int,
+ getter: (() -> Int),
+ setter: ((value: Int) -> Unit),
+ builder: KPrefSeekbar.KPrefSeekbarContract.() -> Unit = {})
+ = list.add(KPrefSeekbar(KPrefSeekbar.KPrefSeekbarBuilder(globalOptions, title, getter, setter)
+ .apply { builder() }))
+
+ @KPrefMarker
internal val list: MutableList<KPrefItemCore> = mutableListOf()
} \ No newline at end of file
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefCheckbox.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefCheckbox.kt
index 22cc927..999a718 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefCheckbox.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefCheckbox.kt
@@ -12,7 +12,7 @@ import ca.allanwang.kau.utils.tint
* Checkbox preference
* When clicked, will toggle the preference and the apply the result to the checkbox
*/
-class KPrefCheckbox(builder: BaseContract<Boolean>) : KPrefItemBase<Boolean>(builder) {
+open class KPrefCheckbox(builder: BaseContract<Boolean>) : KPrefItemBase<Boolean>(builder) {
override fun defaultOnClick(itemView: View, innerContent: View?): Boolean {
pref = !pref
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt
index c573939..762bcf4 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefColorPicker.kt
@@ -16,7 +16,7 @@ import ca.allanwang.kau.kpref.KPrefMarker
* ColorPicker preference
* When a color is successfully selected in the dialog, it will be saved as an int
*/
-class KPrefColorPicker(val builder: KPrefColorContract) : KPrefItemBase<Int>(builder) {
+open class KPrefColorPicker(val builder: KPrefColorContract) : KPrefItemBase<Int>(builder) {
override fun onPostBindView(viewHolder: ViewHolder, textColor: Int?, accentColor: Int?) {
super.onPostBindView(viewHolder, textColor, accentColor)
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefHeader.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefHeader.kt
index fa8efff..4068496 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefHeader.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefHeader.kt
@@ -10,7 +10,7 @@ import ca.allanwang.kau.kpref.KPrefMarker
* Header preference
* This view just holds a title and is not clickable. It is styled using the accent color
*/
-class KPrefHeader(builder: CoreContract) : KPrefItemCore(builder) {
+open class KPrefHeader(builder: CoreContract) : KPrefItemCore(builder) {
override fun getLayoutRes(): Int = R.layout.kau_preference_header
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt
index 5f684ba..18d1bae 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt
@@ -67,7 +67,8 @@ abstract class KPrefItemCore(val core: CoreContract) : AbstractItem<KPrefItemCor
title.text = null
desc?.text = null
icon?.setImageDrawable(null)
-// innerFrame?.removeAllViews()
+ innerFrame?.removeAllViews()
+ lowerFrame?.removeAllViews()
}
}
@@ -107,19 +108,35 @@ abstract class KPrefItemCore(val core: CoreContract) : AbstractItem<KPrefItemCor
val desc: TextView? by bindOptionalView(R.id.kau_pref_desc)
val icon: ImageView? by bindOptionalView(R.id.kau_pref_icon)
val innerFrame: LinearLayout? by bindOptionalView(R.id.kau_pref_inner_frame)
+ val lowerFrame: LinearLayout? by bindOptionalView(R.id.kau_pref_lower_frame)
val innerContent: View?
get() = itemView.findViewById(R.id.kau_pref_inner_content)
+ val lowerContent: View?
+ get() = itemView.findViewById(R.id.kau_pref_lower_content)
+
+ inline fun <reified T : View> bindInnerView(@LayoutRes id: Int) = bindInnerView(id) { _: T -> }
- inline fun <reified T : View> bindInnerView(@LayoutRes id: Int): T {
+ inline fun <reified T : View> bindInnerView(@LayoutRes id: Int, onFirstBind: (T) -> Unit): T {
if (innerFrame == null) throw IllegalStateException("Cannot bind inner view when innerFrame does not exist")
if (innerContent !is T) {
innerFrame!!.removeAllViews()
LayoutInflater.from(innerFrame!!.context).inflate(id, innerFrame)
+ onFirstBind(innerContent as T)
}
return innerContent as T
}
- inline fun <reified T : View> getInnerView() = innerContent as T
+ inline fun <reified T : View> bindLowerView(@LayoutRes id: Int) = bindLowerView(id) { _: T -> }
+
+ inline fun <reified T : View> bindLowerView(@LayoutRes id: Int, onFirstBind: (T) -> Unit): T {
+ if (lowerFrame == null) throw IllegalStateException("Cannot bind inner view when lowerContent does not exist")
+ if (lowerContent !is T) {
+ lowerFrame!!.removeAllViews()
+ LayoutInflater.from(lowerFrame!!.context).inflate(id, lowerFrame)
+ onFirstBind(lowerContent as T)
+ }
+ return lowerContent as T
+ }
operator fun get(@IdRes id: Int): View = itemView.findViewById(id)
}
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefPlainText.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefPlainText.kt
index a782430..6f7adf8 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefPlainText.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefPlainText.kt
@@ -12,7 +12,7 @@ import ca.allanwang.kau.kpref.GlobalOptions
* and when the preference is completely handled by the click
*
*/
-class KPrefPlainText(val builder: KPrefPlainTextBuilder) : KPrefItemBase<Unit>(builder) {
+open class KPrefPlainText(val builder: KPrefPlainTextBuilder) : KPrefItemBase<Unit>(builder) {
override fun defaultOnClick(itemView: View, innerContent: View?): Boolean {
//nothing
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefSeekbar.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefSeekbar.kt
new file mode 100644
index 0000000..a6897a3
--- /dev/null
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefSeekbar.kt
@@ -0,0 +1,110 @@
+package ca.allanwang.kau.kpref.items
+
+import android.view.View
+import android.widget.SeekBar
+import android.widget.TextView
+import ca.allanwang.kau.R
+import ca.allanwang.kau.kpref.GlobalOptions
+import ca.allanwang.kau.kpref.KPrefException
+import ca.allanwang.kau.logging.KL
+import ca.allanwang.kau.utils.tint
+
+/**
+ * Created by Allan Wang on 2017-06-07.
+ *
+ * Checkbox preference
+ * When clicked, will toggle the preference and the apply the result to the checkbox
+ */
+open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase<Int>(builder) {
+
+
+ override fun defaultOnClick(itemView: View, innerContent: View?): Boolean = false
+
+ override fun onPostBindView(viewHolder: ViewHolder, textColor: Int?, accentColor: Int?) {
+ super.onPostBindView(viewHolder, textColor, accentColor)
+ val text = viewHolder.bindInnerView<TextView>(R.layout.kau_preference_seekbar_text)
+ if (textColor != null) text.setTextColor(textColor)
+ val tvc = builder.textViewConfigs
+
+ text.tvc()
+ val seekbar = viewHolder.bindLowerView<SeekBar>(R.layout.kau_preference_seekbar) {
+ it.max = builder.range
+ it.incrementProgressBy(builder.increments)
+ it.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
+ override fun onProgressChanged(sb: SeekBar, progress: Int, fromUser: Boolean) {
+ text.text = builder.toText(progress.fromProgress)
+ }
+
+ override fun onStartTrackingTouch(sb: SeekBar) {
+
+ }
+
+ override fun onStopTrackingTouch(sb: SeekBar) {
+ val trueProgress = sb.progress.fromProgress
+ pref = trueProgress
+ KL.d("New pref $trueProgress")
+ }
+ })
+ }
+ if (accentColor != null) seekbar.tint(accentColor)
+ seekbar.progress = pref.toProgress
+ }
+
+ /**
+ * Extension of the base contract
+ */
+ interface KPrefSeekbarContract : BaseContract<Int> {
+ var min: Int
+ var max: Int
+ var increments: Int
+ var range: Int
+ /**
+ * Once a seekbar is let go, calculates what text to show in the text view
+ */
+ var toText: (Int) -> String
+ var textViewConfigs: TextView.() -> Unit
+ }
+
+ /**
+ * Default implementation of [KPrefSeekbarContract]
+ */
+ class KPrefSeekbarBuilder(
+ globalOptions: GlobalOptions,
+ titleRes: Int,
+ getter: () -> Int,
+ setter: (value: Int) -> Unit
+ ) : KPrefSeekbarContract, BaseContract<Int> by BaseBuilder(globalOptions, titleRes, getter, setter) {
+
+ override var min: Int = 0
+ set(value) {
+ field = value
+ range = -1
+ }
+ override var max: Int = 100
+ set(value) {
+ field = value
+ range = -1
+ }
+ override var increments: Int = 1
+
+ override var range: Int = max - min
+ //value doesn't matter; setting will prompt the check
+ set(value) {
+ if (max <= min) throw KPrefException("Range min ($min) must be smaller than max ($max)")
+ field = max - min
+ }
+
+ override var toText: (Int) -> String = { it.toString() }
+
+ override var textViewConfigs: TextView.() -> Unit = {}
+ }
+
+ val Int.toProgress: Int
+ get() = this - builder.min
+
+ val Int.fromProgress: Int
+ get() = this + builder.min
+
+ override fun getType(): Int = R.id.kau_item_pref_seekbar
+
+} \ No newline at end of file
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefSubItems.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefSubItems.kt
index 51625ab..f373ec4 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefSubItems.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefSubItems.kt
@@ -12,7 +12,7 @@ import ca.allanwang.kau.kpref.KPrefAdapterBuilder
* When clicked, will navigate to a new set of preferences and add the old list to a stack
*
*/
-class KPrefSubItems(val builder: KPrefSubItemsContract) : KPrefItemCore(builder) {
+open class KPrefSubItems(val builder: KPrefSubItemsContract) : KPrefItemCore(builder) {
override fun onClick(itemView: View, innerContent: View?): Boolean {
builder.globalOptions.showNextPrefs(builder.titleRes, builder.itemBuilder)
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefText.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefText.kt
index 8662b6a..9c44cd4 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefText.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefText.kt
@@ -14,7 +14,7 @@ import ca.allanwang.kau.utils.toast
* This is still a generic preference
*
*/
-class KPrefText<T>(val builder: KPrefTextContract<T>) : KPrefItemBase<T>(builder) {
+open class KPrefText<T>(val builder: KPrefTextContract<T>) : KPrefItemBase<T>(builder) {
/**
* Automatically reload on set
diff --git a/core/src/main/res/layout/kau_preference.xml b/core/src/main/res/layout/kau_preference.xml
index c49951b..7ee4f01 100644
--- a/core/src/main/res/layout/kau_preference.xml
+++ b/core/src/main/res/layout/kau_preference.xml
@@ -40,7 +40,7 @@
android:id="@+id/kau_pref_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
- android:layout_marginTop="16dp"
+ android:layout_marginTop="@dimen/kau_padding_normal"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceListItem"
android:textColor="?android:attr/textColorPrimary"
@@ -49,23 +49,36 @@
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@id/kau_pref_icon"
app:layout_constraintTop_toTopOf="parent"
- app:layout_goneMarginBottom="16dp"
+ app:layout_goneMarginBottom="@dimen/kau_padding_normal"
tools:layout_editor_absoluteX="-175dp" />
<TextView
android:id="@id/kau_pref_desc"
android:layout_width="0dp"
android:layout_height="wrap_content"
- android:layout_marginBottom="16dp"
android:ellipsize="end"
android:maxLines="10"
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="?android:attr/textColorSecondary"
- app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintBottom_toTopOf="@+id/kau_pref_lower_frame"
app:layout_constraintEnd_toStartOf="@id/kau_pref_inner_frame"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@id/kau_pref_icon"
app:layout_constraintTop_toBottomOf="@id/kau_pref_title"
+ app:layout_goneMarginBottom="@dimen/kau_padding_normal"
+ tools:layout_editor_absoluteX="-175dp" />
+
+ <LinearLayout
+ android:id="@id/kau_pref_lower_frame"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/kau_padding_normal"
+ android:orientation="vertical"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toStartOf="@id/kau_pref_inner_frame"
+ app:layout_constraintHorizontal_bias="0"
+ app:layout_constraintStart_toEndOf="@id/kau_pref_icon"
+ app:layout_constraintTop_toBottomOf="@id/kau_pref_desc"
tools:layout_editor_absoluteX="-175dp" />
<android.support.constraint.Barrier
@@ -73,7 +86,7 @@
android:layout_width="1dp"
android:layout_height="wrap_content"
app:barrierDirection="end"
- app:constraint_referenced_ids="kau_pref_title,kau_pref_desc"
+ app:constraint_referenced_ids="kau_pref_title,kau_pref_desc,kau_pref_lower_frame"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@@ -83,7 +96,7 @@
android:layout_height="0dp"
android:gravity="center_vertical|end"
android:orientation="horizontal"
- android:paddingStart="16dp"
+ android:paddingStart="@dimen/kau_padding_normal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
diff --git a/core/src/main/res/layout/kau_preference_checkbox.xml b/core/src/main/res/layout/kau_preference_checkbox.xml
index 5ab368b..016394f 100644
--- a/core/src/main/res/layout/kau_preference_checkbox.xml
+++ b/core/src/main/res/layout/kau_preference_checkbox.xml
@@ -1,5 +1,5 @@
<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/kau_pref_inner_content"
+ android:id="@id/kau_pref_inner_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
diff --git a/core/src/main/res/layout/kau_preference_color_preview.xml b/core/src/main/res/layout/kau_preference_color_preview.xml
index 2374971..18ca35a 100644
--- a/core/src/main/res/layout/kau_preference_color_preview.xml
+++ b/core/src/main/res/layout/kau_preference_color_preview.xml
@@ -1,5 +1,5 @@
<ca.allanwang.kau.dialogs.color.CircleView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/kau_pref_inner_content"
+ android:id="@id/kau_pref_inner_content"
android:layout_width="40dp"
android:layout_height="40dp"
android:focusable="false"
diff --git a/core/src/main/res/layout/kau_preference_seekbar.xml b/core/src/main/res/layout/kau_preference_seekbar.xml
new file mode 100644
index 0000000..8da4d5d
--- /dev/null
+++ b/core/src/main/res/layout/kau_preference_seekbar.xml
@@ -0,0 +1,8 @@
+<SeekBar xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@id/kau_pref_lower_content"
+ android:layout_width="match_parent"
+ android:paddingTop="@dimen/kau_padding_normal"
+ android:layout_height="wrap_content"
+ android:focusable="false"
+ android:clickable="false"
+ android:background="@null" /> \ No newline at end of file
diff --git a/core/src/main/res/layout/kau_preference_seekbar_text.xml b/core/src/main/res/layout/kau_preference_seekbar_text.xml
new file mode 100644
index 0000000..6ba2543
--- /dev/null
+++ b/core/src/main/res/layout/kau_preference_seekbar_text.xml
@@ -0,0 +1,12 @@
+<!--TextView that aligns to the bottom-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@id/kau_pref_inner_content"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
+ android:background="@null"
+ android:clickable="false"
+ android:focusable="false"
+ android:gravity="bottom|end"
+ android:paddingBottom="@dimen/kau_padding_normal" /> \ No newline at end of file
diff --git a/core/src/main/res/layout/kau_preference_text.xml b/core/src/main/res/layout/kau_preference_text.xml
index bbabdfb..a4d901e 100644
--- a/core/src/main/res/layout/kau_preference_text.xml
+++ b/core/src/main/res/layout/kau_preference_text.xml
@@ -1,5 +1,5 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/kau_pref_inner_content"
+ android:id="@id/kau_pref_inner_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
diff --git a/core/src/main/res/values/ids.xml b/core/src/main/res/values/ids.xml
index dd42392..0b4322c 100644
--- a/core/src/main/res/values/ids.xml
+++ b/core/src/main/res/values/ids.xml
@@ -4,6 +4,7 @@
<item name="kau_item_pref_header" type="id" />
<item name="kau_item_pref_text" type="id" />
<item name="kau_item_pref_checkbox" type="id" />
+ <item name="kau_item_pref_seekbar" type="id" />
<item name="kau_item_pref_color_picker" type="id" />
<item name="kau_item_pref_sub_item" type="id" />
<item name="kau_item_pref_plain_text" type="id" />
@@ -13,4 +14,6 @@
<item name="kau_item_card" type="id" />
<item name="kau_item_library" type="id" />
<item name="kau_item_about_main" type="id" />
+ <item name="kau_pref_inner_content" type="id" />
+ <item name="kau_pref_lower_content" type="id" />
</resources> \ No newline at end of file
diff --git a/docs/Changelog.md b/docs/Changelog.md
index 9161280..7e99a63 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -1,26 +1,30 @@
# Changelog
+## v1.6
+
## v1.5
* Change snackbar builder
* Change addBundle to withArguments to match ANKO
-* Created KauIItem to replace AbstractItem
-* Created permission manager and permission constants
+* Create KauIItem to replace AbstractItem
+* Create permission manager and permission constants
+* Create swipe, a very simple helper to allow for activities to be dismissed with gestures
+* Create network utils
## v1.4
-* Added about activities
-* Added themed fast item imageAdapter
-* Added chained imageAdapter
-* Added item animators
-* Ported some views over from Plaid
+* Add about activities
+* Add themed fast item imageAdapter
+* Add chained imageAdapter
+* Add item animators
+* Port some views over from Plaid
* Add string arg option for sendEmail
* Add many iitems
## v1.3
-* Added kpref subitems
-* Added DSL markers
-* Added transition utils and other utils
-* Added custom searchview with binders
-* Added KauBoundedCardView
+* Add kpref subitems
+* Add DSL markers
+* Add transition utils and other utils
+* Add custom searchview with binders
+* Add KauBoundedCardView
## v1.2
* Fix title attribute in changelog
@@ -29,14 +33,14 @@
* Add email builder
## v1.1
-* Created kpref items
-* Attached source files
-* Created color dialog
-* Added more utilities
-* Fixed indexStack clearing when starting activity
+* Create kpref items
+* Attach source files
+* Create color dialog
+* Add more utilities
+* Fix indexStack clearing when starting activity
## v1.0
* Initial Changelog
-* Created many extension functions
-* Ported changelog builer
-* Ported ripple canvas
+* Create many extension functions
+* Port changelog builer
+* Port ripple canvas
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt
index a0fbc59..1bbcc47 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt
@@ -15,4 +15,5 @@ object KPrefSample : KPref() {
var check2: Boolean by kpref("check2", false)
var check3: Boolean by kpref("check3", false)
var text: String by kpref("text", "empty")
+ var seekbar: Int by kpref("seekbar", 20)
} \ No newline at end of file
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
index 899a50e..e63f107 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
@@ -143,6 +143,13 @@ class MainActivity : KPrefActivity() {
}
}
+ seekbar(R.string.seekbar, { KPrefSample.seekbar }, { KPrefSample.seekbar = it }) {
+ descRes = R.string.kau_lorem_ipsum
+ textViewConfigs = {
+ minEms = 2
+ }
+ }
+
subItems(R.string.sub_item, subPrefs()) {
descRes = R.string.sub_item_desc
}
@@ -158,7 +165,7 @@ class MainActivity : KPrefActivity() {
}
fun subPrefs(): KPrefAdapterBuilder.() -> Unit = {
- text<String>(R.string.text, { KPrefSample.text }, { KPrefSample.text = it }) {
+ text(R.string.text, { KPrefSample.text }, { KPrefSample.text = it }) {
descRes = R.string.text_desc
onClick = {
itemView, _, item ->
diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml
index a2f1b58..0be46ec 100644
--- a/sample/src/main/res/values/strings.xml
+++ b/sample/src/main/res/values/strings.xml
@@ -15,6 +15,7 @@
<string name="color_custom_alpha">This selector allows for custom colors with alpha values</string>
<string name="text">Text Pref</string>
<string name="text_desc">Saves the text</string>
+ <string name="seekbar">Seekbar</string>
<string name="sub_item">Sub Item Pref</string>
<string name="sub_item_desc">Press this to view the next subset of preferences</string>
<string name="your_email">your.email@here.com</string>
diff --git a/sample/src/main/res/xml/changelog.xml b/sample/src/main/res/xml/changelog.xml
index 7801511..7d79ad5 100644
--- a/sample/src/main/res/xml/changelog.xml
+++ b/sample/src/main/res/xml/changelog.xml
@@ -6,6 +6,13 @@
<item text="" />
-->
+ <version title="v1.6"/>
+ <item text="" />
+ <item text="" />
+ <item text="" />
+ <item text="" />
+ <item text="" />
+
<version title="v1.5"/>
<item text="Change snackbar builder" />
<item text="Change addBundle to withArguments to match ANKO" />
@@ -13,8 +20,6 @@
<item text="Create permission manager and permission constants" />
<item text="Create swipe, a very simple helper to allow for activities to be dismissed with gestures" />
<item text="Create network utils" />
- <item text="" />
- <item text="" />
<version title="v1.4"/>
<item text="Add about activities" />