[
  {
    "path": ".github/ISSUE_TEMPLATE.md",
    "content": "<!-- 提问前有看 常见 issues (https://github.com/JessYanCoding/AndroidAutoSize/issues/13) 和 历史 issues (https://github.com/JessYanCoding/AndroidAutoSize/issues?q=is%3Aissue+is%3Aclosed) 吗？也许里面就有答案，节约你我时间！-->\n<!-- 请将以下信息尽量提供完整，可以帮助框架维护者更快的定位错误，节约大家的时间，如果提问只有标题，没有提供其他有价值的信息，那你的 issues 有很大几率被直接 close!-->\n<!-- Issues 有效周期是一个星期，如果在一个星期内提问者不回复作者以及维护者的消息，或者不积极配合作者以及维护者提供有效信息帮助解决 issues，那作者和维护者有权利将此 issues 当作无效 issues 进行 close 处理，开源社区一定是大家一起维护才能繁荣昌盛，一定不要把自己当作一个消费者去使用开源项目，这样将没有人再愿意为你开源任何项目!-->\n### Environment\n- [x] Autosize Version: <!-- like: v0.7.0 -->\n- [x] Target Android Version: <!-- like: Android 8.0 -->\n- [x] Device Model: <!-- like: Nexus 6 -->\n- [x] Device Resolution: <!-- like: 1080px * 1920px -->\n- [x] Design Size On AndroidManifest: <!-- like: 360dp * 640dp -->\n\n\n### Bug Description:\n<!-- 提问前确定你看过 https://www.jianshu.com/p/55e0fca23b4f，里面有此框架的原理，看完原理你才能更好的使用本框架-->\n\n\n### Log:\n<!-- 在日志中搜索 AndroidAutoSize 找到框架日志复制或截图 -->\n```log\n\n\n```\n\n\n### Screenshot\n<!-- 如果 View 显示有问题，最好提供页面截图-->\n\n\n### Related Code:\n```java\n  \n\n```\n\n\n### Others:\n"
  },
  {
    "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\n\n# Keystore files\n*.jks\n\n# MacOS\n.DS_Store\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: android\njdk: oraclejdk8\nbefore_install:\n- yes | sdkmanager \"platforms;android-29\"\n\nenv:\n  global:\n    - ANDROID_API_LEVEL=29\n    - ANDROID_BUILD_TOOLS_VERSION=29.0.2\n    - TRAVIS_SECURE_ENV_VARS=true\n\nandroid:\n  components:\n    # The BuildTools version used by your project\n    - tools\n    - platform-tools\n    - build-tools-$ANDROID_BUILD_TOOLS_VERSION\n    - extra-android-m2repository\n    - extra-google-android-support\n\n    # The SDK version used to compile your project\n    - android-$ANDROID_API_LEVEL\n  licenses:\n    - '.+'\n\nscript:\n    - ./gradlew clean\n    - ./gradlew assembleDebug"
  },
  {
    "path": "CHANGELOG.md",
    "content": "[ChangeLog](https://github.com/JessYanCoding/AndroidAutoSize/releases)"
  },
  {
    "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": "![Logo](art/autosize_banner.jpg)\n![Official](https://raw.githubusercontent.com/JessYanCoding/MVPArms/master/image/official.jpeg)\n\n<p align=\"center\">\n   <a href=\"https://bintray.com/jessyancoding/maven/autosize/_latestVersion\">\n    <img src=\"https://img.shields.io/badge/Jcenter-v1.2.1-brightgreen.svg?style=flat-square\" alt=\"Latest Stable Version\" />\n  </a>\n  <a href=\"https://travis-ci.org/JessYanCoding/AndroidAutoSize\">\n    <img src=\"https://travis-ci.org/JessYanCoding/AndroidAutoSize.svg?branch=master\" alt=\"Build Status\" />\n  </a>\n  <a href=\"https://developer.android.com/about/versions/android-4.0.html\">\n    <img src=\"https://img.shields.io/badge/API-14%2B-blue.svg?style=flat-square\" alt=\"Min Sdk Version\" />\n  </a>\n  <a href=\"http://www.apache.org/licenses/LICENSE-2.0\">\n    <img src=\"http://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square\" alt=\"License\" />\n  </a>\n  <a href=\"https://www.jianshu.com/u/1d0c0bc634db\">\n    <img src=\"https://img.shields.io/badge/Author-JessYan-orange.svg?style=flat-square\" alt=\"Author\" />\n  </a>\n  <a href=\"https://shang.qq.com/wpa/qunwpa?idkey=7e59e59145e6c7c68932ace10f52790636451f01d1ecadb6a652b1df234df753\">\n    <img src=\"https://img.shields.io/badge/QQ%E7%BE%A4-455850365%20%7C%20301733278-orange.svg?style=flat-square\" alt=\"QQ Group\" />\n  </a>\n</p>\n\n\n## 今日头条屏幕适配方案终极版，一个极低成本的 Android 屏幕适配方案.\n\n\n## Overview\n### Pixel 2 XL | 1440 x 2880 | 560dpi:\n<p>\n   <img src=\"art/1440x2880_width.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/1440x2880_height.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/1440x2880_external.png\" width=\"30%\" height=\"30%\">\n</p>\n\n### Pixel XL | 1440 x 2560 | 560dpi:\n<p>\n   <img src=\"art/1440x2560_width.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/1440x2560_height.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/1440x2560_external.png\" width=\"30%\" height=\"30%\">\n</p>\n\n### Nexus 5X | 1080 x 1920 | 420dpi:\n<p>\n   <img src=\"art/1080x1920_width.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/1080x1920_height.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/1080x1920_external.png\" width=\"30%\" height=\"30%\">\n</p>\n\n### Nexus 4 | 768 x 1280 | 320dpi:\n<p>\n   <img src=\"art/768x1280_width.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/768x1280_height.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/768x1280_external.png\" width=\"30%\" height=\"30%\">\n</p>\n\n### Nexus S | 480 x 800 | 240dpi:\n<p>\n   <img src=\"art/480x800_width.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/480x800_height.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/480x800_external.png\" width=\"30%\" height=\"30%\">\n</p>\n\n## Notice\n* [主流机型设备信息，可以作为参考](https://material.io/tools/devices/)\n\n* [功能介绍](https://juejin.im/post/5bce688e6fb9a05cf715d1c2)\n\n* [原理分析](https://juejin.im/post/5b7a29736fb9a019d53e7ee2)\n\n* [今日头条屏幕适配方案常见问题汇总](https://github.com/JessYanCoding/AndroidAutoSize/issues/13)\n\n* [Android 进阶框架](https://github.com/JessYanCoding/MVPArms)\n\n* 对于老项目，如果使用了 **AndroidAutoLayout**，请参考 [**AndroidAutoLayout** 迁移指南](https://github.com/JessYanCoding/AndroidAutoSize/issues/90)，**AndroidAutoSize** 可以和 [**AndroidAutoLayout**](https://github.com/hongyangAndroid/AndroidAutoLayout) 一起使用，因为 **AndroidAutoLayout** 使用的是 **px**，所以 **AndroidAutoSize** 对它不会产生任何影响，如果老项目的某些页面之前使用了 **dp** 进行布局，并且 **AndroidAutoSize** 对这些页面已经产生了不良影响，可以让之前使用了 **dp** 的旧 **Activity** 实现 **CancelAdapt** 取消适配，**建议使用副单位，使用副单位则不会影响之前使用了 dp 的页面 (也不会影响三方库和系统控件)，详情请查看 [demo-subunits](https://github.com/JessYanCoding/AndroidAutoSize/tree/master/demo-subunits)** \n\n## Download\n### Jcenter ([ ⚠️ 已停止维护: 2022 年 2 月 1 日之后 JCenter 远程仓库将无法使用](https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter)):\n``` gradle\n implementation 'me.jessyan:autosize:1.2.1'\n```\n\n### JitPack:\nStep 1. Add the JitPack repository in your root [build.gradle](https://github.com/JessYanCoding/AndroidAutoSize/blob/master/build.gradle#L20) at the end of repositories:\n\n```gradle\nallprojects {\n    repositories {\n        ...\n        maven { url \"https://jitpack.io\" }\n    }\n}\n```\n\nStep 2. Add the dependency\n\n```gradle\ndependencies {\n    implementation 'com.github.JessYanCoding:AndroidAutoSize:v1.2.1'\n}\n```\n\n## Usage\n### Step 1 (真的不吹牛逼，只需要以下这一步，框架就可以对项目中的所有页面进行适配)\n* **请在 AndroidManifest 中填写全局设计图尺寸 (单位 dp)，如果使用副单位，则可以直接填写像素尺寸，不需要再将像素转化为 dp，详情请查看 [demo-subunits](https://github.com/JessYanCoding/AndroidAutoSize/tree/master/demo-subunits)**\n```xml\n<manifest>\n    <application>            \n        <meta-data\n            android:name=\"design_width_in_dp\"\n            android:value=\"360\"/>\n        <meta-data\n            android:name=\"design_height_in_dp\"\n            android:value=\"640\"/>           \n     </application>           \n</manifest>\n```\n\n<a name=\"preview\"></a>\n## Preview\n* 布局时的实时预览在开发阶段是一个很重要的环节，很多情况下 **Android Studio** 提供的默认预览设备并不能完全展示我们的设计图，所以我们就需要自己创建模拟设备，下面就介绍下 **dp、pt、in、mm** 这四种单位的模拟设备创建方法\n\n* 如果您在预览时不希望在 **Preview** 中出现状态栏和导航栏, 则可以根据下图选择 **panel** 主题，使用该主题后纵向分辨率刚好填充整个预览页面，显示效果完全和设计图一致\n![theme](art/theme_panel.png)\n\n* 为了方便广大新手，所以还是将创建模拟设备的步骤贴出来，为大家操碎了心，如果觉得 **AndroidAutoSize** 不错，请一定记得 **star**，并将 **AndroidAutoSize** 推荐给您的伙伴们\n![create step](art/create_step.png)\n\n### DP\n* 如果您在 **layout** 文件中使用 **dp** 作为单位进行布局 (**AndroidAutoSize** 默认支持 **dp、sp** 进行布局)，则可以根据公式 **(sqrt(纵向分辨率^2+横向分辨率^2))/dpi** 求出屏幕尺寸，然后创建模拟设备 (**只用填写屏幕尺寸和分辨率**)\n![dp](art/unit_dp.png)\n\n### PT\n* 如果您在 **layout** 文件中使用 **pt** 作为单位进行布局 (需要通过 **AutoSizeConfig.getInstance().getUnitsManager().setSupportSubunits(Subunits.PT);** 打开对单位 **pt** 的支持)，则可以根据公式 **(sqrt(纵向分辨率^2+横向分辨率^2))/72** 求出屏幕尺寸，然后创建模拟设备 (**只用填写屏幕尺寸和分辨率**)\n![pt](art/unit_pt.png)\n\n### IN\n* 如果您在 **layout** 文件中使用 **in** 作为单位进行布局 (需要通过 **AutoSizeConfig.getInstance().getUnitsManager().setSupportSubunits(Subunits.IN);** 打开对单位 **in** 的支持)，则可以根据公式 **sqrt(纵向分辨率^2+横向分辨率^2)** 求出屏幕尺寸，然后创建模拟设备 (**只用填写屏幕尺寸和分辨率**)\n![in](art/unit_in.png)\n\n### MM\n* 如果您在 **layout** 文件中使用 **mm** 作为单位进行布局 (需要通过 **AutoSizeConfig.getInstance().getUnitsManager().setSupportSubunits(Subunits.MM);** 打开对单位 **mm** 的支持)，则可以根据公式 **(sqrt(纵向分辨率^2+横向分辨率^2))/25.4** 求出屏幕尺寸，然后创建模拟设备 (**只用填写屏幕尺寸和分辨率**)\n![mm](art/unit_mm.png)\n\n## Advanced (以下用法看不懂？答应我，认真看 demo 好不好？)\n\n### Activity\n* **当某个 Activity 的设计图尺寸与在 AndroidManifest 中填写的全局设计图尺寸不同时，可以实现 CustomAdapt 接口扩展适配参数**\n```java\npublic class CustomAdaptActivity extends AppCompatActivity implements CustomAdapt {\n\n    @Override\n    public boolean isBaseOnWidth() {\n        return false;\n    }\n\n    @Override\n    public float getSizeInDp() {\n        return 667;\n    }\n}\n```\n\n* **当某个 Activity 想放弃适配，请实现 CancelAdapt 接口**\n```java\npublic class CancelAdaptActivity extends AppCompatActivity implements CancelAdapt {\n\n}\n```\n\n### Fragment\n* **首先开启支持 Fragment 自定义参数的功能**\n```java\nAutoSizeConfig.getInstance().setCustomFragment(true);\n```\n\n* **当某个 Fragment 的设计图尺寸与在 AndroidManifest 中填写的全局设计图尺寸不同时，可以实现 CustomAdapt 接口扩展适配参数**\n```java\npublic class CustomAdaptFragment extends Fragment implements CustomAdapt {\n\n    @Override\n    public boolean isBaseOnWidth() {\n        return false;\n    }\n\n    @Override\n    public float getSizeInDp() {\n        return 667;\n    }\n}\n```\n\n* **当某个 Fragment 想放弃适配，请实现 CancelAdapt 接口**\n```java\npublic class CancelAdaptFragment extends Fragment implements CancelAdapt {\n\n}\n```\n\n### Subunits (请认真看 demo-subunits，里面有详细介绍)\n* 可以在 **pt、in、mm** 这三个冷门单位中，选择一个作为副单位，副单位是用于规避修改 **DisplayMetrics#density** 所造成的对于其他使用 **dp** 布局的系统控件或三方库控件的不良影响，使用副单位后可直接填写设计图上的像素尺寸，不需要再将像素转化为 **dp**\n\n\n```java\nAutoSizeConfig.getInstance().getUnitsManager()\n        .setSupportDP(false)\n        .setSupportSP(false)\n        .setSupportSubunits(Subunits.MM);\n```\n\n## About Me\n* **Email**: <jess.yan.effort@gmail.com>\n* **Home**: <http://jessyan.me>\n* **掘金**: <https://juejin.im/user/57a9dbd9165abd0061714613>\n* **简书**: <https://www.jianshu.com/u/1d0c0bc634db>\n\n## License\n```\n Copyright 2018, jessyan\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n```\n"
  },
  {
    "path": "README.md",
    "content": "![Logo](art/autosize_banner.jpg)\n![Official](https://raw.githubusercontent.com/JessYanCoding/MVPArms/master/image/official.jpeg)\n\n<p align=\"center\">\n   <a href=\"https://bintray.com/jessyancoding/maven/autosize/_latestVersion\">\n    <img src=\"https://img.shields.io/badge/Jcenter-v1.2.1-brightgreen.svg?style=flat-square\" alt=\"Latest Stable Version\" />\n  </a>\n  <a href=\"https://travis-ci.org/JessYanCoding/AndroidAutoSize\">\n    <img src=\"https://travis-ci.org/JessYanCoding/AndroidAutoSize.svg?branch=master\" alt=\"Build Status\" />\n  </a>\n  <a href=\"https://developer.android.com/about/versions/android-4.0.html\">\n    <img src=\"https://img.shields.io/badge/API-14%2B-blue.svg?style=flat-square\" alt=\"Min Sdk Version\" />\n  </a>\n  <a href=\"http://www.apache.org/licenses/LICENSE-2.0\">\n    <img src=\"http://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square\" alt=\"License\" />\n  </a>\n  <a href=\"https://www.jianshu.com/u/1d0c0bc634db\">\n    <img src=\"https://img.shields.io/badge/Author-JessYan-orange.svg?style=flat-square\" alt=\"Author\" />\n  </a>\n  <a href=\"https://shang.qq.com/wpa/qunwpa?idkey=7e59e59145e6c7c68932ace10f52790636451f01d1ecadb6a652b1df234df753\">\n    <img src=\"https://img.shields.io/badge/QQ%E7%BE%A4-455850365%20%7C%20301733278-orange.svg?style=flat-square\" alt=\"QQ Group\" />\n  </a>\n</p>\n\n<p align=\"center\">\n  <a href=\"README-zh.md\">\n    <b>中文说明</b>\n  </a>\n</p>\n\n## A low-cost Android screen adaptation solution (今日头条屏幕适配方案终极版，一个极低成本的 Android 屏幕适配方案).\n\n## Overview\n### Pixel 2 XL | 1440 x 2880 | 560dpi:\n<p>\n   <img src=\"art/1440x2880_width.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/1440x2880_height.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/1440x2880_external.png\" width=\"30%\" height=\"30%\">\n</p>\n\n### Pixel XL | 1440 x 2560 | 560dpi:\n<p>\n   <img src=\"art/1440x2560_width.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/1440x2560_height.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/1440x2560_external.png\" width=\"30%\" height=\"30%\">\n</p>\n\n### Nexus 5X | 1080 x 1920 | 420dpi:\n<p>\n   <img src=\"art/1080x1920_width.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/1080x1920_height.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/1080x1920_external.png\" width=\"30%\" height=\"30%\">\n</p>\n\n### Nexus 4 | 768 x 1280 | 320dpi:\n<p>\n   <img src=\"art/768x1280_width.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/768x1280_height.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/768x1280_external.png\" width=\"30%\" height=\"30%\">\n</p>\n\n### Nexus S | 480 x 800 | 240dpi:\n<p>\n   <img src=\"art/480x800_width.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/480x800_height.png\" width=\"30%\" height=\"30%\">\n   <img src=\"art/480x800_external.png\" width=\"30%\" height=\"30%\">\n</p>\n\n## Notice\n* [Devices Info](https://material.io/tools/devices/)\n\n* [Introduction Of Function](https://juejin.im/post/5bce688e6fb9a05cf715d1c2)\n\n* [Framework Analysis](https://juejin.im/post/5b7a29736fb9a019d53e7ee2)\n\n* [Common Issues](https://github.com/JessYanCoding/AndroidAutoSize/issues/13)\n\n* [AndroidAutoLayout Migration Guide](https://github.com/JessYanCoding/AndroidAutoSize/issues/90)\n\n* [Android Advanced Framework](https://github.com/JessYanCoding/MVPArms)\n\n## Download\n### Jcenter ([ ⚠️ DEPRECATION WARNING: the JCenter repository will keep serving packages until February 1st, 2022](https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter)):\n``` gradle\n implementation 'me.jessyan:autosize:1.2.1'\n```\n\n### JitPack:\nStep 1. Add the JitPack repository in your root [build.gradle](https://github.com/JessYanCoding/AndroidAutoSize/blob/master/build.gradle#L20) at the end of repositories:\n\n```gradle\nallprojects {\n    repositories {\n        ...\n        maven { url \"https://jitpack.io\" }\n    }\n}\n```\n\nStep 2. Add the dependency\n\n```gradle\ndependencies {\n    implementation 'com.github.JessYanCoding:AndroidAutoSize:v1.2.1'\n}\n```\n\n## Usage\n### Step 1 (just one steps) \n* **Initialize in AndroidManifest, if you use a subunits, you can write the pixel size, no need to convert the pixel to dp, please see [demo-subunits](https://github.com/JessYanCoding/AndroidAutoSize/tree/master/demo-subunits)**\n```xml\n<manifest>\n    <application>            \n        <meta-data\n            android:name=\"design_width_in_dp\"\n            android:value=\"360\"/>\n        <meta-data\n            android:name=\"design_height_in_dp\"\n            android:value=\"640\"/>           \n     </application>           \n</manifest>\n```\n\n<a name=\"preview\"></a>\n## Preview\n* Real-time preview during layout is an important part of the development phase, in many cases, the default preview device provided by **Android Studio** does not fully display our design, so we need to create the virtual device ourselves, under the **dp, pt, in, mm** four units of virtual device creation method\n\n* If you don't want the status bar and navigation bar to appear in **Preview** during preview, you can select the **panel** theme according to the following image, after using this theme, the vertical resolution just fills the entire preview page\n![theme](art/theme_panel.png)\n\n* Virtual device creation method\n![create step](art/create_step.png)\n\n### DP\n* If you use **dp** as a unit in the **layout** file for layout (**AndroidAutoSize** supports **dp, sp** for layout by default), you can find the screen size according to the formula **(sqrt(vertical resolution^2 + horizontal resolution^2))/dpi** and create an virtual device (**write screen size and resolution only**)\n![dp](art/unit_dp.png)\n\n### PT\n* If you use **pt** as a unit in the **layout** file for layout (requires **AutoSizeConfig.getInstance().getUnitsManager().setSupportSubunits(Subunits.PT);** to open **pt** support), you can find the screen size according to the formula **(sqrt(vertical resolution^2 + horizontal resolution^2))/72** and create an virtual device (**write screen size and resolution only**)\n![pt](art/unit_pt.png)\n\n### IN\n* If you use **in** as a unit in the **layout** file for layout (requires **AutoSizeConfig.getInstance().getUnitsManager().setSupportSubunits(Subunits.IN);** to open **in** support), you can find the screen size according to the formula **sqrt(vertical resolution^2 + horizontal resolution^2)** and create an virtual device (**write screen size and resolution only**)\n![in](art/unit_in.png)\n\n### MM\n* If you use **mm** as a unit in the **layout** file for layout (requires **AutoSizeConfig.getInstance().getUnitsManager().setSupportSubunits(Subunits.MM);** to open **mm** support), you can find the screen size according to the formula **(sqrt(vertical resolution^2 + horizontal resolution^2))/25.4** and create an virtual device (**write screen size and resolution only**)\n![mm](art/unit_mm.png)\n\n## Advance (see demo)\n\n### Activity\n* **Customize the adaptation parameters of the Activity:**\n```java\npublic class CustomAdaptActivity extends AppCompatActivity implements CustomAdapt {\n\n    @Override\n    public boolean isBaseOnWidth() {\n        return false;\n    }\n\n    @Override\n    public float getSizeInDp() {\n        return 667;\n    }\n}\n```\n\n* **Cancel the adaptation of the Activity:**\n```java\npublic class CancelAdaptActivity extends AppCompatActivity implements CancelAdapt {\n\n}\n```\n\n### Fragment\n* **First enable the ability to support Fragment custom parameters**\n```java\nAutoSizeConfig.getInstance().setCustomFragment(true);\n```\n\n* **Customize the adaptation parameters of the Fragment:**\n```java\npublic class CustomAdaptFragment extends Fragment implements CustomAdapt {\n\n    @Override\n    public boolean isBaseOnWidth() {\n        return false;\n    }\n\n    @Override\n    public float getSizeInDp() {\n        return 667;\n    }\n}\n```\n\n* **Cancel the adaptation of the Fragment:**\n```java\npublic class CancelAdaptFragment extends Fragment implements CancelAdapt {\n\n}\n```\n\n### Subunits (see demo-subunits)\n* You can choose one of the three unpopular units of **pt, in, mm** as the subunits, the subunits is used to avoid the adverse effects caused by modifying **DisplayMetrics#density**, after using the subunits, you can write the pixel size on the design, you don't need to convert it to **dp**\n\n\n```java\nAutoSizeConfig.getInstance().getUnitsManager()\n        .setSupportDP(false)\n        .setSupportSP(false)\n        .setSupportSubunits(Subunits.MM);\n```\n\n## About Me\n* **Email**: <jess.yan.effort@gmail.com>\n* **Home**: <http://jessyan.me>\n* **掘金**: <https://juejin.im/user/57a9dbd9165abd0061714613>\n* **简书**: <https://www.jianshu.com/u/1d0c0bc634db>\n\n## License\n```\n Copyright 2018, jessyan\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n```\n"
  },
  {
    "path": "_config.yml",
    "content": "theme: jekyll-theme-modernist"
  },
  {
    "path": "autosize/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "autosize/bintray.gradle",
    "content": "apply plugin: 'com.novoda.bintray-release'\n\nallprojects {\n    repositories {\n        jcenter()\n    }\n    tasks.withType(Javadoc) {\n        options{\n            encoding \"UTF-8\"\n            charSet 'UTF-8'\n            links \"http://docs.oracle.com/javase/7/docs/api\"\n        }\n        options.addStringOption('Xdoclint:none', '-quiet')\n    }\n}\n\n\ndef siteUrl = 'https://github.com/JessYanCoding/AndroidAutoSize'   // 项目的主页\n\npublish {\n    userOrg = 'jessyancoding'      //bintray注册的用户名\n    groupId = 'me.jessyan'         //compile引用时的第1部分groupId\n    artifactId = 'autosize'     //compile引用时的第2部分项目名\n    publishVersion = rootProject.versionName    //compile引用时的第3部分版本号\n    desc = '一个极低成本的 Android 屏幕适配方案'\n    website = siteUrl\n}\n\n\n\n\n\n\n"
  },
  {
    "path": "autosize/build.gradle",
    "content": "apply plugin: 'com.android.library'\n\nandroid {\n    compileSdkVersion rootProject.compileSdkVersion\n    buildToolsVersion rootProject.buildToolsVersion\n\n    defaultConfig {\n        minSdkVersion rootProject.minSdkVersion\n        targetSdkVersion rootProject.targetSdkVersion\n        versionCode rootProject.versionCode\n        versionName rootProject.versionName\n        consumerProguardFiles 'proguard-rules.pro'\n    }\n\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n\n    lintOptions {\n        abortOnError false\n        warning 'InvalidPackage'\n    }\n}\n\ndependencies {\n    compileOnly rootProject.appcompat_v7\n    compileOnly rootProject.androidx_appcompat\n}\n\napply from: 'bintray.gradle'"
  },
  {
    "path": "autosize/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n\n-keep class me.jessyan.autosize.** { *; }\n-keep interface me.jessyan.autosize.** { *; }"
  },
  {
    "path": "autosize/src/main/AndroidManifest.xml",
    "content": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n          package=\"me.jessyan.autosize\">\n\n    <application>\n        <provider\n            android:name=\"me.jessyan.autosize.InitProvider\"\n            android:authorities=\"${applicationId}.autosize-init-provider\"\n            android:exported=\"false\"\n            android:multiprocess=\"true\"/>\n    </application>\n</manifest>"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/ActivityLifecycleCallbacksImpl.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize;\n\nimport android.app.Activity;\nimport android.app.Application;\nimport android.os.Bundle;\n\nimport static me.jessyan.autosize.AutoSizeConfig.DEPENDENCY_ANDROIDX;\nimport static me.jessyan.autosize.AutoSizeConfig.DEPENDENCY_SUPPORT;\n\n/**\n * ================================================\n * {@link ActivityLifecycleCallbacksImpl} 可用来代替在 BaseActivity 中加入适配代码的传统方式\n * {@link ActivityLifecycleCallbacksImpl} 这种方案类似于 AOP, 面向接口, 侵入性低, 方便统一管理, 扩展性强, 并且也支持适配三方库的 {@link Activity}\n * <p>\n * Created by JessYan on 2018/8/8 14:32\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class ActivityLifecycleCallbacksImpl implements Application.ActivityLifecycleCallbacks {\n    /**\n     * 屏幕适配逻辑策略类\n     */\n    private AutoAdaptStrategy mAutoAdaptStrategy;\n    /**\n     * 让 Fragment 支持自定义适配参数\n     */\n    private FragmentLifecycleCallbacksImpl mFragmentLifecycleCallbacks;\n    private FragmentLifecycleCallbacksImplToAndroidx mFragmentLifecycleCallbacksToAndroidx;\n\n    public ActivityLifecycleCallbacksImpl(AutoAdaptStrategy autoAdaptStrategy) {\n        if (DEPENDENCY_ANDROIDX) {\n            mFragmentLifecycleCallbacksToAndroidx = new FragmentLifecycleCallbacksImplToAndroidx(autoAdaptStrategy);\n        } else if (DEPENDENCY_SUPPORT){\n            mFragmentLifecycleCallbacks = new FragmentLifecycleCallbacksImpl(autoAdaptStrategy);\n        }\n        mAutoAdaptStrategy = autoAdaptStrategy;\n    }\n\n    @Override\n    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {\n        if (AutoSizeConfig.getInstance().isCustomFragment()) {\n            if (mFragmentLifecycleCallbacksToAndroidx != null && activity instanceof androidx.fragment.app.FragmentActivity) {\n                ((androidx.fragment.app.FragmentActivity) activity).getSupportFragmentManager().registerFragmentLifecycleCallbacks(mFragmentLifecycleCallbacksToAndroidx, true);\n            } else if (mFragmentLifecycleCallbacks != null && activity instanceof android.support.v4.app.FragmentActivity) {\n                ((android.support.v4.app.FragmentActivity) activity).getSupportFragmentManager().registerFragmentLifecycleCallbacks(mFragmentLifecycleCallbacks, true);\n            }\n        }\n\n        //Activity 中的 setContentView(View) 一定要在 super.onCreate(Bundle); 之后执行\n        if (mAutoAdaptStrategy != null) {\n            mAutoAdaptStrategy.applyAdapt(activity, activity);\n        }\n    }\n\n    @Override\n    public void onActivityStarted(Activity activity) {\n        if (mAutoAdaptStrategy != null) {\n            mAutoAdaptStrategy.applyAdapt(activity, activity);\n        }\n    }\n\n    @Override\n    public void onActivityResumed(Activity activity) {\n\n    }\n\n    @Override\n    public void onActivityPaused(Activity activity) {\n\n    }\n\n    @Override\n    public void onActivityStopped(Activity activity) {\n\n    }\n\n    @Override\n    public void onActivitySaveInstanceState(Activity activity, Bundle outState) {\n\n    }\n\n    @Override\n    public void onActivityDestroyed(Activity activity) {\n\n    }\n\n    /**\n     * 设置屏幕适配逻辑策略类\n     *\n     * @param autoAdaptStrategy {@link AutoAdaptStrategy}\n     */\n    public void setAutoAdaptStrategy(AutoAdaptStrategy autoAdaptStrategy) {\n        mAutoAdaptStrategy = autoAdaptStrategy;\n        if (mFragmentLifecycleCallbacksToAndroidx != null) {\n            mFragmentLifecycleCallbacksToAndroidx.setAutoAdaptStrategy(autoAdaptStrategy);\n        } else if (mFragmentLifecycleCallbacks != null) {\n            mFragmentLifecycleCallbacks.setAutoAdaptStrategy(autoAdaptStrategy);\n        }\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/AutoAdaptStrategy.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize;\n\nimport android.app.Activity;\nimport android.app.Application;\nimport android.util.DisplayMetrics;\n\n/**\n * ================================================\n * 屏幕适配逻辑策略类, 可通过 {@link AutoSizeConfig#init(Application, boolean, AutoAdaptStrategy)}\n * 和 {@link AutoSizeConfig#setAutoAdaptStrategy(AutoAdaptStrategy)} 切换策略\n *\n * @see DefaultAutoAdaptStrategy\n * Created by JessYan on 2018/8/9 15:13\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic interface AutoAdaptStrategy {\n\n    /**\n     * 开始执行屏幕适配逻辑\n     *\n     * @param target   需要屏幕适配的对象 (可能是 {@link Activity} 或者 Fragment)\n     * @param activity 需要拿到当前的 {@link Activity} 才能修改 {@link DisplayMetrics#density}\n     */\n    void applyAdapt(Object target, Activity activity);\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/AutoSize.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize;\n\nimport android.app.Activity;\nimport android.app.Application;\nimport android.app.Dialog;\nimport android.content.Context;\nimport android.content.res.Configuration;\nimport android.content.res.Resources;\nimport android.net.Uri;\nimport android.util.DisplayMetrics;\nimport android.util.SparseArray;\nimport android.view.View;\n\nimport java.util.Locale;\n\nimport me.jessyan.autosize.external.ExternalAdaptInfo;\nimport me.jessyan.autosize.external.ExternalAdaptManager;\nimport me.jessyan.autosize.internal.CancelAdapt;\nimport me.jessyan.autosize.internal.CustomAdapt;\nimport me.jessyan.autosize.utils.AutoSizeLog;\nimport me.jessyan.autosize.utils.Preconditions;\n\n/**\n * ================================================\n * AndroidAutoSize 用于屏幕适配的核心方法都在这里, 核心原理来自于 <a href=\"https://mp.weixin.qq.com/s/d9QCoBP6kV9VSWvVldVVwA\">今日头条官方适配方案</a>\n * 此方案只要应用到 {@link Activity} 上, 这个 {@link Activity} 下的所有 Fragment、{@link Dialog}、\n * 自定义 {@link View} 都会达到适配的效果, 如果某个页面不想使用适配请让该 {@link Activity} 实现 {@link CancelAdapt}\n * <p>\n * 任何方案都不可能完美, 在成本和收益中做出取舍, 选择出最适合自己的方案即可, 在没有更好的方案出来之前, 只有继续忍耐它的不完美, 或者自己作出改变\n * 既然选择, 就不要抱怨, 感谢 今日头条技术团队 和 张鸿洋 等人对 Android 屏幕适配领域的的贡献\n * <p>\n * Created by JessYan on 2018/8/8 19:20\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic final class AutoSize {\n    private static SparseArray<DisplayMetricsInfo> mCache = new SparseArray<>();\n    private static final int MODE_SHIFT = 30;\n    private static final int MODE_MASK  = 0x3 << MODE_SHIFT;\n    private static final int MODE_ON_WIDTH  = 1 << MODE_SHIFT;\n    private static final int MODE_DEVICE_SIZE  = 2 << MODE_SHIFT;\n\n    private AutoSize() {\n        throw new IllegalStateException(\"you can't instantiate me!\");\n    }\n\n    /**\n     * 检查 AndroidAutoSize 是否已经初始化\n     *\n     * @return {@code false} 表示 AndroidAutoSize 还未初始化, {@code true} 表示 AndroidAutoSize 已经初始化\n     */\n    public static boolean checkInit() {\n        return AutoSizeConfig.getInstance().getInitDensity() != -1;\n    }\n\n    /**\n     * 由于 AndroidAutoSize 会通过 {@link InitProvider} 的实例化而自动完成初始化, 并且 {@link AutoSizeConfig#init(Application)}\n     * 只允许被调用一次, 否则会报错, 所以 {@link AutoSizeConfig#init(Application)} 的调用权限并没有设为 public, 不允许外部使用者调用\n     * 但由于某些 issues 反应, 可能会在某些特殊情况下出现 {@link InitProvider} 未能正常实例化的情况, 导致 AndroidAutoSize 未能完成初始化\n     * 所以提供此静态方法用于让外部使用者在异常情况下也可以初始化 AndroidAutoSize, 在 {@link Application#onCreate()} 中调用即可\n     *\n     * @param application {@link Application}\n     */\n    public static void checkAndInit(Application application) {\n        if (!checkInit()) {\n            AutoSizeConfig.getInstance()\n                    .setLog(true)\n                    .init(application)\n                    .setUseDeviceSize(false);\n        }\n    }\n\n    /**\n     * 使用 AndroidAutoSize 初始化时设置的默认适配参数进行适配 (AndroidManifest 的 Meta 属性)\n     *\n     * @param activity {@link Activity}\n     */\n    public static void autoConvertDensityOfGlobal(Activity activity) {\n        if (AutoSizeConfig.getInstance().isBaseOnWidth()) {\n            autoConvertDensityBaseOnWidth(activity, AutoSizeConfig.getInstance().getDesignWidthInDp());\n        } else {\n            autoConvertDensityBaseOnHeight(activity, AutoSizeConfig.getInstance().getDesignHeightInDp());\n        }\n    }\n\n    /**\n     * 使用 {@link Activity} 或 Fragment 的自定义参数进行适配\n     *\n     * @param activity    {@link Activity}\n     * @param customAdapt {@link Activity} 或 Fragment 需实现 {@link CustomAdapt}\n     */\n    public static void autoConvertDensityOfCustomAdapt(Activity activity, CustomAdapt customAdapt) {\n        Preconditions.checkNotNull(customAdapt, \"customAdapt == null\");\n        float sizeInDp = customAdapt.getSizeInDp();\n\n        //如果 CustomAdapt#getSizeInDp() 返回 0, 则使用在 AndroidManifest 上填写的设计图尺寸\n        if (sizeInDp <= 0) {\n            if (customAdapt.isBaseOnWidth()) {\n                sizeInDp = AutoSizeConfig.getInstance().getDesignWidthInDp();\n            } else {\n                sizeInDp = AutoSizeConfig.getInstance().getDesignHeightInDp();\n            }\n        }\n        autoConvertDensity(activity, sizeInDp, customAdapt.isBaseOnWidth());\n    }\n\n    /**\n     * 使用外部三方库的 {@link Activity} 或 Fragment 的自定义适配参数进行适配\n     *\n     * @param activity          {@link Activity}\n     * @param externalAdaptInfo 三方库的 {@link Activity} 或 Fragment 提供的适配参数, 需要配合 {@link ExternalAdaptManager#addExternalAdaptInfoOfActivity(Class, ExternalAdaptInfo)}\n     */\n    public static void autoConvertDensityOfExternalAdaptInfo(Activity activity, ExternalAdaptInfo externalAdaptInfo) {\n        Preconditions.checkNotNull(externalAdaptInfo, \"externalAdaptInfo == null\");\n        float sizeInDp = externalAdaptInfo.getSizeInDp();\n\n        //如果 ExternalAdaptInfo#getSizeInDp() 返回 0, 则使用在 AndroidManifest 上填写的设计图尺寸\n        if (sizeInDp <= 0) {\n            if (externalAdaptInfo.isBaseOnWidth()) {\n                sizeInDp = AutoSizeConfig.getInstance().getDesignWidthInDp();\n            } else {\n                sizeInDp = AutoSizeConfig.getInstance().getDesignHeightInDp();\n            }\n        }\n        autoConvertDensity(activity, sizeInDp, externalAdaptInfo.isBaseOnWidth());\n    }\n\n    /**\n     * 以宽度为基准进行适配\n     *\n     * @param activity        {@link Activity}\n     * @param designWidthInDp 设计图的总宽度\n     */\n    public static void autoConvertDensityBaseOnWidth(Activity activity, float designWidthInDp) {\n        autoConvertDensity(activity, designWidthInDp, true);\n    }\n\n    /**\n     * 以高度为基准进行适配\n     *\n     * @param activity         {@link Activity}\n     * @param designHeightInDp 设计图的总高度\n     */\n    public static void autoConvertDensityBaseOnHeight(Activity activity, float designHeightInDp) {\n        autoConvertDensity(activity, designHeightInDp, false);\n    }\n\n    /**\n     * 这里是今日头条适配方案的核心代码, 核心在于根据当前设备的实际情况做自动计算并转换 {@link DisplayMetrics#density}、\n     * {@link DisplayMetrics#scaledDensity}、{@link DisplayMetrics#densityDpi} 这三个值, 额外增加 {@link DisplayMetrics#xdpi}\n     * 以支持单位 {@code pt}、{@code in}、{@code mm}\n     *\n     * @param activity      {@link Activity}\n     * @param sizeInDp      设计图上的设计尺寸, 单位 dp, 如果 {@param isBaseOnWidth} 设置为 {@code true},\n     *                      {@param sizeInDp} 则应该填写设计图的总宽度, 如果 {@param isBaseOnWidth} 设置为 {@code false},\n     *                      {@param sizeInDp} 则应该填写设计图的总高度\n     * @param isBaseOnWidth 是否按照宽度进行等比例适配, {@code true} 为以宽度进行等比例适配, {@code false} 为以高度进行等比例适配\n     * @see <a href=\"https://mp.weixin.qq.com/s/d9QCoBP6kV9VSWvVldVVwA\">今日头条官方适配方案</a>\n     */\n    public static void autoConvertDensity(Activity activity, float sizeInDp, boolean isBaseOnWidth) {\n        Preconditions.checkNotNull(activity, \"activity == null\");\n        Preconditions.checkMainThread();\n\n        float subunitsDesignSize = isBaseOnWidth ? AutoSizeConfig.getInstance().getUnitsManager().getDesignWidth()\n                : AutoSizeConfig.getInstance().getUnitsManager().getDesignHeight();\n        subunitsDesignSize = subunitsDesignSize > 0 ? subunitsDesignSize : sizeInDp;\n\n        int screenSize = isBaseOnWidth ? AutoSizeConfig.getInstance().getScreenWidth()\n                : AutoSizeConfig.getInstance().getScreenHeight();\n\n        int key = Math.round((sizeInDp + subunitsDesignSize + screenSize) * AutoSizeConfig.getInstance().getInitScaledDensity()) & ~MODE_MASK;\n        key = isBaseOnWidth ? (key | MODE_ON_WIDTH) : (key & ~MODE_ON_WIDTH);\n        key = AutoSizeConfig.getInstance().isUseDeviceSize() ? (key | MODE_DEVICE_SIZE) : (key & ~MODE_DEVICE_SIZE);\n\n        DisplayMetricsInfo displayMetricsInfo = mCache.get(key);\n\n        float targetDensity = 0;\n        int targetDensityDpi = 0;\n        float targetScaledDensity = 0;\n        float targetXdpi = 0;\n        int targetScreenWidthDp;\n        int targetScreenHeightDp;\n\n        if (displayMetricsInfo == null) {\n            if (isBaseOnWidth) {\n                targetDensity = AutoSizeConfig.getInstance().getScreenWidth() * 1.0f / sizeInDp;\n            } else {\n                targetDensity = AutoSizeConfig.getInstance().getScreenHeight() * 1.0f / sizeInDp;\n            }\n            if (AutoSizeConfig.getInstance().getPrivateFontScale() > 0) {\n                targetScaledDensity = targetDensity * AutoSizeConfig.getInstance().getPrivateFontScale();\n            } else {\n                float systemFontScale = AutoSizeConfig.getInstance().isExcludeFontScale() ? 1 : AutoSizeConfig.getInstance().\n                        getInitScaledDensity() * 1.0f / AutoSizeConfig.getInstance().getInitDensity();\n                targetScaledDensity = targetDensity * systemFontScale;\n            }\n            targetDensityDpi = (int) (targetDensity * 160);\n\n            targetScreenWidthDp = (int) (AutoSizeConfig.getInstance().getScreenWidth() / targetDensity);\n            targetScreenHeightDp = (int) (AutoSizeConfig.getInstance().getScreenHeight() / targetDensity);\n\n            if (isBaseOnWidth) {\n                targetXdpi = AutoSizeConfig.getInstance().getScreenWidth() * 1.0f / subunitsDesignSize;\n            } else {\n                targetXdpi = AutoSizeConfig.getInstance().getScreenHeight() * 1.0f / subunitsDesignSize;\n            }\n\n            mCache.put(key, new DisplayMetricsInfo(targetDensity, targetDensityDpi, targetScaledDensity, targetXdpi, targetScreenWidthDp, targetScreenHeightDp));\n        } else {\n            targetDensity = displayMetricsInfo.getDensity();\n            targetDensityDpi = displayMetricsInfo.getDensityDpi();\n            targetScaledDensity = displayMetricsInfo.getScaledDensity();\n            targetXdpi = displayMetricsInfo.getXdpi();\n            targetScreenWidthDp = displayMetricsInfo.getScreenWidthDp();\n            targetScreenHeightDp = displayMetricsInfo.getScreenHeightDp();\n        }\n\n        setDensity(activity, targetDensity, targetDensityDpi, targetScaledDensity, targetXdpi);\n        setScreenSizeDp(activity, targetScreenWidthDp, targetScreenHeightDp);\n\n        AutoSizeLog.d(String.format(Locale.ENGLISH, \"The %s has been adapted! \\n%s Info: isBaseOnWidth = %s, %s = %f, %s = %f, targetDensity = %f, targetScaledDensity = %f, targetDensityDpi = %d, targetXdpi = %f, targetScreenWidthDp = %d, targetScreenHeightDp = %d\"\n                , activity.getClass().getName(), activity.getClass().getSimpleName(), isBaseOnWidth, isBaseOnWidth ? \"designWidthInDp\"\n                        : \"designHeightInDp\", sizeInDp, isBaseOnWidth ? \"designWidthInSubunits\" : \"designHeightInSubunits\", subunitsDesignSize\n                , targetDensity, targetScaledDensity, targetDensityDpi, targetXdpi, targetScreenWidthDp, targetScreenHeightDp));\n    }\n\n    /**\n     * 取消适配\n     *\n     * @param activity {@link Activity}\n     */\n    public static void cancelAdapt(Activity activity) {\n        Preconditions.checkMainThread();\n        float initXdpi = AutoSizeConfig.getInstance().getInitXdpi();\n        switch (AutoSizeConfig.getInstance().getUnitsManager().getSupportSubunits()) {\n            case PT:\n                initXdpi = initXdpi / 72f;\n                break;\n            case MM:\n                initXdpi = initXdpi / 25.4f;\n                break;\n            default:\n        }\n        setDensity(activity, AutoSizeConfig.getInstance().getInitDensity()\n                , AutoSizeConfig.getInstance().getInitDensityDpi()\n                , AutoSizeConfig.getInstance().getInitScaledDensity()\n                , initXdpi);\n        setScreenSizeDp(activity\n                , AutoSizeConfig.getInstance().getInitScreenWidthDp()\n                , AutoSizeConfig.getInstance().getInitScreenHeightDp());\n    }\n\n    /**\n     * 当 App 中出现多进程，并且您需要适配所有的进程，就需要在 App 初始化时调用 {@link #initCompatMultiProcess}\n     * 建议实现自定义 {@link Application} 并在 {@link Application#onCreate()} 中调用 {@link #initCompatMultiProcess}\n     *\n     * @param context {@link Context}\n     */\n    public static void initCompatMultiProcess(Context context) {\n        context.getContentResolver().query(Uri.parse(\"content://\" + context.getPackageName() + \".autosize-init-provider\"), null, null, null, null);\n    }\n\n    /**\n     * 给几大 {@link DisplayMetrics} 赋值\n     *\n     * @param activity      {@link Activity}\n     * @param density       {@link DisplayMetrics#density}\n     * @param densityDpi    {@link DisplayMetrics#densityDpi}\n     * @param scaledDensity {@link DisplayMetrics#scaledDensity}\n     * @param xdpi          {@link DisplayMetrics#xdpi}\n     */\n    private static void setDensity(Activity activity, float density, int densityDpi, float scaledDensity, float xdpi) {\n        DisplayMetrics activityDisplayMetrics = activity.getResources().getDisplayMetrics();\n        setDensity(activityDisplayMetrics, density, densityDpi, scaledDensity, xdpi);\n        DisplayMetrics appDisplayMetrics = AutoSizeConfig.getInstance().getApplication().getResources().getDisplayMetrics();\n        setDensity(appDisplayMetrics, density, densityDpi, scaledDensity, xdpi);\n\n        //兼容 MIUI\n        DisplayMetrics activityDisplayMetricsOnMIUI = getMetricsOnMiui(activity.getResources());\n        DisplayMetrics appDisplayMetricsOnMIUI = getMetricsOnMiui(AutoSizeConfig.getInstance().getApplication().getResources());\n\n        if (activityDisplayMetricsOnMIUI != null) {\n            setDensity(activityDisplayMetricsOnMIUI, density, densityDpi, scaledDensity, xdpi);\n        }\n        if (appDisplayMetricsOnMIUI != null) {\n            setDensity(appDisplayMetricsOnMIUI, density, densityDpi, scaledDensity, xdpi);\n        }\n    }\n\n    /**\n     * 赋值\n     *\n     * @param displayMetrics {@link DisplayMetrics}\n     * @param density        {@link DisplayMetrics#density}\n     * @param densityDpi     {@link DisplayMetrics#densityDpi}\n     * @param scaledDensity  {@link DisplayMetrics#scaledDensity}\n     * @param xdpi           {@link DisplayMetrics#xdpi}\n     */\n    private static void setDensity(DisplayMetrics displayMetrics, float density, int densityDpi, float scaledDensity, float xdpi) {\n        if (AutoSizeConfig.getInstance().getUnitsManager().isSupportDP()) {\n            displayMetrics.density = density;\n            displayMetrics.densityDpi = densityDpi;\n        }\n        if (AutoSizeConfig.getInstance().getUnitsManager().isSupportSP()) {\n            displayMetrics.scaledDensity = scaledDensity;\n        }\n        switch (AutoSizeConfig.getInstance().getUnitsManager().getSupportSubunits()) {\n            case NONE:\n                break;\n            case PT:\n                displayMetrics.xdpi = xdpi * 72f;\n                break;\n            case IN:\n                displayMetrics.xdpi = xdpi;\n                break;\n            case MM:\n                displayMetrics.xdpi = xdpi * 25.4f;\n                break;\n            default:\n        }\n    }\n\n    /**\n     * 给 {@link Configuration} 赋值\n     *\n     * @param activity       {@link Activity}\n     * @param screenWidthDp  {@link Configuration#screenWidthDp}\n     * @param screenHeightDp {@link Configuration#screenHeightDp}\n     */\n    private static void setScreenSizeDp(Activity activity, int screenWidthDp, int screenHeightDp) {\n        if (AutoSizeConfig.getInstance().getUnitsManager().isSupportDP() && AutoSizeConfig.getInstance().getUnitsManager().isSupportScreenSizeDP()) {\n            Configuration activityConfiguration = activity.getResources().getConfiguration();\n            setScreenSizeDp(activityConfiguration, screenWidthDp, screenHeightDp);\n\n            Configuration appConfiguration = AutoSizeConfig.getInstance().getApplication().getResources().getConfiguration();\n            setScreenSizeDp(appConfiguration, screenWidthDp, screenHeightDp);\n        }\n    }\n\n    /**\n     * Configuration赋值\n     *\n     * @param configuration  {@link Configuration}\n     * @param screenWidthDp  {@link Configuration#screenWidthDp}\n     * @param screenHeightDp {@link Configuration#screenHeightDp}\n     */\n    private static void setScreenSizeDp(Configuration configuration, int screenWidthDp, int screenHeightDp) {\n        configuration.screenWidthDp = screenWidthDp;\n        configuration.screenHeightDp = screenHeightDp;\n    }\n\n    /**\n     * 解决 MIUI 更改框架导致的 MIUI7 + Android5.1.1 上出现的失效问题 (以及极少数基于这部分 MIUI 去掉 ART 然后置入 XPosed 的手机)\n     * 来源于: https://github.com/Firedamp/Rudeness/blob/master/rudeness-sdk/src/main/java/com/bulong/rudeness/RudenessScreenHelper.java#L61:5\n     *\n     * @param resources {@link Resources}\n     * @return {@link DisplayMetrics}, 可能为 {@code null}\n     */\n    private static DisplayMetrics getMetricsOnMiui(Resources resources) {\n        if (AutoSizeConfig.getInstance().isMiui() && AutoSizeConfig.getInstance().getTmpMetricsField() != null) {\n            try {\n                return (DisplayMetrics) AutoSizeConfig.getInstance().getTmpMetricsField().get(resources);\n            } catch (Exception e) {\n                return null;\n            }\n        }\n        return null;\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/AutoSizeCompat.java",
    "content": "/*\n * Copyright 2019 JessYan\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 */\npackage me.jessyan.autosize;\n\nimport android.app.Activity;\nimport android.content.res.Configuration;\nimport android.content.res.Resources;\nimport android.util.DisplayMetrics;\nimport android.util.SparseArray;\n\nimport me.jessyan.autosize.external.ExternalAdaptInfo;\nimport me.jessyan.autosize.external.ExternalAdaptManager;\nimport me.jessyan.autosize.internal.CustomAdapt;\nimport me.jessyan.autosize.utils.Preconditions;\n\n/**\n * ================================================\n * 当遇到本来适配正常的布局突然出现适配失效，适配异常等问题, 重写当前 {@link Activity} 的 {@link Activity#getResources()} 并调用\n * {@link AutoSizeCompat} 的对应方法即可解决问题\n * <p>\n * Created by JessYan on 2018/8/8 19:20\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic final class AutoSizeCompat {\n    private static SparseArray<DisplayMetricsInfo> mCache = new SparseArray<>();\n    private static final int MODE_SHIFT = 30;\n    private static final int MODE_MASK  = 0x3 << MODE_SHIFT;\n    private static final int MODE_ON_WIDTH  = 1 << MODE_SHIFT;\n    private static final int MODE_DEVICE_SIZE  = 2 << MODE_SHIFT;\n\n    private AutoSizeCompat() {\n        throw new IllegalStateException(\"you can't instantiate me!\");\n    }\n\n    /**\n     * 使用 AndroidAutoSize 初始化时设置的默认适配参数进行适配 (AndroidManifest 的 Meta 属性)\n     *\n     * @param resources {@link Resources}\n     */\n    public static void autoConvertDensityOfGlobal(Resources resources) {\n        if (AutoSizeConfig.getInstance().isBaseOnWidth()) {\n            autoConvertDensityBaseOnWidth(resources, AutoSizeConfig.getInstance().getDesignWidthInDp());\n        } else {\n            autoConvertDensityBaseOnHeight(resources, AutoSizeConfig.getInstance().getDesignHeightInDp());\n        }\n    }\n\n    /**\n     * 使用 {@link Activity} 或 Fragment 的自定义参数进行适配\n     *\n     * @param resources   {@link Resources}\n     * @param customAdapt {@link Activity} 或 Fragment 需实现 {@link CustomAdapt}\n     */\n    public static void autoConvertDensityOfCustomAdapt(Resources resources, CustomAdapt customAdapt) {\n        Preconditions.checkNotNull(customAdapt, \"customAdapt == null\");\n        float sizeInDp = customAdapt.getSizeInDp();\n\n        //如果 CustomAdapt#getSizeInDp() 返回 0, 则使用在 AndroidManifest 上填写的设计图尺寸\n        if (sizeInDp <= 0) {\n            if (customAdapt.isBaseOnWidth()) {\n                sizeInDp = AutoSizeConfig.getInstance().getDesignWidthInDp();\n            } else {\n                sizeInDp = AutoSizeConfig.getInstance().getDesignHeightInDp();\n            }\n        }\n        autoConvertDensity(resources, sizeInDp, customAdapt.isBaseOnWidth());\n    }\n\n    /**\n     * 使用外部三方库的 {@link Activity} 或 Fragment 的自定义适配参数进行适配\n     *\n     * @param resources         {@link Resources}\n     * @param externalAdaptInfo 三方库的 {@link Activity} 或 Fragment 提供的适配参数, 需要配合 {@link ExternalAdaptManager#addExternalAdaptInfoOfActivity(Class, ExternalAdaptInfo)}\n     */\n    public static void autoConvertDensityOfExternalAdaptInfo(Resources resources, ExternalAdaptInfo externalAdaptInfo) {\n        Preconditions.checkNotNull(externalAdaptInfo, \"externalAdaptInfo == null\");\n        float sizeInDp = externalAdaptInfo.getSizeInDp();\n\n        //如果 ExternalAdaptInfo#getSizeInDp() 返回 0, 则使用在 AndroidManifest 上填写的设计图尺寸\n        if (sizeInDp <= 0) {\n            if (externalAdaptInfo.isBaseOnWidth()) {\n                sizeInDp = AutoSizeConfig.getInstance().getDesignWidthInDp();\n            } else {\n                sizeInDp = AutoSizeConfig.getInstance().getDesignHeightInDp();\n            }\n        }\n        autoConvertDensity(resources, sizeInDp, externalAdaptInfo.isBaseOnWidth());\n    }\n\n    /**\n     * 以宽度为基准进行适配\n     *\n     * @param resources       {@link Resources}\n     * @param designWidthInDp 设计图的总宽度\n     */\n    public static void autoConvertDensityBaseOnWidth(Resources resources, float designWidthInDp) {\n        autoConvertDensity(resources, designWidthInDp, true);\n    }\n\n    /**\n     * 以高度为基准进行适配\n     *\n     * @param resources        {@link Resources}\n     * @param designHeightInDp 设计图的总高度\n     */\n    public static void autoConvertDensityBaseOnHeight(Resources resources, float designHeightInDp) {\n        autoConvertDensity(resources, designHeightInDp, false);\n    }\n\n    /**\n     * 这里是今日头条适配方案的核心代码, 核心在于根据当前设备的实际情况做自动计算并转换 {@link DisplayMetrics#density}、\n     * {@link DisplayMetrics#scaledDensity}、{@link DisplayMetrics#densityDpi} 这三个值, 额外增加 {@link DisplayMetrics#xdpi}\n     * 以支持单位 {@code pt}、{@code in}、{@code mm}\n     *\n     * @param resources     {@link Resources}\n     * @param sizeInDp      设计图上的设计尺寸, 单位 dp, 如果 {@param isBaseOnWidth} 设置为 {@code true},\n     *                      {@param sizeInDp} 则应该填写设计图的总宽度, 如果 {@param isBaseOnWidth} 设置为 {@code false},\n     *                      {@param sizeInDp} 则应该填写设计图的总高度\n     * @param isBaseOnWidth 是否按照宽度进行等比例适配, {@code true} 为以宽度进行等比例适配, {@code false} 为以高度进行等比例适配\n     * @see <a href=\"https://mp.weixin.qq.com/s/d9QCoBP6kV9VSWvVldVVwA\">今日头条官方适配方案</a>\n     */\n    public static void autoConvertDensity(Resources resources, float sizeInDp, boolean isBaseOnWidth) {\n        Preconditions.checkNotNull(resources, \"resources == null\");\n        Preconditions.checkMainThread();\n\n        float subunitsDesignSize = isBaseOnWidth ? AutoSizeConfig.getInstance().getUnitsManager().getDesignWidth()\n                : AutoSizeConfig.getInstance().getUnitsManager().getDesignHeight();\n        subunitsDesignSize = subunitsDesignSize > 0 ? subunitsDesignSize : sizeInDp;\n\n        int screenSize = isBaseOnWidth ? AutoSizeConfig.getInstance().getScreenWidth()\n                : AutoSizeConfig.getInstance().getScreenHeight();\n\n        int key = Math.round((sizeInDp + subunitsDesignSize + screenSize) * AutoSizeConfig.getInstance().getInitScaledDensity()) & ~MODE_MASK;\n        key = isBaseOnWidth ? (key | MODE_ON_WIDTH) : (key & ~MODE_ON_WIDTH);\n        key = AutoSizeConfig.getInstance().isUseDeviceSize() ? (key | MODE_DEVICE_SIZE) : (key & ~MODE_DEVICE_SIZE);\n\n        DisplayMetricsInfo displayMetricsInfo = mCache.get(key);\n\n        float targetDensity = 0;\n        int targetDensityDpi = 0;\n        float targetScaledDensity = 0;\n        float targetXdpi = 0;\n        int targetScreenWidthDp;\n        int targetScreenHeightDp;\n\n        if (displayMetricsInfo == null) {\n            if (isBaseOnWidth) {\n                targetDensity = AutoSizeConfig.getInstance().getScreenWidth() * 1.0f / sizeInDp;\n            } else {\n                targetDensity = AutoSizeConfig.getInstance().getScreenHeight() * 1.0f / sizeInDp;\n            }\n            if (AutoSizeConfig.getInstance().getPrivateFontScale() > 0) {\n                targetScaledDensity = targetDensity * AutoSizeConfig.getInstance().getPrivateFontScale();\n            } else {\n                float systemFontScale = AutoSizeConfig.getInstance().isExcludeFontScale() ? 1 : AutoSizeConfig.getInstance().\n                        getInitScaledDensity() * 1.0f / AutoSizeConfig.getInstance().getInitDensity();\n                targetScaledDensity = targetDensity * systemFontScale;\n            }\n            targetDensityDpi = (int) (targetDensity * 160);\n\n            targetScreenWidthDp = (int) (AutoSizeConfig.getInstance().getScreenWidth() / targetDensity);\n            targetScreenHeightDp = (int) (AutoSizeConfig.getInstance().getScreenHeight() / targetDensity);\n\n            if (isBaseOnWidth) {\n                targetXdpi = AutoSizeConfig.getInstance().getScreenWidth() * 1.0f / subunitsDesignSize;\n            } else {\n                targetXdpi = AutoSizeConfig.getInstance().getScreenHeight() * 1.0f / subunitsDesignSize;\n            }\n\n            mCache.put(key, new DisplayMetricsInfo(targetDensity, targetDensityDpi, targetScaledDensity, targetXdpi, targetScreenWidthDp, targetScreenHeightDp));\n        } else {\n            targetDensity = displayMetricsInfo.getDensity();\n            targetDensityDpi = displayMetricsInfo.getDensityDpi();\n            targetScaledDensity = displayMetricsInfo.getScaledDensity();\n            targetXdpi = displayMetricsInfo.getXdpi();\n            targetScreenWidthDp = displayMetricsInfo.getScreenWidthDp();\n            targetScreenHeightDp = displayMetricsInfo.getScreenHeightDp();\n        }\n\n        setDensity(resources, targetDensity, targetDensityDpi, targetScaledDensity, targetXdpi);\n        setScreenSizeDp(resources, targetScreenWidthDp, targetScreenHeightDp);\n    }\n\n    /**\n     * 取消适配\n     *\n     * @param resources {@link Resources}\n     */\n    public static void cancelAdapt(Resources resources) {\n        Preconditions.checkMainThread();\n        float initXdpi = AutoSizeConfig.getInstance().getInitXdpi();\n        switch (AutoSizeConfig.getInstance().getUnitsManager().getSupportSubunits()) {\n            case PT:\n                initXdpi = initXdpi / 72f;\n                break;\n            case MM:\n                initXdpi = initXdpi / 25.4f;\n                break;\n            default:\n        }\n        setDensity(resources, AutoSizeConfig.getInstance().getInitDensity()\n                , AutoSizeConfig.getInstance().getInitDensityDpi()\n                , AutoSizeConfig.getInstance().getInitScaledDensity()\n                , initXdpi);\n        setScreenSizeDp(resources\n                , AutoSizeConfig.getInstance().getInitScreenWidthDp()\n                , AutoSizeConfig.getInstance().getInitScreenHeightDp());\n    }\n\n    /**\n     * 给几大 {@link DisplayMetrics} 赋值\n     *\n     * @param resources     {@link Resources}\n     * @param density       {@link DisplayMetrics#density}\n     * @param densityDpi    {@link DisplayMetrics#densityDpi}\n     * @param scaledDensity {@link DisplayMetrics#scaledDensity}\n     * @param xdpi          {@link DisplayMetrics#xdpi}\n     */\n    private static void setDensity(Resources resources, float density, int densityDpi, float scaledDensity, float xdpi) {\n        DisplayMetrics activityDisplayMetrics = resources.getDisplayMetrics();\n        setDensity(activityDisplayMetrics, density, densityDpi, scaledDensity, xdpi);\n        DisplayMetrics appDisplayMetrics = AutoSizeConfig.getInstance().getApplication().getResources().getDisplayMetrics();\n        setDensity(appDisplayMetrics, density, densityDpi, scaledDensity, xdpi);\n\n        //兼容 MIUI\n        DisplayMetrics activityDisplayMetricsOnMIUI = getMetricsOnMiui(resources);\n        DisplayMetrics appDisplayMetricsOnMIUI = getMetricsOnMiui(AutoSizeConfig.getInstance().getApplication().getResources());\n\n        if (activityDisplayMetricsOnMIUI != null) {\n            setDensity(activityDisplayMetricsOnMIUI, density, densityDpi, scaledDensity, xdpi);\n        }\n        if (appDisplayMetricsOnMIUI != null) {\n            setDensity(appDisplayMetricsOnMIUI, density, densityDpi, scaledDensity, xdpi);\n        }\n    }\n\n    /**\n     * 赋值\n     *\n     * @param displayMetrics {@link DisplayMetrics}\n     * @param density        {@link DisplayMetrics#density}\n     * @param densityDpi     {@link DisplayMetrics#densityDpi}\n     * @param scaledDensity  {@link DisplayMetrics#scaledDensity}\n     * @param xdpi           {@link DisplayMetrics#xdpi}\n     */\n    private static void setDensity(DisplayMetrics displayMetrics, float density, int densityDpi, float scaledDensity, float xdpi) {\n        if (AutoSizeConfig.getInstance().getUnitsManager().isSupportDP()) {\n            displayMetrics.density = density;\n            displayMetrics.densityDpi = densityDpi;\n        }\n        if (AutoSizeConfig.getInstance().getUnitsManager().isSupportSP()) {\n            displayMetrics.scaledDensity = scaledDensity;\n        }\n        switch (AutoSizeConfig.getInstance().getUnitsManager().getSupportSubunits()) {\n            case NONE:\n                break;\n            case PT:\n                displayMetrics.xdpi = xdpi * 72f;\n                break;\n            case IN:\n                displayMetrics.xdpi = xdpi;\n                break;\n            case MM:\n                displayMetrics.xdpi = xdpi * 25.4f;\n                break;\n            default:\n        }\n    }\n\n    /**\n     * 给 {@link Configuration} 赋值\n     *\n     * @param resources      {@link Resources}\n     * @param screenWidthDp  {@link Configuration#screenWidthDp}\n     * @param screenHeightDp {@link Configuration#screenHeightDp}\n     */\n    private static void setScreenSizeDp(Resources resources, int screenWidthDp, int screenHeightDp) {\n        if (AutoSizeConfig.getInstance().getUnitsManager().isSupportDP() && AutoSizeConfig.getInstance().getUnitsManager().isSupportScreenSizeDP()) {\n            Configuration activityConfiguration = resources.getConfiguration();\n            setScreenSizeDp(activityConfiguration, screenWidthDp, screenHeightDp);\n\n            Configuration appConfiguration = AutoSizeConfig.getInstance().getApplication().getResources().getConfiguration();\n            setScreenSizeDp(appConfiguration, screenWidthDp, screenHeightDp);\n        }\n    }\n\n    /**\n     * Configuration赋值\n     *\n     * @param configuration  {@link Configuration}\n     * @param screenWidthDp  {@link Configuration#screenWidthDp}\n     * @param screenHeightDp {@link Configuration#screenHeightDp}\n     */\n    private static void setScreenSizeDp(Configuration configuration, int screenWidthDp, int screenHeightDp) {\n        configuration.screenWidthDp = screenWidthDp;\n        configuration.screenHeightDp = screenHeightDp;\n    }\n\n    /**\n     * 解决 MIUI 更改框架导致的 MIUI7 + Android5.1.1 上出现的失效问题 (以及极少数基于这部分 MIUI 去掉 ART 然后置入 XPosed 的手机)\n     * 来源于: https://github.com/Firedamp/Rudeness/blob/master/rudeness-sdk/src/main/java/com/bulong/rudeness/RudenessScreenHelper.java#L61:5\n     *\n     * @param resources {@link Resources}\n     * @return {@link DisplayMetrics}, 可能为 {@code null}\n     */\n    private static DisplayMetrics getMetricsOnMiui(Resources resources) {\n        if (AutoSizeConfig.getInstance().isMiui() && AutoSizeConfig.getInstance().getTmpMetricsField() != null) {\n            try {\n                return (DisplayMetrics) AutoSizeConfig.getInstance().getTmpMetricsField().get(resources);\n            } catch (Exception e) {\n                return null;\n            }\n        }\n        return null;\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/AutoSizeConfig.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize;\n\nimport android.app.Activity;\nimport android.app.Application;\nimport android.content.ComponentCallbacks;\nimport android.content.Context;\nimport android.content.pm.ApplicationInfo;\nimport android.content.pm.PackageManager;\nimport android.content.res.Configuration;\nimport android.content.res.Resources;\nimport android.util.DisplayMetrics;\n\nimport java.lang.reflect.Field;\n\nimport me.jessyan.autosize.external.ExternalAdaptManager;\nimport me.jessyan.autosize.unit.Subunits;\nimport me.jessyan.autosize.unit.UnitsManager;\nimport me.jessyan.autosize.utils.AutoSizeLog;\nimport me.jessyan.autosize.utils.Preconditions;\nimport me.jessyan.autosize.utils.ScreenUtils;\n\n/**\n * ================================================\n * AndroidAutoSize 参数配置类, 给 AndroidAutoSize 配置一些必要的自定义参数\n * <p>\n * Created by JessYan on 2018/8/8 09:58\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic final class AutoSizeConfig {\n    private static volatile AutoSizeConfig sInstance;\n    private static final String KEY_DESIGN_WIDTH_IN_DP = \"design_width_in_dp\";\n    private static final String KEY_DESIGN_HEIGHT_IN_DP = \"design_height_in_dp\";\n    public static final boolean DEPENDENCY_ANDROIDX;\n    public static final boolean DEPENDENCY_SUPPORT;\n    private Application mApplication;\n    /**\n     * 用来管理外部三方库 {@link Activity} 的适配\n     */\n    private ExternalAdaptManager mExternalAdaptManager = new ExternalAdaptManager();\n    /**\n     * 用来管理 AndroidAutoSize 支持的所有单位, AndroidAutoSize 支持五种单位 (dp、sp、pt、in、mm)\n     */\n    private UnitsManager mUnitsManager = new UnitsManager();\n    /**\n     * 最初的 {@link DisplayMetrics#density}\n     */\n    private float mInitDensity = -1;\n    /**\n     * 最初的 {@link DisplayMetrics#densityDpi}\n     */\n    private int mInitDensityDpi;\n    /**\n     * 最初的 {@link DisplayMetrics#scaledDensity}\n     */\n    private float mInitScaledDensity;\n    /**\n     * 最初的 {@link DisplayMetrics#xdpi}\n     */\n    private float mInitXdpi;\n    /**\n     * 最初的 {@link Configuration#screenWidthDp}\n     */\n    private int mInitScreenWidthDp;\n    /**\n     * 最初的 {@link Configuration#screenHeightDp}\n     */\n    private int mInitScreenHeightDp;\n    /**\n     * 设计图上的总宽度, 单位 dp\n     */\n    private int mDesignWidthInDp;\n    /**\n     * 设计图上的总高度, 单位 dp\n     */\n    private int mDesignHeightInDp;\n    /**\n     * 设备的屏幕总宽度, 单位 px\n     */\n    private int mScreenWidth;\n    /**\n     * 设备的屏幕总高度, 单位 px, 如果 {@link #isUseDeviceSize} 为 {@code false}, 屏幕总高度会减去状态栏的高度\n     */\n    private int mScreenHeight;\n    /**\n     * 状态栏高度, 当 {@link #isUseDeviceSize} 为 {@code false} 时, AndroidAutoSize 会将 {@link #mScreenHeight} 减去状态栏高度\n     * AndroidAutoSize 默认使用 {@link ScreenUtils#getStatusBarHeight()} 方法获取状态栏高度\n     * AndroidAutoSize 使用者可使用 {@link #setStatusBarHeight(int)} 自行设置状态栏高度\n     */\n    private int mStatusBarHeight;\n    /**\n     * 为了保证在不同高宽比的屏幕上显示效果也能完全一致, 所以本方案适配时是以设计图宽度与设备实际宽度的比例或设计图高度与设备实际高度的比例应用到\n     * 每个 View 上 (只能在宽度和高度之中选一个作为基准), 从而使每个 View 的高和宽用同样的比例缩放, 避免在与设计图高宽比不一致的设备上出现适配的 View 高或宽变形的问题\n     * {@link #isBaseOnWidth} 为 {@code true} 时代表以宽度等比例缩放, {@code false} 代表以高度等比例缩放\n     * {@link #isBaseOnWidth} 为全局配置, 默认为 {@code true}, 每个 {@link Activity} 也可以单独选择使用高或者宽做等比例缩放\n     */\n    private boolean isBaseOnWidth = true;\n    /**\n     * 此字段表示是否使用设备的实际尺寸做适配\n     * {@link #isUseDeviceSize} 为 {@code true} 表示屏幕高度 {@link #mScreenHeight} 包含状态栏的高度\n     * {@link #isUseDeviceSize} 为 {@code false} 表示 {@link #mScreenHeight} 会减去状态栏的高度, 默认为 {@code true}\n     */\n    private boolean isUseDeviceSize = true;\n    /**\n     * {@link #mActivityLifecycleCallbacks} 可用来代替在 BaseActivity 中加入适配代码的传统方式\n     * {@link #mActivityLifecycleCallbacks} 这种方案类似于 AOP, 面向接口, 侵入性低, 方便统一管理, 扩展性强, 并且也支持适配三方库的 {@link Activity}\n     */\n    private ActivityLifecycleCallbacksImpl mActivityLifecycleCallbacks;\n    /**\n     * 框架具有 热插拔 特性, 支持在项目运行中动态停止和重新启动适配功能\n     *\n     * @see #stop(Activity)\n     * @see #restart()\n     */\n    private boolean isStop;\n    /**\n     * 是否让框架支持自定义 Fragment 的适配参数, 由于这个需求是比较少见的, 所以须要使用者手动开启\n     */\n    private boolean isCustomFragment;\n    /**\n     * 屏幕方向, {@code true} 为纵向, {@code false} 为横向\n     */\n    private boolean isVertical;\n    /**\n     * 是否屏蔽系统字体大小对 AndroidAutoSize 的影响, 如果为 {@code true}, App 内的字体的大小将不会跟随系统设置中字体大小的改变\n     * 如果为 {@code false}, 则会跟随系统设置中字体大小的改变, 默认为 {@code false}\n     */\n    private boolean isExcludeFontScale;\n    /**\n     * 区别于系统字体大小的放大比例, AndroidAutoSize 允许 APP 内部可以独立于系统字体大小之外，独自拥有全局调节 APP 字体大小的能力\n     * 当然, 在 APP 内您必须使用 sp 来作为字体的单位, 否则此功能无效, 将此值设为 0 则取消此功能\n     */\n    private float privateFontScale;\n    /**\n     * 是否是 Miui 系统\n     */\n    private boolean isMiui;\n    /**\n     * Miui 系统中的 mTmpMetrics 字段\n     */\n    private Field mTmpMetricsField;\n    /**\n     * 屏幕适配监听器，用于监听屏幕适配时的一些事件\n     */\n    private onAdaptListener mOnAdaptListener;\n\n    static {\n        DEPENDENCY_ANDROIDX = findClassByClassName(\"androidx.fragment.app.FragmentActivity\");\n        DEPENDENCY_SUPPORT = findClassByClassName(\"android.support.v4.app.FragmentActivity\");\n    }\n\n    private static boolean findClassByClassName(String className) {\n        boolean hasDependency;\n        try {\n            Class.forName(className);\n            hasDependency = true;\n        } catch (ClassNotFoundException e) {\n            hasDependency = false;\n        }\n        return hasDependency;\n    }\n\n    public static AutoSizeConfig getInstance() {\n        if (sInstance == null) {\n            synchronized (AutoSizeConfig.class) {\n                if (sInstance == null) {\n                    sInstance = new AutoSizeConfig();\n                }\n            }\n        }\n        return sInstance;\n    }\n\n    private AutoSizeConfig() {\n    }\n\n    public Application getApplication() {\n        Preconditions.checkNotNull(mApplication, \"Please call the AutoSizeConfig#init() first\");\n        return mApplication;\n    }\n\n    /**\n     * v0.7.0 以后, 框架会在 APP 启动时自动调用此方法进行初始化, 使用者无需手动初始化, 初始化方法只能调用一次, 否则报错\n     * 此方法默认使用以宽度进行等比例适配, 如想使用以高度进行等比例适配, 请调用 {@link #init(Application, boolean)}\n     *\n     * @param application {@link Application}\n     */\n    AutoSizeConfig init(Application application) {\n        return init(application, true, null);\n    }\n\n    /**\n     * v0.7.0 以后, 框架会在 APP 启动时自动调用此方法进行初始化, 使用者无需手动初始化, 初始化方法只能调用一次, 否则报错\n     * 此方法使用默认的 {@link AutoAdaptStrategy} 策略, 如想使用自定义的 {@link AutoAdaptStrategy} 策略\n     * 请调用 {@link #init(Application, boolean, AutoAdaptStrategy)}\n     *\n     * @param application   {@link Application}\n     * @param isBaseOnWidth 详情请查看 {@link #isBaseOnWidth} 的注释\n     */\n    AutoSizeConfig init(Application application, boolean isBaseOnWidth) {\n        return init(application, isBaseOnWidth, null);\n    }\n\n    /**\n     * v0.7.0 以后, 框架会在 APP 启动时自动调用此方法进行初始化, 使用者无需手动初始化, 初始化方法只能调用一次, 否则报错\n     *\n     * @param application   {@link Application}\n     * @param isBaseOnWidth 详情请查看 {@link #isBaseOnWidth} 的注释\n     * @param strategy      {@link AutoAdaptStrategy}, 传 {@code null} 则使用 {@link DefaultAutoAdaptStrategy}\n     */\n    AutoSizeConfig init(final Application application, boolean isBaseOnWidth, AutoAdaptStrategy strategy) {\n        Preconditions.checkArgument(mInitDensity == -1, \"AutoSizeConfig#init() can only be called once\");\n        Preconditions.checkNotNull(application, \"application == null\");\n        this.mApplication = application;\n        this.isBaseOnWidth = isBaseOnWidth;\n        final DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();\n        final Configuration configuration = Resources.getSystem().getConfiguration();\n\n        //设置一个默认值, 避免在低配设备上因为获取 MetaData 过慢, 导致适配时未能正常获取到设计图尺寸\n        //建议使用者在低配设备上主动在 Application#onCreate 中调用 setDesignWidthInDp 替代以使用 AndroidManifest 配置设计图尺寸的方式\n        if (AutoSizeConfig.getInstance().getUnitsManager().getSupportSubunits() == Subunits.NONE) {\n            mDesignWidthInDp = 360;\n            mDesignHeightInDp = 640;\n        } else {\n            mDesignWidthInDp = 1080;\n            mDesignHeightInDp = 1920;\n        }\n\n        getMetaData(application);\n        isVertical = application.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;\n        int[] screenSize = ScreenUtils.getScreenSize(application);\n        mScreenWidth = screenSize[0];\n        mScreenHeight = screenSize[1];\n        mStatusBarHeight = ScreenUtils.getStatusBarHeight();\n        AutoSizeLog.d(\"designWidthInDp = \" + mDesignWidthInDp + \", designHeightInDp = \" + mDesignHeightInDp + \", screenWidth = \" + mScreenWidth + \", screenHeight = \" + mScreenHeight);\n\n        mInitDensity = displayMetrics.density;\n        mInitDensityDpi = displayMetrics.densityDpi;\n        mInitScaledDensity = displayMetrics.scaledDensity;\n        mInitXdpi = displayMetrics.xdpi;\n        mInitScreenWidthDp = configuration.screenWidthDp;\n        mInitScreenHeightDp = configuration.screenHeightDp;\n        application.registerComponentCallbacks(new ComponentCallbacks() {\n            @Override\n            public void onConfigurationChanged(Configuration newConfig) {\n                if (newConfig != null) {\n                    if (newConfig.fontScale > 0) {\n                        mInitScaledDensity =\n                                Resources.getSystem().getDisplayMetrics().scaledDensity;\n                        AutoSizeLog.d(\"initScaledDensity = \" + mInitScaledDensity + \" on ConfigurationChanged\");\n                    }\n                    isVertical = newConfig.orientation == Configuration.ORIENTATION_PORTRAIT;\n                    int[] screenSize = ScreenUtils.getScreenSize(application);\n                    mScreenWidth = screenSize[0];\n                    mScreenHeight = screenSize[1];\n                }\n            }\n\n            @Override\n            public void onLowMemory() {\n\n            }\n        });\n        AutoSizeLog.d(\"initDensity = \" + mInitDensity + \", initScaledDensity = \" + mInitScaledDensity);\n        mActivityLifecycleCallbacks = new ActivityLifecycleCallbacksImpl(new WrapperAutoAdaptStrategy(strategy == null ? new DefaultAutoAdaptStrategy() : strategy));\n        application.registerActivityLifecycleCallbacks(mActivityLifecycleCallbacks);\n        if (\"MiuiResources\".equals(application.getResources().getClass().getSimpleName()) || \"XResources\".equals(application.getResources().getClass().getSimpleName())) {\n            isMiui = true;\n            try {\n                mTmpMetricsField = Resources.class.getDeclaredField(\"mTmpMetrics\");\n                mTmpMetricsField.setAccessible(true);\n            } catch (Exception e) {\n                mTmpMetricsField = null;\n            }\n        }\n        return this;\n    }\n\n    /**\n     * 重新开始框架的运行\n     * 框架具有 热插拔 特性, 支持在项目运行中动态停止和重新启动适配功能\n     */\n    public void restart() {\n        Preconditions.checkNotNull(mActivityLifecycleCallbacks, \"Please call the AutoSizeConfig#init() first\");\n        synchronized (AutoSizeConfig.class) {\n            if (isStop) {\n                mApplication.registerActivityLifecycleCallbacks(mActivityLifecycleCallbacks);\n                isStop = false;\n            }\n        }\n    }\n\n    /**\n     * 停止框架的运行\n     * 框架具有 热插拔 特性, 支持在项目运行中动态停止和重新启动适配功能\n     */\n    public void stop(Activity activity) {\n        Preconditions.checkNotNull(mActivityLifecycleCallbacks, \"Please call the AutoSizeConfig#init() first\");\n        synchronized (AutoSizeConfig.class) {\n            if (!isStop) {\n                mApplication.unregisterActivityLifecycleCallbacks(mActivityLifecycleCallbacks);\n                AutoSize.cancelAdapt(activity);\n                isStop = true;\n            }\n        }\n    }\n\n    /**\n     * 设置屏幕适配逻辑策略类\n     *\n     * @param autoAdaptStrategy {@link AutoAdaptStrategy}\n     */\n    public AutoSizeConfig setAutoAdaptStrategy(AutoAdaptStrategy autoAdaptStrategy) {\n        Preconditions.checkNotNull(autoAdaptStrategy, \"autoAdaptStrategy == null\");\n        Preconditions.checkNotNull(mActivityLifecycleCallbacks, \"Please call the AutoSizeConfig#init() first\");\n        mActivityLifecycleCallbacks.setAutoAdaptStrategy(new WrapperAutoAdaptStrategy(autoAdaptStrategy));\n        return this;\n    }\n\n    /**\n     * 设置屏幕适配监听器\n     *\n     * @param onAdaptListener {@link onAdaptListener}\n     */\n    public AutoSizeConfig setOnAdaptListener(onAdaptListener onAdaptListener) {\n        Preconditions.checkNotNull(onAdaptListener, \"onAdaptListener == null\");\n        mOnAdaptListener = onAdaptListener;\n        return this;\n    }\n\n    /**\n     * 是否全局按照宽度进行等比例适配\n     *\n     * @param baseOnWidth {@code true} 为按照宽度, {@code false} 为按照高度\n     * @see #isBaseOnWidth 详情请查看这个字段的注释\n     */\n    public AutoSizeConfig setBaseOnWidth(boolean baseOnWidth) {\n        isBaseOnWidth = baseOnWidth;\n        return this;\n    }\n\n    /**\n     * 是否使用设备的实际尺寸做适配\n     *\n     * @param useDeviceSize {@code true} 为使用设备的实际尺寸 (包含状态栏), {@code false} 为不使用设备的实际尺寸 (不包含状态栏)\n     * @see #isUseDeviceSize 详情请查看这个字段的注释\n     */\n    public AutoSizeConfig setUseDeviceSize(boolean useDeviceSize) {\n        isUseDeviceSize = useDeviceSize;\n        return this;\n    }\n\n    /**\n     * 是否打印 Log\n     *\n     * @param log {@code true} 为打印\n     */\n    public AutoSizeConfig setLog(boolean log) {\n        AutoSizeLog.setDebug(log);\n        return this;\n    }\n\n    /**\n     * 是否让框架支持自定义 Fragment 的适配参数, 由于这个需求是比较少见的, 所以须要使用者手动开启\n     *\n     * @param customFragment {@code true} 为支持\n     */\n    public AutoSizeConfig setCustomFragment(boolean customFragment) {\n        isCustomFragment = customFragment;\n        return this;\n    }\n\n    /**\n     * 框架是否已经开启支持自定义 Fragment 的适配参数\n     *\n     * @return {@code true} 为支持\n     */\n    public boolean isCustomFragment() {\n        return isCustomFragment;\n    }\n\n    /**\n     * 框架是否已经停止运行\n     *\n     * @return {@code false} 框架正在运行, {@code true} 框架已经停止运行\n     */\n    public boolean isStop() {\n        return isStop;\n    }\n\n    /**\n     * {@link ExternalAdaptManager} 用来管理外部三方库 {@link Activity} 的适配\n     *\n     * @return {@link #mExternalAdaptManager}\n     */\n    public ExternalAdaptManager getExternalAdaptManager() {\n        return mExternalAdaptManager;\n    }\n\n    /**\n     * {@link UnitsManager} 用来管理 AndroidAutoSize 支持的所有单位, AndroidAutoSize 支持五种单位 (dp、sp、pt、in、mm)\n     *\n     * @return {@link #mUnitsManager}\n     */\n    public UnitsManager getUnitsManager() {\n        return mUnitsManager;\n    }\n\n    /**\n     * 返回 {@link #mOnAdaptListener}\n     *\n     * @return {@link #mOnAdaptListener}\n     */\n    public onAdaptListener getOnAdaptListener() {\n        return mOnAdaptListener;\n    }\n\n    /**\n     * 返回 {@link #isBaseOnWidth}\n     *\n     * @return {@link #isBaseOnWidth}\n     */\n    public boolean isBaseOnWidth() {\n        return isBaseOnWidth;\n    }\n\n    /**\n     * 返回 {@link #isUseDeviceSize}\n     *\n     * @return {@link #isUseDeviceSize}\n     */\n    public boolean isUseDeviceSize() {\n        return isUseDeviceSize;\n    }\n\n    /**\n     * 返回 {@link #mScreenWidth}\n     *\n     * @return {@link #mScreenWidth}\n     */\n    public int getScreenWidth() {\n        return mScreenWidth;\n    }\n\n    /**\n     * 返回 {@link #mScreenHeight}\n     *\n     * @return {@link #mScreenHeight}\n     */\n    public int getScreenHeight() {\n        return isUseDeviceSize() ? mScreenHeight : mScreenHeight - mStatusBarHeight;\n    }\n\n    /**\n     * 获取 {@link #mDesignWidthInDp}\n     *\n     * @return {@link #mDesignWidthInDp}\n     */\n    public int getDesignWidthInDp() {\n        Preconditions.checkArgument(mDesignWidthInDp > 0, \"you must set \" + KEY_DESIGN_WIDTH_IN_DP + \"  in your AndroidManifest file\");\n        return mDesignWidthInDp;\n    }\n\n    /**\n     * 获取 {@link #mDesignHeightInDp}\n     *\n     * @return {@link #mDesignHeightInDp}\n     */\n    public int getDesignHeightInDp() {\n        Preconditions.checkArgument(mDesignHeightInDp > 0, \"you must set \" + KEY_DESIGN_HEIGHT_IN_DP + \"  in your AndroidManifest file\");\n        return mDesignHeightInDp;\n    }\n\n    /**\n     * 获取 {@link #mInitDensity}\n     *\n     * @return {@link #mInitDensity}\n     */\n    public float getInitDensity() {\n        return mInitDensity;\n    }\n\n    /**\n     * 获取 {@link #mInitDensityDpi}\n     *\n     * @return {@link #mInitDensityDpi}\n     */\n    public int getInitDensityDpi() {\n        return mInitDensityDpi;\n    }\n\n    /**\n     * 获取 {@link #mInitScaledDensity}\n     *\n     * @return {@link #mInitScaledDensity}\n     */\n    public float getInitScaledDensity() {\n        return mInitScaledDensity;\n    }\n\n    /**\n     * 获取 {@link #mInitXdpi}\n     *\n     * @return {@link #mInitXdpi}\n     */\n    public float getInitXdpi() {\n        return mInitXdpi;\n    }\n\n    /**\n     * 获取 {@link #mInitScreenWidthDp}\n     *\n     * @return {@link #mInitScreenWidthDp}\n     */\n    public int getInitScreenWidthDp() {\n        return mInitScreenWidthDp;\n    }\n\n    /**\n     * 获取 {@link #mInitScreenHeightDp}\n     *\n     * @return {@link #mInitScreenHeightDp}\n     */\n    public int getInitScreenHeightDp() {\n        return mInitScreenHeightDp;\n    }\n\n    /**\n     * 获取屏幕方向\n     *\n     * @return {@code true} 为纵向, {@code false} 为横向\n     */\n    public boolean isVertical() {\n        return isVertical;\n    }\n\n    /**\n     * 返回 {@link #isMiui}\n     *\n     * @return {@link #isMiui}\n     */\n    public boolean isMiui() {\n        return isMiui;\n    }\n\n    /**\n     * 返回 {@link #mTmpMetricsField}\n     *\n     * @return {@link #mTmpMetricsField}\n     */\n    public Field getTmpMetricsField() {\n        return mTmpMetricsField;\n    }\n\n    /**\n     * 设置屏幕方向\n     *\n     * @param vertical {@code true} 为纵向, {@code false} 为横向\n     */\n    public AutoSizeConfig setVertical(boolean vertical) {\n        isVertical = vertical;\n        return this;\n    }\n\n    /**\n     * 是否屏蔽系统字体大小对 AndroidAutoSize 的影响, 如果为 {@code true}, App 内的字体的大小将不会跟随系统设置中字体大小的改变\n     * 如果为 {@code false}, 则会跟随系统设置中字体大小的改变, 默认为 {@code false}\n     *\n     * @return {@link #isExcludeFontScale}\n     */\n    public boolean isExcludeFontScale() {\n        return isExcludeFontScale;\n    }\n\n    /**\n     * 是否屏蔽系统字体大小对 AndroidAutoSize 的影响, 如果为 {@code true}, App 内的字体的大小将不会跟随系统设置中字体大小的改变\n     * 如果为 {@code false}, 则会跟随系统设置中字体大小的改变, 默认为 {@code false}\n     *\n     * @param excludeFontScale 是否屏蔽\n     */\n    public AutoSizeConfig setExcludeFontScale(boolean excludeFontScale) {\n        isExcludeFontScale = excludeFontScale;\n        return this;\n    }\n\n    /**\n     * 区别于系统字体大小的放大比例, AndroidAutoSize 允许 APP 内部可以独立于系统字体大小之外，独自拥有全局调节 APP 字体大小的能力\n     * 当然, 在 APP 内您必须使用 sp 来作为字体的单位, 否则此功能无效\n     *\n     * @param fontScale 字体大小放大的比例, 设为 0 则取消此功能\n     */\n    public AutoSizeConfig setPrivateFontScale(float fontScale) {\n        privateFontScale = fontScale;\n        return this;\n    }\n\n    /**\n     * 区别于系统字体大小的放大比例, AndroidAutoSize 允许 APP 内部可以独立于系统字体大小之外，独自拥有全局调节 APP 字体大小的能力\n     * 当然, 在 APP 内您必须使用 sp 来作为字体的单位, 否则此功能无效\n     *\n     * @return 私有的字体大小放大比例\n     */\n    public float getPrivateFontScale() {\n        return privateFontScale;\n    }\n\n    /**\n     * 设置屏幕宽度\n     *\n     * @param screenWidth 屏幕宽度\n     */\n    public AutoSizeConfig setScreenWidth(int screenWidth) {\n        Preconditions.checkArgument(screenWidth > 0, \"screenWidth must be > 0\");\n        mScreenWidth = screenWidth;\n        return this;\n    }\n\n    /**\n     * 设置屏幕高度\n     *\n     * @param screenHeight 屏幕高度 (需要包含状态栏)\n     */\n    public AutoSizeConfig setScreenHeight(int screenHeight) {\n        Preconditions.checkArgument(screenHeight > 0, \"screenHeight must be > 0\");\n        mScreenHeight = screenHeight;\n        return this;\n    }\n\n    /**\n     * 设置全局设计图宽度\n     *\n     * @param designWidthInDp 设计图宽度\n     */\n    public AutoSizeConfig setDesignWidthInDp(int designWidthInDp) {\n        Preconditions.checkArgument(designWidthInDp > 0, \"designWidthInDp must be > 0\");\n        mDesignWidthInDp = designWidthInDp;\n        return this;\n    }\n\n    /**\n     * 设置全局设计图高度\n     *\n     * @param designHeightInDp 设计图高度\n     */\n    public AutoSizeConfig setDesignHeightInDp(int designHeightInDp) {\n        Preconditions.checkArgument(designHeightInDp > 0, \"designHeightInDp must be > 0\");\n        mDesignHeightInDp = designHeightInDp;\n        return this;\n    }\n\n    /**\n     * 设置状态栏高度\n     *\n     * @param statusBarHeight 状态栏高度\n     */\n    public AutoSizeConfig setStatusBarHeight(int statusBarHeight) {\n        Preconditions.checkArgument(statusBarHeight > 0, \"statusBarHeight must be > 0\");\n        mStatusBarHeight = statusBarHeight;\n        return this;\n    }\n\n    /**\n     * 获取使用者在 AndroidManifest 中填写的 Meta 信息\n     * <p>\n     * Example usage:\n     * <pre>\n     * <meta-data android:name=\"design_width_in_dp\"\n     *            android:value=\"360\"/>\n     * <meta-data android:name=\"design_height_in_dp\"\n     *            android:value=\"640\"/>\n     * </pre>\n     *\n     * @param context {@link Context}\n     */\n    private void getMetaData(final Context context) {\n        new Thread(new Runnable() {\n            @Override\n            public void run() {\n                PackageManager packageManager = context.getPackageManager();\n                ApplicationInfo applicationInfo;\n                try {\n                    applicationInfo = packageManager.getApplicationInfo(context\n                            .getPackageName(), PackageManager.GET_META_DATA);\n                    if (applicationInfo != null && applicationInfo.metaData != null) {\n                        if (applicationInfo.metaData.containsKey(KEY_DESIGN_WIDTH_IN_DP)) {\n                            mDesignWidthInDp = (int) applicationInfo.metaData.get(KEY_DESIGN_WIDTH_IN_DP);\n                        }\n                        if (applicationInfo.metaData.containsKey(KEY_DESIGN_HEIGHT_IN_DP)) {\n                            mDesignHeightInDp = (int) applicationInfo.metaData.get(KEY_DESIGN_HEIGHT_IN_DP);\n                        }\n                    }\n                } catch (PackageManager.NameNotFoundException e) {\n                    e.printStackTrace();\n                }\n            }\n        }).start();\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/DefaultAutoAdaptStrategy.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize;\n\nimport android.app.Activity;\nimport android.app.Application;\n\nimport java.util.Locale;\n\nimport me.jessyan.autosize.external.ExternalAdaptInfo;\nimport me.jessyan.autosize.internal.CancelAdapt;\nimport me.jessyan.autosize.internal.CustomAdapt;\nimport me.jessyan.autosize.utils.AutoSizeLog;\n\n/**\n * ================================================\n * 屏幕适配逻辑策略默认实现类, 可通过 {@link AutoSizeConfig#init(Application, boolean, AutoAdaptStrategy)}\n * 和 {@link AutoSizeConfig#setAutoAdaptStrategy(AutoAdaptStrategy)} 切换策略\n *\n * @see AutoAdaptStrategy\n * Created by JessYan on 2018/8/9 15:57\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class DefaultAutoAdaptStrategy implements AutoAdaptStrategy {\n    @Override\n    public void applyAdapt(Object target, Activity activity) {\n\n        //检查是否开启了外部三方库的适配模式, 只要不主动调用 ExternalAdaptManager 的方法, 下面的代码就不会执行\n        if (AutoSizeConfig.getInstance().getExternalAdaptManager().isRun()) {\n            if (AutoSizeConfig.getInstance().getExternalAdaptManager().isCancelAdapt(target.getClass())) {\n                AutoSizeLog.w(String.format(Locale.ENGLISH, \"%s canceled the adaptation!\", target.getClass().getName()));\n                AutoSize.cancelAdapt(activity);\n                return;\n            } else {\n                ExternalAdaptInfo info = AutoSizeConfig.getInstance().getExternalAdaptManager()\n                        .getExternalAdaptInfoOfActivity(target.getClass());\n                if (info != null) {\n                    AutoSizeLog.d(String.format(Locale.ENGLISH, \"%s used %s for adaptation!\", target.getClass().getName(), ExternalAdaptInfo.class.getName()));\n                    AutoSize.autoConvertDensityOfExternalAdaptInfo(activity, info);\n                    return;\n                }\n            }\n        }\n\n        //如果 target 实现 CancelAdapt 接口表示放弃适配, 所有的适配效果都将失效\n        if (target instanceof CancelAdapt) {\n            AutoSizeLog.w(String.format(Locale.ENGLISH, \"%s canceled the adaptation!\", target.getClass().getName()));\n            AutoSize.cancelAdapt(activity);\n            return;\n        }\n\n        //如果 target 实现 CustomAdapt 接口表示该 target 想自定义一些用于适配的参数, 从而改变最终的适配效果\n        if (target instanceof CustomAdapt) {\n            AutoSizeLog.d(String.format(Locale.ENGLISH, \"%s implemented by %s!\", target.getClass().getName(), CustomAdapt.class.getName()));\n            AutoSize.autoConvertDensityOfCustomAdapt(activity, (CustomAdapt) target);\n        } else {\n            AutoSizeLog.d(String.format(Locale.ENGLISH, \"%s used the global configuration.\", target.getClass().getName()));\n            AutoSize.autoConvertDensityOfGlobal(activity);\n        }\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/DisplayMetricsInfo.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize;\n\nimport android.os.Parcel;\nimport android.os.Parcelable;\nimport android.util.DisplayMetrics;\n\n/**\n * ================================================\n * {@link DisplayMetrics} 封装类\n * <p>\n * Created by JessYan on 2018/8/11 16:42\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class DisplayMetricsInfo implements Parcelable {\n    private float density;\n    private int densityDpi;\n    private float scaledDensity;\n    private float xdpi;\n    private int screenWidthDp;\n    private int screenHeightDp;\n\n    public DisplayMetricsInfo(float density, int densityDpi, float scaledDensity, float xdpi) {\n        this.density = density;\n        this.densityDpi = densityDpi;\n        this.scaledDensity = scaledDensity;\n        this.xdpi = xdpi;\n    }\n\n    public DisplayMetricsInfo(float density, int densityDpi, float scaledDensity, float xdpi, int screenWidthDp, int screenHeightDp) {\n        this.density = density;\n        this.densityDpi = densityDpi;\n        this.scaledDensity = scaledDensity;\n        this.xdpi = xdpi;\n        this.screenWidthDp = screenWidthDp;\n        this.screenHeightDp = screenHeightDp;\n    }\n\n    public float getDensity() {\n        return density;\n    }\n\n    public void setDensity(float density) {\n        this.density = density;\n    }\n\n    public int getDensityDpi() {\n        return densityDpi;\n    }\n\n    public void setDensityDpi(int densityDpi) {\n        this.densityDpi = densityDpi;\n    }\n\n    public float getScaledDensity() {\n        return scaledDensity;\n    }\n\n    public void setScaledDensity(float scaledDensity) {\n        this.scaledDensity = scaledDensity;\n    }\n\n    public float getXdpi() {\n        return xdpi;\n    }\n\n    public void setXdpi(float xdpi) {\n        this.xdpi = xdpi;\n    }\n\n    public int getScreenWidthDp() {\n        return screenWidthDp;\n    }\n\n    public void setScreenWidthDp(int screenWidthDp) {\n        this.screenWidthDp = screenWidthDp;\n    }\n\n    public int getScreenHeightDp() {\n        return screenHeightDp;\n    }\n\n    public void setScreenHeightDp(int screenHeightDp) {\n        this.screenHeightDp = screenHeightDp;\n    }\n\n    @Override\n    public int describeContents() {\n        return 0;\n    }\n\n    @Override\n    public void writeToParcel(Parcel dest, int flags) {\n        dest.writeFloat(this.density);\n        dest.writeInt(this.densityDpi);\n        dest.writeFloat(this.scaledDensity);\n        dest.writeFloat(this.xdpi);\n        dest.writeInt(this.screenWidthDp);\n        dest.writeInt(this.screenHeightDp);\n    }\n\n    protected DisplayMetricsInfo(Parcel in) {\n        this.density = in.readFloat();\n        this.densityDpi = in.readInt();\n        this.scaledDensity = in.readFloat();\n        this.xdpi = in.readFloat();\n        this.screenWidthDp = in.readInt();\n        this.screenHeightDp = in.readInt();\n    }\n\n    public static final Creator<DisplayMetricsInfo> CREATOR = new Creator<DisplayMetricsInfo>() {\n        @Override\n        public DisplayMetricsInfo createFromParcel(Parcel source) {\n            return new DisplayMetricsInfo(source);\n        }\n\n        @Override\n        public DisplayMetricsInfo[] newArray(int size) {\n            return new DisplayMetricsInfo[size];\n        }\n    };\n\n    @Override\n    public String toString() {\n        return \"DisplayMetricsInfo{\" +\n                \"density=\" + density +\n                \", densityDpi=\" + densityDpi +\n                \", scaledDensity=\" + scaledDensity +\n                \", xdpi=\" + xdpi +\n                \", screenWidthDp=\" + screenWidthDp +\n                \", screenHeightDp=\" + screenHeightDp +\n                '}';\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/FragmentLifecycleCallbacksImpl.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize;\n\nimport android.os.Bundle;\nimport android.support.v4.app.Fragment;\nimport android.support.v4.app.FragmentManager;\n\n/**\n * ================================================\n * {@link FragmentLifecycleCallbacksImpl} 可用来代替在 BaseFragment 中加入适配代码的传统方式\n * {@link FragmentLifecycleCallbacksImpl} 这种方案类似于 AOP, 面向接口, 侵入性低, 方便统一管理, 扩展性强, 并且也支持适配三方库的 {@link Fragment}\n * <p>\n * Created by JessYan on 2018/8/25 13:52\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class FragmentLifecycleCallbacksImpl extends FragmentManager.FragmentLifecycleCallbacks {\n    /**\n     * 屏幕适配逻辑策略类\n     */\n    private AutoAdaptStrategy mAutoAdaptStrategy;\n\n    public FragmentLifecycleCallbacksImpl(AutoAdaptStrategy autoAdaptStrategy) {\n        mAutoAdaptStrategy = autoAdaptStrategy;\n    }\n\n    @Override\n    public void onFragmentCreated(FragmentManager fm, Fragment f, Bundle savedInstanceState) {\n        if (mAutoAdaptStrategy != null) {\n            mAutoAdaptStrategy.applyAdapt(f, f.getActivity());\n        }\n    }\n\n    /**\n     * 设置屏幕适配逻辑策略类\n     *\n     * @param autoAdaptStrategy {@link AutoAdaptStrategy}\n     */\n    public void setAutoAdaptStrategy(AutoAdaptStrategy autoAdaptStrategy) {\n        mAutoAdaptStrategy = autoAdaptStrategy;\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/FragmentLifecycleCallbacksImplToAndroidx.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize;\n\nimport android.os.Bundle;\nimport androidx.fragment.app.Fragment;\nimport androidx.fragment.app.FragmentManager;\n\n/**\n * ================================================\n * {@link FragmentLifecycleCallbacksImplToAndroidx} 可用来代替在 BaseFragment 中加入适配代码的传统方式\n * {@link FragmentLifecycleCallbacksImplToAndroidx} 这种方案类似于 AOP, 面向接口, 侵入性低, 方便统一管理, 扩展性强, 并且也支持适配三方库的 {@link Fragment}\n * <p>\n * Created by JessYan on 2018/8/25 13:52\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class FragmentLifecycleCallbacksImplToAndroidx extends FragmentManager.FragmentLifecycleCallbacks {\n    /**\n     * 屏幕适配逻辑策略类\n     */\n    private AutoAdaptStrategy mAutoAdaptStrategy;\n\n    public FragmentLifecycleCallbacksImplToAndroidx(AutoAdaptStrategy autoAdaptStrategy) {\n        mAutoAdaptStrategy = autoAdaptStrategy;\n    }\n\n    @Override\n    public void onFragmentCreated(FragmentManager fm, Fragment f, Bundle savedInstanceState) {\n        if (mAutoAdaptStrategy != null) {\n            mAutoAdaptStrategy.applyAdapt(f, f.getActivity());\n        }\n    }\n\n    /**\n     * 设置屏幕适配逻辑策略类\n     *\n     * @param autoAdaptStrategy {@link AutoAdaptStrategy}\n     */\n    public void setAutoAdaptStrategy(AutoAdaptStrategy autoAdaptStrategy) {\n        mAutoAdaptStrategy = autoAdaptStrategy;\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/InitProvider.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize;\n\nimport android.content.Context;\nimport android.app.Application;\nimport android.content.ContentProvider;\nimport android.content.ContentValues;\nimport android.database.Cursor;\nimport android.net.Uri;\n\nimport me.jessyan.autosize.utils.AutoSizeUtils;\n\n/**\n * ================================================\n * 通过声明 {@link ContentProvider} 自动完成初始化\n * Created by JessYan on 2018/8/19 11:55\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class InitProvider extends ContentProvider {\n    @Override\n    public boolean onCreate() {\n        Context application = getContext().getApplicationContext();\n        if (application == null) {\n            application = AutoSizeUtils.getApplicationByReflect();\n        }\n        AutoSizeConfig.getInstance()\n                .setLog(true)\n                .init((Application) application)\n                .setUseDeviceSize(false);\n        return true;\n    }\n\n    @Override\n    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {\n        return null;\n    }\n\n    @Override\n    public String getType(Uri uri) {\n        return null;\n    }\n\n    @Override\n    public Uri insert(Uri uri, ContentValues values) {\n        return null;\n    }\n\n    @Override\n    public int delete(Uri uri, String selection, String[] selectionArgs) {\n        return 0;\n    }\n\n    @Override\n    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {\n        return 0;\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/WrapperAutoAdaptStrategy.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize;\n\nimport android.app.Activity;\n\n/**\n * ================================================\n * {@link AutoAdaptStrategy} 的包装者, 用于给 {@link AutoAdaptStrategy} 的实现类增加一些额外的职责\n * <p>\n * Created by JessYan on 2018/10/30 15:07\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class WrapperAutoAdaptStrategy implements AutoAdaptStrategy {\n    private final AutoAdaptStrategy mAutoAdaptStrategy;\n\n    public WrapperAutoAdaptStrategy(AutoAdaptStrategy autoAdaptStrategy) {\n        mAutoAdaptStrategy = autoAdaptStrategy;\n    }\n\n    @Override\n    public void applyAdapt(Object target, Activity activity) {\n        onAdaptListener onAdaptListener = AutoSizeConfig.getInstance().getOnAdaptListener();\n        if (onAdaptListener != null){\n            onAdaptListener.onAdaptBefore(target, activity);\n        }\n        if (mAutoAdaptStrategy != null) {\n            mAutoAdaptStrategy.applyAdapt(target, activity);\n        }\n        if (onAdaptListener != null){\n            onAdaptListener.onAdaptAfter(target, activity);\n        }\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/external/ExternalAdaptInfo.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.external;\n\nimport android.app.Activity;\nimport android.os.Parcel;\nimport android.os.Parcelable;\n\n/**\n * ================================================\n * {@link ExternalAdaptInfo} 用来存储外部三方库的适配参数, 因为 AndroidAutoSize 默认会对项目中的所有模块都进行适配\n * 三方库的 {@link Activity} 也不例外, 但三方库的适配参数可能和自己项目中的适配参数不一致, 导致三方库的适配效果和理想的效果差别很大\n * 所以需要向 AndroidAutoSize 提供三方库的适配参数, 已完成对三方库的屏幕适配\n * <p>\n * Created by JessYan on 2018/8/9 18:19\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class ExternalAdaptInfo implements Parcelable {\n    /**\n     * 是否按照宽度进行等比例适配 (为了保证在高宽比不同的屏幕上也能正常适配, 所以只能在宽度和高度之中选一个作为基准进行适配)\n     * {@code true} 为按照宽度适配, {@code false} 为按照高度适配\n     */\n    private boolean isBaseOnWidth;\n    /**\n     * 设计图上的设计尺寸, 单位 dp (三方库页面的设计图尺寸可能无法获知, 所以如果想让三方库的适配效果达到最好, 只有靠不断的尝试)\n     * {@link #sizeInDp} 须配合 {@link #isBaseOnWidth} 使用, 规则如下:\n     * 如果 {@link #isBaseOnWidth} 设置为 {@code true}, {@link #sizeInDp} 则应该设置为设计图的总宽度\n     * 如果 {@link #isBaseOnWidth} 设置为 {@code false}, {@link #sizeInDp} 则应该设置为设计图的总高度\n     * 如果您不需要自定义设计图上的设计尺寸, 想继续使用在 AndroidManifest 中填写的设计图尺寸, {@link #sizeInDp} 则设置为 {@code 0}\n     */\n    private float sizeInDp;\n\n    public ExternalAdaptInfo(boolean isBaseOnWidth) {\n        this.isBaseOnWidth = isBaseOnWidth;\n    }\n\n    public ExternalAdaptInfo(boolean isBaseOnWidth, float sizeInDp) {\n        this.isBaseOnWidth = isBaseOnWidth;\n        this.sizeInDp = sizeInDp;\n    }\n\n    public boolean isBaseOnWidth() {\n        return isBaseOnWidth;\n    }\n\n    public void setBaseOnWidth(boolean baseOnWidth) {\n        isBaseOnWidth = baseOnWidth;\n    }\n\n    public float getSizeInDp() {\n        return sizeInDp;\n    }\n\n    public void setSizeInDp(float sizeInDp) {\n        this.sizeInDp = sizeInDp;\n    }\n\n    @Override\n    public int describeContents() {\n        return 0;\n    }\n\n    @Override\n    public void writeToParcel(Parcel dest, int flags) {\n        dest.writeByte(this.isBaseOnWidth ? (byte) 1 : (byte) 0);\n        dest.writeFloat(this.sizeInDp);\n    }\n\n    protected ExternalAdaptInfo(Parcel in) {\n        this.isBaseOnWidth = in.readByte() != 0;\n        this.sizeInDp = in.readFloat();\n    }\n\n    public static final Creator<ExternalAdaptInfo> CREATOR = new Creator<ExternalAdaptInfo>() {\n        @Override\n        public ExternalAdaptInfo createFromParcel(Parcel source) {\n            return new ExternalAdaptInfo(source);\n        }\n\n        @Override\n        public ExternalAdaptInfo[] newArray(int size) {\n            return new ExternalAdaptInfo[size];\n        }\n    };\n\n    @Override\n    public String toString() {\n        return \"ExternalAdaptInfo{\" +\n                \"isBaseOnWidth=\" + isBaseOnWidth +\n                \", sizeInDp=\" + sizeInDp +\n                '}';\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/external/ExternalAdaptManager.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.external;\n\nimport android.app.Activity;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport me.jessyan.autosize.AutoSizeConfig;\nimport me.jessyan.autosize.utils.Preconditions;\n\n/**\n * ================================================\n * 管理三方库的适配信息和状态, 通过 {@link AutoSizeConfig#getExternalAdaptManager()} 获取, 切勿自己 new\n * AndroidAutoSize 通过实现接口的方式来让每个 {@link Activity} 都具有自定义适配参数的功能, 从而让每个 {@link Activity} 都可以自定义适配效果\n * 但通过远程依赖的三方库并不能修改源码, 所以也不能让三方库的 {@link Activity} 实现接口, 实现接口的方式就显得无能为力\n * {@link ExternalAdaptManager} 就是专门用来处理这个问题, 项目初始化时把对应的三方库 {@link Activity} 传入 {@link ExternalAdaptManager} 即可\n * <p>\n * Created by JessYan on 2018/8/10 14:40\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class ExternalAdaptManager {\n    private List<String> mCancelAdaptList;\n    private Map<String, ExternalAdaptInfo> mExternalAdaptInfos;\n    private boolean isRun;\n\n    /**\n     * 将不需要适配的第三方库 {@link Activity} 添加进来 (但不局限于三方库), 即可让该 {@link Activity} 的适配效果失效\n     * <p>\n     * 支持链式调用, 如:\n     * {@link ExternalAdaptManager#addCancelAdaptOfActivity(Class)#addCancelAdaptOfActivity(Class)}\n     *\n     * @param targetClass {@link Activity} class, Fragment class\n     */\n    public synchronized ExternalAdaptManager addCancelAdaptOfActivity(Class<?> targetClass) {\n        Preconditions.checkNotNull(targetClass, \"targetClass == null\");\n        if (!isRun) {\n            isRun = true;\n        }\n        if (mCancelAdaptList == null) {\n            mCancelAdaptList = new ArrayList<>();\n        }\n        mCancelAdaptList.add(targetClass.getCanonicalName());\n        return this;\n    }\n\n    /**\n     * 将需要提供自定义适配参数的三方库 {@link Activity} 添加进来 (但不局限于三方库), 即可让该 {@link Activity} 根据自己提供的适配参数进行适配\n     * 默认的全局适配参数不能满足您时可以使用此方法\n     * <p>\n     * 一般用于三方库的 Activity, 因为三方库的设计图尺寸可能和项目自身的设计图尺寸不一致, 所以要想完美适配三方库的页面\n     * 就需要提供三方库的设计图尺寸, 以及适配的方向 (以宽为基准还是高为基准?)\n     * 三方库页面的设计图尺寸可能无法获知, 所以如果想让三方库的适配效果达到最好, 只有靠不断的尝试\n     * 由于 AndroidAutoSize 可以让布局在所有设备上都等比例缩放, 所以只要您在一个设备上测试出了一个最完美的设计图尺寸\n     * 那这个三方库页面在其他设备上也会呈现出同样的适配效果, 等比例缩放, 所以也就完成了三方库页面的屏幕适配\n     * 即使在不改三方库源码的情况下也可以完美适配三方库的页面, 这就是 AndroidAutoSize 的优势\n     * 但前提是三方库页面的布局使用的是 dp 和 sp, 如果布局全部使用的 px, 那 AndroidAutoSize 也将无能为力\n     * <p>\n     * 支持链式调用, 如:\n     * {@link ExternalAdaptManager#addExternalAdaptInfoOfActivity(Class, ExternalAdaptInfo)#addExternalAdaptInfoOfActivity(Class, ExternalAdaptInfo)}\n     *\n     * @param targetClass {@link Activity} class, Fragment class\n     * @param info        {@link ExternalAdaptInfo} 适配参数\n     */\n    public synchronized ExternalAdaptManager addExternalAdaptInfoOfActivity(Class<?> targetClass, ExternalAdaptInfo info) {\n        Preconditions.checkNotNull(targetClass, \"targetClass == null\");\n        if (!isRun) {\n            isRun = true;\n        }\n        if (mExternalAdaptInfos == null) {\n            mExternalAdaptInfos = new HashMap<>(16);\n        }\n        mExternalAdaptInfos.put(targetClass.getCanonicalName(), info);\n        return this;\n    }\n\n    /**\n     * 这个 {@link Activity} 是否存在在取消适配的列表中, 如果在, 则该 {@link Activity} 适配失效\n     *\n     * @param targetClass {@link Activity} class, Fragment class\n     * @return {@code true} 为存在, {@code false} 为不存在\n     */\n    public synchronized boolean isCancelAdapt(Class<?> targetClass) {\n        Preconditions.checkNotNull(targetClass, \"targetClass == null\");\n        if (mCancelAdaptList == null) {\n            return false;\n        }\n        return mCancelAdaptList.contains(targetClass.getCanonicalName());\n    }\n\n    /**\n     * 这个 {@link Activity} 是否提供有自定义的适配参数, 如果有则使用此适配参数进行适配\n     *\n     * @param targetClass {@link Activity} class, Fragment class\n     * @return 如果返回 {@code null} 则说明该 {@link Activity} 没有提供自定义的适配参数\n     */\n    public synchronized ExternalAdaptInfo getExternalAdaptInfoOfActivity(Class<?> targetClass) {\n        Preconditions.checkNotNull(targetClass, \"targetClass == null\");\n        if (mExternalAdaptInfos == null) {\n            return null;\n        }\n        return mExternalAdaptInfos.get(targetClass.getCanonicalName());\n    }\n\n    /**\n     * 此管理器是否已经启动\n     *\n     * @return {@code true} 为已经启动, {@code false} 为没有启动\n     */\n    public boolean isRun() {\n        return isRun;\n    }\n\n    /**\n     * 设置管理器的运行状态\n     *\n     * @param run {@code true} 为让管理器启动运行, {@code false} 为让管理器停止运行\n     */\n    public ExternalAdaptManager setRun(boolean run) {\n        isRun = run;\n        return this;\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/internal/CancelAdapt.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.internal;\n\nimport android.app.Activity;\n\n/**\n * ================================================\n * AndroidAutoSize 默认项目中的所有模块都使用适配功能, 三方库的 {@link Activity} 也不例外\n * 如果某个页面不想使用适配功能, 请让该页面 {@link Activity} 实现此接口\n * 实现此接口表示放弃适配, 所有的适配效果都将失效\n * <p>\n * Created by JessYan on 2018/8/9 09:54\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic interface CancelAdapt {\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/internal/CustomAdapt.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.internal;\n\nimport android.app.Activity;\n\n/**\n * ================================================\n * 如果某些页面不想使用 AndroidAutoSize 初始化时设置的默认适配参数, 请让该页面 {@link Activity} 实现此接口\n * 实现此接口即可自定义用于适配的一些参数, 从而影响最终的适配效果\n * <p>\n * Created by JessYan on 2018/8/9 10:25\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic interface CustomAdapt {\n\n    /**\n     * 是否按照宽度进行等比例适配 (为了保证在高宽比不同的屏幕上也能正常适配, 所以只能在宽度和高度之中选一个作为基准进行适配)\n     *\n     * @return {@code true} 为按照宽度适配, {@code false} 为按照高度适配\n     */\n    boolean isBaseOnWidth();\n\n    /**\n     * 返回设计图上的设计尺寸, 单位 dp\n     * {@link #getSizeInDp} 须配合 {@link #isBaseOnWidth()} 使用, 规则如下:\n     * 如果 {@link #isBaseOnWidth()} 返回 {@code true}, {@link #getSizeInDp} 则应该返回设计图的总宽度\n     * 如果 {@link #isBaseOnWidth()} 返回 {@code false}, {@link #getSizeInDp} 则应该返回设计图的总高度\n     * 如果您不需要自定义设计图上的设计尺寸, 想继续使用在 AndroidManifest 中填写的设计图尺寸, {@link #getSizeInDp} 则返回 {@code 0}\n     *\n     * @return 设计图上的设计尺寸, 单位 dp\n     */\n    float getSizeInDp();\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/onAdaptListener.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize;\n\nimport android.app.Activity;\n\n/**\n * ================================================\n * 屏幕适配监听器，用于监听屏幕适配时的一些事件\n * <p>\n * Created by JessYan on 2018/10/30 16:29\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic interface onAdaptListener {\n    /**\n     * 在屏幕适配前调用\n     *\n     * @param target   需要屏幕适配的对象 (可能是 {@link Activity} 或者 Fragment)\n     * @param activity 当前 {@link Activity}\n     */\n    void onAdaptBefore(Object target, Activity activity);\n\n    /**\n     * 在屏幕适配后调用\n     *\n     * @param target   需要屏幕适配的对象 (可能是 {@link Activity} 或者 Fragment)\n     * @param activity 当前 {@link Activity}\n     */\n    void onAdaptAfter(Object target, Activity activity);\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/unit/Subunits.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.unit;\n\nimport android.util.DisplayMetrics;\n\n/**\n * ================================================\n * AndroidAutoSize 支持一些在 Android 系统上比较少见的单位作为副单位, 用于规避修改 {@link DisplayMetrics#density}\n * 所造成的对于其他使用 dp 布局的系统控件或三方库控件的不良影响\n * <p>\n * Created by JessYan on 2018/8/28 10:27\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic enum Subunits {\n    /**\n     * 不使用副单位\n     */\n    NONE,\n    /**\n     * 单位 pt\n     *\n     * @see android.util.TypedValue#COMPLEX_UNIT_PT\n     */\n    PT,\n    /**\n     * 单位 in\n     *\n     * @see android.util.TypedValue#COMPLEX_UNIT_IN\n     */\n    IN,\n    /**\n     * 单位 mm\n     *\n     * @see android.util.TypedValue#COMPLEX_UNIT_MM\n     */\n    MM\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/unit/UnitsManager.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.unit;\n\nimport android.util.DisplayMetrics;\n\nimport me.jessyan.autosize.utils.Preconditions;\n\n/**\n * ================================================\n * 管理 AndroidAutoSize 支持的所有单位, AndroidAutoSize 支持五种单位 (dp、sp、pt、in、mm)\n * 其中 dp、sp 这两个是比较常见的单位, 作为 AndroidAutoSize 的主单位, 默认被 AndroidAutoSize 支持\n * pt、in、mm 这三个是比较少见的单位, 只可以选择其中的一个, 作为 AndroidAutoSize 的副单位, 与 dp、sp 一起被 AndroidAutoSize 支持\n * 副单位是用于规避修改 {@link DisplayMetrics#density} 所造成的对于其他使用 dp 布局的系统控件或三方库控件的不良影响\n * 您选择什么单位, 就在 layout 文件中用什么单位布局\n * <p>\n * 两个主单位和一个副单位, 可以随时使用下面的方法关闭和重新开启对它们的支持\n * 如果您想完全规避修改 {@link DisplayMetrics#density} 所造成的对于其他使用 dp 布局的系统控件或三方库控件的不良影响\n * 那请调用 {@link #setSupportDP}、{@link #setSupportSP} 都设置为 {@code false}, 停止对两个主单位的支持 (如果开启 sp, 对其他三方库控件影响不大, 也可以不关闭对 sp 的支持)\n * 并调用 {@link #setSupportSubunits} 从三个冷门单位中选择一个作为副单位 (三个单位的效果都是一样的, 按自己的喜好选择, 比如我就喜欢 mm, 翻译为中文是妹妹的意思)\n * 然后在 layout 文件中只使用这个副单位进行布局, 这样就可以完全规避修改 {@link DisplayMetrics#density} 所造成的问题\n * 因为 dp、sp 这两个单位在其他系统控件或三方库控件中都非常常见, 但三个冷门单位却非常少见\n * <p>\n * Created by JessYan on 2018/8/28 10:21\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class UnitsManager {\n    /**\n     * 设计图上的总宽度, 建议单位为 px, 当使用者想将旧项目从主单位过渡到副单位, 或从副单位过渡到主单位时使用\n     * 因为在使用主单位时, 建议在 AndroidManifest 中填写设计图的 dp 尺寸, 比如 360 * 640\n     * 而副单位有一个特性是可以直接在 AndroidManifest 中填写设计图的 px 尺寸, 比如 1080 * 1920\n     * 但在 AndroidManifest 中却只能填写一套设计图尺寸, 并且已经填写了主单位的设计图尺寸\n     * 所以当项目中同时存在副单位和主单位, 并且副单位的设计图尺寸与主单位的设计图尺寸不同时, 就需要在 {@link UnitsManager} 中保存副单位的设计图尺寸\n     */\n    private float mDesignWidth;\n    /**\n     * 设计图上的总高度, 建议单位为 px, 当使用者想将旧项目从主单位过渡到副单位, 或从副单位过渡到主单位时使用\n     * 因为在使用主单位时, 建议在 AndroidManifest 中填写设计图的 dp 尺寸, 比如 360 * 640\n     * 而副单位有一个特性是可以直接在 AndroidManifest 中填写设计图的 px 尺寸, 比如 1080 * 1920\n     * 但在 AndroidManifest 中却只能填写一套设计图尺寸, 并且已经填写了主单位的设计图尺寸\n     * 所以当项目中同时存在副单位和主单位, 并且副单位的设计图尺寸与主单位的设计图尺寸不同时, 就需要在 {@link UnitsManager} 中保存副单位的设计图尺寸\n     */\n    private float mDesignHeight;\n    /**\n     * 是否支持 dp 单位, 默认支持\n     */\n    private boolean isSupportDP = true;\n    /**\n     * 是否支持 sp 单位, 默认支持\n     */\n    private boolean isSupportSP = true;\n    /**\n     * 是否支持副单位, 以什么为副单位? 默认不支持\n     */\n    private Subunits mSupportSubunits = Subunits.NONE;\n    /**\n     * 是否支持 ScreenSizeDp 修改, 默认不支持\n     */\n    private boolean isSupportScreenSizeDP = false;\n\n    /**\n     * 设置设计图尺寸\n     *\n     * @param designWidth  设计图上的总宽度, 建议单位为 px\n     * @param designHeight 设计图上的总高度, 建议单位为 px\n     * @return {@link UnitsManager}\n     * @see #mDesignWidth 详情请查看这个字段的注释\n     * @see #mDesignHeight 详情请查看这个字段的注释\n     */\n    public UnitsManager setDesignSize(float designWidth, float designHeight) {\n        setDesignWidth(designWidth);\n        setDesignHeight(designHeight);\n        return this;\n    }\n\n    /**\n     * 返回 {@link #mDesignWidth}\n     *\n     * @return {@link #mDesignWidth}\n     */\n    public float getDesignWidth() {\n        return mDesignWidth;\n    }\n\n    /**\n     * 设置设计图上的总宽度, 建议单位为 px\n     *\n     * @param designWidth 设计图上的总宽度, 建议单位为 px\n     * @return {@link UnitsManager}\n     * @see #mDesignWidth 详情请查看这个字段的注释\n     */\n    public UnitsManager setDesignWidth(float designWidth) {\n        Preconditions.checkArgument(designWidth > 0, \"designWidth must be > 0\");\n        mDesignWidth = designWidth;\n        return this;\n    }\n\n    /**\n     * 返回 {@link #mDesignHeight}\n     *\n     * @return {@link #mDesignHeight}\n     */\n    public float getDesignHeight() {\n        return mDesignHeight;\n    }\n\n    /**\n     * 设置设计图上的总高度, 建议单位为 px\n     *\n     * @param designHeight 设计图上的总高度, 建议单位为 px\n     * @return {@link UnitsManager}\n     * @see #mDesignHeight 详情请查看这个字段的注释\n     */\n    public UnitsManager setDesignHeight(float designHeight) {\n        Preconditions.checkArgument(designHeight > 0, \"designHeight must be > 0\");\n        mDesignHeight = designHeight;\n        return this;\n    }\n\n    /**\n     * 是否支持 dp 单位, 默认支持, 详情请看类文件的注释 {@link UnitsManager}\n     *\n     * @return {@code true} 为支持, {@code false} 为不支持\n     */\n    public boolean isSupportDP() {\n        return isSupportDP;\n    }\n\n    /**\n     * 是否让 AndroidAutoSize 支持 dp 单位, 默认支持, 详情请看类文件的注释 {@link UnitsManager}\n     *\n     * @param supportDP {@code true} 为支持, {@code false} 为不支持\n     */\n    public UnitsManager setSupportDP(boolean supportDP) {\n        isSupportDP = supportDP;\n        return this;\n    }\n\n    /**\n     * 是否支持 sp 单位, 默认支持, 详情请看类文件的注释 {@link UnitsManager}\n     *\n     * @return {@code true} 为支持, {@code false} 为不支持\n     */\n    public boolean isSupportSP() {\n        return isSupportSP;\n    }\n\n    /**\n     * 是否让 AndroidAutoSize 支持 sp 单位, 默认支持, 详情请看类文件的注释 {@link UnitsManager}\n     *\n     * @param supportSP {@code true} 为支持, {@code false} 为不支持\n     */\n    public UnitsManager setSupportSP(boolean supportSP) {\n        isSupportSP = supportSP;\n        return this;\n    }\n\n    /**\n     * AndroidAutoSize 以什么单位为副单位, 默认为 {@link Subunits#NONE}, 即不支持副单位, 详情请看类文件的注释 {@link UnitsManager}\n     *\n     * @return {@link Subunits}\n     */\n    public Subunits getSupportSubunits() {\n        return mSupportSubunits;\n    }\n\n    /**\n     * 是否支持 ScreenSizeDp 修改, 默认不支持, 详情请看类文件的注释 {@link UnitsManager}\n     *\n     * @return {@code true} 为支持, {@code false} 为不支持\n     */\n    public boolean isSupportScreenSizeDP() {\n        return isSupportScreenSizeDP;\n    }\n\n    /**\n     * 是否让 AndroidAutoSize 支持 ScreenSizeDp 修改, 默认不支持, 详情请看类文件的注释 {@link UnitsManager}\n     *\n     * @param supportScreenSizeDP {@code true} 为支持, {@code false} 为不支持\n     */\n    public UnitsManager setSupportScreenSizeDP(boolean supportScreenSizeDP) {\n        isSupportScreenSizeDP = supportScreenSizeDP;\n        return this;\n    }\n\n    /**\n     * 让 AndroidAutoSize 以什么单位为副单位, 在 pt、in、mm 这三个冷门单位中选择一个即可, 三个效果都是一样的\n     * 按自己的喜好选择, 比如我就喜欢 mm, 翻译为中文是妹妹的意思\n     * 默认为 {@link Subunits#NONE}, 即不支持副单位, 详情请看类文件的注释 {@link UnitsManager}\n     *\n     * @param supportSubunits {@link Subunits}\n     */\n    public UnitsManager setSupportSubunits(Subunits supportSubunits) {\n        mSupportSubunits = Preconditions.checkNotNull(supportSubunits,\n                \"The supportSubunits can not be null, use Subunits.NONE instead\");\n        return this;\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/utils/AutoSizeLog.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.utils;\n\nimport android.util.Log;\n\n/**\n * ================================================\n * Created by JessYan on 2018/8/8 18:48\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class AutoSizeLog {\n    private static final String TAG = \"AndroidAutoSize\";\n    private static boolean debug;\n\n    private AutoSizeLog() {\n        throw new IllegalStateException(\"you can't instantiate me!\");\n    }\n\n    public static boolean isDebug() {\n        return debug;\n    }\n\n    public static void setDebug(boolean debug) {\n        AutoSizeLog.debug = debug;\n    }\n\n    public static void d(String message) {\n        if (debug) {\n            Log.d(TAG, message);\n        }\n    }\n\n    public static void w(String message) {\n        if (debug) {\n            Log.w(TAG, message);\n        }\n    }\n\n    public static void e(String message) {\n        if (debug) {\n            Log.e(TAG, message);\n        }\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/utils/AutoSizeUtils.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.utils;\n\nimport android.annotation.SuppressLint;\nimport android.content.Context;\nimport android.util.TypedValue;\nimport android.app.Application;\n\nimport java.lang.reflect.InvocationTargetException;\n\n/**\n * ================================================\n * AndroidAutoSize 常用工具类\n * <p>\n * Created by JessYan on 2018/8/25 15:24\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class AutoSizeUtils {\n\n    private AutoSizeUtils() {\n        throw new IllegalStateException(\"you can't instantiate me!\");\n    }\n\n    public static int dp2px(Context context, float value) {\n        return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, context.getResources().getDisplayMetrics()) + 0.5f);\n    }\n\n    public static int sp2px(Context context, float value) {\n        return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, value, context.getResources().getDisplayMetrics()) + 0.5f);\n    }\n\n    public static int pt2px(Context context, float value) {\n        return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PT, value, context.getResources().getDisplayMetrics()) + 0.5f);\n    }\n\n    public static int in2px(Context context, float value) {\n        return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_IN, value, context.getResources().getDisplayMetrics()) + 0.5f);\n    }\n\n    public static int mm2px(Context context, float value) {\n        return (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, value, context.getResources().getDisplayMetrics()) + 0.5f);\n    }\n    \n    public static Application getApplicationByReflect() {\n        try {\n            @SuppressLint(\"PrivateApi\")\n            Class<?> activityThread = Class.forName(\"android.app.ActivityThread\");\n            Object thread = activityThread.getMethod(\"currentActivityThread\").invoke(null);\n            Object app = activityThread.getMethod(\"getApplication\").invoke(thread);\n            if (app == null) {\n                throw new NullPointerException(\"you should init first\");\n            }\n            return (Application) app;\n        } catch (NoSuchMethodException e) {\n            e.printStackTrace();\n        } catch (IllegalAccessException e) {\n            e.printStackTrace();\n        } catch (InvocationTargetException e) {\n            e.printStackTrace();\n        } catch (ClassNotFoundException e) {\n            e.printStackTrace();\n        }\n        throw new NullPointerException(\"you should init first\");\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/utils/Preconditions.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.utils;\n\nimport android.os.Looper;\n\n/**\n * ================================================\n * Created by JessYan on 26/09/2016 13:59\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic final class Preconditions {\n\n    private Preconditions() {\n        throw new IllegalStateException(\"you can't instantiate me!\");\n    }\n\n    public static void checkArgument(boolean expression) {\n        if (!expression) {\n            throw new IllegalArgumentException();\n        }\n    }\n\n    public static void checkArgument(boolean expression, Object errorMessage) {\n        if (!expression) {\n            throw new IllegalArgumentException(String.valueOf(errorMessage));\n        }\n    }\n\n    public static void checkArgument(boolean expression, String errorMessageTemplate, Object... errorMessageArgs) {\n        if (!expression) {\n            throw new IllegalArgumentException(format(errorMessageTemplate, errorMessageArgs));\n        }\n    }\n\n    public static void checkState(boolean expression) {\n        if (!expression) {\n            throw new IllegalStateException();\n        }\n    }\n\n    public static void checkState(boolean expression, Object errorMessage) {\n        if (!expression) {\n            throw new IllegalStateException(String.valueOf(errorMessage));\n        }\n    }\n\n    public static void checkState(boolean expression, String errorMessageTemplate, Object... errorMessageArgs) {\n        if (!expression) {\n            throw new IllegalStateException(format(errorMessageTemplate, errorMessageArgs));\n        }\n    }\n\n    public static <T> T checkNotNull(T reference) {\n        if (reference == null) {\n            throw new NullPointerException();\n        } else {\n            return reference;\n        }\n    }\n\n    public static <T> T checkNotNull(T reference, Object errorMessage) {\n        if (reference == null) {\n            throw new NullPointerException(String.valueOf(errorMessage));\n        } else {\n            return reference;\n        }\n    }\n\n    public static <T> T checkNotNull(T reference, String errorMessageTemplate, Object... errorMessageArgs) {\n        if (reference == null) {\n            throw new NullPointerException(format(errorMessageTemplate, errorMessageArgs));\n        } else {\n            return reference;\n        }\n    }\n\n    public static int checkElementIndex(int index, int size) {\n        return checkElementIndex(index, size, \"index\");\n    }\n\n    public static int checkElementIndex(int index, int size, String desc) {\n        if (index >= 0 && index < size) {\n            return index;\n        } else {\n            throw new IndexOutOfBoundsException(badElementIndex(index, size, desc));\n        }\n    }\n\n    /**\n     * Throws {@link IllegalStateException} if the calling thread is not the application's main\n     * thread.\n     *\n     * @throws IllegalStateException If the calling thread is not the application's main thread.\n     */\n    public static void checkMainThread() {\n        if (Looper.myLooper() != Looper.getMainLooper()) {\n            throw new IllegalStateException(\"Not in applications main thread\");\n        }\n    }\n\n    private static String badElementIndex(int index, int size, String desc) {\n        if (index < 0) {\n            return format(\"%s (%s) must not be negative\", new Object[]{desc, Integer.valueOf(index)});\n        } else if (size < 0) {\n            throw new IllegalArgumentException((new StringBuilder(26)).append(\"negative size: \").append(size).toString());\n        } else {\n            return format(\"%s (%s) must be less than size (%s)\", new Object[]{desc, Integer.valueOf(index), Integer.valueOf(size)});\n        }\n    }\n\n    public static int checkPositionIndex(int index, int size) {\n        return checkPositionIndex(index, size, \"index\");\n    }\n\n    public static int checkPositionIndex(int index, int size, String desc) {\n        if (index >= 0 && index <= size) {\n            return index;\n        } else {\n            throw new IndexOutOfBoundsException(badPositionIndex(index, size, desc));\n        }\n    }\n\n    private static String badPositionIndex(int index, int size, String desc) {\n        if (index < 0) {\n            return format(\"%s (%s) must not be negative\", new Object[]{desc, Integer.valueOf(index)});\n        } else if (size < 0) {\n            throw new IllegalArgumentException((new StringBuilder(26)).append(\"negative size: \").append(size).toString());\n        } else {\n            return format(\"%s (%s) must not be greater than size (%s)\", new Object[]{desc, Integer.valueOf(index), Integer.valueOf(size)});\n        }\n    }\n\n    public static void checkPositionIndexes(int start, int end, int size) {\n        if (start < 0 || end < start || end > size) {\n            throw new IndexOutOfBoundsException(badPositionIndexes(start, end, size));\n        }\n    }\n\n    private static String badPositionIndexes(int start, int end, int size) {\n        return start >= 0 && start <= size ? (end >= 0 && end <= size ? format(\"end index (%s) must not be less than start index (%s)\", new Object[]{Integer.valueOf(end), Integer.valueOf(start)}) : badPositionIndex(end, size, \"end index\")) : badPositionIndex(start, size, \"start index\");\n    }\n\n    static String format(String template, Object... args) {\n        template = String.valueOf(template);\n        StringBuilder builder = new StringBuilder(template.length() + 16 * args.length);\n        int templateStart = 0;\n\n        int i;\n        int placeholderStart;\n        for (i = 0; i < args.length; templateStart = placeholderStart + 2) {\n            placeholderStart = template.indexOf(\"%s\", templateStart);\n            if (placeholderStart == -1) {\n                break;\n            }\n\n            builder.append(template.substring(templateStart, placeholderStart));\n            builder.append(args[i++]);\n        }\n\n        builder.append(template.substring(templateStart));\n        if (i < args.length) {\n            builder.append(\" [\");\n            builder.append(args[i++]);\n\n            while (i < args.length) {\n                builder.append(\", \");\n                builder.append(args[i++]);\n            }\n\n            builder.append(']');\n        }\n\n        return builder.toString();\n    }\n}\n"
  },
  {
    "path": "autosize/src/main/java/me/jessyan/autosize/utils/ScreenUtils.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.utils;\n\nimport android.content.Context;\nimport android.content.res.Resources;\nimport android.graphics.Point;\nimport android.os.Build;\nimport android.provider.Settings;\nimport android.util.DisplayMetrics;\nimport android.view.Display;\nimport android.view.WindowManager;\n\n/**\n * ================================================\n * Created by JessYan on 26/09/2016 16:59\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class ScreenUtils {\n\n    private ScreenUtils() {\n        throw new IllegalStateException(\"you can't instantiate me!\");\n    }\n\n    public static int getStatusBarHeight() {\n        int result = 0;\n        try {\n            int resourceId = Resources.getSystem().getIdentifier(\"status_bar_height\", \"dimen\", \"android\");\n            if (resourceId > 0) {\n                result = Resources.getSystem().getDimensionPixelSize(resourceId);\n            }\n        } catch (Resources.NotFoundException e) {\n            e.printStackTrace();\n        }\n        return result;\n    }\n\n    /**\n     * 获取当前的屏幕尺寸\n     *\n     * @param context {@link Context}\n     * @return 屏幕尺寸\n     */\n    public static int[] getScreenSize(Context context) {\n        int[] size = new int[2];\n\n        WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);\n        Display d = w.getDefaultDisplay();\n        DisplayMetrics metrics = new DisplayMetrics();\n        d.getMetrics(metrics);\n\n        size[0] = metrics.widthPixels;\n        size[1] = metrics.heightPixels;\n        return size;\n    }\n\n    /**\n     * 获取原始的屏幕尺寸\n     *\n     * @param context {@link Context}\n     * @return 屏幕尺寸\n     */\n    public static int[] getRawScreenSize(Context context) {\n        int[] size = new int[2];\n\n        WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);\n        Display d = w.getDefaultDisplay();\n        DisplayMetrics metrics = new DisplayMetrics();\n        d.getMetrics(metrics);\n        // since SDK_INT = 1;\n        int widthPixels = metrics.widthPixels;\n        int heightPixels = metrics.heightPixels;\n\n        // includes window decorations (statusbar bar/menu bar)\n        if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17)\n            try {\n                widthPixels = (Integer) Display.class.getMethod(\"getRawWidth\").invoke(d);\n                heightPixels = (Integer) Display.class.getMethod(\"getRawHeight\").invoke(d);\n            } catch (Exception ignored) {\n            }\n        // includes window decorations (statusbar bar/menu bar)\n        if (Build.VERSION.SDK_INT >= 17)\n            try {\n                Point realSize = new Point();\n                Display.class.getMethod(\"getRealSize\", Point.class).invoke(d, realSize);\n                widthPixels = realSize.x;\n                heightPixels = realSize.y;\n            } catch (Exception ignored) {\n            }\n        size[0] = widthPixels;\n        size[1] = heightPixels;\n        return size;\n    }\n\n    public static int getHeightOfNavigationBar(Context context) {\n        //如果小米手机开启了全面屏手势隐藏了导航栏则返回 0\n        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {\n            if (Settings.Global.getInt(context.getContentResolver(), \"force_fsg_nav_bar\", 0) != 0) {\n                return 0;\n            }\n        }\n\n        int realHeight = getRawScreenSize(context)[1];\n        int displayHeight = getScreenSize(context)[1];\n        return realHeight - displayHeight;\n    }\n}\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        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}\n        jcenter()\n        google()\n    }\n    dependencies {\n        classpath 'com.android.tools.build:gradle:3.5.3'\n        classpath 'com.novoda:bintray-release:0.9.2'\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        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}\n        jcenter()\n        google()\n    }\n}\n\ntask clean(type: Delete) {\n    delete rootProject.buildDir\n}\n\next {\n    minSdkVersion = 14\n    targetSdkVersion = 29\n    compileSdkVersion = 29\n    buildToolsVersion = \"29.0.2\"\n    versionCode = 41\n    versionName = \"1.2.1\"\n    appcompat_v7 = \"com.android.support:appcompat-v7:28.0.0\"\n    androidx_appcompat = \"androidx.appcompat:appcompat:1.1.0\"\n}"
  },
  {
    "path": "demo/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "demo/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion rootProject.compileSdkVersion\n    buildToolsVersion rootProject.buildToolsVersion\n\n    defaultConfig {\n        applicationId \"me.jessyan.autosize.demo\"\n        minSdkVersion rootProject.minSdkVersion\n        targetSdkVersion rootProject.targetSdkVersion\n        versionCode rootProject.versionCode\n        versionName rootProject.versionName\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n//    implementation 'me.jessyan:autosize:1.2.1'\n    implementation project(':autosize')\n    implementation rootProject.appcompat_v7\n    implementation 'cat.ereza:customactivityoncrash:2.2.0'\n    testImplementation 'junit:junit:4.12'\n}\n"
  },
  {
    "path": "demo/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "demo/src/androidTest/java/me/jessyan/autosize/demo/ExampleInstrumentedTest.java",
    "content": "package me.jessyan.autosize.demo;\n\nimport android.content.Context;\nimport android.support.test.InstrumentationRegistry;\nimport android.support.test.runner.AndroidJUnit4;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport static org.junit.Assert.*;\n\n/**\n * Instrumented test, which will execute on an Android device.\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\n@RunWith(AndroidJUnit4.class)\npublic class ExampleInstrumentedTest {\n    @Test\n    public void useAppContext() {\n        // Context of the app under test.\n        Context appContext = InstrumentationRegistry.getTargetContext();\n\n        assertEquals(\"me.jessyan.autosize.demo\", appContext.getPackageName());\n    }\n}\n"
  },
  {
    "path": "demo/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n          package=\"me.jessyan.autosize.demo\">\n\n    <application\n        android:name=\"me.jessyan.autosize.demo.BaseApplication\"\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/autosize_logo\"\n        android:label=\"@string/app_name\"\n        android:supportsRtl=\"true\"\n        android:theme=\"@style/AppTheme\">\n        <activity android:name=\"me.jessyan.autosize.demo.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        <activity android:name=\"me.jessyan.autosize.demo.CustomAdaptActivity\"/>\n        <activity android:name=\"me.jessyan.autosize.demo.FragmentHost\"/>\n\n        <!-- 如果您项目中的所有页面都只需要以高或宽中的一个作为基准进行适配的话, 那就只需要填写高或宽中的一个设计图尺寸即可 -->\n        <meta-data\n            android:name=\"design_width_in_dp\"\n            android:value=\"360\"/>\n        <meta-data\n            android:name=\"design_height_in_dp\"\n            android:value=\"640\"/>\n\n    </application>\n\n</manifest>"
  },
  {
    "path": "demo/src/main/java/me/jessyan/autosize/demo/BaseApplication.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo;\n\nimport android.app.Activity;\nimport android.app.Application;\nimport android.util.DisplayMetrics;\n\nimport java.util.Locale;\n\nimport cat.ereza.customactivityoncrash.activity.DefaultErrorActivity;\nimport me.jessyan.autosize.AutoSize;\nimport me.jessyan.autosize.AutoSizeConfig;\nimport me.jessyan.autosize.external.ExternalAdaptInfo;\nimport me.jessyan.autosize.external.ExternalAdaptManager;\nimport me.jessyan.autosize.internal.CustomAdapt;\nimport me.jessyan.autosize.onAdaptListener;\nimport me.jessyan.autosize.utils.AutoSizeLog;\n\n/**\n * ================================================\n * v0.9.1 发布后新增了副单位，可以在 pt、in、mm 三个冷门单位中选择一个作为副单位，然后在 layout 文件中使用副单位进行布局\n * 副单位可以规避修改 {@link DisplayMetrics#density} 所造成的对于其他使用 dp 布局的系统控件或三方库控件的不良影响\n * 使用副单位后可直接在 AndroidManifest 中填写设计图上的像素尺寸，不需要再将像素转化为 dp\n * <a href=\"https://github.com/JessYanCoding/AndroidAutoSize/blob/master/README-zh.md#preview\">点击查看在布局中的实时预览方式</a>\n * <p>\n * 本框架核心原理来自于 <a href=\"https://mp.weixin.qq.com/s/d9QCoBP6kV9VSWvVldVVwA\">今日头条官方适配方案</a>\n * <p>\n * 本框架源码的注释都很详细, 欢迎阅读学习\n * <p>\n * AndroidAutoSize 会在 APP 启动时自动完成初始化, 如果您想设置自定义参数可以在 {@link Application#onCreate()} 中设置\n * <p>\n * Created by JessYan on 2018/8/9 17:05\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class BaseApplication extends Application {\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        //当 App 中出现多进程, 并且您需要适配所有的进程, 就需要在 App 初始化时调用 initCompatMultiProcess()\n        //在 Demo 中跳转的三方库中的 DefaultErrorActivity 就是在另外一个进程中, 所以要想适配这个 Activity 就需要调用 initCompatMultiProcess()\n        AutoSize.initCompatMultiProcess(this);\n\n        //如果在某些特殊情况下出现 InitProvider 未能正常实例化, 导致 AndroidAutoSize 未能完成初始化\n        //可以主动调用 AutoSize.checkAndInit(this) 方法, 完成 AndroidAutoSize 的初始化后即可正常使用\n//        AutoSize.checkAndInit(this);\n\n//        如何控制 AndroidAutoSize 的初始化，让 AndroidAutoSize 在某些设备上不自动启动？https://github.com/JessYanCoding/AndroidAutoSize/issues/249\n\n        /**\n         * 以下是 AndroidAutoSize 可以自定义的参数, {@link AutoSizeConfig} 的每个方法的注释都写的很详细\n         * 使用前请一定记得跳进源码，查看方法的注释, 下面的注释只是简单描述!!!\n         */\n        AutoSizeConfig.getInstance()\n\n                //是否让框架支持自定义 Fragment 的适配参数, 由于这个需求是比较少见的, 所以须要使用者手动开启\n                //如果没有这个需求建议不开启\n                .setCustomFragment(true)\n\n                //是否屏蔽系统字体大小对 AndroidAutoSize 的影响, 如果为 true, App 内的字体的大小将不会跟随系统设置中字体大小的改变\n                //如果为 false, 则会跟随系统设置中字体大小的改变, 默认为 false\n//                .setExcludeFontScale(true)\n\n                //区别于系统字体大小的放大比例, AndroidAutoSize 允许 APP 内部可以独立于系统字体大小之外，独自拥有全局调节 APP 字体大小的能力\n                //当然, 在 APP 内您必须使用 sp 来作为字体的单位, 否则此功能无效, 不设置或将此值设为 0 则取消此功能\n//                .setPrivateFontScale(0.8f)\n\n                //屏幕适配监听器\n                .setOnAdaptListener(new onAdaptListener() {\n                    @Override\n                    public void onAdaptBefore(Object target, Activity activity) {\n                        //使用以下代码, 可以解决横竖屏切换时的屏幕适配问题\n                        //使用以下代码, 可支持 Android 的分屏或缩放模式, 但前提是在分屏或缩放模式下当用户改变您 App 的窗口大小时\n                        //系统会重绘当前的页面, 经测试在某些机型, 某些情况下系统不会主动重绘当前页面, 所以这时您需要自行重绘当前页面\n                        //ScreenUtils.getScreenSize(activity) 的参数一定要不要传 Application!!!\n//                        AutoSizeConfig.getInstance().setScreenWidth(ScreenUtils.getScreenSize(activity)[0]);\n//                        AutoSizeConfig.getInstance().setScreenHeight(ScreenUtils.getScreenSize(activity)[1]);\n                        AutoSizeLog.d(String.format(Locale.ENGLISH, \"%s onAdaptBefore!\", target.getClass().getName()));\n                    }\n\n                    @Override\n                    public void onAdaptAfter(Object target, Activity activity) {\n                        AutoSizeLog.d(String.format(Locale.ENGLISH, \"%s onAdaptAfter!\", target.getClass().getName()));\n                    }\n                })\n\n                //是否打印 AutoSize 的内部日志, 默认为 true, 如果您不想 AutoSize 打印日志, 则请设置为 false\n//                .setLog(false)\n\n                //是否使用设备的实际尺寸做适配, 默认为 false, 如果设置为 false, 在以屏幕高度为基准进行适配时\n                //AutoSize 会将屏幕总高度减去状态栏高度来做适配\n                //设置为 true 则使用设备的实际屏幕高度, 不会减去状态栏高度\n                //在全面屏或刘海屏幕设备中, 获取到的屏幕高度可能不包含状态栏高度, 所以在全面屏设备中不需要减去状态栏高度，所以可以 setUseDeviceSize(true)\n//                .setUseDeviceSize(true)\n\n                //是否全局按照宽度进行等比例适配, 默认为 true, 如果设置为 false, AutoSize 会全局按照高度进行适配\n//                .setBaseOnWidth(false)\n\n                 //设置屏幕适配逻辑策略类, 一般不用设置, 使用框架默认的就好\n//                .setAutoAdaptStrategy(new AutoAdaptStrategy())\n        ;\n        customAdaptForExternal();\n    }\n\n    /**\n     * 给外部的三方库 {@link Activity} 自定义适配参数, 因为三方库的 {@link Activity} 并不能通过实现\n     * {@link CustomAdapt} 接口的方式来提供自定义适配参数 (因为远程依赖改不了源码)\n     * 所以使用 {@link ExternalAdaptManager} 来替代实现接口的方式, 来提供自定义适配参数\n     */\n    private void customAdaptForExternal() {\n        /**\n         * {@link ExternalAdaptManager} 是一个管理外部三方库的适配信息和状态的管理类, 详细介绍请看 {@link ExternalAdaptManager} 的类注释\n         */\n        AutoSizeConfig.getInstance().getExternalAdaptManager()\n\n                //加入的 Activity 将会放弃屏幕适配, 一般用于三方库的 Activity, 详情请看方法注释\n                //如果不想放弃三方库页面的适配, 请用 addExternalAdaptInfoOfActivity 方法, 建议对三方库页面进行适配, 让自己的 App 更完美一点\n//                .addCancelAdaptOfActivity(DefaultErrorActivity.class)\n\n                //为指定的 Activity 提供自定义适配参数, AndroidAutoSize 将会按照提供的适配参数进行适配, 详情请看方法注释\n                //一般用于三方库的 Activity, 因为三方库的设计图尺寸可能和项目自身的设计图尺寸不一致, 所以要想完美适配三方库的页面\n                //就需要提供三方库的设计图尺寸, 以及适配的方向 (以宽为基准还是高为基准?)\n                //三方库页面的设计图尺寸可能无法获知, 所以如果想让三方库的适配效果达到最好, 只有靠不断的尝试\n                //由于 AndroidAutoSize 可以让布局在所有设备上都等比例缩放, 所以只要您在一个设备上测试出了一个最完美的设计图尺寸\n                //那这个三方库页面在其他设备上也会呈现出同样的适配效果, 等比例缩放, 所以也就完成了三方库页面的屏幕适配\n                //即使在不改三方库源码的情况下也可以完美适配三方库的页面, 这就是 AndroidAutoSize 的优势\n                //但前提是三方库页面的布局使用的是 dp 和 sp, 如果布局全部使用的 px, 那 AndroidAutoSize 也将无能为力\n                //经过测试 DefaultErrorActivity 的设计图宽度在 380dp - 400dp 显示效果都是比较舒服的\n                .addExternalAdaptInfoOfActivity(DefaultErrorActivity.class, new ExternalAdaptInfo(true, 400));\n    }\n}\n"
  },
  {
    "path": "demo/src/main/java/me/jessyan/autosize/demo/CustomAdaptActivity.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo;\n\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.support.v4.app.Fragment;\nimport android.support.v7.app.AppCompatActivity;\nimport android.view.View;\n\nimport me.jessyan.autosize.internal.CustomAdapt;\n\n/**\n * ================================================\n * 本框架核心原理来自于 <a href=\"https://mp.weixin.qq.com/s/d9QCoBP6kV9VSWvVldVVwA\">今日头条官方适配方案</a>\n * <p>\n * {@link CustomAdaptActivity} 展示项目内部的 {@link Activity} 自定义适配参数的用法, 需要实现 {@link CustomAdapt}\n * 现在 AndroidAutoSize 是全局以屏幕宽度为基准进行适配的, 并且全局的设计图尺寸为 360 * 640\n * 这里就展示怎么让 {@link CustomAdaptActivity} 单个页面, 有别于全局设置, 以屏幕高度为基准进行适配, 并且更改设计图尺寸为 iPhone 的设计图尺寸\n * 如果这个页面的设计图尺寸有别于其他页面, AndroidAutoSize 允许您改变单个页面的设计图尺寸, {@link #getSizeInDp()}\n * <p>\n * Created by JessYan on 2018/8/11 11:31\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class CustomAdaptActivity extends AppCompatActivity implements CustomAdapt {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_custom_adapt);\n    }\n\n    /**\n     * 跳转到 {@link FragmentHost}, 展示项目内部的 {@link Fragment} 自定义适配参数的用法\n     *\n     * @param view {@link View}\n     */\n    public void goCustomAdaptFragment(View view) {\n        startActivity(new Intent(getApplicationContext(), FragmentHost.class));\n    }\n\n    /**\n     * 是否按照宽度进行等比例适配 (为了保证在高宽比不同的屏幕上也能正常适配, 所以只能在宽度和高度之中选择一个作为基准进行适配)\n     *\n     * @return {@code true} 为按照宽度进行适配, {@code false} 为按照高度进行适配\n     */\n    @Override\n    public boolean isBaseOnWidth() {\n        return false;\n    }\n\n    /**\n     * 这里使用 iPhone 的设计图, iPhone 的设计图尺寸为 750px * 1334px, 高换算成 dp 为 667 (1334px / 2 = 667dp)\n     * <p>\n     * 返回设计图上的设计尺寸, 单位 dp\n     * {@link #getSizeInDp} 须配合 {@link #isBaseOnWidth()} 使用, 规则如下:\n     * 如果 {@link #isBaseOnWidth()} 返回 {@code true}, {@link #getSizeInDp} 则应该返回设计图的总宽度\n     * 如果 {@link #isBaseOnWidth()} 返回 {@code false}, {@link #getSizeInDp} 则应该返回设计图的总高度\n     * 如果您不需要自定义设计图上的设计尺寸, 想继续使用在 AndroidManifest 中填写的设计图尺寸, {@link #getSizeInDp} 则返回 {@code 0}\n     *\n     * @return 设计图上的设计尺寸, 单位 dp\n     */\n    @Override\n    public float getSizeInDp() {\n        return 667;\n    }\n}\n"
  },
  {
    "path": "demo/src/main/java/me/jessyan/autosize/demo/CustomFragment1.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo;\n\nimport android.os.Bundle;\nimport android.support.annotation.NonNull;\nimport android.support.annotation.Nullable;\nimport android.support.v4.app.Fragment;\nimport android.view.Gravity;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.widget.TextView;\n\nimport me.jessyan.autosize.AutoSize;\nimport me.jessyan.autosize.internal.CustomAdapt;\nimport me.jessyan.autosize.utils.AutoSizeUtils;\n\n/**\n * ================================================\n * Created by JessYan on 2018/8/25 14:06\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class CustomFragment1 extends Fragment implements CustomAdapt {\n\n    @Nullable\n    @Override\n    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {\n        //由于某些原因, 屏幕旋转后 Fragment 的重建, 会导致框架对 Fragment 的自定义适配参数失去效果\n        //所以如果您的 Fragment 允许屏幕旋转, 则请在 onCreateView 手动调用一次 AutoSize.autoConvertDensity()\n        //如果您的 Fragment 不允许屏幕旋转, 则可以将下面调用 AutoSize.autoConvertDensity() 的代码删除掉\n        AutoSize.autoConvertDensity(getActivity(), 1080, true);\n        return createTextView(inflater, \"Fragment-1\\nView width = 360dp\\nTotal width = 1080dp\", 0xffff0000);\n    }\n\n    @Override\n    public boolean isBaseOnWidth() {\n        return true;\n    }\n\n    @Override\n    public float getSizeInDp() {\n        return 1080;\n    }\n\n    public static View createTextView(LayoutInflater inflater, String content, int backgroundColor) {\n        TextView view = new TextView(inflater.getContext());\n        ViewGroup.LayoutParams layoutParams =\n                new ViewGroup.LayoutParams((AutoSizeUtils.dp2px(inflater.getContext(), 360)),\n                        ViewGroup.LayoutParams.MATCH_PARENT);\n        view.setLayoutParams(layoutParams);\n        view.setText(content);\n        view.setTextColor(0xffffffff);\n        view.setGravity(Gravity.CENTER);\n        view.setTextSize(30);\n        view.setBackgroundColor(backgroundColor);\n        return view;\n    }\n}\n"
  },
  {
    "path": "demo/src/main/java/me/jessyan/autosize/demo/CustomFragment2.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo;\n\nimport android.os.Bundle;\nimport android.support.annotation.NonNull;\nimport android.support.annotation.Nullable;\nimport android.support.v4.app.Fragment;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\n\nimport me.jessyan.autosize.AutoSize;\nimport me.jessyan.autosize.internal.CustomAdapt;\n\n/**\n * ================================================\n * Created by JessYan on 2018/8/25 14:06\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class CustomFragment2 extends Fragment implements CustomAdapt{\n\n    @Nullable\n    @Override\n    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {\n        //由于某些原因, 屏幕旋转后 Fragment 的重建, 会导致框架对 Fragment 的自定义适配参数失去效果\n        //所以如果您的 Fragment 允许屏幕旋转, 则请在 onCreateView 手动调用一次 AutoSize.autoConvertDensity()\n        //如果您的 Fragment 不允许屏幕旋转, 则可以将下面调用 AutoSize.autoConvertDensity() 的代码删除掉\n        AutoSize.autoConvertDensity(getActivity(), 720, true);\n        return CustomFragment1.createTextView(inflater, \"Fragment-2\\nView width = 360dp\\nTotal width = 720dp\", 0xff00ff00);\n    }\n\n    @Override\n    public boolean isBaseOnWidth() {\n        return true;\n    }\n\n    @Override\n    public float getSizeInDp() {\n        return 720;\n    }\n}\n"
  },
  {
    "path": "demo/src/main/java/me/jessyan/autosize/demo/CustomFragment3.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo;\n\nimport android.os.Bundle;\nimport android.support.annotation.NonNull;\nimport android.support.annotation.Nullable;\nimport android.support.v4.app.Fragment;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\n\nimport me.jessyan.autosize.AutoSize;\nimport me.jessyan.autosize.internal.CustomAdapt;\n\n/**\n * ================================================\n * Created by JessYan on 2018/8/25 14:06\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class CustomFragment3 extends Fragment implements CustomAdapt{\n\n    @Nullable\n    @Override\n    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {\n        //由于某些原因, 屏幕旋转后 Fragment 的重建, 会导致框架对 Fragment 的自定义适配参数失去效果\n        //所以如果您的 Fragment 允许屏幕旋转, 则请在 onCreateView 手动调用一次 AutoSize.autoConvertDensity()\n        //如果您的 Fragment 不允许屏幕旋转, 则可以将下面调用 AutoSize.autoConvertDensity() 的代码删除掉\n        AutoSize.autoConvertDensity(getActivity(), 360, true);\n        return CustomFragment1.createTextView(inflater, \"Fragment-3\\nView width = 360dp\\nTotal width = 360dp\", 0xff0000ff);\n    }\n\n    @Override\n    public boolean isBaseOnWidth() {\n        return true;\n    }\n\n    @Override\n    public float getSizeInDp() {\n        return 360;\n    }\n}\n"
  },
  {
    "path": "demo/src/main/java/me/jessyan/autosize/demo/FragmentHost.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo;\n\nimport android.os.Bundle;\nimport android.support.annotation.Nullable;\nimport android.support.v7.app.AppCompatActivity;\n\nimport me.jessyan.autosize.internal.CustomAdapt;\n\n/**\n * ================================================\n * Created by JessYan on 2018/8/25 14:39\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class FragmentHost extends AppCompatActivity implements CustomAdapt {\n    @Override\n    protected void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_host);\n        if (getSupportFragmentManager().findFragmentById(R.id.container1) == null) {\n            getSupportFragmentManager().beginTransaction().add(R.id.container1, new CustomFragment1()).commit();\n        }\n        if (getSupportFragmentManager().findFragmentById(R.id.container2) == null) {\n            getSupportFragmentManager().beginTransaction().add(R.id.container2, new CustomFragment2()).commit();\n        }\n        if (getSupportFragmentManager().findFragmentById(R.id.container3) == null) {\n            getSupportFragmentManager().beginTransaction().add(R.id.container3, new CustomFragment3()).commit();\n        }\n    }\n\n    @Override\n    public boolean isBaseOnWidth() {\n        return true;\n    }\n\n    @Override\n    public float getSizeInDp() {\n        return 720;\n    }\n}\n"
  },
  {
    "path": "demo/src/main/java/me/jessyan/autosize/demo/MainActivity.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo;\n\nimport android.app.Activity;\nimport android.app.Dialog;\nimport android.app.Fragment;\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\nimport android.view.View;\nimport android.widget.Toast;\n\nimport cat.ereza.customactivityoncrash.activity.DefaultErrorActivity;\nimport cat.ereza.customactivityoncrash.config.CaocConfig;\nimport me.jessyan.autosize.AutoSizeConfig;\nimport me.jessyan.autosize.internal.CustomAdapt;\n\n/**\n * ================================================\n * 本框架核心原理来自于 <a href=\"https://mp.weixin.qq.com/s/d9QCoBP6kV9VSWvVldVVwA\">今日头条官方适配方案</a>\n * 此方案不光可以适配 {@link Activity}, 这个 {@link Activity} 下的所有 {@link Fragment}、{@link Dialog}、{@link View} 都会自动适配\n * <p>\n * {@link MainActivity} 是以屏幕宽度为基准进行适配的, 并且使用的是在 AndroidManifest 中填写的全局设计图尺寸 360 * 640\n * 不懂什么叫基准的话, 请看 {@link AutoSizeConfig#isBaseOnWidth}) 的注释, AndroidAutoSize 默认全局以屏幕宽度为基准进行适配\n * 如果想更改为全局以屏幕高度为基准进行适配, 请在 {@link BaseApplication} 中按注释中更改, 为什么强调全局？\n * 因为 AndroidAutoSize 允许每个 {@link Activity} 可以自定义适配参数, 自定义适配参数通过实现 {@link CustomAdapt}\n * 如果不自定义适配参数就会使用全局的适配参数, 全局适配参数在 {@link BaseApplication} 中按注释设置\n * <p>\n * Created by JessYan on 2018/8/9 17:05\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\n//实现 CancelAdapt 即可取消当前 Activity 的屏幕适配, 并且这个 Activity 下的所有 Fragment 和 View 都会被取消适配\n//public class MainActivity extends AppCompatActivity implements CancelAdapt {\npublic class MainActivity extends AppCompatActivity {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n    }\n\n    /**\n     * 需要注意的是暂停 AndroidAutoSize 后, AndroidAutoSize 只是停止了对后续还没有启动的 {@link Activity} 进行适配的工作\n     * 但对已经启动且已经适配的 {@link Activity} 不会有任何影响\n     *\n     * @param view {@link View}\n     */\n    public void stop(View view) {\n        Toast.makeText(getApplicationContext(), \"AndroidAutoSize stops working!\", Toast.LENGTH_SHORT).show();\n        AutoSizeConfig.getInstance().stop(this);\n    }\n\n    /**\n     * 需要注意的是重新启动 AndroidAutoSize 后, AndroidAutoSize 只是重新开始了对后续还没有启动的 {@link Activity} 进行适配的工作\n     * 但对已经启动且在 stop 期间未适配的 {@link Activity} 不会有任何影响\n     *\n     * @param view {@link View}\n     */\n    public void restart(View view) {\n        Toast.makeText(getApplicationContext(), \"AndroidAutoSize continues to work\", Toast.LENGTH_SHORT).show();\n        AutoSizeConfig.getInstance().restart();\n    }\n\n    /**\n     * 跳转到 {@link CustomAdaptActivity}, 展示项目内部的 {@link Activity} 自定义适配参数的用法\n     *\n     * @param view {@link View}\n     */\n    public void goCustomAdaptActivity(View view) {\n        startActivity(new Intent(getApplicationContext(), CustomAdaptActivity.class));\n    }\n\n    /**\n     * 跳转到三方库的 {@link Activity}, 展示项目外部某些三方库的 {@link Activity} 自定义适配参数的用法\n     * 跳转前要先在 {@link BaseApplication#customAdaptForExternal()} 中给外部的三方库 {@link Activity} 自定义适配参数\n     *\n     * @param view {@link View}\n     */\n    public void goThirdLibraryActivity(View view) {\n        //这里就是随便找个三方库的 Activity, 测试下适配三方库页面的功能是否可用\n        //以下代码就是为了启动这个三方库的 Activity, 不必在意\n        Intent intent = new Intent(getApplicationContext(), DefaultErrorActivity.class);\n        Bundle extras = new Bundle();\n        extras.putSerializable(\"cat.ereza.customactivityoncrash.EXTRA_CONFIG\", CaocConfig.Builder.create().get());\n        intent.putExtras(extras);\n        startActivity(intent);\n    }\n}\n"
  },
  {
    "path": "demo/src/main/res/drawable/ic_launcher_background.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<vector\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:width=\"108dp\"\n    android:height=\"108dp\"\n    android:viewportHeight=\"108\"\n    android:viewportWidth=\"108\">\n    <path\n        android:fillColor=\"#26A69A\"\n        android:pathData=\"M0,0h108v108h-108z\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M9,0L9,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,0L19,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M29,0L29,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M39,0L39,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M49,0L49,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M59,0L59,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M69,0L69,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M79,0L79,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M89,0L89,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M99,0L99,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,9L108,9\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,19L108,19\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,29L108,29\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,39L108,39\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,49L108,49\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,59L108,59\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,69L108,69\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,79L108,79\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,89L108,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,99L108,99\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,29L89,29\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,39L89,39\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,49L89,49\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,59L89,59\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,69L89,69\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,79L89,79\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M29,19L29,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M39,19L39,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M49,19L49,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M59,19L59,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M69,19L69,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M79,19L79,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n</vector>\n"
  },
  {
    "path": "demo/src/main/res/drawable-v24/ic_launcher_foreground.xml",
    "content": "<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        xmlns:aapt=\"http://schemas.android.com/aapt\"\n        android:width=\"108dp\"\n        android:height=\"108dp\"\n        android:viewportHeight=\"108\"\n        android:viewportWidth=\"108\">\n    <path\n        android:fillType=\"evenOdd\"\n        android:pathData=\"M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z\"\n        android:strokeColor=\"#00000000\"\n        android:strokeWidth=\"1\">\n        <aapt:attr name=\"android:fillColor\">\n            <gradient\n                android:endX=\"78.5885\"\n                android:endY=\"90.9159\"\n                android:startX=\"48.7653\"\n                android:startY=\"61.0927\"\n                android:type=\"linear\">\n                <item\n                    android:color=\"#44000000\"\n                    android:offset=\"0.0\"/>\n                <item\n                    android:color=\"#00000000\"\n                    android:offset=\"1.0\"/>\n            </gradient>\n        </aapt:attr>\n    </path>\n    <path\n        android:fillColor=\"#FFFFFF\"\n        android:fillType=\"nonZero\"\n        android:pathData=\"M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z\"\n        android:strokeColor=\"#00000000\"\n        android:strokeWidth=\"1\"/>\n</vector>\n"
  },
  {
    "path": "demo/src/main/res/layout/activity_custom_adapt.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"horizontal\"\n    tools:context=\".CustomAdaptActivity\">\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:orientation=\"vertical\">\n\n        <TextView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"248dp\"\n            android:background=\"@color/colorPrimary\"\n            android:gravity=\"center\"\n            android:text=\"H-248dp\\n(Height Total:667dp)\"\n            android:textColor=\"#fff\"\n            android:textSize=\"20sp\"/>\n\n        <!--把高度设置为 2 dp 的原因是想展示 AndroidAutoSize 可以把适配精度精确到 1 dp (写 2 dp 是为了更显眼, 写 1 dp 也是可以的)\n        如果您看得到屏幕中间高度为 2 dp 的白色间隙, 说明本适配方案, 能精确适配, 您可以放心填写 dp 值-->\n\n        <TextView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"2dp\"\n            android:background=\"#fff\"\n            />\n\n        <Button\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"100dp\"\n            android:background=\"#0f3\"\n            android:onClick=\"goCustomAdaptFragment\"\n            android:text=\"CustomAdapt(Fragment)\"\n            android:textColor=\"#00f\"\n            android:textSize=\"20sp\"\n            />\n\n        <TextView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"125dp\"\n            android:background=\"#d0f\"\n            android:gravity=\"center\"\n            android:text=\"H-125dp\"\n            android:textColor=\"#fff\"\n            android:textSize=\"20sp\"/>\n\n        <TextView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"191dp\"\n            android:background=\"#d21\"\n            android:gravity=\"center\"\n            android:text=\"H-191dp\"\n            android:textColor=\"#fff\"\n            android:textSize=\"20sp\"/>\n\n        <TextView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"1dp\"\n            android:background=\"#fff\"\n            />\n    </LinearLayout>\n</LinearLayout>"
  },
  {
    "path": "demo/src/main/res/layout/activity_host.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n              android:layout_width=\"match_parent\"\n              android:layout_height=\"match_parent\"\n              android:orientation=\"vertical\">\n\n    <FrameLayout\n        android:id=\"@+id/container1\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"0dp\"\n        android:layout_weight=\"1\"/>\n\n    <FrameLayout\n        android:id=\"@+id/container2\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"0dp\"\n        android:layout_weight=\"1\"/>\n\n    <FrameLayout\n        android:id=\"@+id/container3\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"0dp\"\n        android:layout_weight=\"1\"/>\n</LinearLayout>"
  },
  {
    "path": "demo/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\"\n    tools:context=\".MainActivity\">\n\n    <LinearLayout\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:orientation=\"horizontal\">\n\n        <Button\n            android:layout_width=\"180dp\"\n            android:layout_height=\"100dp\"\n            android:background=\"@color/colorAccent\"\n            android:onClick=\"stop\"\n            android:text=\"stop\"\n            android:textColor=\"#fff\"\n            android:textSize=\"30sp\"/>\n\n        <Button\n            android:layout_width=\"180dp\"\n            android:layout_height=\"100dp\"\n            android:background=\"#0d0\"\n            android:onClick=\"restart\"\n            android:text=\"restart\"\n            android:textColor=\"#fff\"\n            android:textSize=\"30sp\"/>\n\n    </LinearLayout>\n\n    <Button\n        android:layout_width=\"360dp\"\n        android:layout_height=\"100dp\"\n        android:background=\"#fd0\"\n        android:onClick=\"goCustomAdaptActivity\"\n        android:text=\"CustomAdapt(internal)\"\n        android:textColor=\"#fff\"\n        android:textSize=\"25sp\"/>\n\n    <Button\n        android:layout_width=\"360dp\"\n        android:layout_height=\"100dp\"\n        android:background=\"#d00\"\n        android:onClick=\"goThirdLibraryActivity\"\n        android:text=\"CustomAdapt(external)\"\n        android:textColor=\"#fff\"\n        android:textSize=\"25sp\"/>\n\n\n    <LinearLayout\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:orientation=\"horizontal\">\n\n        <TextView\n            android:layout_width=\"250dp\"\n            android:layout_height=\"100dp\"\n            android:background=\"@color/colorPrimary\"\n            android:gravity=\"center\"\n            android:text=\"W-250dp(total:360dp)\"\n            android:textColor=\"#0d0\"\n            android:textSize=\"20sp\"/>\n\n        <TextView\n            android:layout_width=\"1dp\"\n            android:layout_height=\"100dp\"\n            />\n\n        <TextView\n            android:layout_width=\"109dp\"\n            android:layout_height=\"100dp\"\n            android:background=\"#d0a\"\n            android:gravity=\"center\"\n            android:text=\"W-109dp\"\n            android:textColor=\"#0d0\"\n            android:textSize=\"20sp\"/>\n    </LinearLayout>\n\n    <LinearLayout\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"horizontal\">\n\n        <TextView\n            android:layout_width=\"120dp\"\n            android:layout_height=\"match_parent\"\n            android:background=\"#aef\"\n            android:gravity=\"center\"\n            android:text=\"W-120dp\"\n            android:textColor=\"#0d0\"\n            android:textSize=\"20sp\"/>\n\n        <TextView\n            android:layout_width=\"90dp\"\n            android:layout_height=\"match_parent\"\n            android:background=\"#acf\"\n            android:gravity=\"center\"\n            android:text=\"W-90dp\"\n            android:textColor=\"#0d0\"\n            android:textSize=\"20sp\"/>\n\n        <TextView\n            android:layout_width=\"150dp\"\n            android:layout_height=\"match_parent\"\n            android:background=\"#fcf\"\n            android:gravity=\"center\"\n            android:text=\"W-150dp\"\n            android:textColor=\"#0d0\"\n            android:textSize=\"20sp\"/>\n    </LinearLayout>\n\n</LinearLayout>"
  },
  {
    "path": "demo/src/main/res/mipmap-anydpi-v26/ic_launcher.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\"/>\n    <foreground android:drawable=\"@drawable/ic_launcher_foreground\"/>\n</adaptive-icon>"
  },
  {
    "path": "demo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\"/>\n    <foreground android:drawable=\"@drawable/ic_launcher_foreground\"/>\n</adaptive-icon>"
  },
  {
    "path": "demo/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#FF4081</color>\n</resources>\n"
  },
  {
    "path": "demo/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">AutoSize Demo</string>\n</resources>\n"
  },
  {
    "path": "demo/src/main/res/values/styles.xml",
    "content": "<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.NoActionBar\">\n        <!-- Customize your theme here. -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "demo/src/test/java/me/jessyan/autosize/demo/ExampleUnitTest.java",
    "content": "package me.jessyan.autosize.demo;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * Example local unit test, which will execute on the development machine (host).\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "demo-androidx/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "demo-androidx/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion rootProject.compileSdkVersion\n    buildToolsVersion rootProject.buildToolsVersion\n\n    defaultConfig {\n        applicationId \"me.jessyan.autosize.demo.androidx\"\n        minSdkVersion rootProject.minSdkVersion\n        targetSdkVersion rootProject.targetSdkVersion\n        versionCode rootProject.versionCode\n        versionName rootProject.versionName\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n//    implementation 'me.jessyan:autosize:1.2.1'\n    implementation project(':autosize')\n    implementation rootProject.androidx_appcompat\n    testImplementation 'junit:junit:4.12'\n}\n"
  },
  {
    "path": "demo-androidx/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "demo-androidx/src/androidTest/java/me/jessyan/autosize/demo/ExampleInstrumentedTest.java",
    "content": "package me.jessyan.autosize.demo;\n\nimport android.content.Context;\nimport android.support.test.InstrumentationRegistry;\nimport android.support.test.runner.AndroidJUnit4;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport static org.junit.Assert.*;\n\n/**\n * Instrumented test, which will execute on an Android device.\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\n@RunWith(AndroidJUnit4.class)\npublic class ExampleInstrumentedTest {\n    @Test\n    public void useAppContext() {\n        // Context of the app under test.\n        Context appContext = InstrumentationRegistry.getTargetContext();\n\n        assertEquals(\"me.jessyan.autosize.demo\", appContext.getPackageName());\n    }\n}\n"
  },
  {
    "path": "demo-androidx/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n          package=\"me.jessyan.autosize.demo.androidx\">\n\n    <application\n        android:name=\".BaseApplication\"\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/autosize_logo\"\n        android:label=\"@string/app_name\"\n        android:supportsRtl=\"true\"\n        android:theme=\"@style/AppTheme\">\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        <activity android:name=\".CustomAdaptActivity\"/>\n        <activity android:name=\".FragmentHost\"/>\n\n        <!-- 如果您项目中的所有页面都只需要以高或宽中的一个作为基准进行适配的话, 那就只需要填写高或宽中的一个设计图尺寸即可 -->\n        <meta-data\n            android:name=\"design_width_in_dp\"\n            android:value=\"360\"/>\n        <meta-data\n            android:name=\"design_height_in_dp\"\n            android:value=\"640\"/>\n\n    </application>\n\n</manifest>"
  },
  {
    "path": "demo-androidx/src/main/java/me/jessyan/autosize/demo/androidx/BaseApplication.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo.androidx;\n\nimport android.app.Activity;\nimport android.app.Application;\nimport android.util.DisplayMetrics;\n\nimport java.util.Locale;\n\nimport me.jessyan.autosize.AutoSize;\nimport me.jessyan.autosize.AutoSizeConfig;\nimport me.jessyan.autosize.onAdaptListener;\nimport me.jessyan.autosize.utils.AutoSizeLog;\n\n/**\n * ================================================\n * v0.9.1 发布后新增了副单位，可以在 pt、in、mm 三个冷门单位中选择一个作为副单位，然后在 layout 文件中使用副单位进行布局\n * 副单位可以规避修改 {@link DisplayMetrics#density} 所造成的对于其他使用 dp 布局的系统控件或三方库控件的不良影响\n * 使用副单位后可直接在 AndroidManifest 中填写设计图上的像素尺寸，不需要再将像素转化为 dp\n * <a href=\"https://github.com/JessYanCoding/AndroidAutoSize/blob/master/README-zh.md#preview\">点击查看在布局中的实时预览方式</a>\n * <p>\n * 本框架核心原理来自于 <a href=\"https://mp.weixin.qq.com/s/d9QCoBP6kV9VSWvVldVVwA\">今日头条官方适配方案</a>\n * <p>\n * 本框架源码的注释都很详细, 欢迎阅读学习\n * <p>\n * AndroidAutoSize 会在 APP 启动时自动完成初始化, 如果您想设置自定义参数可以在 {@link Application#onCreate()} 中设置\n * <p>\n * Created by JessYan on 2018/8/9 17:05\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class BaseApplication extends Application {\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        //当 App 中出现多进程, 并且您需要适配所有的进程, 就需要在 App 初始化时调用 initCompatMultiProcess()\n        AutoSize.initCompatMultiProcess(this);\n\n        //如果在某些特殊情况下出现 InitProvider 未能正常实例化, 导致 AndroidAutoSize 未能完成初始化\n        //可以主动调用 AutoSize.checkAndInit(this) 方法, 完成 AndroidAutoSize 的初始化后即可正常使用\n//        AutoSize.checkAndInit(this);\n\n//        如何控制 AndroidAutoSize 的初始化，让 AndroidAutoSize 在某些设备上不自动启动？https://github.com/JessYanCoding/AndroidAutoSize/issues/249\n\n        /**\n         * 以下是 AndroidAutoSize 可以自定义的参数, {@link AutoSizeConfig} 的每个方法的注释都写的很详细\n         * 使用前请一定记得跳进源码，查看方法的注释, 下面的注释只是简单描述!!!\n         */\n        AutoSizeConfig.getInstance()\n\n                //是否让框架支持自定义 Fragment 的适配参数, 由于这个需求是比较少见的, 所以须要使用者手动开启\n                //如果没有这个需求建议不开启\n                .setCustomFragment(true)\n\n                //是否屏蔽系统字体大小对 AndroidAutoSize 的影响, 如果为 true, App 内的字体的大小将不会跟随系统设置中字体大小的改变\n                //如果为 false, 则会跟随系统设置中字体大小的改变, 默认为 false\n//                .setExcludeFontScale(true)\n\n                //区别于系统字体大小的放大比例, AndroidAutoSize 允许 APP 内部可以独立于系统字体大小之外，独自拥有全局调节 APP 字体大小的能力\n                //当然, 在 APP 内您必须使用 sp 来作为字体的单位, 否则此功能无效, 不设置或将此值设为 0 则取消此功能\n//                .setPrivateFontScale(0.8f)\n\n                //屏幕适配监听器\n                .setOnAdaptListener(new onAdaptListener() {\n                    @Override\n                    public void onAdaptBefore(Object target, Activity activity) {\n                        //使用以下代码, 可以解决横竖屏切换时的屏幕适配问题\n                        //使用以下代码, 可支持 Android 的分屏或缩放模式, 但前提是在分屏或缩放模式下当用户改变您 App 的窗口大小时\n                        //系统会重绘当前的页面, 经测试在某些机型, 某些情况下系统不会重绘当前页面, ScreenUtils.getScreenSize(activity) 的参数一定要不要传 Application!!!\n//                        AutoSizeConfig.getInstance().setScreenWidth(ScreenUtils.getScreenSize(activity)[0]);\n//                        AutoSizeConfig.getInstance().setScreenHeight(ScreenUtils.getScreenSize(activity)[1]);\n                        AutoSizeLog.d(String.format(Locale.ENGLISH, \"%s onAdaptBefore!\", target.getClass().getName()));\n                    }\n\n                    @Override\n                    public void onAdaptAfter(Object target, Activity activity) {\n                        AutoSizeLog.d(String.format(Locale.ENGLISH, \"%s onAdaptAfter!\", target.getClass().getName()));\n                    }\n                })\n\n                //是否打印 AutoSize 的内部日志, 默认为 true, 如果您不想 AutoSize 打印日志, 则请设置为 false\n//                .setLog(false)\n\n                //是否使用设备的实际尺寸做适配, 默认为 false, 如果设置为 false, 在以屏幕高度为基准进行适配时\n                //AutoSize 会将屏幕总高度减去状态栏高度来做适配\n                //设置为 true 则使用设备的实际屏幕高度, 不会减去状态栏高度\n                //在全面屏或刘海屏幕设备中, 获取到的屏幕高度可能不包含状态栏高度, 所以在全面屏设备中不需要减去状态栏高度，所以可以 setUseDeviceSize(true)\n//                .setUseDeviceSize(true)\n\n                //是否全局按照宽度进行等比例适配, 默认为 true, 如果设置为 false, AutoSize 会全局按照高度进行适配\n//                .setBaseOnWidth(false)\n\n                 //设置屏幕适配逻辑策略类, 一般不用设置, 使用框架默认的就好\n//                .setAutoAdaptStrategy(new AutoAdaptStrategy())\n        ;\n    }\n}\n"
  },
  {
    "path": "demo-androidx/src/main/java/me/jessyan/autosize/demo/androidx/CustomAdaptActivity.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo.androidx;\n\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.view.View;\n\nimport androidx.appcompat.app.AppCompatActivity;\nimport androidx.fragment.app.Fragment;\nimport me.jessyan.autosize.internal.CustomAdapt;\n\n/**\n * ================================================\n * 本框架核心原理来自于 <a href=\"https://mp.weixin.qq.com/s/d9QCoBP6kV9VSWvVldVVwA\">今日头条官方适配方案</a>\n * <p>\n * {@link CustomAdaptActivity} 展示项目内部的 {@link Activity} 自定义适配参数的用法, 需要实现 {@link CustomAdapt}\n * 现在 AndroidAutoSize 是全局以屏幕宽度为基准进行适配的, 并且全局的设计图尺寸为 360 * 640\n * 这里就展示怎么让 {@link CustomAdaptActivity} 单个页面, 有别于全局设置, 以屏幕高度为基准进行适配, 并且更改设计图尺寸为 iPhone 的设计图尺寸\n * 如果这个页面的设计图尺寸有别于其他页面, AndroidAutoSize 允许您改变单个页面的设计图尺寸, {@link #getSizeInDp()}\n * <p>\n * Created by JessYan on 2018/8/11 11:31\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class CustomAdaptActivity extends AppCompatActivity implements CustomAdapt {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_custom_adapt);\n    }\n\n    /**\n     * 跳转到 {@link FragmentHost}, 展示项目内部的 {@link Fragment} 自定义适配参数的用法\n     *\n     * @param view {@link View}\n     */\n    public void goCustomAdaptFragment(View view) {\n        startActivity(new Intent(getApplicationContext(), FragmentHost.class));\n    }\n\n    /**\n     * 是否按照宽度进行等比例适配 (为了保证在高宽比不同的屏幕上也能正常适配, 所以只能在宽度和高度之中选择一个作为基准进行适配)\n     *\n     * @return {@code true} 为按照宽度进行适配, {@code false} 为按照高度进行适配\n     */\n    @Override\n    public boolean isBaseOnWidth() {\n        return false;\n    }\n\n    /**\n     * 这里使用 iPhone 的设计图, iPhone 的设计图尺寸为 750px * 1334px, 高换算成 dp 为 667 (1334px / 2 = 667dp)\n     * <p>\n     * 返回设计图上的设计尺寸, 单位 dp\n     * {@link #getSizeInDp} 须配合 {@link #isBaseOnWidth()} 使用, 规则如下:\n     * 如果 {@link #isBaseOnWidth()} 返回 {@code true}, {@link #getSizeInDp} 则应该返回设计图的总宽度\n     * 如果 {@link #isBaseOnWidth()} 返回 {@code false}, {@link #getSizeInDp} 则应该返回设计图的总高度\n     * 如果您不需要自定义设计图上的设计尺寸, 想继续使用在 AndroidManifest 中填写的设计图尺寸, {@link #getSizeInDp} 则返回 {@code 0}\n     *\n     * @return 设计图上的设计尺寸, 单位 dp\n     */\n    @Override\n    public float getSizeInDp() {\n        return 667;\n    }\n}\n"
  },
  {
    "path": "demo-androidx/src/main/java/me/jessyan/autosize/demo/androidx/CustomFragment1.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo.androidx;\n\nimport android.os.Bundle;\nimport android.view.Gravity;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.widget.TextView;\n\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport androidx.fragment.app.Fragment;\nimport me.jessyan.autosize.AutoSize;\nimport me.jessyan.autosize.internal.CustomAdapt;\nimport me.jessyan.autosize.utils.AutoSizeUtils;\n\n/**\n * ================================================\n * Created by JessYan on 2018/8/25 14:06\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class CustomFragment1 extends Fragment implements CustomAdapt {\n\n    @Nullable\n    @Override\n    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {\n        //由于某些原因, 屏幕旋转后 Fragment 的重建, 会导致框架对 Fragment 的自定义适配参数失去效果\n        //所以如果您的 Fragment 允许屏幕旋转, 则请在 onCreateView 手动调用一次 AutoSize.autoConvertDensity()\n        //如果您的 Fragment 不允许屏幕旋转, 则可以将下面调用 AutoSize.autoConvertDensity() 的代码删除掉\n        AutoSize.autoConvertDensity(getActivity(), 1080, true);\n        return createTextView(inflater, \"Fragment-1\\nView width = 360dp\\nTotal width = 1080dp\", 0xffff0000);\n    }\n\n    @Override\n    public boolean isBaseOnWidth() {\n        return true;\n    }\n\n    @Override\n    public float getSizeInDp() {\n        return 1080;\n    }\n\n    public static View createTextView(LayoutInflater inflater, String content, int backgroundColor) {\n        TextView view = new TextView(inflater.getContext());\n        ViewGroup.LayoutParams layoutParams =\n                new ViewGroup.LayoutParams((AutoSizeUtils.dp2px(inflater.getContext(), 360)),\n                        ViewGroup.LayoutParams.MATCH_PARENT);\n        view.setLayoutParams(layoutParams);\n        view.setText(content);\n        view.setTextColor(0xffffffff);\n        view.setGravity(Gravity.CENTER);\n        view.setTextSize(30);\n        view.setBackgroundColor(backgroundColor);\n        return view;\n    }\n}\n"
  },
  {
    "path": "demo-androidx/src/main/java/me/jessyan/autosize/demo/androidx/CustomFragment2.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo.androidx;\n\nimport android.os.Bundle;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\n\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport androidx.fragment.app.Fragment;\nimport me.jessyan.autosize.AutoSize;\nimport me.jessyan.autosize.internal.CustomAdapt;\n\n/**\n * ================================================\n * Created by JessYan on 2018/8/25 14:06\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class CustomFragment2 extends Fragment implements CustomAdapt{\n\n    @Nullable\n    @Override\n    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {\n        //由于某些原因, 屏幕旋转后 Fragment 的重建, 会导致框架对 Fragment 的自定义适配参数失去效果\n        //所以如果您的 Fragment 允许屏幕旋转, 则请在 onCreateView 手动调用一次 AutoSize.autoConvertDensity()\n        //如果您的 Fragment 不允许屏幕旋转, 则可以将下面调用 AutoSize.autoConvertDensity() 的代码删除掉\n        AutoSize.autoConvertDensity(getActivity(), 720, true);\n        return CustomFragment1.createTextView(inflater, \"Fragment-2\\nView width = 360dp\\nTotal width = 720dp\", 0xff00ff00);\n    }\n\n    @Override\n    public boolean isBaseOnWidth() {\n        return true;\n    }\n\n    @Override\n    public float getSizeInDp() {\n        return 720;\n    }\n}\n"
  },
  {
    "path": "demo-androidx/src/main/java/me/jessyan/autosize/demo/androidx/CustomFragment3.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo.androidx;\n\nimport android.os.Bundle;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\n\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport androidx.fragment.app.Fragment;\nimport me.jessyan.autosize.AutoSize;\nimport me.jessyan.autosize.internal.CustomAdapt;\n\n/**\n * ================================================\n * Created by JessYan on 2018/8/25 14:06\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class CustomFragment3 extends Fragment implements CustomAdapt{\n\n    @Nullable\n    @Override\n    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {\n        //由于某些原因, 屏幕旋转后 Fragment 的重建, 会导致框架对 Fragment 的自定义适配参数失去效果\n        //所以如果您的 Fragment 允许屏幕旋转, 则请在 onCreateView 手动调用一次 AutoSize.autoConvertDensity()\n        //如果您的 Fragment 不允许屏幕旋转, 则可以将下面调用 AutoSize.autoConvertDensity() 的代码删除掉\n        AutoSize.autoConvertDensity(getActivity(), 360, true);\n        return CustomFragment1.createTextView(inflater, \"Fragment-3\\nView width = 360dp\\nTotal width = 360dp\", 0xff0000ff);\n    }\n\n    @Override\n    public boolean isBaseOnWidth() {\n        return true;\n    }\n\n    @Override\n    public float getSizeInDp() {\n        return 360;\n    }\n}\n"
  },
  {
    "path": "demo-androidx/src/main/java/me/jessyan/autosize/demo/androidx/FragmentHost.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo.androidx;\n\nimport android.os.Bundle;\n\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.app.AppCompatActivity;\nimport me.jessyan.autosize.internal.CustomAdapt;\n\n/**\n * ================================================\n * Created by JessYan on 2018/8/25 14:39\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class FragmentHost extends AppCompatActivity implements CustomAdapt {\n    @Override\n    protected void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_host);\n        if (getSupportFragmentManager().findFragmentById(R.id.container1) == null) {\n            getSupportFragmentManager().beginTransaction().add(R.id.container1, new CustomFragment1()).commit();\n        }\n        if (getSupportFragmentManager().findFragmentById(R.id.container2) == null) {\n            getSupportFragmentManager().beginTransaction().add(R.id.container2, new CustomFragment2()).commit();\n        }\n        if (getSupportFragmentManager().findFragmentById(R.id.container3) == null) {\n            getSupportFragmentManager().beginTransaction().add(R.id.container3, new CustomFragment3()).commit();\n        }\n    }\n\n    @Override\n    public boolean isBaseOnWidth() {\n        return true;\n    }\n\n    @Override\n    public float getSizeInDp() {\n        return 720;\n    }\n}\n"
  },
  {
    "path": "demo-androidx/src/main/java/me/jessyan/autosize/demo/androidx/MainActivity.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo.androidx;\n\nimport android.app.Activity;\nimport android.app.Dialog;\nimport android.app.Fragment;\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.view.View;\nimport android.widget.Toast;\n\nimport androidx.appcompat.app.AppCompatActivity;\nimport me.jessyan.autosize.AutoSizeConfig;\nimport me.jessyan.autosize.internal.CustomAdapt;\n\n/**\n * ================================================\n * 本框架核心原理来自于 <a href=\"https://mp.weixin.qq.com/s/d9QCoBP6kV9VSWvVldVVwA\">今日头条官方适配方案</a>\n * 此方案不光可以适配 {@link Activity}, 这个 {@link Activity} 下的所有 {@link Fragment}、{@link Dialog}、{@link View} 都会自动适配\n * <p>\n * {@link MainActivity} 是以屏幕宽度为基准进行适配的, 并且使用的是在 AndroidManifest 中填写的全局设计图尺寸 360 * 640\n * 不懂什么叫基准的话, 请看 {@link AutoSizeConfig#isBaseOnWidth}) 的注释, AndroidAutoSize 默认全局以屏幕宽度为基准进行适配\n * 如果想更改为全局以屏幕高度为基准进行适配, 请在 {@link BaseApplication} 中按注释中更改, 为什么强调全局？\n * 因为 AndroidAutoSize 允许每个 {@link Activity} 可以自定义适配参数, 自定义适配参数通过实现 {@link CustomAdapt}\n * 如果不自定义适配参数就会使用全局的适配参数, 全局适配参数在 {@link BaseApplication} 中按注释设置\n * <p>\n * Created by JessYan on 2018/8/9 17:05\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\n//实现 CancelAdapt 即可取消当前 Activity 的屏幕适配, 并且这个 Activity 下的所有 Fragment 和 View 都会被取消适配\n//public class MainActivity extends AppCompatActivity implements CancelAdapt {\npublic class MainActivity extends AppCompatActivity {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n    }\n\n    /**\n     * 需要注意的是暂停 AndroidAutoSize 后, AndroidAutoSize 只是停止了对后续还没有启动的 {@link Activity} 进行适配的工作\n     * 但对已经启动且已经适配的 {@link Activity} 不会有任何影响\n     *\n     * @param view {@link View}\n     */\n    public void stop(View view) {\n        Toast.makeText(getApplicationContext(), \"AndroidAutoSize stops working!\", Toast.LENGTH_SHORT).show();\n        AutoSizeConfig.getInstance().stop(this);\n    }\n\n    /**\n     * 需要注意的是重新启动 AndroidAutoSize 后, AndroidAutoSize 只是重新开始了对后续还没有启动的 {@link Activity} 进行适配的工作\n     * 但对已经启动且在 stop 期间未适配的 {@link Activity} 不会有任何影响\n     *\n     * @param view {@link View}\n     */\n    public void restart(View view) {\n        Toast.makeText(getApplicationContext(), \"AndroidAutoSize continues to work\", Toast.LENGTH_SHORT).show();\n        AutoSizeConfig.getInstance().restart();\n    }\n\n    /**\n     * 跳转到 {@link CustomAdaptActivity}, 展示项目内部的 {@link Activity} 自定义适配参数的用法\n     *\n     * @param view {@link View}\n     */\n    public void goCustomAdaptActivity(View view) {\n        startActivity(new Intent(getApplicationContext(), CustomAdaptActivity.class));\n    }\n}\n"
  },
  {
    "path": "demo-androidx/src/main/res/drawable/ic_launcher_background.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<vector\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:width=\"108dp\"\n    android:height=\"108dp\"\n    android:viewportHeight=\"108\"\n    android:viewportWidth=\"108\">\n    <path\n        android:fillColor=\"#26A69A\"\n        android:pathData=\"M0,0h108v108h-108z\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M9,0L9,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,0L19,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M29,0L29,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M39,0L39,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M49,0L49,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M59,0L59,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M69,0L69,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M79,0L79,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M89,0L89,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M99,0L99,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,9L108,9\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,19L108,19\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,29L108,29\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,39L108,39\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,49L108,49\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,59L108,59\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,69L108,69\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,79L108,79\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,89L108,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,99L108,99\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,29L89,29\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,39L89,39\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,49L89,49\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,59L89,59\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,69L89,69\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,79L89,79\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M29,19L29,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M39,19L39,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M49,19L49,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M59,19L59,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M69,19L69,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M79,19L79,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n</vector>\n"
  },
  {
    "path": "demo-androidx/src/main/res/drawable-v24/ic_launcher_foreground.xml",
    "content": "<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        xmlns:aapt=\"http://schemas.android.com/aapt\"\n        android:width=\"108dp\"\n        android:height=\"108dp\"\n        android:viewportHeight=\"108\"\n        android:viewportWidth=\"108\">\n    <path\n        android:fillType=\"evenOdd\"\n        android:pathData=\"M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z\"\n        android:strokeColor=\"#00000000\"\n        android:strokeWidth=\"1\">\n        <aapt:attr name=\"android:fillColor\">\n            <gradient\n                android:endX=\"78.5885\"\n                android:endY=\"90.9159\"\n                android:startX=\"48.7653\"\n                android:startY=\"61.0927\"\n                android:type=\"linear\">\n                <item\n                    android:color=\"#44000000\"\n                    android:offset=\"0.0\"/>\n                <item\n                    android:color=\"#00000000\"\n                    android:offset=\"1.0\"/>\n            </gradient>\n        </aapt:attr>\n    </path>\n    <path\n        android:fillColor=\"#FFFFFF\"\n        android:fillType=\"nonZero\"\n        android:pathData=\"M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z\"\n        android:strokeColor=\"#00000000\"\n        android:strokeWidth=\"1\"/>\n</vector>\n"
  },
  {
    "path": "demo-androidx/src/main/res/layout/activity_custom_adapt.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"horizontal\"\n    tools:context=\".CustomAdaptActivity\">\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:orientation=\"vertical\">\n\n        <TextView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"248dp\"\n            android:background=\"@color/colorPrimary\"\n            android:gravity=\"center\"\n            android:text=\"H-248dp\\n(Height Total:667dp)\"\n            android:textColor=\"#fff\"\n            android:textSize=\"20sp\"/>\n\n        <!--把高度设置为 2 dp 的原因是想展示 AndroidAutoSize 可以把适配精度精确到 1 dp (写 2 dp 是为了更显眼, 写 1 dp 也是可以的)\n        如果您看得到屏幕中间高度为 2 dp 的白色间隙, 说明本适配方案, 能精确适配, 您可以放心填写 dp 值-->\n\n        <TextView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"2dp\"\n            android:background=\"#fff\"\n            />\n\n        <Button\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"100dp\"\n            android:background=\"#0f3\"\n            android:onClick=\"goCustomAdaptFragment\"\n            android:text=\"CustomAdapt(Fragment)\"\n            android:textColor=\"#00f\"\n            android:textSize=\"20sp\"\n            />\n\n        <TextView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"125dp\"\n            android:background=\"#d0f\"\n            android:gravity=\"center\"\n            android:text=\"H-125dp\"\n            android:textColor=\"#fff\"\n            android:textSize=\"20sp\"/>\n\n        <TextView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"191dp\"\n            android:background=\"#d21\"\n            android:gravity=\"center\"\n            android:text=\"H-191dp\"\n            android:textColor=\"#fff\"\n            android:textSize=\"20sp\"/>\n\n        <TextView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"1dp\"\n            android:background=\"#fff\"\n            />\n    </LinearLayout>\n</LinearLayout>"
  },
  {
    "path": "demo-androidx/src/main/res/layout/activity_host.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n              android:layout_width=\"match_parent\"\n              android:layout_height=\"match_parent\"\n              android:orientation=\"vertical\">\n\n    <FrameLayout\n        android:id=\"@+id/container1\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"0dp\"\n        android:layout_weight=\"1\"/>\n\n    <FrameLayout\n        android:id=\"@+id/container2\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"0dp\"\n        android:layout_weight=\"1\"/>\n\n    <FrameLayout\n        android:id=\"@+id/container3\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"0dp\"\n        android:layout_weight=\"1\"/>\n</LinearLayout>"
  },
  {
    "path": "demo-androidx/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\"\n    tools:context=\".MainActivity\">\n\n    <LinearLayout\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:orientation=\"horizontal\">\n\n        <Button\n            android:layout_width=\"180dp\"\n            android:layout_height=\"100dp\"\n            android:background=\"@color/colorAccent\"\n            android:onClick=\"stop\"\n            android:text=\"stop\"\n            android:textColor=\"#fff\"\n            android:textSize=\"30sp\"/>\n\n        <Button\n            android:layout_width=\"180dp\"\n            android:layout_height=\"100dp\"\n            android:background=\"#0d0\"\n            android:onClick=\"restart\"\n            android:text=\"restart\"\n            android:textColor=\"#fff\"\n            android:textSize=\"30sp\"/>\n\n    </LinearLayout>\n\n    <Button\n        android:layout_width=\"360dp\"\n        android:layout_height=\"100dp\"\n        android:background=\"#fd0\"\n        android:onClick=\"goCustomAdaptActivity\"\n        android:text=\"CustomAdapt\"\n        android:textColor=\"#fff\"\n        android:textSize=\"25sp\"/>\n\n    <Button\n        android:layout_width=\"360dp\"\n        android:layout_height=\"100dp\"\n        android:background=\"#d00\"\n        android:text=\"W-360dp(total:360dp)\"\n        android:textColor=\"#fff\"\n        android:textSize=\"25sp\"/>\n\n\n    <LinearLayout\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:orientation=\"horizontal\">\n\n        <TextView\n            android:layout_width=\"250dp\"\n            android:layout_height=\"100dp\"\n            android:background=\"@color/colorPrimary\"\n            android:gravity=\"center\"\n            android:text=\"W-250dp\"\n            android:textColor=\"#0d0\"\n            android:textSize=\"20sp\"/>\n\n        <TextView\n            android:layout_width=\"1dp\"\n            android:layout_height=\"100dp\"\n            />\n\n        <TextView\n            android:layout_width=\"109dp\"\n            android:layout_height=\"100dp\"\n            android:background=\"#d0a\"\n            android:gravity=\"center\"\n            android:text=\"W-109dp\"\n            android:textColor=\"#0d0\"\n            android:textSize=\"20sp\"/>\n    </LinearLayout>\n\n    <LinearLayout\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"horizontal\">\n\n        <TextView\n            android:layout_width=\"120dp\"\n            android:layout_height=\"match_parent\"\n            android:background=\"#aef\"\n            android:gravity=\"center\"\n            android:text=\"W-120dp\"\n            android:textColor=\"#0d0\"\n            android:textSize=\"20sp\"/>\n\n        <TextView\n            android:layout_width=\"90dp\"\n            android:layout_height=\"match_parent\"\n            android:background=\"#acf\"\n            android:gravity=\"center\"\n            android:text=\"W-90dp\"\n            android:textColor=\"#0d0\"\n            android:textSize=\"20sp\"/>\n\n        <TextView\n            android:layout_width=\"150dp\"\n            android:layout_height=\"match_parent\"\n            android:background=\"#fcf\"\n            android:gravity=\"center\"\n            android:text=\"W-150dp\"\n            android:textColor=\"#0d0\"\n            android:textSize=\"20sp\"/>\n    </LinearLayout>\n\n</LinearLayout>"
  },
  {
    "path": "demo-androidx/src/main/res/mipmap-anydpi-v26/ic_launcher.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\"/>\n    <foreground android:drawable=\"@drawable/ic_launcher_foreground\"/>\n</adaptive-icon>"
  },
  {
    "path": "demo-androidx/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\"/>\n    <foreground android:drawable=\"@drawable/ic_launcher_foreground\"/>\n</adaptive-icon>"
  },
  {
    "path": "demo-androidx/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#FF4081</color>\n</resources>\n"
  },
  {
    "path": "demo-androidx/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">Androidx Demo</string>\n</resources>\n"
  },
  {
    "path": "demo-androidx/src/main/res/values/styles.xml",
    "content": "<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.NoActionBar\">\n        <!-- Customize your theme here. -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "demo-androidx/src/test/java/me/jessyan/autosize/demo/ExampleUnitTest.java",
    "content": "package me.jessyan.autosize.demo;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * Example local unit test, which will execute on the development machine (host).\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "demo-subunits/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "demo-subunits/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion rootProject.compileSdkVersion\n    buildToolsVersion rootProject.buildToolsVersion\n\n    defaultConfig {\n        applicationId \"me.jessyan.autosize.demo.subunits\"\n        minSdkVersion rootProject.minSdkVersion\n        targetSdkVersion rootProject.targetSdkVersion\n        versionCode rootProject.versionCode\n        versionName rootProject.versionName\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n//    implementation 'me.jessyan:autosize:1.2.1'\n    implementation project(':autosize')\n    implementation rootProject.appcompat_v7\n    testImplementation 'junit:junit:4.12'\n}\n"
  },
  {
    "path": "demo-subunits/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "demo-subunits/src/androidTest/java/me/jessyan/autosize/demo/ExampleInstrumentedTest.java",
    "content": "package me.jessyan.autosize.demo;\n\nimport android.content.Context;\nimport android.support.test.InstrumentationRegistry;\nimport android.support.test.runner.AndroidJUnit4;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport static org.junit.Assert.*;\n\n/**\n * Instrumented test, which will execute on an Android device.\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\n@RunWith(AndroidJUnit4.class)\npublic class ExampleInstrumentedTest {\n    @Test\n    public void useAppContext() {\n        // Context of the app under test.\n        Context appContext = InstrumentationRegistry.getTargetContext();\n\n        assertEquals(\"me.jessyan.autosize.demo\", appContext.getPackageName());\n    }\n}\n"
  },
  {
    "path": "demo-subunits/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n          package=\"me.jessyan.autosize.demo.subunits\">\n\n    <application\n        android:name=\"me.jessyan.autosize.demo.subunits.BaseApplication\"\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/autosize_logo\"\n        android:label=\"@string/app_name\"\n        android:supportsRtl=\"true\"\n        android:theme=\"@style/AppTheme\">\n        <activity android:name=\"me.jessyan.autosize.demo.subunits.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        <activity android:name=\"me.jessyan.autosize.demo.subunits.CustomAdaptActivity\"/>\n\n        <!-- 这个 Demo 主要展示副单位的用法, 如果只使用副单位 (pt、in、mm) 就可以直接以像素作为单位填写设计图的尺寸, 不需再把像素转化为 dp-->\n        <meta-data\n            android:name=\"design_width_in_dp\"\n            android:value=\"1080\"/>\n        <meta-data\n            android:name=\"design_height_in_dp\"\n            android:value=\"1920\"/>\n\n    </application>\n\n</manifest>"
  },
  {
    "path": "demo-subunits/src/main/java/me/jessyan/autosize/demo/subunits/BaseApplication.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo.subunits;\n\nimport android.app.Application;\nimport android.util.DisplayMetrics;\n\nimport me.jessyan.autosize.AutoSizeConfig;\nimport me.jessyan.autosize.unit.Subunits;\nimport me.jessyan.autosize.unit.UnitsManager;\n\n/**\n * ================================================\n * 本框架核心原理来自于 <a href=\"https://mp.weixin.qq.com/s/d9QCoBP6kV9VSWvVldVVwA\">今日头条官方适配方案</a>\n * <p>\n * 本框架源码的注释都很详细, 欢迎阅读学习\n * <p>\n * AndroidAutoSize 会在 APP 启动时自动完成初始化, 如果您想设置自定义参数可以在 {@link Application#onCreate()} 中设置\n * <p>\n * Created by JessYan on 2018/8/9 17:05\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class BaseApplication extends Application {\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        //对单位的自定义配置, 请在 App 启动时完成 \n        configUnits();\n    }\n\n    /**\n     * 注意!!! 布局时的实时预览在开发阶段是一个很重要的环节, 很多情况下 Android Studio 提供的默认预览设备并不能完全展示我们的设计图\n     * 所以我们就需要自己创建模拟设备, 以下链接是给大家的福利, 按照链接中的操作可以让预览效果和设计图完全一致!\n     * @see <a href=\"https://github.com/JessYanCoding/AndroidAutoSize/blob/master/README-zh.md#preview\">dp、pt、in、mm 这四种单位的模拟设备创建方法</a>\n     * <p>\n     * v0.9.0 以后, AndroidAutoSize 强势升级, 将这个方案做到极致, 现在支持5种单位 (dp、sp、pt、in、mm)\n     * {@link UnitsManager} 可以让使用者随意配置自己想使用的单位类型\n     * 其中 dp、sp 这两个是比较常见的单位, 作为 AndroidAutoSize 的主单位, 默认被 AndroidAutoSize 支持\n     * pt、in、mm 这三个是比较少见的单位, 只可以选择其中的一个, 作为 AndroidAutoSize 的副单位, 与 dp、sp 一起被 AndroidAutoSize 支持\n     * 副单位是用于规避修改 {@link DisplayMetrics#density} 所造成的对于其他使用 dp 布局的系统控件或三方库控件的不良影响\n     * 您选择什么单位, 就在 layout 文件中用什么单位布局\n     * <p>\n     * 两个主单位和一个副单位, 可以随时使用 {@link UnitsManager} 的方法关闭和重新开启对它们的支持\n     * 如果您想完全规避修改 {@link DisplayMetrics#density} 所造成的对于其他使用 dp 布局的系统控件或三方库控件的不良影响\n     * 那请调用 {@link UnitsManager#setSupportDP}、{@link UnitsManager#setSupportSP} 都设置为 {@code false}\n     * 停止对两个主单位的支持 (如果开启 sp, 对其他三方库控件影响不大, 也可以不关闭对 sp 的支持)\n     * 并调用 {@link UnitsManager#setSupportSubunits} 从三个冷门单位中选择一个作为副单位\n     * 三个单位的效果都是一样的, 按自己的喜好选择, 比如我就喜欢 mm, 翻译为中文是妹妹的意思\n     * 然后在 layout 文件中只使用这个副单位进行布局, 这样就可以完全规避修改 {@link DisplayMetrics#density} 所造成的不良影响\n     * 因为 dp、sp 这两个单位在其他系统控件或三方库控件中都非常常见, 但三个冷门单位却非常少见\n     */\n    private void configUnits() {\n        //AndroidAutoSize 默认开启对 dp 的支持, 调用 UnitsManager.setSupportDP(false); 可以关闭对 dp 的支持\n        //主单位 dp 和 副单位可以同时开启的原因是, 对于旧项目中已经使用了 dp 进行布局的页面的兼容\n        //让开发者的旧项目可以渐进式的从 dp 切换到副单位, 即新页面用副单位进行布局, 然后抽时间逐渐的将旧页面的布局单位从 dp 改为副单位\n        //最后将 dp 全部改为副单位后, 再使用 UnitsManager.setSupportDP(false); 将 dp 的支持关闭, 彻底隔离修改 density 所造成的不良影响\n        //如果项目完全使用副单位, 则可以直接以像素为单位填写 AndroidManifest 中需要填写的设计图尺寸, 不需再把像素转化为 dp\n        AutoSizeConfig.getInstance().getUnitsManager()\n                .setSupportDP(false)\n\n                //当使用者想将旧项目从主单位过渡到副单位, 或从副单位过渡到主单位时\n                //因为在使用主单位时, 建议在 AndroidManifest 中填写设计图的 dp 尺寸, 比如 360 * 640\n                //而副单位有一个特性是可以直接在 AndroidManifest 中填写设计图的 px 尺寸, 比如 1080 * 1920\n                //但在 AndroidManifest 中却只能填写一套设计图尺寸, 并且已经填写了主单位的设计图尺寸\n                //所以当项目中同时存在副单位和主单位, 并且副单位的设计图尺寸与主单位的设计图尺寸不同时, 可以通过 UnitsManager#setDesignSize() 方法配置\n                //如果副单位的设计图尺寸与主单位的设计图尺寸相同, 则不需要调用 UnitsManager#setDesignSize(), 框架会自动使用 AndroidManifest 中填写的设计图尺寸\n//                .setDesignSize(2160, 3840)\n\n                //AndroidAutoSize 默认开启对 sp 的支持, 调用 UnitsManager.setSupportSP(false); 可以关闭对 sp 的支持\n                //如果关闭对 sp 的支持, 在布局时就应该使用副单位填写字体的尺寸\n                //如果开启 sp, 对其他三方库控件影响不大, 也可以不关闭对 sp 的支持, 这里我就继续开启 sp, 请自行斟酌自己的项目是否需要关闭对 sp 的支持\n//                .setSupportSP(false)\n\n                //AndroidAutoSize 默认不支持副单位, 调用 UnitsManager#setSupportSubunits() 可选择一个自己心仪的副单位, 并开启对副单位的支持\n                //只能在 pt、in、mm 这三个冷门单位中选择一个作为副单位, 三个单位的适配效果其实都是一样的, 您觉的哪个单位看起顺眼就用哪个\n                //您选择什么单位就在 layout 文件中用什么单位进行布局, 我选择用 mm 为单位进行布局, 因为 mm 翻译为中文是妹妹的意思\n                //如果大家生活中没有妹妹, 那我们就让项目中最不缺的就是妹妹!\n                .setSupportSubunits(Subunits.MM);\n    }\n}\n"
  },
  {
    "path": "demo-subunits/src/main/java/me/jessyan/autosize/demo/subunits/CustomAdaptActivity.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo.subunits;\n\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\n\nimport me.jessyan.autosize.internal.CustomAdapt;\n\n/**\n * ================================================\n * 本框架核心原理来自于 <a href=\"https://mp.weixin.qq.com/s/d9QCoBP6kV9VSWvVldVVwA\">今日头条官方适配方案</a>\n * <p>\n * Created by JessYan on 2018/8/11 11:31\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class CustomAdaptActivity extends AppCompatActivity implements CustomAdapt {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_custom_adapt);\n    }\n\n    /**\n     * 是否按照宽度进行等比例适配 (为了保证在高宽比不同的屏幕上也能正常适配, 所以只能在宽度和高度之中选择一个作为基准进行适配)\n     *\n     * @return {@code true} 为按照宽度进行适配, {@code false} 为按照高度进行适配\n     */\n    @Override\n    public boolean isBaseOnWidth() {\n        return false;\n    }\n\n    /**\n     * 这里使用 iPhone 的设计图, iPhone 的设计图尺寸为 750px * 1334px, 因为这个页面使用副单位进行布局\n     * 所以可以直接以像素作为单位返回设计图的尺寸\n     * <p>\n     * 返回设计图上的设计尺寸\n     * {@link #getSizeInDp} 须配合 {@link #isBaseOnWidth()} 使用, 规则如下:\n     * 如果 {@link #isBaseOnWidth()} 返回 {@code true}, {@link #getSizeInDp} 则应该返回设计图的总宽度\n     * 如果 {@link #isBaseOnWidth()} 返回 {@code false}, {@link #getSizeInDp} 则应该返回设计图的总高度\n     * 如果您不需要自定义设计图上的设计尺寸, 想继续使用在 AndroidManifest 中填写的设计图尺寸, {@link #getSizeInDp} 则返回 {@code 0}\n     *\n     * @return 设计图上的设计尺寸\n     */\n    @Override\n    public float getSizeInDp() {\n        return 1334;\n    }\n}\n"
  },
  {
    "path": "demo-subunits/src/main/java/me/jessyan/autosize/demo/subunits/MainActivity.java",
    "content": "/*\n * Copyright 2018 JessYan\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 */\npackage me.jessyan.autosize.demo.subunits;\n\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\nimport android.view.View;\n\n/**\n * ================================================\n * 本框架核心原理来自于 <a href=\"https://mp.weixin.qq.com/s/d9QCoBP6kV9VSWvVldVVwA\">今日头条官方适配方案</a>\n * <p>\n * Created by JessYan on 2018/8/9 17:05\n * <a href=\"mailto:jess.yan.effort@gmail.com\">Contact me</a>\n * <a href=\"https://github.com/JessYanCoding\">Follow me</a>\n * ================================================\n */\npublic class MainActivity extends AppCompatActivity {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n    }\n\n    /**\n     * 跳转到 {@link CustomAdaptActivity}, 展示项目内部的 {@link Activity} 自定义适配参数的用法\n     *\n     * @param view {@link View}\n     */\n    public void goCustomAdaptActivity(View view) {\n        startActivity(new Intent(getApplicationContext(), CustomAdaptActivity.class));\n    }\n}\n"
  },
  {
    "path": "demo-subunits/src/main/res/drawable/ic_launcher_background.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<vector\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:width=\"108dp\"\n    android:height=\"108dp\"\n    android:viewportHeight=\"108\"\n    android:viewportWidth=\"108\">\n    <path\n        android:fillColor=\"#26A69A\"\n        android:pathData=\"M0,0h108v108h-108z\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M9,0L9,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,0L19,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M29,0L29,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M39,0L39,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M49,0L49,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M59,0L59,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M69,0L69,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M79,0L79,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M89,0L89,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M99,0L99,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,9L108,9\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,19L108,19\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,29L108,29\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,39L108,39\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,49L108,49\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,59L108,59\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,69L108,69\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,79L108,79\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,89L108,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,99L108,99\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,29L89,29\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,39L89,39\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,49L89,49\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,59L89,59\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,69L89,69\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,79L89,79\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M29,19L29,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M39,19L39,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M49,19L49,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M59,19L59,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M69,19L69,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M79,19L79,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n</vector>\n"
  },
  {
    "path": "demo-subunits/src/main/res/drawable-v24/ic_launcher_foreground.xml",
    "content": "<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        xmlns:aapt=\"http://schemas.android.com/aapt\"\n        android:width=\"108dp\"\n        android:height=\"108dp\"\n        android:viewportHeight=\"108\"\n        android:viewportWidth=\"108\">\n    <path\n        android:fillType=\"evenOdd\"\n        android:pathData=\"M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z\"\n        android:strokeColor=\"#00000000\"\n        android:strokeWidth=\"1\">\n        <aapt:attr name=\"android:fillColor\">\n            <gradient\n                android:endX=\"78.5885\"\n                android:endY=\"90.9159\"\n                android:startX=\"48.7653\"\n                android:startY=\"61.0927\"\n                android:type=\"linear\">\n                <item\n                    android:color=\"#44000000\"\n                    android:offset=\"0.0\"/>\n                <item\n                    android:color=\"#00000000\"\n                    android:offset=\"1.0\"/>\n            </gradient>\n        </aapt:attr>\n    </path>\n    <path\n        android:fillColor=\"#FFFFFF\"\n        android:fillType=\"nonZero\"\n        android:pathData=\"M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z\"\n        android:strokeColor=\"#00000000\"\n        android:strokeWidth=\"1\"/>\n</vector>\n"
  },
  {
    "path": "demo-subunits/src/main/res/layout/activity_custom_adapt.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"horizontal\"\n    tools:context=\".CustomAdaptActivity\">\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:orientation=\"vertical\">\n\n        <TextView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"496mm\"\n            android:background=\"@color/colorPrimary\"\n            android:gravity=\"center\"\n            android:text=\"H-496mm\\n(Height Total:1334mm)\"\n            android:textColor=\"#fff\"\n            android:textSize=\"50sp\"/>\n\n        <TextView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"2mm\"\n            android:background=\"#fff\"\n            />\n\n        <TextView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"200mm\"\n            android:background=\"#0f3\"\n            android:gravity=\"center\"\n            android:text=\"H-200mm\"\n            android:textColor=\"#fff\"\n            android:textSize=\"50sp\"\n            />\n\n        <TextView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"250mm\"\n            android:background=\"#d0f\"\n            android:gravity=\"center\"\n            android:text=\"H-250mm\"\n            android:textColor=\"#fff\"\n            android:textSize=\"50sp\"/>\n\n        <TextView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"386mm\"\n            android:background=\"#d21\"\n            android:gravity=\"center\"\n            android:text=\"H-386mm\"\n            android:textColor=\"#fff\"\n            android:textSize=\"50sp\"/>\n    </LinearLayout>\n</LinearLayout>"
  },
  {
    "path": "demo-subunits/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\"\n    tools:context=\".MainActivity\">\n\n    <LinearLayout\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:orientation=\"horizontal\">\n\n        <TextView\n            android:layout_width=\"540mm\"\n            android:layout_height=\"300mm\"\n            android:background=\"@color/colorAccent\"\n            android:gravity=\"center\"\n            android:text=\"W-540mm\"\n            android:textColor=\"#fff\"\n            android:textSize=\"70sp\"/>\n\n        <TextView\n            android:layout_width=\"540mm\"\n            android:layout_height=\"300mm\"\n            android:background=\"#0d0\"\n            android:gravity=\"center\"\n            android:text=\"W-540mm\"\n            android:textColor=\"#fff\"\n            android:textSize=\"70sp\"/>\n\n    </LinearLayout>\n\n    <Button\n        android:layout_width=\"1080mm\"\n        android:layout_height=\"300mm\"\n        android:background=\"#fd0\"\n        android:onClick=\"goCustomAdaptActivity\"\n        android:text=\"CustomAdapt\"\n        android:textColor=\"#0d0\"\n        android:textSize=\"70sp\"/>\n\n    <TextView\n        android:layout_width=\"1080mm\"\n        android:layout_height=\"300mm\"\n        android:background=\"#d00\"\n        android:gravity=\"center\"\n        android:text=\"W-1080mm(total:1080mm)\"\n        android:textColor=\"#fff\"\n        android:textSize=\"70sp\"/>\n\n\n    <LinearLayout\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:orientation=\"horizontal\">\n\n        <TextView\n            android:layout_width=\"750mm\"\n            android:layout_height=\"300mm\"\n            android:background=\"@color/colorPrimary\"\n            android:gravity=\"center\"\n            android:text=\"W-750mm\"\n            android:textColor=\"#fff\"\n            android:textSize=\"50sp\"/>\n\n        <TextView\n            android:layout_width=\"2mm\"\n            android:layout_height=\"300mm\"\n            android:gravity=\"center\"\n            />\n\n        <TextView\n            android:layout_width=\"328mm\"\n            android:layout_height=\"300mm\"\n            android:background=\"#d0a\"\n            android:gravity=\"center\"\n            android:text=\"W-328mm\"\n            android:textColor=\"#fff\"\n            android:textSize=\"50sp\"/>\n    </LinearLayout>\n\n    <LinearLayout\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"horizontal\">\n\n        <TextView\n            android:layout_width=\"360mm\"\n            android:layout_height=\"match_parent\"\n            android:background=\"#aef\"\n            android:gravity=\"center\"\n            android:text=\"W-360mm\"\n            android:textColor=\"#fff\"\n            android:textSize=\"50sp\"/>\n\n        <TextView\n            android:layout_width=\"270mm\"\n            android:layout_height=\"match_parent\"\n            android:background=\"#acf\"\n            android:gravity=\"center\"\n            android:text=\"W-270mm\"\n            android:textColor=\"#fff\"\n            android:textSize=\"50sp\"/>\n\n        <TextView\n            android:layout_width=\"450mm\"\n            android:layout_height=\"match_parent\"\n            android:background=\"#fcf\"\n            android:gravity=\"center\"\n            android:text=\"W-450mm\"\n            android:textColor=\"#fff\"\n            android:textSize=\"50sp\"/>\n    </LinearLayout>\n\n</LinearLayout>"
  },
  {
    "path": "demo-subunits/src/main/res/mipmap-anydpi-v26/ic_launcher.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\"/>\n    <foreground android:drawable=\"@drawable/ic_launcher_foreground\"/>\n</adaptive-icon>"
  },
  {
    "path": "demo-subunits/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\"/>\n    <foreground android:drawable=\"@drawable/ic_launcher_foreground\"/>\n</adaptive-icon>"
  },
  {
    "path": "demo-subunits/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#FF4081</color>\n</resources>\n"
  },
  {
    "path": "demo-subunits/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">Subunits Demo</string>\n</resources>\n"
  },
  {
    "path": "demo-subunits/src/main/res/values/styles.xml",
    "content": "<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.NoActionBar\">\n        <!-- Customize your theme here. -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "demo-subunits/src/test/java/me/jessyan/autosize/demo/ExampleUnitTest.java",
    "content": "package me.jessyan.autosize.demo;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * Example local unit test, which will execute on the development machine (host).\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Mon Jan 20 10:23:47 CST 2020\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-5.4.1-all.zip\n"
  },
  {
    "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\n"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env sh\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn () {\n    echo \"$*\"\n}\n\ndie () {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\nnonstop=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\n  NONSTOP* )\n    nonstop=true\n    ;;\nesac\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" -a \"$nonstop\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Escape application args\nsave () {\n    for i do printf %s\\\\n \"$i\" | sed \"s/'/'\\\\\\\\''/g;1s/^/'/;\\$s/\\$/' \\\\\\\\/\" ; done\n    echo \" \"\n}\nAPP_ARGS=$(save \"$@\")\n\n# Collect all arguments for the java command, following the shell quoting and substitution rules\neval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS \"\\\"-Dorg.gradle.appname=$APP_BASE_NAME\\\"\" -classpath \"\\\"$CLASSPATH\\\"\" org.gradle.wrapper.GradleWrapperMain \"$APP_ARGS\"\n\n# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong\nif [ \"$(uname)\" = \"Darwin\" ] && [ \"$HOME\" = \"$PWD\" ]; then\n  cd \"$(dirname \"$0\")\"\nfi\n\nexec \"$JAVACMD\" \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@rem  Gradle startup script for Windows\r\n@rem\r\n@rem ##########################################################################\r\n\r\n@rem Set local scope for the variables with windows NT shell\r\nif \"%OS%\"==\"Windows_NT\" setlocal\r\n\r\nset DIRNAME=%~dp0\r\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\r\nset APP_BASE_NAME=%~n0\r\nset APP_HOME=%DIRNAME%\r\n\r\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\r\nset DEFAULT_JVM_OPTS=\r\n\r\n@rem Find java.exe\r\nif defined JAVA_HOME goto findJavaFromJavaHome\r\n\r\nset JAVA_EXE=java.exe\r\n%JAVA_EXE% -version >NUL 2>&1\r\nif \"%ERRORLEVEL%\" == \"0\" goto init\r\n\r\necho.\r\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:findJavaFromJavaHome\r\nset JAVA_HOME=%JAVA_HOME:\"=%\r\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\r\n\r\nif exist \"%JAVA_EXE%\" goto init\r\n\r\necho.\r\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:init\r\n@rem Get command-line arguments, handling Windows variants\r\n\r\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\r\n\r\n:win9xME_args\r\n@rem Slurp the command line arguments.\r\nset CMD_LINE_ARGS=\r\nset _SKIP=2\r\n\r\n:win9xME_args_slurp\r\nif \"x%~1\" == \"x\" goto execute\r\n\r\nset CMD_LINE_ARGS=%*\r\n\r\n:execute\r\n@rem Setup the command line\r\n\r\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\r\n\r\n@rem Execute Gradle\r\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\r\n\r\n:end\r\n@rem End local scope for the variables with windows NT shell\r\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\r\n\r\n:fail\r\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\r\nrem the _cmd.exe /c_ return code!\r\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\r\nexit /b 1\r\n\r\n:mainEnd\r\nif \"%OS%\"==\"Windows_NT\" endlocal\r\n\r\n:omega\r\n"
  },
  {
    "path": "settings.gradle",
    "content": "include ':demo', ':demo-subunits', ':demo-androidx',':autosize'\n"
  }
]