summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClark Scheff <clark@cyngn.com>2014-09-04 11:51:24 -0700
committerClark Scheff <clark@cyngn.com>2014-09-04 11:51:24 -0700
commite1ab2303f2c1de871b37fffeacc7e3b03b26bfde (patch)
tree71c5b446a84f8e1f3103c6f619821549f4995317
parentd2d24b77ac8feadc3a85709926abf018d37c571b (diff)
downloadpackages_apps_ThemeChooser-e1ab2303f2c1de871b37fffeacc7e3b03b26bfde.zip
packages_apps_ThemeChooser-e1ab2303f2c1de871b37fffeacc7e3b03b26bfde.tar.gz
packages_apps_ThemeChooser-e1ab2303f2c1de871b37fffeacc7e3b03b26bfde.tar.bz2
Use custom TextView that always uses Lato fonts
Change-Id: I2f60da0ab633487e18e216072ce834e255b5d852
-rw-r--r--assets/fonts/Lato-Cond.ttfbin0 -> 957320 bytes
-rw-r--r--assets/fonts/Lato-CondBold.ttfbin0 -> 959444 bytes
-rw-r--r--assets/fonts/Lato-CondBoldItalic.ttfbin0 -> 965540 bytes
-rw-r--r--assets/fonts/Lato-CondItalic.ttfbin0 -> 1004756 bytes
-rw-r--r--assets/fonts/Lato-Light.ttfbin0 -> 632536 bytes
-rw-r--r--assets/fonts/Lato-LightItalic.ttfbin0 -> 647880 bytes
-rw-r--r--assets/fonts/Lato-RegBold.ttfbin0 -> 960340 bytes
-rw-r--r--assets/fonts/Lato-RegBoldItalic.ttfbin0 -> 968788 bytes
-rw-r--r--assets/fonts/Lato-RegItalic.otfbin0 -> 47356 bytes
-rw-r--r--assets/fonts/Lato-Regular.ttfbin0 -> 959916 bytes
-rw-r--r--res/layout/apply_theme_layout.xml2
-rw-r--r--res/layout/audible_card.xml4
-rw-r--r--res/layout/bootani_component_selection_item.xml2
-rw-r--r--res/layout/bootanim_card.xml2
-rw-r--r--res/layout/customize_reset_theme_layout.xml4
-rw-r--r--res/layout/font_card.xml4
-rw-r--r--res/layout/font_component_selection_item.xml2
-rw-r--r--res/layout/fragment_pager_list.xml2
-rw-r--r--res/layout/icon_card.xml2
-rw-r--r--res/layout/icon_component_selection_item.xml2
-rw-r--r--res/layout/navbar_card.xml2
-rw-r--r--res/layout/navigation_bar_component_selection_item.xml2
-rw-r--r--res/layout/shop_themes.xml2
-rw-r--r--res/layout/sound_component_selection_item.xml2
-rw-r--r--res/layout/status_bar_card.xml2
-rw-r--r--res/layout/status_bar_component_selection_item.xml2
-rw-r--r--res/layout/style_card.xml2
-rw-r--r--res/layout/tag_customized.xml3
-rw-r--r--res/layout/tag_default.xml3
-rw-r--r--res/layout/tag_updated.xml3
-rw-r--r--res/layout/wallpaper_card.xml2
-rw-r--r--res/layout/wallpaper_component_selection_item.xml2
-rw-r--r--src/com/cyngn/theme/widget/LatoTextView.java145
33 files changed, 173 insertions, 25 deletions
diff --git a/assets/fonts/Lato-Cond.ttf b/assets/fonts/Lato-Cond.ttf
new file mode 100644
index 0000000..d51333e
--- /dev/null
+++ b/assets/fonts/Lato-Cond.ttf
Binary files differ
diff --git a/assets/fonts/Lato-CondBold.ttf b/assets/fonts/Lato-CondBold.ttf
new file mode 100644
index 0000000..6a58bf8
--- /dev/null
+++ b/assets/fonts/Lato-CondBold.ttf
Binary files differ
diff --git a/assets/fonts/Lato-CondBoldItalic.ttf b/assets/fonts/Lato-CondBoldItalic.ttf
new file mode 100644
index 0000000..2548f1b
--- /dev/null
+++ b/assets/fonts/Lato-CondBoldItalic.ttf
Binary files differ
diff --git a/assets/fonts/Lato-CondItalic.ttf b/assets/fonts/Lato-CondItalic.ttf
new file mode 100644
index 0000000..42c1fae
--- /dev/null
+++ b/assets/fonts/Lato-CondItalic.ttf
Binary files differ
diff --git a/assets/fonts/Lato-Light.ttf b/assets/fonts/Lato-Light.ttf
new file mode 100644
index 0000000..d63374c
--- /dev/null
+++ b/assets/fonts/Lato-Light.ttf
Binary files differ
diff --git a/assets/fonts/Lato-LightItalic.ttf b/assets/fonts/Lato-LightItalic.ttf
new file mode 100644
index 0000000..6fff995
--- /dev/null
+++ b/assets/fonts/Lato-LightItalic.ttf
Binary files differ
diff --git a/assets/fonts/Lato-RegBold.ttf b/assets/fonts/Lato-RegBold.ttf
new file mode 100644
index 0000000..a2c0b0d
--- /dev/null
+++ b/assets/fonts/Lato-RegBold.ttf
Binary files differ
diff --git a/assets/fonts/Lato-RegBoldItalic.ttf b/assets/fonts/Lato-RegBoldItalic.ttf
new file mode 100644
index 0000000..049047a
--- /dev/null
+++ b/assets/fonts/Lato-RegBoldItalic.ttf
Binary files differ
diff --git a/assets/fonts/Lato-RegItalic.otf b/assets/fonts/Lato-RegItalic.otf
new file mode 100644
index 0000000..6341374
--- /dev/null
+++ b/assets/fonts/Lato-RegItalic.otf
Binary files differ
diff --git a/assets/fonts/Lato-Regular.ttf b/assets/fonts/Lato-Regular.ttf
new file mode 100644
index 0000000..6fb22a3
--- /dev/null
+++ b/assets/fonts/Lato-Regular.ttf
Binary files differ
diff --git a/res/layout/apply_theme_layout.xml b/res/layout/apply_theme_layout.xml
index 955efec..fa3c74a 100644
--- a/res/layout/apply_theme_layout.xml
+++ b/res/layout/apply_theme_layout.xml
@@ -9,7 +9,7 @@
android:visibility="gone"
android:background="@color/apply_layout_background">
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:layout_width="wrap_content"
android:layout_height="132dp"
android:layout_gravity="top|center_horizontal"
diff --git a/res/layout/audible_card.xml b/res/layout/audible_card.xml
index 272b489..2c6bd50 100644
--- a/res/layout/audible_card.xml
+++ b/res/layout/audible_card.xml
@@ -8,7 +8,7 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/card_bg">
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -21,7 +21,7 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/audible_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/bootani_component_selection_item.xml b/res/layout/bootani_component_selection_item.xml
index c6623d1..965a266 100644
--- a/res/layout/bootani_component_selection_item.xml
+++ b/res/layout/bootani_component_selection_item.xml
@@ -15,7 +15,7 @@
android:layout_marginTop="@dimen/component_margin_top"
android:layout_gravity="center_horizontal"/>
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/bootanim_card.xml b/res/layout/bootanim_card.xml
index 70d3f8e..0e2f705 100644
--- a/res/layout/bootanim_card.xml
+++ b/res/layout/bootanim_card.xml
@@ -19,7 +19,7 @@
android:layout_marginTop="@dimen/expanded_card_margin_top"
android:adjustViewBounds="true"
android:layout_gravity="center"/>
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/customize_reset_theme_layout.xml b/res/layout/customize_reset_theme_layout.xml
index 9e75298..ca744ba 100644
--- a/res/layout/customize_reset_theme_layout.xml
+++ b/res/layout/customize_reset_theme_layout.xml
@@ -40,7 +40,7 @@
android:scaleType="center"
android:background="@drawable/apply_cancel_bg"/>
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
@@ -74,7 +74,7 @@
android:scaleType="center"
android:background="@drawable/apply_cancel_bg"/>
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
diff --git a/res/layout/font_card.xml b/res/layout/font_card.xml
index efcd691..601f5b2 100644
--- a/res/layout/font_card.xml
+++ b/res/layout/font_card.xml
@@ -11,7 +11,7 @@
android:orientation="vertical"
android:padding="0dp"
android:background="@drawable/theme_component_bg_transition">
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -21,7 +21,7 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/font_preview"
android:layout_width="match_parent"
android:layout_height="48dp"
diff --git a/res/layout/font_component_selection_item.xml b/res/layout/font_component_selection_item.xml
index 04f3400..c520bc7 100644
--- a/res/layout/font_component_selection_item.xml
+++ b/res/layout/font_component_selection_item.xml
@@ -17,7 +17,7 @@
android:layout_marginTop="@dimen/component_margin_top"
android:layout_gravity="center_horizontal"/>
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/fragment_pager_list.xml b/res/layout/fragment_pager_list.xml
index 4a3d16e..41baa30 100644
--- a/res/layout/fragment_pager_list.xml
+++ b/res/layout/fragment_pager_list.xml
@@ -73,7 +73,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/title_card_height"
android:alpha="0">
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="match_parent"
diff --git a/res/layout/icon_card.xml b/res/layout/icon_card.xml
index 2db8bc7..5adf304 100644
--- a/res/layout/icon_card.xml
+++ b/res/layout/icon_card.xml
@@ -11,7 +11,7 @@
android:padding="0dp"
android:layout_marginTop="@dimen/collapsed_icon_card_margin_top"
android:background="@drawable/theme_component_bg_transition">
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/icon_component_selection_item.xml b/res/layout/icon_component_selection_item.xml
index a385bf6..b26972d 100644
--- a/res/layout/icon_component_selection_item.xml
+++ b/res/layout/icon_component_selection_item.xml
@@ -17,7 +17,7 @@
android:layout_marginTop="@dimen/component_margin_top"
android:layout_gravity="center_horizontal"/>
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/navbar_card.xml b/res/layout/navbar_card.xml
index e9343a2..6b19a24 100644
--- a/res/layout/navbar_card.xml
+++ b/res/layout/navbar_card.xml
@@ -12,7 +12,7 @@
android:padding="0dp"
android:gravity="bottom"
android:background="@drawable/theme_component_bg_transition">
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/navigation_bar_component_selection_item.xml b/res/layout/navigation_bar_component_selection_item.xml
index 1c7854c..fef8ee8 100644
--- a/res/layout/navigation_bar_component_selection_item.xml
+++ b/res/layout/navigation_bar_component_selection_item.xml
@@ -25,7 +25,7 @@
</LinearLayout>
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/shop_themes.xml b/res/layout/shop_themes.xml
index 727741f..dc8603c 100644
--- a/res/layout/shop_themes.xml
+++ b/res/layout/shop_themes.xml
@@ -10,7 +10,7 @@
android:layout_gravity="bottom|center_horizontal"
android:alpha="0">
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/shop_themes"
android:layout_width="140dp"
android:layout_height="44dp"
diff --git a/res/layout/sound_component_selection_item.xml b/res/layout/sound_component_selection_item.xml
index e2a7754..7ded01f 100644
--- a/res/layout/sound_component_selection_item.xml
+++ b/res/layout/sound_component_selection_item.xml
@@ -7,7 +7,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
diff --git a/res/layout/status_bar_card.xml b/res/layout/status_bar_card.xml
index a4a4088..ad50167 100644
--- a/res/layout/status_bar_card.xml
+++ b/res/layout/status_bar_card.xml
@@ -12,7 +12,7 @@
android:clickable="true"
android:focusable="true"
android:background="@drawable/theme_component_bg_transition">
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/status_bar_component_selection_item.xml b/res/layout/status_bar_component_selection_item.xml
index 4c5efa0..cd84662 100644
--- a/res/layout/status_bar_component_selection_item.xml
+++ b/res/layout/status_bar_component_selection_item.xml
@@ -37,7 +37,7 @@
</FrameLayout>
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/style_card.xml b/res/layout/style_card.xml
index cff46da..72f51ba 100644
--- a/res/layout/style_card.xml
+++ b/res/layout/style_card.xml
@@ -9,7 +9,7 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/card_bg">
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/tag_customized.xml b/res/layout/tag_customized.xml
index c1ac380..426da25 100644
--- a/res/layout/tag_customized.xml
+++ b/res/layout/tag_customized.xml
@@ -2,7 +2,8 @@
<!--
Copyright (C) 2014 Cyanogen, Inc.
-->
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+<com.cyngn.theme.widget.LatoTextView
+ xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tag_customized"
android:layout_width="100dp"
android:layout_height="24dp"
diff --git a/res/layout/tag_default.xml b/res/layout/tag_default.xml
index 8f2c4a1..fe49d7f 100644
--- a/res/layout/tag_default.xml
+++ b/res/layout/tag_default.xml
@@ -2,7 +2,8 @@
<!--
Copyright (C) 2014 Cyanogen, Inc.
-->
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+<com.cyngn.theme.widget.LatoTextView
+ xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tag_default"
android:layout_width="75dp"
android:layout_height="24dp"
diff --git a/res/layout/tag_updated.xml b/res/layout/tag_updated.xml
index 4a75907..ab05187 100644
--- a/res/layout/tag_updated.xml
+++ b/res/layout/tag_updated.xml
@@ -2,7 +2,8 @@
<!--
Copyright (C) 2014 Cyanogen, Inc.
-->
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+<com.cyngn.theme.widget.LatoTextView
+ xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tag_updated"
android:layout_width="75dp"
android:layout_height="24dp"
diff --git a/res/layout/wallpaper_card.xml b/res/layout/wallpaper_card.xml
index a896cbe..5ed7790 100644
--- a/res/layout/wallpaper_card.xml
+++ b/res/layout/wallpaper_card.xml
@@ -11,7 +11,7 @@
android:layout_height="match_parent"
android:scaleType="centerCrop" />
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/none"
android:layout_width="match_parent"
android:layout_height="match_parent"
diff --git a/res/layout/wallpaper_component_selection_item.xml b/res/layout/wallpaper_component_selection_item.xml
index 7e530a5..3fa99a9 100644
--- a/res/layout/wallpaper_component_selection_item.xml
+++ b/res/layout/wallpaper_component_selection_item.xml
@@ -25,7 +25,7 @@
android:background="@drawable/wallpaper_border" />
</FrameLayout>
- <TextView
+ <com.cyngn.theme.widget.LatoTextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/src/com/cyngn/theme/widget/LatoTextView.java b/src/com/cyngn/theme/widget/LatoTextView.java
new file mode 100644
index 0000000..2c74eaa
--- /dev/null
+++ b/src/com/cyngn/theme/widget/LatoTextView.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2014 Cyanogen, Inc.
+ */
+package com.cyngn.theme.widget;
+
+import android.content.Context;
+import android.content.res.AssetManager;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.graphics.Typeface;
+import android.util.AttributeSet;
+import android.widget.TextView;
+
+import java.io.File;
+
+/**
+ * A custom TextView that always uses the Lato font
+ */
+public class LatoTextView extends TextView {
+ private static final int NUM_TYPEFACE_PER_FAMILY = 4;
+
+ private static final String FONT_ASSSET_DIR = "fonts";
+ // Regular fonts
+ private static final String LATO_REGULAR_PATH =
+ FONT_ASSSET_DIR + File.separator + "Lato-Regular.ttf";
+ private static final String LATO_REGULAR_BOLD_PATH =
+ FONT_ASSSET_DIR + File.separator + "Lato-RegBold.ttf";
+ private static final String LATO_REGULAR_ITALIC_PATH =
+ FONT_ASSSET_DIR + File.separator + "Lato-RegItalic.otf";
+ private static final String LATO_REGULAR_BOLD_ITALIC_PATH =
+ FONT_ASSSET_DIR + File.separator + "Lato-RegBoldItalic.ttf";
+ // Condensed fonts
+ private static final String LATO_CONDENSED_PATH =
+ FONT_ASSSET_DIR + File.separator + "Lato-Cond.ttf";
+ private static final String LATO_CONDENSED_BOLD_PATH =
+ FONT_ASSSET_DIR + File.separator + "Lato-CondBold.ttf";
+ private static final String LATO_CONDENSED_ITALIC_PATH =
+ FONT_ASSSET_DIR + File.separator + "Lato-CondItalic.ttf";
+ private static final String LATO_CONDENSED_BOLD_ITALIC_PATH =
+ FONT_ASSSET_DIR + File.separator + "Lato-CondBoldItalic.ttf";
+ // Light fonts
+ private static final String LATO_LIGHT_PATH =
+ FONT_ASSSET_DIR + File.separator + "Lato-Light.ttf";
+ private static final String LATO_LIGHT_ITALIC_PATH =
+ FONT_ASSSET_DIR + File.separator + "Lato-LightItalic.ttf";
+
+ private static final String CONDENSED = "condensed";
+ private static final String LIGHT = "light";
+
+ private static Typeface[] sLatoRegularTypeface;
+ private static Typeface[] sLatoCondensedTypeface;
+ private static Typeface[] sLatoLightTypeface;
+ private static final Object sLock = new Object();
+
+ public LatoTextView(Context context) {
+ this(context, null);
+ }
+
+ public LatoTextView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public LatoTextView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ synchronized (sLock) {
+ AssetManager assets = context.getAssets();
+ if (sLatoRegularTypeface == null) {
+ sLatoRegularTypeface = new Typeface[NUM_TYPEFACE_PER_FAMILY];
+ sLatoRegularTypeface[Typeface.NORMAL] =
+ Typeface.createFromAsset(assets, LATO_REGULAR_PATH);
+ sLatoRegularTypeface[Typeface.BOLD] =
+ Typeface.createFromAsset(assets, LATO_REGULAR_BOLD_PATH);
+ sLatoRegularTypeface[Typeface.ITALIC] =
+ Typeface.createFromAsset(assets, LATO_REGULAR_ITALIC_PATH);
+ sLatoRegularTypeface[Typeface.BOLD_ITALIC] =
+ Typeface.createFromAsset(assets, LATO_REGULAR_BOLD_ITALIC_PATH);
+ }
+ if (sLatoCondensedTypeface == null) {
+ sLatoCondensedTypeface = new Typeface[NUM_TYPEFACE_PER_FAMILY];
+ sLatoCondensedTypeface[Typeface.NORMAL] =
+ Typeface.createFromAsset(assets, LATO_CONDENSED_PATH);
+ sLatoCondensedTypeface[Typeface.BOLD] =
+ Typeface.createFromAsset(assets, LATO_CONDENSED_BOLD_PATH);
+ sLatoCondensedTypeface[Typeface.ITALIC] =
+ Typeface.createFromAsset(assets, LATO_CONDENSED_ITALIC_PATH);
+ sLatoCondensedTypeface[Typeface.BOLD_ITALIC] =
+ Typeface.createFromAsset(assets, LATO_CONDENSED_BOLD_ITALIC_PATH);
+ }
+ if (sLatoLightTypeface == null) {
+ sLatoLightTypeface = new Typeface[NUM_TYPEFACE_PER_FAMILY];
+ sLatoLightTypeface[Typeface.NORMAL] =
+ Typeface.createFromAsset(assets, LATO_LIGHT_PATH);
+ sLatoLightTypeface[Typeface.BOLD] =
+ sLatoRegularTypeface[Typeface.BOLD];
+ sLatoLightTypeface[Typeface.ITALIC] =
+ Typeface.createFromAsset(assets, LATO_LIGHT_ITALIC_PATH);
+ sLatoLightTypeface[Typeface.BOLD_ITALIC] =
+ sLatoRegularTypeface[Typeface.BOLD_ITALIC];
+ }
+ }
+
+ final Resources.Theme theme = context.getTheme();
+ TypedArray a = theme.obtainStyledAttributes(
+ attrs, com.android.internal.R.styleable.TextView, defStyle, 0);
+ String fontFamily = "sans-serif";
+ int styleIndex = Typeface.NORMAL;
+ if (a != null) {
+ int n = a.getIndexCount();
+ for (int i = 0; i < n; i++) {
+ int attr = a.getIndex(i);
+
+ switch (attr) {
+ case com.android.internal.R.styleable.TextView_fontFamily:
+ fontFamily = a.getString(attr);
+ break;
+
+ case com.android.internal.R.styleable.TextView_textStyle:
+ styleIndex = a.getInt(attr, styleIndex);
+ break;
+ }
+ }
+ a.recycle();
+ }
+
+ setTypefaceFromAttrs(fontFamily, styleIndex);
+ }
+
+ private void setTypefaceFromAttrs(String familyName, int styleIndex) {
+ Typeface tf = null;
+ if (familyName != null) {
+ Typeface[] typefaces = sLatoRegularTypeface;
+ if (familyName.contains(CONDENSED)) {
+ typefaces = sLatoCondensedTypeface;
+ } else if (familyName.contains(LIGHT)) {
+ typefaces = sLatoLightTypeface;
+ }
+ tf = typefaces[styleIndex];
+ if (tf != null) {
+ setTypeface(tf);
+ return;
+ }
+ }
+ setTypeface(tf, styleIndex);
+ }
+}