diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000000..750e8ac81a --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/donate.png diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE/bug_report.md similarity index 77% rename from .github/ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE/bug_report.md index daea781567..e29c2e45b6 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,8 +1,16 @@ +--- +name: Bug report +about: Make AndroidUtilCode more perfect! +labels: bug +assignees: Blankj + +--- + ## Describe the bug A clear and concise description of what the bug is. -- The version of utilcode: +- The version of AndroidUtilCode: - The device: - The version of device: @@ -39,6 +47,6 @@ put the stack of crash here If applicable, add screenshots to help explain your problem. -Please delete the current line and the followings. +## Please delete the current line and the following. -Thank you for supporting [AndroidUtilCode](https://github.com/Blankj/AndroidUtilCode). \ No newline at end of file +Thank you for supporting [AndroidUtilCode](https://github.com/Blankj/AndroidUtilCode). diff --git a/.github/ISSUE_TEMPLATE/bug_report_cn.md b/.github/ISSUE_TEMPLATE/bug_report_cn.md new file mode 100644 index 0000000000..02ea0223e3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report_cn.md @@ -0,0 +1,52 @@ +--- +name: 提交 Bug +about: 让工具类更完美! +labels: bug +assignees: Blankj + +--- + +## 描述 Bug + +简洁地描述下 Bug。 + +- AndroidUtilCode 的版本: +- 出现 Bug 的设备型号: +- 设备的 Android 版本: + +## 相关代码 + + +``` +put your code here +``` + +## 异常堆栈 + + + +``` +put the stack of crash here +``` + +## 截图 + +如果有的话请添加屏幕截图以帮助解释问题。 + + +## 请删除当前行及以下内容 + +感谢支持 [AndroidUtilCode](https://github.com/Blankj/AndroidUtilCode). diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md new file mode 100644 index 0000000000..90a0fe1993 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -0,0 +1,21 @@ +--- +name: Feature request +about: Make AndroidUtilCode more perfect! +labels: help wanted +assignees: Blankj + +--- + +## Describe the feature + +A clear and concise description of what the feature is. + + +## Reference + +Hope to give some reference articles, links, code, if any. + + +## Please delete the current line and the following + +Thank you for supporting [AndroidUtilCode](https://github.com/Blankj/AndroidUtilCode). diff --git a/.github/ISSUE_TEMPLATE/feature-request_cn.md b/.github/ISSUE_TEMPLATE/feature-request_cn.md new file mode 100644 index 0000000000..20862d047b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request_cn.md @@ -0,0 +1,21 @@ +--- +name: 提交需求 +about: 让工具类更健全! +labels: help wanted +assignees: Blankj + +--- + +## 描述需求 + +简洁地描述下需求。 + + +## 可借鉴的 + +如果有的话,可以给出一些参考文章、链接、代码 + + +## 请删除当前行及以下内容 + +感谢支持 [AndroidUtilCode](https://github.com/Blankj/AndroidUtilCode). diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 0000000000..311fc1deaa --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,17 @@ +name: Android CI + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build with Gradle + run: ./gradlew build aR diff --git a/.gitignore b/.gitignore index 9bf2876a4e..9d11f56a24 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,15 @@ *.iml +__api__.json +__bus__.json .gradle -/local.properties +local.properties .idea .DS_Store /build /captures .externalNativeBuild /apk -/maven -__bus__.json \ No newline at end of file +*.phrof +/mavenLocal +/reports +*/reports \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b4e77e194d..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: android -jdk: oraclejdk8 -sudo: false - -android: - components: - - tools - - platform-tools - - build-tools-27.0.2 - - android-27 - - add-on - - extra - - licenses: - - 'android-sdk-license-.+' - - notifications: - email: false - -before_install: - - yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;26.0.2" - -script: - - ./gradlew build connectedCheck --info diff --git a/CHANGELOG.md b/CHANGELOG.md index 0012fe5ae7..73e8145bf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,140 @@ +* `22/10/15` [add] Fix some issue. Publish v1.31.1 +* `21/12/06` [add] Publish v1.31.0 +* `21/05/13` [add] Support publish mavenCentral. +* `21/02/22` [add] Fix ToastUtils rtl bug. Publish v1.30.6. +* `20/11/16` [add] Add ImageUtils#save2Album support param of dirName. +* `20/11/13` [add] Fix MessengerUtils ANR. Add NetworkUtils#getWifiScanResult, [add|remove]OnWifiChangedConsumer. Publish v1.30.5. +* `20/10/29` [add] Fix MessengerUtils startService IllegalStateException. Publish v1.30.4. +* `20/10/28` [add] Fix BusUtils ConcurrentModificationException. Publish v1.30.3. +* `20/10/27` [add] Fix AppUtils#getAppSignatures. Add DeviceUtils#isDevelopmentSettingsEnabled. Publish v1.30.2. +* `20/10/26` [add] Fix AppUtils#isAppForeground. Publish v1.30.1. +* `20/10/24` [add] Publish v1.30.0. +* `20/10/23` [fix] LanguageUtils crash on some device. +* `20/10/21` [add] LogUtils.Config#setOnConsoleOutputListener, setOnFileOutputListener, addFileExtraHead. LogUtils.getCurrentLogFilePath. +* `20/10/20` [opt] ToastUtils. +* `20/10/12` [add] PermissionUtils#explain. +* `20/10/10` [add] ClipboardUtils. +* `20/10/08` [add] VolumeUtils. +* `20/09/06` [add] DebouncingUtils#isValid. +* `20/09/04` [fix] ToastUtils adapt SDK 30. +* `20/05/28` [fix] IntentUtils#getInstallAppIntent file exist wrong. Publish v1.29.0. +* `20/05/23` [fix] BusUtils#postSticky times not right. Publish v1.28.6. +* `20/05/22` [add] IntentUtils#getInstallAppIntent support Uri param. +* `20/05/21` [add] Publish bus plugin v2.6. Publish api plugin v1.4. Publish. Publish v1.28.5. +* `20/05/19` [fix] FileUtils#copyOrMoveDird NPE. +* `20/05/18` [add] IntentUtils#getLaunchAppDetailsSettingsIntent support isNewTask. +* `20/05/17` [add] ImageUtils#save2Album, NetworkUtils#getSSID, UtilsTransActivity4MainProcess. +* `20/05/03` [add] Publish bus plugin v2.5. Publish api plugin v1.3. Publish. Publish v1.28.4. +* `20/04/30` [add] BaseItem support partialUpdate. +* `20/04/29` [add] Publish plugin lib com.blankj:base-transform:1.0. +* `20/04/28` [fix] LanguageUtils#applyLanguage. +* `20/04/27` [fix] BarUtils#isNavBarVisible. +* `20/04/26` [fix] Utils#init fit tinker. Publish v1.28.3. +* `20/04/25` [fix] UriUtils#uri2File Unknown URI. Publish 1.28.2. +* `20/04/24` [add] SnackbarUtils support show on the top; UriUtils#uri2InputStream. +* `20/04/23` [fix] UriUtils#uri2File not support HW; TransActivity crash below 21. +* `20/04/23` [fix] PhoneUtils#getSerial, PhoneUtils#getSerial crash on Android 10. +* `20/04/20` [fix] ImageUtils#isImage. +* `20/04/18` [fix] PermissionUtils#callback. Publish v1.28.1. +* `20/04/17` [fix] ImageUtils#view2Bitmap, ImageUtils.getBitmap(InputStream). +* `20/04/16` [add] ConvertUtils#int2HexString, hexString2Int. +* `20/04/15` [add] UiMessageUtils' demo. +* `20/04/13` [add] NumberUtils. Publish v1.28.0. +* `20/04/12` [opt] TimeUtils#SDF_THREAD_LOCAL. +* `20/04/11` [add] SDCardUtils#getXxTotalSize, SDCardUtils#getXxAvailableSize. FileUtils#getFsTotalSize, FileUtils#getFsAvailableSize. +* `20/04/10` [fix] FileUtils#isFileExists; FragmentUtils#getTop bug. Publish v1.27.6. +* `20/04/09` [add] UriUtils#res2Uri, UriUtils#uri2File support QQBrowser; ThreadUtils#getMainHandler; PathUtils#getxxPathExternalFirst. +* `20/04/08` [fix] ActivityUtils#finish bug. Publish v1.27.5. +* `20/04/08` [fix] CleanUtils clean dir not work. FileUtils#isFileExists. Publish v1.27.4. +* `20/04/08` [fix] CrashUtils DefaultUncaughtExceptionHandler is wrong; LogUtils write file failed; Utils#getApp failed run on remote process. Publish v1.27.3. +* `20/04/07` [mdf] GsonUtils#getGson() method public. +* `20/04/04` [fix] ShadowUtils bug running on lower version devices. Publish v1.27.2. +* `20/04/03` [fix] UtilsActivityLifecycleImpl#HashMap#remove IllegalStateException bug. +* `20/04/02` [fix] PathUtils sdcard enable state is wrong; ActivityUtils finish activity wrong; Publish v1.27.1. +* `20/03/31` [add] Publish v1.27.0. +* `20/03/30` [add] BatteryUtils in subutil. +* `20/03/27` [add] publish.gradle. +* `20/03/24` [add] UtilsBridge to clean the utils. +* `20/03/22` [upd] GsonUtils support custom gson. +* `20/03/20` [add] ActivityUtils#addActivityLifecycleCallbacks, ActivityUtils#removeActivityLifecycleCallbacks. +* `20/01/17` [upd] Leak Canary to v2.1. +* `20/01/06` [add] ClickUtils#expandClickArea, ClickUtils#back2HomeFriendly +* `19/11/30` [add] Publish bus plugin v2.4. Publish api plugin v1.2. +* `19/11/28` [add] Publish v1.26.0. +* `19/11/27` [add] Shadow demo. +* `19/11/26` [add] MVP demo. +* `19/11/22` [fix] Adapt the project for Gradle version of 6.0. +* `19/10/30` [add] Publish bus plugin v2.3. Publish api plugin v1.1. +* `19/10/24` [upd] Demo's UI. +* `19/10/22` [add] NotificationUtils and demo. +* `19/10/20` [add] UiMessageUtils. +* `19/09/20` [add] ShadowUtils. +* `19/08/27` [add] DebugUtils. +* `19/08/26` [fix] PermissionUtils NPE. +* `19/08/25` [upd] ImageUtils#getImageType. [add] LogUtils#getLogFiles. Publish v1.25.9. +* `19/08/24` [fix] PhoneUtils#getIMEI crash on SDK 29. +* `19/08/23` [add] ViewUtils#isLayoutRtl. +* `19/08/22` [add] LogUtils#getLogFiles. +* `19/08/13` [add] MapUtils and MapUtilsTest. Publish v1.25.8. +* `19/08/12` [add] CollectionUtils and CollectionUtilsTest. +* `19/08/11` [add] ArrayUtils and ArrayUtilsTest. +* `19/08/09` [fix] https://www.virustotal.com/gui/home/upload with ESET-NOD32. Publish v1.25.7. +* `19/08/08` [add] BusUtils#post tag support one-to-many. Publish v1.25.6. +* `19/08/04` [add] ThreadUtils#Task support timeout. +* `19/08/01` [upd] EncryptUtils#rsa. +* `19/07/31` [add] DeviceUtils#getUniqueDeviceId, DeviceUtils#isSameDevice. Publish v1.25.5. +* `19/07/30` [fix] ThreadUtils's task can only be executed once. PhoneUtils#getIMEI wrong. +* `19/07/29` [fix] BusUtils post father class useless. KeyboardUtils#hideSoft bug. Publish v1.25.4. +* `19/07/28` [add] NetworkUtils#(un)registerNetworkStatusChangedListener. Publish v1.25.3. +* `19/07/27` [fix] ThreadUtils memory leak. +* `19/07/26` [add] ContainerUtils. Publish v1.25.2. +* `19/07/25` [fix] PermissionUtils' NullPointException. +* `19/07/24` [fix] ZipUtils#unzipFile. +* `19/07/23` [fix] ThreadUtils of cache pool. Publish v1.25.1. +* `19/07/18` [add] README of ApiUtils and BusUtils. +* `19/07/15` [add] Publish v1.25.0. +* `19/07/14` [upd] Bus plugin for use BusUtils. Publish bus plugin v2.0. +* `19/07/13` [add] Api plugin for use ApiUtils. Publish api plugin v1.0. +* `19/07/09` [upd] The frame of project. +* `19/07/06` [upd] BusUtils which behave same as EventBus. +* `19/07/03` [add] ApiUtils which decoupling modules. +* `19/06/30` [add] LanguageUtils support activity's class name. +* `19/06/29` [add] ClickUtils#OnMultiClickListener, and remove dangerous function. Publish v1.24.6. +* `19/06/28` [add] LanguageUtils. Publish v1.24.5. +* `19/06/20` [fix] BusUtils' permission. Publish v1.24.4. +* `19/06/19` [fix] UriUtils. Publish v1.24.3. +* `19/06/18` [add] ClickUtils, ViewUtils. +* `19/06/07` [fix] LogUtils file name contains ':'. Publish v1.24.2. +* `19/06/06` [fix] LogUtils write to file. Publish v1.24.1. +* `19/06/03` [fix] Refactoring framework. Publish v1.24.0. +* `19/04/25` [fix] LogUtils delete due log. +* `19/04/24` [upd] The swipe panel. +* `19/03/17` [fix] The ugly UI. +* `19/03/14` [fix] AdaptScreenUtils didn't work on some HaWei tablet. +* `19/03/09` [fix] UriUtils#uri2File. +* `19/03/08` [add] LogUtils support multi process. Publish v1.23.7. +* `19/03/02` [fix] LogUtils#file. +* `19/02/28` [fix] ImageUtils#calculateInSampleSize. Publish v1.23.6. +* `19/02/26` [fix] UriUtils#uri2File. Publish v1.23.5. +* `19/01/31` [add] HttpUtils. +* `19/01/30` [add] RomUtils. Publish v1.23.4. +* `19/01/29` [fix] LogUtils format json when json not start with '{'. Publish v1.23.3. +* `19/01/28` [fix] KeyboardUtils#fixSoftInputLeaks don't work on the device of HuaWei. +* `19/01/26` [fix] NetworkUtils#getNetworkType. +* `19/01/25` [add] CloneUtils, PermissionUtils support request permission of WRITE_SETTINGS and DRAW_OVERLAYS. Publish v1.23.2. +* `19/01/24` [add] BrightnessUtils and FlashlightUtils. +* `19/01/23` [add] Modify the demo of utilcode use kotlin. Publish v1.23.1. +* `19/01/22` [fix] AppUtils#installApp. +* `19/01/17` [fix] Publish v1.23.0. +* `19/01/16` [fix] BarUtils get Activity from view and delete the function of set status bar alpha. +* `19/01/15` [add] ColorUtils. +* `19/01/04` [add] CacheDiskStaticUtils, CacheDoubleStaticUtils, CacheMemoryStaticUtils. +* `19/01/03` [add] SPStaticUtils. +* `19/01/02` [fix] LogUtils log object. Publish v1.22.10. +* `19/01/01` [add] GsonUtils. +* `18/12/29` [add] AntiShakeUtils and VibrateUtils. Publish v1.22.9. +* `18/12/28` [fix] ToastUtils show behind the dialog when close notification. +* `18/12/27` [fix] LogUtils print StringBuilder failed. * `18/12/24` [fix] Utils$ActivityLifecycleImpl.consumeOnActivityDestroyedListener ConcurrentModificationException. Publish v1.22.7. * `18/12/22` [fix] AdaptScreenUtils#pt2px don't work when start webview. Publish v1.22.6. * `18/12/21` [add] LogUtils support print Map, Collection and Object to String. diff --git a/README-CN.md b/README-CN.md index 09c5ba26c1..5c85dca1fe 100644 --- a/README-CN.md +++ b/README-CN.md @@ -1,6 +1,8 @@ -![logo][logo] +[![logo][logo]](https://github.com/Blankj/AndroidUtilCode) -[![auc][aucSvg]][auc] [![api][apiSvg]][api] [![build][buildSvg]][build] [![License][licenseSvg]][license] +[![frame][frame]](https://github.com/Blankj/AucFrameTemplate) + +[![auc][aucSvg]][auc] [![result][apiSvg]][result] [![build][buildSvg]][build] [![License][licenseSvg]][license] ## [README of English][readme] @@ -38,14 +40,20 @@ ## [Change Log][changeLog.md] +## 打个小广告 + +欢迎加入我的小专栏「**[基你太美](https://xiaozhuanlan.com/Blankj)**」一起学习。 + [logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png -[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.22.7-brightgreen.svg +[frame]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/auc_frame_cn.png + +[aucSvg]: https://github.com/Blankj/AndroidUtilCode/workflows/Android%20CI/badge.svg?branch=master [auc]: https://github.com/Blankj/AndroidUtilCode [apiSvg]: https://img.shields.io/badge/API-14+-brightgreen.svg -[api]: https://android-arsenal.com/api?level=14 +[result]: https://android-arsenal.com/result?level=14 [buildSvg]: https://travis-ci.org/Blankj/AndroidUtilCode.svg?branch=master [build]: https://travis-ci.org/Blankj/AndroidUtilCode @@ -56,11 +64,11 @@ [readme]: https://github.com/Blankj/AndroidUtilCode [readme-cn]: https://github.com/Blankj/AndroidUtilCode/blob/master/README-CN.md -[utilcode]: https://github.com/Blankj/AndroidUtilCode/blob/master/utilcode/README.md -[utilcode-cn]: https://github.com/Blankj/AndroidUtilCode/blob/master/utilcode/README-CN.md +[utilcode]: https://github.com/Blankj/AndroidUtilCode/blob/master/lib/utilcode/README.md +[utilcode-cn]: https://github.com/Blankj/AndroidUtilCode/blob/master/lib/utilcode/README-CN.md -[subutil]: https://github.com/Blankj/AndroidUtilCode/blob/master/subutil/README.md -[subutil-cn]: https://github.com/Blankj/AndroidUtilCode/blob/master/subutil/README-CN.md +[subutil]: https://github.com/Blankj/AndroidUtilCode/blob/master/lib/subutil/README.md +[subutil-cn]: https://github.com/Blankj/AndroidUtilCode/blob/master/lib/subutil/README-CN.md [changeLog.md]: https://github.com/Blankj/AndroidUtilCode/blob/master/CHANGELOG.md diff --git a/README.md b/README.md index ad4d21a999..9ae668e26e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ -![logo][logo] +[![logo][logo]](https://github.com/Blankj/AndroidUtilCode) -[![auc][aucSvg]][auc] [![api][apiSvg]][api] [![build][buildSvg]][build] [![License][licenseSvg]][license] +[![frame][frame]](https://github.com/Blankj/AucFrameTemplate) + +[![auc][aucSvg]][auc] [![result][apiSvg]][result] [![build][buildSvg]][build] [![License][licenseSvg]][license] ## [README of Chinese][readme-cn] @@ -38,14 +40,20 @@ If this project helps you a lot and you want to support the project's developmen ## [Change Log][changeLog.md] +## 打个小广告 + +欢迎加入我的小专栏「**[基你太美](https://xiaozhuanlan.com/Blankj)**」一起学习。 + [logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png -[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.22.7-brightgreen.svg +[frame]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/auc_frame.png + +[aucSvg]: https://github.com/Blankj/AndroidUtilCode/workflows/Android%20CI/badge.svg?branch=master [auc]: https://github.com/Blankj/AndroidUtilCode [apiSvg]: https://img.shields.io/badge/API-14+-brightgreen.svg -[api]: https://android-arsenal.com/api?level=14 +[result]: https://android-arsenal.com/result?level=14 [buildSvg]: https://travis-ci.org/Blankj/AndroidUtilCode.svg?branch=master [build]: https://travis-ci.org/Blankj/AndroidUtilCode @@ -56,11 +64,11 @@ If this project helps you a lot and you want to support the project's developmen [readme]: https://github.com/Blankj/AndroidUtilCode [readme-cn]: https://github.com/Blankj/AndroidUtilCode/blob/master/README-CN.md -[utilcode]: https://github.com/Blankj/AndroidUtilCode/blob/master/utilcode/README.md -[utilcode-cn]: https://github.com/Blankj/AndroidUtilCode/blob/master/utilcode/README-CN.md +[utilcode]: https://github.com/Blankj/AndroidUtilCode/blob/master/lib/utilcode/README.md +[utilcode-cn]: https://github.com/Blankj/AndroidUtilCode/blob/master/lib/utilcode/README-CN.md -[subutil]: https://github.com/Blankj/AndroidUtilCode/blob/master/subutil/README.md -[subutil-cn]: https://github.com/Blankj/AndroidUtilCode/blob/master/subutil/README-CN.md +[subutil]: https://github.com/Blankj/AndroidUtilCode/blob/master/lib/subutil/README.md +[subutil-cn]: https://github.com/Blankj/AndroidUtilCode/blob/master/lib/subutil/README-CN.md [changeLog.md]: https://github.com/Blankj/AndroidUtilCode/blob/master/CHANGELOG.md diff --git a/art/auc_frame.png b/art/auc_frame.png new file mode 100644 index 0000000000..68c92d37b1 Binary files /dev/null and b/art/auc_frame.png differ diff --git a/art/auc_frame_cn.png b/art/auc_frame_cn.png new file mode 100644 index 0000000000..2382c03197 Binary files /dev/null and b/art/auc_frame_cn.png differ diff --git a/art/busutil_vs_eventbus.png b/art/busutil_vs_eventbus.png new file mode 100644 index 0000000000..1a2272b808 Binary files /dev/null and b/art/busutil_vs_eventbus.png differ diff --git a/art/communication.png b/art/communication.png new file mode 100644 index 0000000000..f3d68d0b10 Binary files /dev/null and b/art/communication.png differ diff --git a/art/logo_static_bus.png b/art/logo_static_bus.png deleted file mode 100755 index 4f5308a13a..0000000000 Binary files a/art/logo_static_bus.png and /dev/null differ diff --git a/build.gradle b/build.gradle index 6a8c9055e5..e0f0f36c87 100644 --- a/build.gradle +++ b/build.gradle @@ -1,26 +1,26 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - apply from: 'config.gradle' + ConfigUtils.init(gradle) repositories { - if (bus.isDebug) { - maven() { - url uri(new File(project.rootDir, "maven")) - } - } + mavenLocal() google() + mavenCentral() jcenter() } dependencies { - for (plugin in dep.plugin) { - classpath plugin + for (def entrySet : ConfigUtils.getApplyPlugins().entrySet()) { + classpath entrySet.value.path } } } allprojects { repositories { + mavenLocal() + maven { url "https://jitpack.io/" } google() + mavenCentral() jcenter() } @@ -28,9 +28,9 @@ allprojects { resolutionStrategy.cacheChangingModulesFor 0, 'seconds' resolutionStrategy.eachDependency { - if (it.requested.group == 'com.android.support' - && !it.requested.name.contains('multidex')) { - it.useVersion support_version + if (it.requested.group == 'com.android.support' && !it.requested.name.contains( + 'multidex')) { + it.useVersion Config.supportVersion } } } @@ -38,4 +38,4 @@ allprojects { task clean(type: Delete) { delete rootProject.buildDir -} +} \ No newline at end of file diff --git a/buildApp.gradle b/buildApp.gradle new file mode 100644 index 0000000000..93f0b9b1d4 --- /dev/null +++ b/buildApp.gradle @@ -0,0 +1,131 @@ +apply plugin: "com.android.application" + +apply { + from "${rootDir.path}/buildCommon.gradle" + from "${rootDir.path}/config/flavor.gradle" + if (Config.plugins.plugin_api.isApply) { + plugin Config.plugins.plugin_api.id + } + if (Config.plugins.plugin_bus.isApply) { + plugin Config.plugins.plugin_bus.id + } +} + +configSigning() +configApkName() + +//if (PluginConfig.plugin_bus.isApply) { +// bus { +// onlyScanLibRegex = '^([:]|(com\\.blankj)).+$' +// } +//} +// +//if (PluginConfig.plugin_api.isApply) { +// api { +// onlyScanLibRegex = '^([:]|(com\\.blankj)).+$' +// } +//} + +android { + defaultConfig { + applicationId Config.applicationId + suffix + targetSdkVersion Config.targetSdkVersion + multiDexEnabled true + } + + buildTypes { + debug {} + + release { + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + packagingOptions { + exclude 'META-INF/*' + } + + dexOptions { + preDexLibraries true + javaMaxHeapSize "8g" + maxProcessCount 8 + dexInProcess = true + } + + productFlavors { + dev { + applicationIdSuffix ".dev" + versionNameSuffix "-dev" + resValue "string", "app_name", Config.appName + suffix + "-dev" + } + + production { + resValue "string", "app_name", Config.appName + suffix + } + } +} + +dependencies { + // LeakCanary + debugImplementation Config.libs.leakcanary.path + + debugImplementation Config.modules.lib_utildebug.dep + releaseImplementation Config.modules.lib_utildebug_no_op.dep + + // 根据 Config.pkgConfig 来依赖所有 pkg + for (def entrySet : ConfigUtils.getApplyPkgs().entrySet()) { + api entrySet.value.dep + } + + if (Config.modules.feature_mock.isApply) { + api ModuleConfig.modules.feature_mock.dep + } +} + +def getSuffix() { + if (project.name == "feature_launcher_app") return "" + return "." + project. + name. + substring("feature_".length(), project.name.length() - "_app".length()) +} + +def configSigning() { + + File signPropertiesFile = file("${rootDir.path}/sign/keystore.properties") + if (!signPropertiesFile.exists()) return + + GLog.d("${project.toString()} sign start...") + project.android { + Properties properties = new Properties() + properties.load(new FileInputStream(signPropertiesFile)) + signingConfigs { + release { + storeFile new File(signPropertiesFile.getParent(), properties['keystore']) + storePassword properties['storePassword'] + keyAlias properties['keyAlias'] + keyPassword properties['keyPassword'] + } + } + buildTypes.release.signingConfig signingConfigs.release + } + GLog.d("${project.toString()} sign end...") +} + +def configApkName() { + project.android.applicationVariants.all { variant -> + if (variant.buildType.name != "debug") { + def artifact = variant.getPackageApplicationProvider().get() + artifact.outputDirectory = new File("${rootDir.path}/apk") + variant.outputs.each { + it.outputFileName = "util" + suffix + + (variant.flavorName == "" ? "" : ("_" + variant.flavorName)) + + "_" + + variant.versionName.replace(".", "_") + + "_" + + variant.buildType.name + + ".apk" + } + } + } +} \ No newline at end of file diff --git a/config_lib.gradle b/buildCommon.gradle similarity index 50% rename from config_lib.gradle rename to buildCommon.gradle index 355a3ac0ee..2cba3ffea2 100644 --- a/config_lib.gradle +++ b/buildCommon.gradle @@ -1,31 +1,30 @@ apply { - plugin "com.android.library" plugin "kotlin-android" plugin "kotlin-android-extensions" } android { - compileSdkVersion rootProject.compileSdkVersion + compileSdkVersion Config.compileSdkVersion defaultConfig { - minSdkVersion rootProject.minSdkVersion - versionCode rootProject.versionCode - versionName rootProject.versionName + minSdkVersion Config.minSdkVersion + versionCode Config.versionCode + versionName Config.versionName consumerProguardFiles 'proguard-rules.pro' } buildTypes { release { - minifyEnabled false + minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + lintOptions { abortOnError false } -} - -afterEvaluate { - generateReleaseBuildConfig.enabled = false - generateDebugBuildConfig.enabled = false -} +} \ No newline at end of file diff --git a/buildLib.gradle b/buildLib.gradle new file mode 100644 index 0000000000..aed207cbee --- /dev/null +++ b/buildLib.gradle @@ -0,0 +1,13 @@ +apply plugin: "com.android.library" +apply from: "${rootDir.path}/buildCommon.gradle" + +dependencies { + if (project.name.endsWith("_pkg") || project.name.endsWith("_mock")) { + // if module's name equals 'pkg', api all of export + for (def entrySet : ConfigUtils.getApplyExports().entrySet()) { + api entrySet.value.dep + } + } else if (project.name.endsWith("_export")) { + api Config.modules.lib_common.dep + } +} \ No newline at end of file diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index eaa0a0fc0d..349aed4fec 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -1,23 +1,37 @@ -plugins { - id 'groovy' - id 'java-gradle-plugin' +repositories { + google() + jcenter() +} + +apply { + plugin 'groovy' + plugin 'java-gradle-plugin' } gradlePlugin { plugins { readmeCore { id = 'readme-core' - implementationClass = 'com.blankj.plugin.ReadmeCorePlugin' + implementationClass = 'com.blankj.plugin.readme.ReadmeCorePlugin' } readmeSub { id = 'readme-sub' - implementationClass = 'com.blankj.plugin.ReadmeSubPlugin' + implementationClass = 'com.blankj.plugin.readme.ReadmeSubPlugin' } } } dependencies { - compile gradleApi() - compile localGroovy() + implementation gradleApi() + implementation localGroovy() + implementation "commons-io:commons-io:2.6" } + +sourceSets { + main { + groovy { + srcDirs += 'src/main/java' + } + } +} \ No newline at end of file diff --git a/buildSrc/settings.gradle b/buildSrc/settings.gradle new file mode 100644 index 0000000000..8a313c3b99 --- /dev/null +++ b/buildSrc/settings.gradle @@ -0,0 +1,8 @@ +//dependencyResolutionManagement { +// repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) +// repositories { +// google() +// mavenCentral() +// jcenter() // Warning: this repository is going to shut down soon +// } +//} \ No newline at end of file diff --git a/buildSrc/src/main/groovy/Config.groovy b/buildSrc/src/main/groovy/Config.groovy new file mode 100644 index 0000000000..9a8d69d659 --- /dev/null +++ b/buildSrc/src/main/groovy/Config.groovy @@ -0,0 +1,89 @@ +class Config { + + static applicationId = 'com.blankj.androidutilcode' + static appName = 'Util' + + static compileSdkVersion = 29 + static minSdkVersion = 14 + static targetSdkVersion = 29 + static versionCode = 1_031_001 + static versionName = '1.31.1'// E.g. 1.9.72 => 1,009,072 + + // lib version + static gradlePluginVersion = '4.1.0' + static kotlinVersion = '1.3.72' + static androidxVersion = '1.0.0' + + static modules = [ + /*Don't delete this line*/ + /*Generated by "module_config.json"*/ + plugin_api_gradle_plugin : new ModuleConfig(isApply: true , useLocal: true , localPath: "./plugin/api-gradle-plugin"), + plugin_bus_gradle_plugin : new ModuleConfig(isApply: true , useLocal: true , localPath: "./plugin/bus-gradle-plugin"), + plugin_lib_base_transform : new ModuleConfig(isApply: true , useLocal: true , localPath: "./plugin/lib/base-transform", remotePath: "com.blankj:base-transform:1.0"), + plugin_buildSrc_plugin : new ModuleConfig(isApply: true , useLocal: true , localPath: "./plugin/buildSrc-plugin"), + feature_mock : new ModuleConfig(isApply: false, useLocal: true , localPath: "./feature/mock"), + feature_launcher_app : new ModuleConfig(isApply: true , useLocal: true , localPath: "./feature/launcher/app"), + feature_main_app : new ModuleConfig(isApply: false, useLocal: true , localPath: "./feature/main/app"), + feature_main_pkg : new ModuleConfig(isApply: true , useLocal: true , localPath: "./feature/main/pkg"), + feature_subutil_app : new ModuleConfig(isApply: false, useLocal: true , localPath: "./feature/subutil/app"), + feature_subutil_pkg : new ModuleConfig(isApply: true , useLocal: true , localPath: "./feature/subutil/pkg"), + feature_subutil_export : new ModuleConfig(isApply: true , useLocal: true , localPath: "./feature/subutil/export"), + feature_utilcode_app : new ModuleConfig(isApply: false, useLocal: true , localPath: "./feature/utilcode/app"), + feature_utilcode_pkg : new ModuleConfig(isApply: true , useLocal: true , localPath: "./feature/utilcode/pkg"), + feature_utilcode_export : new ModuleConfig(isApply: true , useLocal: true , localPath: "./feature/utilcode/export", remotePath: "com.blankj:utilcode-export:1.1"), + lib_base : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/base"), + lib_common : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/common"), + lib_subutil : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/subutil"), + lib_utilcode : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/utilcode", remotePath: "com.blankj:utilcodex:$Config.versionName"), + lib_utildebug : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/utildebug"), + lib_utildebug_no_op : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/utildebug-no-op"), + /*Don't delete this line*/ + ] + + static plugins = [ + plugin_gradle : new PluginConfig(path: "com.android.tools.build:gradle:$gradlePluginVersion"), + plugin_kotlin : new PluginConfig(path: "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"), + // 上传到 maven + plugin_maven : new PluginConfig(path: "com.github.dcendents:android-maven-gradle-plugin:2.1", id: "com.github.dcendents.android-maven"), + + // 上传新版本插件更新 path 中的版本号,并设置 isApply = false + // 通过 mavenLocal 上传本地版本,设置 isApply = true 即可应用插件来调试,最后通过 bintrayUpload 来发布插件 + plugin_api : new PluginConfig(isApply: true, useLocal: false, path: "com.blankj:api-gradle-plugin:1.5", id: "com.blankj.api"), + //./gradlew clean :plugin_api-gradle-plugin:mavenLocal // 上传到本地 mavenLocal + //./gradlew clean :plugin_api-gradle-plugin:bintrayUpload // 上传到 jcenter + plugin_bus : new PluginConfig(isApply: true, useLocal: false, path: "com.blankj:bus-gradle-plugin:2.6", id: "com.blankj.bus"), + //./gradlew clean :plugin_bus-gradle-plugin:mavenLocal // 上传到本地 mavenLocal + //./gradlew clean :plugin_bus-gradle-plugin:bintrayUpload // 上传到 jcenter + plugin_buildSrc: new PluginConfig(isApply: false, useLocal: false, path: "com.blankj:buildSrc-plugin:1.0", id: "com.blankj.buildSrc"), + //./gradlew clean :plugin_bus-gradle-plugin:mavenLocal // 上传到本地 mavenLocal + //./gradlew clean :plugin_bus-gradle-plugin:bintrayUpload // 上传到 jcenter + ] + + static libs = [ + androidx_appcompat : new LibConfig(path: "androidx.appcompat:appcompat:$androidxVersion"), + androidx_material : new LibConfig(path: "com.google.android.material:material:$androidxVersion"), + androidx_multidex : new LibConfig(path: "androidx.multidex:multidex:2.0.0"), + androidx_constraint: new LibConfig(path: "androidx.constraintlayout:constraintlayout:1.1.3"), + + kotlin : new LibConfig(path: "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"), + + leakcanary : new LibConfig(path: "com.squareup.leakcanary:leakcanary-android:2.1"), + + free_proguard : new LibConfig(path: "com.blankj:free-proguard:1.0.2"), + swipe_panel : new LibConfig(path: "com.blankj:swipe-panel:1.2"), + + gson : new LibConfig(path: "com.google.code.gson:gson:2.8.5"), + glide : new LibConfig(path: "com.github.bumptech.glide:glide:4.7.1"), + retrofit : new LibConfig(path: "com.squareup.retrofit2:retrofit:2.4.0"), + commons_io : new LibConfig(path: "commons-io:commons-io:2.6"), + + eventbus_lib : new LibConfig(path: "org.greenrobot:eventbus:3.1.1"), + eventbus_processor : new LibConfig(path: "org.greenrobot:eventbus-annotation-processor:3.0.1"), + + photo_view : new LibConfig(path: "com.github.chrisbanes:PhotoView:2.0.0"), + + test_junit : new LibConfig(path: "junit:junit:4.12"), + test_robolectric : new LibConfig(path: "org.robolectric:robolectric:4.3.1"), + ] +} +//./gradlew clean :lib_utilcode:bintrayUpload \ No newline at end of file diff --git a/buildSrc/src/main/groovy/ConfigUtils.groovy b/buildSrc/src/main/groovy/ConfigUtils.groovy new file mode 100644 index 0000000000..6a09d2f2d9 --- /dev/null +++ b/buildSrc/src/main/groovy/ConfigUtils.groovy @@ -0,0 +1,99 @@ +import org.gradle.api.Project +import org.gradle.api.ProjectEvaluationListener +import org.gradle.api.ProjectState +import org.gradle.api.invocation.Gradle + +/** + *
+ * author: blankj + * blog : http://blankj.com + * time : 2019/07/13 + * desc : + *+ */ +class ConfigUtils { + + static init(Gradle gradle) { + generateDep(gradle) + addCommonGradle(gradle) + TaskDurationUtils.init(gradle) + } + + /** + * 根据 depConfig 生成 dep + */ + private static void generateDep(Gradle gradle) { + def configs = [:] + for (Map.Entry
+ * author: blankj + * blog : http://blankj.com + * time : 2019/07/13 + * desc : + *+ */ +class GLog { + + def static debugSwitch = true + + static d(Object... contents) { + if (!debugSwitch) return contents + return l(contents) + } + + static l(Object... contents) { + StringBuilder sb = new StringBuilder() + sb.append(LogConst.BORDER_TOP) + sb.append(borderMsg(processContents(contents))) + sb.append(LogConst.BORDER_BTM) + print sb.toString() + return contents + } + + private static borderMsg(String msg) { + StringBuilder sb = new StringBuilder() + object2String(msg).split(LogConst.LINE_SEP).each { line -> + sb.append(LogConst.BORDER_LFT).append(line).append(LogConst.LINE_SEP) + } + return sb + } + + private static processContents(final Object... contents) { + String body = LogConst.NULL + if (contents != null) { + if (contents.length == 1) { + body = object2String(contents[0]) + } else { + StringBuilder sb = new StringBuilder() + int i = 0 + for (int len = contents.length; i < len; ++i) { + Object content = contents[i] + sb.append("args[$i] = ") + .append(object2String(content)) + .append(LogConst.LINE_SEP) + } + body = sb.toString() + } + } + return body.length() == 0 ? LogConst.NOTHING : body + } + + static String object2String(Object object) { + if (object == null) return "null"; + if (object.getClass().isArray()) return LogFormatter.array2String(object); + if (object instanceof List) return LogFormatter.list2String(object); + if (object instanceof Map) return LogFormatter.map2String(object); + if (object instanceof Throwable) return LogFormatter.throwable2String(object); + return object.toString(); + } + + static class LogFormatter { + + private static array2String(Object object) { + if (object instanceof Object[]) { + return Arrays.deepToString((Object[]) object); + } else if (object instanceof boolean[]) { + return Arrays.toString((boolean[]) object); + } else if (object instanceof byte[]) { + return Arrays.toString((byte[]) object); + } else if (object instanceof char[]) { + return Arrays.toString((char[]) object); + } else if (object instanceof double[]) { + return Arrays.toString((double[]) object); + } else if (object instanceof float[]) { + return Arrays.toString((float[]) object); + } else if (object instanceof int[]) { + return Arrays.toString((int[]) object); + } else if (object instanceof long[]) { + return Arrays.toString((long[]) object); + } else if (object instanceof short[]) { + return Arrays.toString((short[]) object); + } + throw new IllegalArgumentException("Array has incompatible type: " + object.getClass()); + } + + private static list2String(List list) { + StringBuilder sb = new StringBuilder() + sb.append("[") + list.each { v -> + if (v instanceof Map || v instanceof List) { + sb.append(String.format("$LogConst.LINE_SEP%${deep++ * 8}s${object2String(v)},", "")) + deep-- + } else { + sb.append(String.format("$LogConst.LINE_SEP%${deep * 8}s$v,", "")) + } + } + sb.deleteCharAt(sb.length() - 1) + if (deep - 1 == 0) { + sb.append("$LogConst.LINE_SEP]") + } else { + sb.append(String.format("$LogConst.LINE_SEP%${(deep - 1) * 8}s]", "")) + } + return sb.toString() + } + + private static deep = 1; + + private static map2String(Map map) { + StringBuilder sb = new StringBuilder() + sb.append("[") + map.each { k, v -> + if (v instanceof Map || v instanceof List) { + sb.append(String.format("$LogConst.LINE_SEP%${deep++ * 8}s%-26s: ${object2String(v)},", "", k)) + deep-- + } else { + sb.append(String.format("$LogConst.LINE_SEP%${deep * 8}s%-26s: $v,", "", k)) + } + } + sb.deleteCharAt(sb.length() - 1) + if (deep - 1 == 0) { + sb.append("$LogConst.LINE_SEP]") + } else { + sb.append(String.format("$LogConst.LINE_SEP%${(deep - 1) * 8}s]", "")) + } + return sb.toString() + } + + private static throwable2String(Throwable throwable) { + final List
+ * author: blankj + * blog : http://blankj.com + * time : 2019/11/22 + * desc : + *+ */ +class TaskDurationUtils { + + static List
- * author: blankj - * blog : http://blankj.com - * time : 2018/11/25 - * desc : - *- */ -class JavassistUtils { - - public static ClassPool sPool - - static void init(Project project) { - sPool = new ClassPool(null) - sPool.appendSystemPath() - // 加入本地 android 包 - LogUtils.l(project.android.bootClasspath[0].toString()) - sPool.appendClassPath(project.android.bootClasspath[0].toString()) - } - - static ClassPool getPool() { - return sPool - } -} diff --git a/bus-gradle-plugin/src/main/java/com/blankj/util/LogUtils.groovy b/bus-gradle-plugin/src/main/java/com/blankj/util/LogUtils.groovy deleted file mode 100755 index c51d161ea2..0000000000 --- a/bus-gradle-plugin/src/main/java/com/blankj/util/LogUtils.groovy +++ /dev/null @@ -1,34 +0,0 @@ -package com.blankj.util - -import org.gradle.api.Project -import org.gradle.api.logging.Logger - -final class LogUtils { - - private static Logger sLogger - private static String PREFIX = "PLUGIN-BUS >>> " - - static void init(Project project) { - sLogger = project.getLogger() - } - - static void l(Object content) { - sLogger.lifecycle(PREFIX + content) - } - - static void d(Object content) { - sLogger.debug(PREFIX + content) - } - - static void i(Object content) { - sLogger.info(PREFIX + content) - } - - static void w(Object content) { - sLogger.warn(PREFIX + content) - } - - static void e(Object content) { - sLogger.error(PREFIX + content) - } -} \ No newline at end of file diff --git a/bus-gradle-plugin/src/main/java/com/blankj/utilcode/util/BusUtils.java b/bus-gradle-plugin/src/main/java/com/blankj/utilcode/util/BusUtils.java deleted file mode 100755 index 507919ff49..0000000000 --- a/bus-gradle-plugin/src/main/java/com/blankj/utilcode/util/BusUtils.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.blankj.utilcode.util; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -public final class BusUtils { - - @Target({ElementType.METHOD}) - @Retention(RetentionPolicy.CLASS) - public @interface Subscribe { - String name() default ""; - } -} \ No newline at end of file diff --git a/bus-gradle-plugin/src/test/java/com/blankj/bus/BusTest.java b/bus-gradle-plugin/src/test/java/com/blankj/bus/BusTest.java deleted file mode 100755 index 9f7ef5828d..0000000000 --- a/bus-gradle-plugin/src/test/java/com/blankj/bus/BusTest.java +++ /dev/null @@ -1,162 +0,0 @@ -package com.blankj.bus; - - -/** - *
- * author: Blankj - * blog : http://blankj.com - * time : 2018/09/21 - * desc : - *- */ -public class BusTest { - -// @Test -// public void test() throws Exception { -// String rootPath = "/Users/blankj/Repo/AndroidUtilCode/app/build/intermediates/transforms/busTransform/debug/43/"; -// File root = new File(rootPath); -// ClassPool mPool = new ClassPool(null); -// mPool.appendSystemPath(); -// mPool.appendClassPath(rootPath); -// mPool.appendClassPath("/Users/blankj/Library/Android/sdk/platforms/android-27/android.jar"); -// HashMap
+ * author: Blankj + * blog : http://blankj.com + * time : 2016/10/12 + * desc : + *+ */ +public class LauncherApp extends CommonApplication { + + private static LauncherApp sInstance; + + public static LauncherApp getInstance() { + return sInstance; + } + + @Override + public void onCreate() { + super.onCreate(); + sInstance = this; + } +} + + diff --git a/launcher/pkg/.gitignore b/feature/main/app/.gitignore similarity index 100% rename from launcher/pkg/.gitignore rename to feature/main/app/.gitignore diff --git a/feature/main/app/build.gradle b/feature/main/app/build.gradle new file mode 100644 index 0000000000..e69de29bb2 diff --git a/launcher/pkg/proguard-rules.pro b/feature/main/app/proguard-rules.pro similarity index 100% rename from launcher/pkg/proguard-rules.pro rename to feature/main/app/proguard-rules.pro diff --git a/feature/main/app/src/main/AndroidManifest.xml b/feature/main/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..bb8c3398d4 --- /dev/null +++ b/feature/main/app/src/main/AndroidManifest.xml @@ -0,0 +1,28 @@ + +
* author: Blankj * blog : http://blankj.com * time : 2016/10/12 - * desc : app about utils + * desc : **/ -public class SubUtilApp extends BaseApplication { +public class MainApp extends CommonApplication { - private static SubUtilApp sInstance; + private static MainApp sInstance; - public static SubUtilApp getInstance() { + public static MainApp getInstance() { return sInstance; } diff --git a/subutil/app/.gitignore b/feature/main/pkg/.gitignore similarity index 100% rename from subutil/app/.gitignore rename to feature/main/pkg/.gitignore diff --git a/feature/main/pkg/build.gradle b/feature/main/pkg/build.gradle new file mode 100644 index 0000000000..e69de29bb2 diff --git a/subutil/app/proguard-rules.pro b/feature/main/pkg/proguard-rules.pro similarity index 100% rename from subutil/app/proguard-rules.pro rename to feature/main/pkg/proguard-rules.pro diff --git a/launcher/pkg/src/main/AndroidManifest.xml b/feature/main/pkg/src/main/AndroidManifest.xml similarity index 51% rename from launcher/pkg/src/main/AndroidManifest.xml rename to feature/main/pkg/src/main/AndroidManifest.xml index 7d1a12cfcb..1cfdba8f69 100644 --- a/launcher/pkg/src/main/AndroidManifest.xml +++ b/feature/main/pkg/src/main/AndroidManifest.xml @@ -1,11 +1,13 @@
+ * author: Blankj + * blog : http://blankj.com + * time : 2019/07/10 + * desc : + *+ */ +@ApiUtils.Api(isMock = true) +public class SubUtilApiMock extends SubUtilApi { + + @Override + public void startSubUtilActivity(Context context) { + ToastUtils.showShort("startSubUtilActivity"); + } + +} diff --git a/feature/mock/src/main/java/com/blankj/mock/utilcode/UtilCodeApiMock.java b/feature/mock/src/main/java/com/blankj/mock/utilcode/UtilCodeApiMock.java new file mode 100644 index 0000000000..df22cbf92a --- /dev/null +++ b/feature/mock/src/main/java/com/blankj/mock/utilcode/UtilCodeApiMock.java @@ -0,0 +1,32 @@ +package com.blankj.mock.utilcode; + +import android.content.Context; + +import com.blankj.utilcode.export.api.UtilCodeApi; +import com.blankj.utilcode.util.ApiUtils; +import com.blankj.utilcode.util.ToastUtils; + +/** + *
+ * author: Blankj + * blog : http://blankj.com + * time : 2019/07/10 + * desc : + *+ */ +@ApiUtils.Api(isMock = true) +public class UtilCodeApiMock extends UtilCodeApi { + + @Override + public void startUtilCodeActivity(Context context) { + ToastUtils.showShort("startUtilCodeActivity"); + } + + @Override + public void testCallback(Callback callback) { + if (callback != null) { + callback.call(); + } + } + +} diff --git a/subutil/pkg/.gitignore b/feature/subutil/app/.gitignore similarity index 100% rename from subutil/pkg/.gitignore rename to feature/subutil/app/.gitignore diff --git a/feature/subutil/app/build.gradle b/feature/subutil/app/build.gradle new file mode 100644 index 0000000000..e69de29bb2 diff --git a/utilcode/app/proguard-rules.pro b/feature/subutil/app/proguard-rules.pro similarity index 100% rename from utilcode/app/proguard-rules.pro rename to feature/subutil/app/proguard-rules.pro diff --git a/subutil/app/src/main/AndroidManifest.xml b/feature/subutil/app/src/main/AndroidManifest.xml similarity index 86% rename from subutil/app/src/main/AndroidManifest.xml rename to feature/subutil/app/src/main/AndroidManifest.xml index 7dfbfceea3..2989dbfebf 100644 --- a/subutil/app/src/main/AndroidManifest.xml +++ b/feature/subutil/app/src/main/AndroidManifest.xml @@ -11,8 +11,9 @@
+ * author: Blankj + * blog : http://blankj.com + * time : 2019/06/09 + * desc : + *+ */ +public abstract class SubUtilApi extends ApiUtils.BaseApi { + + public abstract void startSubUtilActivity(Context context); + +} diff --git a/utilcode/pkg/.gitignore b/feature/subutil/pkg/.gitignore similarity index 100% rename from utilcode/pkg/.gitignore rename to feature/subutil/pkg/.gitignore diff --git a/feature/subutil/pkg/build.gradle b/feature/subutil/pkg/build.gradle new file mode 100644 index 0000000000..e69de29bb2 diff --git a/feature/subutil/pkg/proguard-rules.pro b/feature/subutil/pkg/proguard-rules.pro new file mode 100644 index 0000000000..f1b424510d --- /dev/null +++ b/feature/subutil/pkg/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/feature/subutil/pkg/src/main/AndroidManifest.xml b/feature/subutil/pkg/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..198eb5c31b --- /dev/null +++ b/feature/subutil/pkg/src/main/AndroidManifest.xml @@ -0,0 +1,55 @@ +
+ * author: Blankj + * blog : http://blankj.com + * time : 2019/07/02 + * desc : + *+ */ +@ApiUtils.Api +public class SubUtilApiImpl extends SubUtilApi { + + @Override + public void startSubUtilActivity(Context context) { + SubUtilActivity.Companion.start(context); + } + +} diff --git a/feature/subutil/pkg/src/main/java/com/blankj/subutil/pkg/feature/SubUtilActivity.kt b/feature/subutil/pkg/src/main/java/com/blankj/subutil/pkg/feature/SubUtilActivity.kt new file mode 100644 index 0000000000..2c6af650ef --- /dev/null +++ b/feature/subutil/pkg/src/main/java/com/blankj/subutil/pkg/feature/SubUtilActivity.kt @@ -0,0 +1,61 @@ +package com.blankj.subutil.pkg.feature + +import android.content.Context +import android.content.Intent +import com.blankj.common.activity.CommonActivity +import com.blankj.common.item.CommonItem +import com.blankj.common.item.CommonItemClick +import com.blankj.subutil.pkg.R +import com.blankj.subutil.pkg.feature.appStore.AppStoreActivity +import com.blankj.subutil.pkg.feature.battery.BatteryActivity +import com.blankj.subutil.pkg.feature.country.CountryActivity +import com.blankj.subutil.pkg.feature.dangerous.DangerousActivity +import com.blankj.subutil.pkg.feature.location.LocationActivity +import com.blankj.subutil.pkg.feature.pinyin.PinyinActivity +import com.blankj.utilcode.util.CollectionUtils + +/** + * ``` + * author: Blankj + * blog : http://blankj.com + * time : 2016/09/29 + * desc : MainActivity + * ``` + */ +class SubUtilActivity : CommonActivity() { + + companion object { + fun start(context: Context) { + val starter = Intent(context, SubUtilActivity::class.java) + context.startActivity(starter) + } + } + + + override fun bindTitleRes(): Int { + return R.string.sub_util + } + + override fun bindItems(): List
+ * author: Blankj + * blog : http://blankj.com + * time : 2019/07/01 + * desc : + *+ */ +public abstract class UtilCodeApi extends ApiUtils.BaseApi { + + public abstract void startUtilCodeActivity(Context context); + + public abstract void testCallback(Callback callback); + + public interface Callback { + void call(); + } + +} \ No newline at end of file diff --git a/feature/utilcode/pkg/.gitignore b/feature/utilcode/pkg/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/feature/utilcode/pkg/.gitignore @@ -0,0 +1 @@ +/build diff --git a/feature/utilcode/pkg/build.gradle b/feature/utilcode/pkg/build.gradle new file mode 100644 index 0000000000..e69de29bb2 diff --git a/feature/utilcode/pkg/proguard-rules.pro b/feature/utilcode/pkg/proguard-rules.pro new file mode 100644 index 0000000000..f1b424510d --- /dev/null +++ b/feature/utilcode/pkg/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/feature/utilcode/pkg/src/main/AndroidManifest.xml b/feature/utilcode/pkg/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..8da0667a23 --- /dev/null +++ b/feature/utilcode/pkg/src/main/AndroidManifest.xml @@ -0,0 +1,284 @@ +
+ * author: Blankj + * blog : http://blankj.com + * time : 2019/07/01 + * desc : + *+ */ +@ApiUtils.Api +public class UtilCodeApiImpl extends UtilCodeApi { + + @Override + public void startUtilCodeActivity(Context context) { + CoreUtilActivity.Companion.start(context); + } + + @Override + public void testCallback(Callback callback) { + if (callback != null) { + callback.call(); + } + } +} diff --git a/feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/CoreUtilActivity.kt b/feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/CoreUtilActivity.kt new file mode 100644 index 0000000000..2640191959 --- /dev/null +++ b/feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/CoreUtilActivity.kt @@ -0,0 +1,226 @@ +package com.blankj.utilcode.pkg.feature + +import android.content.Context +import android.content.Intent +import android.os.Bundle +import android.widget.TextView +import com.blankj.common.activity.CommonActivity +import com.blankj.common.item.CommonItem +import com.blankj.common.item.CommonItemClick +import com.blankj.utilcode.pkg.R +import com.blankj.utilcode.pkg.feature.activity.ActivityActivity +import com.blankj.utilcode.pkg.feature.adaptScreen.AdaptScreenActivity +import com.blankj.utilcode.pkg.feature.api.ApiActivity +import com.blankj.utilcode.pkg.feature.app.AppActivity +import com.blankj.utilcode.pkg.feature.bar.BarActivity +import com.blankj.utilcode.pkg.feature.brightness.BrightnessActivity +import com.blankj.utilcode.pkg.feature.bus.BusActivity +import com.blankj.utilcode.pkg.feature.clean.CleanActivity +import com.blankj.utilcode.pkg.feature.click.ClickActivity +import com.blankj.utilcode.pkg.feature.clipboard.ClipboardActivity +import com.blankj.utilcode.pkg.feature.device.DeviceActivity +import com.blankj.utilcode.pkg.feature.file.FileActivity +import com.blankj.utilcode.pkg.feature.flashlight.FlashlightActivity +import com.blankj.utilcode.pkg.feature.fragment.FragmentActivity +import com.blankj.utilcode.pkg.feature.image.ImageActivity +import com.blankj.utilcode.pkg.feature.intent.IntentActivity +import com.blankj.utilcode.pkg.feature.keyboard.KeyboardActivity +import com.blankj.utilcode.pkg.feature.language.LanguageActivity +import com.blankj.utilcode.pkg.feature.log.LogActivity +import com.blankj.utilcode.pkg.feature.messenger.MessengerActivity +import com.blankj.utilcode.pkg.feature.metaData.MetaDataActivity +import com.blankj.utilcode.pkg.feature.mvp.MvpActivity +import com.blankj.utilcode.pkg.feature.network.NetworkActivity +import com.blankj.utilcode.pkg.feature.notification.NotificationActivity +import com.blankj.utilcode.pkg.feature.path.PathActivity +import com.blankj.utilcode.pkg.feature.permission.PermissionActivity +import com.blankj.utilcode.pkg.feature.phone.PhoneActivity +import com.blankj.utilcode.pkg.feature.process.ProcessActivity +import com.blankj.utilcode.pkg.feature.reflect.ReflectActivity +import com.blankj.utilcode.pkg.feature.resource.ResourceActivity +import com.blankj.utilcode.pkg.feature.rom.RomActivity +import com.blankj.utilcode.pkg.feature.screen.ScreenActivity +import com.blankj.utilcode.pkg.feature.sdcard.SDCardActivity +import com.blankj.utilcode.pkg.feature.shadow.ShadowActivity +import com.blankj.utilcode.pkg.feature.snackbar.SnackbarActivity +import com.blankj.utilcode.pkg.feature.spStatic.SPStaticActivity +import com.blankj.utilcode.pkg.feature.span.SpanActivity +import com.blankj.utilcode.pkg.feature.toast.ToastActivity +import com.blankj.utilcode.pkg.feature.uiMessage.UiMessageActivity +import com.blankj.utilcode.pkg.feature.vibrate.VibrateActivity +import com.blankj.utilcode.pkg.feature.volume.VolumeActivity +import com.blankj.utilcode.pkg.helper.DialogHelper +import com.blankj.utilcode.util.CollectionUtils +import com.blankj.utilcode.util.LogUtils +import com.blankj.utilcode.util.ThreadUtils +import com.blankj.utilcode.util.UtilsTransActivity + +/** + * ``` + * author: Blankj + * blog : http://blankj.com + * time : 2016/09/29 + * desc : + * ``` + */ +class CoreUtilActivity : CommonActivity() { + + companion object { + fun start(context: Context) { + val starter = Intent(context, CoreUtilActivity::class.java) + context.startActivity(starter) + } + } + + override fun bindTitleRes(): Int { + return R.string.core_util + } + + override fun bindItems(): MutableList
+ * author: Blankj + * blog : http://blankj.com + * time : 2019/07/10 + * desc : demo about ApiUtils + *+ */ +public abstract class OtherModuleApi extends ApiUtils.BaseApi { + + public abstract void invokeWithParams(ApiBean bean); + + public abstract ApiBean invokeWithReturnValue(); + + public static class ApiBean { + + public String name; + + public ApiBean(String name) { + this.name = name; + } + } +} diff --git a/feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/api/other/pkg/OtherPkgApiImpl.java b/feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/api/other/pkg/OtherPkgApiImpl.java new file mode 100644 index 0000000000..b3efb7af7a --- /dev/null +++ b/feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/api/other/pkg/OtherPkgApiImpl.java @@ -0,0 +1,28 @@ +package com.blankj.utilcode.pkg.feature.api.other.pkg; + +import com.blankj.utilcode.pkg.feature.api.other.export.OtherModuleApi; +import com.blankj.utilcode.util.ApiUtils; +import com.blankj.utilcode.util.ToastUtils; + +/** + *
+ * author: Blankj + * blog : http://blankj.com + * time : 2019/07/10 + * desc : demo about ApiUtils + *+ */ +@ApiUtils.Api +public class OtherPkgApiImpl extends OtherModuleApi { + + @Override + public void invokeWithParams(ApiBean bean) { + ToastUtils.showShort(bean.name); + } + + @Override + public ApiBean invokeWithReturnValue() { + String value = "value"; + return new ApiBean(value); + } +} diff --git a/feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/app/AppActivity.kt b/feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/app/AppActivity.kt new file mode 100644 index 0000000000..21eb351146 --- /dev/null +++ b/feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/app/AppActivity.kt @@ -0,0 +1,162 @@ +package com.blankj.utilcode.pkg.feature.app + +import android.app.Activity +import android.content.Context +import android.content.Intent +import com.blankj.common.activity.CommonActivity +import com.blankj.common.helper.PermissionHelper +import com.blankj.common.item.* +import com.blankj.utilcode.constant.PermissionConstants +import com.blankj.utilcode.pkg.Config +import com.blankj.utilcode.pkg.R +import com.blankj.utilcode.util.* + +/** + * ``` + * author: Blankj + * blog : http://blankj.com + * time : 2016/10/13 + * desc : demo about AppUtils + * ``` + */ +class AppActivity : CommonActivity(), Utils.OnAppStatusChangedListener { + + var isRegisterAppStatusChangedListener: Boolean = false + + companion object { + fun start(context: Context) { + PermissionHelper.request(context, object : PermissionUtils.SimpleCallback { + override fun onGranted() { + val starter = Intent(context, AppActivity::class.java) + context.startActivity(starter) + } + + override fun onDenied() { + } + }, PermissionConstants.STORAGE) + } + } + + private val listener = object : OnReleasedListener { + override fun onReleased() { + return AppUtils.installApp(Config.TEST_APK_PATH) + } + } + + override fun bindTitleRes(): Int { + return R.string.demo_app + } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) + LogUtils.e(requestCode, resultCode) + } + + override fun bindItems(): MutableList
+ * author: blankj + * blog : http://blankj.com + * time : 2019/11/09 + * desc : + *+ */ +public class MvpActivity extends CommonActivity { + + public static void start(Context context) { + Intent starter = new Intent(context, MvpActivity.class); + context.startActivity(starter); + } + + @Override + public int bindTitleRes() { + return R.string.demo_mvp; + } + + @Override + public int bindLayout() { + return R.layout.mvp_activity; + } + + @Override + public void initView(@Nullable Bundle savedInstanceState, @Nullable View contentView) { + super.initView(savedInstanceState, contentView); + new MvpView(this).addPresenter(new MvpPresenter()); + } +} diff --git a/feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/mvp/MvpModel.java b/feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/mvp/MvpModel.java new file mode 100644 index 0000000000..e16b4f1934 --- /dev/null +++ b/feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/mvp/MvpModel.java @@ -0,0 +1,44 @@ +package com.blankj.utilcode.pkg.feature.mvp; + +import com.blankj.base.mvp.BaseModel; +import com.blankj.utilcode.util.ThreadUtils; +import com.blankj.utilcode.util.Utils; + +/** + *
+ * author: blankj + * blog : http://blankj.com + * time : 2019/11/26 + * desc : + *+ */ +public class MvpModel extends BaseModel implements MvpMvp.Model { + + private int index; + + @Override + public void onCreate() { + index = 0; + } + + @Override + public void requestUpdateMsg(final Utils.Consumer
+ * author: blankj + * blog : http://blankj.com + * time : 2019/11/26 + * desc : + *+ */ +public interface MvpMvp { + + interface View { + void setLoadingVisible(boolean visible); + + void showMsg(CharSequence msg); + } + + interface Presenter { + void updateMsg(); + } + + interface Model { + void requestUpdateMsg(final Utils.Consumer
+ * author: blankj + * blog : http://blankj.com + * time : 2019/11/26 + * desc : + *+ */ +public class MvpPresenter extends BasePresenter
+ * author: blankj + * blog : http://blankj.com + * time : 2019/11/26 + * desc : + *+ */ +public class MvpView extends BaseView
+ * author: blankj + * blog : http://blankj.com + * time : 2019/09/09 + * desc : + *+ */ +@Keep +public class TestPrivateStaticFinal { + public static final String STR = "str"; +} diff --git a/feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/resource/ResourceActivity.kt b/feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/resource/ResourceActivity.kt new file mode 100644 index 0000000000..cf56301068 --- /dev/null +++ b/feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/feature/resource/ResourceActivity.kt @@ -0,0 +1,49 @@ +package com.blankj.utilcode.pkg.feature.resource + +import android.content.Context +import android.content.Intent +import com.blankj.common.activity.CommonActivity +import com.blankj.common.item.CommonItem +import com.blankj.common.item.CommonItemClick +import com.blankj.common.item.CommonItemTitle +import com.blankj.utilcode.pkg.Config +import com.blankj.utilcode.pkg.R +import com.blankj.utilcode.util.CollectionUtils +import com.blankj.utilcode.util.ResourceUtils + +/** + * ``` + * author: Blankj + * blog : http://blankj.com + * time : 2018/05/07 + * desc : demo about ResourceUtils + * ``` + */ +class ResourceActivity : CommonActivity() { + + companion object { + fun start(context: Context) { + val starter = Intent(context, ResourceActivity::class.java) + context.startActivity(starter) + } + } + + override fun bindTitleRes(): Int { + return R.string.demo_resource + } + + override fun bindItems(): MutableList