Skip to content

Commit

Permalink
This fixes #2, resolves #3 and closes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkil committed Oct 21, 2014
1 parent 5cc46c7 commit 55e4cd8
Show file tree
Hide file tree
Showing 37 changed files with 1,712 additions and 1,221 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ Change Log
==========


Version 1.2.0 *(2014-10-21)*
----------------------------

* Support multiple iconic fonts.
* Support for displaying the preview in edit mode.
* Fix: Font size too large to fit in cache.


Version 1.1.0 *(2014-10-06)*
----------------------------

Expand Down
44 changes: 29 additions & 15 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.1.0'
compile 'com.github.johnkil.print:print:1.2.0'
```

Maven:
Expand All @@ -27,22 +27,23 @@ Maven:
<dependency>
<groupId>com.github.johnkil.print</groupId>
<artifactId>print</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</dependency>
```

Usage
-----

First, you need to initialize the iconic font in [Application.onCreate()][1] method.
First, you need to initialize the default iconic font in [Application.onCreate()][1] method. If
the font is not specified, then the font is used by default.

```java
public class MyApplication extends Application {

@Override
public void onCreate() {
super.onCreate();
Print.initFont(getAssets(), "fonts/iconic-font.ttf");
PrintConfig.initDefault(getAssets(), "fonts/iconic-font.ttf");
}

}
Expand All @@ -53,11 +54,12 @@ public class MyApplication extends Application {
Use `PrintView` as single icon in your layout.

```xml
<com.github.johnkil.print.widget.PrintView
<com.github.johnkil.print.PrintView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
print:iconColor="@color/icon_color"
print:iconSize="@dimen/icon_size"
print:iconFont="fonts/iconic-font.ttf"
print:iconText="@string/ic_android"
android:contentDescription="@string/ic_android_description"/>
```
Expand All @@ -67,11 +69,12 @@ Use `PrintView` as single icon in your layout.
Use `PrintButton` to create a button with an icon.

```xml
<com.github.johnkil.print.widget.PrintButton
<com.github.johnkil.print.PrintButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
print:iconColor="@color/icon_color"
print:iconSize="@dimen/icon_size"
print:iconFont="fonts/iconic-font.ttf"
print:iconText="@string/ic_android"
android:contentDescription="@string/ic_android_description"/>
```
Expand All @@ -83,10 +86,14 @@ If you need an icon in `ImageView` or in `ActionBar`, then you should use `Print
```java
ImageView imageView = (ImageView) findViewById(R.id.image);
// Set an icon in the ImageView
imageView.setImageDrawable(new PrintDrawable()
.iconText(getResources().getString(R.string.ic_info))
.iconColor(getResources().getColor(R.color.icon_color))
.iconSize(getResources().getDimensionPixelSize(R.dimen.icon_size)));
imageView.setImageDrawable(
new PrintDrawable.Builder(context)
.iconText(R.string.ic_info)
.iconColor(R.color.icon_color)
.iconSize(R.dimen.icon_size)
.iconFont("fonts/iconic-font.ttf")
.build()
);
```

