Skip to content

Commit

Permalink
Merge branch 'release/v1.7.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Sep 1, 2015
2 parents 4452d22 + 91d375f commit 2b065d2
Showing 13 changed files with 142 additions and 80 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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'
}
```

@@ -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$* {
<fields>;
}
```
All other ProGuard rules are now bundled internally with each font.

#Demo
You can try the sample application out. It's on Google Play ;)
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -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
}

Original file line number Diff line number Diff line change
@@ -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());

Original file line number Diff line number Diff line change
@@ -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);
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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
@@ -30,5 +30,5 @@ allprojects {


task wrapper(type: Wrapper) {
gradleVersion = '2.5'
gradleVersion = '2.6'
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions library-core/build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
@@ -25,5 +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'
}
4 changes: 2 additions & 2 deletions library-core/gradle.properties
Original file line number Diff line number Diff line change
@@ -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
24 changes: 7 additions & 17 deletions library-core/src/main/java/com/mikepenz/iconics/Iconics.java
Original file line number Diff line number Diff line change
@@ -40,12 +40,12 @@
public final class Iconics {
public static final String TAG = Iconics.class.getSimpleName();

private static HashMap<String, ITypeface> FONTS;
private static boolean INIT_DONE = false;
private static HashMap<String, ITypeface> 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,35 +54,25 @@ public static void init(Context ctx) {
Log.e("Android-Iconics", "Can't init: " + fontsClassPath);
}
}

INIT_DONE = true;
}

public static boolean registerFont(ITypeface font) {
FONTS.put(font.getMappingPrefix(), font);
return true;
}

public static ITypeface getDefault(Context ctx) {
if (FONTS == null) {
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<ITypeface> getRegisteredFonts(Context ctx) {
if (FONTS == null) {
if (!INIT_DONE) {
init(ctx);
}

return FONTS.values();
}

public static ITypeface findFont(Context ctx, String key) {
if (FONTS == null) {
if (!INIT_DONE) {
init(ctx);
}

@@ -98,7 +88,7 @@ private Iconics() {
}

private static SpannableString style(Context ctx, HashMap<String, ITypeface> fonts, SpannableString textSpanned, List<CharacterStyle> styles, HashMap<String, List<CharacterStyle>> stylesFor) {
if (FONTS == null) {
if (!INIT_DONE) {
init(ctx);
}

Original file line number Diff line number Diff line change
@@ -44,6 +44,10 @@
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;

import com.mikepenz.iconics.typeface.IIcon;
@@ -120,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);
@@ -202,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();
@@ -215,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);
@@ -241,8 +245,8 @@ 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) {
return color(mContext.getResources().getColor(colorRes));
public IconicsDrawable colorRes(@ColorRes int colorRes) {
return color(ContextCompat.getColor(mContext, colorRes));
}


@@ -252,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));
}

@@ -283,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));
}

@@ -314,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));
}

@@ -375,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));
}

@@ -410,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));
}

@@ -444,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));
}

@@ -479,9 +483,12 @@ public IconicsDrawable sizePxY(int sizeY) {
* @param contourColor
* @return The current IconExtDrawable for chaining.
*/
public IconicsDrawable contourColor(int contourColor) {
mContourPaint.setColor(contourColor);
drawContour(true);
public IconicsDrawable contourColor(@ColorInt int contourColor) {
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;
}
@@ -492,11 +499,8 @@ public IconicsDrawable contourColor(int contourColor) {
* @param contourColorRes
* @return The current IconExtDrawable for chaining.
*/
public IconicsDrawable contourColorRes(int contourColorRes) {
mContourPaint.setColor(mContext.getResources().getColor(contourColorRes));
drawContour(true);
invalidateSelf();
return this;
public IconicsDrawable contourColorRes(@ColorRes int contourColorRes) {
return contourColor(ContextCompat.getColor(mContext, contourColorRes));
}

/**
@@ -505,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;
@@ -518,8 +522,8 @@ public IconicsDrawable backgroundColor(int backgroundColor) {
* @param backgroundColorRes
* @return
*/
public IconicsDrawable backgroundColorRes(int backgroundColorRes) {
return backgroundColor(mContext.getResources().getColor(backgroundColorRes));
public IconicsDrawable backgroundColorRes(@ColorRes int backgroundColorRes) {
return backgroundColor(ContextCompat.getColor(mContext, backgroundColorRes));
}

/**
@@ -528,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;
}
@@ -561,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;
}
@@ -594,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;
@@ -630,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));
}

@@ -778,7 +782,7 @@ public int getOpacity() {

@Override
public void setAlpha(int alpha) {
//mIconPaint.setAlpha(alpha);
mIconPaint.setAlpha(alpha);
mAlpha = alpha;
}

Loading

0 comments on commit 2b065d2

Please sign in to comment.