aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/androidTest/kotlin/ca/allanwang/kau/Utils.kt22
-rw-r--r--core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt36
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt47
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBuilder.kt132
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt29
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefFactory.kt37
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt14
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt2
-rw-r--r--core/src/main/res-public/values/public.xml34
-rw-r--r--core/src/test/kotlin/ca/allanwang/kau/kotlin/DebounceTest.kt2
10 files changed, 259 insertions, 96 deletions
diff --git a/core/src/androidTest/kotlin/ca/allanwang/kau/Utils.kt b/core/src/androidTest/kotlin/ca/allanwang/kau/Utils.kt
new file mode 100644
index 0000000..c9d4e31
--- /dev/null
+++ b/core/src/androidTest/kotlin/ca/allanwang/kau/Utils.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2020 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ca.allanwang.kau
+
+import android.content.Context
+import androidx.test.platform.app.InstrumentationRegistry
+
+val context: Context
+ get() = InstrumentationRegistry.getInstrumentation().context
diff --git a/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt b/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt
index 04c6444..70558df 100644
--- a/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt
+++ b/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt
@@ -16,10 +16,10 @@
package ca.allanwang.kau.kpref
import android.annotation.SuppressLint
-import android.content.Context
-import androidx.test.core.app.ApplicationProvider
+import android.content.SharedPreferences
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
+import ca.allanwang.kau.context
import kotlin.test.assertEquals
import org.junit.Before
import org.junit.Test
@@ -33,13 +33,11 @@ import org.junit.runner.RunWith
class KPrefTest {
lateinit var androidPref: TestPref
+ lateinit var androidSp: SharedPreferences
lateinit var memPref: TestPref
- class TestPref(builder: KPrefBuilder) : KPref(builder) {
-
- init {
- initialize(ApplicationProvider.getApplicationContext<Context>(), "kpref_test_${System.currentTimeMillis()}")
- }
+ class TestPref(factory: KPrefFactory) :
+ KPref("kpref_test_${System.currentTimeMillis()}", factory) {
var postSetterCount: Int = 0
@@ -60,9 +58,10 @@ class KPrefTest {
@Before
fun init() {
- androidPref = TestPref(KPrefBuilderAndroid)
- androidPref.sp.edit().clear().commit()
- memPref = TestPref(KPrefBuilderInMemory)
+ androidPref = TestPref(KPrefFactoryAndroid(context))
+ androidSp = (androidPref.builder as KPrefBuilderAndroid).sp
+ androidSp.edit().clear().commit()
+ memPref = TestPref(KPrefFactoryInMemory)
}
private fun pref(action: TestPref.() -> Unit) {
@@ -70,7 +69,11 @@ class KPrefTest {
memPref.action()
}
- private fun <T> assertPrefEquals(expected: T, actual: TestPref.() -> T, message: String? = null) {
+ private fun <T> assertPrefEquals(
+ expected: T,
+ actual: TestPref.() -> T,
+ message: String? = null
+ ) {
assertEquals(expected, androidPref.actual(), "Android KPrefs: $message")
assertEquals(expected, memPref.actual(), "In Mem KPrefs: $message")
}
@@ -83,7 +86,7 @@ class KPrefTest {
assertPrefEquals("hello", { hello })
assertPrefEquals(3, { set.size })
assertPrefEquals(setOf("po", "ta", "to"), { set })
- assertEquals(0, androidPref.sp.all.size, "Defaults should not be set automatically")
+ assertEquals(0, androidSp.all.size, "Defaults should not be set automatically")
}
@Test
@@ -93,8 +96,8 @@ class KPrefTest {
assertPrefEquals(2, { one })
pref { hello = "goodbye" }
assertPrefEquals("goodbye", { hello })
- assertEquals(androidPref.hello, androidPref.sp.getString("hello", "badfallback"))
- assertEquals(2, androidPref.sp.all.size)
+ assertEquals(androidPref.hello, androidSp.getString("hello", "badfallback"))
+ assertEquals(2, androidSp.all.size)
}
@SuppressLint("CommitPrefEdits")
@@ -104,9 +107,10 @@ class KPrefTest {
assertPrefEquals(2, { one })
assertPrefEquals(6, { prefMap.size }, "Prefmap does not have all elements")
pref { reset() } // only invalidates our lazy delegate; doesn't change the actual pref
- assertPrefEquals(2, { one }, "Kpref did not properly fetch from shared prefs")
+ assertEquals(1, memPref.one, "Memory Kpref did not invalidate value")
+ assertEquals(2, androidPref.one, "Android Kpref did not properly fetch from shared prefs")
// Android pref only
- androidPref.sp.edit().putInt("one", -1).commit()
+ androidSp.edit().putInt("one", -1).commit()
assertEquals(2, androidPref.one, "Lazy kpref should still retain old value")
androidPref.reset()
assertEquals(-1, androidPref.one, "Kpref did not refetch from shared prefs upon reset")
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt
index fc7a76a..7f75370 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPref.kt
@@ -15,10 +15,7 @@
*/
package ca.allanwang.kau.kpref
-import android.content.Context
-import android.content.SharedPreferences
import ca.allanwang.kau.kotlin.ILazyResettable
-import ca.allanwang.kau.logging.KL
/**
* Created by Allan Wang on 2017-06-07.
@@ -32,38 +29,36 @@ import ca.allanwang.kau.logging.KL
* Furthermore, all kprefs are held in the [prefMap],
* so if you wish to reset a preference, you must also invalidate the kpref
* from that map
- *
- * You may optionally override [deleteKeys]. This will be called on initialization
- * And delete all keys returned from that method
*/
-open class KPref(builder: KPrefBuilder = KPrefBuilderAndroid) : KPrefBuilder by builder {
-
- lateinit var PREFERENCE_NAME: String
- lateinit var sp: SharedPreferences
+open class KPref private constructor(
+ val preferenceName: String,
+ val builder: KPrefBuilder
+) : KPrefBuilder by builder {
- fun initialize(
- c: Context,
- preferenceName: String,
- sharedPrefs: SharedPreferences = c.applicationContext.getSharedPreferences(preferenceName, Context.MODE_PRIVATE)
- ) {
- PREFERENCE_NAME = preferenceName
- sp = sharedPrefs
- KL.d { "Shared Preference $preferenceName has been initialized" }
- val toDelete = deleteKeys()
- if (toDelete.isNotEmpty()) {
- val edit = sp.edit()
- toDelete.forEach { edit.remove(it) }
- edit.apply()
- }
- }
+ constructor(preferenceName: String, factory: KPrefFactory) : this(
+ preferenceName,
+ factory.createBuilder(preferenceName)
+ )
internal val prefMap: MutableMap<String, ILazyResettable<*>> = mutableMapOf()
+ fun add(entry: KPrefDelegate<*>) {
+ if (prefMap.containsKey(entry.key))
+ throw KPrefException("${entry.key} is already used elsewhere in preference $preferenceName")
+ prefMap[entry.key] = entry
+ }
+
fun reset() {
prefMap.values.forEach { it.invalidate() }
}
operator fun get(key: String): ILazyResettable<*>? = prefMap[key]
- open fun deleteKeys(): Array<String> = arrayOf()
+ /**
+ * Exposed key deletion function from builder.
+ * To avoid recursion, this type uses vararg
+ */
+ fun deleteKeys(vararg keys: String) {
+ deleteKeys(keys)
+ }
}
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBuilder.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBuilder.kt
index 8f6d0c5..7a35ac2 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBuilder.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBuilder.kt
@@ -15,22 +15,44 @@
*/
package ca.allanwang.kau.kpref
+import android.content.SharedPreferences
+
interface KPrefBuilder {
- fun KPref.kpref(key: String, fallback: Boolean, postSetter: (value: Boolean) -> Unit = {}): KPrefDelegate<Boolean>
+ fun KPref.kpref(
+ key: String,
+ fallback: Boolean,
+ postSetter: (value: Boolean) -> Unit = {}
+ ): KPrefDelegate<Boolean>
- fun KPref.kpref(key: String, fallback: Float, postSetter: (value: Float) -> Unit = {}): KPrefDelegate<Float>
+ fun KPref.kpref(
+ key: String,
+ fallback: Float,
+ postSetter: (value: Float) -> Unit = {}
+ ): KPrefDelegate<Float>
@Deprecated(
"Double is not supported in SharedPreferences; cast to float yourself",
ReplaceWith("kpref(key, fallback.toFloat(), postSetter)"),
DeprecationLevel.WARNING
)
- fun KPref.kpref(key: String, fallback: Double, postSetter: (value: Float) -> Unit = {}): KPrefDelegate<Float> =
+ fun KPref.kpref(
+ key: String,
+ fallback: Double,
+ postSetter: (value: Float) -> Unit = {}
+ ): KPrefDelegate<Float> =
kpref(key, fallback.toFloat(), postSetter)
- fun KPref.kpref(key: String, fallback: Int, postSetter: (value: Int) -> Unit = {}): KPrefDelegate<Int>
+ fun KPref.kpref(
+ key: String,
+ fallback: Int,
+ postSetter: (value: Int) -> Unit = {}
+ ): KPrefDelegate<Int>
- fun KPref.kpref(key: String, fallback: Long, postSetter: (value: Long) -> Unit = {}): KPrefDelegate<Long>
+ fun KPref.kpref(
+ key: String,
+ fallback: Long,
+ postSetter: (value: Long) -> Unit = {}
+ ): KPrefDelegate<Long>
fun KPref.kpref(
key: String,
@@ -38,32 +60,97 @@ interface KPrefBuilder {
postSetter: (value: Set<String>) -> Unit = {}
): KPrefDelegate<Set<String>>
- fun KPref.kpref(key: String, fallback: String, postSetter: (value: String) -> Unit = {}): KPrefDelegate<String>
+ fun KPref.kpref(
+ key: String,
+ fallback: String,
+ postSetter: (value: String) -> Unit = {}
+ ): KPrefDelegate<String>
fun KPref.kprefSingle(key: String): KPrefSingleDelegate
+
+ /**
+ * Remove keys from pref so they revert to the default
+ */
+ fun KPref.deleteKeys(keys: Array<out String>)
}
-object KPrefBuilderAndroid : KPrefBuilder {
+class KPrefBuilderAndroid(val sp: SharedPreferences) : KPrefBuilder {
override fun KPref.kpref(key: String, fallback: Boolean, postSetter: (value: Boolean) -> Unit) =
- KPrefDelegateAndroid(key, fallback, this, KPrefBooleanTransaction, postSetter)
+ KPrefDelegateAndroid(
+ key,
+ fallback,
+ this,
+ this@KPrefBuilderAndroid,
+ KPrefBooleanTransaction,
+ postSetter
+ )
override fun KPref.kpref(key: String, fallback: Float, postSetter: (value: Float) -> Unit) =
- KPrefDelegateAndroid(key, fallback, this, KPrefFloatTransaction, postSetter)
+ KPrefDelegateAndroid(
+ key,
+ fallback,
+ this,
+ this@KPrefBuilderAndroid,
+ KPrefFloatTransaction,
+ postSetter
+ )
override fun KPref.kpref(key: String, fallback: Int, postSetter: (value: Int) -> Unit) =
- KPrefDelegateAndroid(key, fallback, this, KPrefIntTransaction, postSetter)
+ KPrefDelegateAndroid(
+ key,
+ fallback,
+ this,
+ this@KPrefBuilderAndroid,
+ KPrefIntTransaction,
+ postSetter
+ )
override fun KPref.kpref(key: String, fallback: Long, postSetter: (value: Long) -> Unit) =
- KPrefDelegateAndroid(key, fallback, this, KPrefLongTransaction, postSetter)
-
- override fun KPref.kpref(key: String, fallback: Set<String>, postSetter: (value: Set<String>) -> Unit) =
- KPrefDelegateAndroid(key, fallback, this, KPrefSetTransaction, postSetter)
+ KPrefDelegateAndroid(
+ key,
+ fallback,
+ this,
+ this@KPrefBuilderAndroid,
+ KPrefLongTransaction,
+ postSetter
+ )
+
+ override fun KPref.kpref(
+ key: String,
+ fallback: Set<String>,
+ postSetter: (value: Set<String>) -> Unit
+ ) =
+ KPrefDelegateAndroid(
+ key,
+ fallback,
+ this,
+ this@KPrefBuilderAndroid,
+ KPrefSetTransaction,
+ postSetter
+ )
override fun KPref.kpref(key: String, fallback: String, postSetter: (value: String) -> Unit) =
- KPrefDelegateAndroid(key, fallback, this, KPrefStringTransaction, postSetter)
-
- override fun KPref.kprefSingle(key: String) = KPrefSingleDelegateAndroid(key, this)
+ KPrefDelegateAndroid(
+ key,
+ fallback,
+ this,
+ this@KPrefBuilderAndroid,
+ KPrefStringTransaction,
+ postSetter
+ )
+
+ override fun KPref.kprefSingle(key: String) =
+ KPrefSingleDelegateAndroid(key, this, this@KPrefBuilderAndroid)
+
+ override fun KPref.deleteKeys(keys: Array<out String>) {
+ // Remove pref listing
+ sp.edit().apply {
+ keys.forEach { remove(it) }
+ }.apply()
+ // Clear cached values
+ keys.forEach { prefMap[it]?.invalidate() }
+ }
}
object KPrefBuilderInMemory : KPrefBuilder {
@@ -80,11 +167,20 @@ object KPrefBuilderInMemory : KPrefBuilder {
override fun KPref.kpref(key: String, fallback: Long, postSetter: (value: Long) -> Unit) =
KPrefDelegateInMemory(key, fallback, this, postSetter)
- override fun KPref.kpref(key: String, fallback: Set<String>, postSetter: (value: Set<String>) -> Unit) =
+ override fun KPref.kpref(
+ key: String,
+ fallback: Set<String>,
+ postSetter: (value: Set<String>) -> Unit
+ ) =
KPrefDelegateInMemory(key, fallback, this, postSetter)
override fun KPref.kpref(key: String, fallback: String, postSetter: (value: String) -> Unit) =
KPrefDelegateInMemory(key, fallback, this, postSetter)
override fun KPref.kprefSingle(key: String) = KPrefSingleDelegateInMemory(key, this)
+
+ override fun KPref.deleteKeys(keys: Array<out String>) {
+ // Clear cached values
+ keys.forEach { prefMap[it]?.invalidate() }
+ }
}
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt
index 684b139..217bc6e 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt
@@ -15,6 +15,7 @@
*/
package ca.allanwang.kau.kpref
+import android.content.SharedPreferences
import ca.allanwang.kau.kotlin.ILazyResettable
/**
@@ -26,29 +27,31 @@ import ca.allanwang.kau.kotlin.ILazyResettable
*/
interface KPrefDelegate<T> : ILazyResettable<T> {
+ val key: String
operator fun setValue(any: Any, property: kotlin.reflect.KProperty<*>, t: T)
}
class KPrefException(message: String) : IllegalAccessException(message)
class KPrefDelegateAndroid<T> internal constructor(
- private val key: String,
+ override val key: String,
private val fallback: T,
private val pref: KPref,
+ private val prefBuilder: KPrefBuilderAndroid,
private val transaction: KPrefTransaction<T>,
private var postSetter: (value: T) -> Unit = {}
) : KPrefDelegate<T> {
private object UNINITIALIZED
+ private val sp: SharedPreferences get() = prefBuilder.sp
+
@Volatile
private var _value: Any? = UNINITIALIZED
private val lock = this
init {
- if (pref.prefMap.containsKey(key))
- throw KPrefException("$key is already used elsewhere in preference ${pref.PREFERENCE_NAME}")
- pref.prefMap[key] = this@KPrefDelegateAndroid
+ pref.add(this)
}
override fun invalidate() {
@@ -67,7 +70,7 @@ class KPrefDelegateAndroid<T> internal constructor(
if (_v2 !== UNINITIALIZED) {
_v2 as T
} else {
- _value = transaction.get(pref.sp, key, fallback)
+ _value = transaction.get(sp, key, fallback)
_value as T
}
}
@@ -75,11 +78,12 @@ class KPrefDelegateAndroid<T> internal constructor(
override fun isInitialized(): Boolean = _value !== UNINITIALIZED
- override fun toString(): String = if (isInitialized()) value.toString() else "Lazy kPref $key not initialized yet."
+ override fun toString(): String =
+ if (isInitialized()) value.toString() else "Lazy kPref $key not initialized yet."
override operator fun setValue(any: Any, property: kotlin.reflect.KProperty<*>, t: T) {
_value = t
- val editor = pref.sp.edit()
+ val editor = sp.edit()
transaction.set(editor, key, t)
editor.apply()
postSetter(t)
@@ -87,7 +91,7 @@ class KPrefDelegateAndroid<T> internal constructor(
}
class KPrefDelegateInMemory<T> internal constructor(
- private val key: String,
+ override val key: String,
private val fallback: T,
private val pref: KPref,
private var postSetter: (value: T) -> Unit = {}
@@ -100,13 +104,11 @@ class KPrefDelegateInMemory<T> internal constructor(
private val lock = this
init {
- if (pref.prefMap.containsKey(key))
- throw KPrefException("$key is already used elsewhere in preference ${pref.PREFERENCE_NAME}")
- pref.prefMap[key] = this
+ pref.add(this)
}
override fun invalidate() {
- // No op
+ _value = UNINITIALIZED
}
@Suppress("UNCHECKED_CAST")
@@ -129,7 +131,8 @@ class KPrefDelegateInMemory<T> internal constructor(
override fun isInitialized(): Boolean = _value !== UNINITIALIZED
- override fun toString(): String = if (isInitialized()) value.toString() else "Lazy kPref $key not initialized yet."
+ override fun toString(): String =
+ if (isInitialized()) value.toString() else "Lazy kPref $key not initialized yet."
override operator fun setValue(any: Any, property: kotlin.reflect.KProperty<*>, t: T) {
_value = t
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefFactory.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefFactory.kt
new file mode 100644
index 0000000..dd6da29
--- /dev/null
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefFactory.kt
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2020 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ca.allanwang.kau.kpref
+
+import android.content.Context
+
+interface KPrefFactory {
+ fun createBuilder(preferenceName: String): KPrefBuilder
+}
+
+/**
+ * Default factory for Android preferences
+ */
+class KPrefFactoryAndroid(context: Context) : KPrefFactory {
+
+ val context: Context = context.applicationContext
+
+ override fun createBuilder(preferenceName: String): KPrefBuilder =
+ KPrefBuilderAndroid(context.getSharedPreferences(preferenceName, Context.MODE_PRIVATE))
+}
+
+object KPrefFactoryInMemory : KPrefFactory {
+ override fun createBuilder(preferenceName: String): KPrefBuilder = KPrefBuilderInMemory
+}
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt
index ae1f855..9d03a16 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt
@@ -15,6 +15,7 @@
*/
package ca.allanwang.kau.kpref
+import android.content.SharedPreferences
import ca.allanwang.kau.kotlin.ILazyResettable
/**
@@ -29,16 +30,19 @@ interface KPrefSingleDelegate : ILazyResettable<Boolean>
class KPrefSingleDelegateAndroid internal constructor(
private val key: String,
- private val pref: KPref
+ private val pref: KPref,
+ private val prefBuilder: KPrefBuilderAndroid
) : KPrefSingleDelegate {
@Volatile
private var _value: Boolean? = null
private val lock = this
+ private val sp: SharedPreferences get() = prefBuilder.sp
+
init {
if (pref.prefMap.containsKey(key))
- throw KPrefException("$key is already used elsewhere in preference ${pref.PREFERENCE_NAME}")
+ throw KPrefException("$key is already used elsewhere in preference ${pref.preferenceName}")
pref.prefMap[key] = this
}
@@ -57,9 +61,9 @@ class KPrefSingleDelegateAndroid internal constructor(
if (_v2 != null) {
_v2
} else {
- _value = pref.sp.getBoolean(key, true)
+ _value = sp.getBoolean(key, true)
if (_value!!) {
- pref.sp.edit().putBoolean(key, false).apply()
+ sp.edit().putBoolean(key, false).apply()
_value = false
true
} else false
@@ -82,7 +86,7 @@ class KPrefSingleDelegateInMemory internal constructor(
init {
if (pref.prefMap.containsKey(key))
- throw KPrefException("$key is already used elsewhere in preference ${pref.PREFERENCE_NAME}")
+ throw KPrefException("$key is already used elsewhere in preference ${pref.preferenceName}")
pref.prefMap[key] = this
}
diff --git a/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt b/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt
index 9410c4c..a9a97b7 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt
@@ -47,7 +47,7 @@ open class KauLogger(
/**
* Toggle to dictate whether a message should be logged
*/
- var shouldLog: (priority: Int) -> Boolean = { true }
+ var shouldLog: (priority: Int) -> Boolean = { it >= Log.INFO }
) {
inline fun v(message: () -> Any?) = log(Log.VERBOSE, message)
diff --git a/core/src/main/res-public/values/public.xml b/core/src/main/res-public/values/public.xml
index 9f8780e..de08b64 100644
--- a/core/src/main/res-public/values/public.xml
+++ b/core/src/main/res-public/values/public.xml
@@ -1,19 +1,27 @@
<resources xmlns:tools='http://schemas.android.com/tools' tools:ignore='ResourceName'>
<!-- AUTO-GENERATED FILE. DO NOT MODIFY. public.xml is generated by the generatepublicxml gradle task -->
- <public name='kau_slide_in_top' type='anim' />
- <public name='kau_slide_in_left' type='anim' />
- <public name='kau_slide_out_right' type='anim' />
- <public name='kau_slide_out_right_top' type='anim' />
<public name='kau_fade_in' type='anim' />
- <public name='kau_slide_out_top' type='anim' />
- <public name='kau_slide_out_bottom' type='anim' />
<public name='kau_fade_out' type='anim' />
- <public name='kau_slide_out_left' type='anim' />
- <public name='kau_slide_out_left_top' type='anim' />
<public name='kau_slide_in_bottom' type='anim' />
+ <public name='kau_slide_in_left' type='anim' />
<public name='kau_slide_in_right' type='anim' />
- <public name='kau_transparent' type='drawable' />
+ <public name='kau_slide_in_top' type='anim' />
+ <public name='kau_slide_out_bottom' type='anim' />
+ <public name='kau_slide_out_left' type='anim' />
+ <public name='kau_slide_out_left_top' type='anim' />
+ <public name='kau_slide_out_right' type='anim' />
+ <public name='kau_slide_out_right_top' type='anim' />
+ <public name='kau_slide_out_top' type='anim' />
<public name='kau_selectable_white' type='drawable' />
+ <public name='kau_transparent' type='drawable' />
+ <public name='kau_enter_slide_bottom' type='transition' />
+ <public name='kau_enter_slide_left' type='transition' />
+ <public name='kau_enter_slide_right' type='transition' />
+ <public name='kau_enter_slide_top' type='transition' />
+ <public name='kau_exit_slide_bottom' type='transition' />
+ <public name='kau_exit_slide_left' type='transition' />
+ <public name='kau_exit_slide_right' type='transition' />
+ <public name='kau_exit_slide_top' type='transition' />
<public name='kau_shadow_overlay' type='color' />
<public name='kau_activity_horizontal_margin' type='dimen' />
<public name='kau_activity_vertical_margin' type='dimen' />
@@ -106,12 +114,4 @@
<public name='KauSlideInFadeOut' type='style' />
<public name='KauSlideInSlideOutRight' type='style' />
<public name='KauSlideInSlideOutBottom' type='style' />
- <public name='kau_enter_slide_bottom' type='transition' />
- <public name='kau_enter_slide_top' type='transition' />
- <public name='kau_exit_slide_bottom' type='transition' />
- <public name='kau_exit_slide_top' type='transition' />
- <public name='kau_enter_slide_right' type='transition' />
- <public name='kau_exit_slide_right' type='transition' />
- <public name='kau_exit_slide_left' type='transition' />
- <public name='kau_enter_slide_left' type='transition' />
</resources> \ No newline at end of file
diff --git a/core/src/test/kotlin/ca/allanwang/kau/kotlin/DebounceTest.kt b/core/src/test/kotlin/ca/allanwang/kau/kotlin/DebounceTest.kt
index a95c442..530f766 100644
--- a/core/src/test/kotlin/ca/allanwang/kau/kotlin/DebounceTest.kt
+++ b/core/src/test/kotlin/ca/allanwang/kau/kotlin/DebounceTest.kt
@@ -16,6 +16,7 @@
package ca.allanwang.kau.kotlin
import kotlin.test.assertEquals
+import org.junit.Ignore
import org.junit.Test
/**
@@ -47,6 +48,7 @@ class DebounceTest {
}
@Test
+ @Ignore("Pending fix")
fun multipleDebounces() {
var i = 0
val debounce = debounce<Int>(20) { i += it }