[
  {
    "path": ".gitignore",
    "content": "# built application files\n*.apk\n*.ap_\n\n# files for the dex VM\n*.dex\n\n# Java class files\n*.class\n\n# generated files\nbin/\ngen/\n\n# Local configuration file (sdk path, etc)\nlocal.properties\n/local.properties\n\n# Eclipse\n.classpath\n.project\n.settings\n\n# Android Studio (InteliJ)\n.idea/\n/.idea/workspace.xml\n*.iml\n*.iws\n*.ipr\n/*/out\n/*/build\n/*/*/production\n\n#Gradle\n.gradletasknamecache\n.gradle/\nbuild/\nbin/\n\n#Crashlytics\ncom_crashlytics_export_strings.xml\n\n#OSx\n.DS_Store\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Changelog\n\n# 2.3.0 (11/05/2017)\n- Fix Toolbar TextView's layout race condition. [@ansman](https://github.com/ansman) #386, #368, #327, #280, #304, #363\n\n# 2.2.0 (05/04/2016)\n- Added AppCompat Styles (AppCompatTextView will now pickup textViewStyle etc). Thanks @paul-turner\n- Fix for Toolbar not inflating `TextView`s upfront.\n\n# 2.1.0 (27/04/2015)\n- Fixed #155, We now clone correctly.\n- Added Styles for Custom Views. (`builder.addCustomStyle(ToggleButton.class, android.R.attr.buttonStyleToggle)`)\n\n# 2.0.2 (05/01/2015)\n- Fixed `CalligraphyConfig.Builder` missing return statements.\n- Fixed `createView()` getting the wrong parent context, Fixed: #135, #120\n\n# 2.0.1 (28/01/2014)\n- Throw exception on passing null into `CalligraphySpan`\n- Fixed memory bug with `Toolbar`. [@dlew](https://github.com/dlew)\n\n# 2.0.0 (16/01/2014)\n**Breaking changes**\nThis is a massive rewrite of the interception model. Look at `CalligraphyLayoutInflater` and\n`CalligraphyConfig` for more information on options and changes.\n\n- **BREAKING CHANGE** This is an API change to Calligraphy config.\n Changed CalligraphyConfig to a builder pattern, use `CalligraphyConfig.Builder().build()`;\n\nNotable changes:\n- Removed jar binary, We build an @aar due to the way we tag `View`s.\n- Intercept View creation at each stage.\n- Defer view creation to native components (Except CustomViews).\n- Inject `setPrivateFactory` on the `Activity`.\n- We wrap Factory not disturbing underlying factory and layout inflater invocation.\n- Better support for `cloneInContext()` which the compat library uses heavily.\n\n# 1.2.0 (20/10/2014)\n- Fixes issues with `appcompat-v7:21+` (uses underlying `Toolbar` impl).\n- Lollipop support.\n- Fast path view with font already set by us.\n\n# 1.1.0 (02/08/2014)\n- Fixes ActionBar Title/SubTitle `textStyles`.\n- Fixes `textAllCaps` bug, now works correctly.\n- Fixes some `Spannable` issues reported, we are more careful what we apply `Spannable`'s too now.\n- Fixes missing Typeface on hint text on `EditText`/`AutoComplete`.\n- Fixes empty source and javadoc jars on maven.\n\n# 1.0.0 (05/07/2014)\n- Added ActionBar Title/SubTitle support.\n- Toast support via default style/or TextView theme style.\n- Removed FontFamily parsing as it lead to users not being able to use `fontFamily`\n- Added TextAppearance Support - Thanks [@codebutler](https://github.com/codebutler) & [@loganj](https://github.com/loganj)\n- Default Font no longer required.\n\n# 0.8/9 (Skipped major API change)\n\n# 0.7.1 (22/04/2014)\n- Fixed Resources not found Exception - [@Smuldr](https://github.com/Smuldr)\n\n# 0.7.0 (28/01/2014)\n- Added Anti-aliasing support\n- Added custom font attribute support - Thanks [@Roman Zhilich](https://github.com/RomanZhilich)\n- Changed Maven groupId to `uk.co.chrisjenx` artifact is now `calligraphy`. `compile 'uk.co.chrisjenx:calligraphy:0.+'`\n\n# 0.6.0 (02/01/2014)\n- Supports all Android implementations of `TextView`\n- Supports Custom `TextView`s - Thanks [@mironov-nsk](https://github.com/mironov-nsk)\n- Caches none found fonts as null\n\n# 0.5.0\n- Added support for `Button` class\n\n# 0.4.0\n- Initial Release\n"
  },
  {
    "path": "CalligraphySample/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "CalligraphySample/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n    buildToolsVersion rootProject.ext.buildToolsVersion\n\n    defaultConfig {\n        minSdkVersion rootProject.ext.minSdkVersion\n        targetSdkVersion rootProject.ext.targetSdkVersion\n        versionCode project.ext.versionCodeInt\n        versionName version\n    }\n    buildTypes {\n        debug {\n            minifyEnabled true\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'\n        }\n        release {\n            minifyEnabled true\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'\n        }\n    }\n}\n\ndependencies {\n    implementation project(':calligraphy')\n    implementation \"com.android.support:support-v4:${supportLibraryVersion}\"\n    implementation \"com.android.support:appcompat-v7:${supportLibraryVersion}\"\n\n    implementation 'com.jakewharton:butterknife:8.8.1'\n    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'\n\n//    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.3.1'\n    debugImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'\n    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'\n}\n"
  },
  {
    "path": "CalligraphySample/proguard-rules.txt",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /Developer/android-sdk-osx/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the ProGuard\n# include property in project.properties.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n-keep class butterknife.** { *; }\n-dontwarn butterknife.internal.**\n-keep class **$$ViewBinder { *; }\n\n-keepclasseswithmembernames class * {\n    @butterknife.* <fields>;\n}\n\n-keepclasseswithmembernames class * {\n    @butterknife.* <methods>;\n}\n"
  },
  {
    "path": "CalligraphySample/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest\n    package=\"uk.co.chrisjenx.calligraphy.sample\"\n    xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n    <application\n        android:name=\".CalligraphyApplication\"\n        android:allowBackup=\"true\"\n        android:icon=\"@drawable/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:theme=\"@style/AppTheme\">\n        <activity\n            android:name=\"uk.co.chrisjenx.calligraphy.sample.MainActivity\"\n            android:label=\"@string/app_name\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\"/>\n\n                <category android:name=\"android.intent.category.LAUNCHER\"/>\n            </intent-filter>\n        </activity>\n    </application>\n\n</manifest>\n"
  },
  {
    "path": "CalligraphySample/src/main/java/uk/co/chrisjenx/calligraphy/sample/CalligraphyApplication.java",
    "content": "package uk.co.chrisjenx.calligraphy.sample;\n\nimport android.app.Application;\n\nimport uk.co.chrisjenx.calligraphy.CalligraphyConfig;\n\n/**\n * Created by chris on 06/05/2014.\n * For Calligraphy.\n */\npublic class CalligraphyApplication extends Application {\n\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()\n                .setDefaultFontPath(\"fonts/Roboto-ThinItalic.ttf\")\n                .setFontAttrId(R.attr.fontPath)\n                .addCustomViewWithSetTypeface(CustomViewWithTypefaceSupport.class)\n                .addCustomStyle(TextField.class, R.attr.textFieldStyle)\n                .build()\n        );\n    }\n}\n"
  },
  {
    "path": "CalligraphySample/src/main/java/uk/co/chrisjenx/calligraphy/sample/CustomTextView.java",
    "content": "package uk.co.chrisjenx.calligraphy.sample;\n\nimport android.content.Context;\nimport android.util.AttributeSet;\nimport android.widget.TextView;\n\npublic class CustomTextView extends TextView {\n\n    public CustomTextView(Context context) {\n        super(context);\n    }\n\n    public CustomTextView(Context context, AttributeSet attrs) {\n        super(context, attrs);\n    }\n\n    public CustomTextView(Context context, AttributeSet attrs, int defStyle) {\n        super(context, attrs, defStyle);\n    }\n\n}\n"
  },
  {
    "path": "CalligraphySample/src/main/java/uk/co/chrisjenx/calligraphy/sample/CustomViewWithTypefaceSupport.java",
    "content": "package uk.co.chrisjenx.calligraphy.sample;\n\nimport android.annotation.TargetApi;\nimport android.content.Context;\nimport android.graphics.Canvas;\nimport android.graphics.Paint;\nimport android.graphics.Rect;\nimport android.graphics.Typeface;\nimport android.os.Build;\nimport android.util.AttributeSet;\nimport android.view.View;\n\n/**\n * @author Dmitriy Tarasov\n */\npublic class CustomViewWithTypefaceSupport extends View {\n\n    private Paint paint;\n    private Rect textBounds;\n    private int width;\n    private int height;\n\n    public CustomViewWithTypefaceSupport(Context context) {\n        super(context);\n        init();\n    }\n\n    public CustomViewWithTypefaceSupport(Context context, AttributeSet attrs) {\n        super(context, attrs);\n        init();\n    }\n\n    public CustomViewWithTypefaceSupport(Context context, AttributeSet attrs, int defStyleAttr) {\n        super(context, attrs, defStyleAttr);\n        init();\n    }\n\n    @TargetApi(Build.VERSION_CODES.LOLLIPOP)\n    public CustomViewWithTypefaceSupport(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {\n        super(context, attrs, defStyleAttr, defStyleRes);\n        init();\n    }\n\n    private void init() {\n        paint = new Paint();\n        paint.setTextSize(50);\n        textBounds = new Rect();\n    }\n\n    @Override\n    protected void onDraw(Canvas canvas) {\n        String text = \"This is a custom view with setTypeface support\";\n        Paint.FontMetrics fm = paint.getFontMetrics();\n        paint.getTextBounds(text, 0, text.length(), textBounds);\n\n        width = textBounds.left + textBounds.right + getPaddingLeft() + getPaddingRight();\n        height = (int) (Math.abs(fm.top) + fm.bottom);\n\n        canvas.drawText(text, 0, -fm.top + getPaddingTop(), paint);\n    }\n\n    @Override\n    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {\n        setMeasuredDimension(width, height);\n    }\n\n    /**\n     * Used by Calligraphy to change view's typeface\n     */\n    @SuppressWarnings(\"unused\")\n    public void setTypeface(Typeface tf) {\n        paint.setTypeface(tf);\n        invalidate();\n    }\n}\n"
  },
  {
    "path": "CalligraphySample/src/main/java/uk/co/chrisjenx/calligraphy/sample/MainActivity.java",
    "content": "package uk.co.chrisjenx.calligraphy.sample;\n\nimport android.content.Context;\nimport android.os.Bundle;\nimport android.os.Handler;\nimport android.os.Looper;\nimport android.support.v7.app.AppCompatActivity;\nimport android.support.v7.widget.Toolbar;\n\nimport uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;\n\nimport static butterknife.ButterKnife.findById;\n\npublic class MainActivity extends AppCompatActivity {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        final Toolbar toolbar = findById(this, R.id.toolbar);\n        setSupportActionBar(toolbar);\n\n        // Inject pragmatically\n        getSupportFragmentManager()\n                .beginTransaction()\n                .replace(R.id.container, PlaceholderFragment.getInstance())\n                .commit();\n\n\n        final Handler handler = new Handler(Looper.getMainLooper());\n        handler.postDelayed(new Runnable() {\n            @Override\n            public void run() {\n//                toolbar.setTitle(\"Calligraphy Added\");\n                toolbar.setSubtitle(\"Added subtitle\");\n            }\n        }, 1000);\n\n        handler.postDelayed(new Runnable() {\n            @Override public void run() {\n                toolbar.setTitle(null);\n                toolbar.setSubtitle(\"Added subtitle\");\n            }\n        }, 2000);\n\n        handler.postDelayed(new Runnable() {\n            @Override public void run() {\n                toolbar.setTitle(\"Calligraphy added back\");\n                toolbar.setSubtitle(\"Added subtitle\");\n            }\n        }, 3000);\n    }\n\n    /*\n        Uncomment if you disable PrivateFactory injection. See CalligraphyConfig#disablePrivateFactoryInjection()\n     */\n//    @Override\n//    @TargetApi(Build.VERSION_CODES.HONEYCOMB)\n//    public View onCreateView(View parent, String name, @NonNull Context context, @NonNull AttributeSet attrs) {\n//        return CalligraphyContextWrapper.onActivityCreateView(this, parent, super.onCreateView(parent, name, context, attrs), name, context, attrs);\n//    }\n\n    @Override\n    protected void attachBaseContext(Context newBase) {\n        super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));\n    }\n\n}\n"
  },
  {
    "path": "CalligraphySample/src/main/java/uk/co/chrisjenx/calligraphy/sample/PlaceholderFragment.java",
    "content": "package uk.co.chrisjenx.calligraphy.sample;\n\nimport android.app.AlertDialog;\nimport android.content.DialogInterface;\nimport android.os.Bundle;\nimport android.support.v4.app.Fragment;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.widget.Toast;\n\nimport butterknife.ButterKnife;\nimport butterknife.OnClick;\n\n/**\n * A placeholder fragment containing a simple view.\n */\npublic class PlaceholderFragment extends Fragment {\n\n    public static Fragment getInstance() {\n        return new PlaceholderFragment();\n    }\n\n    @Override\n    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {\n        return inflater.inflate(R.layout.fragment_main, container, false);\n    }\n\n    @Override\n    public void onViewCreated(View view, Bundle savedInstanceState) {\n        super.onViewCreated(view, savedInstanceState);\n        ButterKnife.bind(this, view);\n    }\n\n    @OnClick(R.id.button_bold)\n    public void onClickBoldButton() {\n        Toast.makeText(getActivity(), \"Custom Typeface toast text\", Toast.LENGTH_SHORT).show();\n    }\n\n    @OnClick(R.id.button_default)\n    public void onClickDefaultButton() {\n        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());\n        builder.setMessage(\"Custom Typeface Dialog\");\n        builder.setTitle(\"Sample Dialog\");\n        builder.setPositiveButton(\"OK\", new DialogInterface.OnClickListener() {\n            @Override\n            public void onClick(DialogInterface dialog, int which) {\n                dialog.dismiss();\n            }\n        });\n        builder.create().show();\n    }\n}\n"
  },
  {
    "path": "CalligraphySample/src/main/java/uk/co/chrisjenx/calligraphy/sample/TextField.java",
    "content": "package uk.co.chrisjenx.calligraphy.sample;\n\nimport android.content.Context;\nimport android.util.AttributeSet;\nimport android.widget.TextView;\n\n/**\n * Created by chris on 17/03/15.\n * For Calligraphy.\n */\npublic class TextField extends TextView {\n\n    public TextField(final Context context, final AttributeSet attrs) {\n        super(context, attrs, R.attr.textFieldStyle);\n    }\n\n}\n"
  },
  {
    "path": "CalligraphySample/src/main/res/layout/activity_main.xml",
    "content": "<merge\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    tools:context=\"uk.co.chrisjenx.calligraphy.sample.MainActivity\"\n    tools:ignore=\"MergeRootFrame\">\n\n    <android.support.v7.widget.Toolbar\n        android:id=\"@+id/toolbar\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:background=\"@color/primary_material_light\"\n        android:minHeight=\"?attr/actionBarSize\"\n        android:translationZ=\"4dp\"\n        android:theme=\"@style/ThemeOverlay.AppCompat.Light\"/>\n\n    <FrameLayout\n        android:id=\"@+id/container\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:layout_marginTop=\"?attr/actionBarSize\"\n        />\n\n\n</merge>\n"
  },
  {
    "path": "CalligraphySample/src/main/res/layout/fragment_main.xml",
    "content": "<ScrollView\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:fillViewport=\"true\">\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:orientation=\"vertical\"\n        android:paddingBottom=\"@dimen/activity_vertical_margin\"\n        android:paddingLeft=\"@dimen/activity_horizontal_margin\"\n        android:paddingRight=\"@dimen/activity_horizontal_margin\"\n        android:paddingTop=\"@dimen/activity_vertical_margin\"\n        tools:context=\"uk.co.chrisjenx.calligraphy.sample.PlaceholderFragment\"\n        tools:ignore=\"MissingPrefix\">\n\n        <TextView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:text=\"@string/default_theme\"/>\n\n        <TextView\n            fontPath=\"fonts/Roboto-Bold.ttf\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:text=\"@string/defined_fontpath_view\"/>\n\n        <TextView\n            fontPath=\"fonts/Roboto-None.ttf\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:text=\"@string/defined_incorrect\"/>\n\n        <TextView\n            style=\"@style/AppTheme.Widget.TextView.Style\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:text=\"@string/defined_in_style\"/>\n\n        <TextView\n            style=\"@style/AppTheme.Widget.TextViewAppearanceStyle\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:text=\"@string/defined_in_appears_style\"/>\n\n        <TextView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:text=\"@string/defined_in_appears\"\n            android:textAppearance=\"@style/TextAppearance.FontPathView\"/>\n\n        <TextView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:ellipsize=\"end\"\n            android:singleLine=\"true\"\n            android:text=\"@string/defined_in_appears\"\n            android:textAppearance=\"@style/TextAppearance.FontPathView\"/>\n\n        <TextView\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:text=\"@string/defined_in_appears_caps\"\n            android:textAllCaps=\"true\"\n            android:textAppearance=\"@style/TextAppearance.FontPathView\"/>\n\n        <uk.co.chrisjenx.calligraphy.sample.CustomTextView\n            fontPath=\"fonts/Oswald-Stencbab.ttf\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:text=\"@string/defined_custom_view\"/>\n\n        <uk.co.chrisjenx.calligraphy.sample.CustomViewWithTypefaceSupport\n            fontPath=\"fonts/Oswald-Stencbab.ttf\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\" />\n\n        <ViewStub\n            android:id=\"@+id/stub\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout=\"@layout/stub\"/>\n\n        <ViewStub\n            android:id=\"@+id/stub_with_font_path\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout=\"@layout/stub_with_font_path\"/>\n\n        <CheckBox\n            fontPath=\"fonts/Oswald-Stencbab.ttf\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"wrap_content\"\n            android:layout_marginBottom=\"16dp\"\n            android:layout_marginTop=\"16dp\"\n            android:text=\"@string/checkbox_custom\"/>\n\n        <EditText\n            android:id=\"@+id/edit_text\"\n            fontPath=\"fonts/Roboto-Bold.ttf\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"wrap_content\"\n            android:layout_marginBottom=\"16dp\"\n            android:layout_marginTop=\"16dp\"\n            android:hint=\"@string/edit_text_hint\"/>\n\n        <uk.co.chrisjenx.calligraphy.sample.TextField\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"wrap_content\"\n            android:text=\"@string/custom_view_style_text\"/>\n\n        <Button\n            android:id=\"@+id/button_default\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center_horizontal\"\n            android:layout_marginTop=\"16dp\"\n            android:text=\"@string/button_default\"/>\n\n        <Button\n            android:id=\"@+id/button_bold\"\n            fontPath=\"fonts/Roboto-Bold.ttf\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center_horizontal\"\n            android:layout_marginTop=\"12dp\"\n            android:text=\"@string/button_defined\"/>\n\n    </LinearLayout>\n</ScrollView>\n"
  },
  {
    "path": "CalligraphySample/src/main/res/layout/stub.xml",
    "content": "<TextView\n\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:text=\"@string/defined_view_stub\"/>\n"
  },
  {
    "path": "CalligraphySample/src/main/res/layout/stub_with_font_path.xml",
    "content": "<TextView\n    fontPath=\"fonts/Oswald-Stencbab.ttf\"\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:text=\"@string/defined_view_stub_font_path\"\n    tools:ignore=\"MissingPrefix\"/>\n"
  },
  {
    "path": "CalligraphySample/src/main/res/values/attrs.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <attr name=\"textFieldStyle\" format=\"reference\"/>\n\n</resources>"
  },
  {
    "path": "CalligraphySample/src/main/res/values/dimens.xml",
    "content": "<resources>\n    <!-- Default screen margins, per the Android Design guidelines. -->\n    <dimen name=\"activity_horizontal_margin\">16dp</dimen>\n    <dimen name=\"activity_vertical_margin\">16dp</dimen>\n\n    </resources>\n"
  },
  {
    "path": "CalligraphySample/src/main/res/values/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <string name=\"app_name\">Calligraphy</string>\n    <string name=\"defined_gtw\">\\nThis is text set by the gtw style.\\n</string>\n    <string name=\"default_theme\">\\nThis is text set by the default theme fontPath.\\n</string>\n    <string name=\"defined_fontpath_view\">\\nThis has a font path set to Roboto Bold, on the View.\\n</string>\n    <string name=\"defined_incorrect\">\\nThis has a fontPath set to a font file that does not exist, it goes back to the default.\\n</string>\n    <string name=\"defined_in_style\">\\nThis has the font path defined in the style as Roboto Condensed.\\n</string>\n    <string name=\"defined_in_appears_style\">\\nThis has the font path defined in the Styles TextAppearance as Roboto Condensed.\\n</string>\n    <string name=\"defined_in_appears\">\\nThis has the font path defined in the Views TextAppearance as Oswald.\\n</string>\n    <string name=\"defined_in_appears_caps\">\\nThis has the font path defined in the Views TextAppearance as Oswald. textAllCaps is applied.\\n</string>\n    <string name=\"defined_custom_view\">\\nThis is a custom TextView with Oswald font.\\n</string>\n    <string name=\"defined_view_stub\">\\nThis is a TextView inflated from a ViewStub.\\n</string>\n    <string name=\"defined_view_stub_font_path\">\\nThis is a TextView inflated from a ViewStub w/ fontPath declared.\\n</string>\n\n    <string name=\"checkbox_custom\">Custom Oswald checkbox</string>\n\n    <string name=\"edit_text_hint\">Custom Roboto Bold Hint</string>\n\n    <string name=\"custom_view_style_text\">\\nCustom View Style, taken from a Custom style attribute.\\n</string>\n\n    <string name=\"button_default\">Default Font (show dialog)</string>\n    <string name=\"button_defined\">Bold Button (show toast)</string>\n\n</resources>\n"
  },
  {
    "path": "CalligraphySample/src/main/res/values/styles.xml",
    "content": "<resources\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    tools:ignore=\"NewApi\">\n\n    <!-- Base application theme. -->\n    <!--<style name=\"AppTheme\" parent=\"android:Theme.Holo.Light.DarkActionBar\">-->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.NoActionBar\">\n        <!-- Customize your theme here. -->\n        <item name=\"android:textViewStyle\">@style/AppTheme.Widget.TextView</item>\n        <!-- Action Bar Theme -->\n        <item name=\"android:actionBarStyle\">@style/AppTheme.ActionBar</item>\n        <!-- Custom Style Attribute-->\n        <item name=\"textFieldStyle\">@style/TextField</item>\n    </style>\n\n    <!-- AppTheme ActionBar Style -->\n    <style name=\"AppTheme.ActionBar\" parent=\"android:Widget.Holo.Light.ActionBar.Solid.Inverse\">\n        <item name=\"android:titleTextStyle\">@style/AppTheme.ActionBar.TextAppearance</item>\n        <item name=\"android:subtitleTextStyle\">@style/AppTheme.ActionBar.TextAppearance.SubTitle</item>\n    </style>\n\n    <style name=\"AppTheme.ActionBar.TextAppearance\" parent=\"TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse\">\n        <item name=\"fontPath\">fonts/Oswald-Stencbab.ttf</item>\n    </style>\n\n    <style name=\"AppTheme.ActionBar.TextAppearance.SubTitle\" parent=\"TextAppearance.AppCompat.Widget.ActionBar.Subtitle.Inverse\">\n        <item name=\"fontPath\">fonts/gtw.ttf</item>\n    </style>\n\n\n    <style name=\"AppTheme.Widget\"/>\n\n    <style name=\"TextViewNoStyleParent\">\n        <item name=\"android:textColor\">@android:color/holo_blue_dark</item>\n        <item name=\"fontPath\">fonts/gtw.ttf</item>\n    </style>\n\n    <style name=\"AppTheme.Widget.TextView\" parent=\"android:Widget.Holo.Light.TextView\">\n        <!-- Custom Attr-->\n        <item name=\"fontPath\">fonts/RobotoCondensed-Regular.ttf</item>\n    </style>\n\n    <style name=\"AppTheme.Widget.TextView.Style\">\n        <item name=\"fontPath\">fonts/RobotoCondensed-Regular.ttf</item>\n    </style>\n\n    <style name=\"AppTheme.Widget.TextViewAppearanceStyle\" parent=\"android:Widget.Holo.Light.TextView\">\n        <item name=\"android:textAppearance\">@style/TextAppearance.FontPath</item>\n    </style>\n\n    <style name=\"TextAppearance.FontPath\" parent=\"android:TextAppearance\">\n        <!-- Custom Attr-->\n        <item name=\"fontPath\">fonts/RobotoCondensed-Regular.ttf</item>\n        <item name=\"android:textColor\">#444</item>\n    </style>\n\n    <style name=\"TextAppearance.FontPathView\" parent=\"android:TextAppearance\">\n        <!-- Custom Attr-->\n        <item name=\"fontPath\">fonts/Oswald-Stencbab.ttf</item>\n        <item name=\"android:textColor\">#444</item>\n    </style>\n\n    <!-- Custom Class Styles -->\n    <style name=\"TextField\" parent=\"android:Widget.Holo.Light.TextView\">\n        <item name=\"fontPath\">fonts/gtw.ttf</item>\n        <item name=\"android:textSize\">@dimen/abc_text_size_small_material</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "CalligraphySample/src/main/res/values-w820dp/dimens.xml",
    "content": "<resources>\n    <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n         (such as screen margins) for screens with more than 820dp of available width. This\n         would include 7\" and 10\" devices in landscape (~960dp and ~1280dp respectively). -->\n    <dimen name=\"activity_horizontal_margin\">64dp</dimen>\n</resources>\n"
  },
  {
    "path": "LICENSE",
    "content": "Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"{}\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright 2013 Christopher Jenkins\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n\n"
  },
  {
    "path": "README.md",
    "content": "# This version of Calligraphy has reached its end-of-life and is no longer maintained. Please migrate to [Calligraphy 3](https://github.com/InflationX/Calligraphy)!\n\nCalligraphy\n===========\n\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Calligraphy-blue.svg?style=flat)](http://android-arsenal.com/details/1/163)\n\nCustom fonts in Android an OK way.\n\nAre you fed up of Custom Views to set fonts? Or traversing the ViewTree to find TextViews? Yeah me too.\n\n![alt text](https://github.com/chrisjenx/Calligraphy/raw/master/screenshot.png \"ScreenShot Of Font Samples\")\n\n## Getting started\n\n### Dependency\n\nInclude the dependency [Download (.aar)](http://search.maven.org/remotecontent?filepath=uk/co/chrisjenx/calligraphy/2.3.0/calligraphy-2.3.0.aar) :\n\n```groovy\ndependencies {\n    compile 'uk.co.chrisjenx:calligraphy:2.3.0'\n}\n```\n### Add Fonts\n\nAdd your custom fonts to `assets/`. All font definitions are relative to this path.\n\nAssuming that you are using Gradle you should create the assets directory under `src/main/` in your project directory if it does not already exist.\nAs it's popular to use multi-project build with Gradle the path is usually `app/src/main/assets/`, where `app` is the project name.\n\nYou might consider creating a `fonts/` subdirectory in the assets directory (as in examples).\n\n### Usage\n\n```xml\n<TextView fontPath=\"fonts/MyFont.ttf\"/>\n``` \n**Note: The missing namespace, this __IS__ intentional.**\n\n### Installation\n\nDefine your default font using `CalligraphyConfig`, in your `Application` class in the `#onCreate()` method.\n\n```java\n@Override\npublic void onCreate() {\n    super.onCreate();\n    CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()\n                            .setDefaultFontPath(\"fonts/Roboto-RobotoRegular.ttf\")\n                            .setFontAttrId(R.attr.fontPath)\n                            .build()\n            );\n    //....\n}\n```\n\n_Note: You don't need to define `CalligraphyConfig` but the library will apply\nno default font and use the default attribute of `R.attr.fontPath`._\n\n### Inject into Context\n\nWrap the `Activity` Context:\n\n```java\n@Override\nprotected void attachBaseContext(Context newBase) {\n    super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));\n}\n```\n\n_You're good to go!_\n\n\n## Usage\n\n### Custom font per TextView\n\n```xml\n<TextView\n    android:text=\"@string/hello_world\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    fontPath=\"fonts/Roboto-Bold.ttf\"/>\n```\n\n_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=\"\nhttp://schemas.android.com/tools\"`. See https://code.google.com/p/android/issues/detail?id=65176._\n\n### Custom font in TextAppearance\n\n\n```xml\n<style name=\"TextAppearance.FontPath\" parent=\"android:TextAppearance\">\n    <!-- Custom Attr-->\n    <item name=\"fontPath\">fonts/RobotoCondensed-Regular.ttf</item>\n</style>\n```\n\n```xml\n<TextView\n    android:text=\"@string/hello_world\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:textAppearance=\"@style/TextAppearance.FontPath\"/>\n\n```\n\n### Custom font in Styles\n\n\n```xml\n<style name=\"TextViewCustomFont\">\n    <item name=\"fontPath\">fonts/RobotoCondensed-Regular.ttf</item>\n</style>\n```\n\n### Custom font defined in Theme\n\n```xml\n<style name=\"AppTheme\" parent=\"android:Theme.Holo.Light.DarkActionBar\">\n    <item name=\"android:textViewStyle\">@style/AppTheme.Widget.TextView</item>\n</style>\n\n<style name=\"AppTheme.Widget\"/>\n\n<style name=\"AppTheme.Widget.TextView\" parent=\"android:Widget.Holo.Light.TextView\">\n    <item name=\"fontPath\">fonts/Roboto-ThinItalic.ttf</item>\n</style>\n```\n\n\n# FAQ\n\n### Font Resolution \n\nThe `CalligraphyFactory` looks for the font in a pretty specific order, for the _most part_ it's\n very similar to how the Android framework resolves attributes.\n \n1. `View` xml - attr defined here will always take priority.\n2. `Style` xml - attr defined here is checked next.\n3. `TextAppearance` xml - attr is checked next, the only caveat to this is **IF** you have a font \n defined in the `Style` and a `TextAttribute` defined in the `View` the `Style` attribute is picked first!\n4. `Theme` - if defined this is used.\n5. `Default` - if defined in the `CalligraphyConfig` this is used of none of the above are found \n**OR** if one of the above returns an invalid font. \n\n### Why *not* piggyback off of fontFamily attribute?\n\nWe originally did, but it conflicted with users wanting to actually use that attribute, you now \nhave to define a custom attribute.\n\n### Why no jar?\n\nWe needed to ship a custom ID with Calligraphy to improve the Font Injection flow. This\nunfortunately means that it has to be an `aar`. But you're using Gradle now anyway right?\n\n### Multiple Typeface's per TextView / Spannables\n\nIt is possible to use multiple Typefaces inside a `TextView`, this isn't new concept to Android.\n\nThis _could_ be achieved using something like the following code.\n\n```java\nSpannableStringBuilder sBuilder = new SpannableStringBuilder();\nsBuilder.append(\"Hello!\") // Bold this\n        .append(\"I use Calligraphy\"); // Default TextView font.\n// Create the Typeface you want to apply to certain text\nCalligraphyTypefaceSpan typefaceSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), \"fonts/Roboto-Bold.ttf\"));\n// Apply typeface to the Spannable 0 - 6 \"Hello!\" This can of course by dynamic.\nsBuilder.setSpan(typefaceSpan, 0, 6, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);\nsetText(sBuilder, TextView.BufferType.SPANNABLE);\n```\nOf course this is just an example. Your mileage may vary.\n\n### Exceptions / Pitfalls\n\nTo our knowledge (try: `grep -r -e \"void set[^(]*(Typeface \" <android source dir>`) there are two standard Android widgets that have multiple methods to set typefaces. They are:\n\n - android.support.v7.widget.SwitchCompat\n - android.widget.Switch\n\nBoth have a method called `setSwitchTypeface` that sets the typeface within the switch (e.g. on/off, yes/no). `SetTypeface` sets the typeface of the label. You will need to create your own subclass that overrides `setTypeface` and calls both `super.setTypeface` and `super.setSwitchTypeface`.\n\n\n\n\n\n# Collaborators\n\n- [@mironov-nsk](https://github.com/mironov-nsk)\n- [@Roman Zhilich](https://github.com/RomanZhilich)\n- [@Smuldr](https://github.com/Smuldr)\n- [@Codebutler](https://github.com/codebutler)\n- [@loganj](https://github.com/loganj)\n- [@dlew](https://github.com/dlew)\n- [@ansman](https://github.com/ansman)\n\n# Note\n\nThis library was created because it is currently not possible to declare a custom font in XML files in Android.\n\nIf you feel this should be possible to do, please star [this issue](https://code.google.com/p/android/issues/detail?id=88945) on the official Android bug tracker.\n\n# Licence\n\n    Copyright 2013 Christopher Jenkins\n    \n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n    \n        http://www.apache.org/licenses/LICENSE-2.0\n    \n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n[![Badge](http://www.libtastic.com/static/osbadges/79.png)](http://www.libtastic.com/technology/79/)\n"
  },
  {
    "path": "build.gradle",
    "content": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\nbuildscript {\n  repositories {\n    jcenter()\n    google()\n  }\n  dependencies {\n    classpath 'com.android.tools.build:gradle:3.1.1'\n  }\n}\n\nallprojects {\n  repositories {\n    jcenter()\n    google()\n  }\n  // Is Release Build?\n  version = getProperty('VERSION_NAME')\n\n  ext {\n    isReleaseVersion = has(\"release\")\n    versionCodeInt = getProperty('VERSION_CODE').toInteger()\n    supportLibraryVersion = '27.1.1'\n    buildToolsVersion = '27.0.3'\n    compileSdkVersion = 27\n    minSdkVersion = 14\n    targetSdkVersion = 27\n  }\n}\n\ntask wrapper(type: Wrapper) {\n  gradleVersion = '3.5'\n  distributionUrl = \"https://services.gradle.org/distributions/gradle-$gradleVersion-bin.zip\"\n}\n"
  },
  {
    "path": "calligraphy/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "calligraphy/build.gradle",
    "content": "apply plugin: 'com.android.library'\napply from: rootProject.file('gradle/deploy.gradle')\n\nandroid {\n    compileSdkVersion project.compileSdkVersion\n    buildToolsVersion project.buildToolsVersion\n\n    defaultConfig {\n        minSdkVersion project.minSdkVersion\n        targetSdkVersion project.targetSdkVersion\n        versionCode project.versionCodeInt\n        versionName version\n        consumerProguardFiles 'consumer-proguard-rules.txt'\n    }\n\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'consumer-proguard-rules.txt'\n        }\n    }\n}\n\ndependencies {\n    api \"com.android.support:appcompat-v7:${supportLibraryVersion}\"\n}\n"
  },
  {
    "path": "calligraphy/consumer-proguard-rules.txt",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /Developer/android-sdk-osx/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the ProGuard\n# include property in project.properties.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n-keep class uk.co.chrisjenx.calligraphy.* { *; }\n-keep class uk.co.chrisjenx.calligraphy.*$* { *; }\n\n"
  },
  {
    "path": "calligraphy/gradle.properties",
    "content": "# SubProject Library Gradle Properties\n# See parent properties for global properties\n\nPOM_NAME=Calligraphy\nPOM_ARTIFACT_ID=calligraphy\nPOM_PACKAGING=aar"
  },
  {
    "path": "calligraphy/src/main/AndroidManifest.xml",
    "content": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"uk.co.chrisjenx.calligraphy\">\n    <application />\n</manifest>\n"
  },
  {
    "path": "calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/CalligraphyActivityFactory.java",
    "content": "package uk.co.chrisjenx.calligraphy;\n\nimport android.content.Context;\nimport android.util.AttributeSet;\nimport android.view.View;\n\n/**\n * Created by chris on 09/11/14.\n * For Calligraphy.\n */\ninterface CalligraphyActivityFactory {\n\n    /**\n     * Used to Wrap the Activity onCreateView method.\n     *\n     * You implement this method like so in your base activity.\n     * <pre>\n     * {@code\n     * public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {\n     *   return CalligraphyContextWrapper.get(getBaseContext()).onActivityCreateView(super.onCreateView(parent, name, context, attrs), attrs);\n     * }\n     * }\n     * </pre>\n     *\n     * @param parent  parent view, can be null.\n     * @param view    result of {@code super.onCreateView(parent, name, context, attrs)}, this might be null, which is fine.\n     * @param name    Name of View we are trying to inflate\n     * @param context current context (normally the Activity's)\n     * @param attrs   see {@link android.view.LayoutInflater.Factory2#onCreateView(android.view.View, String, android.content.Context, android.util.AttributeSet)}  @return the result from the activities {@code onCreateView()}\n     * @return The view passed in, or null if nothing was passed in.\n     * @see android.view.LayoutInflater.Factory2\n     */\n    View onActivityCreateView(View parent, View view, String name, Context context, AttributeSet attrs);\n}\n"
  },
  {
    "path": "calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/CalligraphyConfig.java",
    "content": "package uk.co.chrisjenx.calligraphy;\n\nimport android.os.Build;\nimport android.text.TextUtils;\nimport android.view.View;\nimport android.widget.AutoCompleteTextView;\nimport android.widget.Button;\nimport android.widget.CheckBox;\nimport android.widget.EditText;\nimport android.widget.MultiAutoCompleteTextView;\nimport android.widget.RadioButton;\nimport android.widget.TextView;\nimport android.widget.ToggleButton;\n\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.Map;\nimport java.util.Set;\n\n/**\n * Created by chris on 20/12/2013\n * Project: Calligraphy\n */\npublic class CalligraphyConfig {\n\n    /**\n     * The default styles for the factory to lookup. The builder builds an extended immutable\n     * map of this with any additional custom styles.\n     */\n    private static final Map<Class<? extends TextView>, Integer> DEFAULT_STYLES = new HashMap<>();\n\n    static {\n        {\n            DEFAULT_STYLES.put(TextView.class, android.R.attr.textViewStyle);\n            DEFAULT_STYLES.put(Button.class, android.R.attr.buttonStyle);\n            DEFAULT_STYLES.put(EditText.class, android.R.attr.editTextStyle);\n            DEFAULT_STYLES.put(AutoCompleteTextView.class, android.R.attr.autoCompleteTextViewStyle);\n            DEFAULT_STYLES.put(MultiAutoCompleteTextView.class, android.R.attr.autoCompleteTextViewStyle);\n            DEFAULT_STYLES.put(CheckBox.class, android.R.attr.checkboxStyle);\n            DEFAULT_STYLES.put(RadioButton.class, android.R.attr.radioButtonStyle);\n            DEFAULT_STYLES.put(ToggleButton.class, android.R.attr.buttonStyleToggle);\n            if (CalligraphyUtils.canAddV7AppCompatViews()) {\n                addAppCompatViews();\n            }\n        }\n    }\n\n    /**\n     * AppCompat will inflate special versions of views for Material tinting etc,\n     * this adds those classes to the style lookup map\n     */\n    private static void addAppCompatViews() {\n        DEFAULT_STYLES.put(android.support.v7.widget.AppCompatTextView.class, android.R.attr.textViewStyle);\n        DEFAULT_STYLES.put(android.support.v7.widget.AppCompatButton.class, android.R.attr.buttonStyle);\n        DEFAULT_STYLES.put(android.support.v7.widget.AppCompatEditText.class, android.R.attr.editTextStyle);\n        DEFAULT_STYLES.put(android.support.v7.widget.AppCompatAutoCompleteTextView.class, android.R.attr.autoCompleteTextViewStyle);\n        DEFAULT_STYLES.put(android.support.v7.widget.AppCompatMultiAutoCompleteTextView.class, android.R.attr.autoCompleteTextViewStyle);\n        DEFAULT_STYLES.put(android.support.v7.widget.AppCompatCheckBox.class, android.R.attr.checkboxStyle);\n        DEFAULT_STYLES.put(android.support.v7.widget.AppCompatRadioButton.class, android.R.attr.radioButtonStyle);\n        DEFAULT_STYLES.put(android.support.v7.widget.AppCompatCheckedTextView.class, android.R.attr.checkedTextViewStyle);\n    }\n\n    private static CalligraphyConfig sInstance;\n\n    /**\n     * Set the default Calligraphy Config\n     *\n     * @param calligraphyConfig the config build using the builder.\n     * @see uk.co.chrisjenx.calligraphy.CalligraphyConfig.Builder\n     */\n    public static void initDefault(CalligraphyConfig calligraphyConfig) {\n        sInstance = calligraphyConfig;\n    }\n\n    /**\n     * The current Calligraphy Config.\n     * If not set it will create a default config.\n     */\n    public static CalligraphyConfig get() {\n        if (sInstance == null)\n            sInstance = new CalligraphyConfig(new Builder());\n        return sInstance;\n    }\n\n    /**\n     * Is a default font set?\n     */\n    private final boolean mIsFontSet;\n    /**\n     * The default Font Path if nothing else is setup.\n     */\n    private final String mFontPath;\n    /**\n     * Default Font Path Attr Id to lookup\n     */\n    private final int mAttrId;\n    /**\n     * Use Reflection to inject the private factory.\n     */\n    private final boolean mReflection;\n    /**\n     * Use Reflection to intercept CustomView inflation with the correct Context.\n     */\n    private final boolean mCustomViewCreation;\n    /**\n     * Use Reflection to try to set typeface for custom views if they has setTypeface method\n     */\n    private final boolean mCustomViewTypefaceSupport;\n    /**\n     * Class Styles. Build from DEFAULT_STYLES and the builder.\n     */\n    private final Map<Class<? extends TextView>, Integer> mClassStyleAttributeMap;\n    /**\n     * Collection of custom non-{@code TextView}'s registered for applying typeface during inflation\n     * @see uk.co.chrisjenx.calligraphy.CalligraphyConfig.Builder#addCustomViewWithSetTypeface(Class)\n     */\n    private final Set<Class<?>> hasTypefaceViews;\n\n    protected CalligraphyConfig(Builder builder) {\n        mIsFontSet = builder.isFontSet;\n        mFontPath = builder.fontAssetPath;\n        mAttrId = builder.attrId;\n        mReflection = builder.reflection;\n        mCustomViewCreation = builder.customViewCreation;\n        mCustomViewTypefaceSupport = builder.customViewTypefaceSupport;\n        final Map<Class<? extends TextView>, Integer> tempMap = new HashMap<>(DEFAULT_STYLES);\n        tempMap.putAll(builder.mStyleClassMap);\n        mClassStyleAttributeMap = Collections.unmodifiableMap(tempMap);\n        hasTypefaceViews = Collections.unmodifiableSet(builder.mHasTypefaceClasses);\n    }\n\n    /**\n     * @return mFontPath for text views might be null\n     */\n    public String getFontPath() {\n        return mFontPath;\n    }\n\n    /**\n     * @return true if set, false if null|empty\n     */\n    boolean isFontSet() {\n        return mIsFontSet;\n    }\n\n    public boolean isReflection() {\n        return mReflection;\n    }\n\n    public boolean isCustomViewCreation() {\n        return mCustomViewCreation;\n    }\n\n    public boolean isCustomViewTypefaceSupport() {\n        return mCustomViewTypefaceSupport;\n    }\n\n    public boolean isCustomViewHasTypeface(View view) {\n        return hasTypefaceViews.contains(view.getClass());\n    }\n\n    /* default */ Map<Class<? extends TextView>, Integer> getClassStyles() {\n        return mClassStyleAttributeMap;\n    }\n\n    /**\n     * @return the custom attrId to look for, -1 if not set.\n     */\n    public int getAttrId() {\n        return mAttrId;\n    }\n\n    public static class Builder {\n        /**\n         * Default AttrID if not set.\n         */\n        public static final int INVALID_ATTR_ID = -1;\n        /**\n         * Use Reflection to inject the private factory. Doesn't exist pre HC. so defaults to false.\n         */\n        private boolean reflection = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;\n        /**\n         * Use Reflection to intercept CustomView inflation with the correct Context.\n         */\n        private boolean customViewCreation = true;\n        /**\n         * Use Reflection during view creation to try change typeface via setTypeface method if it exists\n         */\n        private boolean customViewTypefaceSupport = false;\n        /**\n         * The fontAttrId to look up the font path from.\n         */\n        private int attrId = R.attr.fontPath;\n        /**\n         * Has the user set the default font path.\n         */\n        private boolean isFontSet = false;\n        /**\n         * The default fontPath\n         */\n        private String fontAssetPath = null;\n        /**\n         * Additional Class Styles. Can be empty.\n         */\n        private Map<Class<? extends TextView>, Integer> mStyleClassMap = new HashMap<>();\n\n        private Set<Class<?>> mHasTypefaceClasses = new HashSet<>();\n\n        /**\n         * This defaults to R.attr.fontPath. So only override if you want to use your own attrId.\n         *\n         * @param fontAssetAttrId the custom attribute to look for fonts in assets.\n         * @return this builder.\n         */\n        public Builder setFontAttrId(int fontAssetAttrId) {\n            this.attrId = fontAssetAttrId;\n            return this;\n        }\n\n        /**\n         * Set the default font if you don't define one else where in your styles.\n         *\n         * @param defaultFontAssetPath a path to a font file in the assets folder, e.g. \"fonts/Roboto-light.ttf\",\n         *                             passing null will default to the device font-family.\n         * @return this builder.\n         */\n        public Builder setDefaultFontPath(String defaultFontAssetPath) {\n            this.isFontSet = !TextUtils.isEmpty(defaultFontAssetPath);\n            this.fontAssetPath = defaultFontAssetPath;\n            return this;\n        }\n\n        /**\n         * <p>Turn of the use of Reflection to inject the private factory.\n         * This has operational consequences! Please read and understand before disabling.\n         * <b>This is already disabled on pre Honeycomb devices. (API 11)</b></p>\n         *\n         * <p> If you disable this you will need to override your {@link android.app.Activity#onCreateView(android.view.View, String, android.content.Context, android.util.AttributeSet)}\n         * as this is set as the {@link android.view.LayoutInflater} private factory.</p>\n         * <br>\n         * <b> Use the following code in the Activity if you disable FactoryInjection:</b>\n         * <pre><code>\n         * {@literal @}Override\n         * {@literal @}TargetApi(Build.VERSION_CODES.HONEYCOMB)\n         * public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {\n         *   return CalligraphyContextWrapper.onActivityCreateView(this, parent, super.onCreateView(parent, name, context, attrs), name, context, attrs);\n         * }\n         * </code></pre>\n         */\n        public Builder disablePrivateFactoryInjection() {\n            this.reflection = false;\n            return this;\n        }\n\n        /**\n         * Due to the poor inflation order where custom views are created and never returned inside an\n         * {@code onCreateView(...)} method. We have to create CustomView's at the latest point in the\n         * overrideable injection flow.\n         *\n         * On HoneyComb+ this is inside the {@link android.app.Activity#onCreateView(android.view.View, String, android.content.Context, android.util.AttributeSet)}\n         * Pre HoneyComb this is in the {@link android.view.LayoutInflater.Factory#onCreateView(String, android.util.AttributeSet)}\n         *\n         * We wrap base implementations, so if you LayoutInflater/Factory/Activity creates the\n         * custom view before we get to this point, your view is used. (Such is the case with the\n         * TintEditText etc)\n         *\n         * The problem is, the native methods pass there parents context to the constructor in a really\n         * specific place. We have to mimic this in {@link uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater#createCustomViewInternal(android.view.View, android.view.View, String, android.content.Context, android.util.AttributeSet)}\n         * To mimic this we have to use reflection as the Class constructor args are hidden to us.\n         *\n         * We have discussed other means of doing this but this is the only semi-clean way of doing it.\n         * (Without having to do proxy classes etc).\n         *\n         * Calling this will of course speed up inflation by turning off reflection, but not by much,\n         * But if you want Calligraphy to inject the correct typeface then you will need to make sure your CustomView's\n         * are created before reaching the LayoutInflater onViewCreated.\n         */\n        public Builder disableCustomViewInflation() {\n            this.customViewCreation = false;\n            return this;\n        }\n\n        /**\n         * Add a custom style to get looked up. If you use a custom class that has a parent style\n         * which is not part of the default android styles you will need to add it here.\n         *\n         * The Calligraphy inflater is unaware of custom styles in your custom classes. We use\n         * the class type to look up the style attribute in the theme resources.\n         *\n         * So if you had a {@code MyTextField.class} which looked up it's default style as\n         * {@code R.attr.textFieldStyle} you would add those here.\n         *\n         * {@code builder.addCustomStyle(MyTextField.class,R.attr.textFieldStyle}\n         *\n         * @param styleClass             the class that related to the parent styleResource. null is ignored.\n         * @param styleResourceAttribute e.g. {@code R.attr.textFieldStyle}, 0 is ignored.\n         * @return this builder.\n         */\n        public Builder addCustomStyle(final Class<? extends TextView> styleClass, final int styleResourceAttribute) {\n            if (styleClass == null || styleResourceAttribute == 0) return this;\n            mStyleClassMap.put(styleClass, styleResourceAttribute);\n            return this;\n        }\n\n        /**\n         * Register custom non-{@code TextView}'s which implement {@code setTypeface} so they can have the Typeface applied during inflation.\n         */\n        public Builder addCustomViewWithSetTypeface(Class<?> clazz) {\n            customViewTypefaceSupport = true;\n            mHasTypefaceClasses.add(clazz);\n            return this;\n        }\n\n        public CalligraphyConfig build() {\n            this.isFontSet = !TextUtils.isEmpty(fontAssetPath);\n            return new CalligraphyConfig(this);\n        }\n    }\n}\n"
  },
  {
    "path": "calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/CalligraphyContextWrapper.java",
    "content": "package uk.co.chrisjenx.calligraphy;\n\nimport android.app.Activity;\nimport android.content.Context;\nimport android.content.ContextWrapper;\nimport android.util.AttributeSet;\nimport android.view.LayoutInflater;\nimport android.view.View;\n\n/**\n * Created by chris on 19/12/2013\n * Project: Calligraphy\n */\npublic class CalligraphyContextWrapper extends ContextWrapper {\n\n    private CalligraphyLayoutInflater mInflater;\n\n    private final int mAttributeId;\n\n    /**\n     * Uses the default configuration from {@link uk.co.chrisjenx.calligraphy.CalligraphyConfig}\n     *\n     * Remember if you are defining default in the\n     * {@link uk.co.chrisjenx.calligraphy.CalligraphyConfig} make sure this is initialised before\n     * the activity is created.\n     *\n     * @param base ContextBase to Wrap.\n     * @return ContextWrapper to pass back to the activity.\n     */\n    public static ContextWrapper wrap(Context base) {\n        return new CalligraphyContextWrapper(base);\n    }\n\n    /**\n     * You only need to call this <b>IF</b> you call\n     * {@link uk.co.chrisjenx.calligraphy.CalligraphyConfig.Builder#disablePrivateFactoryInjection()}\n     * This will need to be called from the\n     * {@link android.app.Activity#onCreateView(android.view.View, String, android.content.Context, android.util.AttributeSet)}\n     * method to enable view font injection if the view is created inside the activity onCreateView.\n     *\n     * You would implement this method like so in you base activity.\n     * <pre>\n     * {@code\n     * public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {\n     *   return CalligraphyContextWrapper.onActivityCreateView(this, parent, super.onCreateView(parent, name, context, attrs), name, context, attrs);\n     * }\n     * }\n     * </pre>\n     *\n     * @param activity The activity the original that the ContextWrapper was attached too.\n     * @param parent   Parent view from onCreateView\n     * @param view     The View Created inside onCreateView or from super.onCreateView\n     * @param name     The View name from onCreateView\n     * @param context  The context from onCreateView\n     * @param attr     The AttributeSet from onCreateView\n     * @return The same view passed in, or null if null passed in.\n     */\n    public static View onActivityCreateView(Activity activity, View parent, View view, String name, Context context, AttributeSet attr) {\n        return get(activity).onActivityCreateView(parent, view, name, context, attr);\n    }\n\n    /**\n     * Get the Calligraphy Activity Fragment Instance to allow callbacks for when views are created.\n     *\n     * @param activity The activity the original that the ContextWrapper was attached too.\n     * @return Interface allowing you to call onActivityViewCreated\n     */\n    static CalligraphyActivityFactory get(Activity activity) {\n        if (!(activity.getLayoutInflater() instanceof CalligraphyLayoutInflater)) {\n            throw new RuntimeException(\"This activity does not wrap the Base Context! See CalligraphyContextWrapper.wrap(Context)\");\n        }\n        return (CalligraphyActivityFactory) activity.getLayoutInflater();\n    }\n\n    /**\n     * Uses the default configuration from {@link uk.co.chrisjenx.calligraphy.CalligraphyConfig}\n     *\n     * Remember if you are defining default in the\n     * {@link uk.co.chrisjenx.calligraphy.CalligraphyConfig} make sure this is initialised before\n     * the activity is created.\n     *\n     * @param base ContextBase to Wrap\n     */\n    CalligraphyContextWrapper(Context base) {\n        super(base);\n        mAttributeId = CalligraphyConfig.get().getAttrId();\n    }\n\n    /**\n     * Override the default AttributeId, this will always take the custom attribute defined here\n     * and ignore the one set in {@link uk.co.chrisjenx.calligraphy.CalligraphyConfig}.\n     *\n     * Remember if you are defining default in the\n     * {@link uk.co.chrisjenx.calligraphy.CalligraphyConfig} make sure this is initialised before\n     * the activity is created.\n     *\n     * @param base        ContextBase to Wrap\n     * @param attributeId Attribute to lookup.\n     * @deprecated use {@link #wrap(android.content.Context)}\n     */\n    @Deprecated\n    public CalligraphyContextWrapper(Context base, int attributeId) {\n        super(base);\n        mAttributeId = attributeId;\n    }\n\n    @Override\n    public Object getSystemService(String name) {\n        if (LAYOUT_INFLATER_SERVICE.equals(name)) {\n            if (mInflater == null) {\n                mInflater = new CalligraphyLayoutInflater(LayoutInflater.from(getBaseContext()), this, mAttributeId, false);\n            }\n            return mInflater;\n        }\n        return super.getSystemService(name);\n    }\n\n}\n"
  },
  {
    "path": "calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/CalligraphyFactory.java",
    "content": "package uk.co.chrisjenx.calligraphy;\n\nimport android.annotation.SuppressLint;\nimport android.content.Context;\nimport android.graphics.Typeface;\nimport android.support.v7.widget.Toolbar;\nimport android.text.TextUtils;\nimport android.util.AttributeSet;\nimport android.view.View;\nimport android.widget.TextView;\n\nimport java.lang.reflect.Method;\n\nclass CalligraphyFactory {\n\n    private static final String ACTION_BAR_TITLE = \"action_bar_title\";\n    private static final String ACTION_BAR_SUBTITLE = \"action_bar_subtitle\";\n\n    /**\n     * Some styles are in sub styles, such as actionBarTextStyle etc..\n     *\n     * @param view view to check.\n     * @return 2 element array, default to -1 unless a style has been found.\n     */\n    protected static int[] getStyleForTextView(TextView view) {\n        final int[] styleIds = new int[]{-1, -1};\n        // Try to find the specific actionbar styles\n        if (isActionBarTitle(view)) {\n            styleIds[0] = android.R.attr.actionBarStyle;\n            styleIds[1] = android.R.attr.titleTextStyle;\n        } else if (isActionBarSubTitle(view)) {\n            styleIds[0] = android.R.attr.actionBarStyle;\n            styleIds[1] = android.R.attr.subtitleTextStyle;\n        }\n        if (styleIds[0] == -1) {\n            // Use TextAppearance as default style\n            styleIds[0] = CalligraphyConfig.get().getClassStyles().containsKey(view.getClass())\n                    ? CalligraphyConfig.get().getClassStyles().get(view.getClass())\n                    : android.R.attr.textAppearance;\n        }\n        return styleIds;\n    }\n\n    /**\n     * An even dirtier way to see if the TextView is part of the ActionBar\n     *\n     * @param view TextView to check is Title\n     * @return true if it is.\n     */\n    @SuppressLint(\"NewApi\")\n    protected static boolean isActionBarTitle(TextView view) {\n        if (matchesResourceIdName(view, ACTION_BAR_TITLE)) return true;\n        if (parentIsToolbarV7(view)) {\n            final android.support.v7.widget.Toolbar parent = (android.support.v7.widget.Toolbar) view.getParent();\n            return TextUtils.equals(parent.getTitle(), view.getText());\n        }\n        return false;\n    }\n\n    /**\n     * An even dirtier way to see if the TextView is part of the ActionBar\n     *\n     * @param view TextView to check is Title\n     * @return true if it is.\n     */\n    @SuppressLint(\"NewApi\")\n    protected static boolean isActionBarSubTitle(TextView view) {\n        if (matchesResourceIdName(view, ACTION_BAR_SUBTITLE)) return true;\n        if (parentIsToolbarV7(view)) {\n            final android.support.v7.widget.Toolbar parent = (android.support.v7.widget.Toolbar) view.getParent();\n            return TextUtils.equals(parent.getSubtitle(), view.getText());\n        }\n        return false;\n    }\n\n    protected static boolean parentIsToolbarV7(View view) {\n        return CalligraphyUtils.canCheckForV7Toolbar() && view.getParent() != null && (view.getParent() instanceof android.support.v7.widget.Toolbar);\n    }\n\n    /**\n     * Use to match a view against a potential view id. Such as ActionBar title etc.\n     *\n     * @param view    not null view you want to see has resource matching name.\n     * @param matches not null resource name to match against. Its not case sensitive.\n     * @return true if matches false otherwise.\n     */\n    protected static boolean matchesResourceIdName(View view, String matches) {\n        if (view.getId() == View.NO_ID) return false;\n        final String resourceEntryName = view.getResources().getResourceEntryName(view.getId());\n        return resourceEntryName.equalsIgnoreCase(matches);\n    }\n\n    private final int[] mAttributeId;\n\n    public CalligraphyFactory(int attributeId) {\n        this.mAttributeId = new int[]{attributeId};\n    }\n\n    /**\n     * Handle the created view\n     *\n     * @param view    nullable.\n     * @param context shouldn't be null.\n     * @param attrs   shouldn't be null.\n     * @return null if null is passed in.\n     */\n\n    public View onViewCreated(View view, Context context, AttributeSet attrs) {\n        if (view != null && view.getTag(R.id.calligraphy_tag_id) != Boolean.TRUE) {\n            onViewCreatedInternal(view, context, attrs);\n            view.setTag(R.id.calligraphy_tag_id, Boolean.TRUE);\n        }\n        return view;\n    }\n\n    void onViewCreatedInternal(View view, final Context context, AttributeSet attrs) {\n        if (view instanceof TextView) {\n            // Fast path the setting of TextView's font, means if we do some delayed setting of font,\n            // which has already been set by use we skip this TextView (mainly for inflating custom,\n            // TextView's inside the Toolbar/ActionBar).\n            if (TypefaceUtils.isLoaded(((TextView) view).getTypeface())) {\n                return;\n            }\n            // Try to get typeface attribute value\n            // Since we're not using namespace it's a little bit tricky\n\n            // Check xml attrs, style attrs and text appearance for font path\n            String textViewFont = resolveFontPath(context, attrs);\n\n            // Try theme attributes\n            if (TextUtils.isEmpty(textViewFont)) {\n                final int[] styleForTextView = getStyleForTextView((TextView) view);\n                if (styleForTextView[1] != -1)\n                    textViewFont = CalligraphyUtils.pullFontPathFromTheme(context, styleForTextView[0], styleForTextView[1], mAttributeId);\n                else\n                    textViewFont = CalligraphyUtils.pullFontPathFromTheme(context, styleForTextView[0], mAttributeId);\n            }\n\n            // Still need to defer the Native action bar, appcompat-v7:21+ uses the Toolbar underneath. But won't match these anyway.\n            final boolean deferred = matchesResourceIdName(view, ACTION_BAR_TITLE) || matchesResourceIdName(view, ACTION_BAR_SUBTITLE);\n\n            CalligraphyUtils.applyFontToTextView(context, (TextView) view, CalligraphyConfig.get(), textViewFont, deferred);\n        }\n\n        // AppCompat API21+ The ActionBar doesn't inflate default Title/SubTitle, we need to scan the\n        // Toolbar(Which underlies the ActionBar) for its children.\n        if (CalligraphyUtils.canCheckForV7Toolbar() && view instanceof android.support.v7.widget.Toolbar) {\n            applyFontToToolbar((Toolbar) view);\n        }\n\n        // Try to set typeface for custom views using interface method or via reflection if available\n        if (view instanceof HasTypeface) {\n            Typeface typeface = getDefaultTypeface(context, resolveFontPath(context, attrs));\n            if (typeface != null) {\n                ((HasTypeface) view).setTypeface(typeface);\n            }\n        } else if (CalligraphyConfig.get().isCustomViewTypefaceSupport() && CalligraphyConfig.get().isCustomViewHasTypeface(view)) {\n            final Method setTypeface = ReflectionUtils.getMethod(view.getClass(), \"setTypeface\");\n            String fontPath = resolveFontPath(context, attrs);\n            Typeface typeface = getDefaultTypeface(context, fontPath);\n            if (setTypeface != null && typeface != null) {\n                ReflectionUtils.invokeMethod(view, setTypeface, typeface);\n            }\n        }\n\n    }\n\n    private Typeface getDefaultTypeface(Context context, String fontPath) {\n        if (TextUtils.isEmpty(fontPath)) {\n            fontPath = CalligraphyConfig.get().getFontPath();\n        }\n        if (!TextUtils.isEmpty(fontPath)) {\n            return TypefaceUtils.load(context.getAssets(), fontPath);\n        }\n        return null;\n    }\n\n    /**\n     * Resolving font path from xml attrs, style attrs or text appearance\n     */\n    private String resolveFontPath(Context context, AttributeSet attrs) {\n        // Try view xml attributes\n        String textViewFont = CalligraphyUtils.pullFontPathFromView(context, attrs, mAttributeId);\n\n        // Try view style attributes\n        if (TextUtils.isEmpty(textViewFont)) {\n            textViewFont = CalligraphyUtils.pullFontPathFromStyle(context, attrs, mAttributeId);\n        }\n\n        // Try View TextAppearance\n        if (TextUtils.isEmpty(textViewFont)) {\n            textViewFont = CalligraphyUtils.pullFontPathFromTextAppearance(context, attrs, mAttributeId);\n        }\n\n        return textViewFont;\n    }\n\n    /**\n     * Will forcibly set text on the views then remove ones that didn't have copy.\n     *\n     * @param view toolbar view.\n     */\n    private void applyFontToToolbar(final Toolbar view) {\n        final CharSequence previousTitle = view.getTitle();\n        final CharSequence previousSubtitle = view.getSubtitle();\n        // The toolbar inflates both the title and the subtitle views lazily but luckily they do it\n        // synchronously when you set a title and a subtitle programmatically.\n        // So we set a title and a subtitle to something, then get the views, then revert.\n        view.setTitle(\"uk.co.chrisjenx.calligraphy:toolbar_title\");\n        view.setSubtitle(\"uk.co.chrisjenx.calligraphy:toolbar_subtitle\");\n\n        // Iterate through the children to run post inflation on them\n        final int childCount = view.getChildCount();\n        for (int i = 0; i < childCount; i++) {\n            onViewCreated(view.getChildAt(i), view.getContext(), null);\n        }\n        // Remove views from view if they didn't have copy set.\n        view.setTitle(previousTitle);\n        view.setSubtitle(previousSubtitle);\n    }\n}\n"
  },
  {
    "path": "calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/CalligraphyLayoutInflater.java",
    "content": "package uk.co.chrisjenx.calligraphy;\n\nimport android.annotation.TargetApi;\nimport android.content.Context;\nimport android.os.Build;\nimport android.util.AttributeSet;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\n\nimport org.xmlpull.v1.XmlPullParser;\n\nimport java.lang.reflect.Field;\nimport java.lang.reflect.Method;\n\n/**\n * Created by chris on 19/12/2013\n * Project: Calligraphy\n */\nclass CalligraphyLayoutInflater extends LayoutInflater implements CalligraphyActivityFactory {\n\n    private static final String[] sClassPrefixList = {\n            \"android.widget.\",\n            \"android.webkit.\"\n    };\n\n    private final int mAttributeId;\n    private final CalligraphyFactory mCalligraphyFactory;\n    // Reflection Hax\n    private boolean mSetPrivateFactory = false;\n    private Field mConstructorArgs = null;\n\n    protected CalligraphyLayoutInflater(Context context, int attributeId) {\n        super(context);\n        mAttributeId = attributeId;\n        mCalligraphyFactory = new CalligraphyFactory(attributeId);\n        setUpLayoutFactories(false);\n    }\n\n    protected CalligraphyLayoutInflater(LayoutInflater original, Context newContext, int attributeId, final boolean cloned) {\n        super(original, newContext);\n        mAttributeId = attributeId;\n        mCalligraphyFactory = new CalligraphyFactory(attributeId);\n        setUpLayoutFactories(cloned);\n    }\n\n    @Override\n    public LayoutInflater cloneInContext(Context newContext) {\n        return new CalligraphyLayoutInflater(this, newContext, mAttributeId, true);\n    }\n\n    // ===\n    // Wrapping goodies\n    // ===\n\n\n    @Override\n    public View inflate(XmlPullParser parser, ViewGroup root, boolean attachToRoot) {\n        setPrivateFactoryInternal();\n        return super.inflate(parser, root, attachToRoot);\n    }\n\n    /**\n     * We don't want to unnecessary create/set our factories if there are none there. We try to be\n     * as lazy as possible.\n     */\n    private void setUpLayoutFactories(boolean cloned) {\n        if (cloned) return;\n        // If we are HC+ we get and set Factory2 otherwise we just wrap Factory1\n        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {\n            if (getFactory2() != null && !(getFactory2() instanceof WrapperFactory2)) {\n                // Sets both Factory/Factory2\n                setFactory2(getFactory2());\n            }\n        }\n        // We can do this as setFactory2 is used for both methods.\n        if (getFactory() != null && !(getFactory() instanceof WrapperFactory)) {\n            setFactory(getFactory());\n        }\n    }\n\n    @Override\n    public void setFactory(Factory factory) {\n        // Only set our factory and wrap calls to the Factory trying to be set!\n        if (!(factory instanceof WrapperFactory)) {\n            super.setFactory(new WrapperFactory(factory, this, mCalligraphyFactory));\n        } else {\n            super.setFactory(factory);\n        }\n    }\n\n    @Override\n    @TargetApi(Build.VERSION_CODES.HONEYCOMB)\n    public void setFactory2(Factory2 factory2) {\n        // Only set our factory and wrap calls to the Factory2 trying to be set!\n        if (!(factory2 instanceof WrapperFactory2)) {\n//            LayoutInflaterCompat.setFactory(this, new WrapperFactory2(factory2, mCalligraphyFactory));\n            super.setFactory2(new WrapperFactory2(factory2, mCalligraphyFactory));\n        } else {\n            super.setFactory2(factory2);\n        }\n    }\n\n    private void setPrivateFactoryInternal() {\n        // Already tried to set the factory.\n        if (mSetPrivateFactory) return;\n        // Reflection (Or Old Device) skip.\n        if (!CalligraphyConfig.get().isReflection()) return;\n        // Skip if not attached to an activity.\n        if (!(getContext() instanceof Factory2)) {\n            mSetPrivateFactory = true;\n            return;\n        }\n\n        final Method setPrivateFactoryMethod = ReflectionUtils\n                .getMethod(LayoutInflater.class, \"setPrivateFactory\");\n\n        if (setPrivateFactoryMethod != null) {\n            ReflectionUtils.invokeMethod(this,\n                    setPrivateFactoryMethod,\n                    new PrivateWrapperFactory2((Factory2) getContext(), this, mCalligraphyFactory));\n        }\n        mSetPrivateFactory = true;\n    }\n\n    // ===\n    // LayoutInflater ViewCreators\n    // Works in order of inflation\n    // ===\n\n    /**\n     * The Activity onCreateView (PrivateFactory) is the third port of call for LayoutInflation.\n     * We opted to manual injection over aggressive reflection, this should be less fragile.\n     */\n    @Override\n    @TargetApi(Build.VERSION_CODES.HONEYCOMB)\n    public View onActivityCreateView(View parent, View view, String name, Context context, AttributeSet attrs) {\n        return mCalligraphyFactory.onViewCreated(createCustomViewInternal(parent, view, name, context, attrs), context, attrs);\n    }\n\n    /**\n     * The LayoutInflater onCreateView is the fourth port of call for LayoutInflation.\n     * BUT only for none CustomViews.\n     */\n    @Override\n    @TargetApi(Build.VERSION_CODES.HONEYCOMB)\n    protected View onCreateView(View parent, String name, AttributeSet attrs) throws ClassNotFoundException {\n        return mCalligraphyFactory.onViewCreated(super.onCreateView(parent, name, attrs),\n                getContext(), attrs);\n    }\n\n    /**\n     * The LayoutInflater onCreateView is the fourth port of call for LayoutInflation.\n     * BUT only for none CustomViews.\n     * Basically if this method doesn't inflate the View nothing probably will.\n     */\n    @Override\n    protected View onCreateView(String name, AttributeSet attrs) throws ClassNotFoundException {\n        // This mimics the {@code PhoneLayoutInflater} in the way it tries to inflate the base\n        // classes, if this fails its pretty certain the app will fail at this point.\n        View view = null;\n        for (String prefix : sClassPrefixList) {\n            try {\n                view = createView(name, prefix, attrs);\n            } catch (ClassNotFoundException ignored) {\n            }\n        }\n        // In this case we want to let the base class take a crack\n        // at it.\n        if (view == null) view = super.onCreateView(name, attrs);\n\n        return mCalligraphyFactory.onViewCreated(view, view.getContext(), attrs);\n    }\n\n    /**\n     * Nasty method to inflate custom layouts that haven't been handled else where. If this fails it\n     * will fall back through to the PhoneLayoutInflater method of inflating custom views where\n     * Calligraphy will NOT have a hook into.\n     *\n     * @param parent      parent view\n     * @param view        view if it has been inflated by this point, if this is not null this method\n     *                    just returns this value.\n     * @param name        name of the thing to inflate.\n     * @param viewContext Context to inflate by if parent is null\n     * @param attrs       Attr for this view which we can steal fontPath from too.\n     * @return view or the View we inflate in here.\n     */\n    private View createCustomViewInternal(View parent, View view, String name, Context viewContext, AttributeSet attrs) {\n        // I by no means advise anyone to do this normally, but Google have locked down access to\n        // the createView() method, so we never get a callback with attributes at the end of the\n        // createViewFromTag chain (which would solve all this unnecessary rubbish).\n        // We at the very least try to optimise this as much as possible.\n        // We only call for customViews (As they are the ones that never go through onCreateView(...)).\n        // We also maintain the Field reference and make it accessible which will make a pretty\n        // significant difference to performance on Android 4.0+.\n\n        // If CustomViewCreation is off skip this.\n        if (!CalligraphyConfig.get().isCustomViewCreation()) return view;\n        if (view == null && name.indexOf('.') > -1) {\n            if (mConstructorArgs == null)\n                mConstructorArgs = ReflectionUtils.getField(LayoutInflater.class, \"mConstructorArgs\");\n\n            final Object[] mConstructorArgsArr = (Object[]) ReflectionUtils.getValue(mConstructorArgs, this);\n            final Object lastContext = mConstructorArgsArr[0];\n            // The LayoutInflater actually finds out the correct context to use. We just need to set\n            // it on the mConstructor for the internal method.\n            // Set the constructor ars up for the createView, not sure why we can't pass these in.\n            mConstructorArgsArr[0] = viewContext;\n            ReflectionUtils.setValue(mConstructorArgs, this, mConstructorArgsArr);\n            try {\n                view = createView(name, null, attrs);\n            } catch (ClassNotFoundException ignored) {\n            } finally {\n                mConstructorArgsArr[0] = lastContext;\n                ReflectionUtils.setValue(mConstructorArgs, this, mConstructorArgsArr);\n            }\n        }\n        return view;\n    }\n\n    // ===\n    // Wrapper Factories for Pre/Post HC\n    // ===\n\n    /**\n     * Factory 1 is the first port of call for LayoutInflation\n     */\n    private static class WrapperFactory implements Factory {\n\n        private final Factory mFactory;\n        private final CalligraphyLayoutInflater mInflater;\n        private final CalligraphyFactory mCalligraphyFactory;\n\n        public WrapperFactory(Factory factory, CalligraphyLayoutInflater inflater, CalligraphyFactory calligraphyFactory) {\n            mFactory = factory;\n            mInflater = inflater;\n            mCalligraphyFactory = calligraphyFactory;\n        }\n\n        @Override\n        public View onCreateView(String name, Context context, AttributeSet attrs) {\n            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {\n                return mCalligraphyFactory.onViewCreated(\n                        mInflater.createCustomViewInternal(\n                                null, mFactory.onCreateView(name, context, attrs), name, context, attrs\n                        ),\n                        context, attrs\n                );\n            }\n            return mCalligraphyFactory.onViewCreated(\n                    mFactory.onCreateView(name, context, attrs),\n                    context, attrs\n            );\n        }\n    }\n\n    /**\n     * Factory 2 is the second port of call for LayoutInflation\n     */\n    @TargetApi(Build.VERSION_CODES.HONEYCOMB)\n    private static class WrapperFactory2 implements Factory2 {\n        protected final Factory2 mFactory2;\n        protected final CalligraphyFactory mCalligraphyFactory;\n\n        public WrapperFactory2(Factory2 factory2, CalligraphyFactory calligraphyFactory) {\n            mFactory2 = factory2;\n            mCalligraphyFactory = calligraphyFactory;\n        }\n\n        @Override\n        public View onCreateView(String name, Context context, AttributeSet attrs) {\n            return mCalligraphyFactory.onViewCreated(\n                    mFactory2.onCreateView(name, context, attrs),\n                    context, attrs);\n        }\n\n        @Override\n        public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {\n            return mCalligraphyFactory.onViewCreated(\n                    mFactory2.onCreateView(parent, name, context, attrs),\n                    context, attrs);\n        }\n    }\n\n    /**\n     * Private factory is step three for Activity Inflation, this is what is attached to the\n     * Activity on HC+ devices.\n     */\n    @TargetApi(Build.VERSION_CODES.HONEYCOMB)\n    private static class PrivateWrapperFactory2 extends WrapperFactory2 {\n\n        private final CalligraphyLayoutInflater mInflater;\n\n        public PrivateWrapperFactory2(Factory2 factory2, CalligraphyLayoutInflater inflater, CalligraphyFactory calligraphyFactory) {\n            super(factory2, calligraphyFactory);\n            mInflater = inflater;\n        }\n\n        @Override\n        public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {\n            return mCalligraphyFactory.onViewCreated(\n                    mInflater.createCustomViewInternal(parent,\n                            mFactory2.onCreateView(parent, name, context, attrs),\n                            name, context, attrs\n                    ),\n                    context, attrs\n            );\n        }\n    }\n\n}\n"
  },
  {
    "path": "calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/CalligraphyTypefaceSpan.java",
    "content": "package uk.co.chrisjenx.calligraphy;\n\nimport android.graphics.Paint;\nimport android.graphics.Typeface;\nimport android.text.TextPaint;\nimport android.text.style.MetricAffectingSpan;\n\npublic class CalligraphyTypefaceSpan extends MetricAffectingSpan {\n    private final Typeface typeface;\n\n    public CalligraphyTypefaceSpan(final Typeface typeface) {\n        if (typeface == null) {\n            throw new IllegalArgumentException(\"typeface is null\");\n        }\n        \n        this.typeface = typeface;\n    }\n\n    @Override\n    public void updateDrawState(final TextPaint drawState) {\n        apply(drawState);\n    }\n\n    @Override\n    public void updateMeasureState(final TextPaint paint) {\n        apply(paint);\n    }\n\n    private void apply(final Paint paint) {\n        final Typeface oldTypeface = paint.getTypeface();\n        final int oldStyle = oldTypeface != null ? oldTypeface.getStyle() : 0;\n        final int fakeStyle = oldStyle & ~typeface.getStyle();\n\n        if ((fakeStyle & Typeface.BOLD) != 0) {\n            paint.setFakeBoldText(true);\n        }\n\n        if ((fakeStyle & Typeface.ITALIC) != 0) {\n            paint.setTextSkewX(-0.25f);\n        }\n\n        paint.setTypeface(typeface);\n    }\n}\n"
  },
  {
    "path": "calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/CalligraphyUtils.java",
    "content": "package uk.co.chrisjenx.calligraphy;\n\nimport android.content.Context;\nimport android.content.res.AssetManager;\nimport android.content.res.Resources;\nimport android.content.res.TypedArray;\nimport android.graphics.Paint;\nimport android.graphics.Typeface;\nimport android.text.Editable;\nimport android.text.Spannable;\nimport android.text.SpannableString;\nimport android.text.Spanned;\nimport android.text.TextUtils;\nimport android.text.TextWatcher;\nimport android.util.AttributeSet;\nimport android.util.TypedValue;\nimport android.widget.TextView;\n\n/**\n * Created by chris on 20/12/2013\n * Project: Calligraphy\n */\npublic final class CalligraphyUtils {\n\n    public static final int[] ANDROID_ATTR_TEXT_APPEARANCE = new int[]{android.R.attr.textAppearance};\n\n    /**\n     * Applies a custom typeface span to the text.\n     *\n     * @param s        text to apply it too.\n     * @param typeface typeface to apply.\n     * @return Either the passed in Object or new Spannable with the typeface span applied.\n     */\n    public static CharSequence applyTypefaceSpan(CharSequence s, Typeface typeface) {\n        if (s != null && s.length() > 0) {\n            if (!(s instanceof Spannable)) {\n                s = new SpannableString(s);\n            }\n            ((Spannable) s).setSpan(TypefaceUtils.getSpan(typeface), 0, s.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);\n        }\n        return s;\n    }\n\n    /**\n     * Applies a Typeface to a TextView.\n     * Defaults to false for deferring, if you are having issues with the textview keeping\n     * the custom Typeface, use\n     * {@link #applyFontToTextView(android.widget.TextView, android.graphics.Typeface, boolean)}\n     *\n     * @param textView Not null, TextView or child of.\n     * @param typeface Not null, Typeface to apply to the TextView.\n     * @return true if applied otherwise false.\n     * @see #applyFontToTextView(android.widget.TextView, android.graphics.Typeface, boolean)\n     */\n    public static boolean applyFontToTextView(final TextView textView, final Typeface typeface) {\n        return applyFontToTextView(textView, typeface, false);\n    }\n\n    /**\n     * Applies a Typeface to a TextView, if deferred,its recommend you don't call this multiple\n     * times, as this adds a TextWatcher.\n     *\n     * Deferring should really only be used on tricky views which get Typeface set by the system at\n     * weird times.\n     *\n     * @param textView Not null, TextView or child of.\n     * @param typeface Not null, Typeface to apply to the TextView.\n     * @param deferred If true we use Typefaces and TextChange listener to make sure font is always\n     *                 applied, but this sometimes conflicts with other\n     *                 {@link android.text.Spannable}'s.\n     * @return true if applied otherwise false.\n     * @see #applyFontToTextView(android.widget.TextView, android.graphics.Typeface)\n     */\n    public static boolean applyFontToTextView(final TextView textView, final Typeface typeface, boolean deferred) {\n        if (textView == null || typeface == null) return false;\n        textView.setPaintFlags(textView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);\n        textView.setTypeface(typeface);\n        if (deferred) {\n            textView.setText(applyTypefaceSpan(textView.getText(), typeface), TextView.BufferType.SPANNABLE);\n            textView.addTextChangedListener(new TextWatcher() {\n                @Override\n                public void beforeTextChanged(CharSequence s, int start, int count, int after) {\n                }\n\n                @Override\n                public void onTextChanged(CharSequence s, int start, int before, int count) {\n                }\n\n                @Override\n                public void afterTextChanged(Editable s) {\n                    applyTypefaceSpan(s, typeface);\n                }\n            });\n        }\n        return true;\n    }\n\n    /**\n     * Useful for manually fonts to a TextView. Will not default back to font\n     * set in {@link uk.co.chrisjenx.calligraphy.CalligraphyConfig}\n     *\n     * @param context  Context\n     * @param textView Not null, TextView to apply to.\n     * @param filePath if null/empty will do nothing.\n     * @return true if fonts been applied\n     */\n    public static boolean applyFontToTextView(final Context context, final TextView textView, final String filePath) {\n        return applyFontToTextView(context, textView, filePath, false);\n    }\n\n    static boolean applyFontToTextView(final Context context, final TextView textView, final String filePath, boolean deferred) {\n        if (textView == null || context == null) return false;\n        final AssetManager assetManager = context.getAssets();\n        final Typeface typeface = TypefaceUtils.load(assetManager, filePath);\n        return applyFontToTextView(textView, typeface, deferred);\n    }\n\n    static void applyFontToTextView(final Context context, final TextView textView, final CalligraphyConfig config) {\n        applyFontToTextView(context, textView, config, false);\n    }\n\n    static void applyFontToTextView(final Context context, final TextView textView, final CalligraphyConfig config, boolean deferred) {\n        if (context == null || textView == null || config == null) return;\n        if (!config.isFontSet()) return;\n        applyFontToTextView(context, textView, config.getFontPath(), deferred);\n    }\n\n    /**\n     * Applies font to TextView. Will fall back to the default one if not set.\n     *\n     * @param context      context\n     * @param textView     textView to apply to.\n     * @param config       Default Config\n     * @param textViewFont nullable, will use Default Config if null or fails to find the\n     *                     defined font.\n     */\n    public static void applyFontToTextView(final Context context, final TextView textView, final CalligraphyConfig config, final String textViewFont) {\n        applyFontToTextView(context, textView, config, textViewFont, false);\n    }\n\n    static void applyFontToTextView(final Context context, final TextView textView, final CalligraphyConfig config, final String textViewFont, boolean deferred) {\n        if (context == null || textView == null || config == null) return;\n        if (!TextUtils.isEmpty(textViewFont) && applyFontToTextView(context, textView, textViewFont, deferred)) {\n            return;\n        }\n        applyFontToTextView(context, textView, config, deferred);\n    }\n\n    /**\n     * Tries to pull the Custom Attribute directly from the TextView.\n     *\n     * @param context     Activity Context\n     * @param attrs       View Attributes\n     * @param attributeId if -1 returns null.\n     * @return null if attribute is not defined or added to View\n     */\n    static String pullFontPathFromView(Context context, AttributeSet attrs, int[] attributeId) {\n        if (attributeId == null || attrs == null)\n            return null;\n\n        final String attributeName;\n        try {\n            attributeName = context.getResources().getResourceEntryName(attributeId[0]);\n        } catch (Resources.NotFoundException e) {\n            // invalid attribute ID\n            return null;\n        }\n\n        final int stringResourceId = attrs.getAttributeResourceValue(null, attributeName, -1);\n        return stringResourceId > 0\n                ? context.getString(stringResourceId)\n                : attrs.getAttributeValue(null, attributeName);\n    }\n\n    /**\n     * Tries to pull the Font Path from the View Style as this is the next decendent after being\n     * defined in the View's xml.\n     *\n     * @param context     Activity Activity Context\n     * @param attrs       View Attributes\n     * @param attributeId if -1 returns null.\n     * @return null if attribute is not defined or found in the Style\n     */\n    static String pullFontPathFromStyle(Context context, AttributeSet attrs, int[] attributeId) {\n        if (attributeId == null || attrs == null)\n            return null;\n        final TypedArray typedArray = context.obtainStyledAttributes(attrs, attributeId);\n        if (typedArray != null) {\n            try {\n                // First defined attribute\n                String fontFromAttribute = typedArray.getString(0);\n                if (!TextUtils.isEmpty(fontFromAttribute)) {\n                    return fontFromAttribute;\n                }\n            } catch (Exception ignore) {\n                // Failed for some reason.\n            } finally {\n                typedArray.recycle();\n            }\n        }\n        return null;\n    }\n\n    /**\n     * Tries to pull the Font Path from the Text Appearance.\n     *\n     * @param context     Activity Context\n     * @param attrs       View Attributes\n     * @param attributeId if -1 returns null.\n     * @return returns null if attribute is not defined or if no TextAppearance is found.\n     */\n    static String pullFontPathFromTextAppearance(final Context context, AttributeSet attrs, int[] attributeId) {\n        if (attributeId == null || attrs == null) {\n            return null;\n        }\n\n        int textAppearanceId = -1;\n        final TypedArray typedArrayAttr = context.obtainStyledAttributes(attrs, ANDROID_ATTR_TEXT_APPEARANCE);\n        if (typedArrayAttr != null) {\n            try {\n                textAppearanceId = typedArrayAttr.getResourceId(0, -1);\n            } catch (Exception ignored) {\n                // Failed for some reason\n                return null;\n            } finally {\n                typedArrayAttr.recycle();\n            }\n        }\n\n        final TypedArray textAppearanceAttrs = context.obtainStyledAttributes(textAppearanceId, attributeId);\n        if (textAppearanceAttrs != null) {\n            try {\n                return textAppearanceAttrs.getString(0);\n            } catch (Exception ignore) {\n                // Failed for some reason.\n                return null;\n            } finally {\n                textAppearanceAttrs.recycle();\n            }\n        }\n        return null;\n    }\n\n    /**\n     * Last but not least, try to pull the Font Path from the Theme, which is defined.\n     *\n     * @param context     Activity Context\n     * @param styleAttrId Theme style id\n     * @param attributeId if -1 returns null.\n     * @return null if no theme or attribute defined.\n     */\n    static String pullFontPathFromTheme(Context context, int styleAttrId, int[] attributeId) {\n        if (styleAttrId == -1 || attributeId == null)\n            return null;\n\n        final Resources.Theme theme = context.getTheme();\n        final TypedValue value = new TypedValue();\n\n        theme.resolveAttribute(styleAttrId, value, true);\n        final TypedArray typedArray = theme.obtainStyledAttributes(value.resourceId, attributeId);\n        try {\n            String font = typedArray.getString(0);\n            return font;\n        } catch (Exception ignore) {\n            // Failed for some reason.\n            return null;\n        } finally {\n            typedArray.recycle();\n        }\n    }\n\n    /**\n     * Last but not least, try to pull the Font Path from the Theme, which is defined.\n     *\n     * @param context        Activity Context\n     * @param styleAttrId    Theme style id\n     * @param subStyleAttrId the sub style from the theme to look up after the first style\n     * @param attributeId    if -1 returns null.\n     * @return null if no theme or attribute defined.\n     */\n    static String pullFontPathFromTheme(Context context, int styleAttrId, int subStyleAttrId, int[] attributeId) {\n        if (styleAttrId == -1 || attributeId == null)\n            return null;\n\n        final Resources.Theme theme = context.getTheme();\n        final TypedValue value = new TypedValue();\n\n        theme.resolveAttribute(styleAttrId, value, true);\n        int subStyleResId = -1;\n        final TypedArray parentTypedArray = theme.obtainStyledAttributes(value.resourceId, new int[]{subStyleAttrId});\n        try {\n            subStyleResId = parentTypedArray.getResourceId(0, -1);\n        } catch (Exception ignore) {\n            // Failed for some reason.\n            return null;\n        } finally {\n            parentTypedArray.recycle();\n        }\n\n        if (subStyleResId == -1) return null;\n        final TypedArray subTypedArray = context.obtainStyledAttributes(subStyleResId, attributeId);\n        if (subTypedArray != null) {\n            try {\n                return subTypedArray.getString(0);\n            } catch (Exception ignore) {\n                // Failed for some reason.\n                return null;\n            } finally {\n                subTypedArray.recycle();\n            }\n        }\n        return null;\n    }\n\n    private static Boolean sToolbarCheck = null;\n    private static Boolean sAppCompatViewCheck = null;\n\n    /**\n     * See if the user has added appcompat-v7, this is done at runtime, so we only check once.\n     *\n     * @return true if the v7.Toolbar is on the classpath\n     */\n    static boolean canCheckForV7Toolbar() {\n        if (sToolbarCheck == null) {\n            try {\n                Class.forName(\"android.support.v7.widget.Toolbar\");\n                sToolbarCheck = Boolean.TRUE;\n            } catch (ClassNotFoundException e) {\n                sToolbarCheck = Boolean.FALSE;\n            }\n        }\n        return sToolbarCheck;\n    }\n\n    /**\n     * See if the user has added appcompat-v7 with AppCompatViews\n     *\n     * @return true if AppcompatTextView is on the classpath\n     */\n    static boolean canAddV7AppCompatViews() {\n        if (sAppCompatViewCheck == null) {\n            try {\n                Class.forName(\"android.support.v7.widget.AppCompatTextView\");\n                sAppCompatViewCheck = Boolean.TRUE;\n            } catch (ClassNotFoundException e) {\n                sAppCompatViewCheck = Boolean.FALSE;\n            }\n        }\n        return sAppCompatViewCheck;\n    }\n\n    private CalligraphyUtils() {\n    }\n\n}\n"
  },
  {
    "path": "calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/HasTypeface.java",
    "content": "package uk.co.chrisjenx.calligraphy;\n\nimport android.graphics.Typeface;\n\n/**\n * There are two ways to set typeface for custom views:\n * <ul>\n *     <li>Implementing this interface. You should only implements {@link #setTypeface(Typeface)} method.</li>\n *     <li>Or via reflection. If custom view already has setTypeface method you can\n *     register it during Calligraphy configuration\n *     {@link uk.co.chrisjenx.calligraphy.CalligraphyConfig.Builder#addCustomViewWithSetTypeface(Class)}</li>\n * </ul>\n * First way is faster but encourage more effort from the developer to implements interface. Second one\n * requires less effort but works slowly cause reflection calls.\n *\n * @author Dmitriy Tarasov\n */\npublic interface HasTypeface {\n\n    void setTypeface(Typeface typeface);\n\n}\n"
  },
  {
    "path": "calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/ReflectionUtils.java",
    "content": "package uk.co.chrisjenx.calligraphy;\n\nimport android.util.Log;\n\nimport java.lang.reflect.Field;\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\n\n/**\n * Created by chris on 17/12/14.\n * For Calligraphy.\n */\nclass ReflectionUtils {\n\n    private static final String TAG = ReflectionUtils.class.getSimpleName();\n\n    static Field getField(Class clazz, String fieldName) {\n        try {\n            final Field f = clazz.getDeclaredField(fieldName);\n            f.setAccessible(true);\n            return f;\n        } catch (NoSuchFieldException ignored) {\n        }\n        return null;\n    }\n\n    static Object getValue(Field field, Object obj) {\n        try {\n            return field.get(obj);\n        } catch (IllegalAccessException ignored) {\n        }\n        return null;\n    }\n\n    static void setValue(Field field, Object obj, Object value) {\n        try {\n            field.set(obj, value);\n        } catch (IllegalAccessException ignored) {\n        }\n    }\n\n    static Method getMethod(Class clazz, String methodName) {\n        final Method[] methods = clazz.getMethods();\n        for (Method method : methods) {\n            if (method.getName().equals(methodName)) {\n                method.setAccessible(true);\n                return method;\n            }\n        }\n        return null;\n    }\n\n    static void invokeMethod(Object object, Method method, Object... args) {\n        try {\n            if (method == null) return;\n            method.invoke(object, args);\n        } catch (IllegalAccessException | InvocationTargetException e) {\n            Log.d(TAG, \"Can't invoke method using reflection\", e);\n        }\n    }\n}\n"
  },
  {
    "path": "calligraphy/src/main/java/uk/co/chrisjenx/calligraphy/TypefaceUtils.java",
    "content": "package uk.co.chrisjenx.calligraphy;\n\nimport android.content.res.AssetManager;\nimport android.graphics.Typeface;\nimport android.util.Log;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\n/**\n * A helper loading {@link android.graphics.Typeface} avoiding the leak of the font when loaded\n * by multiple calls to {@link android.graphics.Typeface#createFromAsset(android.content.res.AssetManager, String)}\n * on pre-ICS versions.\n * <p>\n * More details can be found here https://code.google.com/p/android/issues/detail?id=9904\n * <p>\n * Created by Chris Jenkins on 04/09/13.\n */\npublic final class TypefaceUtils {\n\n    private static final Map<String, Typeface> sCachedFonts = new HashMap<String, Typeface>();\n    private static final Map<Typeface, CalligraphyTypefaceSpan> sCachedSpans = new HashMap<Typeface, CalligraphyTypefaceSpan>();\n\n    /**\n     * A helper loading a custom font.\n     *\n     * @param assetManager App's asset manager.\n     * @param filePath     The path of the file.\n     * @return Return {@link android.graphics.Typeface} or null if the path is invalid.\n     */\n    public static Typeface load(final AssetManager assetManager, final String filePath) {\n        synchronized (sCachedFonts) {\n            try {\n                if (!sCachedFonts.containsKey(filePath)) {\n                    final Typeface typeface = Typeface.createFromAsset(assetManager, filePath);\n                    sCachedFonts.put(filePath, typeface);\n                    return typeface;\n                }\n            } catch (Exception e) {\n                Log.w(\"Calligraphy\", \"Can't create asset from \" + filePath + \". Make sure you have passed in the correct path and file name.\", e);\n                sCachedFonts.put(filePath, null);\n                return null;\n            }\n            return sCachedFonts.get(filePath);\n        }\n    }\n\n    /**\n     * A helper loading custom spans so we don't have to keep creating hundreds of spans.\n     *\n     * @param typeface not null typeface\n     * @return will return null of typeface passed in is null.\n     */\n    public static CalligraphyTypefaceSpan getSpan(final Typeface typeface) {\n        if (typeface == null) return null;\n        synchronized (sCachedSpans) {\n            if (!sCachedSpans.containsKey(typeface)) {\n                final CalligraphyTypefaceSpan span = new CalligraphyTypefaceSpan(typeface);\n                sCachedSpans.put(typeface, span);\n                return span;\n            }\n            return sCachedSpans.get(typeface);\n        }\n    }\n\n    /**\n     * Is the passed in typeface one of ours?\n     *\n     * @param typeface nullable, the typeface to check if ours.\n     * @return true if we have loaded it false otherwise.\n     */\n    public static boolean isLoaded(Typeface typeface) {\n        return typeface != null && sCachedFonts.containsValue(typeface);\n    }\n\n    private TypefaceUtils() {\n    }\n}\n"
  },
  {
    "path": "calligraphy/src/main/res/values/attrs.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <attr name=\"fontPath\" format=\"string\"/>\n</resources>"
  },
  {
    "path": "calligraphy/src/main/res/values/ids.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <item name=\"calligraphy_tag_id\" type=\"id\"/>\n</resources>"
  },
  {
    "path": "calligraphy/src/main/res/values/public.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <public name=\"fontPath\" type=\"attr\"/>\n</resources>\n"
  },
  {
    "path": "gradle/deploy.gradle",
    "content": "/*\n * Copyright 2013 Chris Banes\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\napply plugin: 'maven'\napply plugin: 'signing'\n\ndef isReleaseBuild() {\n    project.ext.isReleaseVersion\n}\n\ndef getReleaseRepositoryUrl() {\n    return \"https://oss.sonatype.org/service/local/staging/deploy/maven2/\"\n}\n\ndef getSnapshotRepositoryUrl() {\n    return \"https://oss.sonatype.org/content/repositories/snapshots/\"\n}\n\ndef getRepositoryUsername() {\n    return hasProperty('sonatypeUsername') ? sonatypeUsername : \"\"\n}\n\ndef getRepositoryPassword() {\n    return hasProperty('sonatypePassword') ? sonatypePassword : \"\"\n}\n\n// Debug Build or Release?\nif (isReleaseBuild()) {\n    println \"RELEASE BUILD $version\"\n} else {\n    version += \"-SNAPSHOT\"\n    println \"DEBUG BUILD $version\"\n}\n\nafterEvaluate { project ->\n    uploadArchives {\n        repositories {\n            mavenDeployer {\n                beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }\n\n                pom.groupId = GROUP\n                pom.version = version\n                pom.artifactId = POM_ARTIFACT_ID\n\n                repository(url: getReleaseRepositoryUrl()) {\n                    authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())\n                }\n                snapshotRepository(url: getSnapshotRepositoryUrl()) {\n                    authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())\n                }\n\n                pom.project {\n                    name POM_NAME\n                    packaging POM_PACKAGING\n                    description POM_DESCRIPTION\n                    url POM_URL\n\n                    scm {\n                        url POM_SCM_URL\n                        connection POM_SCM_CONNECTION\n                        developerConnection POM_SCM_DEV_CONNECTION\n                    }\n\n                    licenses {\n                        license {\n                            name POM_LICENCE_NAME\n                            url POM_LICENCE_URL\n                            distribution POM_LICENCE_DIST\n                        }\n                    }\n\n                    developers {\n                        developer {\n                            id POM_DEVELOPER_ID\n                            name POM_DEVELOPER_NAME\n                            email POM_DEVELOPER_EMAIL\n                        }\n                    }\n                }\n            }\n        }\n    }\n\n    signing {\n        required { isReleaseBuild() && gradle.taskGraph.hasTask(\"uploadArchives\") }\n        sign configurations.archives\n    }\n\n    task androidJavadocs(type: Javadoc) {\n        source = android.sourceSets.main.java.source\n        classpath += project.files(android.getBootClasspath().join(File.pathSeparator))\n    }\n\n    task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {\n        classifier = 'javadoc'\n        from androidJavadocs.destinationDir\n    }\n\n    task androidSourcesJar(type: Jar) {\n        classifier = 'sources'\n//        from android.sourceSets.main.java\n        from android.sourceSets.main.java.source\n    }\n\n    artifacts {\n        archives androidSourcesJar\n        archives androidJavadocsJar\n    }\n}"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Mon Apr 16 11:48:42 CEST 2018\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-4.4-all.zip\n"
  },
  {
    "path": "gradle.properties",
    "content": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Settings specified in this file will override any Gradle settings\n# configured through the IDE.\n\n# For more details on how to configure your build environment visit\n# http://www.gradle.org/docs/current/userguide/build_environment.html\n\n# Specifies the JVM arguments used for the daemon process.\n# The setting is particularly useful for tweaking memory settings.\n# Default value: -Xmx10248m -XX:MaxPermSize=256m\n# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8\n\n# When configured, Gradle will run in incubating parallel mode.\n# This option should only be used with decoupled projects. More details, visit\n# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects\n# org.gradle.parallel=true\n\nGROUP=uk.co.chrisjenx\nVERSION_NAME=2.3.0\nVERSION_CODE=24\n\nPOM_PACKAGING=aar\nPOM_URL=https://github.com/chrisjenx/Calligraphy\nPOM_DESCRIPTION=Custom Font injection through styles and attributes.\nPOM_SCM_URL=https://github.com/chrisjenx/Calligraphy\nPOM_SCM_CONNECTION=scm:git@github.com:chrisjenx/Calligraphy.git\nPOM_SCM_DEV_CONNECTION=scm:git@github.com:chrisjenx/Calligraphy.git\nPOM_LICENCE_NAME=The Apache Software License, Version 2.0\nPOM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt\nPOM_LICENCE_DIST=repo\nPOM_DEVELOPER_ID=chrisjenx\nPOM_DEVELOPER_NAME=Christopher Jenkins\nPOM_DEVELOPER_EMAIL=chris.mark.jenkins@gmail.com\n"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env sh\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn ( ) {\n    echo \"$*\"\n}\n\ndie ( ) {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\nnonstop=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\n  NONSTOP* )\n    nonstop=true\n    ;;\nesac\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" -a \"$nonstop\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Escape application args\nsave ( ) {\n    for i do printf %s\\\\n \"$i\" | sed \"s/'/'\\\\\\\\''/g;1s/^/'/;\\$s/\\$/' \\\\\\\\/\" ; done\n    echo \" \"\n}\nAPP_ARGS=$(save \"$@\")\n\n# Collect all arguments for the java command, following the shell quoting and substitution rules\neval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS \"\\\"-Dorg.gradle.appname=$APP_BASE_NAME\\\"\" -classpath \"\\\"$CLASSPATH\\\"\" org.gradle.wrapper.GradleWrapperMain \"$APP_ARGS\"\n\n# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong\nif [ \"$(uname)\" = \"Darwin\" ] && [ \"$HOME\" = \"$PWD\" ]; then\n  cd \"$(dirname \"$0\")\"\nfi\n\nexec \"$JAVACMD\" \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@rem  Gradle startup script for Windows\r\n@rem\r\n@rem ##########################################################################\r\n\r\n@rem Set local scope for the variables with windows NT shell\r\nif \"%OS%\"==\"Windows_NT\" setlocal\r\n\r\nset DIRNAME=%~dp0\r\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\r\nset APP_BASE_NAME=%~n0\r\nset APP_HOME=%DIRNAME%\r\n\r\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\r\nset DEFAULT_JVM_OPTS=\r\n\r\n@rem Find java.exe\r\nif defined JAVA_HOME goto findJavaFromJavaHome\r\n\r\nset JAVA_EXE=java.exe\r\n%JAVA_EXE% -version >NUL 2>&1\r\nif \"%ERRORLEVEL%\" == \"0\" goto init\r\n\r\necho.\r\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:findJavaFromJavaHome\r\nset JAVA_HOME=%JAVA_HOME:\"=%\r\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\r\n\r\nif exist \"%JAVA_EXE%\" goto init\r\n\r\necho.\r\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:init\r\n@rem Get command-line arguments, handling Windows variants\r\n\r\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\r\n\r\n:win9xME_args\r\n@rem Slurp the command line arguments.\r\nset CMD_LINE_ARGS=\r\nset _SKIP=2\r\n\r\n:win9xME_args_slurp\r\nif \"x%~1\" == \"x\" goto execute\r\n\r\nset CMD_LINE_ARGS=%*\r\n\r\n:execute\r\n@rem Setup the command line\r\n\r\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\r\n\r\n@rem Execute Gradle\r\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\r\n\r\n:end\r\n@rem End local scope for the variables with windows NT shell\r\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\r\n\r\n:fail\r\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\r\nrem the _cmd.exe /c_ return code!\r\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\r\nexit /b 1\r\n\r\n:mainEnd\r\nif \"%OS%\"==\"Windows_NT\" endlocal\r\n\r\n:omega\r\n"
  },
  {
    "path": "settings.gradle",
    "content": "include ':calligraphy', ':CalligraphySample'\n"
  }
]