Skip to content

Commit

Permalink
Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkil committed Feb 13, 2017
1 parent ddc6b4a commit aa1295f
Show file tree
Hide file tree
Showing 10 changed files with 167 additions and 226 deletions.
58 changes: 41 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Download
Gradle:

```groovy
compile 'com.github.johnkil.android-robototextview:robototextview:2.5.1'
compile 'com.github.johnkil.android-robototextview:robototextview:2.6.0'
```

Maven:
Expand All @@ -41,7 +41,7 @@ Maven:
<dependency>
<groupId>com.github.johnkil.android-robototextview</groupId>
<artifactId>robototextview</artifactId>
<version>2.5.1</version>
<version>2.6.0</version>
<type>aar</type>
</dependency>
```
Expand Down Expand Up @@ -82,30 +82,28 @@ Set up typeface in code:
Using parameter `typeface`:
``` java
RobotoTextView textView = new RobotoTextView(context);
Typeface typeface = RobotoTypefaceManager.obtainTypeface(
context,
RobotoTypefaceManager.Typeface.ROBOTO_LIGHT_ITALIC);
RobotoTypefaceUtils.setUp(textView, typeface);
RobotoTypefaces.setUpTypeface(
textView,
RobotoTypefaces.TYPEFACE_ROBOTO_LIGHT_ITALIC);
```

Using parameters `fontFamily`, `textWeight` and `textStyle`:
``` java
RobotoTextView textView = new RobotoTextView(context);
Typeface typeface = RobotoTypefaceManager.obtainTypeface(
context,
RobotoTypefaceManager.FontFamily.ROBOTO,
RobotoTypefaceManager.TextWeight.LIGHT,
RobotoTypefaceManager.TextStyle.ITALIC);
RobotoTypefaceUtils.setUp(textView, typeface);
RobotoTypefaces.setUpTypeface(
textView,
RobotoTypefaces.FONT_FAMILY_ROBOTO,
RobotoTypefaces.TEXT_WEIGHT_LIGHT,
RobotoTypefaces.TEXT_STYLE_ITALIC);
```

#### With Span

Using parameter `typeface`:
``` java
RobotoTypefaceSpan span = new RobotoTypefaceSpan(
context,
RobotoTypefaceManager.Typeface.ROBOTO_BOLD);
context,
RobotoTypefaces.TYPEFACE_ROBOTO_LIGHT_ITALIC);
Spannable spannable = new SpannableString("text");
spannable.setSpan(span, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
```
Expand All @@ -114,13 +112,38 @@ Using parameters `fontFamily`, `textWeight` and `textStyle`:
``` java
RobotoTypefaceSpan span = new RobotoTypefaceSpan(
context,
RobotoTypefaceManager.FontFamily.ROBOTO,
RobotoTypefaceManager.TextWeight.LIGHT,
RobotoTypefaceManager.TextStyle.ITALIC);
RobotoTypefaces.FONT_FAMILY_ROBOTO,
RobotoTypefaces.TEXT_WEIGHT_LIGHT,
RobotoTypefaces.TEXT_STYLE_ITALIC);
Spannable spannable = new SpannableString("text");
spannable.setSpan(span, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
```

#### RobotoInflater

To apply roboto typeface for original TextView (like a [Calligraphy][7]) you must attach inflater in your `Activity` class in the `#onCreate()` method.
```java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
RobotoInflater.attach(this);
super.onCreate(savedInstanceState);
}
```

and specify the typeface in xml:
``` xml
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:typeface="roboto_light_italic"/>
```

_Note: Popular IDE's (Android Studio, IntelliJ) will likely mark this as an error despite being correct. You may want to add `tools:ignore="MissingPrefix"` to either the View itself or its parent ViewGroup to avoid this. You'll need to add the tools namespace to have access to this "ignore" attribute. `xmlns:tools="
http://schemas.android.com/tools"`. See https://code.google.com/p/android/issues/detail?id=65176._


Gradle
------

Expand Down Expand Up @@ -167,5 +190,6 @@ License
[4]: https://www.google.com/fonts/specimen/Roboto+Mono
[5]: http://www.google.com/design/spec/style/typography.html
[6]: http://developer.android.com/reference/android/widget/TextView.html
[7]: https://github.com/chrisjenx/Calligraphy

[0]: https://github.com/google/roboto
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# suppress inspection "UnusedProperty" for whole file
GROUP=com.github.johnkil.android-robototextview
VERSION_NAME=2.6.0-SNAPSHOT

Expand Down
11 changes: 7 additions & 4 deletions robototextview-sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<manifest
package="com.devspark.robototextview.sample"
xmlns:android="http://schemas.android.com/apk/res/android">
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.devspark.robototextview.sample">

<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">

<activity android:name="MainActivity">
<intent-filter>
Expand All @@ -14,7 +17,7 @@
</intent-filter>
</activity>

<activity android:name=".InflaterActivity"/>
<activity android:name="InflaterActivity"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class MainActivity extends AppCompatActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.btnGoToInflater).setOnClickListener(new View.OnClickListener() {
findViewById(R.id.btn_go_to_inflater).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, InflaterActivity.class));
Expand Down
Loading

0 comments on commit aa1295f

Please sign in to comment.