Skip to content

Commit

Permalink
Release version 1.3
Browse files Browse the repository at this point in the history
Implemeted of direct/indirect subclasses of TextView with native support for the Roboto fonts (`RobotoAutoCompleteTextView`, `RobotoButton`, `RobotoCheckBox`, `RobotoCheckedTextView`, `RobotoChronometer`, `RobotoCompoundButton`, `RobotoDigitalClock`, `RobotoEditText`, `RobotoExtractEditText`, `RobotoMultiAutoCompleteTextView`, `RobotoRadioButton`, `RobotoSwitch`, `RobotoTextClock`, `RobotoToggleButton`).
  • Loading branch information
johnkil committed May 20, 2013
1 parent 948d3cd commit 9ab0549
Show file tree
Hide file tree
Showing 21 changed files with 1,607 additions and 175 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.devspark.robototextview"
android:versionCode="3"
android:versionName="1.2">
android:versionCode="4"
android:versionName="1.3">

<uses-sdk
android:minSdkVersion="3"
Expand Down
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.3 *(2013-05-20)*
--------------------------

* Implemeted of direct/indirect subclasses of TextView with native support for the Roboto fonts (`RobotoAutoCompleteTextView`, `RobotoButton`, `RobotoCheckBox`, `RobotoCheckedTextView`, `RobotoChronometer`, `RobotoCompoundButton`, `RobotoDigitalClock`, `RobotoEditText`, `RobotoExtractEditText`, `RobotoMultiAutoCompleteTextView`, `RobotoRadioButton`, `RobotoSwitch`, `RobotoTextClock`, `RobotoToggleButton`).


Version 1.2 *(2013-03-31)*
--------------------------

Expand Down
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
Android-RobotoTextView
======================

