diff options
author | Allan Wang <me@allanwang.ca> | 2021-10-24 17:45:09 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2021-10-24 17:45:09 -0700 |
commit | 222709bc15ace77ebf03e5a8e17e0bf026520970 (patch) | |
tree | 802f80dc3e6956b9e8bdf15f4d265f3b863fa58d /core | |
parent | 8c95d32ce4a82ec00590c428d163a3604b7d44ec (diff) | |
download | kau-222709bc15ace77ebf03e5a8e17e0bf026520970.tar.gz kau-222709bc15ace77ebf03e5a8e17e0bf026520970.tar.bz2 kau-222709bc15ace77ebf03e5a8e17e0bf026520970.zip |
Many version bumps
Diffstat (limited to 'core')
20 files changed, 83 insertions, 64 deletions
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 70558df..77a3b62 100644 --- a/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt +++ b/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt @@ -20,10 +20,10 @@ 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 import org.junit.runner.RunWith +import kotlin.test.assertEquals /** * Created by Allan Wang on 2017-08-01. @@ -45,9 +45,12 @@ class KPrefTest { var two by kpref("two", 2f) - var `true` by kpref("true", true, postSetter = { - postSetterCount++ - }) + var `true` by kpref( + "true", true, + postSetter = { + postSetterCount++ + } + ) var hello by kpref("hello", "hello") diff --git a/core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt b/core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt index 5e4688b..96ebd3a 100644 --- a/core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt +++ b/core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt @@ -22,12 +22,12 @@ import android.widget.TextView import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.MediumTest import androidx.test.platform.app.InstrumentationRegistry -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertNull import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import kotlin.test.assertEquals +import kotlin.test.assertNotNull +import kotlin.test.assertNull /** * Created by Allan Wang on 2017-07-30. diff --git a/core/src/androidTest/kotlin/ca/allanwang/kau/utils/UtilsAndroidTest.kt b/core/src/androidTest/kotlin/ca/allanwang/kau/utils/UtilsAndroidTest.kt index ffd903c..665e0b2 100644 --- a/core/src/androidTest/kotlin/ca/allanwang/kau/utils/UtilsAndroidTest.kt +++ b/core/src/androidTest/kotlin/ca/allanwang/kau/utils/UtilsAndroidTest.kt @@ -17,9 +17,9 @@ package ca.allanwang.kau.utils import android.graphics.Color import androidx.test.ext.junit.runners.AndroidJUnit4 -import kotlin.test.assertEquals import org.junit.Test import org.junit.runner.RunWith +import kotlin.test.assertEquals /** * Created by Allan Wang on 2018-12-24. diff --git a/core/src/androidTest/kotlin/ca/allanwang/kau/xml/FaqTest.kt b/core/src/androidTest/kotlin/ca/allanwang/kau/xml/FaqTest.kt index a98e254..7ec2a41 100644 --- a/core/src/androidTest/kotlin/ca/allanwang/kau/xml/FaqTest.kt +++ b/core/src/androidTest/kotlin/ca/allanwang/kau/xml/FaqTest.kt @@ -20,9 +20,9 @@ import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.MediumTest import ca.allanwang.kau.test.R -import kotlin.test.assertEquals import org.junit.Test import org.junit.runner.RunWith +import kotlin.test.assertEquals /** * Created by Allan Wang on 2017-08-01. diff --git a/core/src/main/kotlin/ca/allanwang/kau/internal/KauBaseActivity.kt b/core/src/main/kotlin/ca/allanwang/kau/internal/KauBaseActivity.kt index 6fb8f1f..cb8f4bf 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/internal/KauBaseActivity.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/internal/KauBaseActivity.kt @@ -19,10 +19,10 @@ import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import ca.allanwang.kau.permissions.kauOnRequestPermissionsResult import ca.allanwang.kau.utils.ContextHelper -import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.SupervisorJob +import kotlin.coroutines.CoroutineContext /** * Created by Allan Wang on 2017-08-01. 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 a9a97b7..1475720 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/logging/KauLogger.kt @@ -113,14 +113,18 @@ class KauLoggerExtension(val tag: String, val logger: KauLogger) { } inline fun log(priority: Int, message: () -> Any?, t: Throwable? = null) = - logger.log(priority, { - val msg = message()?.toString() - if (msg == null) { - null - } else { - "$tag: $msg" - } - }, t) + logger.log( + priority, + { + val msg = message()?.toString() + if (msg == null) { + null + } else { + "$tag: $msg" + } + }, + t + ) inline fun checkThread(id: Int) { d { diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/RelativeSlider.kt b/core/src/main/kotlin/ca/allanwang/kau/swipe/RelativeSlider.kt index e3baa94..78bf253 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/swipe/RelativeSlider.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/RelativeSlider.kt @@ -48,14 +48,18 @@ internal class RelativeSlider(var curPage: SwipeBackPage) : SwipeListener { return } when (edgeFlag) { - SWIPE_EDGE_LEFT -> page.swipeBackLayout.x = - min(-offset * max(1 - percent, 0f) + DEFAULT_OFFSET, 0f) - SWIPE_EDGE_RIGHT -> page.swipeBackLayout.x = - min(offset * max(1 - percent, 0f) - DEFAULT_OFFSET, 0f) - SWIPE_EDGE_TOP -> page.swipeBackLayout.y = - min(-offset * max(1 - percent, 0f) + DEFAULT_OFFSET, 0f) - SWIPE_EDGE_BOTTOM -> page.swipeBackLayout.y = - min(offset * max(1 - percent, 0f) - DEFAULT_OFFSET, 0f) + SWIPE_EDGE_LEFT -> + page.swipeBackLayout.x = + min(-offset * max(1 - percent, 0f) + DEFAULT_OFFSET, 0f) + SWIPE_EDGE_RIGHT -> + page.swipeBackLayout.x = + min(offset * max(1 - percent, 0f) - DEFAULT_OFFSET, 0f) + SWIPE_EDGE_TOP -> + page.swipeBackLayout.y = + min(-offset * max(1 - percent, 0f) + DEFAULT_OFFSET, 0f) + SWIPE_EDGE_BOTTOM -> + page.swipeBackLayout.y = + min(offset * max(1 - percent, 0f) - DEFAULT_OFFSET, 0f) } } diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/AnimUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/AnimUtils.kt index c8c8b34..0c1475a 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/AnimUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/AnimUtils.kt @@ -166,10 +166,13 @@ fun View.fadeOut( @KauUtils fun TextView.setTextWithFade(text: String, duration: Long = 200, onFinish: (() -> Unit)? = null) { - fadeOut(duration = duration, onFinish = { - setText(text) - fadeIn(duration = duration, onFinish = onFinish) - }) + fadeOut( + duration = duration, + onFinish = { + setText(text) + fadeIn(duration = duration, onFinish = onFinish) + } + ) } @KauUtils diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt index b857eb0..6dab5cf 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt @@ -93,9 +93,12 @@ fun bundleOf(vararg params: kotlin.Pair<String, Any?>): Bundle { * create a scene transition animation */ fun Bundle.withSceneTransitionAnimation(parent: View, data: Map<Int, String>) = - withSceneTransitionAnimation(parent.context, data.mapKeys { (id, _) -> - parent.findViewById<View>(id) - }) + withSceneTransitionAnimation( + parent.context, + data.mapKeys { (id, _) -> + parent.findViewById<View>(id) + } + ) /** * Given a mapping of views to tags, diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt index 0131302..29c0919 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt @@ -89,9 +89,11 @@ fun Int.isColorVisibleOn( @IntRange(from = 0L, to = 255L) minAlpha: Int = 50 ): Boolean = if (Color.alpha(this) < minAlpha) false - else !(abs(Color.red(this) - Color.red(color)) < delta && - abs(Color.green(this) - Color.green(color)) < delta && - abs(Color.blue(this) - Color.blue(color)) < delta) + else !( + abs(Color.red(this) - Color.red(color)) < delta && + abs(Color.green(this) - Color.green(color)) < delta && + abs(Color.blue(this) - Color.blue(color)) < delta + ) @ColorInt fun Context.getDisabledColor(): Int { diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt index 7d4a934..e797cfc 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt @@ -57,9 +57,9 @@ inline fun <reified T : Activity> Context.startActivity( ) = startActivity(T::class.java, clearStack, bundleBuilder, intentBuilder) @Deprecated( - "Use reified generic instead of passing class", - ReplaceWith("startActivity<T>(clearStack, bundleBuilder, intentBuilder)"), - DeprecationLevel.WARNING + "Use reified generic instead of passing class", + ReplaceWith("startActivity<T>(clearStack, bundleBuilder, intentBuilder)"), + DeprecationLevel.WARNING ) inline fun <T : Activity> Context.startActivity( clazz: Class<T>, @@ -120,13 +120,13 @@ fun Context.startLink(@StringRes url: Int): Boolean = startLink(string(url)) // Toast helpers inline fun View.toast(@StringRes id: Int, duration: Int = Toast.LENGTH_LONG, log: Boolean = false) = - context.toast(id, duration, log) + context.toast(id, duration, log) inline fun Context.toast(@StringRes id: Int, duration: Int = Toast.LENGTH_LONG, log: Boolean = false) = - toast(this.string(id), duration, log) + toast(this.string(id), duration, log) inline fun View.toast(text: String, duration: Int = Toast.LENGTH_LONG, log: Boolean = false) = - context.toast(text, duration, log) + context.toast(text, duration, log) inline fun Context.toast(text: String, duration: Int = Toast.LENGTH_LONG, log: Boolean = false) { Toast.makeText(this, text, duration).show() @@ -139,10 +139,10 @@ const val INVALID_ID = 0 inline fun Context.string(@StringRes id: Int): String = getString(id) inline fun Context.string(@StringRes id: Int, fallback: String?): String? = - if (id != INVALID_ID) string(id) else fallback + if (id != INVALID_ID) string(id) else fallback inline fun Context.string(@StringRes id: Int, fallback: () -> String?): String? = - if (id != INVALID_ID) string(id) else fallback() + if (id != INVALID_ID) string(id) else fallback() inline fun Context.color(@ColorRes id: Int): Int = ContextCompat.getColor(this, id) inline fun Context.boolean(@BoolRes id: Int): Boolean = resources.getBoolean(id) @@ -150,13 +150,13 @@ inline fun Context.integer(@IntegerRes id: Int): Int = resources.getInteger(id) inline fun Context.dimen(@DimenRes id: Int): Float = resources.getDimension(id) inline fun Context.dimenPixelSize(@DimenRes id: Int): Int = resources.getDimensionPixelSize(id) inline fun Context.drawable(@DrawableRes id: Int): Drawable = ContextCompat.getDrawable(this, id) - ?: throw KauException("Drawable with id $id not found") + ?: throw KauException("Drawable with id $id not found") inline fun Context.drawable(@DrawableRes id: Int, fallback: Drawable?): Drawable? = - if (id != INVALID_ID) drawable(id) else fallback + if (id != INVALID_ID) drawable(id) else fallback inline fun Context.drawable(@DrawableRes id: Int, fallback: () -> Drawable?): Drawable? = - if (id != INVALID_ID) drawable(id) else fallback() + if (id != INVALID_ID) drawable(id) else fallback() inline fun Context.interpolator(@InterpolatorRes id: Int) = AnimationUtils.loadInterpolator(this, id)!! inline fun Context.animation(@AnimRes id: Int) = AnimationUtils.loadAnimation(this, id)!! @@ -165,7 +165,7 @@ inline fun Context.animation(@AnimRes id: Int) = AnimationUtils.loadAnimation(th * Returns plural form of res. The quantity is also passed to the formatter as an int */ inline fun Context.plural(@PluralsRes id: Int, quantity: Number) = - resources.getQuantityString(id, quantity.toInt(), quantity.toInt()) + resources.getQuantityString(id, quantity.toInt(), quantity.toInt()) // Attr retrievers fun Context.resolveColor(@AttrRes attr: Int, @ColorInt fallback: Int = 0): Int { @@ -221,7 +221,7 @@ inline fun Context.materialDialog( } fun Context.getDip(value: Float): Float = - TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, resources.displayMetrics) + TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, resources.displayMetrics) inline val Context.isRtl: Boolean get() = resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL @@ -239,8 +239,8 @@ inline val Context.isNavBarOnBottom: Boolean } fun Context.hasPermission(permissions: String) = !buildIsMarshmallowAndUp || ContextCompat.checkSelfPermission( - this, - permissions + this, + permissions ) == PackageManager.PERMISSION_GRANTED fun Context.copyToClipboard(text: String?, label: String = "Copied Text", showToast: Boolean = true) { diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/CoroutineUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/CoroutineUtils.kt index 741f4e2..4d6ee54 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/CoroutineUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/CoroutineUtils.kt @@ -19,14 +19,14 @@ import android.content.Context import android.os.Handler import android.os.Looper import ca.allanwang.kau.internal.KauBaseActivity -import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.EmptyCoroutineContext import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.android.asCoroutineDispatcher import kotlinx.coroutines.async import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import kotlin.coroutines.CoroutineContext +import kotlin.coroutines.EmptyCoroutineContext object ContextHelper : CoroutineScope { diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt index 7c3e3cb..fac9421 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt @@ -34,14 +34,14 @@ import android.app.Dialog import android.app.DialogFragment import android.app.Fragment import android.view.View -import androidx.fragment.app.DialogFragment as SupportDialogFragment -import androidx.fragment.app.Fragment as SupportFragment import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView.ViewHolder import java.util.Collections import java.util.WeakHashMap import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KProperty +import androidx.fragment.app.DialogFragment as SupportDialogFragment +import androidx.fragment.app.Fragment as SupportFragment fun <V : View> View.bindView(id: Int): ReadOnlyProperty<View, V> = required(id, viewFinder) diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/TransitionUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/TransitionUtils.kt index 3e4a26a..523a586 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/TransitionUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/TransitionUtils.kt @@ -21,9 +21,9 @@ import android.view.ViewGroup import androidx.annotation.RequiresApi import androidx.annotation.TransitionRes import androidx.transition.AutoTransition -import androidx.transition.Transition as SupportTransition import androidx.transition.TransitionInflater import androidx.transition.TransitionManager +import androidx.transition.Transition as SupportTransition /** * Created by Allan Wang on 2017-06-24. diff --git a/core/src/test/kotlin/ca/allanwang/kau/kotlin/CoroutineTest.kt b/core/src/test/kotlin/ca/allanwang/kau/kotlin/CoroutineTest.kt index 6c09a3e..1e86305 100644 --- a/core/src/test/kotlin/ca/allanwang/kau/kotlin/CoroutineTest.kt +++ b/core/src/test/kotlin/ca/allanwang/kau/kotlin/CoroutineTest.kt @@ -15,14 +15,14 @@ */ package ca.allanwang.kau.kotlin -import kotlin.test.assertEquals -import kotlin.test.fail import kotlinx.coroutines.CancellationException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext import org.junit.Test +import kotlin.test.assertEquals +import kotlin.test.fail /** * Tests geared towards coroutines 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 530f766..bc45ba5 100644 --- a/core/src/test/kotlin/ca/allanwang/kau/kotlin/DebounceTest.kt +++ b/core/src/test/kotlin/ca/allanwang/kau/kotlin/DebounceTest.kt @@ -15,9 +15,9 @@ */ package ca.allanwang.kau.kotlin -import kotlin.test.assertEquals import org.junit.Ignore import org.junit.Test +import kotlin.test.assertEquals /** * Created by Allan Wang on 2017-08-05. diff --git a/core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt b/core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt index 556979f..eaaaacb 100644 --- a/core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt +++ b/core/src/test/kotlin/ca/allanwang/kau/kotlin/LazyResettableTest.kt @@ -15,10 +15,10 @@ */ package ca.allanwang.kau.kotlin -import kotlin.test.assertEquals -import kotlin.test.assertNotEquals import org.junit.Before import org.junit.Test +import kotlin.test.assertEquals +import kotlin.test.assertNotEquals /** * Created by Allan Wang on 2017-07-29. diff --git a/core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt b/core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt index f2d7fd6..e3d4e5b 100644 --- a/core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt +++ b/core/src/test/kotlin/ca/allanwang/kau/kotlin/StreamsTest.kt @@ -15,8 +15,8 @@ */ package ca.allanwang.kau.kotlin -import kotlin.test.assertEquals import org.junit.Test +import kotlin.test.assertEquals /** * Created by Allan Wang on 2017-08-05. diff --git a/core/src/test/kotlin/ca/allanwang/kau/ui/ProgressAnimatorTest.kt b/core/src/test/kotlin/ca/allanwang/kau/ui/ProgressAnimatorTest.kt index a7edb05..8b99f3c 100644 --- a/core/src/test/kotlin/ca/allanwang/kau/ui/ProgressAnimatorTest.kt +++ b/core/src/test/kotlin/ca/allanwang/kau/ui/ProgressAnimatorTest.kt @@ -15,11 +15,11 @@ */ package ca.allanwang.kau.ui +import org.junit.Test import kotlin.math.min import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertTrue -import org.junit.Test class ProgressAnimatorTest { diff --git a/core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt b/core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt index 4aa2f25..b9c200a 100644 --- a/core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt +++ b/core/src/test/kotlin/ca/allanwang/kau/utils/UtilsTest.kt @@ -16,8 +16,8 @@ package ca.allanwang.kau.utils import android.graphics.Color -import kotlin.test.assertEquals import org.junit.Test +import kotlin.test.assertEquals /** * Created by Allan Wang on 2017-06-23. |