diff options
author | Allan Wang <me@allanwang.ca> | 2018-09-07 14:42:37 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-07 14:42:37 -0400 |
commit | 718a51ed00a0a5c3dc7a655e617308e82da65d1a (patch) | |
tree | 970783021ea2e21135a63fa888240f8dd3e8d543 | |
parent | 6af0c6f7671898d0756c2e63dd17e830a2389885 (diff) | |
download | kau-718a51ed00a0a5c3dc7a655e617308e82da65d1a.tar.gz kau-718a51ed00a0a5c3dc7a655e617308e82da65d1a.tar.bz2 kau-718a51ed00a0a5c3dc7a655e617308e82da65d1a.zip |
Fix up cutoutview setup (#160)
* Fix up cutoutview setup
* Update gradle plugin versions
* Update kotlin gradle version
* Update canvas dimensions
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy | 16 | ||||
-rw-r--r-- | core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/CutoutView.kt | 40 | ||||
-rw-r--r-- | core-ui/src/main/res-public/values/public.xml | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/ca/allanwang/kau/ui/views/RippleCanvas.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt | 26 | ||||
-rw-r--r-- | core/src/main/res-public/values/public.xml | 98 | ||||
-rw-r--r-- | docs/Changelog.md | 1 | ||||
-rw-r--r-- | mediapicker/src/main/res-public/values/public.xml | 4 |
9 files changed, 105 insertions, 86 deletions
diff --git a/.travis.yml b/.travis.yml index a5086d4..22743c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ cache: - $HOME/.gradle/wrapper/ - $HOME/.android/build-cache before_install: -- yes | sdkmanager "platforms;android-27" +- yes | sdkmanager "platforms;android-28" - openssl aes-256-cbc -K $encrypted_12e8842891a3_key -iv $encrypted_12e8842891a3_iv -in files/kau.tar.enc -out kau.tar -d - tar xvf kau.tar
\ No newline at end of file diff --git a/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy b/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy index 4b7149e..936e22b 100644 --- a/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy +++ b/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy @@ -3,16 +3,16 @@ package ca.allanwang.kau class Versions { static def coreMinSdk = 19 static def minSdk = 21 - static def targetSdk = 27 + static def targetSdk = 28 // https://developer.android.com/studio/releases/build-tools - static def buildTools = '27.0.3' + static def buildTools = '28.0.2' // https://developer.android.com/topic/libraries/support-library/revisions static def supportLibs = '27.1.1' // https://kotlinlang.org/docs/reference/using-gradle.html - static def kotlin = '1.2.41' + static def kotlin = '1.2.61' // https://github.com/mikepenz/AboutLibraries/releases static def aboutLibraries = '6.0.8' @@ -45,11 +45,11 @@ class Versions { static def junit = '4.12' static def testRunner = '1.0.1' - static def gradlePlugin = '3.1.2' - static def mavenPlugin = '2.0' - static def playPublishPlugin = '1.2.0' + static def gradlePlugin = '3.2.0-rc02' + static def mavenPlugin = '2.1' + static def playPublishPlugin = '1.2.2' // https://github.com/KeepSafe/dexcount-gradle-plugin/releases - static def dexCountPlugin = '0.8.2' - static def gitVersionPlugin = '0.4.3' + static def dexCountPlugin = '0.8.3' + static def gitVersionPlugin = '0.4.4' }
\ No newline at end of file diff --git a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/CutoutView.kt b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/CutoutView.kt index fc03563..eeaac6e 100644 --- a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/CutoutView.kt +++ b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/CutoutView.kt @@ -39,29 +39,39 @@ class CutoutView @JvmOverloads constructor( companion object { const val PHI = 1.6182f - const val TYPE_TEXT = 100 - const val TYPE_DRAWABLE = 101 + const val TYPE_EMPTY = 100 + const val TYPE_TEXT = 101 + const val TYPE_DRAWABLE = 102 } - private val paint: TextPaint = TextPaint(Paint.ANTI_ALIAS_FLAG) + private val paint: TextPaint = TextPaint().apply { + isAntiAlias = true + xfermode = PorterDuffXfermode(PorterDuff.Mode.CLEAR) + } private var bitmapScaling: Float = 1f private var cutout: Bitmap? = null var foregroundColor = Color.MAGENTA var text: String? = "Text" set(value) { field = value - if (value != null) cutoutType = TYPE_TEXT - else if (drawable != null) cutoutType = TYPE_DRAWABLE + cutoutType = when { + value != null -> TYPE_TEXT + drawable != null -> TYPE_DRAWABLE + else -> TYPE_EMPTY + } } - var cutoutType: Int = TYPE_TEXT + var cutoutType: Int = TYPE_EMPTY private var textSize: Float = 0f private var cutoutY: Float = 0f private var cutoutX: Float = 0f var drawable: Drawable? = null set(value) { field = value - if (value != null) cutoutType = TYPE_DRAWABLE - else if (text != null) cutoutType = TYPE_TEXT + cutoutType = when { + drawable != null -> TYPE_DRAWABLE + value != null -> TYPE_TEXT + else -> TYPE_EMPTY + } } private var heightPercentage: Float = 0f private var minHeight: Float = 0f @@ -159,22 +169,22 @@ class CutoutView @JvmOverloads constructor( if (cutout?.isRecycled == false) cutout?.recycle() if (width == 0 || height == 0) return - cutout = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) - cutout!!.setHasAlpha(true) + cutout = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888).apply { + setHasAlpha(true) + } val cutoutCanvas = Canvas(cutout!!) cutoutCanvas.drawColor(foregroundColor) - paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.CLEAR) when (cutoutType) { TYPE_TEXT -> { - // this is the magic – Clear mode punches out the bitmap - paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.CLEAR) - cutoutCanvas.drawText(text, cutoutX, cutoutY, paint) + cutoutCanvas.drawText(text!!, cutoutX, cutoutY, paint) } TYPE_DRAWABLE -> { cutoutCanvas.drawBitmap(drawable!!.toBitmap(bitmapScaling, Bitmap.Config.ALPHA_8), cutoutX, cutoutY, paint) } - + TYPE_EMPTY -> { + // do nothing + } } } diff --git a/core-ui/src/main/res-public/values/public.xml b/core-ui/src/main/res-public/values/public.xml index dcaa583..f46b3eb 100644 --- a/core-ui/src/main/res-public/values/public.xml +++ b/core-ui/src/main/res-public/values/public.xml @@ -1,8 +1,8 @@ <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_recycler_detached_background' type='layout' /> - <public name='kau_recycler_textslider' type='layout' /> <public name='kau_elastic_recycler_activity' type='layout' /> + <public name='kau_recycler_textslider' type='layout' /> <public name='Kau.Translucent' type='style' /> <public name='Kau.Translucent.NoAnimation' type='style' /> <public name='Kau.Translucent.SlideBottom' type='style' /> 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 diff --git a/docs/Changelog.md b/docs/Changelog.md index aeb119a..a93b4c8 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -5,6 +5,7 @@ * Fix new lint issues (see Migration for resource related methods) * :adapter: Add more IAdapter functions to help retrieve selections * :core: Add deprecation warning to bindView for fragment based extensions; use bindViewResettable instead +* :kpref-activity: Fix seekbar increment ## v3.7.1 * Update appcompat to 27.1.0 diff --git a/mediapicker/src/main/res-public/values/public.xml b/mediapicker/src/main/res-public/values/public.xml index 3c6f0fa..ac608bb 100644 --- a/mediapicker/src/main/res-public/values/public.xml +++ b/mediapicker/src/main/res-public/values/public.xml @@ -1,7 +1,7 @@ <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.MediaPicker' type='style' /> - <public name='Kau.MediaPicker.Overlay' type='style' /> <public name='kau_blurred_image_selection_overlay' type='color' /> <public name='kau_image_minimum_size' type='dimen' /> + <public name='Kau.MediaPicker' type='style' /> + <public name='Kau.MediaPicker.Overlay' type='style' /> </resources>
\ No newline at end of file |