aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt2
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt26
-rw-r--r--core/src/main/res-public/values/public.xml98
3 files changed, 67 insertions, 59 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt b/core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt
index 62a16d9..3d86419 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt
@@ -36,7 +36,7 @@ class RippleCanvas @JvmOverloads constructor(
*/
override fun onDraw(canvas: Canvas) {
paint.color = baseColor
- canvas.drawRect(0f, 0f, canvas.width.toFloat(), canvas.height.toFloat(), paint)
+ canvas.drawRect(0f, 0f, width.toFloat(), height.toFloat(), paint)
val itr = ripples.iterator()
while (itr.hasNext()) {
val r = itr.next()
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt
index 9a70ae7..46e29b2 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt
@@ -25,28 +25,36 @@ import java.text.DecimalFormat
@DslMarker
annotation class KauUtils
-@KauUtils inline val Float.dpToPx: Float
+@KauUtils
+inline val Float.dpToPx: Float
get() = this * Resources.getSystem().displayMetrics.density
-@KauUtils inline val Int.dpToPx: Int
+@KauUtils
+inline val Int.dpToPx: Int
get() = toFloat().dpToPx.toInt()
-@KauUtils inline val Float.pxToDp: Float
+@KauUtils
+inline val Float.pxToDp: Float
get() = this / Resources.getSystem().displayMetrics.density
-@KauUtils inline val Int.pxToDp: Int
+@KauUtils
+inline val Int.pxToDp: Int
get() = toFloat().pxToDp.toInt()
-@KauUtils inline val Float.dpToSp: Float
+@KauUtils
+inline val Float.dpToSp: Float
get() = this * Resources.getSystem().displayMetrics.scaledDensity
-@KauUtils inline val Int.dpToSp: Int
+@KauUtils
+inline val Int.dpToSp: Int
get() = toFloat().dpToSp.toInt()
-@KauUtils inline val Float.spToDp: Float
+@KauUtils
+inline val Float.spToDp: Float
get() = this / Resources.getSystem().displayMetrics.scaledDensity
-@KauUtils inline val Int.spToDp: Int
+@KauUtils
+inline val Int.spToDp: Int
get() = toFloat().spToDp.toInt()
/**
@@ -87,7 +95,7 @@ fun Drawable.toBitmap(scaling: Float = 1f, config: Bitmap.Config = Bitmap.Config
else
Bitmap.createBitmap((intrinsicWidth * scaling).toInt(), (intrinsicHeight * scaling).toInt(), config)
val canvas = Canvas(bitmap)
- setBounds(0, 0, canvas.width, canvas.height)
+ setBounds(0, 0, bitmap.width, bitmap.height)
draw(canvas)
return bitmap
}
diff --git a/core/src/main/res-public/values/public.xml b/core/src/main/res-public/values/public.xml
index f831c6d..ea8ed73 100644
--- a/core/src/main/res-public/values/public.xml
+++ b/core/src/main/res-public/values/public.xml
@@ -1,29 +1,48 @@
<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_exit_slide_bottom' type='transition' />
- <public name='kau_exit_slide_left' type='transition' />
- <public name='kau_enter_slide_right' type='transition' />
- <public name='kau_exit_slide_top' type='transition' />
- <public name='kau_exit_slide_right' type='transition' />
- <public name='kau_enter_slide_bottom' type='transition' />
- <public name='kau_enter_slide_top' type='transition' />
- <public name='kau_enter_slide_left' type='transition' />
- <public name='kau_selectable_white' type='drawable' />
- <public name='kau_transparent' type='drawable' />
- <public name='kau_fade_out' type='anim' />
- <public name='kau_slide_in_right' type='anim' />
- <public name='kau_fade_in' type='anim' />
- <public name='kau_slide_out_right' type='anim' />
- <public name='kau_slide_out_left' type='anim' />
+ <public name='kau_slide_in_top' type='anim' />
<public name='kau_slide_in_left' type='anim' />
- <public name='kau_slide_out_bottom' type='anim' />
+ <public name='kau_slide_out_right' type='anim' />
<public name='kau_slide_out_right_top' type='anim' />
- <public name='kau_slide_in_top' type='anim' />
+ <public name='kau_fade_in' type='anim' />
<public name='kau_slide_out_top' type='anim' />
- <public name='kau_slide_in_bottom' 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' type='style' />
- <public name='Kau.Translucent' type='style' />
+ <public name='kau_slide_in_bottom' type='anim' />
+ <public name='kau_slide_in_right' type='anim' />
+ <public name='kau_transparent' type='drawable' />
+ <public name='kau_selectable_white' type='drawable' />
+ <public name='kau_shadow_overlay' type='color' />
+ <public name='kau_activity_horizontal_margin' type='dimen' />
+ <public name='kau_activity_vertical_margin' type='dimen' />
+ <public name='kau_dialog_margin' type='dimen' />
+ <public name='kau_dialog_margin_bottom' type='dimen' />
+ <public name='kau_fab_margin' type='dimen' />
+ <public name='kau_appbar_padding_top' type='dimen' />
+ <public name='kau_splash_logo' type='dimen' />
+ <public name='kau_progress_bar_height' type='dimen' />
+ <public name='kau_account_image_size' type='dimen' />
+ <public name='kau_status_bar_height' type='dimen' />
+ <public name='kau_drag_dismiss_distance' type='dimen' />
+ <public name='kau_drag_dismiss_distance_large' type='dimen' />
+ <public name='kau_spacing_normal' type='dimen' />
+ <public name='kau_spacing_micro' type='dimen' />
+ <public name='kau_spacing_large' type='dimen' />
+ <public name='kau_spacing_xlarge' type='dimen' />
+ <public name='kau_spacing_huge' type='dimen' />
+ <public name='kau_padding_small' type='dimen' />
+ <public name='kau_padding_normal' type='dimen' />
+ <public name='kau_padding_large' type='dimen' />
+ <public name='kau_fab_size' type='dimen' />
+ <public name='kau_fab_radius' type='dimen' />
+ <public name='kau_display_4_text_size' type='dimen' />
+ <public name='kau_avatar_size' type='dimen' />
+ <public name='kau_avatar_bounds' type='dimen' />
+ <public name='kau_avatar_padding' type='dimen' />
+ <public name='kau_avatar_margin' type='dimen' />
+ <public name='kau_avatar_ripple_radius' type='dimen' />
<public name='kau_about_app' type='string' />
<public name='kau_about_x' type='string' />
<public name='kau_add_account' type='string' />
@@ -79,7 +98,8 @@
<public name='kau_permission_denied' type='string' />
<public name='kau_0' type='string' />
<public name='kau_bullet_point' type='string' />
- <public name='kau_shadow_overlay' type='color' />
+ <public name='Kau' type='style' />
+ <public name='Kau.Translucent' type='style' />
<public name='KauFadeIn' type='style' />
<public name='KauFadeInFadeOut' type='style' />
<public name='KauSlideInRight' type='style' />
@@ -87,32 +107,12 @@
<public name='KauSlideInFadeOut' type='style' />
<public name='KauSlideInSlideOutRight' type='style' />
<public name='KauSlideInSlideOutBottom' type='style' />
- <public name='kau_activity_horizontal_margin' type='dimen' />
- <public name='kau_activity_vertical_margin' type='dimen' />
- <public name='kau_dialog_margin' type='dimen' />
- <public name='kau_dialog_margin_bottom' type='dimen' />
- <public name='kau_fab_margin' type='dimen' />
- <public name='kau_appbar_padding_top' type='dimen' />
- <public name='kau_splash_logo' type='dimen' />
- <public name='kau_progress_bar_height' type='dimen' />
- <public name='kau_account_image_size' type='dimen' />
- <public name='kau_status_bar_height' type='dimen' />
- <public name='kau_drag_dismiss_distance' type='dimen' />
- <public name='kau_drag_dismiss_distance_large' type='dimen' />
- <public name='kau_spacing_normal' type='dimen' />
- <public name='kau_spacing_micro' type='dimen' />
- <public name='kau_spacing_large' type='dimen' />
- <public name='kau_spacing_xlarge' type='dimen' />
- <public name='kau_spacing_huge' type='dimen' />
- <public name='kau_padding_small' type='dimen' />
- <public name='kau_padding_normal' type='dimen' />
- <public name='kau_padding_large' type='dimen' />
- <public name='kau_fab_size' type='dimen' />
- <public name='kau_fab_radius' type='dimen' />
- <public name='kau_display_4_text_size' type='dimen' />
- <public name='kau_avatar_size' type='dimen' />
- <public name='kau_avatar_bounds' type='dimen' />
- <public name='kau_avatar_padding' type='dimen' />
- <public name='kau_avatar_margin' type='dimen' />
- <public name='kau_avatar_ripple_radius' type='dimen' />
+ <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