Skip to content

Commit d21bcb5

Browse files
committed
# Conflicts: # build.gradle
2 parents 2fdbd96 + 4625d7e commit d21bcb5

File tree

457 files changed

+38627
-12025
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

457 files changed

+38627
-12025
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.iml
2+
*__bus__.json
23
.gradle
34
/local.properties
45
.idea
@@ -7,5 +8,5 @@
78
/captures
89
.externalNativeBuild
910
/apk
10-
/maven
11-
__bus__.json
11+
*.phrof
12+
/busMaven

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ android:
1818
email: false
1919

2020
before_install:
21-
- yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;26.0.2"
21+
- yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;26.0.2"
2222

2323
script:
24-
- ./gradlew build connectedCheck --info
24+
- ./gradlew build connectedCheck

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
* `19/06/20` [fix] BusUtils' permission. Publish v1.24.4.
2+
* `19/06/19` [fix] UriUtils. Publish v1.24.3.
3+
* `19/06/18` [add] ClickUtils, ViewUtils.
4+
* `19/06/07` [fix] LogUtils file name contains ':'. Publish v1.24.2.
5+
* `19/06/06` [fix] LogUtils write to file. Publish v1.24.1.
6+
* `19/06/03` [fix] Refactoring framework. Publish v1.24.0.
7+
* `19/04/25` [fix] LogUtils delete due log.
8+
* `19/04/24` [upd] The swipe panel.
9+
* `19/03/17` [fix] The ugly UI.
10+
* `19/03/14` [fix] AdaptScreenUtils didn't work on some HaWei tablet.
11+
* `19/03/08` [add] LogUtils support multi process. Publish v1.23.7.
12+
* `19/03/02` [fix] LogUtils#file.
13+
* `19/02/28` [fix] ImageUtils#calculateInSampleSize. Publish v1.23.6.
14+
* `19/02/26` [fix] UriUtils#uri2File. Publish v1.23.5.
15+
* `19/01/31` [add] HttpUtils.
16+
* `19/01/30` [add] RomUtils. Publish v1.23.4.
17+
* `19/01/29` [fix] LogUtils format json when json not start with '{'. Publish v1.23.3.
18+
* `19/01/28` [fix] KeyboardUtils#fixSoftInputLeaks don't work on the device of HuaWei.
19+
* `19/01/26` [fix] NetworkUtils#getNetworkType.
20+
* `19/01/25` [add] CloneUtils, PermissionUtils support request permission of WRITE_SETTINGS and DRAW_OVERLAYS. Publish v1.23.2.
21+
* `19/01/24` [add] BrightnessUtils and FlashlightUtils.
22+
* `19/01/23` [add] Modify the demo of utilcode use kotlin. Publish v1.23.1.
23+
* `19/01/22` [fix] AppUtils#installApp.
24+
* `19/01/17` [fix] Publish v1.23.0.
25+
* `19/01/16` [fix] BarUtils get Activity from view and delete the function of set status bar alpha.
26+
* `19/01/15` [add] ColorUtils.
27+
* `19/01/04` [add] CacheDiskStaticUtils, CacheDoubleStaticUtils, CacheMemoryStaticUtils.
28+
* `19/01/03` [add] SPStaticUtils.
29+
* `19/01/02` [fix] LogUtils log object. Publish v1.22.10.
30+
* `19/01/01` [add] GsonUtils.
31+
* `18/12/29` [add] AntiShakeUtils and VibrateUtils. Publish v1.22.9.
32+
* `18/12/28` [fix] ToastUtils show behind the dialog when close notification.
33+
* `18/12/27` [fix] LogUtils print StringBuilder failed.
34+
* `18/12/24` [fix] Utils$ActivityLifecycleImpl.consumeOnActivityDestroyedListener ConcurrentModificationException. Publish v1.22.7.
135
* `18/12/22` [fix] AdaptScreenUtils#pt2px don't work when start webview. Publish v1.22.6.
236
* `18/12/21` [add] LogUtils support print Map, Collection and Object to String.
337
* `18/12/19` [fix] AdaptScreenUtils don't work in MIUI on Android 5.1.1. Publish v1.22.5.