```java
Expand All @@ -95,10 +102,12 @@ public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
// Set an icon in the ActionBar
menu.findItem(R.id.action_info).setIcon(
new PrintDrawable()
.iconText(getResources().getString(R.string.ic_info))
.iconColor(getResources().getColor(R.color.ab_icon_color))
.iconSize(getResources().getDimensionPixelSize(R.dimen.ab_icon_size))
new PrintDrawable.Builder(context)
.iconText(R.string.ic_info)
.iconColor(R.color.ab_icon_color)
.iconSize(R.dimen.ab_icon_size)
.iconFont("fonts/iconic-font.ttf")
.build()
);
return true;
}
Expand Down Expand Up @@ -129,4 +138,9 @@ License


[1]: http://developer.android.com/reference/android/app/Application.html#onCreate%28%29
[2]: https://github.com/johnkil/Android-Icon-Fonts
[2]: https://github.com/johnkil/Android-Icon-Fonts

[0]: https://github.com/shamanland/fonticon
[0]: https://github.com/atermenji/IconicDroid
[0]: https://github.com/JoanZapata/android-iconify
[0]: https://github.com/chrisjenx/Calligraphy
File renamed without changes
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.2'
classpath 'com.android.tools.build:gradle:0.13.3'
}
}

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.1.0-SNAPSHOT
VERSION_CODE=2
VERSION_NAME=1.2.0-SNAPSHOT
VERSION_CODE=3
GROUP=com.github.johnkil.print

POM_DESCRIPTION=A lightweight Android library for use iconic fonts.
Expand Down
12 changes: 6 additions & 6 deletions print-sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
compileSdkVersion 21
buildToolsVersion "21.0.1"

defaultConfig {
applicationId "com.github.johnkil.print.sample"
minSdkVersion 8
targetSdkVersion 20
versionCode 2
versionName "1.1.0"
targetSdkVersion 21
versionCode 3
versionName "1.2.0"
}
}

dependencies {
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
compile project(':print')
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014 Evgeny Shishkin
* Copyright (C) 2014 Evgeny Shishkin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,13 +25,9 @@
import android.widget.SeekBar;
import android.widget.TextView;

import com.github.johnkil.print.drawable.PrintDrawable;
import com.github.johnkil.print.widget.PrintView;
import com.github.johnkil.print.PrintDrawable;
import com.github.johnkil.print.PrintView;


/**
* @author Evgeny Shishkin
*/
public class MainActivity extends ActionBarActivity {

@Override
Expand All @@ -46,9 +42,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
sizeValue.setText(getString(R.string.size_format, progress));
int iconSize = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, progress, getResources().getDisplayMetrics());
iconView.setIconSize(iconSize);
iconView.setIconSize(TypedValue.COMPLEX_UNIT_DIP, progress);
}

@Override
Expand All @@ -70,16 +64,19 @@ public void onClick(View v) {
// on click process
}
});

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
menu.findItem(R.id.action_info).setIcon(
new PrintDrawable()
.iconText(getResources().getString(R.string.ic_info))
.iconColor(getResources().getColor(R.color.ab_icon_color))
.iconSize(getResources().getDimensionPixelSize(R.dimen.ab_icon_size))
new PrintDrawable.Builder(this)
.iconText(R.string.ic_holo_about)
.iconColor(R.color.ab_icon_color)
.iconFont("fonts/holo-icon-font.ttf")
.iconSize(R.dimen.ab_icon_size)
.build()
);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014 Evgeny Shishkin
* Copyright (C) 2014 Evgeny Shishkin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,17 +18,14 @@

import android.app.Application;

import com.github.johnkil.print.Print;
import com.github.johnkil.print.PrintConfig;

/**
* @author Evgeny Shishkin
*/
public class PrintApplication extends Application {

@Override
public void onCreate() {
super.onCreate();
Print.initFont(getAssets(), "fonts/material-icon-font.ttf");
PrintConfig.initDefault(getAssets(), "fonts/material-icon-font.ttf");
}

}
15 changes: 15 additions & 0 deletions print-sample/src/main/res/color/icon.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2014 Evgeny Shishkin
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
Expand Down
21 changes: 19 additions & 2 deletions print-sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2014 Evgeny Shishkin
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:print="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
Expand Down Expand Up @@ -31,13 +48,13 @@
android:layout_below="@id/size_label"
android:max="320"/>

<com.github.johnkil.print.widget.PrintView
<com.github.johnkil.print.PrintView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/size_bar"
android:contentDescription="@string/ic_adb_description"
print:iconText="@string/ic_adb"
print:iconText="@string/ic_material_adb"
print:iconColor="@color/icon"
print:iconSize="180dp"/>

Expand Down
17 changes: 17 additions & 0 deletions print-sample/src/main/res/menu/main.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2014 Evgeny Shishkin
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
Expand Down
17 changes: 17 additions & 0 deletions print-sample/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2014 Evgeny Shishkin
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<resources>

<!-- Black 87% -->
<color name="primary_text">#de000000</color>
<!-- Black 54% -->
<color name="secondary_text">#8a000000</color>

<!-- action bar icon color -->
<color name="ab_icon_color">#ffffff</color>

</resources>
18 changes: 18 additions & 0 deletions print-sample/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2014 Evgeny Shishkin
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<resources>

<!-- action bar icon size -->
<dimen name="ab_icon_size">32dp</dimen>

</resources>
Loading

0 comments on commit 55e4cd8

Please sign in to comment.