From 9d99b385110c8796b4bba7f7032a3fa2a1af6f16 Mon Sep 17 00:00:00 2001 From: Evgeny Shishkin Date: Wed, 21 Jan 2015 17:02:08 +0300 Subject: [PATCH] Fixes #9 --- CHANGELOG.md | 6 ++++++ README.md | 4 ++-- gradle.properties | 4 ++-- print-sample/build.gradle | 4 ++-- print/build.gradle | 4 ++-- .../com/github/johnkil/print/PrintDrawable.java | 17 ++++++++++++++--- .../github/johnkil/print/PrintViewUtils.java | 2 ++ 7 files changed, 30 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d5a033..0edc432 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ Change Log ========== +Version 1.2.3 *(2015-01-21)* +---------------------------- + +* Fix: Error displaying the graphics preview in the layout editor. + + Version 1.2.2 *(2015-01-20)* ---------------------------- diff --git a/README.md b/README.md index 518bafd..299c711 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Download Gradle: ```groovy -compile 'com.github.johnkil.print:print:1.2.2' +compile 'com.github.johnkil.print:print:1.2.3' ``` Maven: @@ -27,7 +27,7 @@ Maven: com.github.johnkil.print print - 1.2.2 + 1.2.3 aar ``` diff --git a/gradle.properties b/gradle.properties index acf8e2b..7da4f4f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ -VERSION_NAME=1.2.2-SNAPSHOT -VERSION_CODE=5 +VERSION_NAME=1.2.3-SNAPSHOT +VERSION_CODE=6 GROUP=com.github.johnkil.print POM_DESCRIPTION=A lightweight Android library for use iconic fonts. diff --git a/print-sample/build.gradle b/print-sample/build.gradle index 6f56c37..2ebe371 100644 --- a/print-sample/build.gradle +++ b/print-sample/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.github.johnkil.print.sample" minSdkVersion 7 targetSdkVersion 21 - versionCode 5 - versionName "1.2.2" + versionCode 6 + versionName "1.2.3" } } diff --git a/print/build.gradle b/print/build.gradle index 80c7697..c0e35e3 100644 --- a/print/build.gradle +++ b/print/build.gradle @@ -7,8 +7,8 @@ android { defaultConfig { minSdkVersion 3 targetSdkVersion 21 - versionCode 5 - versionName "1.2.2" + versionCode 6 + versionName "1.2.3" } } diff --git a/print/src/main/java/com/github/johnkil/print/PrintDrawable.java b/print/src/main/java/com/github/johnkil/print/PrintDrawable.java index cd179cf..f1ec407 100644 --- a/print/src/main/java/com/github/johnkil/print/PrintDrawable.java +++ b/print/src/main/java/com/github/johnkil/print/PrintDrawable.java @@ -51,6 +51,8 @@ public static class Builder { private Typeface iconFont; private int iconSize; + private boolean inEditMode = false; + /** * Start building a new {@link PrintDrawable} instance. */ @@ -101,6 +103,11 @@ public Builder iconSize(int unit, float size) { return this; } + Builder inEditMode(boolean inEditMode) { + this.inEditMode = inEditMode; + return this; + } + /** * Create the {@link PrintDrawable} instance. */ @@ -114,7 +121,7 @@ public PrintDrawable build() { } } - return new PrintDrawable(context, iconText, iconColor, iconFont, iconSize); + return new PrintDrawable(context, iconText, iconColor, iconFont, iconSize, inEditMode); } } @@ -130,8 +137,10 @@ public PrintDrawable build() { private int mCurIconColor; + private boolean mInEditMode; + private PrintDrawable(Context context, CharSequence iconText, - ColorStateList iconColor, Typeface iconFont, int iconSize) { + ColorStateList iconColor, Typeface iconFont, int iconSize, boolean inEditMode) { mContext = context; mPaint = new Paint(); mPaint.setFlags(mPaint.getFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); @@ -143,6 +152,8 @@ private PrintDrawable(Context context, CharSequence iconText, mIconFont = iconFont; mIconSize = iconSize; + mInEditMode = inEditMode; + mPaint.setTextSize(mIconSize); mPaint.setTypeface(mIconFont); updateIconColors(); @@ -257,7 +268,7 @@ public int getIntrinsicWidth() { @Override public void draw(Canvas canvas) { - if (mIconText != null) { + if (mIconText != null && !mInEditMode) { final Rect bounds = getBounds(); mPaint.getTextPath(mIconText.toString(), 0, mIconText.length(), 0, bounds.height(), mPath); diff --git a/print/src/main/java/com/github/johnkil/print/PrintViewUtils.java b/print/src/main/java/com/github/johnkil/print/PrintViewUtils.java index 33db2b9..2f796b3 100644 --- a/print/src/main/java/com/github/johnkil/print/PrintViewUtils.java +++ b/print/src/main/java/com/github/johnkil/print/PrintViewUtils.java @@ -57,6 +57,8 @@ static PrintDrawable initIcon(Context context, AttributeSet attrs, boolean inEdi int iconSize = a.getDimensionPixelSize(R.styleable.PrintView_iconSize, 0); iconBuilder.iconSize(TypedValue.COMPLEX_UNIT_PX, iconSize); + iconBuilder.inEditMode(inEditMode); + a.recycle(); }