Implementation of a [TextView](http://developer.android.com/reference/android/widget/TextView.html) with native support for all the [Roboto](http://developer.android.com/design/style/typography.html) fonts on all versions of Android.
Implementation of a [TextView](http://developer.android.com/reference/android/widget/TextView.html) and all its direct/indirect subclasses with native support for the [Roboto](http://developer.android.com/design/style/typography.html) fonts, includes the brand new [Roboto Slab](http://www.google.com/fonts/specimen/Roboto+Slab) fonts.

Implemented next views:

* `RobotoTextView`
* `RobotoAutoCompleteTextView`
* `RobotoButton`
* `RobotoCheckBox`
* `RobotoCheckedTextView`
* `RobotoChronometer`
* `RobotoCompoundButton`
* `RobotoDigitalClock`
* `RobotoEditText`
* `RobotoExtractEditText`
* `RobotoMultiAutoCompleteTextView`
* `RobotoRadioButton`
* `RobotoSwitch`
* `RobotoTextClock`
* `RobotoToggleButton`


Sample
Expand Down Expand Up @@ -44,6 +62,30 @@ Sample layout with RobotoTextView:
</FrameLayout>
```

Available values ​​for the `typeface` attribute:

* roboto_thin
* roboto_thin_italic
* roboto_light
* roboto_light_italic
* roboto_regular
* roboto_italic
* roboto_medium
* roboto_medium_italic
* roboto_bold
* roboto_bold_italic
* roboto_black
* roboto_black_italic
* roboto_condensed
* roboto_condensed_italic
* roboto_condensed_bold
* roboto_condensed_bold_italic
* robotoslab_thin
* robotoslab_light
* robotoslab_regular
* robotoslab_bold



Developed By
------------
Expand Down
32 changes: 0 additions & 32 deletions res/values/attr.xml

This file was deleted.

88 changes: 88 additions & 0 deletions res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<declare-styleable name="RobotoTextView">
<attr name="typeface"/>
</declare-styleable>

<declare-styleable name="RobotoAutoCompleteTextView">
<attr name="typeface"/>
</declare-styleable>

<declare-styleable name="RobotoButton">
<attr name="typeface"/>
</declare-styleable>

<declare-styleable name="RobotoCheckBox">
<attr name="typeface"/>
</declare-styleable>

<declare-styleable name="RobotoCheckedTextView">
<attr name="typeface"/>
</declare-styleable>

<declare-styleable name="RobotoChronometer">
<attr name="typeface"/>
</declare-styleable>

<declare-styleable name="RobotoCompoundButton">
<attr name="typeface"/>
</declare-styleable>

<declare-styleable name="RobotoDigitalClock">
<attr name="typeface"/>
</declare-styleable>

<declare-styleable name="RobotoEditText">
<attr name="typeface"/>
</declare-styleable>

<declare-styleable name="RobotoExtractEditText">
<attr name="typeface"/>
</declare-styleable>

<declare-styleable name="RobotoMultiAutoCompleteTextView">
<attr name="typeface"/>
</declare-styleable>

<declare-styleable name="RobotoRadioButton">
<attr name="typeface"/>
</declare-styleable>

<declare-styleable name="RobotoSwitch">
<attr name="typeface"/>
</declare-styleable>

<declare-styleable name="RobotoTextClock">
<attr name="typeface"/>
</declare-styleable>

<declare-styleable name="RobotoToggleButton">
<attr name="typeface"/>
</declare-styleable>

<!-- Changing the attribute must be reflected in the com.devspark.robototextview.RobotoTypefaceManager -->
<attr name="typeface" format="enum">
<enum name="roboto_thin" value="0"/>
<enum name="roboto_thin_italic" value="1"/>
<enum name="roboto_light" value="2"/>
<enum name="roboto_light_italic" value="3"/>
<enum name="roboto_regular" value="4"/>
<enum name="roboto_italic" value="5"/>
<enum name="roboto_medium" value="6"/>
<enum name="roboto_medium_italic" value="7"/>
<enum name="roboto_bold" value="8"/>
<enum name="roboto_bold_italic" value="9"/>
<enum name="roboto_black" value="10"/>
<enum name="roboto_black_italic" value="11"/>
<enum name="roboto_condensed" value="12"/>
<enum name="roboto_condensed_italic" value="13"/>
<enum name="roboto_condensed_bold" value="14"/>
<enum name="roboto_condensed_bold_italic" value="15"/>
<enum name="robotoslab_thin" value="16"/>
<enum name="robotoslab_light" value="17"/>
<enum name="robotoslab_regular" value="18"/>
<enum name="robotoslab_bold" value="19"/>
</attr>

</resources>
138 changes: 138 additions & 0 deletions src/com/devspark/robototextview/RobotoTypefaceManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package com.devspark.robototextview;

import android.content.Context;
import android.graphics.Typeface;
import android.util.SparseArray;

/**
* The manager of roboto typefaces.
*
* @author e.shishkin
*/
public class RobotoTypefaceManager {

/*
* Available values ​​for the "typeface" attribute.
*/
private final static int ROBOTO_THIN = 0;
private final static int ROBOTO_THIN_ITALIC = 1;
private final static int ROBOTO_LIGHT = 2;
private final static int ROBOTO_LIGHT_ITALIC = 3;
private final static int ROBOTO_REGULAR = 4;
private final static int ROBOTO_ITALIC = 5;
private final static int ROBOTO_MEDIUM = 6;
private final static int ROBOTO_MEDIUM_ITALIC = 7;
private final static int ROBOTO_BOLD = 8;
private final static int ROBOTO_BOLD_ITALIC = 9;
private final static int ROBOTO_BLACK = 10;
private final static int ROBOTO_BLACK_ITALIC = 11;
private final static int ROBOTO_CONDENSED = 12;
private final static int ROBOTO_CONDENSED_ITALIC = 13;
private final static int ROBOTO_CONDENSED_BOLD = 14;
private final static int ROBOTO_CONDENSED_BOLD_ITALIC = 15;
private final static int ROBOTOSLAB_THIN = 16;
private final static int ROBOTOSLAB_LIGHT = 17;
private final static int ROBOTOSLAB_REGULAR = 18;
private final static int ROBOTOSLAB_BOLD = 19;

/**
* Array of created typefaces for later reused.
*/
private final static SparseArray<Typeface> mTypefaces = new SparseArray<Typeface>(20);

/**
* Obtain typeface.
*
* @param context The Context the widget is running in, through which it can access the current theme, resources, etc.
* @param typefaceValue The value of "typeface" attribute
* @return specify {@link Typeface}
* @throws IllegalArgumentException if unknown `typeface` attribute value.
*/
public static Typeface obtaintTypeface(Context context, int typefaceValue) throws IllegalArgumentException {
Typeface typeface = mTypefaces.get(typefaceValue);
if (typeface == null) {
typeface = createTypeface(context, typefaceValue);
mTypefaces.put(typefaceValue, typeface);
}
return typeface;
}

/**
* Create typeface from assets.
*
* @param context The Context the widget is running in, through which it can
* access the current theme, resources, etc.
* @param typefaceValue The value of "typeface" attribute
* @return Roboto {@link Typeface}
* @throws IllegalArgumentException if unknown `typeface` attribute value.
*/
private static Typeface createTypeface(Context context, int typefaceValue) throws IllegalArgumentException {
Typeface typeface;
switch (typefaceValue) {
case ROBOTO_THIN:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Thin.ttf");
break;
case ROBOTO_THIN_ITALIC:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-ThinItalic.ttf");
break;
case ROBOTO_LIGHT:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Light.ttf");
break;
case ROBOTO_LIGHT_ITALIC:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-LightItalic.ttf");
break;
case ROBOTO_REGULAR:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Regular.ttf");
break;
case ROBOTO_ITALIC:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Italic.ttf");
break;
case ROBOTO_MEDIUM:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Medium.ttf");
break;
case ROBOTO_MEDIUM_ITALIC:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-MediumItalic.ttf");
break;
case ROBOTO_BOLD:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Bold.ttf");
break;
case ROBOTO_BOLD_ITALIC:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-BoldItalic.ttf");
break;
case ROBOTO_BLACK:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Black.ttf");
break;
case ROBOTO_BLACK_ITALIC:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-BlackItalic.ttf");
break;
case ROBOTO_CONDENSED:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Condensed.ttf");
break;
case ROBOTO_CONDENSED_ITALIC:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-CondensedItalic.ttf");
break;
case ROBOTO_CONDENSED_BOLD:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-BoldCondensed.ttf");
break;
case ROBOTO_CONDENSED_BOLD_ITALIC:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-BoldCondensedItalic.ttf");
break;
case ROBOTOSLAB_THIN:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/RobotoSlab-Thin.ttf");
break;
case ROBOTOSLAB_LIGHT:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/RobotoSlab-Light.ttf");
break;
case ROBOTOSLAB_REGULAR:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/RobotoSlab-Regular.ttf");
break;
case ROBOTOSLAB_BOLD:
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/RobotoSlab-Bold.ttf");
break;
default:
throw new IllegalArgumentException("Unknown `typeface` attribute value " + typefaceValue);
}
return typeface;
}

}
Loading

0 comments on commit 9ab0549

Please sign in to comment.