[
  {
    "path": ".gitignore",
    "content": "# Built application files\n*.apk\n*.ap_\n\n# Files for the ART/Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Generated files\nbin/\ngen/\nout/\n\n# Gradle files\n.gradle/\nbuild/\n\n# Local configuration file (sdk path, etc)\nlocal.properties\n\n# Proguard folder generated by Eclipse\nproguard/\n\n# Log Files\n*.log\n\n# Android Studio Navigation editor temp files\n.navigation/\n\n# Android Studio captures folder\ncaptures/\n\n# IntelliJ\n*.iml\n.idea/workspace.xml\n.idea/tasks.xml\n.idea/gradle.xml\n.idea/assetWizardSettings.xml\n.idea/dictionaries\n.idea/libraries\n.idea/caches\n\n# Keystore files\n# Uncomment the following line if you do not want to check your keystore files in.\n#*.jks\n\n# External native build folder generated in Android Studio 2.2 and later\n.externalNativeBuild\n\n# Google Services (e.g. APIs or Firebase)\ngoogle-services.json\n\n# Freeline\nfreeline.py\nfreeline/\nfreeline_project_description.json\n\n# fastlane\nfastlane/report.xml\nfastlane/Preview.html\nfastlane/screenshots\nfastlane/test_output\nfastlane/readme.md\n\npreview_support/libs/*.jar\n.idea/"
  },
  {
    "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 [yyyy] [name of copyright owner]\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"
  },
  {
    "path": "README-zh.md",
    "content": "### 为什么需要Folivora\n对于android开发者来说，在layout文件中引用drawable来设置`View`的背景或者`ImageView`的`src`是很常见的事情，需要我们在drawable文件夹下写好xml文件就可以应用了，但是有许多drawable文件可能只被使用了一次，也有可能我们只是为了实现一个简单的圆角背景的功能。越来越多的drawable文件导致开发和维护成本的增加，有没有什么方法可以直接在layout文件中去创建drawable呢，Folivora为你提供了这样的功能。\n\n### Folivora能做什么\nFolivora可以为你的View设置一个背景或者ImageView的src,当前支持的drawable类型有\n\n* shape (GradientDrawable)\n* selector (StateListDrawable)\n* ripple (RippleDrawable)\n* layerlist (LayerListDrawable)\n* levellist (LevelListDrawable)\n* inset (InsetDrawable)\n* clip (ClipDrawable)\n* scale (ScaleDrawable)\n* animation (AnimationDrawable)\n* 自定义的Drawable **(新增)**\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview.gif\" width=\"50%\" height=\"50%\"></img>\n\n### 使用方法\n - **STEP1** :\n添加Gradle依赖，在项目的build.gradle中加入\n```groovy\n  dependencies {\n    implementation 'cn.cricin:folivora:0.1.0'\n  }\n```\n\n - **STEP2** :\n在layout.xml中加入自定义的属性, 告诉Folivora如何创建drawable，Folivora提供的内置drawable属性前缀如下\n\n* shape       -> shape\n* selectror   -> selector\n* layer-list  -> layer\n* level-list  -> level\n* clip        -> clip\n* scale       -> scale\n* inset       -> inset\n* ripple      -> ripple\n* animation   -> anim\n\n例如所有的shape属性设置的前缀都是shape, 如`shapeSolidColor`, `shapeCornerRadius`等, 在设置了`drawableType`\n之后，敲出指定的前缀，IDE会自动的给出所有该drawableType可用的属性\n\n> shape\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_shape.png\"></img>\n\n我们来试着在xml中书写Folivora为我们提供的属性来实现上图中第一个的圆角shape效果\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:text=\"shape1\"\n  android:gravity=\"center\"\n  android:textColor=\"@android:color/white\"\n  app:drawableType=\"shape\"\n  app:shapeCornerRadius=\"6dp\"\n  app:shapeSolidColor=\"@color/blue_light\"/>\n```\n\n我们在看一下其他几种drawable的用法：\n\n> layerlist\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_layerlist.png\"></img>\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:text=\"layerlist\"\n  android:gravity=\"center\"\n  android:textColor=\"@android:color/white\"\n  app:drawableType=\"layer_list\"\n  app:layerItem0Drawable=\"@color/blue_light\"\n  app:layerItem1Drawable=\"@color/blue_dark\"\n  app:layerItem1Insets=\"4dp\"\n  app:layerItem2Drawable=\"@color/blue_bright\"\n  app:layerItem2Insets=\"8dp\"/>\n```\n\n> levellist\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_levellist.png\"></img>\n\n```xml\n<!-- this level-list level is 95, levelItem1 matches -->\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:gravity=\"center\"\n  android:text=\"levellist\"\n  android:textColor=\"@android:color/white\"\n  app:drawableType=\"level_list\"\n  app:levelCurrentLevel=\"95\"\n  app:levelItem0Drawable=\"@color/green_dark\"\n  app:levelItem1Drawable=\"@color/blue_light\"\n  app:levelItem1MaxLevel=\"100\"\n  app:levelItem1MinLevel=\"90\"/>\n```\n\n> selector\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_selector.gif\"></img>\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:textColor=\"@android:color/white\"\n  android:gravity=\"center\"\n  android:text=\"selector\"\n  app:drawableType=\"selector\"\n  app:selectorStateNormal=\"@color/blue_light\"\n  app:selectorStatePressed=\"@color/blue_dark\"/>\n```\n\n在0.0.7版本中，Folivora加入了对创建复杂state的selector支持，使用app:selectorItemXStates指定需要的state flags，使用app:selectorItemXDrawable指定对应states的drawable(X可以是0，1，2，3，4)，现在可以用新的方式实现上面的drawable。\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:textColor=\"@android:color/white\"\n  android:gravity=\"center\"\n  android:text=\"selector\"\n  app:drawableType=\"selector\"\n  app:selectorItem0States=\"pressed\"\n  app:selectorItem0Drawable=\"@color/blue_dark\"\n  app:selectorStateNormal=\"@color/blue_light\"/>\n```\n\n注：两种selector写法最好不要混用，推荐使用新的selector写法，这种方式的selector顺序是严格按照item定义的顺序添加进selector的，唯一的限制是只能定义5个states和drawables，不过对于一般的selector应该够用了\n\n> ripple\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_ripple.gif\"></img>\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:textColor=\"@android:color/white\"\n  android:gravity=\"center\"\n  android:text=\"ripple\"\n  app:drawableType=\"ripple\"\n  app:rippleColor=\"@android:color/white\"\n  app:rippleContent=\"@color/blue_light\"/>\n```\n\n使用ripple的确是酷炫多了，但是ripple效果是5.0之后引入的，那5.0之前的设备怎么办呢，Folivora为你提供了`RippleFallback`接口，用来创建一个替换`RippleDrawable`的`Drawable`实例，让我们试着用一个selector来代替ripple:\n```java\nFolivora.setRippleFallback(new Folivora.RippleFallback()){\n  @Override\n  public Drawable onFallback(ColorStateList ripple, Drawable content, Drawable mask, Context ctx){\n    StateListDrawable sld = new StateListDrawable();\n    sld.addState(new int[]{android.R.attr.state_pressed}, new ColorDrawable(ripple.getDefaultColor()));\n    sld.addState(new int[0], content);\n    return sld;\n  }\n}\n```\n\n> clip\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_clip.png\"></img>\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:gravity=\"center\"\n  android:text=\"clip\"\n  android:textColor=\"@android:color/white\"\n  app:clipDrawable=\"@color/blue_light\"\n  app:clipLevel=\"6000\"\n  app:drawableType=\"clip\"/>\n```\n\n> inset\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_inset.png\"></img>\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:gravity=\"center\"\n  android:text=\"inset\"\n  android:textColor=\"@android:color/white\"\n  app:drawableType=\"inset\"\n  app:insetAll=\"4dp\"\n  app:insetDrawable=\"@color/blue_light\"/>\n```\n\n> scale\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_scale.png\"></img>\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:gravity=\"center\"\n  android:text=\"scale\"\n  android:textColor=\"@android:color/white\"\n  app:drawableType=\"scale\"\n  app:scaleDrawable=\"@color/blue_light\"\n  app:scaleGravity=\"center\"\n  app:scaleHeight=\"0.3\"\n  app:scaleWidth=\"0.3\"/>\n```\n\n> animation\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_animation.gif\"></img>\n\n```xml\n<TextView\n  android:id=\"@+id/animation\"\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:gravity=\"center\"\n  android:text=\"animation\"\n  android:textColor=\"@android:color/white\"\n  app:animAutoPlay=\"true\"\n  app:animDuration=\"300\"\n  app:animFrame0=\"@drawable/animation0\"\n  app:animFrame1=\"@drawable/animation1\"\n  app:animFrame2=\"@drawable/animation2\"\n  app:animFrame3=\"@drawable/animation3\"\n  app:animFrame4=\"@drawable/animation4\"\n  app:animFrame5=\"@drawable/animation5\"\n  app:animFrame6=\"@drawable/animation6\"\n  app:animFrame7=\"@drawable/animation7\"\n  app:animFrame8=\"@drawable/animation8\"\n  app:animFrame9=\"@drawable/animation9\"\n  app:drawableType=\"animation\"/>\n```\n\n注: 如果你在layout文件中用Folivora为系统控件添加drawable，如`View`和`TextView`等，许多 IDE (Android Studio, IntelliJ) 会把这些Folivora提供的属性标注为错误，但是实际上是正确的。可以在这个View或者根ViewGroup上加上`tools:ignore=\"MissingPrefix\"`来避免报错。为了使用 `ignore`属性，可以加上`xmlns:tools=\" http://schemas.android.com/tools\"`。关于这个问题，可以查看： https://code.google.com/p/android/issues/detail?id=65176.\n\n - **STEP3** :\n在Activity中启用Folivora, 有两种方法：\n1.\n```java\npublic class MainActivity extends Activity {\n  @Override\n  protected void attachBaseContext(Context newBase) {\n    super.attachBaseContext(Folivora.wrap(newBase));\n  }\n}\n```\n2.\n```java\npublic class MainActivity extends Activity {\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    Folivora.installViewFactory(this);\n    setContentView(R.layout.your_layout_xml_name);\n  }\n}\n\n```\n\n### 使用嵌套的shape\n\nFolivora现在支持在drawable中嵌套shape了，除了animation以外，所有的drawable的子drawable除了可以使用`@drawable/xxx`和颜色之外，新增了shape/shape1/shape2/shape3/shape4这5个值，参考定义shape的例子，替换相应的前缀即可, 我们来定义嵌套了shape的selector试一试\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:gravity=\"center\"\n  android:text=\"selector\"\n  android:textColor=\"@android:color/white\"\n  app:drawableType=\"selector\"\n  app:selectorStateNormal=\"shape\"\n  app:shapeSolidColor=\"@color/blue_light\"\n  app:shapeCornerRadius=\"10dp\"\n  app:selectorStatePressed=\"shape1\"\n  app:shape1SolidColor=\"@color/blue_dark\"\n  app:shape1CornerRadius=\"10dp\"/>\n```\n\n效果是这样的\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_shape_nested.gif\"></img>\n\n### 使用自定义Drawable\n\n从0.0.4版本开始，Folivora除了支持自带的drawable以外，还支持使用自定的drawable类型了，让你使用自定义drawable就和使用自定义view一样轻松。这里我们以自定义一个绘制纸风车的`WindmillDrawable`为例，来让Folivora为我们提供支持：\n\n1. 首先我们和自定义`View`一样，为`WindmillDrawable`提供自定义的属性：\n```xml\n<!-- 和自定义view相同，这里declare-styleable的name最好和自定义drawable的名字一样 -->\n<declare-styleable name=\"WindmillDrawable\">\n    <attr name=\"wdSize\" format=\"dimension\"/> <!-- 纸风车的默认大小 -->\n    <attr name=\"wdColor0\" format=\"color\"/> <!-- 纸风车第一个叶子的颜色 -->\n    <attr name=\"wdColor1\" format=\"color\"/> <!-- 纸风车第二个叶子的颜色 -->\n    <attr name=\"wdColor2\" format=\"color\"/> <!-- 纸风车第三个叶子的颜色 -->\n    <attr name=\"wdColor3\" format=\"color\"/> <!-- 纸风车第四个叶子的颜色 -->\n    <attr name=\"wdCenterDotRadius\" format=\"dimension\"/> <!-- 中心圆的半径 -->\n    <attr name=\"wdCenterDotColor\" format=\"color\"/> <!-- 中心圆的填充色 -->\n    <attr name=\"wdRotateDegrees\" format=\"integer\"/> <!-- 纸风车旋转角度 -->\n  </declare-styleable>\n```\n可以看到，自定义属性这部分和普通的`View`自定义属性是一样的。name和自定义drawable的类名相同就行了，Folivora就可以在layout文件中为这些drawable的自定义属性提供属性的自动提示了\n\n2. 创建自定义的`WindmillDrawable`，继承自`Drawable`, 提供一个`public WindmillDrawable(Context ctx, AttributeSet attrs)`的构造方法，在这个构造方法里就可以获取自定义的属性, 代码如下：\n```java\npublic WindmillDrawable(Context ctx, AttributeSet attrs) {\n  TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.WindmillDrawable);\n  int count = a.getIndexCount();\n  for (int i = 0; i < count; i++) {\n    int index = a.getIndex(i);\n    switch (index) {\n      case R.styleable.WindmillDrawable_wdSize:\n        mSize = a.getDimensionPixelSize(index, mSize);\n        break;\n      case R.styleable.WindmillDrawable_wdColor0:\n        mColors[0] = a.getColor(index, mColors[0]);\n        break;\n      case R.styleable.WindmillDrawable_wdColor1:\n        mColors[1] = a.getColor(index, mColors[1]);\n        break;\n      ...\n      default://no-op unexpected attr index\n        break;\n    }\n  }\n  a.recycle();\n}\n```\n这部分代码其实和自定义`View`的属性获取没有什么区别，主要就是给drawable添加一个构造方法，具体绘制代码就不贴了，如果想要查看具体细节，可以点击[这里](https://github.com/Cricin/Folivora/blob/master/sample/src/main/java/cn/cricin/folivora/sample/drawable/WindmillDrawable.java)查看源码\n\n3. 在layout文件中使用自定义drawable，Folivora提供了`drawableName`属性，使用该属性指定需要使用的drawable：\n```xml\n<View\n  andorid:layout_width=\"120dp\"\n  android:layout_height=\"120dp\"\n  app:drawableName=\"cn.cricin.folivora.sample.drawable.WindmillDrawable\"\n  app:wdColor0=\"@color/blue_light\"\n  app:wdColor1=\"@color/green_dark\"\n  app:wdColor2=\"@color/green_light\"\n  app:wdColor3=\"@color/purple\"\n  app:wdRotateDegrees=\"45\"/>\n```\n运行之后的效果：\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_custom_drawable.png\"></img>\n\n\n到这里，Folivora就会为该`View`设置我们指定的drawable了，有人可能就会问了，drawable名字这么长，写起来会不会太复杂了，不用担心，当你敲出drawableName的时候，Folivora会为你自动提示可用的drawable名字的，并且该drawable的自定义属性也会有自动提示。\n\n> 如果我的自定义drawable没有上面指定的构造方法，并且我没办法直接修改该drawable的源码来添加这个构造方法该怎么办呢？\n\nFolivora考虑到了这一点，有些drawable的源码我们没法修改，但是它总会有向外提供设置属性的方法吧？所以，我们提供了一个`DrawableFactory`接口，假设`WindmillDrawable`只有一个无参的构造方法，但是提供了设置各种属性的方法，我们需要让Folivora支持`WindmillDrawable`，可以这样做：\n```java\nFolivora.addDrawableFactory(new Folivora.DrawableFactory() {\n  @Override\n  public Drawable newDrawable(Context context, AttributeSet attrs) {\n    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.WindmillDrawable);\n    WindmillDrawable d = new WindmillDrawable();\n    d.setColor0(a.getColor(R.styleable.WindmillDrawable_wdColor0, Color.BLACK));\n    d.setRotateDegrees(a.getInt(R.styleable.WindmillDrawable_wdRotateDegrees, 0));\n    ...\n    a.recycle();\n    return d;\n  }\n\n  @Override\n  public Class<? extends Drawable> drawableClass() {\n    return WindmillDrawable.class;\n  }\n});\n```\n> 自定义Drawable请注意，如果你的drawable需要获取其他drawable，建议使用`Folivora.getDrawable(Context ctx, TypedArray a, AttributeSet attrs, int attrIndex)`方法获取，这样可以支持获取内嵌的`shape`，当然如果你不需要支持内嵌的`shape`，可以不用这样做。\n\n### 使用Drawable缓存\n\n在之前的版本中，Folivora会根据view tag中的属性创建drawable，每次都会创建一个新的drawable实例，很浪费资源，现在Folivora支持了drawable的缓存功能(LruCache，大小为128), 使用缓存非常简单，只需要添加`app:drawableId`属性，为drawable指定一个id(string类型，不是android的id类型)即可。Folivora在为view设置drawable的时候，如果drawable在缓存中，会直接从缓存中取。这就带来了一个便利，如果在一个layout文件中，一个drawable被多次使用，只需要在第一次使用的地方编写drawable定义就行了，其他的地方可以直接使用drawableId引用该drawable。\n\n```xml\n<LinearLayout\n  android:layout_width=\"wrap_content\"\n  android:layout_height=\"wrap_content\">\n\n    <View\n      android:layout_width=\"100dp\"\n      android:layout_height=\"40dp\"\n      app:drawableId=\"shape_rounded_6dp\"\n      app:drawableType=\"shape\"\n      app:shapeCornerRadius=\"6dp\"\n      app:shapeSolidColor=\"@color/blue_light\"/>\n\n    <View\n      android:layout_width=\"100dp\"\n      android:layout_height=\"40dp\"\n      app:drawableId=\"shape_rounded_6dp\"/>\n\n</LinearLayout>\n```\n\n建议为需要复用的drawable和经常使用的layout文件中的drawable设置`drawableId`, 以提升性能。\n\n### 下载示例APK\n[点击下载](https://raw.githubusercontent.com/Cricin/Folivora/master/sample.apk)\n\n### 编辑layout文件时的预览\n\n> 预览效果\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/studio_preview.gif\"></img>\n\n依赖了Folivora之后，默认是可以直接预览的，如果没有效果，尝试build一下你的项目。\n\n### Folivora支持的属性列表\n\n##### 通用属性\n\n属性 | 取值| 描述\n ---|--- | --- |\napp:setAs|background(default) &#124; src &#124; foreground| 设置view背景或者ImageView的src或者view前景\napp:drawableType|shape &#124; layer_list &#124; selector &#124; ripple &#124; clip &#124; scale &#124; animation &#124; level_list|drawable类型\napp:drawableName|string|自定义drawable的class全名\napp:drawableId|string|用于缓存的drawable唯一id\n\n##### shape属性\n\n属性 | 取值| 描述\n ---|--- | --- |\napp:shapeType|rectangle(default)&#124;oval&#124;line&#124;ring|形状\napp:shapeSolidSize|dimension|宽高\napp:shapeSolidWidth|dimension|宽\napp:shapeSolidHeight|dimension|高\napp:shapeSolidColor|color|填充色\napp:shapeSolidColor|color|边框填充色\napp:shapeStokeWidth|dimension|边框厚度\napp:shapeStokeDashWidth|dimension|边框线宽\napp:shapeStokeDashGap|dimension|边框线间距\napp:shapeCornerRadius|dimension|角半径\napp:shapeCornerRadiusTopLeft|dimension|左上角半径\napp:shapeCornerRadiusTopRight|dimension|右上角半径\napp:shapeCornerRadiusBottomLeft|dimension|坐下角半径\napp:shapeCornerRadiusBottomRight|dimension|右下角半径\napp:shapeGradientType|linear &#124; radial &#124; sweep|渐变类型\napp:shapeGradientAngle|tb &#124; tr_bl &#124; rl &#124; br_tl &#124; bt &#124; bl_tr &#124; lr &#124; tl_br|渐变角度\napp:shapeGradientStartColor|color|渐变起始颜色\napp:shapeGradientCenterColor|color|渐变中间颜色\napp:shapeGradientEndColor|color|渐变结束颜色\napp:shapeGradientRadius|dimension|渐变半径\napp:shapeGradientCenterX|float|渐变中点x轴位置\napp:shapeGradientCenterY|float|渐变中点y轴位置\n\n##### selector属性\n\n属性 | 取值| 描述\n ---|--- | --- |\napp:selectorStateFirst|reference &#124; color|selector状态：第一个\napp:selectorStateMiddle|reference &#124; color|selector状态：中间\napp:selectorStateLast|reference &#124; color|selector状态：最后一个\napp:selectorStateActive|reference &#124; color|selector状态：活动\napp:selectorStateActivated|reference &#124; color|selector状态：激活的\napp:selectorStateAccelerate|reference &#124; color|selector状态：加速的\napp:selectorStateChecked|reference &#124; color|selector状态：勾选的\napp:selectorStateCheckable|reference &#124; color|selector状态：可勾选的\napp:selectorStateEnabled|reference &#124; color|selector状态：启用的\napp:selectorStateFocused|reference &#124; color|selector状态：获得焦点\napp:selectorStatePressed|reference &#124; color|selector状态：点击\napp:selectorStateNormal|reference &#124; color|selector状态：正常状态\n\n##### layerlist属性\n\n属性 | 取值| 描述\n ---|--- | --- |\napp:layerItem0Drawable| reference &#124; color| 最底层的drawable\napp:layerItem0Insets|dimension|该drawable的margin\napp:layerItem0Left|dimension| 该drawable的左margin\napp:layerItem0Right|dimension|该drawable的右margin\napp:layerItem0Top|dimension|该drawable的上margin\napp:layerItem0Bottom|dimension|该drawable的下margin\n\n...\n\nlayerlist支持最多5个drawable，替换相应的数字即可\n\n##### ripple属性\n\n属性 | 取值| 描述\n ---|--- | --- |\napp:rippleColor|color|ripple点击时的涟漪色\napp:rippleMask|reference &#124; color|ripple涟漪色的遮罩\napp:rippleContent|reference &#124; color|ripple的内容背景\n\n如果设备不支持Ripple效果(<Api21)，可以给Folivora设置一个`RippleFallback`, 用来创建替代RippleDrawable的Drawable\n\n##### levellist属性\n\n属性 | 取值| 描述\n ---|--- | --- |\napp:levelCurrentLevel|integer|当前的level\napp:levelItem0Drawable|reference &#124; color|第一个item的drawable\napp:levelItem1MinLevel|integer|该drawable的最小level\napp:levelItem1MaxLevel|integer|该drawable的最大level\n\n...\n\nlevellist支持最多5个drawable，替换相应的数字即可\n\n##### clip属性\n\n属性 | 取值| 描述\n ---|--- | --- |\napp:clipDrawable|reference &#124; color|需要裁剪的drawable\napp:clipGravity|同View的layout_gravity|裁剪位置\napp:clipOrientation|vertical &#124; horizontal|裁剪的方向\napp:clipLevel|integer|当前level\n\n##### scale属性\n\n属性 | 取值| 描述\n ---|--- | --- |\napp:scaleDrawable|reference &#124; color|需要缩放的drawable\napp:scaleGravity|同View的layout_gravity|缩放位置\napp:scaleWidth|float[0,1] or -1()|宽度缩放比例\napp:scaleHeight|float[0,1] or -1()|高度缩放比例\napp:scaleLevel|integer[0,10000]|当前的level\n\n##### inset属性\n\n属性 | 取值| 描述\n ---|--- | --- |\napp:insetDrawable|reference &#124; color|需要插入边距的drawable\napp:insetAll|dimension|所有方向的边距\napp:insetLeft|dimension|左边距\napp:insetTop|dimension|上边距\napp:insetRight|dimension|右边距\napp:insetBottom|dimension|下边距\n\n##### animation属性\n\n属性 | 取值| 描述\n ---|--- | --- |\napp:animAutoPlay|boolean|是否自动开始动画\napp:animDuration|int(millisecond)|每一帧的持续时间\napp:animOneShot|boolean|是否只播放一次\napp:animFrame0|reference &#124; color|第0帧\napp:animDuration0|int(millisecond)|第0帧持续时间\n\nanimation支持最多10帧，替换相应的数字即可\n\n\n## License\n\nCopyright 2019 Cricin\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "English | [中文](https://github.com/Cricin/Folivora/blob/master/README-zh.md)\n\n### Why Folivora\nFor most android develpers, it is usual to set `View`s background or `ImageView`s `src` by reference a drawable, which required to define a drawable.xml under drawable folder, but some drawable files may be only referenced once, or only to used as a round corner backgrond. more and more drawables may lead to develop and maintain hardly, is there a way to create and use drawables in layout.xml? yeah, Folivora can do this work for you.\n\n### What does Folivora can do?\nFolivora sets a View's background, foreground or ImageView's src in your layout.xml files, currently supported drawables are:\n\n* shape (GradientDrawable)\n* selector (StateListDrawable)\n* ripple (RippleDrawable)\n* layerlist (LayerListDrawable)\n* levellist (LevelListDrawable)\n* inset (InsetDrawable)\n* clip (ClipDrawable)\n* scale (ScaleDrawable)\n* animation (AnimationDrawable)\n* custom drawable **(newly supported)**\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview.gif\" width=\"50%\" height=\"50%\"></img>\n\n### Usage\n - **STEP1** :\ngradle dependency, add below in your project's build.gradle\n```groovy\n  dependencies {\n    implementation 'cn.cricin:folivora:0.1.0'\n  }\n```\n\n - **STEP2** :\nwrite down the attribute provided by folivora, tell folivora how to create drawable, prefix of drawables folivora builtin supported are:\n\n* shape       -> shape\n* selectror   -> selector\n* layer-list  -> layer\n* level-list  -> level\n* clip        -> clip\n* scale       -> scale\n* inset       -> inset\n* ripple      -> ripple\n* animation   -> anim\n\nfor example, all attributes prefix of a GradientDrawable is shape, like `shapeSolidColor`, `shapeCornerRadius`, IDE will gives you all available attributes after you write down `drawableType` and typed the drawable prefix.\n\n> shape\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_shape.png\"></img>\n\nlet's try to write down some code to introduce how folivora works with the first view above\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:text=\"shape1\"\n  android:gravity=\"center\"\n  android:textColor=\"@android:color/white\"\n  app:drawableType=\"shape\"\n  app:shapeCornerRadius=\"6dp\"\n  app:shapeSolidColor=\"@color/blue_light\"/>\n```\n\nhere are some other supported drawable usages:\n\n> layerlist\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_layerlist.png\"></img>\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:text=\"layerlist\"\n  android:gravity=\"center\"\n  android:textColor=\"@android:color/white\"\n  app:drawableType=\"layer_list\"\n  app:layerItem0Drawable=\"@color/blue_light\"\n  app:layerItem1Drawable=\"@color/blue_dark\"\n  app:layerItem1Insets=\"4dp\"\n  app:layerItem2Drawable=\"@color/blue_bright\"\n  app:layerItem2Insets=\"8dp\"/>\n```\n\n> levellist\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_levellist.png\"></img>\n\n```xml\n<!-- this level-list level is 95, levelItem1 matches -->\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:gravity=\"center\"\n  android:text=\"levellist\"\n  android:textColor=\"@android:color/white\"\n  app:drawableType=\"level_list\"\n  app:levelCurrentLevel=\"95\"\n  app:levelItem0Drawable=\"@color/green_dark\"\n  app:levelItem1Drawable=\"@color/blue_light\"\n  app:levelItem1MaxLevel=\"100\"\n  app:levelItem1MinLevel=\"90\"/>\n```\n\n> selector\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_selector.gif\"></img>\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:textColor=\"@android:color/white\"\n  android:gravity=\"center\"\n  android:text=\"selector\"\n  app:drawableType=\"selector\"\n  app:selectorStateNormal=\"@color/blue_light\"\n  app:selectorStatePressed=\"@color/blue_dark\"/>\n```\n\nsince 0.0.7，Folivora added support about complicated state selector，use `app:selectorItemXStates` to set state flags，and use `app:selectorItemXDrawable` set corresponding drawable to the states(X can be 0，1，2，3，4)，now we can use the new way to describe drawable above。\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:textColor=\"@android:color/white\"\n  android:gravity=\"center\"\n  android:text=\"selector\"\n  app:drawableType=\"selector\"\n  app:selectorItem0States=\"pressed\"\n  app:selectorItem0Drawable=\"@color/blue_dark\"\n  app:selectorStateNormal=\"@color/blue_light\"/>\n```\n\nNote：it is recommended to not mixed two selector definitions，just use the new way is better，which is ordered when add in selector by item index, constraint is only support 5 items for now, which is enough for usual selectors.\n\n> ripple\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_ripple.gif\"></img>\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:textColor=\"@android:color/white\"\n  android:gravity=\"center\"\n  android:text=\"ripple\"\n  app:drawableType=\"ripple\"\n  app:rippleColor=\"@android:color/white\"\n  app:rippleContent=\"@color/blue_light\"/>\n```\n\nmuch cooler after used ripple drawable, but ripple effect is introduced in lollipop, if the device platform version is lower than lolipop, folivora provided a `RippleFallback` for you, you can provide a substitude drawable if ripple is unavailable, let's try a create a `selector` instead of `ripple`:\n```java\nFolivora.setRippleFallback(new RippleFallback()){\n  @Override\n  public Drawable onFallback(ColorStateList ripple, Drawable content, Drawable mask, Context ctx){\n    StateListDrawable sld = new StateListDrawable();\n    sld.addState(new int[]{android.R.attr.state_pressed}, new ColorDrawable(ripple.getDefaultColor()));\n    sld.addState(new int[0], content);\n    return sld;\n  }\n}\n```\n\n> clip\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_clip.png\"></img>\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:gravity=\"center\"\n  android:text=\"clip\"\n  android:textColor=\"@android:color/white\"\n  app:clipDrawable=\"@color/blue_light\"\n  app:clipLevel=\"6000\"\n  app:drawableType=\"clip\"/>\n```\n\n> inset\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_inset.png\"></img>\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:gravity=\"center\"\n  android:text=\"inset\"\n  android:textColor=\"@android:color/white\"\n  app:drawableType=\"inset\"\n  app:insetAll=\"4dp\"\n  app:insetDrawable=\"@color/blue_light\"/>\n```\n\n> scale\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_scale.png\"></img>\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:gravity=\"center\"\n  android:text=\"scale\"\n  android:textColor=\"@android:color/white\"\n  app:drawableType=\"scale\"\n  app:scaleDrawable=\"@color/blue_light\"\n  app:scaleGravity=\"center\"\n  app:scaleHeight=\"0.3\"\n  app:scaleWidth=\"0.3\"/>\n```\n\n> animation\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_animation.gif\"></img>\n\n```xml\n<TextView\n  android:id=\"@+id/animation\"\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:gravity=\"center\"\n  android:text=\"animation\"\n  android:textColor=\"@android:color/white\"\n  app:animAutoPlay=\"true\"\n  app:animDuration=\"300\"\n  app:animFrame0=\"@drawable/animation0\"\n  app:animFrame1=\"@drawable/animation1\"\n  app:animFrame2=\"@drawable/animation2\"\n  app:animFrame3=\"@drawable/animation3\"\n  app:animFrame4=\"@drawable/animation4\"\n  app:animFrame5=\"@drawable/animation5\"\n  app:animFrame6=\"@drawable/animation6\"\n  app:animFrame7=\"@drawable/animation7\"\n  app:animFrame8=\"@drawable/animation8\"\n  app:animFrame9=\"@drawable/animation9\"\n  app:drawableType=\"animation\"/>\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 - **STEP3** :\nenable folivora in your app, there are two ways:\n\n```java\npublic class MainActivity extends Activity {\n  @Override\n  protected void attachBaseContext(Context newBase) {\n    super.attachBaseContext(Folivora.wrap(newBase));\n  }\n}\n```\nor\n```java\npublic class MainActivity extends Activity {\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    Folivra.installViewFactory(this);\n    setContentView(R.layout.your_layout_xml_name);\n  }\n}\n\n```\n\n#### Use nested shape\n\nFolivora now support nest shape in drawable, except `animation`, all drawable's child drawable can use `@drawable/xxx`, a color, or one of shape/shape1/shape2/shape3/shape4, you can use this prefix combine with the shape attrs, let's define two round corner shape nested in selector:\n\n```xml\n<TextView\n  android:layout_width=\"100dp\"\n  android:layout_height=\"40dp\"\n  android:gravity=\"center\"\n  android:text=\"selector\"\n  android:textColor=\"@android:color/white\"\n  app:drawableType=\"selector\"\n  app:selectorStateNormal=\"shape\"\n  app:shapeSolidColor=\"@color/blue_light\"\n  app:shapeCornerRadius=\"10dp\"\n  app:selectorStatePressed=\"shape1\"\n  app:shape1SolidColor=\"@color/blue_dark\"\n  app:shape1CornerRadius=\"10dp\"/>\n```\n\neffect is:\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_shape_nested.gif\"></img>\n\n### Use custom drawable\n\nsince 0.0.4，Folivora support use custom drawable, makes it easyly to use custom drawables just like custom views，for example, let's write a `WindmillDrawable` which draws a paper windmill：\n\n1. first, write down some attrs we needed for `WindmillDrawable`, just like the way of custom view:\n```xml\n<declare-styleable name=\"WindmillDrawable\">\n    <attr name=\"wdSize\" format=\"dimension\"/> <!-- default size -->\n    <attr name=\"wdColor0\" format=\"color\"/> <!-- first leaf color -->\n    <attr name=\"wdColor1\" format=\"color\"/> <!-- second leaf color -->\n    <attr name=\"wdColor2\" format=\"color\"/> <!-- third leaf color -->\n    <attr name=\"wdColor3\" format=\"color\"/> <!-- forth leaf color -->\n    <attr name=\"wdCenterDotRadius\" format=\"dimension\"/> <!-- center dot radius -->\n    <attr name=\"wdCenterDotColor\" format=\"color\"/> <!-- center dot color -->\n    <attr name=\"wdRotateDegrees\" format=\"integer\"/> <!-- rotation degrees -->\n  </declare-styleable>\n```\nNote: declare-styleable name must equals with the drawable's simple class name, so folivora will support code completion about the custom attrs.\n\n2. Create a `WindmillDrawable`，extends `Drawable`, provide a `public WindmillDrawable(Context ctx, AttributeSet attrs)` constructor，you can retrieve custom attrs here, like this：\n```java\npublic WindmillDrawable(Context ctx, AttributeSet attrs) {\n  TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.WindmillDrawable);\n  int count = a.getIndexCount();\n  for (int i = 0; i < count; i++) {\n    int index = a.getIndex(i);\n    switch (index) {\n      case R.styleable.WindmillDrawable_wdSize:\n        mSize = a.getDimensionPixelSize(index, mSize);\n        break;\n      case R.styleable.WindmillDrawable_wdColor0:\n        mColors[0] = a.getColor(index, mColors[0]);\n        break;\n      case R.styleable.WindmillDrawable_wdColor1:\n        mColors[1] = a.getColor(index, mColors[1]);\n        break;\n      ...\n      default://no-op unexpected attr index\n        break;\n    }\n  }\n  a.recycle();\n}\n```\nthis is samilar to costom `View`，the main purpose is to add a constructor that takes a `Context` and `AttributeSet` as parameter, other code is emitted here, for more details，[click](https://github.com/Cricin/Folivora/blob/master/sample/src/main/java/cn/cricin/folivora/sample/drawable/WindmillDrawable.java) to view source code\n\n3. use `WindmillDrawable` in your layout files，Folivora provided a `drawableName` attr，you can declare the drawable name here：\n```xml\n<View\n  andorid:layout_width=\"120dp\"\n  android:layout_height=\"120dp\"\n  app:drawableName=\"cn.cricin.folivora.sample.drawable.WindmillDrawable\"\n  app:wdColor0=\"@color/blue_light\"\n  app:wdColor1=\"@color/green_dark\"\n  app:wdColor2=\"@color/green_light\"\n  app:wdColor3=\"@color/purple\"\n  app:wdRotateDegrees=\"45\"/>\n```\nat runtime, the drawable is created by folivora and get worked：\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/preview_custom_drawable.png\"></img>\n\nyou may ask, the drawable's name is to long to remember, it's difficult to write down，don't worry at it，folivora will gives the candidate of custom drawables if you typed down drawableName attr, attrs about the specific drawable is also will have code completion support.\n\n> Support of custom drawables do not have the constructor which recieves `Context` and `AttributeSet` as parameter\n\nFolivora take concerned it, source code of some drawables is not permited to modify, so，we provided a `DrawableFactory` interface，assume `WindmillDrawable` only have a constructor takes no parameter，but provided some methods to modify it, to support `WindmillDrawable`，we can do this：\n```java\nFolivora.addDrawableFactory(new Folivora.DrawableFactory() {\n  @Override\n  public Drawable newDrawable(Context context, AttributeSet attrs) {\n    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.WindmillDrawable);\n    WindmillDrawable d = new WindmillDrawable();\n    d.setColor0(a.getColor(R.styleable.WindmillDrawable_wdColor0, Color.BLACK));\n    d.setRotateDegrees(a.getInt(R.styleable.WindmillDrawable_wdRotateDegrees, 0));\n    ...\n    a.recycle();\n    return d;\n  }\n\n  @Override\n  public Class<? extends Drawable> drawableClass() {\n    return WindmillDrawable.class;\n  }\n});\n```\n> If you are using custom drawable，and your drawable contains other drawables, it is recommended to use `Folivora.getDrawable(Context ctx, TypedArray a, AttributeSet attrs, int attrIndex)` to get a drawable, this method will take care about nested shape creation, also you can do not follow this tip if you do not need nested shape support。\n\n### Drawable caches\n\nIn previous releases，Folivora will create drawables according to attrs from view tag, a new instance is created for per view, which is waste resources, now Folivora supported drawable caching(LruCache，max = 128), usage is very simple，just add `app:drawableId` attr，set a id(string type，not android's id type) to drawable is ok。Folivora will lookup cache to find a cached drawable, which means，if in a layout.xml，a drawable should be referenced multi places, define it at first occurrence, then at other place, use the same `drawableId` to reference this drawable.\n\n```xml\n<LinearLayout\n  android:layout_width=\"wrap_content\"\n  android:layout_height=\"wrap_content\">\n\n    <TextView\n      android:layout_width=\"100dp\"\n      android:layout_height=\"40dp\"\n      android:text=\"shape1\"\n      android:gravity=\"center\"\n      android:textColor=\"@android:color/white\"\n      app:drawableId=\"shape_rounded_6dp\"\n      app:drawableType=\"shape\"\n      app:shapeCornerRadius=\"6dp\"\n      app:shapeSolidColor=\"@color/blue_light\"/>\n\n    <TextView\n      android:layout_width=\"100dp\"\n      android:layout_height=\"40dp\"\n      android:text=\"shape2\"\n      android:gravity=\"center\"\n      android:textColor=\"@android:color/white\"\n      app:drawableId=\"shape_rounded_6dp\"/>\n\n</LinearLayout>\n```\n\nIt is recommended to set `drawableId` to drawable which is reusable or inside a frequently used layout files, which makes a better performance.\n\n### Download Sample APK\n[Click to download](https://raw.githubusercontent.com/Cricin/Folivora/master/sample.apk)\n\n\n### Design time preview\n\n> preview result\n\n<img src=\"https://raw.githubusercontent.com/Cricin/Folivora/master/pics/studio_preview.gif\"></img>\n\nafter you added folivora in gradle and sync project，preview would been enabled by default, if unavailable, try to build your project.\n\n### Attrs Reference\n\n##### Common Attrs\n\nattr | value| desc\n ---|--- | --- |\napp:setAs|background(default) &#124; src &#124; foreground| set drawable as backgrond or src or foreground\napp:drawableType|shape &#124; layer_list &#124; selector &#124; ripple &#124; clip &#124; scale &#124; animation &#124; level_list|drawable type\napp:drawableName|string|fq class name of custom drawable\napp:drawableId|string|drawable unique id for cache use\n\n##### Shape Attrs\n\nattr | value | desc\n ---|--- | --- |\napp:shapeType|rectangle(default)&#124;oval&#124;line&#124;ring\napp:shapeSolidSize|dimension\napp:shapeSolidWidth|dimension\napp:shapeSolidHeight|dimension\napp:shapeSolidColor|color\napp:shapeStokeWidth|dimension\napp:shapeStokeDashWidth|dimension\napp:shapeStokeDashGap|dimension\napp:shapeCornerRadius|dimension\napp:shapeCornerRadiusTopLeft|dimension\napp:shapeCornerRadiusTopRight|dimension\napp:shapeCornerRadiusBottomLeft|dimension\napp:shapeCornerRadiusBottomRight|dimension\napp:shapeGradientType|linear &#124; radial &#124; sweep\napp:shapeGradientAngle|tb &#124; tr_bl &#124; rl &#124; br_tl &#124; bt &#124; bl_tr &#124; lr &#124; tl_br|\napp:shapeGradientStartColor|color\napp:shapeGradientCenterColor|color\napp:shapeGradientEndColor|color\napp:shapeGradientRadius|dimension\napp:shapeGradientCenterX|float(default 0.5)\napp:shapeGradientCenterY|float(default 0.5)\n\n##### Selector Attrs\n\nattr | value| desc\n ---|--- | --- |\napp:selectorStateFirst|reference &#124; color|\napp:selectorStateMiddle|reference &#124; color|\napp:selectorStateLast|reference &#124; color|\napp:selectorStateActive|reference &#124; color|\napp:selectorStateActivated|reference &#124; color|\napp:selectorStateAccelerate|reference &#124; color|\napp:selectorStateChecked|reference &#124; color|\napp:selectorStateCheckable|reference &#124; color|\napp:selectorStateEnabled|reference &#124; color|\napp:selectorStateFocused|reference &#124; color|\napp:selectorStatePressed|reference &#124; color|\napp:selectorStateNormal|reference &#124; color|\n\n##### LayerList Attrs\n\nattr | value| desc\n ---|--- | --- |\napp:layerItem0Drawable| reference &#124; color| drawable innermost\napp:layerItem0Insets|dimension|margin for drawable\napp:layerItem0Left|dimension| left margin\napp:layerItem0Right|dimension|right margin\napp:layerItem0Top|dimension|top margin\napp:layerItem0Bottom|dimension|bottom margin\n\n...\n\nlayerlist supports at most 5 children drawables, just substitute the digit\n\n##### Ripple Attrs\n\nattr | value| desc\n ---|--- | --- |\napp:rippleColor|color|ripple color when touched\napp:rippleMask|reference &#124; color|mask for ripple\napp:rippleContent|reference &#124; color|content for ripple\n\n##### LevelList Attrs\n\nattr | value| desc\n ---|--- | --- |\napp:levelCurrentLevel|integer|current level\napp:levelItem0Drawable|reference &#124; color|drawable for item0\napp:levelItem1MinLevel|integer|min level for item0\napp:levelItem1MaxLevel|integer|max level for item0\n\n...\n\nlevellist supports at most 5 children drawables, just substitute the digit\n\n##### Clip Attrs\n\nattr | value| desc\n ---|--- | --- |\napp:clipDrawable|reference &#124; color|drawable to be clipped\napp:clipGravity|same as View's layout_gravity|gravity to clip\napp:clipOrientation|vertical &#124; horizontal|clip orientation\napp:clipLevel|integer|current level(used to clip the drawable)\n\n##### Scale Attrs\n\nattr | value| desc\n ---|--- | --- |\napp:scaleDrawable|reference &#124; color|drawable to be scaled\napp:scaleGravity|same as View's layout_gravity|gravity to scale\napp:scaleWidth|float[0,1] or -1()|scale ratio for width\napp:scaleHeight|float[0,1] or -1()|scale ratio for height\napp:scaleLevel|integer[0,10000]|current level(used to scale the drawable)\n\n##### Inset Attrs\n\nattr | value| desc\n ---|--- | --- |\napp:insetDrawable|reference &#124; color|drawable to be inseted\napp:insetAll|dimension|all inset\napp:insetLeft|dimension|inset of left\napp:insetTop|dimension|inset of top\napp:insetRight|dimension|inset of right\napp:insetBottom|dimension|inset of bottom\n\n##### Animation Attrs\n\nattr | value| desc\n ---|--- | --- |\napp:animAutoPlay|boolean|play animation automaticly\napp:animDuration|int(millisecond)|displayed duration per frame\napp:animOneShot|boolean|play just once\napp:animFrame0|reference &#124; color|first frame's drawable\napp:animDuration0|int(millisecond)|first frame displayed duration\n\nanimation supports at most 10 frames, just substitute the digit\n\n\n## License\n\nCopyright 2019 Cricin\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n"
  },
  {
    "path": "android_release_aar.gradle",
    "content": "// ./gradlew clean build generateRelease\napply plugin: 'maven'\n\ndef groupId = project.PUBLISH_GROUP_ID\ndef artifactId = project.PUBLISH_ARTIFACT_ID\ndef version = project.PUBLISH_VERSION\n\ndef localReleaseDest = \"${buildDir}/release/${version}\"\n\ntask androidJavadocs(type: Javadoc) {\n  failOnError = false\n  source = android.sourceSets.main.java.srcDirs\n  ext.androidJar = \"${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar\"\n  classpath += files(ext.androidJar)\n}\n\ntask androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {\n  classifier = 'javadoc'\n  from androidJavadocs.destinationDir\n}\n\ntask androidSourcesJar(type: Jar) {\n  classifier = 'sources'\n  from android.sourceSets.main.java.srcDirs\n}\n\nuploadArchives {\n  repositories.mavenDeployer {\n    pom.groupId = groupId\n    pom.artifactId = artifactId\n    pom.version = version\n    // Add other pom properties here if you want (developer details / licenses)\n    repository(url: \"file://${localReleaseDest}\")\n  }\n}\n\ntask zipRelease(type: Zip) {\n  from localReleaseDest\n  destinationDir buildDir\n  archiveName \"release-${version}.zip\"\n}\n\ntask generateRelease {\n  doLast {\n    println \"Release ${version} can be found at ${localReleaseDest}/\"\n    println \"Release ${version} zipped can be found ${buildDir}/release-${version}.zip\"\n  }\n}\n\ngenerateRelease.dependsOn(uploadArchives)\ngenerateRelease.dependsOn(zipRelease)\n\n\nartifacts {\n  archives androidSourcesJar\n  archives androidJavadocsJar\n}"
  },
  {
    "path": "build.gradle",
    "content": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n  repositories {\n    google()\n    jcenter()\n  }\n  dependencies {\n    classpath 'com.android.tools.build:gradle:3.6.1'\n\n    // NOTE: Do not place your application dependencies here; they belong\n    // in the individual module build.gradle files\n  }\n}\n\nallprojects {\n  repositories {\n    google()\n    jcenter()\n  }\n}\n\ntask clean(type: Delete) {\n  delete rootProject.buildDir\n}\n"
  },
  {
    "path": "folivora/build.gradle",
    "content": "apply plugin: 'com.android.library'\n\ndef verName = '0.1.0'\n\nandroid {\n  compileSdkVersion 29\n  defaultConfig {\n    minSdkVersion 16\n    targetSdkVersion 29\n  }\n  buildTypes {\n    release {\n      minifyEnabled false\n      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n    }\n  }\n}\n\ndependencies {\n  lintChecks project(':lint')\n  lintPublish project(':lint')\n}\n\next {\n  PUBLISH_GROUP_ID = 'cn.cricin'\n  PUBLISH_ARTIFACT_ID = 'folivora'\n  PUBLISH_VERSION = verName\n}\napply from: rootProject.file('android_release_aar.gradle')"
  },
  {
    "path": "folivora/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest package=\"cn.cricin.folivora\"/>"
  },
  {
    "path": "folivora/src/main/java/cn/cricin/folivora/DrawableParser.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora;\n\nimport android.content.Context;\nimport android.content.res.ColorStateList;\nimport android.content.res.TypedArray;\nimport android.graphics.Color;\nimport android.graphics.Rect;\nimport android.graphics.drawable.AnimationDrawable;\nimport android.graphics.drawable.ClipDrawable;\nimport android.graphics.drawable.Drawable;\nimport android.graphics.drawable.GradientDrawable;\nimport android.graphics.drawable.InsetDrawable;\nimport android.graphics.drawable.LayerDrawable;\nimport android.graphics.drawable.LevelListDrawable;\nimport android.graphics.drawable.RippleDrawable;\nimport android.graphics.drawable.ScaleDrawable;\nimport android.graphics.drawable.StateListDrawable;\nimport android.os.Build;\nimport android.util.AttributeSet;\nimport android.util.Log;\nimport android.util.StateSet;\nimport android.view.Gravity;\n\nimport java.lang.reflect.Constructor;\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Set;\n\nimport static cn.cricin.folivora.Folivora.TAG;\nimport static cn.cricin.folivora.Folivora.getDrawable;\n\n/**\n * A DrawableParser take responsibility of drawable parsing, Folivora\n * will find best match DrawableParser to parse a drawable instance\n * for view. each subclass handles one or more drawable parsing when\n * a view want a drawable to decorate self.\n */\npublic interface DrawableParser {\n\n  /**\n   * Entry point for subclass to accomplish drawable parsing task\n   * @param request current parsing request\n   * @return a parsed drawable instance, or null\n   */\n  Drawable parse(ParseRequest request);\n\n  /**\n   * Create a new GradientDrawable(shape).\n   * attrs:\n   * <p>\n   * app:shapeType                    enum\n   * app:shapeSolidSize               dimension\n   * app:shapeSolidWidth              dimension\n   * app:shapeSolidHeight             dimension\n   * app:shapeSolidColor              color\n   * <p>\n   * app:shapeStrokeWidth             dimension\n   * app:shapeStrokeColor             color\n   * app:shapeStrokeDashGap           dimension\n   * app:shapeStrokeDashWidth         dimension\n   * <p>\n   * app:shapeGradientType            enum\n   * app:shapeGradientRadius          dimension\n   * app:shapeGradientCenterX         dimension\n   * app:shapeGradientCenterY         dimension\n   * app:shapeGradientStartColor      color\n   * app:shapeGradientCenterColor     color\n   * app:shapeGradientEndColor        color\n   * app:shapeGradientAngle           enum\n   * <p>\n   * app:shapeCornerRadius            dimension\n   * app:shapeCornerRadiusTopLeft     dimension\n   * app:shapeCornerRadiusTopRight    dimension\n   * app:shapeCornerRadiusBottomLeft  dimension\n   * app:shapeCornerRadiusBottomRight dimension\n   */\n  class GradientDrawableParser implements DrawableParser {\n\n    @Override\n    public Drawable parse(ParseRequest request) {\n      final Context ctx = request.context();\n      final AttributeSet attrs = request.attrs();\n      final ShapeAttrs shapeAttrs = request.shapeAttrs();\n\n      GradientDrawable gd = new GradientDrawable();\n      TypedArray a = ctx.obtainStyledAttributes(attrs, shapeAttrs.mAttrStyleable);\n      gd.setShape(a.getInt(shapeAttrs.mShapeType, GradientDrawable.RECTANGLE));\n\n      final int size = a.getDimensionPixelSize(shapeAttrs.mShapeSolidSize, -1);\n      gd.setSize(a.getDimensionPixelSize(shapeAttrs.mShapeSolidWidth, size),\n        a.getDimensionPixelSize(shapeAttrs.mShapeSolidHeight, size));\n\n      gd.setGradientType(a.getInt(shapeAttrs.mShapeGradientType, GradientDrawable.LINEAR_GRADIENT));\n      gd.setGradientRadius(a.getDimension(shapeAttrs.mShapeGradientRadius, 0));\n      gd.setGradientCenter(a.getFloat(shapeAttrs.mShapeGradientCenterX, 0.5F),\n        a.getFloat(shapeAttrs.mShapeGradientCenterY, 0.5F));\n      int[] gradientColors;\n      final int gradientStartColor = a.getColor(shapeAttrs.mShapeGradientStartColor, 0);\n      final int gradientEndColor = a.getColor(shapeAttrs.mShapeGradientEndColor, 0);\n      final int gradientCenterColor = a.getColor(shapeAttrs.mShapeGradientCenterColor, 0);\n      if (a.hasValue(shapeAttrs.mShapeGradientCenterColor)) {\n        gradientColors = new int[]{gradientStartColor, gradientCenterColor, gradientEndColor};\n      } else {\n        gradientColors = new int[]{gradientStartColor, gradientEndColor};\n      }\n      gd.setColors(gradientColors);\n      final int orientationIndex = a.getInt(shapeAttrs.mShapeGradientAngle, 0);\n      gd.setOrientation(GradientDrawable.Orientation.values()[orientationIndex]);\n\n      if (a.hasValue(shapeAttrs.mShapeSolidColor)) {\n        gd.setColor(a.getColor(shapeAttrs.mShapeSolidColor, Color.WHITE));\n      }\n\n      gd.setStroke(\n        a.getDimensionPixelSize(shapeAttrs.mShapeStrokeWidth, -1),\n        a.getColor(shapeAttrs.mShapeStrokeColor, Color.WHITE),\n        a.getDimensionPixelSize(shapeAttrs.mShapeStrokeDashGap, 0),\n        a.getDimensionPixelSize(shapeAttrs.mShapeStrokeDashWidth, 0)\n      );\n      final float radius = a.getDimension(shapeAttrs.mShapeCornerRadius, 0);\n      gd.setCornerRadii(new float[]{\n        a.getDimension(shapeAttrs.mShapeCornerRadiusTopLeft, radius),\n        a.getDimension(shapeAttrs.mShapeCornerRadiusTopLeft, radius),\n        a.getDimension(shapeAttrs.mShapeCornerRadiusTopRight, radius),\n        a.getDimension(shapeAttrs.mShapeCornerRadiusTopRight, radius),\n        a.getDimension(shapeAttrs.mShapeCornerRadiusBottomRight, radius),\n        a.getDimension(shapeAttrs.mShapeCornerRadiusBottomRight, radius),\n        a.getDimension(shapeAttrs.mShapeCornerRadiusBottomLeft, radius),\n        a.getDimension(shapeAttrs.mShapeCornerRadiusBottomLeft, radius),\n      });\n      a.recycle();\n      return gd;\n    }\n  }\n\n  /**\n   * Create a new StateListDrawable, only support single state match.\n   * attrs:\n   * <p>\n   * app:selectorStateFirst          drawable\n   * app:selectorStateMiddle         drawable\n   * app:selectorStateLast           drawable\n   * app:selectorStateActive         drawable\n   * app:selectorStateActivate       drawable\n   * app:selectorStateAccelerate     drawable\n   * app:selectorStateChecked        drawable\n   * app:selectorStateCheckable      drawable\n   * app:selectorStateEnabled        drawable\n   * app:selectorStateFocused        drawable\n   * app:selectorStatePressed        drawable\n   * app:selectorStateNormal         drawable\n   * app:selectorStateSelected       drawable\n   * app:selectorStateSingle         drawable\n   * app:selectorStateHovered        drawable\n   * app:selectorStateWindowFocused  drawable\n   *\n   * note that if you want use more complicated state combination, use\n   * <p>\n   * selectorItemXXX instead.\n   * app:selectorItemXStates         flags\n   * app:selectorItemXDrawable       drawable\n   * ...\n   */\n  class StateListDrawableParser implements DrawableParser {\n    // Single state constants of view, keep sync with Folivora_Selector attrs\n    private static final int[] STATE_FIRST = {android.R.attr.state_first};\n    private static final int[] STATE_MIDDLE = {android.R.attr.state_middle};\n    private static final int[] STATE_LAST = {android.R.attr.state_last};\n    private static final int[] STATE_ACTIVE = {android.R.attr.state_active};\n    private static final int[] STATE_ACTIVATED = {android.R.attr.state_activated};\n    private static final int[] STATE_ACCELERATE = {android.R.attr.state_accelerated};\n    private static final int[] STATE_CHECKED = {android.R.attr.state_checked};\n    private static final int[] STATE_CHECKABLE = {android.R.attr.state_checkable};\n    private static final int[] STATE_ENABLED = {android.R.attr.state_enabled};\n    private static final int[] STATE_FOCUSED = {android.R.attr.state_focused};\n    private static final int[] STATE_PRESSED = {android.R.attr.state_pressed};\n    private static final int[] STATE_SELECTED = {android.R.attr.state_selected};\n    private static final int[] STATE_SINGLE = {android.R.attr.state_single};\n    private static final int[] STATE_HOVERED = {android.R.attr.state_hovered};\n    private static final int[] STATE_WINDOW_FOCUSED = {android.R.attr.state_window_focused};\n    // Should we support these state?\n    //private static final int[] STATE_DRAG_HOVERED = {android.R.attr.state_drag_hovered};\n    //private static final int[] STATE_DRAG_CAN_ACCEPT = {android.R.attr.state_drag_can_accept};\n    private static final int[] STATE_NORMAL = {};\n\n    // State flags\n    private static final int FIRST = 1;\n    private static final int FIRST_NOT = 1 << 1;\n    private static final int MIDDLE = 1 << 2;\n    private static final int MIDDLE_NOT = 1 << 3;\n    private static final int LAST = 1 << 4;\n    private static final int LAST_NOT = 1 << 5;\n    private static final int ACTIVE = 1 << 6;\n    private static final int ACTIVE_NOT = 1 << 7;\n    private static final int ACTIVATED = 1 << 8;\n    private static final int ACTIVATED_NOT = 1 << 9;\n    private static final int ACCELERATE = 1 << 10;\n    private static final int ACCELERATE_NOT = 1 << 11;\n    private static final int CHECKED = 1 << 12;\n    private static final int CHECKED_NOT = 1 << 13;\n    private static final int CHECKABLE = 1 << 14;\n    private static final int CHECKABLE_NOT = 1 << 15;\n    private static final int ENABLED = 1 << 16;\n    private static final int ENABLED_NOT = 1 << 17;\n    private static final int FOCUSED = 1 << 18;\n    private static final int FOCUSED_NOT = 1 << 19;\n    private static final int PRESSED = 1 << 20;\n    private static final int PRESSED_NOT = 1 << 21;\n    private static final int SELECTED = 1 << 22;\n    private static final int SELECTED_NOT = 1 << 23;\n    private static final int SINGLE = 1 << 24;\n    private static final int SINGLE_NOT = 1 << 25;\n    private static final int HOVERED = 1 << 26;\n    private static final int HOVERED_NOT = 1 << 27;\n    private static final int WINDOW_FOCUSED = 1 << 28;\n    private static final int WINDOW_FOCUSED_NOT = 1 << 29;\n    private static final int[] TEMP_STATE_SET = new int[15];\n\n    @Override\n    public Drawable parse(ParseRequest request) {\n      final Context ctx = request.context();\n      final AttributeSet attrs = request.attrs();\n      StateListDrawable d = new StateListDrawable();\n      Drawable temp;\n      int[] states;\n      TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.Folivora_Selector);\n      states = parseStateSet(a.getInt(R.styleable.Folivora_Selector_selectorItem0States, 0));\n      if (states != null && (temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorItem0Drawable)) != null) {\n        d.addState(states, temp);\n      }\n      states = parseStateSet(a.getInt(R.styleable.Folivora_Selector_selectorItem1States, 0));\n      if (states != null && (temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorItem1Drawable)) != null) {\n        d.addState(states, temp);\n      }\n      states = parseStateSet(a.getInt(R.styleable.Folivora_Selector_selectorItem2States, 0));\n      if (states != null && (temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorItem2Drawable)) != null) {\n        d.addState(states, temp);\n      }\n      states = parseStateSet(a.getInt(R.styleable.Folivora_Selector_selectorItem3States, 0));\n      if (states != null && (temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorItem3Drawable)) != null) {\n        d.addState(states, temp);\n      }\n      states = parseStateSet(a.getInt(R.styleable.Folivora_Selector_selectorItem4States, 0));\n      if (states != null && (temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorItem4Drawable)) != null) {\n        d.addState(states, temp);\n      }\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStateFirst);\n      if (temp != null) d.addState(STATE_FIRST, temp);\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStateMiddle);\n      if (temp != null) d.addState(STATE_MIDDLE, temp);\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStateLast);\n      if (temp != null) d.addState(STATE_LAST, temp);\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStateActive);\n      if (temp != null) d.addState(STATE_ACTIVE, temp);\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStateActivated);\n      if (temp != null) d.addState(STATE_ACTIVATED, temp);\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStateAccelerate);\n      if (temp != null) d.addState(STATE_ACCELERATE, temp);\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStateChecked);\n      if (temp != null) d.addState(STATE_CHECKED, temp);\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStateCheckable);\n      if (temp != null) d.addState(STATE_CHECKABLE, temp);\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStateEnabled);\n      if (temp != null) d.addState(STATE_ENABLED, temp);\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStateFocused);\n      if (temp != null) d.addState(STATE_FOCUSED, temp);\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStatePressed);\n      if (temp != null) d.addState(STATE_PRESSED, temp);\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStateSelected);\n      if (temp != null) d.addState(STATE_SELECTED, temp);\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStateSingle);\n      if (temp != null) d.addState(STATE_SINGLE, temp);\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStateHovered);\n      if (temp != null) d.addState(STATE_HOVERED, temp);\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStateWindowFocused);\n      if (temp != null) d.addState(STATE_WINDOW_FOCUSED, temp);\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Selector_selectorStateNormal);\n      if (temp != null) d.addState(STATE_NORMAL, temp);\n      a.recycle();\n      return d;\n    }\n\n    /**\n     * Parse state sets from the stateFlags\n     *\n     * @param stateFlags the flags which states combined\n     * @return state set or null if absent\n     */\n    private static int[] parseStateSet(int stateFlags) {\n      if (stateFlags == 0) return null;\n      int index = 0;\n      if ((stateFlags & FIRST) == FIRST) {\n        TEMP_STATE_SET[index++] = android.R.attr.state_first;\n      }\n      if ((stateFlags & FIRST_NOT) == FIRST_NOT) {\n        TEMP_STATE_SET[index++] = -android.R.attr.state_first;\n      }\n      if ((stateFlags & MIDDLE) == MIDDLE) {\n        TEMP_STATE_SET[index++] = android.R.attr.state_middle;\n      }\n      if ((stateFlags & MIDDLE_NOT) == MIDDLE_NOT) {\n        TEMP_STATE_SET[index++] = -android.R.attr.state_middle;\n      }\n      if ((stateFlags & LAST) == LAST) {\n        TEMP_STATE_SET[index++] = android.R.attr.state_last;\n      }\n      if ((stateFlags & LAST_NOT) == LAST_NOT) {\n        TEMP_STATE_SET[index++] = -android.R.attr.state_last;\n      }\n      if ((stateFlags & ACTIVE) == ACTIVE) {\n        TEMP_STATE_SET[index++] = android.R.attr.state_active;\n      }\n      if ((stateFlags & ACTIVE_NOT) == ACTIVE_NOT) {\n        TEMP_STATE_SET[index++] = -android.R.attr.state_active;\n      }\n      if ((stateFlags & ACTIVATED) == ACTIVATED) {\n        TEMP_STATE_SET[index++] = android.R.attr.state_activated;\n      }\n      if ((stateFlags & ACTIVATED_NOT) == ACTIVATED_NOT) {\n        TEMP_STATE_SET[index++] = -android.R.attr.state_activated;\n      }\n      if ((stateFlags & ACCELERATE) == ACCELERATE) {\n        TEMP_STATE_SET[index++] = android.R.attr.state_accelerated;\n      }\n      if ((stateFlags & ACCELERATE_NOT) == ACCELERATE_NOT) {\n        TEMP_STATE_SET[index++] = -android.R.attr.state_accelerated;\n      }\n      if ((stateFlags & CHECKED) == CHECKED) {\n        TEMP_STATE_SET[index++] = android.R.attr.state_checked;\n      }\n      if ((stateFlags & CHECKED_NOT) == CHECKED_NOT) {\n        TEMP_STATE_SET[index++] = -android.R.attr.state_checked;\n      }\n      if ((stateFlags & CHECKABLE) == CHECKABLE) {\n        TEMP_STATE_SET[index++] = android.R.attr.state_checkable;\n      }\n      if ((stateFlags & CHECKABLE_NOT) == CHECKABLE_NOT) {\n        TEMP_STATE_SET[index++] = -android.R.attr.state_checkable;\n      }\n      if ((stateFlags & ENABLED) == ENABLED) {\n        TEMP_STATE_SET[index++] = android.R.attr.state_enabled;\n      }\n      if ((stateFlags & ENABLED_NOT) == ENABLED_NOT) {\n        TEMP_STATE_SET[index++] = -android.R.attr.state_enabled;\n      }\n      if ((stateFlags & FOCUSED) == FOCUSED) {\n        TEMP_STATE_SET[index++] = android.R.attr.state_focused;\n      }\n      if ((stateFlags & FOCUSED_NOT) == FOCUSED_NOT) {\n        TEMP_STATE_SET[index++] = -android.R.attr.state_focused;\n      }\n      if ((stateFlags & PRESSED) == PRESSED) {\n        TEMP_STATE_SET[index++] = android.R.attr.state_pressed;\n      }\n      if ((stateFlags & PRESSED_NOT) == PRESSED_NOT) {\n        TEMP_STATE_SET[index++] = -android.R.attr.state_pressed;\n      }\n      if ((stateFlags & SELECTED) == SELECTED) {\n        TEMP_STATE_SET[index++] = android.R.attr.state_selected;\n      }\n      if ((stateFlags & SELECTED_NOT) == SELECTED_NOT) {\n        TEMP_STATE_SET[index++] = -android.R.attr.state_selected;\n      }\n      if ((stateFlags & SINGLE) == SINGLE) {\n        TEMP_STATE_SET[index++] = android.R.attr.state_single;\n      }\n      if ((stateFlags & SINGLE_NOT) == SINGLE_NOT) {\n        TEMP_STATE_SET[index++] = -android.R.attr.state_single;\n      }\n      if ((stateFlags & HOVERED) == HOVERED) {\n        TEMP_STATE_SET[index++] = android.R.attr.state_hovered;\n      }\n      if ((stateFlags & HOVERED_NOT) == HOVERED_NOT) {\n        TEMP_STATE_SET[index++] = -android.R.attr.state_hovered;\n      }\n      if ((stateFlags & WINDOW_FOCUSED) == WINDOW_FOCUSED) {\n        TEMP_STATE_SET[index++] = android.R.attr.state_window_focused;\n      }\n      if ((stateFlags & WINDOW_FOCUSED_NOT) == WINDOW_FOCUSED_NOT) {\n        TEMP_STATE_SET[index++] = -android.R.attr.state_window_focused;\n      }\n      if (index == 0) return null;\n      return StateSet.trimStateSet(TEMP_STATE_SET, index);\n    }\n  }\n\n  /**\n   * Create a new LayerDrawable, currently we only support 5 children drawables.\n   * attrs:\n   * <p>\n   * app:layerItem0Drawable       drawable\n   * app:layerItem0Insets         dimension\n   * app:layerItem0Left           dimension\n   * app:layerItem0Top            dimension\n   * app:layerItem0Right          dimension\n   * app:layerItem0Bottom         dimension\n   * <p>\n   * app:layerItem1Drawable       drawable\n   * app:layerItem1Insets         dimension\n   * app:layerItem1Left           dimension\n   * app:layerItem1Top            dimension\n   * app:layerItem1Right          dimension\n   * app:layerItem1Bottom         dimension\n   * <p>\n   * app:layerItem2Drawable       drawable\n   * app:layerItem2Insets         dimension\n   * app:layerItem2Left           dimension\n   * app:layerItem2Top            dimension\n   * app:layerItem2Right          dimension\n   * app:layerItem2Bottom         dimension\n   * <p>\n   * app:layerItem3Drawable       drawable\n   * app:layerItem3Insets         dimension\n   * app:layerItem3Left           dimension\n   * app:layerItem3Top            dimension\n   * app:layerItem3Right          dimension\n   * app:layerItem3Bottom         dimension\n   * <p>\n   * app:layerItem4Drawable       drawable\n   * app:layerItem4Insets         dimension\n   * app:layerItem4Left           dimension\n   * app:layerItem4Top            dimension\n   * app:layerItem4Right          dimension\n   * app:layerItem4Bottom         dimension\n   */\n  class LayerDrawableParser implements DrawableParser {\n    @Override\n    public Drawable parse(ParseRequest request) {\n      final Context ctx = request.context();\n      final AttributeSet attrs = request.attrs();\n      TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.Folivora_Layer);\n      List<Drawable> childDrawables = new ArrayList<>(5);\n      List<Rect> childInsets = new ArrayList<>(5);\n\n      Drawable temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Layer_layerItem0Drawable);\n      if (temp != null) {\n        childDrawables.add(temp);\n        int insets = a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem0Insets, 0);\n        childInsets.add(new Rect(\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem0Left, insets),\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem0Top, insets),\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem0Right, insets),\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem0Bottom, insets)\n        ));\n      }\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Layer_layerItem1Drawable);\n      if (temp != null) {\n        childDrawables.add(temp);\n        int insets = a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem1Insets, 0);\n        childInsets.add(new Rect(\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem1Left, insets),\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem1Top, insets),\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem1Right, insets),\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem1Bottom, insets)\n        ));\n      }\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Layer_layerItem2Drawable);\n      if (temp != null) {\n        childDrawables.add(temp);\n        int insets = a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem2Insets, 0);\n        childInsets.add(new Rect(\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem2Left, insets),\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem2Top, insets),\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem2Right, insets),\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem2Bottom, insets)\n        ));\n      }\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Layer_layerItem3Drawable);\n      if (temp != null) {\n        childDrawables.add(temp);\n        int insets = a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem3Insets, 0);\n        childInsets.add(new Rect(\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem3Left, insets),\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem3Top, insets),\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem3Right, insets),\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem3Bottom, insets)\n        ));\n      }\n      temp = getDrawable(ctx, a, attrs, R.styleable.Folivora_Layer_layerItem4Drawable);\n      if (temp != null) {\n        childDrawables.add(temp);\n        int insets = a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem4Insets, 0);\n        childInsets.add(new Rect(\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem4Left, insets),\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem4Top, insets),\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem4Right, insets),\n          a.getDimensionPixelSize(R.styleable.Folivora_Layer_layerItem4Bottom, insets)\n        ));\n      }\n      a.recycle();\n      LayerDrawable d = new LayerDrawable(childDrawables.toArray(new Drawable[0]));\n      for (int i = 0; i < childInsets.size(); i++) {\n        Rect inset = childInsets.get(i);\n        d.setLayerInset(i, inset.left, inset.top, inset.right, inset.bottom);\n      }\n      return d;\n    }\n  }\n\n  /**\n   * Create a new RippleDrawable, if current platform does not support,\n   * we will try to create a substitute from {@link RippleFallback} rippleFallback.\n   * attrs:\n   * <p>\n   * app:rippleColor              color\n   * app:rippleContent            drawable\n   * app:rippleMask               drawable\n   */\n  class RippleDrawableParser implements DrawableParser {\n    @Override\n    public Drawable parse(ParseRequest request) {\n      final Context ctx = request.context();\n      final AttributeSet attrs = request.attrs();\n      final RippleFallback fallback = request.rippleFallback();\n\n      TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.Folivora_Ripple);\n      ColorStateList color;\n      Drawable content;\n      Drawable mask;\n      try {\n        color = a.getColorStateList(R.styleable.Folivora_Ripple_rippleColor);\n        if (color == null) {\n          throw new IllegalStateException(\"rippleColor not set\");\n        }\n        content = getDrawable(ctx, a, attrs, R.styleable.Folivora_Ripple_rippleContent);\n        mask = getDrawable(ctx, a, attrs, R.styleable.Folivora_Ripple_rippleMask);\n      } finally {\n        a.recycle();\n      }\n\n      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {\n        return new RippleDrawable(color, content, mask);\n      } else if (fallback != null) {\n        return fallback.onFallback(color, content, mask, ctx);\n      } else {\n        Log.w(TAG, \"RippleDrawable is not available in current platform\");\n        return null;\n      }\n    }\n  }\n\n  /**\n   * Create a new LevelListDrawable, currently we only support 5 children drawables.\n   * attrs:\n   * <p>\n   * app:levelCurrentLevel        int\n   * app:levelItem0Drawable       drawable\n   * app:levelItem0MinLevel       int\n   * app:levelItem0MaxLevel       int\n   * app:levelItem1Drawable       drawable\n   * app:levelItem1MinLevel       int\n   * app:levelItem1MaxLevel       int\n   * app:levelItem2Drawable       drawable\n   * app:levelItem2MinLevel       int\n   * app:levelItem2MaxLevel       int\n   * app:levelItem3Drawable       drawable\n   * app:levelItem3MinLevel       int\n   * app:levelItem3MaxLevel       int\n   * app:levelItem4Drawable       drawable\n   * app:levelItem4MinLevel       int\n   * app:levelItem4MaxLevel       int\n   */\n  class LevelListDrawableParser implements DrawableParser {\n    @Override\n    public Drawable parse(ParseRequest request) {\n      final Context ctx = request.context();\n      final AttributeSet attrs = request.attrs();\n      LevelListDrawable lld = new LevelListDrawable();\n      TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.Folivora_Level);\n      if (a.hasValue(R.styleable.Folivora_Level_levelItem0Drawable)) {\n        lld.addLevel(\n          a.getInt(R.styleable.Folivora_Level_levelItem0MinLevel, 0),\n          a.getInt(R.styleable.Folivora_Level_levelItem0MaxLevel, 0),\n          getDrawable(ctx, a, attrs, R.styleable.Folivora_Level_levelItem0Drawable)\n        );\n      }\n      if (a.hasValue(R.styleable.Folivora_Level_levelItem1Drawable)) {\n        lld.addLevel(\n          a.getInt(R.styleable.Folivora_Level_levelItem1MinLevel, 0),\n          a.getInt(R.styleable.Folivora_Level_levelItem1MaxLevel, 0),\n          getDrawable(ctx, a, attrs, R.styleable.Folivora_Level_levelItem1Drawable)\n        );\n      }\n      if (a.hasValue(R.styleable.Folivora_Level_levelItem2Drawable)) {\n        lld.addLevel(\n          a.getInt(R.styleable.Folivora_Level_levelItem2MinLevel, 0),\n          a.getInt(R.styleable.Folivora_Level_levelItem2MaxLevel, 0),\n          getDrawable(ctx, a, attrs, R.styleable.Folivora_Level_levelItem2Drawable)\n        );\n      }\n      if (a.hasValue(R.styleable.Folivora_Level_levelItem3Drawable)) {\n        lld.addLevel(\n          a.getInt(R.styleable.Folivora_Level_levelItem3MinLevel, 0),\n          a.getInt(R.styleable.Folivora_Level_levelItem3MaxLevel, 0),\n          getDrawable(ctx, a, attrs, R.styleable.Folivora_Level_levelItem3Drawable)\n        );\n      }\n      if (a.hasValue(R.styleable.Folivora_Level_levelItem4Drawable)) {\n        lld.addLevel(\n          a.getInt(R.styleable.Folivora_Level_levelItem4MinLevel, 0),\n          a.getInt(R.styleable.Folivora_Level_levelItem4MaxLevel, 0),\n          getDrawable(ctx, a, attrs, R.styleable.Folivora_Level_levelItem4Drawable)\n        );\n      }\n      lld.setLevel(a.getInt(R.styleable.Folivora_Level_levelCurrentLevel, 0));\n      a.recycle();\n      return lld;\n    }\n  }\n\n  /**\n   * Create a new ClipDrawable.\n   * attrs:\n   * <p>\n   * app:clipDrawable             drawable\n   * app:clipGravity              enum\n   * app:clipOrientation          enum\n   * app:clipLevel                int(10000 means no clip)\n   */\n  class ClipDrawableParser implements DrawableParser {\n    @Override\n    public Drawable parse(ParseRequest request) {\n      final Context ctx = request.context();\n      final AttributeSet attrs = request.attrs();\n      TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.Folivora_Clip);\n      final Drawable child = getDrawable(ctx, a, attrs, R.styleable.Folivora_Clip_clipDrawable);\n      final int clipGravity = a.getInt(R.styleable.Folivora_Clip_clipGravity, Gravity.START);\n      final int clipOrientation = a.getInt(R.styleable.Folivora_Clip_clipOrientation, ClipDrawable.HORIZONTAL);\n\n      ClipDrawable cd = new ClipDrawable(child, clipGravity, clipOrientation);\n      cd.setLevel(a.getInt(R.styleable.Folivora_Clip_clipLevel, 10000/*no clip*/));\n      a.recycle();\n      return cd;\n    }\n  }\n\n  /**\n   * Create a new InsetDrawable, inset by fraction is not support, since it is an new api.\n   * attrs:\n   * <p>\n   * app:insetDrawable            drawable\n   * app:insetAll                 dimension\n   * app:insetLeft                dimension\n   * app:insetTop                 dimension\n   * app:insetRight               dimension\n   * app:insetBottom              dimension\n   */\n  class InsetDrawableParser implements DrawableParser {\n    @Override\n    public Drawable parse(ParseRequest request) {\n      final Context ctx = request.context();\n      final AttributeSet attrs = request.attrs();\n      TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.Folivora_Inset);\n      int insetAll = a.getDimensionPixelSize(R.styleable.Folivora_Inset_insetAll, 0);\n      int[] ints = {\n        R.styleable.Folivora_Inset_insetLeft,\n        R.styleable.Folivora_Inset_insetTop,\n        R.styleable.Folivora_Inset_insetRight,\n        R.styleable.Folivora_Inset_insetBottom\n      };\n      for (int i = 0; i < ints.length; i++) {\n        ints[i] = a.getDimensionPixelSize(ints[i], insetAll);\n      }\n      final Drawable child = getDrawable(ctx, a, attrs, R.styleable.Folivora_Inset_insetDrawable);\n      a.recycle();\n      return new InsetDrawable(child, ints[0], ints[1], ints[2], ints[3]);\n    }\n  }\n\n  /**\n   * Create a new ScaleDrawable.\n   * attrs:\n   * <p>\n   * app:scaleDrawable            drawable\n   * app:scaleGravity             enum\n   * app:scaleWidth               float\n   * app:scaleHeight              float\n   * app:scaleLevel               int\n   */\n  class ScaleDrawableParser implements DrawableParser {\n    @Override\n    public Drawable parse(ParseRequest request) {\n      final Context ctx = request.context();\n      final AttributeSet attrs = request.attrs();\n      TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.Folivora_Scale);\n      ScaleDrawable sd = new ScaleDrawable(\n        getDrawable(ctx, a, attrs, R.styleable.Folivora_Scale_scaleDrawable),\n        a.getInt(R.styleable.Folivora_Scale_scaleGravity, Gravity.START),\n        a.getFloat(R.styleable.Folivora_Scale_scaleWidth, -1F),\n        a.getFloat(R.styleable.Folivora_Scale_scaleHeight, -1F)\n      );\n      sd.setLevel(a.getInt(R.styleable.Folivora_Scale_scaleLevel, 1));\n      a.recycle();\n      return sd;\n    }\n  }\n\n  /**\n   * Create a new AnimationDrawable, currently we only support 10 frames.\n   * attrs:\n   * <p>\n   * app:animAutoPlay             boolean\n   * app:animDuration             int(millisecond)\n   * app:animOneShot              boolean\n   * <p>\n   * app:animFrame0               drawable\n   * app:animDuration0            int(millisecond)\n   * app:animFrame1               drawable\n   * app:animDuration1            int(millisecond)\n   * app:animFrame2               drawable\n   * app:animDuration2            int(millisecond)\n   * app:animFrame3               drawable\n   * app:animDuration3            int(millisecond)\n   * app:animFrame4               drawable\n   * app:animDuration4            int(millisecond)\n   * app:animFrame5               drawable\n   * app:animDuration5            int(millisecond)\n   * app:animFrame6               drawable\n   * app:animDuration6            int(millisecond)\n   * app:animFrame7               drawable\n   * app:animDuration7            int(millisecond)\n   * app:animFrame8               drawable\n   * app:animDuration8            int(millisecond)\n   * app:animFrame9               drawable\n   * app:animDuration9            int(millisecond)\n   */\n  class AnimationDrawableParser implements DrawableParser {\n    @SuppressWarnings(\"ConstantConditions\")\n    @Override\n    public Drawable parse(ParseRequest request) {\n      final Context ctx = request.context();\n      final AttributeSet attrs = request.attrs();\n      AnimationDrawable ad;\n      TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.Folivora_Animation);\n      final boolean autoPlay = a.getBoolean(R.styleable.Folivora_Animation_animAutoPlay, false);\n      if (autoPlay) {\n        // Workaround for android bug, animation drawable does not played\n        // normally when calling start() on activity's onCreate() method.\n        ad = new AnimationDrawable() {\n          boolean autoPlayed;\n\n          @Override\n          protected void onBoundsChange(Rect bounds) {\n            super.onBoundsChange(bounds);\n            if (!autoPlayed) {\n              if (isOneShot()) {\n                Log.i(TAG, \"Auto play and oneshot both enabled, you could not see the animation\");\n              }\n              this.start();\n              autoPlayed = true;\n            }\n          }\n        };\n      } else {\n        ad = new AnimationDrawable();\n      }\n      ad.setOneShot(a.getBoolean(R.styleable.Folivora_Animation_animOneShot, false));\n      final int frameDuration = a.getInt(R.styleable.Folivora_Animation_animDuration, -1);\n\n      if (a.hasValue(R.styleable.Folivora_Animation_animFrame0)) {\n        ad.addFrame(a.getDrawable(R.styleable.Folivora_Animation_animFrame0),\n          a.getInt(R.styleable.Folivora_Animation_animDuration0, frameDuration));\n      }\n      if (a.hasValue(R.styleable.Folivora_Animation_animFrame1)) {\n        ad.addFrame(a.getDrawable(R.styleable.Folivora_Animation_animFrame1),\n          a.getInt(R.styleable.Folivora_Animation_animDuration1, frameDuration));\n      }\n      if (a.hasValue(R.styleable.Folivora_Animation_animFrame2)) {\n        ad.addFrame(a.getDrawable(R.styleable.Folivora_Animation_animFrame2),\n          a.getInt(R.styleable.Folivora_Animation_animDuration2, frameDuration));\n      }\n      if (a.hasValue(R.styleable.Folivora_Animation_animFrame3)) {\n        ad.addFrame(a.getDrawable(R.styleable.Folivora_Animation_animFrame3),\n          a.getInt(R.styleable.Folivora_Animation_animDuration3, frameDuration));\n      }\n      if (a.hasValue(R.styleable.Folivora_Animation_animFrame4)) {\n        ad.addFrame(a.getDrawable(R.styleable.Folivora_Animation_animFrame4),\n          a.getInt(R.styleable.Folivora_Animation_animDuration4, frameDuration));\n      }\n      if (a.hasValue(R.styleable.Folivora_Animation_animFrame5)) {\n        ad.addFrame(a.getDrawable(R.styleable.Folivora_Animation_animFrame5),\n          a.getInt(R.styleable.Folivora_Animation_animDuration5, frameDuration));\n      }\n      if (a.hasValue(R.styleable.Folivora_Animation_animFrame6)) {\n        ad.addFrame(a.getDrawable(R.styleable.Folivora_Animation_animFrame6),\n          a.getInt(R.styleable.Folivora_Animation_animDuration6, frameDuration));\n      }\n      if (a.hasValue(R.styleable.Folivora_Animation_animFrame7)) {\n        ad.addFrame(a.getDrawable(R.styleable.Folivora_Animation_animFrame7),\n          a.getInt(R.styleable.Folivora_Animation_animDuration7, frameDuration));\n      }\n      if (a.hasValue(R.styleable.Folivora_Animation_animFrame8)) {\n        ad.addFrame(a.getDrawable(R.styleable.Folivora_Animation_animFrame8),\n          a.getInt(R.styleable.Folivora_Animation_animDuration8, frameDuration));\n      }\n      if (a.hasValue(R.styleable.Folivora_Animation_animFrame9)) {\n        ad.addFrame(a.getDrawable(R.styleable.Folivora_Animation_animFrame9),\n          a.getInt(R.styleable.Folivora_Animation_animDuration9, frameDuration));\n      }\n      a.recycle();\n      return ad;\n    }\n  }\n\n  /**\n   * Try to create a custom drawable from the given class name, note\n   * that the custom drawable class must have a public constructor\n   * that takes a {@link Context} context and a {@link AttributeSet}\n   * attrs as parameters\n   */\n  class ReflectiveDrawableParser implements DrawableParser {\n    // Stuffs for create custom drawable reflectively\n    private static Set<String> sFailedNames = new HashSet<>();\n    private static Class[] sConstructorSignature = {Context.class, AttributeSet.class};\n    private static Object[] sConstructorArgs = new Object[2];\n    private static Map<String, Constructor<? extends Drawable>> sConstructorCache = new HashMap<>();\n\n    @Override\n    public Drawable parse(ParseRequest request) {\n      final Context ctx = request.context();\n      final AttributeSet attrs = request.attrs();\n      final String drawableName = request.drawableClassName();\n      if (sFailedNames.contains(drawableName)) return null;\n      if (drawableName.indexOf('.') == -1) return null;\n      Constructor<? extends Drawable> constructor = sConstructorCache.get(drawableName);\n\n      try {\n        if (constructor == null) {\n          Class<? extends Drawable> clazz = ctx.getClassLoader().loadClass(drawableName)\n            .asSubclass(Drawable.class);\n          constructor = clazz.getConstructor(sConstructorSignature);\n          constructor.setAccessible(true);\n          sConstructorCache.put(drawableName, constructor);\n        }\n        sConstructorArgs[0] = ctx;\n        sConstructorArgs[1] = attrs;\n        return constructor.newInstance(sConstructorArgs);\n      } catch (ClassNotFoundException cnfe) {\n        sFailedNames.add(drawableName);\n        Log.w(TAG, \"drawable class [\" + drawableName\n          + \"] not found, Folivora will never try to load it any more\");\n      } catch (NoSuchMethodException nsme) {\n        sFailedNames.add(drawableName);\n        final String classSimpleName = drawableName.substring(drawableName.lastIndexOf('.') + 1);\n        final String msg = \"constructor \" + classSimpleName + \"(Context context, AttributeSet attrs)\"\n          + \" does not exists in drawable class [\" + drawableName + \"], Folivora will never try to\" +\n          \" load it any more\";\n        Log.w(TAG, msg);\n      } catch (IllegalAccessException iae) {\n        throw new AssertionError(iae);//never happen\n      } catch (Exception e) {\n        Log.w(TAG, \"exception occurred instantiating drawable [\" + drawableName + \"]\", e);\n      } finally {\n        sConstructorArgs[0] = null;\n        sConstructorArgs[1] = null;\n      }\n      return null;\n    }\n  }\n}"
  },
  {
    "path": "folivora/src/main/java/cn/cricin/folivora/Folivora.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora;\n\nimport android.content.Context;\nimport android.content.ContextWrapper;\nimport android.content.res.TypedArray;\nimport android.graphics.drawable.Drawable;\nimport android.graphics.drawable.RippleDrawable;\nimport android.os.Build;\nimport android.util.AttributeSet;\nimport android.util.Log;\nimport android.util.LruCache;\nimport android.util.SparseArray;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.widget.FrameLayout;\nimport android.widget.ImageView;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\n/**\n * Folivora support sets drawable directly in your layout.xml files, no need\n * to create XXX.xml in drawable directory. just write down attributes we\n * provided in your layout.xml, folivora will take care of with this attrs\n * and create suitable drawable's for view.\n * <p>\n * Folivora is light weight, you would use {@link #wrap(Context)} wrap()\n * or {@link #installViewFactory(Context)} installViewFactory() to enable\n * folivora functions\n *\n * @see #wrap(Context)\n * @see #installViewFactory(Context)\n * @see #setRippleFallback(RippleFallback)\n * @see #getDrawable(Context, TypedArray, AttributeSet, int)\n * @see #addOnViewCreatedListener(OnViewCreatedListener)\n */\npublic final class Folivora {\n  static final String TAG = \"Folivora\";\n\n  // Drawable type enums, keep sync with app:drawableType\n  private static final int DRAWABLE_TYPE_SHAPE = 0;\n  private static final int DRAWABLE_TYPE_SELECTOR = 1;\n  private static final int DRAWABLE_TYPE_LAYER = 2;\n  private static final int DRAWABLE_TYPE_RIPPLE = 3;\n  private static final int DRAWABLE_TYPE_LEVEL = 4;\n  private static final int DRAWABLE_TYPE_CLIP = 5;\n  private static final int DRAWABLE_TYPE_INSET = 6;\n  private static final int DRAWABLE_TYPE_SCALE = 7;\n  private static final int DRAWABLE_TYPE_ANIMATION = 8;\n\n  // Set as enums, keep sync with app:setAs\n  private static final int SET_AS_BACKGROUND = 0;\n  private static final int SET_AS_SRC = 1;\n  private static final int SET_AS_FOREGROUND = 2;\n\n  // Exposed apis\n  private static RippleFallback sRippleFallback;\n  private static List<OnViewCreatedListener> sOnViewCreatedListeners;\n  private static Map<String, DrawableParser> sDrawableParsers = new HashMap<>();\n  private static DrawableParser sReflectiveDrawableParser = new DrawableParser.ReflectiveDrawableParser();\n  private static SparseArray<String> sSystemDrawableNames = new SparseArray<>();\n\n  static {\n    sDrawableParsers.put(\"android.graphics.drawable.GradientDrawable\", new DrawableParser.GradientDrawableParser());\n    sDrawableParsers.put(\"android.graphics.drawable.StateListDrawable\", new DrawableParser.StateListDrawableParser());\n    sDrawableParsers.put(\"android.graphics.drawable.LayerDrawable\", new DrawableParser.LayerDrawableParser());\n    sDrawableParsers.put(\"android.graphics.drawable.RippleDrawable\", new DrawableParser.RippleDrawableParser());\n    sDrawableParsers.put(\"android.graphics.drawable.LevelListDrawable\", new DrawableParser.LevelListDrawableParser());\n    sDrawableParsers.put(\"android.graphics.drawable.ClipDrawable\", new DrawableParser.ClipDrawableParser());\n    sDrawableParsers.put(\"android.graphics.drawable.InsetDrawable\", new DrawableParser.InsetDrawableParser());\n    sDrawableParsers.put(\"android.graphics.drawable.ScaleDrawable\", new DrawableParser.ScaleDrawableParser());\n    sDrawableParsers.put(\"android.graphics.drawable.AnimationDrawable\", new DrawableParser.AnimationDrawableParser());\n\n    sSystemDrawableNames.put(DRAWABLE_TYPE_SHAPE, \"android.graphics.drawable.GradientDrawable\");\n    sSystemDrawableNames.put(DRAWABLE_TYPE_SELECTOR, \"android.graphics.drawable.StateListDrawable\");\n    sSystemDrawableNames.put(DRAWABLE_TYPE_LAYER, \"android.graphics.drawable.LayerDrawable\");\n    sSystemDrawableNames.put(DRAWABLE_TYPE_RIPPLE, \"android.graphics.drawable.RippleDrawable\");\n    sSystemDrawableNames.put(DRAWABLE_TYPE_LEVEL, \"android.graphics.drawable.LevelListDrawable\");\n    sSystemDrawableNames.put(DRAWABLE_TYPE_CLIP, \"android.graphics.drawable.ClipDrawable\");\n    sSystemDrawableNames.put(DRAWABLE_TYPE_INSET, \"android.graphics.drawable.InsetDrawable\");\n    sSystemDrawableNames.put(DRAWABLE_TYPE_SCALE, \"android.graphics.drawable.ScaleDrawable\");\n    sSystemDrawableNames.put(DRAWABLE_TYPE_ANIMATION, \"android.graphics.drawable.AnimationDrawable\");\n\n  }\n\n  // Cached drawables with it's ids\n  private static LruCache<String, Drawable> sDrawableCache = new LruCache<>(128);\n  // Cache is enabled at runtime, but at design time, this should be disabled for work properly\n  @SuppressWarnings(\"FieldCanBeLocal\") // This is accessed by layout editor\n  private static boolean sDrawableCacheEnabled = true;\n\n  /**\n   * Try to get a child drawable, if the attrIndex pointing to a specific drawable,\n   * then load it in normal way, if the attrIndex pointing a enum(shape index), try\n   * to create it from the given attrs\n   *\n   * @param ctx       current context\n   * @param a         caller's typed array\n   * @param attrs     attributes from view tag\n   * @param attrIndex attribute index in the typed array\n   * @return a drawable, or a newly created GradientDrawable from attrs, or null\n   */\n  @SuppressWarnings(\"WeakerAccess\")\n  public static Drawable getDrawable(Context ctx, TypedArray a, AttributeSet attrs, int attrIndex) {\n    if (!a.hasValue(attrIndex)) return null;\n    Drawable result = null;\n    ShapeAttrs shapeAttrs = ShapeAttrs.forIndex(a.getInt(attrIndex, -1));\n    if (shapeAttrs != null) {\n      final String className = \"android.graphics.drawable.GradientDrawable\";\n      DrawableParser parser = sDrawableParsers.get(className);\n      ParseRequest request = new ParseRequest(ctx, attrs, sRippleFallback, shapeAttrs, className);\n      if (parser != null) {\n        result = parser.parse(request);\n      }\n    }\n\n    if (result == null) {\n      result = a.getDrawable(attrIndex);\n    }\n    return result;\n  }\n\n  /**\n   * Create a drawable to the specific view with attrs, this method is\n   * used by folivora internally, but in order to support preview for\n   * the views folivora not stubbed, this method becomes publicly\n   *\n   * @param view  view of drawable attached\n   * @param attrs attributes from view tag\n   */\n  static void applyDrawableToView(View view, AttributeSet attrs) {\n    final Context ctx = view.getContext();\n    // Step1 extract attrs\n    TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.Folivora);\n    int drawableType = a.getInt(R.styleable.Folivora_drawableType, -1);\n    String drawableId = a.getString(R.styleable.Folivora_drawableId);\n    String drawableName = a.getString(R.styleable.Folivora_drawableName);\n    int setAs = a.getInt(R.styleable.Folivora_setAs, SET_AS_BACKGROUND);\n    a.recycle();\n    if (drawableType < 0 && drawableId == null && drawableName == null) return;\n    // Step2 lookup cached if available\n    Drawable cached = null;\n    Drawable d = null;\n    if (drawableId != null) {\n      cached = sDrawableCache.get(drawableId);\n      if (cached != null && cached.getConstantState() != null) {\n        cached = cached.getConstantState().newDrawable();\n      }\n    }\n    // Step3 try to create a new drawable and cached it\n    if (!sDrawableCacheEnabled || cached == null) {\n      d = createDrawable(ctx, attrs, drawableType, drawableName);\n      if (d != null && d.getConstantState() != null && drawableId != null) {\n        sDrawableCache.put(drawableId, d);\n      }\n    }\n    d = d == null ? cached : d;\n    if (d == null) return;\n    // Step4 set drawable to view\n    if (setAs == SET_AS_BACKGROUND) {\n      view.setBackground(d);\n    } else if (setAs == SET_AS_SRC && view instanceof ImageView) {\n      ((ImageView) view).setImageDrawable(d);\n    } else if (setAs == SET_AS_FOREGROUND) {\n      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {\n        view.setForeground(d);\n      } else if (view instanceof FrameLayout) {\n        //noinspection RedundantCast\n        ((FrameLayout) view).setForeground(d);\n      } else {\n        Log.w(TAG, \"Folivora can not set foreground to [\" + view.getClass()\n          + \"], Current device platform is lower than MarshMallow\");\n      }\n    }\n  }\n\n  private static Drawable createDrawable(Context ctx, AttributeSet attrs, int drawableType, String drawableName) {\n    String realDrawableName = null;\n    if (drawableType >= 0) {\n      realDrawableName = sSystemDrawableNames.get(drawableType);\n    }\n    if (realDrawableName == null) {\n      realDrawableName = drawableName;\n    }\n    if (realDrawableName == null) return null;\n    DrawableParser parser = sDrawableParsers.get(realDrawableName);\n    if (parser == null && !realDrawableName.startsWith(\"android.graphics.drawable\")) {\n      parser = sReflectiveDrawableParser;\n    }\n    if (parser == null) return null;\n    ParseRequest request = new ParseRequest(ctx, attrs, sRippleFallback, ShapeAttrs.forIndex(0), realDrawableName);\n    return parser.parse(request);\n  }\n\n  /**\n   * Install Folivora's ViewFactory to current context. note that if\n   * you are using AppCompatActivity, this method should called after\n   * your activity's super.onCreate() method, since AppCompatDelegate\n   * will install a {@link LayoutInflater.Factory2} factory2 to this\n   * context.\n   *\n   * @param ctx context to enable folivora support\n   */\n  public static void installViewFactory(Context ctx) {\n    LayoutInflater inflater = LayoutInflater.from(ctx);\n    LayoutInflater.Factory2 factory2 = inflater.getFactory2();\n    if (factory2 instanceof FolivoraViewFactory) return;\n    FolivoraViewFactory viewFactory = new FolivoraViewFactory();\n    viewFactory.mFactory2 = factory2;\n    if (factory2 != null) {\n      FolivoraViewFactory.forceSetFactory2(inflater, viewFactory);\n    } else {\n      inflater.setFactory2(viewFactory);\n    }\n  }\n\n  /**\n   * Wraps the given context, replace the {@link LayoutInflater} inflater\n   * to folivora's implementation, this method does nothing if the given\n   * context is already been wrapped.\n   *\n   * @param newBase new base context\n   * @return a wrapped context\n   */\n  public static Context wrap(final Context newBase) {\n    final LayoutInflater inflater = LayoutInflater.from(newBase);\n    if (inflater instanceof FolivoraInflater) return newBase;\n    return new ContextWrapper(newBase) {\n      private FolivoraInflater mInflater;\n\n      @Override\n      public Object getSystemService(String name) {\n        if (LAYOUT_INFLATER_SERVICE.equals(name)) {\n          if (mInflater == null) {\n            mInflater = new FolivoraInflater(newBase, inflater);\n          }\n          return mInflater;\n        }\n        return super.getSystemService(name);\n      }\n    };\n  }\n\n  /**\n   * Set a fallback to create substitute drawable when the {@link RippleDrawable}\n   * RippleDrawable is not available in current device.\n   *\n   * @param fallback a fallback to create drawable\n   */\n  public static void setRippleFallback(RippleFallback fallback) {\n    sRippleFallback = fallback;\n  }\n\n  public static void registerDrawableParser(Class<? extends Drawable> drawableClass, DrawableParser parser) {\n    final String className = drawableClass.getCanonicalName();\n    sDrawableParsers.put(className, parser);\n  }\n\n  /**\n   * Add a {@link OnViewCreatedListener} listener to folivora, folivora\n   * will notify these listeners when a view is created. this listener\n   * allows you do some extra customization about the inflated views.\n   *\n   * @param l listener to register\n   */\n  public static void addOnViewCreatedListener(OnViewCreatedListener l) {\n    if (sOnViewCreatedListeners == null) {\n      sOnViewCreatedListeners = new ArrayList<>();\n    }\n    sOnViewCreatedListeners.add(l);\n  }\n\n  static void dispatchViewCreated(View view, AttributeSet attrs) {\n    if (sOnViewCreatedListeners != null) {\n      for (OnViewCreatedListener l : sOnViewCreatedListeners) {\n        l.onViewCreated(view, attrs);\n      }\n    }\n  }\n\n  private Folivora() {}\n}\n"
  },
  {
    "path": "folivora/src/main/java/cn/cricin/folivora/FolivoraInflater.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora;\n\nimport android.content.Context;\nimport android.util.AttributeSet;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\n\nimport org.xmlpull.v1.XmlPullParser;\n\n/**\n * A LayoutInflater implementation which delegate all view creation\n * to {@link FolivoraViewFactory}.\n */\nfinal class FolivoraInflater extends LayoutInflater {\n  private static final String[] sClassPrefixList = {\n    \"android.widget.\",\n    \"android.webkit.\",\n    \"android.app.\"\n  };\n\n  FolivoraInflater(Context newContext, LayoutInflater original) {\n    super(original, newContext);\n  }\n\n  @Override\n  public LayoutInflater cloneInContext(Context newContext) {\n    return new FolivoraInflater(newContext, this);\n  }\n\n  @Override\n  public void setFactory(Factory factory) {\n    FolivoraViewFactory f = (FolivoraViewFactory) getFactory2();\n    if (f == null) {\n      super.setFactory2(f = new FolivoraViewFactory());\n    }\n    f.mFactory = factory;\n  }\n\n  @Override\n  public void setFactory2(Factory2 factory2) {\n    FolivoraViewFactory f = (FolivoraViewFactory) getFactory2();\n    if (f == null) {\n      super.setFactory2(f = new FolivoraViewFactory());\n    }\n    f.mFactory2 = factory2;\n  }\n\n  @Override\n  public View inflate(XmlPullParser parser, ViewGroup root, boolean attachToRoot) {\n    Factory2 factory2 = getFactory2();\n    if (factory2 == null) {\n      super.setFactory2(new FolivoraViewFactory());\n    }\n    return super.inflate(parser, root, attachToRoot);\n  }\n\n  /** fallback if FolivoraViewFactory could not create views properly */\n  @Override\n  protected View onCreateView(String name, AttributeSet attrs) throws ClassNotFoundException {\n    for (String prefix : sClassPrefixList) {\n      try {\n        View view = createView(name, prefix, attrs);\n        if (view != null) {\n          return view;\n        }\n      } catch (ClassNotFoundException e) {\n        // In this case we want to let the base class take a crack\n        // at it.\n      }\n    }\n    return super.onCreateView(name, attrs);\n  }\n}\n"
  },
  {
    "path": "folivora/src/main/java/cn/cricin/folivora/FolivoraViewFactory.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora;\n\nimport android.content.Context;\nimport android.util.AttributeSet;\nimport android.util.Log;\nimport android.view.LayoutInflater;\nimport android.view.View;\n\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Field;\nimport java.util.HashMap;\nimport java.util.Map;\n\n/**\n * A view factory takes responsibility of view creation, if the view\n * is created, folivora will create a drawable for it if available.\n */\nfinal class FolivoraViewFactory implements LayoutInflater.Factory2 {\n  private static final String[] sClassPrefixList = {\n    \"android.widget.\",\n    \"android.webkit.\",\n    \"android.app.\",\n    \"android.view.\"\n  };\n\n  private static final Class<?>[] sConstructorSignature = new Class[]{\n    Context.class, AttributeSet.class};\n  private static Object[] sConstructorArgs = new Object[2];\n  private static Map<String, Constructor<? extends View>> sConstructorMap = new HashMap<>();\n\n  LayoutInflater.Factory2 mFactory2;\n  LayoutInflater.Factory mFactory;\n\n  @Override\n  public View onCreateView(String name, Context context, AttributeSet attrs) {\n    return onCreateView(null, name, context, attrs);\n  }\n\n  @Override\n  public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {\n    View view = null;\n    if (mFactory2 != null) {\n      view = mFactory2.onCreateView(parent, name, context, attrs);\n    }\n    if (view == null && mFactory != null) {\n      view = mFactory.onCreateView(name, context, attrs);\n    }\n    if (view == null && name.endsWith(\"ViewStub\")) return null;//fix NPE when creating ViewStub\n\n    if (view == null && name.indexOf('.') != -1) {\n      view = createView(name, context, attrs);\n    }\n\n    if (view == null) {\n      for (String prefix : sClassPrefixList) {\n        view = createView(prefix + name, context, attrs);\n        if (view != null) break;\n      }\n    }\n    if (view != null) {\n      Folivora.applyDrawableToView(view, attrs);\n      Folivora.dispatchViewCreated(view, attrs);\n    }\n    return view;\n  }\n\n  private static View createView(String name, Context ctx, AttributeSet attrs) {\n    Constructor<? extends View> constructor = sConstructorMap.get(name);\n    try {\n      if (constructor == null) {\n        // Class not found in the cache, see if it's real, and try to add it\n        Class<? extends View> clazz = ctx.getClassLoader().loadClass(name).asSubclass(View.class);\n\n        constructor = clazz.getConstructor(sConstructorSignature);\n        sConstructorMap.put(name, constructor);\n      }\n      constructor.setAccessible(true);\n      sConstructorArgs[0] = ctx;\n      sConstructorArgs[1] = attrs;\n      return constructor.newInstance(sConstructorArgs);\n    } catch (Exception e) {\n      // We do not want to catch these, lets return null and let the actual LayoutInflater\n      // try\n      return null;\n    } finally {\n      sConstructorArgs[0] = null;\n      sConstructorArgs[1] = null;\n    }\n  }\n\n  private static LayoutInflater getLayoutInflater(Context context) {\n    return LayoutInflater.from(context);\n  }\n\n  private static boolean sCheckedField;\n  private static Field sLayoutInflaterFactory2Field;\n\n  static void forceSetFactory2(LayoutInflater inflater, LayoutInflater.Factory2 factory) {\n    if (!sCheckedField) {\n      try {\n        //noinspection JavaReflectionMemberAccess\n        sLayoutInflaterFactory2Field = LayoutInflater.class.getDeclaredField(\"mFactory2\");\n        sLayoutInflaterFactory2Field.setAccessible(true);\n      } catch (NoSuchFieldException e) {\n        Log.e(Folivora.TAG, \"forceSetFactory2 Could not find field 'mFactory2' on class \"\n          + inflater.getClass().getName() + \"; Folivora will not available.\", e);\n      }\n      sCheckedField = true;\n    }\n    if (sLayoutInflaterFactory2Field != null) {\n      try {\n        sLayoutInflaterFactory2Field.set(inflater, factory);\n      } catch (Exception e) {\n        Log.e(Folivora.TAG, \"forceSetFactory2 could not set the Factory2 on LayoutInflater \"\n          + inflater + \"; Folivora will not available.\", e);\n      }\n    }\n  }\n\n}\n"
  },
  {
    "path": "folivora/src/main/java/cn/cricin/folivora/OnViewCreatedListener.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora;\n\nimport android.util.AttributeSet;\nimport android.view.View;\n\n/**\n * A listener notified when a view is been created. you can\n * do some customization on the view based on the attrs. eg,\n * change text or typeface of TextView or change src of ImageView\n */\npublic interface OnViewCreatedListener {\n  void onViewCreated(View view, AttributeSet attrs);\n}"
  },
  {
    "path": "folivora/src/main/java/cn/cricin/folivora/ParseRequest.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora;\n\nimport android.content.Context;\nimport android.util.AttributeSet;\n\n/**\n * A ParseRequest holding all information of drawable parsing task\n * each field may be used by different DrawableParsers.\n */\npublic final class ParseRequest {\n  private final Context mContext;\n  private final AttributeSet mAttrs;\n  private final RippleFallback mRippleFallback;\n  private final ShapeAttrs mShapeAttrs;\n  private final String mDrawableClassName;\n\n  /*package*/ParseRequest(Context context,\n               AttributeSet attrs,\n               RippleFallback fallback,\n               ShapeAttrs shapeAttrs,\n               String drawableClassName) {\n    this.mContext = context;\n    this.mAttrs = attrs;\n    this.mRippleFallback = fallback;\n    this.mShapeAttrs = shapeAttrs;\n    this.mDrawableClassName = drawableClassName;\n  }\n\n  /**\n   * @return current inflation context\n   */\n  public Context context() {\n    return mContext;\n  }\n\n  /**\n   * @return attribute retrieved from view tag\n   */\n  public AttributeSet attrs() {\n    return mAttrs;\n  }\n\n  /**\n   * @return a fallback for RippleDrawable\n   */\n  public RippleFallback rippleFallback() {\n    return mRippleFallback;\n  }\n\n  /**\n   * @return attribute information of a shape at different indexes, used by GradientDrawableParser\n   */\n  public ShapeAttrs shapeAttrs() {\n    return mShapeAttrs;\n  }\n\n  /**\n   * @return full qualified class name of drawable to be inflated\n   */\n  public String drawableClassName() {\n    return mDrawableClassName;\n  }\n}"
  },
  {
    "path": "folivora/src/main/java/cn/cricin/folivora/RippleFallback.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora;\n\nimport android.content.Context;\nimport android.content.res.ColorStateList;\nimport android.graphics.drawable.Drawable;\nimport android.os.Build;\n\n/**\n * This class is designed for device platform lowers than\n * {@link Build.VERSION_CODES#LOLLIPOP} lollipop, which RippleDrawable\n * is unavailable, you can create substitution drawable here\n */\npublic interface RippleFallback {\n  /**\n   * Called when the view want a RippleDrawable, but it is unavailable in\n   * current device\n   *\n   * @param color   ripple color, nonnull\n   * @param content content of ripple, nullable\n   * @param mask    ripple mask, nullable\n   * @param ctx     current context\n   * @return a substitute drawable, or null\n   */\n  Drawable onFallback(ColorStateList color, Drawable content,\n                      Drawable mask, Context ctx);\n}"
  },
  {
    "path": "folivora/src/main/java/cn/cricin/folivora/ShapeAttrs.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora;\n\n/**\n * ShapeAttrs represents for a set of shape xml attribute indexes,\n * so we can refactor shape creating method to reduce boilerplate code\n */\nfinal class ShapeAttrs {\n  int[] mAttrStyleable;\n  int mShapeType;\n  int mShapeSolidSize;\n  int mShapeSolidWidth;\n  int mShapeSolidHeight;\n  int mShapeGradientType;\n  int mShapeGradientRadius;\n  int mShapeGradientCenterX;\n  int mShapeGradientCenterY;\n  int mShapeGradientStartColor;\n  int mShapeGradientCenterColor;\n  int mShapeGradientEndColor;\n  int mShapeGradientAngle;\n  int mShapeSolidColor;\n  int mShapeStrokeWidth;\n  int mShapeStrokeColor;\n  int mShapeStrokeDashGap;\n  int mShapeStrokeDashWidth;\n  int mShapeCornerRadius;\n  int mShapeCornerRadiusTopLeft;\n  int mShapeCornerRadiusTopRight;\n  int mShapeCornerRadiusBottomLeft;\n  int mShapeCornerRadiusBottomRight;\n\n  private ShapeAttrs(\n    int[] attrStyleable,\n    int shapeType,\n    int shapeSolidSize,\n    int shapeSolidWidth,\n    int shapeSolidHeight,\n    int shapeGradientType,\n    int shapeGradientRadius,\n    int shapeGradientCenterX,\n    int shapeGradientCenterY,\n    int shapeGradientStartColor,\n    int shapeGradientCenterColor,\n    int shapeGradientEndColor,\n    int shapeGradientAngle,\n    int shapeSolidColor,\n    int shapeStrokeWidth,\n    int shapeStrokeColor,\n    int shapeStrokeDashGap,\n    int shapeStrokeDashWidth,\n    int shapeCornerRadius,\n    int shapeCornerRadiusTopLeft,\n    int shapeCornerRadiusTopRight,\n    int shapeCornerRadiusBottomLeft,\n    int shapeCornerRadiusBottomRight\n  ) {\n    this.mAttrStyleable = attrStyleable;\n    this.mShapeType = shapeType;\n    this.mShapeSolidSize = shapeSolidSize;\n    this.mShapeSolidWidth = shapeSolidWidth;\n    this.mShapeSolidHeight = shapeSolidHeight;\n    this.mShapeGradientType = shapeGradientType;\n    this.mShapeGradientRadius = shapeGradientRadius;\n    this.mShapeGradientCenterX = shapeGradientCenterX;\n    this.mShapeGradientCenterY = shapeGradientCenterY;\n    this.mShapeGradientStartColor = shapeGradientStartColor;\n    this.mShapeGradientCenterColor = shapeGradientCenterColor;\n    this.mShapeGradientEndColor = shapeGradientEndColor;\n    this.mShapeGradientAngle = shapeGradientAngle;\n    this.mShapeSolidColor = shapeSolidColor;\n    this.mShapeStrokeWidth = shapeStrokeWidth;\n    this.mShapeStrokeColor = shapeStrokeColor;\n    this.mShapeStrokeDashGap = shapeStrokeDashGap;\n    this.mShapeStrokeDashWidth = shapeStrokeDashWidth;\n    this.mShapeCornerRadius = shapeCornerRadius;\n    this.mShapeCornerRadiusTopLeft = shapeCornerRadiusTopLeft;\n    this.mShapeCornerRadiusTopRight = shapeCornerRadiusTopRight;\n    this.mShapeCornerRadiusBottomLeft = shapeCornerRadiusBottomLeft;\n    this.mShapeCornerRadiusBottomRight = shapeCornerRadiusBottomRight;\n  }\n\n  private static final ShapeAttrs[] SHAPE_ATTRS_ARRAY = {\n    new ShapeAttrs(\n      R.styleable.Folivora_Shape,\n      R.styleable.Folivora_Shape_shapeType,\n      R.styleable.Folivora_Shape_shapeSolidSize,\n      R.styleable.Folivora_Shape_shapeSolidWidth,\n      R.styleable.Folivora_Shape_shapeSolidHeight,\n      R.styleable.Folivora_Shape_shapeGradientType,\n      R.styleable.Folivora_Shape_shapeGradientRadius,\n      R.styleable.Folivora_Shape_shapeGradientCenterX,\n      R.styleable.Folivora_Shape_shapeGradientCenterY,\n      R.styleable.Folivora_Shape_shapeGradientStartColor,\n      R.styleable.Folivora_Shape_shapeGradientEndColor,\n      R.styleable.Folivora_Shape_shapeGradientCenterColor,\n      R.styleable.Folivora_Shape_shapeGradientAngle,\n      R.styleable.Folivora_Shape_shapeSolidColor,\n      R.styleable.Folivora_Shape_shapeStrokeWidth,\n      R.styleable.Folivora_Shape_shapeStrokeColor,\n      R.styleable.Folivora_Shape_shapeStokeDashGap,\n      R.styleable.Folivora_Shape_shapeStokeDashWidth,\n      R.styleable.Folivora_Shape_shapeCornerRadius,\n      R.styleable.Folivora_Shape_shapeCornerRadiusTopLeft,\n      R.styleable.Folivora_Shape_shapeCornerRadiusTopRight,\n      R.styleable.Folivora_Shape_shapeCornerRadiusBottomRight,\n      R.styleable.Folivora_Shape_shapeCornerRadiusBottomLeft\n    ),\n    new ShapeAttrs(\n      R.styleable.Folivora_Shape1,\n      R.styleable.Folivora_Shape1_shape1Type,\n      R.styleable.Folivora_Shape1_shape1SolidSize,\n      R.styleable.Folivora_Shape1_shape1SolidWidth,\n      R.styleable.Folivora_Shape1_shape1SolidHeight,\n      R.styleable.Folivora_Shape1_shape1GradientType,\n      R.styleable.Folivora_Shape1_shape1GradientRadius,\n      R.styleable.Folivora_Shape1_shape1GradientCenterX,\n      R.styleable.Folivora_Shape1_shape1GradientCenterY,\n      R.styleable.Folivora_Shape1_shape1GradientStartColor,\n      R.styleable.Folivora_Shape1_shape1GradientEndColor,\n      R.styleable.Folivora_Shape1_shape1GradientCenterColor,\n      R.styleable.Folivora_Shape1_shape1GradientAngle,\n      R.styleable.Folivora_Shape1_shape1SolidColor,\n      R.styleable.Folivora_Shape1_shape1StrokeWidth,\n      R.styleable.Folivora_Shape1_shape1StrokeColor,\n      R.styleable.Folivora_Shape1_shape1StokeDashGap,\n      R.styleable.Folivora_Shape1_shape1StokeDashWidth,\n      R.styleable.Folivora_Shape1_shape1CornerRadius,\n      R.styleable.Folivora_Shape1_shape1CornerRadiusTopLeft,\n      R.styleable.Folivora_Shape1_shape1CornerRadiusTopRight,\n      R.styleable.Folivora_Shape1_shape1CornerRadiusBottomRight,\n      R.styleable.Folivora_Shape1_shape1CornerRadiusBottomLeft\n    ),\n    new ShapeAttrs(\n      R.styleable.Folivora_Shape2,\n      R.styleable.Folivora_Shape2_shape2Type,\n      R.styleable.Folivora_Shape2_shape2SolidSize,\n      R.styleable.Folivora_Shape2_shape2SolidWidth,\n      R.styleable.Folivora_Shape2_shape2SolidHeight,\n      R.styleable.Folivora_Shape2_shape2GradientType,\n      R.styleable.Folivora_Shape2_shape2GradientRadius,\n      R.styleable.Folivora_Shape2_shape2GradientCenterX,\n      R.styleable.Folivora_Shape2_shape2GradientCenterY,\n      R.styleable.Folivora_Shape2_shape2GradientStartColor,\n      R.styleable.Folivora_Shape2_shape2GradientEndColor,\n      R.styleable.Folivora_Shape2_shape2GradientCenterColor,\n      R.styleable.Folivora_Shape2_shape2GradientAngle,\n      R.styleable.Folivora_Shape2_shape2SolidColor,\n      R.styleable.Folivora_Shape2_shape2StrokeWidth,\n      R.styleable.Folivora_Shape2_shape2StrokeColor,\n      R.styleable.Folivora_Shape2_shape2StokeDashGap,\n      R.styleable.Folivora_Shape2_shape2StokeDashWidth,\n      R.styleable.Folivora_Shape2_shape2CornerRadius,\n      R.styleable.Folivora_Shape2_shape2CornerRadiusTopLeft,\n      R.styleable.Folivora_Shape2_shape2CornerRadiusTopRight,\n      R.styleable.Folivora_Shape2_shape2CornerRadiusBottomRight,\n      R.styleable.Folivora_Shape2_shape2CornerRadiusBottomLeft\n    ),\n    new ShapeAttrs(\n      R.styleable.Folivora_Shape3,\n      R.styleable.Folivora_Shape3_shape3Type,\n      R.styleable.Folivora_Shape3_shape3SolidSize,\n      R.styleable.Folivora_Shape3_shape3SolidWidth,\n      R.styleable.Folivora_Shape3_shape3SolidHeight,\n      R.styleable.Folivora_Shape3_shape3GradientType,\n      R.styleable.Folivora_Shape3_shape3GradientRadius,\n      R.styleable.Folivora_Shape3_shape3GradientCenterX,\n      R.styleable.Folivora_Shape3_shape3GradientCenterY,\n      R.styleable.Folivora_Shape3_shape3GradientStartColor,\n      R.styleable.Folivora_Shape3_shape3GradientEndColor,\n      R.styleable.Folivora_Shape3_shape3GradientCenterColor,\n      R.styleable.Folivora_Shape3_shape3GradientAngle,\n      R.styleable.Folivora_Shape3_shape3SolidColor,\n      R.styleable.Folivora_Shape3_shape3StrokeWidth,\n      R.styleable.Folivora_Shape3_shape3StrokeColor,\n      R.styleable.Folivora_Shape3_shape3StokeDashGap,\n      R.styleable.Folivora_Shape3_shape3StokeDashWidth,\n      R.styleable.Folivora_Shape3_shape3CornerRadius,\n      R.styleable.Folivora_Shape3_shape3CornerRadiusTopLeft,\n      R.styleable.Folivora_Shape3_shape3CornerRadiusTopRight,\n      R.styleable.Folivora_Shape3_shape3CornerRadiusBottomRight,\n      R.styleable.Folivora_Shape3_shape3CornerRadiusBottomLeft\n    ),\n    new ShapeAttrs(\n      R.styleable.Folivora_Shape4,\n      R.styleable.Folivora_Shape4_shape4Type,\n      R.styleable.Folivora_Shape4_shape4SolidSize,\n      R.styleable.Folivora_Shape4_shape4SolidWidth,\n      R.styleable.Folivora_Shape4_shape4SolidHeight,\n      R.styleable.Folivora_Shape4_shape4GradientType,\n      R.styleable.Folivora_Shape4_shape4GradientRadius,\n      R.styleable.Folivora_Shape4_shape4GradientCenterX,\n      R.styleable.Folivora_Shape4_shape4GradientCenterY,\n      R.styleable.Folivora_Shape4_shape4GradientStartColor,\n      R.styleable.Folivora_Shape4_shape4GradientEndColor,\n      R.styleable.Folivora_Shape4_shape4GradientCenterColor,\n      R.styleable.Folivora_Shape4_shape4GradientAngle,\n      R.styleable.Folivora_Shape4_shape4SolidColor,\n      R.styleable.Folivora_Shape4_shape4StrokeWidth,\n      R.styleable.Folivora_Shape4_shape4StrokeColor,\n      R.styleable.Folivora_Shape4_shape4StokeDashGap,\n      R.styleable.Folivora_Shape4_shape4StokeDashWidth,\n      R.styleable.Folivora_Shape4_shape4CornerRadius,\n      R.styleable.Folivora_Shape4_shape4CornerRadiusTopLeft,\n      R.styleable.Folivora_Shape4_shape4CornerRadiusTopRight,\n      R.styleable.Folivora_Shape4_shape4CornerRadiusBottomRight,\n      R.styleable.Folivora_Shape4_shape4CornerRadiusBottomLeft\n    )\n  };\n\n  static ShapeAttrs forIndex(int index) {\n    if (index < 0 || index > 4) {\n      return null;\n    } else {\n      return SHAPE_ATTRS_ARRAY[index];\n    }\n  }\n}"
  },
  {
    "path": "folivora/src/main/res/values/attrs.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n  * Copyright (C) 2019 Cricin\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\n<resources>\n\n  <!--shape-->\n  <declare-styleable name=\"Folivora_Shape\">\n    <attr name=\"shapeType\" format=\"enum\">\n      <enum name=\"rectangle\" value=\"0\"/>\n      <enum name=\"oval\" value=\"1\"/>\n      <enum name=\"line\" value=\"2\"/>\n      <enum name=\"ring\" value=\"3\"/>\n    </attr>\n\n    <attr name=\"shapeSolidSize\" format=\"dimension\"/>\n    <attr name=\"shapeSolidWidth\" format=\"dimension\"/>\n    <attr name=\"shapeSolidHeight\" format=\"dimension\"/>\n    <attr name=\"shapeSolidColor\" format=\"color\"/>\n\n    <attr name=\"shapeStrokeWidth\" format=\"dimension\"/>\n    <attr name=\"shapeStrokeColor\" format=\"color\"/>\n    <attr name=\"shapeStokeDashWidth\" format=\"dimension\"/>\n    <attr name=\"shapeStokeDashGap\" format=\"dimension\"/>\n\n    <attr name=\"shapeCornerRadius\" format=\"dimension\"/>\n    <attr name=\"shapeCornerRadiusTopLeft\" format=\"dimension\"/>\n    <attr name=\"shapeCornerRadiusTopRight\" format=\"dimension\"/>\n    <attr name=\"shapeCornerRadiusBottomLeft\" format=\"dimension\"/>\n    <attr name=\"shapeCornerRadiusBottomRight\" format=\"dimension\"/>\n\n    <attr name=\"shapeGradientType\" format=\"enum\">\n      <enum name=\"linear\" value=\"0\"/>\n      <enum name=\"radial\" value=\"1\"/>\n      <enum name=\"sweep\" value=\"2\"/>\n    </attr>\n    <attr name=\"shapeGradientAngle\" format=\"enum\">\n      <enum name=\"tb\" value=\"0\"/>\n      <enum name=\"tr_bl\" value=\"1\"/>\n      <enum name=\"rl\" value=\"2\"/>\n      <enum name=\"br_tl\" value=\"3\"/>\n      <enum name=\"bt\" value=\"4\"/>\n      <enum name=\"bl_tr\" value=\"5\"/>\n      <enum name=\"lr\" value=\"6\"/>\n      <enum name=\"tl_br\" value=\"7\"/>\n\n    </attr>\n    <attr name=\"shapeGradientStartColor\" format=\"color\"/>\n    <attr name=\"shapeGradientCenterColor\" format=\"color\"/>\n    <attr name=\"shapeGradientEndColor\" format=\"color\"/>\n    <attr name=\"shapeGradientRadius\" format=\"dimension\"/>\n    <attr name=\"shapeGradientCenterX\" format=\"float\"/>\n    <attr name=\"shapeGradientCenterY\" format=\"float\"/>\n\n  </declare-styleable>\n\n  <!--shape1-->\n  <declare-styleable name=\"Folivora_Shape1\">\n    <attr name=\"shape1Type\" format=\"enum\">\n      <enum name=\"rectangle\" value=\"0\"/>\n      <enum name=\"oval\" value=\"1\"/>\n      <enum name=\"line\" value=\"2\"/>\n      <enum name=\"ring\" value=\"3\"/>\n    </attr>\n\n    <attr name=\"shape1SolidSize\" format=\"dimension\"/>\n    <attr name=\"shape1SolidWidth\" format=\"dimension\"/>\n    <attr name=\"shape1SolidHeight\" format=\"dimension\"/>\n    <attr name=\"shape1SolidColor\" format=\"color\"/>\n\n    <attr name=\"shape1StrokeWidth\" format=\"dimension\"/>\n    <attr name=\"shape1StrokeColor\" format=\"color\"/>\n    <attr name=\"shape1StokeDashWidth\" format=\"dimension\"/>\n    <attr name=\"shape1StokeDashGap\" format=\"dimension\"/>\n\n    <attr name=\"shape1CornerRadius\" format=\"dimension\"/>\n    <attr name=\"shape1CornerRadiusTopLeft\" format=\"dimension\"/>\n    <attr name=\"shape1CornerRadiusTopRight\" format=\"dimension\"/>\n    <attr name=\"shape1CornerRadiusBottomLeft\" format=\"dimension\"/>\n    <attr name=\"shape1CornerRadiusBottomRight\" format=\"dimension\"/>\n\n    <attr name=\"shape1GradientType\" format=\"enum\">\n      <enum name=\"linear\" value=\"0\"/>\n      <enum name=\"radial\" value=\"1\"/>\n      <enum name=\"sweep\" value=\"2\"/>\n    </attr>\n    <attr name=\"shape1GradientAngle\" format=\"enum\">\n      <enum name=\"tb\" value=\"0\"/>\n      <enum name=\"tr_bl\" value=\"1\"/>\n      <enum name=\"rl\" value=\"2\"/>\n      <enum name=\"br_tl\" value=\"3\"/>\n      <enum name=\"bt\" value=\"4\"/>\n      <enum name=\"bl_tr\" value=\"5\"/>\n      <enum name=\"lr\" value=\"6\"/>\n      <enum name=\"tl_br\" value=\"7\"/>\n\n    </attr>\n    <attr name=\"shape1GradientStartColor\" format=\"color\"/>\n    <attr name=\"shape1GradientCenterColor\" format=\"color\"/>\n    <attr name=\"shape1GradientEndColor\" format=\"color\"/>\n    <attr name=\"shape1GradientRadius\" format=\"dimension\"/>\n    <attr name=\"shape1GradientCenterX\" format=\"float\"/>\n    <attr name=\"shape1GradientCenterY\" format=\"float\"/>\n\n  </declare-styleable>\n\n  <!--shape2-->\n  <declare-styleable name=\"Folivora_Shape2\">\n    <attr name=\"shape2Type\" format=\"enum\">\n      <enum name=\"rectangle\" value=\"0\"/>\n      <enum name=\"oval\" value=\"1\"/>\n      <enum name=\"line\" value=\"2\"/>\n      <enum name=\"ring\" value=\"3\"/>\n    </attr>\n\n    <attr name=\"shape2SolidSize\" format=\"dimension\"/>\n    <attr name=\"shape2SolidWidth\" format=\"dimension\"/>\n    <attr name=\"shape2SolidHeight\" format=\"dimension\"/>\n    <attr name=\"shape2SolidColor\" format=\"color\"/>\n\n    <attr name=\"shape2StrokeWidth\" format=\"dimension\"/>\n    <attr name=\"shape2StrokeColor\" format=\"color\"/>\n    <attr name=\"shape2StokeDashWidth\" format=\"dimension\"/>\n    <attr name=\"shape2StokeDashGap\" format=\"dimension\"/>\n\n    <attr name=\"shape2CornerRadius\" format=\"dimension\"/>\n    <attr name=\"shape2CornerRadiusTopLeft\" format=\"dimension\"/>\n    <attr name=\"shape2CornerRadiusTopRight\" format=\"dimension\"/>\n    <attr name=\"shape2CornerRadiusBottomLeft\" format=\"dimension\"/>\n    <attr name=\"shape2CornerRadiusBottomRight\" format=\"dimension\"/>\n\n    <attr name=\"shape2GradientType\" format=\"enum\">\n      <enum name=\"linear\" value=\"0\"/>\n      <enum name=\"radial\" value=\"1\"/>\n      <enum name=\"sweep\" value=\"2\"/>\n    </attr>\n    <attr name=\"shape2GradientAngle\" format=\"enum\">\n      <enum name=\"tb\" value=\"0\"/>\n      <enum name=\"tr_bl\" value=\"1\"/>\n      <enum name=\"rl\" value=\"2\"/>\n      <enum name=\"br_tl\" value=\"3\"/>\n      <enum name=\"bt\" value=\"4\"/>\n      <enum name=\"bl_tr\" value=\"5\"/>\n      <enum name=\"lr\" value=\"6\"/>\n      <enum name=\"tl_br\" value=\"7\"/>\n\n    </attr>\n    <attr name=\"shape2GradientStartColor\" format=\"color\"/>\n    <attr name=\"shape2GradientCenterColor\" format=\"color\"/>\n    <attr name=\"shape2GradientEndColor\" format=\"color\"/>\n    <attr name=\"shape2GradientRadius\" format=\"dimension\"/>\n    <attr name=\"shape2GradientCenterX\" format=\"float\"/>\n    <attr name=\"shape2GradientCenterY\" format=\"float\"/>\n\n  </declare-styleable>\n\n  <!--shape3-->\n  <declare-styleable name=\"Folivora_Shape3\">\n    <attr name=\"shape3Type\" format=\"enum\">\n      <enum name=\"rectangle\" value=\"0\"/>\n      <enum name=\"oval\" value=\"1\"/>\n      <enum name=\"line\" value=\"2\"/>\n      <enum name=\"ring\" value=\"3\"/>\n    </attr>\n\n    <attr name=\"shape3SolidSize\" format=\"dimension\"/>\n    <attr name=\"shape3SolidWidth\" format=\"dimension\"/>\n    <attr name=\"shape3SolidHeight\" format=\"dimension\"/>\n    <attr name=\"shape3SolidColor\" format=\"color\"/>\n\n    <attr name=\"shape3StrokeWidth\" format=\"dimension\"/>\n    <attr name=\"shape3StrokeColor\" format=\"color\"/>\n    <attr name=\"shape3StokeDashWidth\" format=\"dimension\"/>\n    <attr name=\"shape3StokeDashGap\" format=\"dimension\"/>\n\n    <attr name=\"shape3CornerRadius\" format=\"dimension\"/>\n    <attr name=\"shape3CornerRadiusTopLeft\" format=\"dimension\"/>\n    <attr name=\"shape3CornerRadiusTopRight\" format=\"dimension\"/>\n    <attr name=\"shape3CornerRadiusBottomLeft\" format=\"dimension\"/>\n    <attr name=\"shape3CornerRadiusBottomRight\" format=\"dimension\"/>\n\n    <attr name=\"shape3GradientType\" format=\"enum\">\n      <enum name=\"linear\" value=\"0\"/>\n      <enum name=\"radial\" value=\"1\"/>\n      <enum name=\"sweep\" value=\"2\"/>\n    </attr>\n    <attr name=\"shape3GradientAngle\" format=\"enum\">\n      <enum name=\"tb\" value=\"0\"/>\n      <enum name=\"tr_bl\" value=\"1\"/>\n      <enum name=\"rl\" value=\"2\"/>\n      <enum name=\"br_tl\" value=\"3\"/>\n      <enum name=\"bt\" value=\"4\"/>\n      <enum name=\"bl_tr\" value=\"5\"/>\n      <enum name=\"lr\" value=\"6\"/>\n      <enum name=\"tl_br\" value=\"7\"/>\n\n    </attr>\n    <attr name=\"shape3GradientStartColor\" format=\"color\"/>\n    <attr name=\"shape3GradientCenterColor\" format=\"color\"/>\n    <attr name=\"shape3GradientEndColor\" format=\"color\"/>\n    <attr name=\"shape3GradientRadius\" format=\"dimension\"/>\n    <attr name=\"shape3GradientCenterX\" format=\"float\"/>\n    <attr name=\"shape3GradientCenterY\" format=\"float\"/>\n\n  </declare-styleable>\n\n  <!--shape4-->\n  <declare-styleable name=\"Folivora_Shape4\">\n    <attr name=\"shape4Type\" format=\"enum\">\n      <enum name=\"rectangle\" value=\"0\"/>\n      <enum name=\"oval\" value=\"1\"/>\n      <enum name=\"line\" value=\"2\"/>\n      <enum name=\"ring\" value=\"3\"/>\n    </attr>\n\n    <attr name=\"shape4SolidSize\" format=\"dimension\"/>\n    <attr name=\"shape4SolidWidth\" format=\"dimension\"/>\n    <attr name=\"shape4SolidHeight\" format=\"dimension\"/>\n    <attr name=\"shape4SolidColor\" format=\"color\"/>\n\n    <attr name=\"shape4StrokeWidth\" format=\"dimension\"/>\n    <attr name=\"shape4StrokeColor\" format=\"color\"/>\n    <attr name=\"shape4StokeDashWidth\" format=\"dimension\"/>\n    <attr name=\"shape4StokeDashGap\" format=\"dimension\"/>\n\n    <attr name=\"shape4CornerRadius\" format=\"dimension\"/>\n    <attr name=\"shape4CornerRadiusTopLeft\" format=\"dimension\"/>\n    <attr name=\"shape4CornerRadiusTopRight\" format=\"dimension\"/>\n    <attr name=\"shape4CornerRadiusBottomLeft\" format=\"dimension\"/>\n    <attr name=\"shape4CornerRadiusBottomRight\" format=\"dimension\"/>\n\n    <attr name=\"shape4GradientType\" format=\"enum\">\n      <enum name=\"linear\" value=\"0\"/>\n      <enum name=\"radial\" value=\"1\"/>\n      <enum name=\"sweep\" value=\"2\"/>\n    </attr>\n    <attr name=\"shape4GradientAngle\" format=\"enum\">\n      <enum name=\"tb\" value=\"0\"/>\n      <enum name=\"tr_bl\" value=\"1\"/>\n      <enum name=\"rl\" value=\"2\"/>\n      <enum name=\"br_tl\" value=\"3\"/>\n      <enum name=\"bt\" value=\"4\"/>\n      <enum name=\"bl_tr\" value=\"5\"/>\n      <enum name=\"lr\" value=\"6\"/>\n      <enum name=\"tl_br\" value=\"7\"/>\n\n    </attr>\n    <attr name=\"shape4GradientStartColor\" format=\"color\"/>\n    <attr name=\"shape4GradientCenterColor\" format=\"color\"/>\n    <attr name=\"shape4GradientEndColor\" format=\"color\"/>\n    <attr name=\"shape4GradientRadius\" format=\"dimension\"/>\n    <attr name=\"shape4GradientCenterX\" format=\"float\"/>\n    <attr name=\"shape4GradientCenterY\" format=\"float\"/>\n\n  </declare-styleable>\n\n  <!--selector-->\n  <declare-styleable name=\"Folivora_Selector\">\n    <attr name=\"selectorStateFirst\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorStateMiddle\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorStateLast\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorStateActive\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorStateActivated\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorStateAccelerate\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorStateChecked\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorStateCheckable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorStateEnabled\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorStateFocused\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorStatePressed\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorStateSelected\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorStateSingle\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorStateHovered\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorStateWindowFocused\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorStateNormal\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorItem0States\" format=\"flags\">\n      <flag name=\"first\" value=\"0x1\"/>\n      <flag name=\"firstNot\" value=\"0x2\"/>\n      <flag name=\"middle\" value=\"0x4\"/>\n      <flag name=\"middleNot\" value=\"0x8\"/>\n      <flag name=\"last\" value=\"0x10\"/>\n      <flag name=\"lastNot\" value=\"0x20\"/>\n      <flag name=\"active\" value=\"0x40\"/>\n      <flag name=\"activeNot\" value=\"0x80\"/>\n      <flag name=\"activated\" value=\"0x100\"/>\n      <flag name=\"activatedNot\" value=\"0x200\"/>\n      <flag name=\"accelerate\" value=\"0x400\"/>\n      <flag name=\"accelerateNot\" value=\"0x800\"/>\n      <flag name=\"checked\" value=\"0x1000\"/>\n      <flag name=\"checkedNot\" value=\"0x2000\"/>\n      <flag name=\"checkable\" value=\"0x4000\"/>\n      <flag name=\"checkableNot\" value=\"0x8000\"/>\n      <flag name=\"enabled\" value=\"0x10000\"/>\n      <flag name=\"enableNot\" value=\"0x20000\"/>\n      <flag name=\"focused\" value=\"0x40000\"/>\n      <flag name=\"focusedNot\" value=\"0x80000\"/>\n      <flag name=\"pressed\" value=\"0x100000\"/>\n      <flag name=\"pressedNot\" value=\"0x200000\"/>\n      <flag name=\"selected\" value=\"0x400000\"/>\n      <flag name=\"selectedNot\" value=\"0x800000\"/>\n      <flag name=\"single\" value=\"0x1000000\"/>\n      <flag name=\"singleNot\" value=\"0x2000000\"/>\n      <flag name=\"hovered\" value=\"0x4000000\"/>\n      <flag name=\"hoveredNot\" value=\"0x8000000\"/>\n      <flag name=\"windowFocused\" value=\"0x10000000\"/>\n      <flag name=\"windowFocusedNot\" value=\"0x20000000\"/>\n    </attr>\n    <attr name=\"selectorItem0Drawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorItem1States\" format=\"flags\">\n      <flag name=\"first\" value=\"0x1\"/>\n      <flag name=\"firstNot\" value=\"0x2\"/>\n      <flag name=\"middle\" value=\"0x4\"/>\n      <flag name=\"middleNot\" value=\"0x8\"/>\n      <flag name=\"last\" value=\"0x10\"/>\n      <flag name=\"lastNot\" value=\"0x20\"/>\n      <flag name=\"active\" value=\"0x40\"/>\n      <flag name=\"activeNot\" value=\"0x80\"/>\n      <flag name=\"activated\" value=\"0x100\"/>\n      <flag name=\"activatedNot\" value=\"0x200\"/>\n      <flag name=\"accelerate\" value=\"0x400\"/>\n      <flag name=\"accelerateNot\" value=\"0x800\"/>\n      <flag name=\"checked\" value=\"0x1000\"/>\n      <flag name=\"checkedNot\" value=\"0x2000\"/>\n      <flag name=\"checkable\" value=\"0x4000\"/>\n      <flag name=\"checkableNot\" value=\"0x8000\"/>\n      <flag name=\"enabled\" value=\"0x10000\"/>\n      <flag name=\"enableNot\" value=\"0x20000\"/>\n      <flag name=\"focused\" value=\"0x40000\"/>\n      <flag name=\"focusedNot\" value=\"0x80000\"/>\n      <flag name=\"pressed\" value=\"0x100000\"/>\n      <flag name=\"pressedNot\" value=\"0x200000\"/>\n      <flag name=\"selected\" value=\"0x400000\"/>\n      <flag name=\"selectedNot\" value=\"0x800000\"/>\n      <flag name=\"single\" value=\"0x1000000\"/>\n      <flag name=\"singleNot\" value=\"0x2000000\"/>\n      <flag name=\"hovered\" value=\"0x4000000\"/>\n      <flag name=\"hoveredNot\" value=\"0x8000000\"/>\n      <flag name=\"windowFocused\" value=\"0x10000000\"/>\n      <flag name=\"windowFocusedNot\" value=\"0x20000000\"/>\n    </attr>\n    <attr name=\"selectorItem1Drawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorItem2States\" format=\"flags\">\n      <flag name=\"first\" value=\"0x1\"/>\n      <flag name=\"firstNot\" value=\"0x2\"/>\n      <flag name=\"middle\" value=\"0x4\"/>\n      <flag name=\"middleNot\" value=\"0x8\"/>\n      <flag name=\"last\" value=\"0x10\"/>\n      <flag name=\"lastNot\" value=\"0x20\"/>\n      <flag name=\"active\" value=\"0x40\"/>\n      <flag name=\"activeNot\" value=\"0x80\"/>\n      <flag name=\"activated\" value=\"0x100\"/>\n      <flag name=\"activatedNot\" value=\"0x200\"/>\n      <flag name=\"accelerate\" value=\"0x400\"/>\n      <flag name=\"accelerateNot\" value=\"0x800\"/>\n      <flag name=\"checked\" value=\"0x1000\"/>\n      <flag name=\"checkedNot\" value=\"0x2000\"/>\n      <flag name=\"checkable\" value=\"0x4000\"/>\n      <flag name=\"checkableNot\" value=\"0x8000\"/>\n      <flag name=\"enabled\" value=\"0x10000\"/>\n      <flag name=\"enableNot\" value=\"0x20000\"/>\n      <flag name=\"focused\" value=\"0x40000\"/>\n      <flag name=\"focusedNot\" value=\"0x80000\"/>\n      <flag name=\"pressed\" value=\"0x100000\"/>\n      <flag name=\"pressedNot\" value=\"0x200000\"/>\n      <flag name=\"selected\" value=\"0x400000\"/>\n      <flag name=\"selectedNot\" value=\"0x800000\"/>\n      <flag name=\"single\" value=\"0x1000000\"/>\n      <flag name=\"singleNot\" value=\"0x2000000\"/>\n      <flag name=\"hovered\" value=\"0x4000000\"/>\n      <flag name=\"hoveredNot\" value=\"0x8000000\"/>\n      <flag name=\"windowFocused\" value=\"0x10000000\"/>\n      <flag name=\"windowFocusedNot\" value=\"0x20000000\"/>\n    </attr>\n    <attr name=\"selectorItem2Drawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorItem3States\" format=\"flags\">\n      <flag name=\"first\" value=\"0x1\"/>\n      <flag name=\"firstNot\" value=\"0x2\"/>\n      <flag name=\"middle\" value=\"0x4\"/>\n      <flag name=\"middleNot\" value=\"0x8\"/>\n      <flag name=\"last\" value=\"0x10\"/>\n      <flag name=\"lastNot\" value=\"0x20\"/>\n      <flag name=\"active\" value=\"0x40\"/>\n      <flag name=\"activeNot\" value=\"0x80\"/>\n      <flag name=\"activated\" value=\"0x100\"/>\n      <flag name=\"activatedNot\" value=\"0x200\"/>\n      <flag name=\"accelerate\" value=\"0x400\"/>\n      <flag name=\"accelerateNot\" value=\"0x800\"/>\n      <flag name=\"checked\" value=\"0x1000\"/>\n      <flag name=\"checkedNot\" value=\"0x2000\"/>\n      <flag name=\"checkable\" value=\"0x4000\"/>\n      <flag name=\"checkableNot\" value=\"0x8000\"/>\n      <flag name=\"enabled\" value=\"0x10000\"/>\n      <flag name=\"enableNot\" value=\"0x20000\"/>\n      <flag name=\"focused\" value=\"0x40000\"/>\n      <flag name=\"focusedNot\" value=\"0x80000\"/>\n      <flag name=\"pressed\" value=\"0x100000\"/>\n      <flag name=\"pressedNot\" value=\"0x200000\"/>\n      <flag name=\"selected\" value=\"0x400000\"/>\n      <flag name=\"selectedNot\" value=\"0x800000\"/>\n      <flag name=\"single\" value=\"0x1000000\"/>\n      <flag name=\"singleNot\" value=\"0x2000000\"/>\n      <flag name=\"hovered\" value=\"0x4000000\"/>\n      <flag name=\"hoveredNot\" value=\"0x8000000\"/>\n      <flag name=\"windowFocused\" value=\"0x10000000\"/>\n      <flag name=\"windowFocusedNot\" value=\"0x20000000\"/>\n    </attr>\n    <attr name=\"selectorItem3Drawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"selectorItem4States\" format=\"flags\">\n      <flag name=\"first\" value=\"0x1\"/>\n      <flag name=\"firstNot\" value=\"0x2\"/>\n      <flag name=\"middle\" value=\"0x4\"/>\n      <flag name=\"middleNot\" value=\"0x8\"/>\n      <flag name=\"last\" value=\"0x10\"/>\n      <flag name=\"lastNot\" value=\"0x20\"/>\n      <flag name=\"active\" value=\"0x40\"/>\n      <flag name=\"activeNot\" value=\"0x80\"/>\n      <flag name=\"activated\" value=\"0x100\"/>\n      <flag name=\"activatedNot\" value=\"0x200\"/>\n      <flag name=\"accelerate\" value=\"0x400\"/>\n      <flag name=\"accelerateNot\" value=\"0x800\"/>\n      <flag name=\"checked\" value=\"0x1000\"/>\n      <flag name=\"checkedNot\" value=\"0x2000\"/>\n      <flag name=\"checkable\" value=\"0x4000\"/>\n      <flag name=\"checkableNot\" value=\"0x8000\"/>\n      <flag name=\"enabled\" value=\"0x10000\"/>\n      <flag name=\"enableNot\" value=\"0x20000\"/>\n      <flag name=\"focused\" value=\"0x40000\"/>\n      <flag name=\"focusedNot\" value=\"0x80000\"/>\n      <flag name=\"pressed\" value=\"0x100000\"/>\n      <flag name=\"pressedNot\" value=\"0x200000\"/>\n      <flag name=\"selected\" value=\"0x400000\"/>\n      <flag name=\"selectedNot\" value=\"0x800000\"/>\n      <flag name=\"single\" value=\"0x1000000\"/>\n      <flag name=\"singleNot\" value=\"0x2000000\"/>\n      <flag name=\"hovered\" value=\"0x4000000\"/>\n      <flag name=\"hoveredNot\" value=\"0x8000000\"/>\n      <flag name=\"windowFocused\" value=\"0x10000000\"/>\n      <flag name=\"windowFocusedNot\" value=\"0x20000000\"/>\n    </attr>\n    <attr name=\"selectorItem4Drawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n  </declare-styleable>\n\n  <!--layer-list-->\n  <declare-styleable name=\"Folivora_Layer\">\n    <attr name=\"layerItem0Insets\" format=\"dimension\"/>\n    <attr name=\"layerItem0Left\" format=\"dimension\"/>\n    <attr name=\"layerItem0Top\" format=\"dimension\"/>\n    <attr name=\"layerItem0Right\" format=\"dimension\"/>\n    <attr name=\"layerItem0Bottom\" format=\"dimension\"/>\n    <attr name=\"layerItem0Drawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n\n    <attr name=\"layerItem1Insets\" format=\"dimension\"/>\n    <attr name=\"layerItem1Left\" format=\"dimension\"/>\n    <attr name=\"layerItem1Top\" format=\"dimension\"/>\n    <attr name=\"layerItem1Right\" format=\"dimension\"/>\n    <attr name=\"layerItem1Bottom\" format=\"dimension\"/>\n    <attr name=\"layerItem1Drawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n\n    <attr name=\"layerItem2Insets\" format=\"dimension\"/>\n    <attr name=\"layerItem2Left\" format=\"dimension\"/>\n    <attr name=\"layerItem2Top\" format=\"dimension\"/>\n    <attr name=\"layerItem2Right\" format=\"dimension\"/>\n    <attr name=\"layerItem2Bottom\" format=\"dimension\"/>\n    <attr name=\"layerItem2Drawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n\n    <attr name=\"layerItem3Insets\" format=\"dimension\"/>\n    <attr name=\"layerItem3Left\" format=\"dimension\"/>\n    <attr name=\"layerItem3Top\" format=\"dimension\"/>\n    <attr name=\"layerItem3Right\" format=\"dimension\"/>\n    <attr name=\"layerItem3Bottom\" format=\"dimension\"/>\n    <attr name=\"layerItem3Drawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n\n    <attr name=\"layerItem4Insets\" format=\"dimension\"/>\n    <attr name=\"layerItem4Left\" format=\"dimension\"/>\n    <attr name=\"layerItem4Top\" format=\"dimension\"/>\n    <attr name=\"layerItem4Right\" format=\"dimension\"/>\n    <attr name=\"layerItem4Bottom\" format=\"dimension\"/>\n    <attr name=\"layerItem4Drawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n  </declare-styleable>\n\n  <!--ripple only worked on Lollipop or higher-->\n  <declare-styleable name=\"Folivora_Ripple\">\n    <attr name=\"rippleColor\" format=\"color\"/>\n    <attr name=\"rippleMask\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"rippleContent\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n  </declare-styleable>\n\n  <declare-styleable name=\"Folivora\">\n    <attr name=\"setAs\" format=\"enum\">\n      <enum name=\"background\" value=\"0\"/>\n      <enum name=\"src\" value=\"1\"/>\n      <enum name=\"foreground\" value=\"2\"/>\n    </attr>\n    <attr name=\"drawableType\" format=\"enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"selector\" value=\"1\"/>\n      <enum name=\"layer_list\" value=\"2\"/>\n      <enum name=\"ripple\" value=\"3\"/>\n      <enum name=\"level_list\" value=\"4\"/>\n      <enum name=\"clip\" value=\"5\"/>\n      <enum name=\"inset\" value=\"6\"/>\n      <enum name=\"scale\" value=\"7\"/>\n      <enum name=\"animation\" value=\"8\"/>\n    </attr>\n    <attr name=\"drawableName\" format=\"string\"/>\n    <attr name=\"drawableId\" format=\"string\"/>\n  </declare-styleable>\n\n  <!--clip-->\n  <declare-styleable name=\"Folivora_Clip\">\n    <attr name=\"clipOrientation\" format=\"enum\">\n      <enum name=\"horizontal\" value=\"1\"/>\n      <enum name=\"vertical\" value=\"2\"/>\n    </attr>\n    <attr name=\"clipDrawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"clipLevel\" format=\"integer\"/>\n    <!-- Keep sync with android.view.Gravity -->\n    <attr name=\"clipGravity\" format=\"flags\">\n      <!-- Push object to the top of its container, not changing its size. -->\n      <flag name=\"top\" value=\"0x30\" />\n      <!-- Push object to the bottom of its container, not changing its size. -->\n      <flag name=\"bottom\" value=\"0x50\" />\n      <!-- Push object to the left of its container, not changing its size. -->\n      <flag name=\"left\" value=\"0x03\" />\n      <!-- Push object to the right of its container, not changing its size. -->\n      <flag name=\"right\" value=\"0x05\" />\n      <!-- Place object in the vertical center of its container, not changing its size. -->\n      <flag name=\"center_vertical\" value=\"0x10\" />\n      <!-- Grow the vertical size of the object if needed so it completely fills its container. -->\n      <flag name=\"fill_vertical\" value=\"0x70\" />\n      <!-- Place object in the horizontal center of its container, not changing its size. -->\n      <flag name=\"center_horizontal\" value=\"0x01\" />\n      <!-- Grow the horizontal size of the object if needed so it completely fills its container. -->\n      <flag name=\"fill_horizontal\" value=\"0x07\" />\n      <!-- Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. -->\n      <flag name=\"center\" value=\"0x11\" />\n      <!-- Grow the horizontal and vertical size of the object if needed so it completely fills its container. -->\n      <flag name=\"fill\" value=\"0x77\" />\n      <!-- Additional option that can be set to have the top and/or bottom edges of\n           the child clipped to its container's bounds.\n           The clip will be based on the vertical gravity: a top gravity will clip the bottom\n           edge, a bottom gravity will clip the top edge, and neither will clip both edges. -->\n      <flag name=\"clip_vertical\" value=\"0x80\" />\n      <!-- Additional option that can be set to have the left and/or right edges of\n           the child clipped to its container's bounds.\n           The clip will be based on the horizontal gravity: a left gravity will clip the right\n           edge, a right gravity will clip the left edge, and neither will clip both edges. -->\n      <flag name=\"clip_horizontal\" value=\"0x08\" />\n      <!-- Push object to the beginning of its container, not changing its size. -->\n      <flag name=\"start\" value=\"0x00800003\" />\n      <!-- Push object to the end of its container, not changing its size. -->\n      <flag name=\"end\" value=\"0x00800005\" />\n    </attr>\n  </declare-styleable>\n\n  <!--inset-->\n  <declare-styleable name=\"Folivora_Inset\">\n    <attr name=\"insetDrawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"insetAll\" format=\"dimension|fraction\"/>\n    <attr name=\"insetLeft\" format=\"dimension|fraction\"/>\n    <attr name=\"insetTop\" format=\"dimension|fraction\"/>\n    <attr name=\"insetRight\" format=\"dimension|fraction\"/>\n    <attr name=\"insetBottom\" format=\"dimension|fraction\"/>\n  </declare-styleable>\n\n  <!--scale-->\n  <declare-styleable name=\"Folivora_Scale\">\n    <attr name=\"scaleLevel\" format=\"integer\"/>\n    <attr name=\"scaleDrawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <!-- Keep sync with android.view.Gravity -->\n    <attr name=\"scaleGravity\" format=\"flags\">\n\n      <!-- Push object to the top of its container, not changing its size. -->\n      <flag name=\"top\" value=\"0x30\" />\n      <!-- Push object to the bottom of its container, not changing its size. -->\n      <flag name=\"bottom\" value=\"0x50\" />\n      <!-- Push object to the left of its container, not changing its size. -->\n      <flag name=\"left\" value=\"0x03\" />\n      <!-- Push object to the right of its container, not changing its size. -->\n      <flag name=\"right\" value=\"0x05\" />\n      <!-- Place object in the vertical center of its container, not changing its size. -->\n      <flag name=\"center_vertical\" value=\"0x10\" />\n      <!-- Grow the vertical size of the object if needed so it completely fills its container. -->\n      <flag name=\"fill_vertical\" value=\"0x70\" />\n      <!-- Place object in the horizontal center of its container, not changing its size. -->\n      <flag name=\"center_horizontal\" value=\"0x01\" />\n      <!-- Grow the horizontal size of the object if needed so it completely fills its container. -->\n      <flag name=\"fill_horizontal\" value=\"0x07\" />\n      <!-- Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. -->\n      <flag name=\"center\" value=\"0x11\" />\n      <!-- Grow the horizontal and vertical size of the object if needed so it completely fills its container. -->\n      <flag name=\"fill\" value=\"0x77\" />\n      <!-- Additional option that can be set to have the top and/or bottom edges of\n           the child clipped to its container's bounds.\n           The clip will be based on the vertical gravity: a top gravity will clip the bottom\n           edge, a bottom gravity will clip the top edge, and neither will clip both edges. -->\n      <flag name=\"clip_vertical\" value=\"0x80\" />\n      <!-- Additional option that can be set to have the left and/or right edges of\n           the child clipped to its container's bounds.\n           The clip will be based on the horizontal gravity: a left gravity will clip the right\n           edge, a right gravity will clip the left edge, and neither will clip both edges. -->\n      <flag name=\"clip_horizontal\" value=\"0x08\" />\n      <!-- Push object to the beginning of its container, not changing its size. -->\n      <flag name=\"start\" value=\"0x00800003\" />\n      <!-- Push object to the end of its container, not changing its size. -->\n      <flag name=\"end\" value=\"0x00800005\" />\n\n    </attr>\n    <attr name=\"scaleWidth\" format=\"float\"/>\n    <attr name=\"scaleHeight\" format=\"float\"/>\n  </declare-styleable>\n\n  <!--animation-->\n  <declare-styleable name=\"Folivora_Animation\">\n    <attr name=\"animAutoPlay\" format=\"boolean\"/>\n    <attr name=\"animOneShot\" format=\"boolean\"/>\n    <attr name=\"animFrame0\" format=\"reference|color\"/>\n    <attr name=\"animFrame1\" format=\"reference|color\"/>\n    <attr name=\"animFrame2\" format=\"reference|color\"/>\n    <attr name=\"animFrame3\" format=\"reference|color\"/>\n    <attr name=\"animFrame4\" format=\"reference|color\"/>\n    <attr name=\"animFrame5\" format=\"reference|color\"/>\n    <attr name=\"animFrame6\" format=\"reference|color\"/>\n    <attr name=\"animFrame7\" format=\"reference|color\"/>\n    <attr name=\"animFrame8\" format=\"reference|color\"/>\n    <attr name=\"animFrame9\" format=\"reference|color\"/>\n\n    <attr name=\"animDuration\" format=\"integer\"/>\n    <attr name=\"animDuration0\" format=\"integer\"/>\n    <attr name=\"animDuration1\" format=\"integer\"/>\n    <attr name=\"animDuration2\" format=\"integer\"/>\n    <attr name=\"animDuration3\" format=\"integer\"/>\n    <attr name=\"animDuration4\" format=\"integer\"/>\n    <attr name=\"animDuration5\" format=\"integer\"/>\n    <attr name=\"animDuration6\" format=\"integer\"/>\n    <attr name=\"animDuration7\" format=\"integer\"/>\n    <attr name=\"animDuration8\" format=\"integer\"/>\n    <attr name=\"animDuration9\" format=\"integer\"/>\n\n  </declare-styleable>\n\n  <!--level-->\n  <declare-styleable name=\"Folivora_Level\">\n    <attr name=\"levelCurrentLevel\" format=\"integer\"/>\n    <attr name=\"levelItem0Drawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"levelItem0MinLevel\" format=\"integer\"/>\n    <attr name=\"levelItem0MaxLevel\" format=\"integer\"/>\n    <attr name=\"levelItem1Drawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"levelItem1MinLevel\" format=\"integer\"/>\n    <attr name=\"levelItem1MaxLevel\" format=\"integer\"/>\n    <attr name=\"levelItem2Drawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"levelItem2MinLevel\" format=\"integer\"/>\n    <attr name=\"levelItem2MaxLevel\" format=\"integer\"/>\n    <attr name=\"levelItem3Drawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"levelItem3MinLevel\" format=\"integer\"/>\n    <attr name=\"levelItem3MaxLevel\" format=\"integer\"/>\n    <attr name=\"levelItem4Drawable\" format=\"reference|color|enum\">\n      <enum name=\"shape\" value=\"0\"/>\n      <enum name=\"shape1\" value=\"1\"/>\n      <enum name=\"shape2\" value=\"2\"/>\n      <enum name=\"shape3\" value=\"3\"/>\n      <enum name=\"shape4\" value=\"4\"/>\n    </attr>\n    <attr name=\"levelItem4MinLevel\" format=\"integer\"/>\n    <attr name=\"levelItem4MaxLevel\" format=\"integer\"/>\n  </declare-styleable>\n\n\n</resources>"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Sat Mar 21 17:57:59 CST 2020\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-5.6.4-all.zip"
  },
  {
    "path": "gradle.properties",
    "content": "# Project-wide Gradle settings.\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will override*\n# any settings specified in this file.\n# For more details on how to configure your build environment visit\n# http://www.gradle.org/docs/current/userguide/build_environment.html\n# Specifies the JVM arguments used for the daemon process.\n# The setting is particularly useful for tweaking memory settings.\norg.gradle.jvmargs=-Xmx1536m\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\nandroid.useAndroidX=true"
  },
  {
    "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\n@rem ##########################################################################\n@rem\n@rem  Gradle startup script for Windows\n@rem\n@rem ##########################################################################\n\n@rem Set local scope for the variables with windows NT shell\nif \"%OS%\"==\"Windows_NT\" setlocal\n\nset DIRNAME=%~dp0\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\nset APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nset DEFAULT_JVM_OPTS=\n\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n\nset JAVA_EXE=java.exe\n%JAVA_EXE% -version >NUL 2>&1\nif \"%ERRORLEVEL%\" == \"0\" goto init\n\necho.\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:findJavaFromJavaHome\nset JAVA_HOME=%JAVA_HOME:\"=%\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\n\nif exist \"%JAVA_EXE%\" goto init\n\necho.\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:init\n@rem Get command-line arguments, handling Windows variants\n\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\n\n:win9xME_args\n@rem Slurp the command line arguments.\nset CMD_LINE_ARGS=\nset _SKIP=2\n\n:win9xME_args_slurp\nif \"x%~1\" == \"x\" goto execute\n\nset CMD_LINE_ARGS=%*\n\n:execute\n@rem Setup the command line\n\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\n\n@rem Execute Gradle\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%\n\n:end\n@rem End local scope for the variables with windows NT shell\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\n\n:fail\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\nrem the _cmd.exe /c_ return code!\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\nexit /b 1\n\n:mainEnd\nif \"%OS%\"==\"Windows_NT\" endlocal\n\n:omega\n"
  },
  {
    "path": "lint/build.gradle",
    "content": "apply plugin: 'java'\n\ndef ideInstallationDir = new File('d:/android/studio')\ndef androidPluginLibPath = 'plugins/android/lib'\ndef lintVersion = '26.2.0-alpha06'\n\nconfigurations.all {\n  transitive = false\n}\n\ndependencies {\n  compileOnly \"com.android.tools.lint:lint-api:$lintVersion\"\n  compileOnly \"com.android.tools.lint:lint-checks:$lintVersion\"\n  compileOnly \"com.android.tools.lint:lint:$lintVersion\"\n  compileOnly \"com.android.tools.external.org-jetbrains:uast:$lintVersion\"\n  compileOnly \"com.android.tools.external.com-intellij:intellij-core:$lintVersion\"\n  compileOnly 'com.android.tools:common:26.6.1'\n  compileOnly 'com.android.tools.layoutlib:layoutlib-api:26.6.1'\n  if (ideInstallationDir.exists() && ideInstallationDir.isDirectory()) {\n     [\"${androidPluginLibPath}/android.jar\",\n     'lib/openapi.jar',\n     'lib/platform-api.jar',\n     'lib/idea.jar'\n    ].each { lib ->\n       def file = new File(ideInstallationDir, lib)\n       if(!file.exists()) throw new Exception(\"file $file does not exist\")\n      compileOnly files(file)\n    }\n    def legacyLayoutLib = new File(\"${androidPluginLibPath}/layoutlib.jar\")\n    def layoutLib = new File(ideInstallationDir, \"plugins/android-layoutlib/lib/layoutlib.jar\")\n    if (legacyLayoutLib.exists()) {\n      compileOnly files(legacyLayoutLib)\n    } else if(layoutLib.exists()) {\n      compileOnly files(layoutLib)\n    } else {\n      throw new Exception(\"layoutlib does not exist\")\n    }\n  } else {\n    throw new GradleException('Invalid ide installation dir')\n  }\n}\n\njar {\n  manifest {\n    attributes(\"Lint-Registry-v2\": \"cn.cricin.folivora.lint.FolivoraIssueRegistry\")\n    attributes(\"Lint-Registry\": \"cn.cricin.folivora.lint.FolivoraIssueRegistry\")\n  }\n  archiveName('folivora-lint.jar')\n}\n\ntask installLint(type: Copy) {\n  setGroup('install')\n  def jarTask = tasks.findByName('jar')\n  dependsOn(jarTask)\n  from(jarTask.outputs.files)\n  into(new File(new File(System.getProperty(\"user.home\")), '.android/lint/'))\n}\n\ntask uninstallLint() {\n  setGroup('install')\n  doFirst {\n    File lintLibDir = new File(new File(System.getProperty(\"user.home\")), '.android/lint')\n    def folivoraLintJar = new File(lintLibDir, 'folivora-lint.jar')\n    if (folivoraLintJar.exists()) {\n      folivoraLintJar.delete()\n    }\n  }\n}"
  },
  {
    "path": "lint/src/main/java/cn/cricin/folivora/dom/AndroidFacetCompat.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora.dom;\n\nimport com.android.tools.idea.model.AndroidModel;\nimport com.intellij.openapi.util.Pair;\n\nimport org.jetbrains.android.dom.manifest.Manifest;\nimport org.jetbrains.android.facet.AndroidFacet;\nimport org.jetbrains.android.resourceManagers.LocalResourceManager;\nimport org.jetbrains.android.resourceManagers.ModuleResourceManagers;\nimport org.jetbrains.android.resourceManagers.ResourceManager;\n\nimport java.lang.reflect.Method;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.concurrent.Callable;\n\n/**\n * Since the API of AndroidFacet class changed so frequently\n * in different version of Android Studio, a compat utility\n * is needed for those API changes.\n */\nfinal class AndroidFacetCompat {\n  private static boolean sModuleResourceManagerExists = true;\n\n  static ResourceManager getAppResourceManager(AndroidFacet facet) {\n    ResourceManager manager = null;\n    if (sModuleResourceManagerExists) {\n      try {\n        manager = ModuleResourceManagers.getInstance(facet).getResourceManager(null);\n      } catch (Throwable ignore) {\n        sModuleResourceManagerExists = false;\n      }\n    }\n    if (!sModuleResourceManagerExists) {\n      manager = LocalResourceManager.getInstance(facet.getModule());\n    }\n    return manager;\n  }\n\n  /**\n   * Added for android studio 3.0\n   */\n  static boolean isAppProject(AndroidFacet facet) {\n    Boolean value = invoke(AndroidFacet.class, \"isAppProject\", facet, null, null, new Callable<Boolean>() {\n      @Override\n      public Boolean call() throws Exception {\n        return facet.getConfiguration().isAppProject();\n      }\n    });\n    return value != null && value;\n  }\n\n  /**\n   * Added for android studio 4.0 canary release\n   */\n  static boolean requiresAndroidModel(AndroidFacet facet) {\n    Boolean value = invoke(AndroidModel.class, \"isRequired\", null, new Class[]{AndroidFacet.class}, new Object[]{facet}, new Callable<Boolean>() {\n      @Override\n      public Boolean call() throws Exception {\n        return facet.requiresAndroidModel();\n      }\n    });\n    return value != null && value;\n  }\n\n  /**\n   * Added for android studio 4.0 canary release\n   */\n  static Manifest getManifest(AndroidFacet facet) {\n    return invoke(AndroidFacet.class, \"getManifest\", facet, null, null, new Callable<Manifest>() {\n      @Override\n      public Manifest call() throws Exception {\n        return Manifest.getMainManifest(facet);\n      }\n    });\n  }\n\n  private static Map<Pair<Class<?>, String>, Method> sInvokableMethods = new HashMap<>();\n\n  @SuppressWarnings(\"unchecked\")\n  private static <R> R invoke(Class<?> clazz, String methodName, Object receiver, Class<?>[] argClasses, Object[] args, Callable<R> c) {\n    final Pair<Class<?>, String> pair = Pair.create(clazz, methodName);\n    Method method = sInvokableMethods.get(pair);\n    if (method != null) {\n      try {\n        return (R) method.invoke(receiver, args);\n      } catch (Throwable ignore) {\n      }\n    }\n    try {\n      return c.call();\n    } catch (Throwable ignore) {\n    }\n    try {\n      method = clazz.getDeclaredMethod(methodName, argClasses);\n      Object result = method.invoke(receiver, args);\n      sInvokableMethods.put(pair, method);\n      return (R) result;\n    } catch (Throwable ignore) {\n    }\n    return null;\n  }\n\n  private AndroidFacetCompat() {\n  }\n}"
  },
  {
    "path": "lint/src/main/java/cn/cricin/folivora/dom/DrawableIdConverter.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora.dom;\n\nimport com.android.SdkConstants;\nimport com.intellij.psi.PsiElement;\nimport com.intellij.psi.PsiRecursiveElementVisitor;\nimport com.intellij.psi.xml.XmlFile;\nimport com.intellij.psi.xml.XmlTag;\nimport com.intellij.util.xml.ConvertContext;\nimport com.intellij.util.xml.ResolvingConverter;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.HashSet;\nimport java.util.Set;\n\n/**\n * This converter keeps track app:drawableId values used\n * in project, and gives cached candidates when use drawableId\n */\npublic class DrawableIdConverter extends ResolvingConverter<String> {\n\n  @NotNull\n  @Override\n  public Collection<? extends String> getVariants(ConvertContext convertContext) {\n    if (convertContext == null) return Collections.emptyList();\n    XmlFile file = convertContext.getFile();\n    final Set<String> drawableIds = new HashSet<>();\n    file.accept(new PsiRecursiveElementVisitor() {\n      @Override\n      public void visitElement(PsiElement element) {\n        super.visitElement(element);\n        if (element instanceof XmlTag) {\n          String drawableId = ((XmlTag) element).getAttributeValue(\"drawableId\", SdkConstants.AUTO_URI);\n          if(drawableId != null && !drawableId.isEmpty()) {\n            drawableIds.add(drawableId);\n          }\n        }\n      }\n    });\n    return new ArrayList<>(drawableIds);\n  }\n\n  @Nullable\n  @Override\n  public String fromString(@Nullable String s, ConvertContext convertContext) {\n    return s;\n  }\n\n  @Nullable\n  @Override\n  public String toString(@Nullable String s, ConvertContext convertContext) {\n    return s;\n  }\n\n}\n"
  },
  {
    "path": "lint/src/main/java/cn/cricin/folivora/dom/FolivoraAttrProcessing.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora.dom;\n\nimport com.android.SdkConstants;\nimport com.intellij.psi.xml.XmlAttribute;\nimport com.intellij.psi.xml.XmlTag;\nimport com.intellij.util.xml.Converter;\nimport com.intellij.util.xml.DomElement;\nimport com.intellij.util.xml.XmlName;\nimport com.intellij.util.xml.reflect.DomExtension;\n\nimport org.jetbrains.android.dom.AndroidDomElement;\nimport org.jetbrains.android.dom.AndroidDomUtil;\nimport org.jetbrains.android.dom.AttributeProcessingUtil;\nimport org.jetbrains.android.dom.attrs.AttributeDefinition;\nimport org.jetbrains.android.dom.attrs.AttributeDefinitions;\nimport org.jetbrains.android.dom.attrs.StyleableDefinition;\nimport org.jetbrains.android.dom.attrs.ToolsAttributeUtil;\nimport org.jetbrains.android.dom.converters.CompositeConverter;\nimport org.jetbrains.android.dom.converters.PackageClassConverter;\nimport org.jetbrains.android.dom.converters.ResourceReferenceConverter;\nimport org.jetbrains.android.dom.layout.DataBindingElement;\nimport org.jetbrains.android.dom.layout.LayoutElement;\nimport org.jetbrains.android.dom.manifest.Manifest;\nimport org.jetbrains.android.facet.AndroidFacet;\nimport org.jetbrains.android.resourceManagers.ResourceManager;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.HashMap;\nimport java.util.List;\n\n/**\n * Process folivora attr's to the current dom element\n */\nfinal class FolivoraAttrProcessing {\n  /**\n   * If this attr name exists in xml tag, it's value is treated as\n   * declare styleables, folivora will also register these attributes\n   * to current xml tag.\n   */\n  private static final String EXTRA_STYLEABLE_ATTR_NAME = \"extraStyleables\";\n  /**\n   * This converter is used to find custom drawable classes in current project\n   */\n  private static final PackageClassConverter DRAWABLE_CLASS_CONVERTER =\n    new PackageClassConverter(\"android.graphics.drawable.Drawable\");\n  private static final DrawableIdConverter DRAWABLE_ID_CONVERTER = new DrawableIdConverter();\n  private static final HashMap<String, String> TYPE_TO_STYLEABLE = new HashMap<>();\n  private static final HashMap<String, String> SHAPE_TO_STYLEABLE = new HashMap<>();\n\n  static {\n    TYPE_TO_STYLEABLE.put(\"shape\", \"Folivora_Shape\");\n    TYPE_TO_STYLEABLE.put(\"selector\", \"Folivora_Selector\");\n    TYPE_TO_STYLEABLE.put(\"layer_list\", \"Folivora_Layer\");\n    TYPE_TO_STYLEABLE.put(\"ripple\", \"Folivora_Ripple\");\n    TYPE_TO_STYLEABLE.put(\"level_list\", \"Folivora_Level\");\n    TYPE_TO_STYLEABLE.put(\"clip\", \"Folivora_Clip\");\n    TYPE_TO_STYLEABLE.put(\"inset\", \"Folivora_Inset\");\n    TYPE_TO_STYLEABLE.put(\"scale\", \"Folivora_Scale\");\n    TYPE_TO_STYLEABLE.put(\"animation\", \"Folivora_Animation\");\n\n    SHAPE_TO_STYLEABLE.put(\"shape\", \"Folivora_Shape\");\n    SHAPE_TO_STYLEABLE.put(\"shape1\", \"Folivora_Shape1\");\n    SHAPE_TO_STYLEABLE.put(\"shape2\", \"Folivora_Shape2\");\n    SHAPE_TO_STYLEABLE.put(\"shape3\", \"Folivora_Shape3\");\n    SHAPE_TO_STYLEABLE.put(\"shape4\", \"Folivora_Shape4\");\n  }\n\n  static void registerFolivoraAttributes(AndroidFacet facet,\n                                         AndroidDomElement element,\n                                         AttributeProcessingUtil.AttributeProcessor callback) {\n    if (!(element instanceof LayoutElement)) return;\n    if (element instanceof DataBindingElement) return;\n    XmlTag tag = element.getXmlTag();\n    if (tag == null) return;\n    if (isInvalidTagName(tag.getName())) return;\n    List<String> styleableNames = getStyleablesToRegister(tag.getAttributes());\n    for (String styleableName : styleableNames) {\n      if (styleableName != null && styleableName.length() > 0) {\n        registerAttributes(facet, element, styleableName, callback);\n      }\n    }\n  }\n\n  private static List<String> getStyleablesToRegister(XmlAttribute[] attrs) {\n    List<String> styleableNames = new ArrayList<>(6);\n    styleableNames.add(\"Folivora\");\n    String drawableType = null;\n    String drawableName = null;\n    for (XmlAttribute attr : attrs) {\n      String attrName = attr.getLocalName();\n      String attrValue = attr.getValue();\n      if (\"drawableType\".equals(attrName)) {\n        drawableType = attrValue;\n      } else if (\"drawableName\".equals(attrName)) {\n        drawableName = attrValue;\n      } else if (EXTRA_STYLEABLE_ATTR_NAME.equals(attrName) && attrValue != null) {\n        if (attrValue.indexOf(',') != -1) {\n          styleableNames.addAll(Arrays.asList(attrValue.split(\",\")));\n        } else {\n          styleableNames.add(attrValue);\n        }\n      }\n    }\n    if (drawableType == null && drawableName == null) return styleableNames;\n    if (drawableType != null) styleableNames.add(TYPE_TO_STYLEABLE.get(drawableType));\n    if (drawableName != null) styleableNames.add(getSimpleClassName(drawableName));\n\n    // process nested shapes\n    String styleable;\n    for (XmlAttribute attr : attrs) {\n      String attrName = attr.getLocalName();\n      String attrValue = attr.getValue();\n      if (attrName.startsWith(\"shape1\")\n        || attrName.startsWith(\"shape2\")\n        || attrName.startsWith(\"shape3\")\n        || attrName.startsWith(\"shape4\")) continue;\n      styleable = SHAPE_TO_STYLEABLE.get(attrValue);\n      if (styleable == null) continue;\n      if (drawableType != null && attrName.startsWith(drawableType)) {\n        styleableNames.add(styleable);\n      } else if (drawableName != null) {\n        // if is custom drawable, we don't know whether this drawable\n        // need nested shapes, so register nested shape anyway\n        styleableNames.add(styleable);\n      }\n    }\n    return styleableNames;\n  }\n\n  private static String getSimpleClassName(String className) {\n    if (className == null) return null;\n    int dotIndex = className.lastIndexOf('.');\n    if (dotIndex == -1 || dotIndex + 1 >= className.length()) return null;\n    return className.substring(dotIndex + 1);\n  }\n\n  private static boolean isInvalidTagName(String tagName) {\n    return \"layout\".equals(tagName)\n      || \"fragment\".equals(tagName)\n      || \"include\".equals(tagName)\n      || \"requestFocus\".equals(tagName)\n      || \"merge\".equals(tagName);\n  }\n\n  private static void registerAttributes(/*NotNull*/ AndroidFacet facet,\n    /*NotNull*/ DomElement element,\n    /*NotNull*/ String styleableName,\n    /*NotNull*/ AttributeProcessingUtil.AttributeProcessor callback) {\n\n    ResourceManager manager = AndroidFacetCompat.getAppResourceManager(facet);\n    if (manager == null) {\n      return;\n    }\n\n    AttributeDefinitions attrDefs = manager.getAttributeDefinitions();\n    if (attrDefs == null) {\n      return;\n    }\n\n    String namespace = getNamespaceUriByResourcePackage(facet, null);\n    StyleableDefinition styleable = attrDefs.getStyleableByName(styleableName);\n    if (styleable != null) {\n      registerStyleableAttributes(element, styleable, namespace, callback);\n    }\n    // It's a good idea to add a warning when styleable not found, to make sure that code doesn't\n    // try to use attributes that don't exist. However, current AndroidDomExtender code relies on\n    // a lot of \"heuristics\" that fail quite a lot (like adding a bunch of suffixes to short\n    // class names)\n    // TODO: add a warning when rest of the code of AndroidDomExtender is cleaned up\n  }\n\n  /*Nullable*/\n  private static String getNamespaceUriByResourcePackage(/*NotNull*/ AndroidFacet facet,\n    /*Nullable*/ String resPackage) {\n    if (resPackage == null) {\n      if (!AndroidFacetCompat.isAppProject(facet)|| AndroidFacetCompat.requiresAndroidModel(facet)) {\n        return SdkConstants.AUTO_URI;\n      }\n      Manifest manifest = AndroidFacetCompat.getManifest(facet);\n      if (manifest != null) {\n        String aPackage = manifest.getPackage().getValue();\n        if (aPackage != null && !aPackage.isEmpty()) {\n          return SdkConstants.URI_PREFIX + aPackage;\n        }\n      }\n    } else if (resPackage.equals(SdkConstants.ANDROID_NS_NAME)) {\n      return SdkConstants.ANDROID_URI;\n    }\n    return null;\n  }\n\n  private static void registerStyleableAttributes(\n    /*NotNull*/ DomElement element,\n    /*NotNull*/ StyleableDefinition styleable,\n    /*Nullable*/ String namespaceUri,\n    /*NotNull*/ AttributeProcessingUtil.AttributeProcessor callback) {\n    for (AttributeDefinition attrDef : styleable.getAttributes()) {\n      registerAttribute(attrDef, styleable.getName(), namespaceUri, element, callback);\n    }\n  }\n\n  private static void registerAttribute(\n    AttributeDefinition attrDef,\n    String parentStyleableName,\n    String namespaceKey,\n    DomElement element,\n    AttributeProcessingUtil.AttributeProcessor callback) {\n    String name = attrDef.getName();\n    if (!SdkConstants.ANDROID_URI.equals(namespaceKey) && name.startsWith(SdkConstants.ANDROID_NS_NAME_PREFIX)) {\n      name = name.substring(SdkConstants.ANDROID_NS_NAME_PREFIX.length());\n      namespaceKey = SdkConstants.ANDROID_URI;\n    }\n\n    XmlName xmlName = new XmlName(name, namespaceKey);\n    DomExtension extension = callback.processAttribute(xmlName, attrDef, parentStyleableName);\n    if (extension != null) {\n      Converter converter = AndroidDomUtil.getSpecificConverter(xmlName, element);\n      if (\"drawableName\".equals(name)) {\n        converter = DRAWABLE_CLASS_CONVERTER;\n      }\n      if (\"drawableId\".equals(name)) {\n        converter = DRAWABLE_ID_CONVERTER;\n      }\n      if (converter == null) {\n        if (SdkConstants.TOOLS_URI.equals(namespaceKey)) {\n          converter = ToolsAttributeUtil.getConverter(attrDef);\n        } else {\n          converter = AndroidDomUtil.getConverter(attrDef);\n        }\n      }\n\n      if (converter != null) {\n        extension.setConverter(converter, mustBeSoft(converter, attrDef.getFormats()));\n      }\n    }\n  }\n\n  private static boolean mustBeSoft(Converter converter, Collection formats) {\n    if (!(converter instanceof CompositeConverter)\n      && !(converter instanceof ResourceReferenceConverter)) {\n      return formats.size() > 1;\n    } else {\n      return false;\n    }\n  }\n\n  private FolivoraAttrProcessing() {}\n}\n"
  },
  {
    "path": "lint/src/main/java/cn/cricin/folivora/dom/FolivoraDomExtender.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora.dom;\n\nimport com.intellij.openapi.extensions.ExtensionPoint;\nimport com.intellij.openapi.extensions.Extensions;\nimport com.intellij.util.xml.GenericAttributeValue;\nimport com.intellij.util.xml.reflect.DomExtender;\nimport com.intellij.util.xml.reflect.DomExtenderEP;\nimport com.intellij.util.xml.reflect.DomExtensionsRegistrar;\n\nimport org.jetbrains.android.dom.AndroidDomElement;\nimport org.jetbrains.android.dom.AttributeProcessingUtil;\nimport org.jetbrains.android.dom.resources.ResourceValue;\nimport org.jetbrains.android.facet.AndroidFacet;\n\nimport java.lang.reflect.Field;\nimport java.util.HashMap;\nimport java.util.Set;\n\nimport javax.annotation.Nonnull;\n\n@SuppressWarnings(\"unchecked\")\npublic final class FolivoraDomExtender extends DomExtender<AndroidDomElement> {\n  private static HashMap<Object, Class> sValueClasses = new HashMap<>();\n\n  static {\n    try {\n      Class legacyAttributeFormatClass = Class.forName(\"org.jetbrains.android.dom.attrs.AttributeFormat\");\n      sValueClasses.put(Enum.valueOf(legacyAttributeFormatClass, \"Boolean\"), boolean.class);\n      sValueClasses.put(Enum.valueOf(legacyAttributeFormatClass, \"Reference\"), ResourceValue.class);\n      sValueClasses.put(Enum.valueOf(legacyAttributeFormatClass, \"Dimension\"), ResourceValue.class);\n      sValueClasses.put(Enum.valueOf(legacyAttributeFormatClass, \"Color\"), ResourceValue.class);\n    } catch (ClassNotFoundException ignore) {\n    }\n    try {\n      Class.forName(\"com.android.ide.common.rendering.api.AttributeFormat\");\n      sValueClasses.put(com.android.ide.common.rendering.api.AttributeFormat.BOOLEAN, boolean.class);\n      sValueClasses.put(com.android.ide.common.rendering.api.AttributeFormat.REFERENCE, ResourceValue.class);\n      sValueClasses.put(com.android.ide.common.rendering.api.AttributeFormat.DIMENSION, ResourceValue.class);\n      sValueClasses.put(com.android.ide.common.rendering.api.AttributeFormat.COLOR, ResourceValue.class);\n    } catch (ClassNotFoundException ignore) {\n    }\n  }\n\n  @Override\n  public boolean supportsStubs() {\n    return false;\n  }\n\n  private static Class getValueClass(Object format) {\n    Class cls = sValueClasses.get(format);\n    return cls == null ? String.class : cls;\n  }\n\n  @Override\n  public void registerExtensions(@Nonnull AndroidDomElement element,\n                                 @Nonnull final DomExtensionsRegistrar registrar) {\n    final AndroidFacet facet = AndroidFacet.getInstance(element);\n\n    if (facet == null) {\n      return;\n    }\n\n    AttributeProcessingUtil.AttributeProcessor callback = (xmlName, attrDef, parentStyleableName)\n      -> {\n      Set<?> formats = attrDef.getFormats();\n      Class valueClass = formats.size() == 1 ? getValueClass(formats.iterator().next()) : String\n        .class;\n      registrar.registerAttributeChildExtension(xmlName, GenericAttributeValue.class);\n      return registrar.registerGenericAttributeValueChildExtension(xmlName, valueClass);\n    };\n\n    try {\n      FolivoraAttrProcessing.registerFolivoraAttributes(facet, element, callback);\n    } catch (Exception ignore) {}\n  }\n\n\n  public static void install() {\n    ExtensionPoint<DomExtenderEP> point = Extensions.getRootArea().getExtensionPoint\n      (DomExtenderEP.EP_NAME);\n    String clazzName = FolivoraDomExtender.class.getCanonicalName();\n    DomExtenderEP androidDomExtenderEp = null;\n    DomExtenderEP[] eps = point.getExtensions();\n    for (DomExtenderEP ep : eps) {\n      if (clazzName.equals(ep.extenderClassName)) {\n        return;// already registered\n      }\n      if (ep.extenderClassName.endsWith(\"AndroidDomExtender\")) {\n        androidDomExtenderEp = ep;\n      }\n    }\n    if (androidDomExtenderEp != null) {\n      DomExtenderEP ep = new DomExtenderEP();\n      ep.setPluginDescriptor(androidDomExtenderEp.getPluginDescriptor());\n      ep.domClassName = AndroidDomElement.class.getCanonicalName();\n      ep.extenderClassName = FolivoraDomExtender.class.getCanonicalName();\n      try {\n        Field field = ep.getClass().getDeclaredField(\"myExtender\");\n        field.setAccessible(true);\n        field.set(ep, new FolivoraDomExtender());\n        point.registerExtension(ep);\n      } catch (Exception ignore) {}\n    }\n  }\n}\n"
  },
  {
    "path": "lint/src/main/java/cn/cricin/folivora/lint/FolivoraIssueRegistry.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora.lint;\n\nimport com.android.tools.lint.client.api.IssueRegistry;\nimport com.android.tools.lint.detector.api.ApiKt;\nimport com.android.tools.lint.detector.api.Issue;\n\nimport java.util.Collections;\nimport java.util.List;\n\nimport cn.cricin.folivora.dom.FolivoraDomExtender;\nimport cn.cricin.folivora.preview.FolivoraPreview;\n\n@SuppressWarnings(\"unused\")\npublic final class FolivoraIssueRegistry extends IssueRegistry {\n\n  static {\n    installStudioPlugins();\n  }\n\n  private static void installStudioPlugins() {\n    boolean lintInsideStudio;\n    try {\n      Class.forName(\"org.jetbrains.android.dom.AndroidDomElement\");\n      lintInsideStudio = true;\n    } catch (ClassNotFoundException e) {\n      lintInsideStudio = false;\n    }\n    if (lintInsideStudio) {\n      try {\n        FolivoraDomExtender.install();\n      } catch (Exception ignore) {}\n      try {\n        FolivoraPreview.install();\n      } catch (Exception ignore) {}\n    }\n  }\n\n  @Override\n  public List<Issue> getIssues() {\n    return Collections.singletonList(\n      InstalledBeforeSuperDetector.ISSUE\n    );\n  }\n\n  @Override\n  public int getApi() {\n    return ApiKt.CURRENT_API;\n  }\n}\n"
  },
  {
    "path": "lint/src/main/java/cn/cricin/folivora/lint/InstalledBeforeSuperDetector.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora.lint;\n\nimport com.android.tools.lint.client.api.JavaEvaluator;\nimport com.android.tools.lint.detector.api.Category;\nimport com.android.tools.lint.detector.api.Detector;\nimport com.android.tools.lint.detector.api.Implementation;\nimport com.android.tools.lint.detector.api.Issue;\nimport com.android.tools.lint.detector.api.JavaContext;\nimport com.android.tools.lint.detector.api.LintUtils;\nimport com.android.tools.lint.detector.api.Scope;\nimport com.android.tools.lint.detector.api.Severity;\nimport com.android.tools.lint.detector.api.SourceCodeScanner;\nimport com.intellij.psi.PsiClass;\nimport com.intellij.psi.PsiMethod;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.uast.UCallExpression;\nimport org.jetbrains.uast.UMethod;\nimport org.jetbrains.uast.UastUtils;\nimport org.jetbrains.uast.visitor.AbstractUastVisitor;\n\nimport java.util.Collections;\nimport java.util.List;\n\npublic final class InstalledBeforeSuperDetector extends Detector implements SourceCodeScanner, Detector\n  .UastScanner {\n  static final Issue ISSUE = Issue.create(\n    \"FolivoraInstalledBeforeSuper\",\n    \"Folivora installed before super.onCreate()\",\n    \"You have installed Folivora before super.onCreate(),\" +\n      \" this will cause AppCompatViews unavailable if you are using AppCompatActivity\",\n    Category.CORRECTNESS,\n    7,\n    Severity.WARNING,\n    new Implementation(InstalledBeforeSuperDetector.class, Scope.JAVA_FILE_SCOPE)\n  );\n\n  private static final String INSTALL_METHOD = \"installViewFactory\";\n  private static final String TYPE_FOLIVORA = \"cn.cricin.folivora.Folivora\";\n  private static final String LEGACY_COMPAT_ACTIVITY = \"android.support.v7.app.AppCompatActivity\";\n  private static final String COMPAT_ACTIVITY = \"androidx.appcompat.app.AppCompatActivity\";\n\n  @Nullable\n  @Override\n  public List<String> getApplicableMethodNames() {\n    return Collections.singletonList(INSTALL_METHOD);\n  }\n\n  @Override\n  public void visitMethod(JavaContext context,\n                          UCallExpression call,\n                          PsiMethod method) {\n    JavaEvaluator evaluator = context.getEvaluator();\n\n    //check Folivora.installViewFactory() call\n    String methodName = method.getName();\n    if (!methodName.equals(INSTALL_METHOD) || !evaluator.isMemberInClass(method, TYPE_FOLIVORA))\n      return;\n\n    //check current class is decent of AppCompatActivity\n    PsiClass legacyCompatActClass = evaluator.findClass(LEGACY_COMPAT_ACTIVITY);\n    PsiClass compatActClass = evaluator.findClass(COMPAT_ACTIVITY);\n    PsiClass c = UastUtils.getContainingClass(call);\n    boolean isAppCompatActivity = false;\n    if (c != null) {\n      isAppCompatActivity = (legacyCompatActClass != null && c.isInheritor(legacyCompatActClass,\n        true/*deep check*/))\n        || compatActClass != null && c.isInheritor(compatActClass, true/*deep check*/);\n    }\n    if (!isAppCompatActivity) return;\n\n    //check current method is onCreate\n    @SuppressWarnings(\"unchecked\")\n    UMethod uMethod = UastUtils.getParentOfType(call, true, UMethod.class);\n    if (uMethod == null || !\"onCreate\".equals(uMethod.getName())) return;\n\n    SuperOnCreateFinder finder = new SuperOnCreateFinder(call);\n    uMethod.accept(finder);\n    if (!finder.isSuperOnCreateCalled()) {\n      context.report(ISSUE, call, context.getLocation(call),\n        \"calling `Folivora.installViewFactory()` before super.onCreate can cause AppCompatViews unavailable\");\n    }\n  }\n\n  private static class SuperOnCreateFinder extends AbstractUastVisitor {\n    /** The target installViewFactory call */\n    private final UCallExpression target;\n    /** Whether we've found the super.onCreate() before folivora installed */\n    private boolean ok;\n    /** Whether we've seen the target super.onCreate() node yet */\n    private boolean onCreateFound;\n\n    private SuperOnCreateFinder(UCallExpression target) {\n      this.target = target;\n    }\n\n    @Override\n    public boolean visitCallExpression(UCallExpression node) {\n      if (node == target || node.getPsi() != null && node.getPsi() == target.getPsi()) {\n        if (onCreateFound) {\n          ok = true;\n          return true;\n        }\n      } else {\n        if (\"onCreate\".equals(LintUtils.getMethodName(node))\n          && node.getReceiver() != null\n          && \"super\".equals(node.getReceiver().toString())) {\n          onCreateFound = true;\n        }\n      }\n      return super.visitCallExpression(node);\n    }\n\n    boolean isSuperOnCreateCalled() {\n      return ok;\n    }\n  }\n}\n"
  },
  {
    "path": "lint/src/main/java/cn/cricin/folivora/lint/InternalFolivoraApiDetector.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora.lint;\n\nimport com.android.tools.lint.client.api.JavaEvaluator;\nimport com.android.tools.lint.detector.api.Category;\nimport com.android.tools.lint.detector.api.Detector;\nimport com.android.tools.lint.detector.api.Implementation;\nimport com.android.tools.lint.detector.api.Issue;\nimport com.android.tools.lint.detector.api.JavaContext;\nimport com.android.tools.lint.detector.api.Scope;\nimport com.android.tools.lint.detector.api.Severity;\nimport com.android.tools.lint.detector.api.SourceCodeScanner;\nimport com.intellij.psi.PsiClass;\nimport com.intellij.psi.PsiMethod;\nimport com.intellij.psi.PsiSubstitutor;\nimport com.intellij.psi.PsiType;\nimport com.intellij.psi.util.MethodSignature;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\nimport org.jetbrains.uast.UCallExpression;\nimport org.jetbrains.uast.UMethod;\nimport org.jetbrains.uast.UastUtils;\n\nimport java.util.Collections;\nimport java.util.List;\n\n@Deprecated\npublic final class InternalFolivoraApiDetector extends Detector\n  implements SourceCodeScanner, Detector.UastScanner {\n\n  static final Issue ISSUE = Issue.create(\n    \"InternalFolivoraCall\",\n    \"You are using Folivora internal API\",\n    \"Using Folivora.applyDrawableToView() outside view's (Context context,\" +\n      \" AttributeSet attrs) constructor is not recommended, you should avoid doing this\",\n    Category.CORRECTNESS,\n    7,\n    Severity.ERROR,\n    new Implementation(InternalFolivoraApiDetector.class, Scope.JAVA_FILE_SCOPE)\n  );\n\n  private static final String APPLY_METHOD = \"applyDrawableToView\";\n  private static final String FOLIVORA_CLASS = \"cn.cricin.folivora.Folivora\";\n  private static final String VIEW_CLASS = \"android.view.View\";\n  private static final String CONTEXT_CLASS = \"android.content.Context\";\n  private static final String ATTRS_CLASS = \"android.util.AttributeSet\";\n\n  @Nullable\n  @Override\n  public List<String> getApplicableMethodNames() {\n    return Collections.singletonList(APPLY_METHOD);\n  }\n\n  @Override\n  public void visitMethod(@NotNull JavaContext context,\n                          @NotNull UCallExpression call,\n                          @NotNull PsiMethod method) {\n    JavaEvaluator evaluator = context.getEvaluator();\n\n    //check Folivora.applyDrawableToView() call\n    String methodName = method.getName();\n    if (!methodName.equals(APPLY_METHOD) || !evaluator.isMemberInClass(method, FOLIVORA_CLASS)) return;\n\n    PsiClass viewClass = evaluator.findClass(VIEW_CLASS);\n    PsiClass currentClass = UastUtils.getContainingClass(call);\n    if(currentClass == null || viewClass == null) return;\n    if (!currentClass.isInheritor(viewClass, true/*deep check*/)) {\n      report(context, call);\n      return;\n    }\n\n    UMethod uMethod = UastUtils.getParentOfType(call, UMethod.class, false);\n    if(uMethod == null) return;\n\n    //check it is a view's constructor\n    if (!uMethod.isConstructor()) {\n      report(context, call);\n      return;\n    }\n\n    MethodSignature signature = uMethod.getSignature(PsiSubstitutor.EMPTY);\n    PsiType[] types = signature.getParameterTypes();\n    if (types.length != 2) {\n      report(context, call);\n      return;\n    }\n\n    if (!types[0].equalsToText(CONTEXT_CLASS)\n      || !types[1].equalsToText(ATTRS_CLASS)) {\n      report(context, call);\n    }\n  }\n\n  private void report(JavaContext context, UCallExpression call) {\n    context.report(ISSUE, call, context.getLocation(call),\n      \"`Folivora.applyDrawableToView()` should only be called in preview stub view's (Context context, AttributeSet attrs) constructor\");\n  }\n\n}\n"
  },
  {
    "path": "lint/src/main/java/cn/cricin/folivora/lint/PreferStubViewDetector.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora.lint;\n\nimport com.android.resources.ResourceFolderType;\nimport com.android.tools.lint.detector.api.Category;\nimport com.android.tools.lint.detector.api.Detector;\nimport com.android.tools.lint.detector.api.Implementation;\nimport com.android.tools.lint.detector.api.Issue;\nimport com.android.tools.lint.detector.api.LintFix;\nimport com.android.tools.lint.detector.api.Scope;\nimport com.android.tools.lint.detector.api.Severity;\nimport com.android.tools.lint.detector.api.XmlContext;\nimport com.android.tools.lint.detector.api.XmlScanner;\n\nimport org.jetbrains.annotations.NotNull;\nimport org.w3c.dom.Attr;\nimport org.w3c.dom.Element;\n\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.HashSet;\nimport java.util.Set;\n\n@Deprecated\npublic final class PreferStubViewDetector extends Detector implements Detector.XmlScanner, XmlScanner {\n  static final Issue ISSUE = Issue.create(\n    \"PreferUseStubView\",\n    \"Using stub view folivora provided instead\",\n    \"To work with design time preview, use stub view provided by folivora instead of system views\",\n    Category.CORRECTNESS,\n    7,\n    Severity.ERROR,\n    new Implementation(PreferStubViewDetector.class, Scope.RESOURCE_FILE_SCOPE)\n  );\n\n\n  private static Set<String> sSystemViewNames = new HashSet<>(Arrays.asList(\n    \"Button\", \"CheckBox\", \"EditText\", \"FrameLayout\", \"GridView\", \"HorizontalScrollView\",\n    \"ImageView\", \"LinearLayout\", \"ListView\", \"ProgressBar\", \"RelativeLayout\", \"ScrollView\",\n    \"SeekBar\", \"Spinner\", \"TextView\", \"View\"));\n\n\n  @Override\n  public Collection<String> getApplicableAttributes() {\n    return Arrays.asList(\"drawableType\", \"drawableName\");\n  }\n\n  @Override\n  public boolean appliesTo(@NotNull ResourceFolderType folderType) {\n    return folderType == ResourceFolderType.LAYOUT;\n  }\n\n  @Override\n  public void visitAttribute(@NotNull XmlContext context, @NotNull Attr attribute) {\n    Element tag = attribute.getOwnerElement();\n    String tagName = tag.getTagName();\n    if (sSystemViewNames.contains(tagName)) {\n      LintFix fix = LintFix.create().replace().range(context.getLocation(tag))\n        .text(tagName).with(\"cn.cricin.folivora.view.\" + tagName).build();\n      context.report(ISSUE, context.getLocation(tag),\n        \"Using cn.cricin.folivora.view.\" + tagName + \" instead to support design time preview\", fix);\n    }\n  }\n}\n"
  },
  {
    "path": "lint/src/main/java/cn/cricin/folivora/preview/FolivoraPreview.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora.preview;\n\nimport android.content.res.Resources;\nimport android.content.res.Resources_Delegate;\nimport android.view.LayoutInflater;\n\nimport com.android.layoutlib.bridge.android.BridgeContext;\nimport com.intellij.openapi.diagnostic.Logger;\n\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.Field;\nimport java.lang.reflect.Modifier;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.WeakHashMap;\n\nimport sun.misc.Unsafe;\n\n/**\n * Preview support entry point for Folivora.\n */\n@SuppressWarnings(\"unchecked\")\npublic final class FolivoraPreview {\n  static final Logger sLogger = Logger.getInstance(FolivoraPreview.class);\n\n  private static Field sContextField;\n  private static WeakHashMap<Resources, BridgeContext> sContextMap;\n\n  public static void install() {\n    try {\n      Field field = Resources_Delegate.class.getDeclaredField(\"sContexts\");\n      field.setAccessible(true);\n      sContextMap = (WeakHashMap<Resources, BridgeContext>) field.get(null);\n    } catch (Throwable t) {\n      sLogger.info(\"Unable to find static field sContexts in\" +\n        \" Resource_Delegate, current AS version may lower than 3.0\", t);\n    }\n    if (sContextMap == null) {\n      try {\n        sContextField = Resources.class.getDeclaredField(\"mContext\");\n        sContextField.setAccessible(true);\n      } catch (Throwable t) {\n        sLogger.info(\"Unable to find static field mContext in\" +\n          \" Resource_Delegate, current AS version may higher than 3.0\", t);\n      }\n    }\n    if (sContextField == null && sContextMap == null) {\n      sLogger.info(\"Preview install failed, AS version not supported\");\n      return;\n    }\n    tryHookConstructorMap();\n  }\n\n  private static void tryHookConstructorMap() {\n    Field field = null;\n    HashMap<String, Constructor<?>> origin = null;\n    boolean needHookWithUnsafe = false;\n    try {\n      field = LayoutInflater.class.getDeclaredField(\"sConstructorMap\");\n      field.setAccessible(true);\n      Field modifiers = Field.class.getDeclaredField(\"modifiers\");\n      modifiers.setAccessible(true);\n      modifiers.set(field, field.getModifiers() & ~Modifier.FINAL);\n      origin = (HashMap<String, Constructor<?>>) field.get(null);\n      if (origin.getClass().getCanonicalName().endsWith(\"MyHashMap\")) return;// already hooked\n      field.set(null, new MyHashMap<>(origin));\n    } catch (Exception ex) {\n      needHookWithUnsafe = true;\n    }\n    if(field == null || origin == null) {\n      sLogger.info(\"Preview install failed, Unable to find field LayoutInflater.sConstructorMap\");\n      return;\n    }\n    // if failed, hook using unsafe\n    if (needHookWithUnsafe) {\n      Unsafe unsafe = getUnsafe();\n      if(unsafe == null) return;\n      Object fieldBase = unsafe.staticFieldBase(field);\n      long offset = unsafe.staticFieldOffset(field);\n      unsafe.putObjectVolatile(fieldBase, offset, new MyHashMap<>(origin));\n    }\n    try {\n      Object o = field.get(null);\n      if (o != null && o.getClass().getCanonicalName().endsWith(\"MyHashMap\")) {\n        sLogger.info(\"Preview installed successfully\");\n      } else {\n        sLogger.info(\"Preview install failed\");\n      }\n    } catch (Exception e) {\n      sLogger.info(\"Preview install failed\");\n    }\n  }\n\n  private static Unsafe getUnsafe(){\n    Unsafe unsafe = null;\n    try {\n      unsafe = Unsafe.getUnsafe();\n    } catch (SecurityException e){\n      try {\n        Field field = Unsafe.class.getDeclaredField(\"theUnsafe\");\n        field.setAccessible(true);\n        unsafe = (Unsafe) field.get(null);\n      } catch (Exception ignore) {}\n    }\n    return unsafe;\n  }\n\n  private static void installViewFactoryIfNeeded() {\n    Collection<BridgeContext> contexts = peekContexts();\n    for (BridgeContext context : contexts) {\n      LayoutInflater inflater = LayoutInflater.from(context);\n      if (inflater.getFactory2() == null) {\n        inflater.setFactory2(new ViewFactory(inflater, context.getLayoutlibCallback()));\n      }\n    }\n  }\n\n  private static Collection<BridgeContext> peekContexts() {\n    if (sContextMap != null) {\n      return sContextMap.values();\n    } else if (sContextField != null) {\n      try {\n        return Collections.singletonList((BridgeContext) sContextField.get(Resources.getSystem()));\n      } catch (Exception ignore) {}\n    }\n    return Collections.emptyList();\n  }\n\n  static class MyHashMap<K,V> extends HashMap<K,V>{\n    MyHashMap(Map<? extends K, ? extends V> map) {\n      super(map);\n    }\n\n    @Override\n    public V get(Object o) {\n      installViewFactoryIfNeeded();\n      return super.get(o);\n    }\n  }\n\n}\n"
  },
  {
    "path": "lint/src/main/java/cn/cricin/folivora/preview/ViewFactory.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora.preview;\n\nimport android.content.Context;\nimport android.util.AttributeSet;\nimport android.view.LayoutInflater;\nimport android.view.View;\n\nimport com.android.ide.common.rendering.api.LayoutlibCallback;\nimport com.android.layoutlib.bridge.Bridge;\nimport com.android.layoutlib.bridge.android.BridgeContext;\n\nimport java.lang.reflect.Field;\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\nimport java.util.Arrays;\nimport java.util.HashSet;\nimport java.util.Set;\n\n/**\n * A view factory takes responsibility of view creation, if the view\n * is created, folivora will create a drawable for it if available.\n */\nfinal class ViewFactory implements LayoutInflater.Factory2 {\n  private static final String[] sClassPrefixList = {\n    \"android.widget.\",\n    \"android.webkit.\",\n    \"android.app.\",\n    \"android.view.\"\n  };\n  private static final Set<String> APPCOMPAT_VIEWS = new HashSet<>(Arrays.asList(\n    \"TextView\", \"ImageView\", \"Button\", \"EditText\", \"Spinner\", \"ImageButton\",\n    \"CheckBox\", \"RadioButton\", \"CheckedTextView\", \"AutoCompleteTextView\",\n    \"MultiAutoCompleteTextView\", \"RatingBar\", \"SeekBar\"));\n  private static final String sAutoNs = \"http://schemas.android.com/apk/res-auto\";\n  private static boolean sExceptionCaught = false; //only log exception once, don't mess up log file\n  private Set<String> mFailedAppCompatViews = new HashSet<>();\n  private static final Class<?>[] sConstructorSignature = {Context.class, AttributeSet.class};\n  private static final Object[] sConstructorArgs = new Object[2];\n  private static final String sLegacyAppCompatViewPrefix = \"android.support.v7.widget.AppCompat\";\n  private static final String sAndroidxViewPrefix = \"androidx.appcompat.widget.AppCompat\";\n\n  private LayoutInflater mDelegate;\n  private boolean mLoadAppCompatViews;\n  private LayoutlibCallback mLayoutLibCallback;\n  private boolean mUseAndroidx;\n\n  ViewFactory(LayoutInflater inflater, LayoutlibCallback layoutlibCallback) {\n    this.mDelegate = inflater;\n    this.mLayoutLibCallback = layoutlibCallback;\n    this.mLoadAppCompatViews = getContext().isAppCompatTheme();\n    try {\n      this.mUseAndroidx = layoutlibCallback.hasAndroidXAppCompat();\n    } catch (Throwable ignored) {}\n  }\n\n  private BridgeContext getContext() {\n    return (BridgeContext) mDelegate.getContext();\n  }\n\n  @Override\n  public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {\n    View result = null;\n    if (this.mLoadAppCompatViews && APPCOMPAT_VIEWS.contains(name) && !this.mFailedAppCompatViews.contains(name)) {\n      result = this.loadCustomView((mUseAndroidx ? sAndroidxViewPrefix : sLegacyAppCompatViewPrefix) + name, attrs);\n      if (result == null) {\n        this.mFailedAppCompatViews.add(name);\n      }\n    }\n\n    if (result == null) {\n      for (String prefix : sClassPrefixList) {\n        try {\n          result = mDelegate.createView(name, prefix, attrs);\n          if (result != null) {\n            break;\n          }\n        } catch (ClassNotFoundException e) {\n          // In this case we want to let the base class take a crack\n          // at it.\n        }\n      }\n    }\n\n    //if is a custom view\n    if (result == null) {\n      result = loadCustomView(name, attrs);\n    }\n\n    if (result != null) {\n      String drawableType = attrs.getAttributeValue(sAutoNs, \"drawableType\");\n      String drawableName = attrs.getAttributeValue(sAutoNs, \"drawableName\");\n      String drawableId = attrs.getAttributeValue(sAutoNs, \"drawableId\");\n      if (drawableType != null || drawableName != null || drawableId != null) {\n        applyDrawableToView(result, attrs);\n      }\n    }\n    return result;\n  }\n\n  private void applyDrawableToView(View view, AttributeSet attrs) {\n    try {\n      Class<?> c = mLayoutLibCallback.findClass(\"cn.cricin.folivora.Folivora\");\n      Method method = c.getDeclaredMethod(\"applyDrawableToView\", View.class, AttributeSet.class);\n      method.setAccessible(true);\n      Field field = c.getDeclaredField(\"sDrawableCacheEnabled\");\n      field.setAccessible(true);\n      field.set(null, false);\n      method.invoke(null, view, attrs);\n    } catch (Throwable e) {\n      if (e instanceof InvocationTargetException) {\n        Throwable ex = ((InvocationTargetException) e).getTargetException();\n        if (ex instanceof NoClassDefFoundError && ex.getMessage().contains(\"folivora/R$styleable\")) {\n          Bridge.getLog().warning(\"build-needed\", \"folivora not worked due to missing R.class, try assemble project to refresh\", null, null);\n        }\n      } else {\n        if (!sExceptionCaught) {\n          sExceptionCaught = true;\n          FolivoraPreview.sLogger.info(e);\n        }\n      }\n    }\n  }\n\n  private View loadCustomView(String name, AttributeSet attrs) {\n    if (mLayoutLibCallback == null) return null;\n    if (name.equals(\"view\")) {\n      name = attrs.getAttributeValue(null, \"class\");\n      if (name == null) {\n        return null;\n      }\n    }\n    sConstructorArgs[0] = getContext();\n    sConstructorArgs[1] = attrs;\n    Object customView = null;\n\n    try {\n      customView = mLayoutLibCallback.loadView(name, sConstructorSignature, sConstructorArgs);\n    } catch (Exception e) {\n      //empty\n    } finally {\n      sConstructorArgs[0] = null;\n      sConstructorArgs[1] = null;\n    }\n    if (customView instanceof View) {\n      return (View) customView;\n    }\n    return null;\n  }\n\n  @Override\n  public View onCreateView(String name, Context context, AttributeSet attrs) {\n    return onCreateView(null, name, context, attrs);\n  }\n\n}\n"
  },
  {
    "path": "sample/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n  compileSdkVersion 29\n  defaultConfig {\n    applicationId \"cn.cricin.folivora.sample\"\n    minSdkVersion 16\n    targetSdkVersion 29\n    versionCode 1\n    versionName \"1.0\"\n  }\n  buildTypes {\n    release {\n      minifyEnabled false\n      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n    }\n  }\n}\n\ndependencies {\n  implementation 'androidx.annotation:annotation:1.1.0'\n  implementation project(':folivora')\n}\n\ntask copyApkToRootDir(type: Copy) {\n  from(\"$buildDir/outputs/apk/debug/sample-debug.apk\")\n  into(\"$rootProject.projectDir\")\n  rename '-debug', ''\n}"
  },
  {
    "path": "sample/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest\n  xmlns:android=\"http://schemas.android.com/apk/res/android\"\n  xmlns:tools=\"http://schemas.android.com/tools\"\n  package=\"cn.cricin.folivora.sample\">\n\n  <application\n    android:icon=\"@mipmap/ic_launcher\"\n    android:label=\"@string/app_name\"\n    android:supportsRtl=\"true\"\n    android:theme=\"@style/AppTheme\"\n    tools:ignore=\"AllowBackup,GoogleAppIndexingWarning\">\n\n    <activity android:name=\".MainActivity\">\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\n  </application>\n\n</manifest>"
  },
  {
    "path": "sample/src/main/java/cn/cricin/folivora/sample/MainActivity.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora.sample;\n\nimport android.app.Activity;\nimport android.content.Context;\nimport android.content.res.ColorStateList;\nimport android.content.res.TypedArray;\nimport android.graphics.Color;\nimport android.graphics.drawable.ColorDrawable;\nimport android.graphics.drawable.Drawable;\nimport android.graphics.drawable.StateListDrawable;\nimport android.os.Bundle;\nimport android.util.AttributeSet;\nimport android.view.View;\nimport android.widget.TextView;\n\nimport cn.cricin.folivora.DrawableParser;\nimport cn.cricin.folivora.Folivora;\nimport cn.cricin.folivora.OnViewCreatedListener;\nimport cn.cricin.folivora.ParseRequest;\nimport cn.cricin.folivora.RippleFallback;\nimport cn.cricin.folivora.sample.drawable.UmbrellaDrawable;\n\npublic class MainActivity extends Activity {\n\n  @Override\n  protected void attachBaseContext(Context newBase) {\n    super.attachBaseContext(Folivora.wrap(newBase));\n  }\n\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    //Folivora.installViewFactory(this); //if you do not want folivora wraps the base context, using this\n\n    //create a selector if ripple drawable is unavailable\n    Folivora.setRippleFallback(new RippleFallback() {\n      @Override\n      public Drawable onFallback(ColorStateList color, Drawable content, Drawable mask, Context ctx) {\n        StateListDrawable sld = new StateListDrawable();\n        sld.addState(new int[]{android.R.attr.state_pressed}, new ColorDrawable(color.getDefaultColor()));\n        sld.addState(new int[0], content);\n        return sld;\n      }\n    });\n\n    //UmbrellaDrawable does not have a UmbrellaDrawable(Context ctx, AttributeSet attrs)\n    //constructor, so we take over creation here\n    Folivora.registerDrawableParser(UmbrellaDrawable.class, new DrawableParser() {\n      @Override\n      public Drawable parse(ParseRequest request) {\n        TypedArray a = request.context().obtainStyledAttributes(request.attrs(), R.styleable.UmbrellaDrawable);\n        UmbrellaDrawable d = new UmbrellaDrawable();\n        d.setBackgroundColor(a.getColor(R.styleable.UmbrellaDrawable_udBackgroundColor, d.getBackgroundColor()));\n        d.setColor1(a.getColor(R.styleable.UmbrellaDrawable_udColor1, d.getColor1()));\n        d.setColor2(a.getColor(R.styleable.UmbrellaDrawable_udColor2, d.getColor2()));\n        a.recycle();\n        return d;\n      }\n    });\n\n    // If you want to do some further customization, this will be helpful\n    Folivora.addOnViewCreatedListener(new OnViewCreatedListener() {\n      @Override\n      public void onViewCreated(View view, AttributeSet attrs) {\n        //we change text color to green here\n        if (view instanceof TextView) {\n          ((TextView) view).setTextColor(Color.GREEN);\n        }\n      }\n    });\n\n    setContentView(R.layout.activity_main);\n  }\n}\n"
  },
  {
    "path": "sample/src/main/java/cn/cricin/folivora/sample/drawable/AlphaBackgroundDrawable.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora.sample.drawable;\n\nimport android.content.Context;\nimport android.content.res.TypedArray;\nimport android.graphics.Bitmap;\nimport android.graphics.BitmapShader;\nimport android.graphics.Canvas;\nimport android.graphics.Color;\nimport android.graphics.ColorFilter;\nimport android.graphics.Paint;\nimport android.graphics.PixelFormat;\nimport android.graphics.Shader;\nimport android.graphics.drawable.Drawable;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport android.util.AttributeSet;\nimport android.util.TypedValue;\n\nimport cn.cricin.folivora.sample.R;\n\n@SuppressWarnings(\"WeakerAccess, unused\")\npublic class AlphaBackgroundDrawable extends Drawable {\n  private static final int DEFAULT_COLOR_0 = Color.WHITE;\n  private static final int DEFAULT_COLOR_1 = Color.BLACK;\n  private static final int DEFAULT_SQUARE_SIZE = 8;//dp\n\n  private Paint mPaint;\n\n  public AlphaBackgroundDrawable(Context ctx) {\n    initPaint(DEFAULT_COLOR_0,\n      DEFAULT_COLOR_1,\n      (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_SQUARE_SIZE,\n        ctx.getResources().getDisplayMetrics()));\n  }\n\n  public AlphaBackgroundDrawable(Context ctx, AttributeSet attrs) {\n    TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.AlphaBackgroundDrawable);\n    final int color0 = a.getColor(R.styleable.AlphaBackgroundDrawable_abdSquareColor0, DEFAULT_COLOR_0);\n    final int color1 = a.getColor(R.styleable.AlphaBackgroundDrawable_abdSquareColor1, DEFAULT_COLOR_1);\n    final int squareSize = a.getDimensionPixelSize(R.styleable.AlphaBackgroundDrawable_abdSquareSize,\n      DEFAULT_SQUARE_SIZE);\n    a.recycle();\n\n    initPaint(color0, color1, squareSize);\n  }\n\n  @SuppressWarnings(\"SuspiciousNameCombination\")\n  void initPaint(int color0, int color1, int squareSize) {\n    final int squareSizeX2 = squareSize * 2;\n\n    Bitmap temp = Bitmap.createBitmap(squareSizeX2, squareSizeX2, Bitmap.Config.ARGB_8888);\n    Canvas canvas = new Canvas(temp);\n    Paint paint = new Paint();\n    paint.setColor(color0);\n    canvas.drawRect(0, 0, squareSize, squareSize, paint);\n    canvas.drawRect(squareSize, squareSize, squareSizeX2, squareSizeX2, paint);\n\n    paint.setColor(color1);\n    canvas.drawRect(squareSize, 0, squareSizeX2, squareSize, paint);\n    canvas.drawRect(0, squareSize, squareSize, squareSizeX2, paint);\n    Bitmap bg = Bitmap.createBitmap(temp);\n    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);\n    BitmapShader bs = new BitmapShader(bg, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);\n    mPaint.setShader(bs);\n  }\n\n  @Override\n  public void draw(@NonNull Canvas canvas) {\n    canvas.save();\n    canvas.clipRect(getBounds());\n    canvas.drawRect(getBounds(), mPaint);\n    canvas.restore();\n  }\n\n  @Override\n  public void setAlpha(int alpha) {\n    mPaint.setAlpha(alpha);\n  }\n\n  @Override\n  public void setColorFilter(@Nullable ColorFilter colorFilter) {\n    mPaint.setColorFilter(colorFilter);\n  }\n\n  @Override\n  public int getOpacity() {\n    int alpha = mPaint.getAlpha();\n    if (alpha == 255) {\n      return PixelFormat.OPAQUE;\n    } else if (alpha == 0) {\n      return PixelFormat.TRANSPARENT;\n    } else {\n      return PixelFormat.TRANSLUCENT;\n    }\n  }\n}\n"
  },
  {
    "path": "sample/src/main/java/cn/cricin/folivora/sample/drawable/UmbrellaDrawable.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora.sample.drawable;\n\nimport android.graphics.Canvas;\nimport android.graphics.Color;\nimport android.graphics.ColorFilter;\nimport android.graphics.LinearGradient;\nimport android.graphics.Paint;\nimport android.graphics.Path;\nimport android.graphics.PixelFormat;\nimport android.graphics.Rect;\nimport android.graphics.Shader;\nimport android.graphics.drawable.Drawable;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\n\nimport java.util.Arrays;\nimport java.util.List;\n\n\n@SuppressWarnings(\"unused\")\npublic class UmbrellaDrawable extends Drawable {\n  private static final float TAN20 = (float) Math.tan(Math.toRadians(20));\n\n  private Shader mShader1;\n  private Shader mShader2;\n\n  private int mColor1;\n  private int mColor2;\n  private int mBackgroundColor;\n\n  private Path mPath;\n  private Paint mPaint;\n\n  public UmbrellaDrawable() {\n    mColor1 = Color.RED;\n    mColor2 = Color.WHITE;\n    mBackgroundColor = Color.BLACK;\n    mPath = new Path();\n    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);\n  }\n\n  @Override\n  public void draw(@NonNull Canvas canvas) {\n    Rect bounds = getBounds();\n    canvas.save();\n    canvas.clipRect(bounds);\n    canvas.drawColor(mBackgroundColor);\n    canvas.translate(bounds.centerX(), bounds.centerY());\n    List<Shader> shaderList = Arrays.asList(mShader1, mShader2);\n    for (int i = 0; i < 8; i++) {\n      mPaint.setShader(shaderList.get(i % 2));\n      canvas.drawPath(mPath, mPaint);\n      canvas.rotate(45);\n    }\n    canvas.restore();\n  }\n\n  @Override\n  protected void onBoundsChange(Rect bounds) {\n    final int radius = Math.max(bounds.width(), bounds.height()) / 2;\n    mPath.reset();\n    mPath.moveTo(radius * 0.07F, 0);\n    mPath.lineTo(radius, -radius * TAN20);\n    mPath.quadTo(0.7F * radius, 0, radius, radius * TAN20);\n    mPath.close();\n\n    createShader();\n  }\n\n  private void createShader() {\n    Rect bounds = getBounds();\n    if (bounds.isEmpty()) return;\n    final int radius = Math.max(bounds.width(), bounds.height()) / 2;\n    mShader1 = new LinearGradient(0, 0, radius, 0, mColor1, mBackgroundColor, Shader.TileMode.CLAMP);\n    mShader2 = new LinearGradient(0, 0, radius, 0, mColor2, mBackgroundColor, Shader.TileMode.CLAMP);\n  }\n\n  public void setColor1(int color) {\n    if (mColor1 != color) {\n      mColor1 = color;\n      createShader();\n      invalidateSelf();\n    }\n  }\n\n  public void setColor2(int color) {\n    if (mColor2 != color) {\n      mColor2 = color;\n      createShader();\n      invalidateSelf();\n    }\n  }\n\n  public void setBackgroundColor(int color) {\n    if (mBackgroundColor != color) {\n      mBackgroundColor = color;\n      invalidateSelf();\n    }\n  }\n\n  public int getColor1() {\n    return mColor1;\n  }\n\n  public int getColor2() {\n    return mColor2;\n  }\n\n  public int getBackgroundColor() {\n    return mBackgroundColor;\n  }\n\n\n  @Override\n  public void setAlpha(int alpha) {\n    //not supported\n  }\n\n  @Override\n  public void setColorFilter(@Nullable ColorFilter colorFilter) {\n    //not supported\n  }\n\n  @Override\n  public int getOpacity() {\n    return PixelFormat.OPAQUE;\n  }\n}"
  },
  {
    "path": "sample/src/main/java/cn/cricin/folivora/sample/drawable/WindmillDrawable.java",
    "content": "/*\n * Copyright (C) 2019 Cricin\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\npackage cn.cricin.folivora.sample.drawable;\n\nimport android.content.Context;\nimport android.content.res.TypedArray;\nimport android.graphics.Canvas;\nimport android.graphics.Color;\nimport android.graphics.ColorFilter;\nimport android.graphics.Paint;\nimport android.graphics.PixelFormat;\nimport android.graphics.Rect;\nimport android.graphics.RectF;\nimport android.graphics.drawable.Drawable;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport android.util.AttributeSet;\nimport android.util.TypedValue;\n\nimport cn.cricin.folivora.sample.R;\n\n@SuppressWarnings(\"WeakerAccess, unused\")\npublic class WindmillDrawable extends Drawable {\n  private static final int DEFAULT_SIZE = 100;//dp\n  private static final int DEFAULT_CENTER_DOT_RADIUS = 4;//dp\n\n  private Paint mPaint;\n  private int mSize;\n  private int[] mColors;\n  private RectF mRectF = new RectF();\n  private int mCenterDotColor;\n  private int mCenterDotRadius;\n  private int mRotateDegrees;\n\n  public WindmillDrawable(Context ctx) {\n    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);\n    mColors = new int[]{Color.RED, Color.GREEN, Color.BLUE, Color.BLACK};\n    mSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,\n      DEFAULT_SIZE, ctx.getResources().getDisplayMetrics());\n    mCenterDotRadius = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,\n      DEFAULT_CENTER_DOT_RADIUS, ctx.getResources().getDisplayMetrics());\n    mCenterDotColor = Color.WHITE;\n  }\n\n  public WindmillDrawable(Context ctx, AttributeSet attrs) {\n    this(ctx);\n    TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.WindmillDrawable);\n    int count = a.getIndexCount();\n    for (int i = 0; i < count; i++) {\n      int index = a.getIndex(i);\n      switch (index) {\n        case R.styleable.WindmillDrawable_wdSize:\n          mSize = a.getDimensionPixelSize(index, mSize);\n          break;\n        case R.styleable.WindmillDrawable_wdColor0:\n          mColors[0] = a.getColor(index, mColors[0]);\n          break;\n        case R.styleable.WindmillDrawable_wdColor1:\n          mColors[1] = a.getColor(index, mColors[1]);\n          break;\n        case R.styleable.WindmillDrawable_wdColor2:\n          mColors[2] = a.getColor(index, mColors[2]);\n          break;\n        case R.styleable.WindmillDrawable_wdColor3:\n          mColors[3] = a.getColor(index, mColors[3]);\n          break;\n        case R.styleable.WindmillDrawable_wdCenterDotRadius:\n          mCenterDotRadius = a.getDimensionPixelSize(index, mCenterDotRadius);\n          break;\n        case R.styleable.WindmillDrawable_wdCenterDotColor:\n          mCenterDotColor = a.getColor(index, mCenterDotColor);\n          break;\n        case R.styleable.WindmillDrawable_wdRotateDegrees:\n          mRotateDegrees = a.getInt(index, 0);\n          break;\n        default://no-op\n          break;\n      }\n    }\n    a.recycle();\n  }\n\n  @Override\n  public void draw(@NonNull Canvas canvas) {\n    final Rect bounds = getBounds();\n    canvas.save();\n    canvas.clipRect(bounds);\n    canvas.translate(bounds.centerX(), bounds.centerY());\n    canvas.rotate(mRotateDegrees);\n    float radius = Math.min(bounds.width(), bounds.height()) / (float) 2;\n    mRectF.set(0, -radius / 2, radius, radius / 2);\n    for (int i = 0; i < mColors.length; i++) {\n      mPaint.setColor(mColors[i]);\n      canvas.rotate(90 * i);\n      canvas.drawArc(mRectF, 0, 180, true, mPaint);\n    }\n    mPaint.setColor(mCenterDotColor);\n    canvas.drawCircle(0, 0, mCenterDotRadius, mPaint);\n    canvas.restore();\n  }\n\n  @Override\n  public void setAlpha(int alpha) {\n    mPaint.setAlpha(alpha);\n  }\n\n  @Override\n  public void setColorFilter(@Nullable ColorFilter colorFilter) {\n    mPaint.setColorFilter(colorFilter);\n  }\n\n  @Override\n  public int getOpacity() {\n    return PixelFormat.TRANSLUCENT;\n  }\n\n  @Override\n  public int getIntrinsicWidth() {\n    return mSize;\n  }\n\n  @Override\n  public int getIntrinsicHeight() {\n    return mSize;\n  }\n}\n"
  },
  {
    "path": "sample/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?><!--\n  * Copyright (C) 2019 Cricin\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\n<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n  xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n  xmlns:tools=\"http://schemas.android.com/tools\"\n  android:layout_width=\"match_parent\"\n  android:layout_height=\"match_parent\"\n  tools:context=\".MainActivity\"\n  tools:ignore=\"MissingPrefix,Rtlhardcoded, HardcodedText\">\n\n  <LinearLayout\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\"\n    android:layout_marginLeft=\"10dp\"\n    android:orientation=\"vertical\">\n\n    <TextView\n      android:layout_width=\"wrap_content\"\n      android:layout_height=\"wrap_content\"\n      android:layout_marginTop=\"10dp\"\n      android:text=\"Drawables builtin supported:\"\n      android:textColor=\"@color/colorPrimary\" />\n\n    <LinearLayout\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:layout_marginTop=\"10dp\"\n      android:orientation=\"horizontal\">\n\n      <TextView\n        android:layout_width=\"100dp\"\n        android:layout_height=\"40dp\"\n        android:gravity=\"center\"\n        android:text=\"shape1\"\n        android:textColor=\"@color/white\"\n        app:drawableType=\"shape\"\n        app:shapeCornerRadius=\"10dp\"\n        app:shapeSolidColor=\"@color/blue_light\" />\n\n      <TextView\n        android:layout_width=\"50dp\"\n        android:layout_height=\"50dp\"\n        android:layout_marginLeft=\"10dp\"\n        android:gravity=\"center\"\n        android:text=\"shape2\"\n        android:textColor=\"@color/white\"\n        app:drawableType=\"shape\"\n        app:shapeCornerRadius=\"40dp\"\n        app:shapeSolidColor=\"@color/blue_light\" />\n\n      <TextView\n        android:layout_width=\"100dp\"\n        android:layout_height=\"40dp\"\n        android:layout_marginLeft=\"10dp\"\n        android:gravity=\"center\"\n        android:text=\"shape3\"\n        android:textColor=\"@color/white\"\n        app:drawableType=\"shape\"\n        app:shapeGradientAngle=\"lr\"\n        app:shapeGradientCenterColor=\"@color/blue_light\"\n        app:shapeGradientEndColor=\"@color/red\"\n        app:shapeGradientStartColor=\"@color/purple\" />\n\n    </LinearLayout>\n\n    <LinearLayout\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:layout_marginTop=\"10dp\"\n      android:orientation=\"horizontal\">\n\n      <TextView\n        android:layout_width=\"100dp\"\n        android:layout_height=\"40dp\"\n        android:gravity=\"center\"\n        android:text=\"layerlist\"\n        android:textColor=\"@color/white\"\n        app:drawableType=\"layer_list\"\n        app:layerItem0Drawable=\"@color/blue_light\"\n        app:layerItem1Drawable=\"@color/purple\"\n        app:layerItem1Insets=\"4dp\"\n        app:layerItem2Drawable=\"@color/blue_dark\"\n        app:layerItem2Insets=\"8dp\" />\n\n      <TextView\n        android:layout_width=\"100dp\"\n        android:layout_height=\"40dp\"\n        android:layout_marginLeft=\"10dp\"\n        android:clickable=\"true\"\n        android:focusable=\"true\"\n        android:gravity=\"center\"\n        android:text=\"selector\"\n        android:textColor=\"@color/white\"\n        app:drawableType=\"selector\"\n        app:selectorStateNormal=\"@color/blue_light\"\n        app:selectorStatePressed=\"@color/blue_dark\" />\n\n      <TextView\n        android:layout_width=\"100dp\"\n        android:layout_height=\"40dp\"\n        android:layout_marginLeft=\"10dp\"\n        android:clickable=\"true\"\n        android:focusable=\"true\"\n        android:gravity=\"center\"\n        android:text=\"levellist\"\n        android:textColor=\"@color/white\"\n        app:drawableType=\"level_list\"\n        app:levelCurrentLevel=\"95\"\n        app:levelItem0Drawable=\"@color/green_dark\"\n        app:levelItem1Drawable=\"@color/blue_light\"\n        app:levelItem1MaxLevel=\"100\"\n        app:levelItem1MinLevel=\"90\" />\n\n    </LinearLayout>\n\n    <LinearLayout\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:layout_marginTop=\"10dp\"\n      android:orientation=\"horizontal\">\n\n      <TextView\n        android:layout_width=\"100dp\"\n        android:layout_height=\"40dp\"\n        android:clickable=\"true\"\n        android:focusable=\"true\"\n        android:gravity=\"center\"\n        android:text=\"ripple\"\n        android:textColor=\"@color/white\"\n        app:drawableType=\"ripple\"\n        app:rippleColor=\"@color/white\"\n        app:rippleContent=\"@color/blue_light\" />\n\n      <FrameLayout\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_marginLeft=\"10dp\"\n        app:drawableType=\"shape\"\n        app:shapeStrokeColor=\"@color/green_light\"\n        app:shapeStrokeWidth=\"1dp\">\n\n        <TextView\n          android:layout_width=\"100dp\"\n          android:layout_height=\"40dp\"\n          android:gravity=\"center\"\n          android:text=\"clip\"\n          android:textColor=\"@color/white\"\n          app:clipDrawable=\"@color/blue_light\"\n          app:clipLevel=\"6000\"\n          app:drawableType=\"clip\" />\n\n      </FrameLayout>\n\n      <FrameLayout\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_marginLeft=\"10dp\"\n        app:drawableType=\"shape\"\n        app:shapeStrokeColor=\"@color/green_light\"\n        app:shapeStrokeWidth=\"1dp\">\n\n        <TextView\n          android:layout_width=\"100dp\"\n          android:layout_height=\"40dp\"\n          android:gravity=\"center\"\n          android:text=\"inset\"\n          android:textColor=\"@color/white\"\n          app:drawableType=\"inset\"\n          app:insetAll=\"4dp\"\n          app:insetDrawable=\"@color/blue_light\" />\n\n      </FrameLayout>\n\n    </LinearLayout>\n\n    <LinearLayout\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:layout_marginTop=\"10dp\"\n      android:orientation=\"horizontal\">\n\n      <FrameLayout\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        app:drawableType=\"shape\"\n        app:shapeStrokeColor=\"@color/green_light\"\n        app:shapeStrokeWidth=\"1dp\">\n\n        <TextView\n          android:layout_width=\"100dp\"\n          android:layout_height=\"40dp\"\n          android:gravity=\"center\"\n          android:text=\"scale\"\n          android:textColor=\"@color/white\"\n          app:drawableType=\"scale\"\n          app:scaleDrawable=\"@color/blue_light\"\n          app:scaleGravity=\"center\"\n          app:scaleHeight=\"0.3\"\n          app:scaleWidth=\"0.3\" />\n\n      </FrameLayout>\n\n      <TextView\n        android:layout_width=\"100dp\"\n        android:layout_height=\"40dp\"\n        android:layout_marginLeft=\"10dp\"\n        android:gravity=\"center\"\n        android:text=\"animation\"\n        android:textColor=\"@color/white\"\n        app:animAutoPlay=\"true\"\n        app:animDuration=\"300\"\n        app:animFrame0=\"@drawable/animation0\"\n        app:animFrame1=\"@drawable/animation1\"\n        app:animFrame2=\"@drawable/animation2\"\n        app:animFrame3=\"@drawable/animation3\"\n        app:animFrame4=\"@drawable/animation4\"\n        app:animFrame5=\"@drawable/animation5\"\n        app:animFrame6=\"@drawable/animation6\"\n        app:animFrame7=\"@drawable/animation7\"\n        app:animFrame8=\"@drawable/animation8\"\n        app:animFrame9=\"@drawable/animation9\"\n        app:drawableType=\"animation\" />\n\n      <TextView\n        android:layout_width=\"100dp\"\n        android:layout_height=\"40dp\"\n        android:layout_marginLeft=\"10dp\"\n        android:clickable=\"true\"\n        android:focusable=\"true\"\n        android:gravity=\"center\"\n        android:text=\"nested shape\"\n        android:textColor=\"@color/white\"\n        app:drawableType=\"selector\"\n        app:selectorStateNormal=\"shape\"\n        app:selectorStatePressed=\"shape1\"\n        app:shape1CornerRadius=\"10dp\"\n        app:shape1SolidColor=\"@color/blue_dark\"\n        app:shapeCornerRadius=\"10dp\"\n        app:shapeSolidColor=\"@color/blue_light\" />\n\n    </LinearLayout>\n\n    <LinearLayout\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:layout_marginTop=\"10dp\"\n      android:orientation=\"horizontal\">\n\n      <TextView\n        android:layout_width=\"100dp\"\n        android:layout_height=\"40dp\"\n        android:clickable=\"true\"\n        android:focusable=\"true\"\n        android:gravity=\"center\"\n        android:text=\"new selector\"\n        android:textColor=\"@color/white\"\n        app:drawableId=\"selector_pressed\"\n        app:drawableType=\"selector\"\n        app:selectorItem0Drawable=\"@color/blue_dark\"\n        app:selectorItem0States=\"pressed\"\n        app:selectorStateNormal=\"@color/blue_light\" />\n\n      <TextView\n        android:layout_width=\"100dp\"\n        android:layout_height=\"40dp\"\n        android:layout_marginLeft=\"10dp\"\n        android:clickable=\"true\"\n        android:focusable=\"true\"\n        android:gravity=\"center\"\n        android:text=\"new selector\"\n        android:textColor=\"@color/white\"\n        app:drawableId=\"selector_pressed\" />\n\n    </LinearLayout>\n\n    <TextView\n      android:layout_width=\"wrap_content\"\n      android:layout_height=\"wrap_content\"\n      android:layout_marginTop=\"10dp\"\n      android:text=\"Custom drawables loaded by it's constructor:\"\n      android:textColor=\"@color/colorPrimary\" />\n\n    <LinearLayout\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:layout_marginTop=\"10dp\"\n      android:orientation=\"horizontal\">\n\n      <View\n        android:layout_width=\"120dp\"\n        android:layout_height=\"120dp\"\n        app:drawableName=\"cn.cricin.folivora.sample.drawable.WindmillDrawable\"\n        app:wdColor0=\"@color/blue_light\"\n        app:wdColor1=\"@color/green_dark\"\n        app:wdColor2=\"@color/green_light\"\n        app:wdColor3=\"@color/purple\"\n        app:wdRotateDegrees=\"45\" />\n\n      <View\n        android:layout_width=\"120dp\"\n        android:layout_height=\"120dp\"\n        android:layout_marginLeft=\"10dp\"\n        app:abdSquareColor0=\"@color/gray\"\n        app:abdSquareColor1=\"@color/gray_light\"\n        app:abdSquareSize=\"5dp\"\n        app:drawableName=\"cn.cricin.folivora.sample.drawable.AlphaBackgroundDrawable\" />\n\n    </LinearLayout>\n\n    <TextView\n      android:layout_width=\"wrap_content\"\n      android:layout_height=\"wrap_content\"\n      android:layout_marginTop=\"10dp\"\n      android:text=\"Custom drawables loaded by DrawableFactory:\"\n      android:textColor=\"@color/colorPrimary\" />\n\n    <LinearLayout\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:layout_marginTop=\"10dp\"\n      android:orientation=\"horizontal\">\n\n      <View\n        android:layout_width=\"120dp\"\n        android:layout_height=\"120dp\"\n        app:drawableName=\"cn.cricin.folivora.sample.drawable.UmbrellaDrawable\"\n        app:udBackgroundColor=\"@color/black\"\n        app:udColor1=\"@color/red\"\n        app:udColor2=\"@color/white\" />\n\n      <View\n        android:layout_width=\"120dp\"\n        android:layout_height=\"120dp\"\n        android:layout_marginLeft=\"10dp\"\n        app:drawableName=\"cn.cricin.folivora.sample.drawable.UmbrellaDrawable\"\n        app:udBackgroundColor=\"@color/black\"\n        app:udColor1=\"@color/green_dark\"\n        app:udColor2=\"@color/white\" />\n\n    </LinearLayout>\n\n  </LinearLayout>\n\n</ScrollView>\n"
  },
  {
    "path": "sample/src/main/res/values/attrs.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n  <declare-styleable name=\"WindmillDrawable\">\n    <attr name=\"wdSize\" format=\"dimension\"/>\n    <attr name=\"wdColor0\" format=\"color\"/>\n    <attr name=\"wdColor1\" format=\"color\"/>\n    <attr name=\"wdColor2\" format=\"color\"/>\n    <attr name=\"wdColor3\" format=\"color\"/>\n    <attr name=\"wdCenterDotRadius\" format=\"dimension\"/>\n    <attr name=\"wdCenterDotColor\" format=\"color\"/>\n    <attr name=\"wdRotateDegrees\" format=\"integer\"/>\n  </declare-styleable>\n\n  <declare-styleable name=\"AlphaBackgroundDrawable\">\n    <attr name=\"abdSquareSize\" format=\"dimension\"/>\n    <attr name=\"abdSquareColor0\" format=\"color\"/>\n    <attr name=\"abdSquareColor1\" format=\"color\"/>\n  </declare-styleable>\n\n  <declare-styleable name=\"UmbrellaDrawable\">\n    <attr name=\"udBackgroundColor\" format=\"color\"/>\n    <attr name=\"udColor1\" format=\"color\"/>\n    <attr name=\"udColor2\" format=\"color\"/>\n  </declare-styleable>\n\n</resources>"
  },
  {
    "path": "sample/src/main/res/values/colors.xml",
    "content": "<resources>\n  <color name=\"colorPrimary\">#008577</color>\n  <color name=\"colorPrimaryDark\">#00574B</color>\n  <color name=\"colorAccent\">@android:color/holo_blue_light</color>\n  <color name=\"red\">#FF0000</color>\n  <color name=\"white\">#FFFFFF</color>\n  <color name=\"black\">#000000</color>\n  <color name=\"gray_light\">#DDDDDD</color>\n  <color name=\"gray\">#888888</color>\n  <color name=\"purple\">@android:color/holo_purple</color>\n  <color name=\"blue_light\">@android:color/holo_blue_light</color>\n  <color name=\"blue_dark\">@android:color/holo_blue_dark</color>\n  <color name=\"green_light\">@android:color/holo_green_light</color>\n  <color name=\"green_dark\">@color/colorPrimary</color>\n</resources>\n"
  },
  {
    "path": "sample/src/main/res/values/strings.xml",
    "content": "<resources>\n  <string name=\"app_name\">Folivora-Sample</string>\n</resources>\n"
  },
  {
    "path": "sample/src/main/res/values/styles.xml",
    "content": "<resources>\n\n  <!-- Base application theme. -->\n  <style name=\"AppTheme\"/>\n\n</resources>\n"
  },
  {
    "path": "settings.gradle",
    "content": "include ':sample'\ninclude ':folivora'\ninclude ':lint'"
  }
]