README-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.22.6-brightgreen.svg
44+
[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.24.4-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apiSvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.22.6-brightgreen.svg
44+
[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.24.4-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apiSvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

build.gradle

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
buildscript {
3-
apply from: 'config.gradle'
43
repositories {
54
maven {
65
url 'https://maven.aliyun.com/repository/public'
@@ -14,18 +13,22 @@ buildscript {
1413
url 'https://maven.aliyun.com/repository/google'
1514
name '代替 google()'
1615
}
17-
if (bus.isDebug) {
16+
if (gradle.ext.depConfig.plugin_bus.useLocal) {
1817
maven() {
19-
url uri(new File(project.rootDir, "maven"))
18+
// use for debug plugin local
19+
url new File("busMaven")
2020
}
2121
}
2222
google()
2323
jcenter()
2424
}
2525

2626
dependencies {
27-
for (plugin in dep.plugin) {
28-
classpath plugin
27+
// 根据 config 来 configClasspath 各 plugin
28+
gradle.ext.depConfig.each { name, config ->
29+
if (name.startsWith("plugin_") && config.isApply) {
30+
classpath config.remotePath
31+
}
2932
}
3033
}
3134
}
@@ -54,7 +57,7 @@ allprojects {
5457
resolutionStrategy.eachDependency {
5558
if (it.requested.group == 'com.android.support'
5659
&& !it.requested.name.contains('multidex')) {
57-
it.useVersion support_version
60+
it.useVersion gradle.ext.support_version
5861
}
5962
}
6063
}

bus-gradle-plugin/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## v1.8
4+
兼容最新工程组件化
5+
6+
## v1.7
7+
兼容 utilcodex
8+
39
## v1.6
410
修复 inject 时候 zip 操作不对导致混淆出错的问题
511

bus-gradle-plugin/build.gradle

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ plugins {
55
apply {
66
plugin "groovy"
77
plugin "java-gradle-plugin"
8-
from "${rootDir.path}/gradle/pluginPublish.gradle"
9-
if (bus.isDebug) {
8+
from "${rootDir.path}/gradle/upload/pluginPublish.gradle"
9+
if (gradle.ext.depConfig.plugin_bus.useLocal) {
1010
plugin "maven"
11-
from "${rootDir.path}/gradle/localMavenUpload.gradle"
1211
} else {
1312
plugin "com.github.dcendents.android-maven"
1413
plugin "com.jfrog.bintray"
15-
from "${rootDir.path}/gradle/bintrayUploadJava.gradle"
14+
from "${rootDir.path}/gradle/upload/bintrayUploadJava.gradle"
1615
}
1716
}
1817

@@ -26,13 +25,15 @@ gradlePlugin {
2625
}
2726

2827
dependencies {
29-
implementation dep.plugin[0]
30-
implementation dep.javassist
31-
implementation dep.commons_io
28+
implementation "com.android.tools.build:gradle:3.4.0"
29+
implementation "com.android.tools.build:gradle-api:3.4.0"
30+
31+
implementation gradle.ext.dep.javassist
32+
implementation gradle.ext.dep.commons_io
3233
implementation gradleApi()
3334
implementation localGroovy()
3435

35-
testImplementation dep.junit
36+
testImplementation gradle.ext.dep.junit
3637
}
3738

3839
sourceSets {
@@ -49,8 +50,18 @@ sourceSets {
4950
}
5051
}
5152

52-
group = bus.group
53-
version = bus.version
53+
group = gradle.ext.depConfig.plugin_bus.groupId
54+
version = gradle.ext.depConfig.plugin_bus.version
55+
56+
if (gradle.ext.depConfig.plugin_bus.useLocal) {
57+
uploadArchives {
58+
repositories {
59+
mavenDeployer {
60+
repository(url: uri(new File(project.rootDir, "busMaven")))
61+
}
62+
}
63+
}
64+
}
5465

5566
//./gradlew bus-gradle-plugin:bintrayUpload
5667
//./gradlew publishPlugins
-1.71 KB
Binary file not shown.

bus-gradle-plugin/project.properties

100755100644
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
#project
12
project.name=StaticBusPlugin
2-
project.siteUrl=https://github.com/Blankj/StaticBus
3-
project.gitUrl=https://github.com/Blankj/StaticBus.git
4-
3+
project.groupId=com.blankj
4+
project.artifactId=bus-gradle-plugin
5+
project.packaging=aar
6+
project.siteUrl=https://github.com/Blankj/AndroidUtilCode
7+
project.gitUrl=https://github.com/Blankj/AndroidUtilCode.git
58
#javadoc
6-
javadoc.name=StaticBus
9+
javadoc.name=StaticBusPlugin

bus-gradle-plugin/src/main/java/com/blankj/bus/BusInject.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class BusInject {
1515
File decompressedJar = new File(decompressedJarPath)
1616
ZipUtils.unzipFile(busJar, decompressedJar)
1717

18-
CtClass busUtils = JavassistUtils.getPool().get(Config.BUS_UTILS_CLASS)
18+
CtClass busUtils = JavassistUtils.getClass(Config.BUS_UTILS_CLASS)
1919
CtMethod callMethod;
2020
try {
2121
callMethod = busUtils.getDeclaredMethod("injectShell");

bus-gradle-plugin/src/main/java/com/blankj/bus/BusPlugin.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.blankj.bus
33
import com.android.build.gradle.AppExtension
44
import com.android.build.gradle.AppPlugin
55
import com.blankj.util.LogUtils
6-
76
import org.gradle.api.Plugin
87
import org.gradle.api.Project
98

bus-gradle-plugin/src/main/java/com/blankj/bus/BusScan.groovy

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ import java.lang.reflect.Modifier
1515

1616
class BusScan {
1717

18+
HashMap<String, String> busStaticMap
1819
HashMap<String, String> busMap
1920
List<File> scans
2021
File busJar
2122

2223
BusScan() {
24+
busStaticMap = [:]
2325
busMap = [:]
2426
scans = []
2527
}
@@ -34,50 +36,52 @@ class BusScan {
3436
}
3537

3638
void scanDir(File root) {
39+
if (!root.isDirectory()) return
3740
String rootPath = root.getAbsolutePath()
3841
if (!rootPath.endsWith(Config.FILE_SEP)) {
3942
rootPath += Config.FILE_SEP
4043
}
4144

42-
if (root.isDirectory()) {
43-
root.eachFileRecurse(FileType.FILES) { File file ->
44-
def fileName = file.name
45-
if (!fileName.endsWith('.class')
46-
|| fileName.startsWith('R$')
47-
|| fileName == 'R.class'
48-
|| fileName == 'BuildConfig.class') {
49-
return
50-
}
45+
root.eachFileRecurse(FileType.FILES) { File file ->
46+
def fileName = file.name
47+
if (!fileName.endsWith('.class')
48+
|| fileName.startsWith('R$')
49+
|| fileName == 'R.class'
50+
|| fileName == 'BuildConfig.class') {
51+
return
52+
}
5153

52-
def filePath = file.absolutePath
53-
def packagePath = filePath.replace(rootPath, '')
54-
def className = packagePath.replace(Config.FILE_SEP, ".")
55-
// delete .class
56-
className = className.substring(0, className.length() - 6)
54+
def filePath = file.absolutePath
55+
def packagePath = filePath.replace(rootPath, '')
56+
def className = packagePath.replace(Config.FILE_SEP, ".")
57+
// delete .class
58+
className = className.substring(0, className.length() - 6)
5759

58-
CtClass ctClass = JavassistUtils.getPool().get(className)
59-
CtMethod[] methods = ctClass.getMethods();
60-
for (CtMethod method : methods) {
61-
if (method.hasAnnotation(BusUtils.Subscribe.class)) {
62-
String name = ((BusUtils.Subscribe) method.getAnnotation(BusUtils.Subscribe.class)).name();
63-
if (busMap.containsKey(name)) {
64-
LogUtils.l("bus of " + name + " has registered: " + method.getLongName());
65-
continue;
66-
}
67-
String methodLongName = method.getLongName();
68-
if (Modifier.isStatic(method.getModifiers())) {
69-
String sign = method.getReturnType().getName() + ' ' + methodLongName;
70-
busMap.put(name, sign);
71-
} else {// may be is kotlin
72-
processKt(method, name, methodLongName)
60+
CtClass ctClass = JavassistUtils.getClass(className)
61+
CtMethod[] methods = ctClass.getMethods();
62+
for (CtMethod method : methods) {
63+
if (method.hasAnnotation(BusUtils.Subscribe.class)) {
64+
String name = ((BusUtils.Subscribe) method.getAnnotation(BusUtils.Subscribe.class)).name();
65+
if (busStaticMap.containsKey(name)) {
66+
LogUtils.l("bus of " + name + " has registered: " + method.getLongName());
67+
continue;
68+
}
69+
String methodLongName = method.getLongName();
70+
if (Modifier.isStatic(method.getModifiers())) {
71+
String sign = method.getReturnType().getName() + ' ' + methodLongName;
72+
busStaticMap.put(name, sign);
73+
} else {// may be is kotlin
74+
if (!processKt(method, name, methodLongName)) {
75+
int priority = ((BusUtils.Subscribe) method.getAnnotation(BusUtils.Subscribe.class)).priority();
76+
processEventBus(method, name, methodLongName);
7377
}
7478
}
7579
}
7680
}
7781
}
7882
}
7983

80-
private void processKt(CtMethod method, String name, String longMethodName) {
84+
private boolean processKt(CtMethod method, String name, String longMethodName) {
8185
CtClass ktClass = method.getDeclaringClass();
8286
try {
8387
CtField instance = ktClass.getField("INSTANCE");
@@ -86,28 +90,35 @@ class BusScan {
8690
String temp = longMethodName.substring(0, i);
8791
int j = temp.lastIndexOf('.');
8892
String sign = method.getReturnType().getName() + ' ' +
89-
longMethodName.substring(0, j) +
90-
".INSTANCE" +
91-
longMethodName.substring(j);
92-
busMap.put(name, sign);
93+
longMethodName.substring(0, j) +
94+
".INSTANCE" +
95+
longMethodName.substring(j);
96+
busStaticMap.put(name, sign);
97+
return true
9398
} catch (NotFoundException ignore) {
9499
String innerClassSimpleName = ktClass.getSimpleName();
95100
if (innerClassSimpleName.contains('$') && !innerClassSimpleName.endsWith('$')) {
96101
String innerClassName = ktClass.getName();
97102
String outerClassName = innerClassName.substring(0, innerClassName.lastIndexOf('$'));
98-
CtClass outerClass = JavassistUtils.getPool().get(outerClassName);
103+
CtClass outerClass = JavassistUtils.getClass(outerClassName);
99104
try {
100105
CtField ctField = outerClass.getField(innerClassSimpleName.substring(innerClassSimpleName.lastIndexOf('$') + 1));
101106
String fieldName = ctField.getName();
102107
String methodName = longMethodName.replace('$' + fieldName, '.' + fieldName);
103108
String sign = method.getReturnType().getName() + ' ' + methodName;
104-
busMap.put(name, sign);
109+
busStaticMap.put(name, sign);
110+
return true
105111
} catch (NotFoundException ignored) {
106112
LogUtils.l(longMethodName + "is not static");
107113
}
108114
} else {
109115
LogUtils.l(longMethodName + "is not static");
110116
}
111117
}
118+
return false
119+
}
120+
121+
private boolean processEventBus(CtMethod method, String name, String longMethodName) {
122+
112123
}
113124
}

bus-gradle-plugin/src/main/java/com/blankj/bus/BusTransform.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import com.android.build.gradle.internal.pipeline.TransformManager
55
import com.blankj.util.JavassistUtils
66
import com.blankj.util.JsonUtils
77
import com.blankj.util.LogUtils
8-
98
import org.apache.commons.io.FileUtils
109
import org.gradle.api.Project
1110

@@ -86,7 +85,8 @@ class BusTransform extends Transform {
8685
FileUtils.copyFile(jar, dest)
8786

8887
if (jarName.startsWith("com.blankj:utilcode:")
89-
|| jarName.contains("utilcode-lib")) {
88+
|| jarName.startsWith("com.blankj:utilcodex:")
89+
|| jarName.equals(":utilcode:lib")) {
9090
busScan.busJar = dest
9191
LogUtils.l("bus jar: $jarName [$dest]")
9292
return
@@ -105,10 +105,10 @@ class BusTransform extends Transform {
105105

106106
if (busScan.busJar != null) {
107107
File jsonFile = new File(mProject.projectDir.getAbsolutePath(), "__bus__.json")
108-
String busJson = JsonUtils.getFormatJson(busScan.busMap)
108+
String busJson = JsonUtils.getFormatJson(busScan.busStaticMap)
109109
LogUtils.l(jsonFile.toString() + ": " + busJson)
110110
FileUtils.write(jsonFile, busJson)
111-
BusInject.start(busScan.busMap, busScan.busJar)
111+
BusInject.start(busScan.busStaticMap, busScan.busJar)
112112
} else {
113113
LogUtils.l('u should <implementation "com.blankj:utilcode:1.22.+">')
114114
}

0 commit comments

Comments
 (0)