From 8fa7d1466aa07649942712fcc3af5977e105e83e Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Sat, 29 Aug 2015 10:20:07 +0200 Subject: [PATCH 01/13] * improve font initialization --- .../mikepenz/iconics/sample/CustomApplication.java | 3 --- .../main/java/com/mikepenz/iconics/Iconics.java | 14 ++++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/mikepenz/iconics/sample/CustomApplication.java b/app/src/main/java/com/mikepenz/iconics/sample/CustomApplication.java index 50ee64ab..3fab107d 100644 --- a/app/src/main/java/com/mikepenz/iconics/sample/CustomApplication.java +++ b/app/src/main/java/com/mikepenz/iconics/sample/CustomApplication.java @@ -13,9 +13,6 @@ public class CustomApplication extends Application { public void onCreate() { super.onCreate(); - //only required if you add a custom or generic font on your own - Iconics.init(getApplicationContext()); - //register custom fonts like this (or also provide a font definition file) Iconics.registerFont(new CustomFont()); diff --git a/library-core/src/main/java/com/mikepenz/iconics/Iconics.java b/library-core/src/main/java/com/mikepenz/iconics/Iconics.java index 287e9bce..2439a671 100644 --- a/library-core/src/main/java/com/mikepenz/iconics/Iconics.java +++ b/library-core/src/main/java/com/mikepenz/iconics/Iconics.java @@ -40,12 +40,12 @@ public final class Iconics { public static final String TAG = Iconics.class.getSimpleName(); - private static HashMap FONTS; + private static boolean INIT_DONE = false; + private static HashMap FONTS = new HashMap<>(); public static void init(Context ctx) { String[] fonts = GenericsUtil.getFields(ctx); - FONTS = new HashMap<>(); for (String fontsClassPath : fonts) { try { ITypeface typeface = (ITypeface) Class.forName(fontsClassPath).newInstance(); @@ -54,6 +54,8 @@ public static void init(Context ctx) { Log.e("Android-Iconics", "Can't init: " + fontsClassPath); } } + + INIT_DONE = true; } public static boolean registerFont(ITypeface font) { @@ -62,7 +64,7 @@ public static boolean registerFont(ITypeface font) { } public static ITypeface getDefault(Context ctx) { - if (FONTS == null) { + if (!INIT_DONE) { init(ctx); } @@ -74,7 +76,7 @@ public static ITypeface getDefault(Context ctx) { } public static Collection getRegisteredFonts(Context ctx) { - if (FONTS == null) { + if (!INIT_DONE) { init(ctx); } @@ -82,7 +84,7 @@ public static Collection getRegisteredFonts(Context ctx) { } public static ITypeface findFont(Context ctx, String key) { - if (FONTS == null) { + if (!INIT_DONE) { init(ctx); } @@ -98,7 +100,7 @@ private Iconics() { } private static SpannableString style(Context ctx, HashMap fonts, SpannableString textSpanned, List styles, HashMap> stylesFor) { - if (FONTS == null) { + if (!INIT_DONE) { init(ctx); } From 292d0df2ce4d3f30f1fceb40793d2b1c139658c8 Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Mon, 31 Aug 2015 22:29:40 +0200 Subject: [PATCH 02/13] Update README.md * add ProGuard information for AutoDetecting --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e84cc12d..4008bb81 100644 --- a/README.md +++ b/README.md @@ -314,7 +314,14 @@ public class CustomFont implements ITypeface { ``` #ProGuard -ProGuard rules are now bundled internally with each font. No additional rules are required on your end. +Exclude `R` from ProGuard to enable the font addon auto detection +```proguard +-keep class .R +-keep class .R$* { + ; +} +``` +All other ProGuard rules are now bundled internally with each font. #Demo You can try the sample application out. It's on Google Play ;) From 715ed6483996d23f645af6b5253aaf42024a615f Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Tue, 1 Sep 2015 19:43:35 +0200 Subject: [PATCH 03/13] * update to gradle 2.6 --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 22da0bce..761f7b44 100644 --- a/build.gradle +++ b/build.gradle @@ -30,5 +30,5 @@ allprojects { task wrapper(type: Wrapper) { - gradleVersion = '2.5' + gradleVersion = '2.6' } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1f5570df..43b8ab01 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Jun 04 00:41:53 CEST 2015 +#Tue Sep 01 18:52:34 CEST 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-all.zip From 15bb7707539aacdb25370ff68523bb5a0cc5894f Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Tue, 1 Sep 2015 19:47:23 +0200 Subject: [PATCH 04/13] * use the ContextCompat to get the color from Res to use the Theme for the Color starting with Android M --- library-core/build.gradle | 1 + .../main/java/com/mikepenz/iconics/IconicsDrawable.java | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/library-core/build.gradle b/library-core/build.gradle index 48e6d955..5e6c52c1 100644 --- a/library-core/build.gradle +++ b/library-core/build.gradle @@ -26,4 +26,5 @@ if (project.hasProperty('pushall') || project.hasProperty('librarycoreonly')) { dependencies { compile 'com.android.support:support-annotations:23.0.0' + compile 'com.android.support:support-v4:23.0.0' } diff --git a/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java b/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java index a3e0958d..f1ad8b46 100644 --- a/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java +++ b/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java @@ -44,6 +44,7 @@ import android.graphics.RectF; import android.graphics.Typeface; import android.graphics.drawable.Drawable; +import android.support.v4.content.ContextCompat; import android.util.Log; import com.mikepenz.iconics.typeface.IIcon; @@ -242,7 +243,7 @@ public int adjustAlpha(int color, float factor) { * @return The current IconExtDrawable for chaining. */ public IconicsDrawable colorRes(int colorRes) { - return color(mContext.getResources().getColor(colorRes)); + return color(ContextCompat.getColor(mContext, colorRes)); } @@ -493,7 +494,7 @@ public IconicsDrawable contourColor(int contourColor) { * @return The current IconExtDrawable for chaining. */ public IconicsDrawable contourColorRes(int contourColorRes) { - mContourPaint.setColor(mContext.getResources().getColor(contourColorRes)); + mContourPaint.setColor(ContextCompat.getColor(mContext, contourColorRes)); drawContour(true); invalidateSelf(); return this; @@ -519,7 +520,7 @@ public IconicsDrawable backgroundColor(int backgroundColor) { * @return */ public IconicsDrawable backgroundColorRes(int backgroundColorRes) { - return backgroundColor(mContext.getResources().getColor(backgroundColorRes)); + return backgroundColor(ContextCompat.getColor(mContext, backgroundColorRes)); } /** From 22663b8bd9337a488e1bb7758c41e7fa2916ec6c Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Tue, 1 Sep 2015 19:51:22 +0200 Subject: [PATCH 05/13] * update gradle build tools to v1.3.1 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 761f7b44..55bc342b 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.3.0' + classpath 'com.android.tools.build:gradle:1.3.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files From f6218ff5410611661d5cde61d6051469f102b090 Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Tue, 1 Sep 2015 20:00:17 +0200 Subject: [PATCH 06/13] * remove support annotations dependency as it is already a child of the appcompat-v7 dependency --- library-core/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/library-core/build.gradle b/library-core/build.gradle index 5e6c52c1..edeedd4a 100644 --- a/library-core/build.gradle +++ b/library-core/build.gradle @@ -25,6 +25,5 @@ if (project.hasProperty('pushall') || project.hasProperty('librarycoreonly')) { } dependencies { - compile 'com.android.support:support-annotations:23.0.0' compile 'com.android.support:support-v4:23.0.0' } From d4c703ff52cfd47dfd247ca884d8ce714e905e8f Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Tue, 1 Sep 2015 20:00:29 +0200 Subject: [PATCH 07/13] * remove unused method --- .../src/main/java/com/mikepenz/iconics/Iconics.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/library-core/src/main/java/com/mikepenz/iconics/Iconics.java b/library-core/src/main/java/com/mikepenz/iconics/Iconics.java index 2439a671..364f0df2 100644 --- a/library-core/src/main/java/com/mikepenz/iconics/Iconics.java +++ b/library-core/src/main/java/com/mikepenz/iconics/Iconics.java @@ -63,18 +63,6 @@ public static boolean registerFont(ITypeface font) { return true; } - public static ITypeface getDefault(Context ctx) { - if (!INIT_DONE) { - init(ctx); - } - - if (FONTS != null && FONTS.size() > 0) { - return FONTS.entrySet().iterator().next().getValue(); - } else { - throw new RuntimeException("You have to provide at least one Typeface to use this functionality"); - } - } - public static Collection getRegisteredFonts(Context ctx) { if (!INIT_DONE) { init(ctx); From 75ac9721a109d0421aba2efe0cd8b63cb118a14e Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Tue, 1 Sep 2015 20:01:04 +0200 Subject: [PATCH 08/13] * add some support annotations to the IconicsDrawable to prevent wrong color/dimen --- .../com/mikepenz/iconics/IconicsDrawable.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java b/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java index f1ad8b46..fd2499fc 100644 --- a/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java +++ b/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java @@ -44,6 +44,9 @@ import android.graphics.RectF; import android.graphics.Typeface; import android.graphics.drawable.Drawable; +import android.support.annotation.ColorInt; +import android.support.annotation.ColorRes; +import android.support.annotation.DimenRes; import android.support.v4.content.ContextCompat; import android.util.Log; @@ -216,7 +219,7 @@ public IconicsDrawable icon(ITypeface typeface, IIcon icon) { * @param color The color, usually from android.graphics.Color or 0xFF012345. * @return The current IconExtDrawable for chaining. */ - public IconicsDrawable color(int color) { + public IconicsDrawable color(@ColorInt int color) { int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); @@ -242,7 +245,7 @@ public int adjustAlpha(int color, float factor) { * @param colorRes The color resource, from your R file. * @return The current IconExtDrawable for chaining. */ - public IconicsDrawable colorRes(int colorRes) { + public IconicsDrawable colorRes(@ColorRes int colorRes) { return color(ContextCompat.getColor(mContext, colorRes)); } @@ -253,7 +256,7 @@ public IconicsDrawable colorRes(int colorRes) { * @param iconOffsetXRes * @return */ - public IconicsDrawable iconOffsetXRes(int iconOffsetXRes) { + public IconicsDrawable iconOffsetXRes(@DimenRes int iconOffsetXRes) { return iconOffsetXPx(mContext.getResources().getDimensionPixelSize(iconOffsetXRes)); } @@ -284,7 +287,7 @@ public IconicsDrawable iconOffsetXPx(int iconOffsetX) { * @param iconOffsetYRes * @return */ - public IconicsDrawable iconOffsetYRes(int iconOffsetYRes) { + public IconicsDrawable iconOffsetYRes(@DimenRes int iconOffsetYRes) { return iconOffsetYPx(mContext.getResources().getDimensionPixelSize(iconOffsetYRes)); } @@ -315,7 +318,7 @@ public IconicsDrawable iconOffsetYPx(int iconOffsetY) { * @param dimenRes * @return The current IconExtDrawable for chaining. */ - public IconicsDrawable paddingRes(int dimenRes) { + public IconicsDrawable paddingRes(@DimenRes int dimenRes) { return paddingPx(mContext.getResources().getDimensionPixelSize(dimenRes)); } @@ -376,7 +379,7 @@ public IconicsDrawable actionBar() { * @param dimenRes The dimension resource. * @return The current IconExtDrawable for chaining. */ - public IconicsDrawable sizeRes(int dimenRes) { + public IconicsDrawable sizeRes(@DimenRes int dimenRes) { return sizePx(mContext.getResources().getDimensionPixelSize(dimenRes)); } @@ -411,7 +414,7 @@ public IconicsDrawable sizePx(int size) { * @param dimenResX The dimension resource. * @return The current IconExtDrawable for chaining. */ - public IconicsDrawable sizeResX(int dimenResX) { + public IconicsDrawable sizeResX(@DimenRes int dimenResX) { return sizePxX(mContext.getResources().getDimensionPixelSize(dimenResX)); } @@ -445,7 +448,7 @@ public IconicsDrawable sizePxX(int sizeX) { * @param dimenResY The dimension resource. * @return The current IconExtDrawable for chaining. */ - public IconicsDrawable sizeResY(int dimenResY) { + public IconicsDrawable sizeResY(@DimenRes int dimenResY) { return sizePxY(mContext.getResources().getDimensionPixelSize(dimenResY)); } @@ -480,7 +483,7 @@ public IconicsDrawable sizePxY(int sizeY) { * @param contourColor * @return The current IconExtDrawable for chaining. */ - public IconicsDrawable contourColor(int contourColor) { + public IconicsDrawable contourColor(@ColorInt int contourColor) { mContourPaint.setColor(contourColor); drawContour(true); invalidateSelf(); @@ -493,7 +496,7 @@ public IconicsDrawable contourColor(int contourColor) { * @param contourColorRes * @return The current IconExtDrawable for chaining. */ - public IconicsDrawable contourColorRes(int contourColorRes) { + public IconicsDrawable contourColorRes(@ColorRes int contourColorRes) { mContourPaint.setColor(ContextCompat.getColor(mContext, contourColorRes)); drawContour(true); invalidateSelf(); @@ -506,7 +509,7 @@ public IconicsDrawable contourColorRes(int contourColorRes) { * @param backgroundColor * @return */ - public IconicsDrawable backgroundColor(int backgroundColor) { + public IconicsDrawable backgroundColor(@ColorInt int backgroundColor) { this.mBackgroundPaint.setColor(backgroundColor); this.mRoundedCornerRx = 0; this.mRoundedCornerRy = 0; @@ -519,7 +522,7 @@ public IconicsDrawable backgroundColor(int backgroundColor) { * @param backgroundColorRes * @return */ - public IconicsDrawable backgroundColorRes(int backgroundColorRes) { + public IconicsDrawable backgroundColorRes(@ColorRes int backgroundColorRes) { return backgroundColor(ContextCompat.getColor(mContext, backgroundColorRes)); } @@ -529,7 +532,7 @@ public IconicsDrawable backgroundColorRes(int backgroundColorRes) { * @param roundedCornerRxRes * @return */ - public IconicsDrawable roundedCornersRxRes(int roundedCornerRxRes) { + public IconicsDrawable roundedCornersRxRes(@DimenRes int roundedCornerRxRes) { this.mRoundedCornerRx = mContext.getResources().getDimensionPixelSize(roundedCornerRxRes); return this; } @@ -562,7 +565,7 @@ public IconicsDrawable roundedCornersRxPx(int roundedCornerRxPx) { * @param roundedCornerRyRes * @return */ - public IconicsDrawable roundedCornersRyRes(int roundedCornerRyRes) { + public IconicsDrawable roundedCornersRyRes(@DimenRes int roundedCornerRyRes) { this.mRoundedCornerRy = mContext.getResources().getDimensionPixelSize(roundedCornerRyRes); return this; } @@ -595,7 +598,7 @@ public IconicsDrawable roundedCornersRyPx(int roundedCornerRyPx) { * @param roundedCornerRes * @return */ - public IconicsDrawable roundedCornersRes(int roundedCornerRes) { + public IconicsDrawable roundedCornersRes(@DimenRes int roundedCornerRes) { this.mRoundedCornerRx = mContext.getResources().getDimensionPixelSize(roundedCornerRes); this.mRoundedCornerRy = this.mRoundedCornerRx; return this; @@ -631,7 +634,7 @@ public IconicsDrawable roundedCornersPx(int roundedCornerPx) { * @param contourWidthRes * @return The current IconExtDrawable for chaining. */ - public IconicsDrawable contourWidthRes(int contourWidthRes) { + public IconicsDrawable contourWidthRes(@DimenRes int contourWidthRes) { return contourWidthPx(mContext.getResources().getDimensionPixelSize(contourWidthRes)); } From e926aec7174e45ea88191204942bc88ac2f92abe Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Tue, 1 Sep 2015 21:36:03 +0200 Subject: [PATCH 09/13] * add more attributes to the IconicsImageView --- .../iconics/view/IconicsImageView.java | 94 +++++++++++++++---- library-core/src/main/res/values/attrs.xml | 4 + 2 files changed, 81 insertions(+), 17 deletions(-) diff --git a/library-core/src/main/java/com/mikepenz/iconics/view/IconicsImageView.java b/library-core/src/main/java/com/mikepenz/iconics/view/IconicsImageView.java index da86ccfa..2584cd11 100644 --- a/library-core/src/main/java/com/mikepenz/iconics/view/IconicsImageView.java +++ b/library-core/src/main/java/com/mikepenz/iconics/view/IconicsImageView.java @@ -32,6 +32,12 @@ public class IconicsImageView extends ImageView { private IconicsDrawable mIcon = null; private int mColor = 0; + private int mSize = -1; + private int mPadding = -1; + private int mContourColor = 0; + private int mContourWidth = -1; + private int mBackgroundColor = 0; + private int mCornerRadius = -1; public IconicsImageView(Context context) { this(context, null); @@ -50,6 +56,15 @@ public IconicsImageView(Context context, AttributeSet attrs, int defStyle) { //set the color even if we had no image yet mColor = a.getColor(R.styleable.IconicsImageView_iiv_color, 0); + mSize = a.getDimensionPixelSize(R.styleable.IconicsImageView_iiv_size, -1); + mPadding = a.getDimensionPixelSize(R.styleable.IconicsImageView_iiv_padding, -1); + mContourColor = a.getColor(R.styleable.IconicsImageView_iiv_contour_color, 0); + mContourWidth = a.getDimensionPixelSize(R.styleable.IconicsImageView_iiv_contour_width, -1); + mBackgroundColor = a.getColor(R.styleable.IconicsImageView_iiv_background_color, 0); + mCornerRadius = a.getDimensionPixelSize(R.styleable.IconicsImageView_iiv_corner_radius, -1); + + //recycle the typedArray + a.recycle(); //set the scale type for this view setScaleType(ScaleType.CENTER_INSIDE); @@ -59,43 +74,88 @@ public IconicsImageView(Context context, AttributeSet attrs, int defStyle) { return; } - int mSize = a.getDimensionPixelSize(R.styleable.IconicsImageView_iiv_size, -1); - int mPadding = a.getDimensionPixelSize(R.styleable.IconicsImageView_iiv_padding, -1); //get the drawable mIcon = new IconicsDrawable(context, icon); - if (mColor != 0) { - mIcon.color(mColor); - } - if (mSize != -1) { - mIcon.sizePx(mSize); - } - if (mSize != -1) { - mIcon.paddingPx(mPadding); - } - a.recycle(); + + //set attributes + setAttributes(); //set our values for this view setImageDrawable(mIcon); } } + public void setIcon(Character icon) { + setIcon(icon, true); + } + + public void setIcon(Character icon, boolean resetAttributes) { + setIcon(new IconicsDrawable(getContext(), icon), resetAttributes); + } + public void setIcon(String icon) { - setIcon(new IconicsDrawable(getContext(), icon)); + setIcon(icon, true); + } + + public void setIcon(String icon, boolean resetAttributes) { + setIcon(new IconicsDrawable(getContext(), icon), resetAttributes); } public void setIcon(IIcon icon) { - setIcon(new IconicsDrawable(getContext(), icon)); + setIcon(icon, true); + } + + public void setIcon(IIcon icon, boolean resetAttributes) { + setIcon(new IconicsDrawable(getContext(), icon), resetAttributes); } public void setIcon(IconicsDrawable icon) { - if (mColor != 0) { - icon.color(mColor); - } + setIcon(icon, true); + } + + public void setIcon(IconicsDrawable icon, boolean resetAttributes) { mIcon = icon; + //reset the attributes defined via the layout + if (resetAttributes) { + setAttributes(); + } + //set the imageDrawable setImageDrawable(mIcon); } + public void setIconText(String iconText) { + setIconText(iconText, true); + } + + public void setIconText(String iconText, boolean resetAttributes) { + setIcon(new IconicsDrawable(getContext()).iconText(iconText), resetAttributes); + } + + private void setAttributes() { + if (mColor != 0) { + mIcon.color(mColor); + } + if (mSize != -1) { + mIcon.sizePx(mSize); + } + if (mSize != -1) { + mIcon.paddingPx(mPadding); + } + if (mContourColor != 0) { + mIcon.contourColor(mContourColor); + } + if (mContourWidth != -1) { + mIcon.contourWidthPx(mContourWidth); + } + if (mBackgroundColor != 0) { + mIcon.backgroundColor(mBackgroundColor); + } + if (mCornerRadius != -1) { + mIcon.roundedCornersPx(mCornerRadius); + } + } + public void setColor(@ColorInt int color) { if (getDrawable() instanceof IconicsDrawable) { ((IconicsDrawable) getDrawable()).color(color); diff --git a/library-core/src/main/res/values/attrs.xml b/library-core/src/main/res/values/attrs.xml index 9ad29acf..46d638b8 100644 --- a/library-core/src/main/res/values/attrs.xml +++ b/library-core/src/main/res/values/attrs.xml @@ -20,5 +20,9 @@ + + + + \ No newline at end of file From 0428c8f59b0f2bc0a2f5c0b7380b17b1ee923b2d Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Tue, 1 Sep 2015 21:36:36 +0200 Subject: [PATCH 10/13] * mark method as protected --- .../src/main/java/com/mikepenz/iconics/IconicsDrawable.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java b/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java index fd2499fc..8ddff1f1 100644 --- a/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java +++ b/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java @@ -124,7 +124,7 @@ public IconicsDrawable(Context context, final IIcon icon) { icon(icon); } - public IconicsDrawable(Context context, final ITypeface typeface, final IIcon icon) { + protected IconicsDrawable(Context context, final ITypeface typeface, final IIcon icon) { mContext = context.getApplicationContext(); prepare(); icon(typeface, icon); @@ -206,7 +206,7 @@ public IconicsDrawable icon(IIcon icon) { * @param icon * @return The current IconExtDrawable for chaining. */ - public IconicsDrawable icon(ITypeface typeface, IIcon icon) { + protected IconicsDrawable icon(ITypeface typeface, IIcon icon) { mIcon = icon; mIconPaint.setTypeface(typeface.getTypeface(mContext)); invalidateSelf(); From 22dfc153213f7333c23a9d8885e7c4ac60a1e1a7 Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Tue, 1 Sep 2015 21:36:48 +0200 Subject: [PATCH 11/13] * improve alpha handling for contour * improve alpha handling for color --- .../java/com/mikepenz/iconics/IconicsDrawable.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java b/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java index 8ddff1f1..86ae0684 100644 --- a/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java +++ b/library-core/src/main/java/com/mikepenz/iconics/IconicsDrawable.java @@ -484,8 +484,11 @@ public IconicsDrawable sizePxY(int sizeY) { * @return The current IconExtDrawable for chaining. */ public IconicsDrawable contourColor(@ColorInt int contourColor) { - mContourPaint.setColor(contourColor); - drawContour(true); + int red = Color.red(contourColor); + int green = Color.green(contourColor); + int blue = Color.blue(contourColor); + mContourPaint.setColor(Color.rgb(red, green, blue)); + mContourPaint.setAlpha(Color.alpha(contourColor)); invalidateSelf(); return this; } @@ -497,10 +500,7 @@ public IconicsDrawable contourColor(@ColorInt int contourColor) { * @return The current IconExtDrawable for chaining. */ public IconicsDrawable contourColorRes(@ColorRes int contourColorRes) { - mContourPaint.setColor(ContextCompat.getColor(mContext, contourColorRes)); - drawContour(true); - invalidateSelf(); - return this; + return contourColor(ContextCompat.getColor(mContext, contourColorRes)); } /** @@ -782,7 +782,7 @@ public int getOpacity() { @Override public void setAlpha(int alpha) { - //mIconPaint.setAlpha(alpha); + mIconPaint.setAlpha(alpha); mAlpha = alpha; } From 608d8f664788ba6c456038283a445d81d81bc2d7 Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Tue, 1 Sep 2015 21:37:49 +0200 Subject: [PATCH 12/13] * [release] v1.7.5 --- README.md | 2 +- app/build.gradle | 4 ++-- library-core/build.gradle | 4 ++-- library-core/gradle.properties | 4 ++-- .../src/main/res/values/library_androidiconics_strings.xml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4008bb81..7250a426 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Provide additional fonts for you project, or even create your custom font with j ##1. Provide the gradle dependency ```gradle dependencies { - compile 'com.mikepenz:iconics-core:1.7.4@aar' + compile 'com.mikepenz:iconics-core:1.7.5@aar' } ``` diff --git a/app/build.gradle b/app/build.gradle index 5455d9c3..25d76808 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,8 +12,8 @@ android { defaultConfig { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 174 - versionName "1.7.4" + versionCode 175 + versionName "1.7.5" enforceUniquePackageName false } diff --git a/library-core/build.gradle b/library-core/build.gradle index edeedd4a..e1509564 100644 --- a/library-core/build.gradle +++ b/library-core/build.gradle @@ -7,8 +7,8 @@ android { defaultConfig { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 174 - versionName "1.7.4" + versionCode 175 + versionName "1.7.5" } buildTypes { release { diff --git a/library-core/gradle.properties b/library-core/gradle.properties index 0af4f641..a8a8d14c 100755 --- a/library-core/gradle.properties +++ b/library-core/gradle.properties @@ -32,8 +32,8 @@ # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME=1.7.4 -VERSION_CODE=174 +VERSION_NAME=1.7.5 +VERSION_CODE=175 POM_NAME=Android-Iconics Library POM_ARTIFACT_ID=iconics-core diff --git a/library-core/src/main/res/values/library_androidiconics_strings.xml b/library-core/src/main/res/values/library_androidiconics_strings.xml index 8b52fb33..72b94134 100755 --- a/library-core/src/main/res/values/library_androidiconics_strings.xml +++ b/library-core/src/main/res/values/library_androidiconics_strings.xml @@ -25,7 +25,7 @@ This library allows you to include vector icons everywhere in your project. No limits are given. Scale with no limit, use any Color at any time, provide a contour, and many additional customizations ]]> - 1.7.4 + 1.7.5 https://github.com/mikepenz/Android-Iconics apache_2_0 true From 91d375f74966b469b026bf252618b0ac8db2c448 Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Tue, 1 Sep 2015 21:40:30 +0200 Subject: [PATCH 13/13] * do not use unnecessary protected method --- .../java/com/mikepenz/iconics/sample/PlaygroundActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/mikepenz/iconics/sample/PlaygroundActivity.java b/app/src/main/java/com/mikepenz/iconics/sample/PlaygroundActivity.java index 166455a9..18ffb631 100644 --- a/app/src/main/java/com/mikepenz/iconics/sample/PlaygroundActivity.java +++ b/app/src/main/java/com/mikepenz/iconics/sample/PlaygroundActivity.java @@ -36,10 +36,10 @@ import android.widget.ListView; import android.widget.TextView; +import com.mikepenz.fontawesome_typeface_library.FontAwesome; import com.mikepenz.iconics.Iconics; import com.mikepenz.iconics.IconicsArrayBuilder; import com.mikepenz.iconics.IconicsDrawable; -import com.mikepenz.fontawesome_typeface_library.FontAwesome; import com.mikepenz.octicons_typeface_library.Octicons; @@ -72,7 +72,7 @@ protected void onCreate(Bundle savedInstanceState) { //Set the icon of an ImageView (or something else) as bitmap ImageView iv3 = (ImageView) findViewById(R.id.test3); - iv3.setImageBitmap(new IconicsDrawable(this, new FontAwesome(), FontAwesome.Icon.faw_android).sizeDpX(48).sizeDpY(32).paddingDp(4).roundedCornersDp(8).color(Color.parseColor("#deFF0000")).toBitmap()); + iv3.setImageBitmap(new IconicsDrawable(this, FontAwesome.Icon.faw_android).sizeDpX(48).sizeDpY(32).paddingDp(4).roundedCornersDp(8).color(Color.parseColor("#deFF0000")).toBitmap()); //Show how to style the text of an existing button (NOT WORKING AT THE MOMENT) Button b4 = (Button) findViewById(R.id.test4);