From aa747a2b154cebfdcdde93b68b674d776d964558 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 11 Jun 2017 19:10:05 -0700 Subject: finalize Pref layout --- build.gradle | 1 + gradle.properties | 12 +++-- library/build.gradle | 2 +- .../kotlin/ca/allanwang/kau/changelog/Changelog.kt | 2 +- .../ca/allanwang/kau/kpref/items/KPrefItemCore.kt | 2 +- .../kotlin/ca/allanwang/kau/utils/IIconUtils.kt | 3 +- .../kotlin/ca/allanwang/kau/utils/ViewUtils.kt | 9 ++-- library/src/main/res/layout/kau_preference.xml | 55 +++++++++++++--------- sample/build.gradle | 1 + .../kotlin/ca/allanwang/kau/sample/MainActivity.kt | 4 +- sample/src/main/res/values/strings.xml | 2 +- 11 files changed, 54 insertions(+), 39 deletions(-) diff --git a/build.gradle b/build.gradle index e922f4f..a166712 100644 --- a/build.gradle +++ b/build.gradle @@ -19,6 +19,7 @@ allprojects { jcenter() mavenCentral() maven { url "https://jitpack.io" } + maven { url "https://maven.google.com" } } } diff --git a/gradle.properties b/gradle.properties index 1ea34fe..ac10513 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,16 +18,18 @@ org.gradle.jvmargs=-Xmx1536m APP_ID=KPrefs APP_GROUP=ca.allanwang MIN_SDK=21 -TARGET_SDK=25 -BUILD_TOOLS=25.0.2 +TARGET_SDK=26 +BUILD_TOOLS=26.0.0 VERSION_CODE=1 VERSION_NAME=0.1 -ANDROID_SUPPORT_LIBS=25.3.1 +ANDROID_SUPPORT_LIBS=26.0.0-alpha1 MATERIAL_DIALOG=0.9.4.3 ICONICS=2.8.5 +IICON_GOOGLE=3.0.1.0 TIMBER=4.5.1 -CONSTRAINT_LAYOUT=1.0.2 -FAST_ADAPTER=2.6.0 +CONSTRAINT_LAYOUT=1.1.0-beta1 +FAST_ADAPTER=2.6.2 +FAST_ADAPTER_COMMONS=2.6.0 BUTTERKNIFE=8.6.0 diff --git a/library/build.gradle b/library/build.gradle index 8e5b674..44f22cf 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -50,7 +50,7 @@ dependencies { compile "com.android.support.constraint:constraint-layout:${CONSTRAINT_LAYOUT}" compile "com.mikepenz:fastadapter:${FAST_ADAPTER}@aar" - compile "com.mikepenz:fastadapter-commons:${FAST_ADAPTER}@aar" + compile "com.mikepenz:fastadapter-commons:${FAST_ADAPTER_COMMONS}@aar" compile "com.afollestad.material-dialogs:core:${MATERIAL_DIALOG}" compile "com.afollestad.material-dialogs:commons:${MATERIAL_DIALOG}" diff --git a/library/src/main/kotlin/ca/allanwang/kau/changelog/Changelog.kt b/library/src/main/kotlin/ca/allanwang/kau/changelog/Changelog.kt index 14b8c4e..7f71195 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/changelog/Changelog.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/changelog/Changelog.kt @@ -34,7 +34,7 @@ internal class ChangelogAdapter(val items: List>) : override fun getItemCount() = items.size internal class ChangelogVH(itemView: View) : RecyclerView.ViewHolder(itemView) { - val text: TextView = itemView.findViewById(R.id.kau_changelog_text) as TextView + val text: TextView = itemView.findViewById(R.id.kau_changelog_text) } } diff --git a/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt index dcb9dc5..8d5eca2 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt @@ -42,7 +42,7 @@ abstract class KPrefItemCore(val builder: KPrefAdapterBuilder, desc?.visible()?.setText(description) else desc?.gone() - if (iicon != null) icon?.visible()?.setIcon(iicon, 48) + if (iicon != null) icon?.visible()?.setIcon(iicon, 24) else icon?.gone() innerFrame?.removeAllViews() val textColor = builder.textColor?.invoke() diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt index d47d133..4bb72a8 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt @@ -11,9 +11,10 @@ import com.mikepenz.iconics.typeface.IIcon /** * Created by Allan Wang on 2017-05-29. */ -fun IIcon.toDrawable(c: Context, sizeDp: Int = 24, @ColorInt color: Int = Color.WHITE): Drawable { +fun IIcon.toDrawable(c: Context, sizeDp: Int = 24, @ColorInt color: Int = Color.WHITE, builder: IconicsDrawable.() -> Unit = {}): Drawable { val state = ColorStateList.valueOf(color) val icon = IconicsDrawable(c).icon(this).sizeDp(sizeDp) icon.setTintList(state) + icon.builder() return icon } \ No newline at end of file diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt index bd8478d..72b8573 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt @@ -1,17 +1,14 @@ package ca.allanwang.kau.utils -import android.content.res.ColorStateList import android.graphics.Color import android.support.annotation.ColorInt -import android.support.annotation.ColorRes import android.support.annotation.StringRes import android.support.design.widget.Snackbar -import android.support.v4.content.ContextCompat import android.view.View import android.view.ViewGroup import android.widget.ImageView -import android.widget.ProgressBar import android.widget.TextView +import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.typeface.IIcon @@ -57,8 +54,8 @@ fun TextView.setTextIfValid(@StringRes id: Int) { if (id > 0) text = context.string(id) } -fun ImageView.setIcon(icon: IIcon?, sizeDp: Int = 24, @ColorInt color: Int = Color.WHITE) { +fun ImageView.setIcon(icon: IIcon?, sizeDp: Int = 24, @ColorInt color: Int = Color.WHITE, builder: IconicsDrawable.() -> Unit = {}) { if (icon == null) return - setImageDrawable(icon.toDrawable(context, sizeDp, color)) + setImageDrawable(icon.toDrawable(context, sizeDp = sizeDp, color = color, builder = builder)) } diff --git a/library/src/main/res/layout/kau_preference.xml b/library/src/main/res/layout/kau_preference.xml index 4401145..677b0dc 100644 --- a/library/src/main/res/layout/kau_preference.xml +++ b/library/src/main/res/layout/kau_preference.xml @@ -20,45 +20,32 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> + + - - + + + + \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index 9a349e6..9f4b555 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -35,4 +35,5 @@ dependencies { testCompile 'junit:junit:4.12' compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" + compile "com.mikepenz:google-material-typeface:${IICON_GOOGLE}.original@aar" } diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt index 98285d8..ac80fc6 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -9,6 +9,7 @@ import ca.allanwang.kau.utils.darken import ca.allanwang.kau.utils.navigationBarColor import ca.allanwang.kau.utils.showChangelog import ca.allanwang.kau.views.RippleCanvas +import com.mikepenz.google_material_typeface_library.GoogleMaterial class MainActivity : KPrefActivity() { @@ -39,7 +40,8 @@ class MainActivity : KPrefActivity() { configs = { allowCustom = false }) - colorPicker(title = R.string.background_color, description = R.string.color_custom_alpha, + colorPicker(iicon = GoogleMaterial.Icon.gmd_colorize, + title = R.string.background_color, description = R.string.color_custom_alpha, getter = { KPrefSample.bgColor }, setter = { KPrefSample.bgColor = it; bgCanvas.ripple(it, duration = 500L) }, configs = { allowCustomAlpha = true diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml index d76a9e6..56addfd 100644 --- a/sample/src/main/res/values/strings.xml +++ b/sample/src/main/res/values/strings.xml @@ -12,5 +12,5 @@ Background Color This selector allows custom colors This selector does not allow custom colors - This selector allows for custom colors with alpha values kjljkjljk ljl lijl ijlijl + This selector allows for custom colors with alpha values -- cgit v1.2.3