diff options
author | Allan Wang <me@allanwang.ca> | 2018-10-08 01:06:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-08 01:06:44 -0400 |
commit | 81518f74fa76b6c2274a0e02ad4169f5d7f61e59 (patch) | |
tree | 8af3ed7f0fecad644a4a3c485cac760968ae8b2b /core/src/main/kotlin | |
parent | 4029fb9ab284f56f5dc838399fe38c42cb93c708 (diff) | |
download | kau-81518f74fa76b6c2274a0e02ad4169f5d7f61e59.tar.gz kau-81518f74fa76b6c2274a0e02ad4169f5d7f61e59.tar.bz2 kau-81518f74fa76b6c2274a0e02ad4169f5d7f61e59.zip |
Update translations (#169)
* New translations strings_about.xml (Polish)
* New translations strings_commons.xml (Hebrew)
* New translations strings_commons.xml (Tagalog)
* New translations strings_commons.xml (Swedish)
* New translations strings_commons.xml (Serbian (Cyrillic))
* New translations strings_commons.xml (Russian)
* New translations strings_commons.xml (Romanian)
* New translations strings_commons.xml (Portuguese, Brazilian)
* New translations strings_commons.xml (Portuguese)
* New translations strings_commons.xml (Norwegian)
* New translations strings_commons.xml (Korean)
* New translations strings_commons.xml (Japanese)
* New translations strings_commons.xml (Italian)
* New translations strings_commons.xml (Hungarian)
* New translations strings_commons.xml (Greek)
* New translations strings_commons.xml (German)
* New translations strings_commons.xml (Galician)
* New translations strings_commons.xml (French)
* New translations strings_commons.xml (Finnish)
* New translations strings_commons.xml (English)
* New translations strings_commons.xml (Dutch)
* New translations strings_commons.xml (Czech)
* New translations strings_commons.xml (Chinese Traditional)
* New translations strings_commons.xml (Chinese Simplified)
* New translations strings_commons.xml (Catalan)
* New translations strings_commons.xml (Arabic)
* New translations strings_commons.xml (Afrikaans)
* New translations strings_colorpicker.xml (Ukrainian)
* New translations strings_commons.xml (Ukrainian)
* New translations strings_mediapicker.xml (Ukrainian)
* New translations strings_mediapicker.xml (Tagalog)
* New translations strings_mediapicker.xml (Swedish)
* New translations strings_mediapicker.xml (Serbian (Cyrillic))
* New translations strings_mediapicker.xml (Russian)
* New translations strings_mediapicker.xml (Romanian)
* New translations strings_mediapicker.xml (Portuguese, Brazilian)
* New translations strings_mediapicker.xml (Portuguese)
* New translations strings_mediapicker.xml (Norwegian)
* New translations strings_mediapicker.xml (Korean)
* New translations strings_mediapicker.xml (Japanese)
* New translations strings_mediapicker.xml (Italian)
* New translations strings_mediapicker.xml (Hungarian)
* New translations strings_commons.xml (Vietnamese)
* New translations strings_mediapicker.xml (Hebrew)
* New translations strings_mediapicker.xml (Greek)
* New translations strings_mediapicker.xml (German)
* New translations strings_mediapicker.xml (Galician)
* New translations strings_mediapicker.xml (French)
* New translations strings_mediapicker.xml (Finnish)
* New translations strings_mediapicker.xml (English)
* New translations strings_mediapicker.xml (Dutch)
* New translations strings_mediapicker.xml (Czech)
* New translations strings_mediapicker.xml (Chinese Traditional)
* New translations strings_mediapicker.xml (Chinese Simplified)
* New translations strings_mediapicker.xml (Catalan)
* New translations strings_mediapicker.xml (Arabic)
* New translations strings_mediapicker.xml (Afrikaans)
* New translations strings_colorpicker.xml (Tagalog)
* New translations strings_mediapicker.xml (Polish)
* New translations strings_about.xml (English)
* New translations strings_about.xml (Portuguese, Brazilian)
* New translations strings_about.xml (Portuguese)
* New translations strings_about.xml (Norwegian)
* New translations strings_about.xml (Korean)
* New translations strings_about.xml (Japanese)
* New translations strings_about.xml (Italian)
* New translations strings_about.xml (Hungarian)
* New translations strings_about.xml (Hebrew)
* New translations strings_about.xml (Greek)
* New translations strings_about.xml (German)
* New translations strings_about.xml (Galician)
* New translations strings_about.xml (French)
* New translations strings_about.xml (Finnish)
* New translations strings_about.xml (Dutch)
* New translations strings_about.xml (Russian)
* New translations strings_about.xml (Czech)
* New translations strings_about.xml (Chinese Simplified)
* New translations strings_about.xml (Catalan)
* New translations strings_about.xml (Arabic)
* New translations strings_about.xml (Afrikaans)
* New translations strings_mediapicker.xml (Danish)
* New translations strings_commons.xml (Danish)
* New translations strings_colorpicker.xml (Danish)
* New translations strings_about.xml (Danish)
* New translations strings_mediapicker.xml (Spanish)
* New translations strings_commons.xml (Spanish)
* New translations strings_about.xml (Spanish)
* New translations strings_about.xml (Chinese Traditional)
* New translations strings_about.xml (Romanian)
* New translations strings_about.xml (Serbian (Cyrillic))
* New translations strings_colorpicker.xml (Swedish)
* New translations strings_colorpicker.xml (Serbian (Cyrillic))
* New translations strings_colorpicker.xml (Russian)
* New translations strings_colorpicker.xml (Romanian)
* New translations strings_colorpicker.xml (Portuguese)
* New translations strings_colorpicker.xml (Japanese)
* New translations strings_colorpicker.xml (Hebrew)
* New translations strings_colorpicker.xml (Greek)
* New translations strings_about.xml (Swedish)
* New translations strings_colorpicker.xml (Arabic)
* New translations strings_about.xml (Tagalog)
* New translations strings_about.xml (Ukrainian)
* New translations strings_about.xml (Vietnamese)
* New translations strings_colorpicker.xml (Afrikaans)
* New translations strings_colorpicker.xml (Catalan)
* New translations strings_colorpicker.xml (Chinese Traditional)
* New translations strings_colorpicker.xml (Czech)
* New translations strings_colorpicker.xml (Dutch)
* New translations strings_colorpicker.xml (English)
* New translations strings_colorpicker.xml (Finnish)
* New translations strings_mediapicker.xml (Vietnamese)
* New translations strings_commons.xml (Danish)
* New translations strings_about.xml (Swedish)
* New translations strings_about.xml (Ukrainian)
* New translations strings_colorpicker.xml (Swedish)
* New translations strings_colorpicker.xml (Ukrainian)
* New translations strings_commons.xml (Swedish)
* New translations strings_commons.xml (Ukrainian)
* New translations strings_mediapicker.xml (Swedish)
* New translations strings_mediapicker.xml (Ukrainian)
* Delete empty files
* Optimize all source files
Diffstat (limited to 'core/src/main/kotlin')
14 files changed, 65 insertions, 48 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyResettable.kt b/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyResettable.kt index ceeaa30..979f7a7 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyResettable.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyResettable.kt @@ -14,7 +14,8 @@ internal object UNINITIALIZED fun <T : Any> lazyResettable(initializer: () -> T): LazyResettable<T> = LazyResettable<T>(initializer) class LazyResettable<T : Any>(private val initializer: () -> T, lock: Any? = null) : ILazyResettable<T>, Serializable { - @Volatile private var _value: Any = UNINITIALIZED + @Volatile + private var _value: Any = UNINITIALIZED private val lock = lock ?: this override fun invalidate() { @@ -69,8 +70,7 @@ class LazyResettableRegistry : ILazyResettableRegistry { var lazyRegistry: MutableList<LazyResettable<*>> = mutableListOf() - override fun <T : Any> lazy(initializer: () -> T): LazyResettable<T> - = add(lazyResettable(initializer)) + override fun <T : Any> lazy(initializer: () -> T): LazyResettable<T> = add(lazyResettable(initializer)) override fun <T : Any> add(resettable: LazyResettable<T>): LazyResettable<T> { lazyRegistry.add(resettable) diff --git a/core/src/main/kotlin/ca/allanwang/kau/kotlin/Utils.kt b/core/src/main/kotlin/ca/allanwang/kau/kotlin/Utils.kt index db28914..1ba1de6 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/kotlin/Utils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/kotlin/Utils.kt @@ -3,4 +3,4 @@ package ca.allanwang.kau.kotlin /** * Created by Allan Wang on 07/04/18. */ -inline fun <reified T: Any> javaClass(): Class<T> = T::class.java
\ No newline at end of file +inline fun <reified T : Any> javaClass(): Class<T> = T::class.java
\ No newline at end of file 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 33ba807..60d03ad 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt @@ -26,7 +26,8 @@ class KPrefDelegate<T : Any> internal constructor( private object UNINITIALIZED - @Volatile private var _value: Any = UNINITIALIZED + @Volatile + private var _value: Any = UNINITIALIZED private val lock = lock ?: this init { @@ -89,5 +90,6 @@ class KPrefDelegate<T : Any> internal constructor( } class KPrefException(message: String) : IllegalAccessException(message) { - constructor(element: Any?) : this("Invalid type in pref cache: ${element?.javaClass?.simpleName ?: "null"}") + constructor(element: Any?) : this("Invalid type in pref cache: ${element?.javaClass?.simpleName + ?: "null"}") }
\ No newline at end of file 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 6525305..ed30a44 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt @@ -14,7 +14,8 @@ fun KPref.kprefSingle(key: String) = KPrefSingleDelegate(key, this) */ class KPrefSingleDelegate internal constructor(private val key: String, private val pref: KPref, lock: Any? = null) : ILazyResettable<Boolean> { - @Volatile private var _value: Boolean? = null + @Volatile + private var _value: Boolean? = null private val lock = lock ?: this init { diff --git a/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionManager.kt b/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionManager.kt index 3b15e0b..36456ec 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionManager.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionManager.kt @@ -29,7 +29,8 @@ internal object PermissionManager { */ private val manifestPermission = lazyContext<Array<String>> { try { - it.packageManager.getPackageInfo(it.packageName, PackageManager.GET_PERMISSIONS)?.requestedPermissions ?: emptyArray() + it.packageManager.getPackageInfo(it.packageName, PackageManager.GET_PERMISSIONS)?.requestedPermissions + ?: emptyArray() } catch (e: Exception) { emptyArray() } @@ -47,7 +48,8 @@ internal object PermissionManager { } else KL.d { "Request is postponed since another one is still in progress; did you remember to override onRequestPermissionsResult?" } } - @Synchronized private fun requestPermissions(context: Context, permissions: Array<out String>) { + @Synchronized + private fun requestPermissions(context: Context, permissions: Array<out String>) { permissions.forEach { if (!manifestPermission(context).contains(it)) { KL.e { "Requested permission $it is not stated in the manifest" } @@ -55,7 +57,8 @@ internal object PermissionManager { //we'll let the request pass through so it can be denied and so the callback can be triggered } } - val activity = (context as? Activity) ?: throw KauException("Context is not an instance of an activity; cannot request permissions") + val activity = (context as? Activity) + ?: throw KauException("Context is not an instance of an activity; cannot request permissions") KL.i { "Requesting permissions ${permissions.contentToString()}" } ActivityCompat.requestPermissions(activity, permissions, 1) } diff --git a/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt b/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt index 4de6695..248e484 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt @@ -22,8 +22,7 @@ import android.support.annotation.RequiresApi /** * Hook that should be added inside all [Activity.onRequestPermissionsResult] so that the Permission manager can handle the responses */ -fun Activity.kauOnRequestPermissionsResult(permissions: Array<out String>, grantResults: IntArray) - = PermissionManager.onRequestPermissionsResult(this, permissions, grantResults) +fun Activity.kauOnRequestPermissionsResult(permissions: Array<out String>, grantResults: IntArray) = PermissionManager.onRequestPermissionsResult(this, permissions, grantResults) /** * Request a permission with a callback @@ -32,8 +31,7 @@ fun Activity.kauOnRequestPermissionsResult(permissions: Array<out String>, grant * The [callback] returns [granted], which is true if all permissions are granted * [deniedPerm] is the first denied permission, if granted is false */ -fun Context.kauRequestPermissions(vararg permissions: String, callback: (granted: Boolean, deniedPerm: String?) -> Unit) - = PermissionManager(this, permissions, callback) +fun Context.kauRequestPermissions(vararg permissions: String, callback: (granted: Boolean, deniedPerm: String?) -> Unit) = PermissionManager(this, permissions, callback) /** * See http://developer.android.com/guide/topics/security/permissions.html#normal-dangerous for a diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackHelper.kt b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackHelper.kt index 41cd2e0..018d7c7 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackHelper.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackHelper.kt @@ -16,8 +16,7 @@ internal object SwipeBackHelper { private val pageStack = Stack<SwipeBackPage>() - private operator fun get(activity: Activity): SwipeBackPage? - = pageStack.firstOrNull { it.activityRef.get() === activity } + private operator fun get(activity: Activity): SwipeBackPage? = pageStack.firstOrNull { it.activityRef.get() === activity } fun onCreate(activity: Activity, builder: SwipeBackContract.() -> Unit = {}) { val page = this[activity] ?: pageStack.push(SwipeBackPage(activity).apply { builder() }) diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt index 7b6654d..4dba622 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt @@ -40,7 +40,8 @@ internal class SwipeBackPage(activity: Activity) : SwipeBackContractInternal by } private fun handleLayout() { - val activity = activityRef.get() ?: return KL.v { "KauSwipe activity ref gone during handleLayout" } + val activity = activityRef.get() + ?: return KL.v { "KauSwipe activity ref gone during handleLayout" } if (swipeEnabled) swipeBackLayout.attachToActivity(activity) else swipeBackLayout.removeFromActivity(activity) } 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 d0e1f8f..236f2ca 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt @@ -94,12 +94,10 @@ fun Int.blendWith(@ColorInt color: Int, @FloatRange(from = 0.0, to = 1.0) ratio: } @ColorInt -fun Int.withAlpha(@IntRange(from = 0L, to = 255L) alpha: Int): Int - = Color.argb(alpha, Color.red(this), Color.green(this), Color.blue(this)) +fun Int.withAlpha(@IntRange(from = 0L, to = 255L) alpha: Int): Int = Color.argb(alpha, Color.red(this), Color.green(this), Color.blue(this)) @ColorInt -fun Int.withMinAlpha(@IntRange(from = 0L, to = 255L) alpha: Int): Int - = Color.argb(Math.max(alpha, Color.alpha(this)), Color.red(this), Color.green(this), Color.blue(this)) +fun Int.withMinAlpha(@IntRange(from = 0L, to = 255L) alpha: Int): Int = Color.argb(Math.max(alpha, Color.alpha(this)), Color.red(this), Color.green(this), Color.blue(this)) @ColorInt fun Int.lighten(@FloatRange(from = 0.0, to = 1.0) factor: Float = 0.1f): Int { @@ -116,12 +114,10 @@ fun Int.darken(@FloatRange(from = 0.0, to = 1.0) factor: Float = 0.1f): Int { } @ColorInt -fun Int.colorToBackground(@FloatRange(from = 0.0, to = 1.0) factor: Float = 0.1f): Int - = if (isColorDark) darken(factor) else lighten(factor) +fun Int.colorToBackground(@FloatRange(from = 0.0, to = 1.0) factor: Float = 0.1f): Int = if (isColorDark) darken(factor) else lighten(factor) @ColorInt -fun Int.colorToForeground(@FloatRange(from = 0.0, to = 1.0) factor: Float = 0.1f): Int - = if (isColorDark) lighten(factor) else darken(factor) +fun Int.colorToForeground(@FloatRange(from = 0.0, to = 1.0) factor: Float = 0.1f): Int = if (isColorDark) lighten(factor) else darken(factor) @Throws(IllegalArgumentException::class) fun String.toColor(): Int { diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/FileUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/FileUtils.kt index b97f4aa..bfbc009 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/FileUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/FileUtils.kt @@ -6,5 +6,4 @@ import java.io.InputStream /** * Created by Allan Wang on 2017-08-04. */ -fun File.copyFromInputStream(inputStream: InputStream) - = inputStream.use { input -> outputStream().use { output -> input.copyTo(output) } }
\ No newline at end of file +fun File.copyFromInputStream(inputStream: InputStream) = inputStream.use { input -> outputStream().use { output -> input.copyTo(output) } }
\ No newline at end of file diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/FontUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/FontUtils.kt index 05073c7..1db7694 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/FontUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/FontUtils.kt @@ -17,7 +17,8 @@ object FontUtils { context.applicationContext.assets, "fonts/$font.ttf") sTypefaceCache.put(font, tf) } - return sTypefaceCache.get(font) ?: throw IllegalArgumentException("Font error; typeface does not exist at assets/fonts$font.ttf") + return sTypefaceCache.get(font) + ?: throw IllegalArgumentException("Font error; typeface does not exist at assets/fonts$font.ttf") } } diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/NotificationUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/NotificationUtils.kt index 23a8370..1eb0076 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/NotificationUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/NotificationUtils.kt @@ -7,5 +7,4 @@ import android.support.v4.app.NotificationManagerCompat /** * Created by Allan Wang on 2017-08-04. */ -fun Context.cancelNotification(notifId: Int) - = NotificationManagerCompat.from(this).cancel(notifId)
\ No newline at end of file +fun Context.cancelNotification(notifId: Int) = NotificationManagerCompat.from(this).cancel(notifId)
\ No newline at end of file diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt index 9a1e9b0..4e020bc 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt @@ -23,7 +23,6 @@ import android.view.ViewGroup import android.view.inputmethod.InputMethodManager import android.widget.EditText import android.widget.ImageView -import android.widget.TextView import ca.allanwang.kau.ui.createSimpleRippleDrawable import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.typeface.IIcon @@ -33,34 +32,47 @@ import com.mikepenz.iconics.typeface.IIcon * Created by Allan Wang on 2017-05-31. */ -@KauUtils inline fun <T : View> T.visible(): T { +@KauUtils +inline fun <T : View> T.visible(): T { visibility = View.VISIBLE return this } -@KauUtils inline fun <T : View> T.invisible(): T { +@KauUtils +inline fun <T : View> T.invisible(): T { visibility = View.INVISIBLE return this } -@KauUtils inline fun <T : View> T.gone(): T { +@KauUtils +inline fun <T : View> T.gone(): T { visibility = View.GONE return this } -@KauUtils inline fun <T : View> T.invisibleIf(invisible: Boolean): T = if (invisible) invisible() else visible() +@KauUtils +inline fun <T : View> T.invisibleIf(invisible: Boolean): T = if (invisible) invisible() else visible() -@KauUtils inline fun <T : View> T.visibleIf(visible: Boolean): T = if (visible) visible() else gone() +@KauUtils +inline fun <T : View> T.visibleIf(visible: Boolean): T = if (visible) visible() else gone() -@KauUtils inline fun <T : View> T.goneIf(gone: Boolean): T = visibleIf(!gone) +@KauUtils +inline fun <T : View> T.goneIf(gone: Boolean): T = visibleIf(!gone) -@KauUtils inline val View.isVisible: Boolean get() = visibility == View.VISIBLE +@KauUtils +inline val View.isVisible: Boolean + get() = visibility == View.VISIBLE -@KauUtils inline val View.isInvisible: Boolean get() = visibility == View.INVISIBLE +@KauUtils +inline val View.isInvisible: Boolean + get() = visibility == View.INVISIBLE -@KauUtils inline val View.isGone: Boolean get() = visibility == View.GONE +@KauUtils +inline val View.isGone: Boolean + get() = visibility == View.GONE -@KauUtils inline fun View.setBackgroundColorRes(@ColorRes color: Int) = setBackgroundColor(context.color(color)) +@KauUtils +inline fun View.setBackgroundColorRes(@ColorRes color: Int) = setBackgroundColor(context.color(color)) fun View.snackbar(text: String, duration: Int = Snackbar.LENGTH_LONG, builder: Snackbar.() -> Unit = {}): Snackbar { val snackbar = Snackbar.make(this, text, duration) @@ -69,8 +81,7 @@ fun View.snackbar(text: String, duration: Int = Snackbar.LENGTH_LONG, builder: S return snackbar } -fun View.snackbar(@StringRes textId: Int, duration: Int = Snackbar.LENGTH_LONG, builder: Snackbar.() -> Unit = {}) - = snackbar(context.string(textId), duration, builder) +fun View.snackbar(@StringRes textId: Int, duration: Int = Snackbar.LENGTH_LONG, builder: Snackbar.() -> Unit = {}) = snackbar(context.string(textId), duration, builder) @KauUtils fun ImageView.setIcon(icon: IIcon?, sizeDp: Int = 24, @ColorInt color: Int = Color.WHITE, builder: IconicsDrawable.() -> Unit = {}) { @@ -78,7 +89,9 @@ fun ImageView.setIcon(icon: IIcon?, sizeDp: Int = 24, @ColorInt color: Int = Col setImageDrawable(icon.toDrawable(context, sizeDp = sizeDp, color = color, builder = builder)) } -@KauUtils inline val FloatingActionButton.isHidden get() = !isShown +@KauUtils +inline val FloatingActionButton.isHidden + get() = !isShown fun FloatingActionButton.showIf(show: Boolean) = if (show) show() else hide() @@ -133,7 +146,8 @@ fun View.setMargin(margin: Int) = setMargins(margin, KAU_ALL) * Base margin setter * returns true if setting is successful, false otherwise */ -@KauUtils private fun View.setMargins(margin: Int, flag: Int): Boolean { +@KauUtils +private fun View.setMargins(margin: Int, flag: Int): Boolean { val p = (layoutParams as? ViewGroup.MarginLayoutParams) ?: return false p.setMargins( if (flag and KAU_LEFT > 0) margin else p.leftMargin, @@ -189,7 +203,8 @@ fun View.setPadding(padding: Int) = setPadding(padding, KAU_ALL) /** * Base padding setter */ -@KauUtils private fun View.setPadding(padding: Int, flag: Int) { +@KauUtils +private fun View.setPadding(padding: Int, flag: Int) { setPadding( if (flag and KAU_LEFT > 0) padding else paddingLeft, if (flag and KAU_TOP > 0) padding else paddingTop, @@ -217,7 +232,9 @@ fun View.setRippleBackground(@ColorInt foregroundColor: Int, @ColorInt backgroun background = createSimpleRippleDrawable(foregroundColor, backgroundColor) } -@KauUtils inline val View.parentViewGroup: ViewGroup get() = parent as ViewGroup +@KauUtils +inline val View.parentViewGroup: ViewGroup + get() = parent as ViewGroup inline val EditText.value: String get() = text.toString().trim() diff --git a/core/src/main/kotlin/ca/allanwang/kau/xml/FAQ.kt b/core/src/main/kotlin/ca/allanwang/kau/xml/FAQ.kt index f804b70..7caf5d6 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/xml/FAQ.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/xml/FAQ.kt @@ -47,7 +47,8 @@ fun Context.kauParseFaq( } 1 -> { items.add(FaqItem(items.size + 1, - question ?: throw IllegalArgumentException("KAU FAQ answer found without a question"), + question + ?: throw IllegalArgumentException("KAU FAQ answer found without a question"), Html.fromHtml(parser.text.replace("\n", if (parseNewLine) "<br/>" else "")))) question = null flag = -1 |