Skip to content

Commit

Permalink
Fixes #9
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkil committed Jan 21, 2015
1 parent dde1dbc commit 9d99b38
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)*
----------------------------

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -27,7 +27,7 @@ Maven:
<dependency>
<groupId>com.github.johnkil.print</groupId>
<artifactId>print</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
<type>aar</type>
</dependency>
```
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions print-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

Expand Down
4 changes: 2 additions & 2 deletions print/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 3
targetSdkVersion 21
versionCode 5
versionName "1.2.2"
versionCode 6
versionName "1.2.3"
}
}

Expand Down
17 changes: 14 additions & 3 deletions print/src/main/java/com/github/johnkil/print/PrintDrawable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*/
Expand All @@ -114,7 +121,7 @@ public PrintDrawable build() {
}
}

return new PrintDrawable(context, iconText, iconColor, iconFont, iconSize);
return new PrintDrawable(context, iconText, iconColor, iconFont, iconSize, inEditMode);
}
}

Expand All @@ -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);
Expand All @@ -143,6 +152,8 @@ private PrintDrawable(Context context, CharSequence iconText,
mIconFont = iconFont;
mIconSize = iconSize;

mInEditMode = inEditMode;

mPaint.setTextSize(mIconSize);
mPaint.setTypeface(mIconFont);
updateIconColors();
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 9d99b38

Please sign in to comment.