Skip to content

Commit 5f0b789

Browse files
committed
see 03/09 log
1 parent 7cd66ff commit 5f0b789

File tree

30 files changed

+261
-121
lines changed

30 files changed

+261
-121
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* `20/01/20` [upd] Publish v1.26.1.
2+
* `20/01/19` [add] Publish bus plugin v1.4.
3+
* `20/01/18` [add] Publish api plugin v2.6.
4+
* `20/01/17` [upd] Leak Canary to v2.1.
15
* `19/12/08` [add] Publish bus plugin v2.5.
26
* `19/12/06` [add] Publish api plugin v1.3.
37
* `19/11/30` [add] Publish bus plugin v2.4. Publish api plugin v1.2.

buildApp.gradle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ android {
6767
dependencies {
6868
// LeakCanary
6969
debugImplementation Config.depConfig.leakcanary_android.dep
70-
debugImplementation Config.depConfig.leakcanary_support_fragment.dep
71-
releaseImplementation Config.depConfig.leakcanary_android_no_op.dep
7270

7371
debugImplementation Config.depConfig.lib_utildebug.dep
7472
releaseImplementation Config.depConfig.lib_utildebug_no_op.dep
@@ -84,8 +82,8 @@ dependencies {
8482
}
8583

8684
def getSuffix() {
87-
if (project.path == ":feature:launcher:app") return ""
88-
return project.path.replace(":", "_").substring(":feature".length(), project.path.length() - ":app".length())
85+
if (project.path == ":feature_launcher_app") return ""
86+
return "." + project.path.substring(":feature_".length(), project.path.length() - "_app".length())
8987
}
9088

9189
def configSigning() {

buildLib.gradle

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,19 @@ android {
2424
lintOptions {
2525
abortOnError false
2626
}
27-
}
2827

29-
afterEvaluate {
30-
generateReleaseBuildConfig.enabled = false
31-
generateDebugBuildConfig.enabled = false
28+
// viewBinding {
29+
// enabled = true
30+
// }
3231
}
3332

3433
dependencies {
35-
if (project.name == 'pkg' || project.name == 'mock') {
34+
if (project.name.endsWith("_pkg") || project.name.endsWith("_mock")) {
3635
// if module's name equals 'pkg', api all of export
3736
for (def entrySet : ConfigUtils.getApplyExports().entrySet()) {
3837
api entrySet.value.dep
3938
}
40-
} else if (project.name == 'export') {
39+
} else if (project.name.endsWith("_export")) {
4140
api Config.depConfig.lib_common.dep
4241
}
4342
}

buildSrc/src/main/groovy/Config.groovy

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@ class Config {
1111
static applicationId = 'com.blankj.androidutilcode'
1212
static appName = 'Util'
1313

14-
static compileSdkVersion = 28
14+
static compileSdkVersion = 29
1515
static minSdkVersion = 14
16-
static targetSdkVersion = 28
16+
static targetSdkVersion = 29
1717
static versionCode = 1_026_001
18-
static versionName = '1.26.1-alpha0'// E.g. 1.9.72 => 1,009,072
18+
static versionName = '1.26.1-alpha3'// E.g. 1.9.72 => 1,009,072
1919

2020
// lib version
21-
static gradlePluginVersion = '3.5.2'
21+
static gradlePluginVersion = '3.5.0'
2222
static kotlinVersion = '1.3.50'
2323
static supportVersion = '28.0.0'
24-
static leakcanaryVersion = '1.6.3'
2524

2625
static depConfig = [
2726
/*Never delete this line*/
@@ -54,10 +53,10 @@ class Config {
5453
// 本地第一次上传插件新的版本需设置 isApply = false, useLocal = true
5554
// 本地上传成功之后 isApply = true 即可应用插件来调试,后续版本更新无需设置 isApply = false
5655
// 发布版本的话把 isApply = false, useLocal = false,更新版本号,发布成功后 isApply = true 即可使用远程库版本
57-
plugin_api : new DepConfig(isApply: false, useLocal: true, pluginPath: "com.blankj:api-gradle-plugin:1.3-r4", pluginId: "com.blankj.api"),
56+
plugin_api : new DepConfig(isApply: true, useLocal: false, pluginPath: "com.blankj:api-gradle-plugin:1.4-r1", pluginId: "com.blankj.api"),
5857
//./gradlew plugin:api-gradle-plugin:uploadArchives // 上传到本地 maven
5958
//./gradlew plugin:api-gradle-plugin:bintrayUpload // 上传到 jcenter
60-
plugin_bus : new DepConfig(isApply: true, useLocal: true, pluginPath: "com.blankj:bus-gradle-plugin:2.5", pluginId: "com.blankj.bus"),
59+
plugin_bus : new DepConfig(isApply: true, useLocal: false, pluginPath: "com.blankj:bus-gradle-plugin:2.6-r2", pluginId: "com.blankj.bus"),
6160
//./gradlew plugin:bus-gradle-plugin:uploadArchives // 上传到本地 maven
6261
//./gradlew plugin:bus-gradle-plugin:bintrayUpload // 上传到 jcenter
6362

@@ -68,9 +67,7 @@ class Config {
6867

6968
kotlin : new DepConfig("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"),
7069

71-
leakcanary_android : new DepConfig("com.squareup.leakcanary:leakcanary-android:$leakcanaryVersion"),
72-
leakcanary_android_no_op : new DepConfig("com.squareup.leakcanary:leakcanary-android-no-op:$leakcanaryVersion"),
73-
leakcanary_support_fragment: new DepConfig("com.squareup.leakcanary:leakcanary-support-fragment:$leakcanaryVersion"),
70+
leakcanary_android : new DepConfig("com.squareup.leakcanary:leakcanary-android:2.1"),
7471

7572
free_proguard : new DepConfig("com.blankj:free-proguard:1.0.2"),
7673
swipe_panel : new DepConfig("com.blankj:swipe-panel:1.2"),
@@ -86,7 +83,7 @@ class Config {
8683
photo_view : new DepConfig("com.github.chrisbanes:PhotoView:2.0.0"),
8784

8885
test_junit : new DepConfig("junit:junit:4.12"),
89-
test_robolectric : new DepConfig("org.robolectric:robolectric:4.2"),
86+
test_robolectric : new DepConfig("org.robolectric:robolectric:4.3.1"),
9087
]
9188
}
9289
//./gradlew clean :lib:utilcode:bintrayUpload

buildSrc/src/main/groovy/ConfigUtils.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import org.gradle.api.invocation.Gradle
1414
class ConfigUtils {
1515

1616
static init(Gradle gradle) {
17-
GitUtils.init(gradle)
1817
generateDep(gradle)
1918
addCommonGradle(gradle)
2019
TaskDurationUtils.init(gradle)
20+
GitUtils.init(gradle)
2121
}
2222

2323
/**
@@ -47,10 +47,10 @@ class ConfigUtils {
4747
void beforeEvaluate(Project project) {
4848
// 在 project 的 build.gradle 前 do sth.
4949
if (project.subprojects.isEmpty()) {
50-
if (project.path.contains(":plugin:")) {
50+
if (project.name.startsWith("plugin")) {
5151
return
5252
}
53-
if (project.name == "app") {
53+
if (project.name.endsWith("_app")) {
5454
GLog.l(project.toString() + " applies buildApp.gradle")
5555
project.apply {
5656
from "${project.rootDir.path}/buildApp.gradle"

buildSrc/src/main/groovy/DepConfig.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ class DepConfig {
7575
return splits.length == 3 ? splits[2] : null
7676
}
7777

78+
String getLocalPath() {
79+
return ":" + localPath.replace(":", "_").substring(1)
80+
}
81+
7882
@Override
7983
String toString() {
8084
return "{ isApply = ${getFlag(isApply)}" +

buildSrc/src/main/groovy/GitUtils.groovy

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ class GitUtils {
1919
static void init(Gradle gradle) {
2020
rootProject = gradle.rootProject
2121
addGitHelpTask()
22-
// gradle.rootProject(new Action<Project>() {
23-
// @Override
24-
// void execute(Project project) {
25-
// addGitHelpTask()
26-
// }
27-
// })
2822
}
2923

3024
static def addGitHelpTask() {

feature/utilcode/pkg/src/main/java/com/blankj/utilcode/pkg/helper/DialogHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ object DialogHelper {
8888
contentView.findViewById<View>(R.id.keyboardDialogCloseBtn).setOnClickListener(listener)
8989

9090
dialog.dialog.setOnShowListener(DialogInterface.OnShowListener {
91-
KeyboardUtils.fixAndroidBug5497(dialog.dialog.window)
91+
KeyboardUtils.fixAndroidBug5497(dialog.dialog.window!!)
9292
})
9393
}
9494

lib/base/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ dependencies {
1212
api Config.depConfig.swipe_panel.dep
1313
api Config.depConfig.eventbus_lib.dep
1414
compileOnly Config.depConfig.lib_utildebug_no_op.dep
15-
compileOnly Config.depConfig.leakcanary_android_no_op.dep
1615
}

lib/base/src/main/java/com/blankj/base/BaseApplication.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.blankj.utilcode.util.CrashUtils;
99
import com.blankj.utilcode.util.LogUtils;
1010
import com.blankj.utilcode.util.ProcessUtils;
11-
import com.squareup.leakcanary.LeakCanary;
1211

1312
import java.util.ArrayList;
1413

@@ -43,22 +42,10 @@ protected void attachBaseContext(Context base) {
4342
public void onCreate() {
4443
super.onCreate();
4544
sInstance = this;
46-
initLeakCanary();
4745
initLog();
4846
initCrash();
4947
}
5048

51-
private void initLeakCanary() {// 内存泄露检查工具
52-
if (isDebug()) {
53-
if (LeakCanary.isInAnalyzerProcess(this)) {
54-
// This process is dedicated to LeakCanary for heap analysis.
55-
// You should not init your app in this process.
56-
return;
57-
}
58-
LeakCanary.install(this);
59-
}
60-
}
61-
6249
// init it in ur application
6350
public void initLog() {
6451
LogUtils.Config config = LogUtils.getConfig()

lib/utilcode/README-CN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ implementation 'com.blankj:utilcodex:1.26.0'
1313

1414
* ### Activity 相关 -> [ActivityUtils.java][activity.java] -> [Demo][activity.demo]
1515
```
16-
getActivityByView : 根据视图获取 Activity
16+
getAliveActivityByContext : 根据上下文获取存活的 Activity
1717
getActivityByContext : 根据上下文获取 Activity
1818
isActivityExists : 判断 Activity 是否存在
1919
startActivity : 启动 Activity
@@ -135,8 +135,8 @@ isNavBarVisible : 判断导航栏是否可见
135135
setNavBarColor : 设置导航栏颜色
136136
getNavBarColor : 获取导航栏颜色
137137
isSupportNavBar : 判断是否支持导航栏
138-
setNavBarLightMode : 设置状态栏是否为浅色模式
139-
isNavBarLightMode : 判断状态栏是否为浅色模式
138+
setNavBarLightMode : 设置导航栏是否为浅色模式
139+
isNavBarLightMode : 判断导航栏是否为浅色模式
140140
```
141141

142142
* ### 亮度相关 -> [BrightnessUtils.java][brightness.java] -> [Demo][brightness.demo]

lib/utilcode/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ implementation 'com.blankj:utilcodex:1.26.0'
1313

1414
* ### About Activity -> [ActivityUtils.java][activity.java] -> [Demo][activity.demo]
1515
```
16-
getActivityByView
16+
getAliveActivityByContext
1717
getActivityByContext
1818
isActivityExists
1919
startActivity
@@ -272,6 +272,8 @@ applyPressedBgAlpha
272272
applyPressedBgDark
273273
applySingleDebouncing
274274
applyGlobalDebouncing
275+
expandClickArea
276+
back2HomeFriendly
275277
ClickUtils#OnDebouncingClickListener
276278
ClickUtils#OnMultiClickListener
277279
```

lib/utilcode/src/main/java/com/blankj/utilcode/constant/RegexConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public final class RegexConstants {
2222
* <p>global star: 1349</p>
2323
* <p>virtual operator: 170</p>
2424
*/
25-
public static final String REGEX_MOBILE_EXACT = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(16[6])|(17[0,1,3,5-8])|(18[0-9])|(19[1,8,9]))\\d{8}$";
25+
public static final String REGEX_MOBILE_EXACT = "^((13[0-9])|(14[57])|(15[0-35-9])|(16[6])|(17[0135-8])|(18[0-9])|(19[189]))\\d{8}$";
2626
/**
2727
* Regex of telephone number.
2828
*/

lib/utilcode/src/main/java/com/blankj/utilcode/util/ActivityUtils.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ private ActivityUtils() {
4040
}
4141

4242
/**
43-
* Return the activity by view.
43+
* Return the activity by context.
4444
*
45-
* @param view The view.
46-
* @return the activity by view.
45+
* @param context The context.
46+
* @return the activity by context.
4747
*/
48-
public static Activity getActivityByView(@NonNull View view) {
49-
return getActivityByContext(view.getContext());
48+
public static Activity getAliveActivityByContext(Context context) {
49+
Activity activity = getActivityByContext(context);
50+
if (!isActivityAlive(activity)) return null;
51+
return activity;
5052
}
5153

5254
/**

lib/utilcode/src/main/java/com/blankj/utilcode/util/BarUtils.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import android.view.Window;
2626
import android.view.WindowManager;
2727

28+
import java.lang.ref.WeakReference;
29+
import java.lang.reflect.Field;
2830
import java.lang.reflect.Method;
2931

3032
import static android.Manifest.permission.EXPAND_STATUS_BAR;
@@ -272,7 +274,7 @@ public static View setStatusBarColor(@NonNull final Window window,
272274
public static void setStatusBarColor(@NonNull final View fakeStatusBar,
273275
@ColorInt final int color) {
274276
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
275-
Activity activity = getActivityByView(fakeStatusBar);
277+
Activity activity = getActivityByContext(fakeStatusBar.getContext());
276278
if (activity == null) return;
277279
transparentStatusBar(activity);
278280
fakeStatusBar.setVisibility(View.VISIBLE);
@@ -289,7 +291,7 @@ public static void setStatusBarColor(@NonNull final View fakeStatusBar,
289291
*/
290292
public static void setStatusBarCustom(@NonNull final View fakeStatusBar) {
291293
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
292-
Activity activity = getActivityByView(fakeStatusBar);
294+
Activity activity = getActivityByContext(fakeStatusBar.getContext());
293295
if (activity == null) return;
294296
transparentStatusBar(activity);
295297
fakeStatusBar.setVisibility(View.VISIBLE);
@@ -334,7 +336,7 @@ public static void setStatusBarColor4Drawer(@NonNull final DrawerLayout drawer,
334336
@ColorInt final int color,
335337
final boolean isTop) {
336338
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
337-
Activity activity = getActivityByView(fakeStatusBar);
339+
Activity activity = getActivityByContext(fakeStatusBar.getContext());
338340
if (activity == null) return;
339341
transparentStatusBar(activity);
340342
drawer.setFitsSystemWindows(false);
@@ -699,15 +701,24 @@ public static boolean isNavBarLightMode(@NonNull final Window window) {
699701
return false;
700702
}
701703

702-
private static Activity getActivityByView(@NonNull final View view) {
703-
Context context = view.getContext();
704+
private static Activity getActivityByContext(Context context) {
705+
if (context instanceof Activity) return (Activity) context;
706+
if (context != null && context.getClass().getName().equals("com.android.internal.policy.DecorContext")) {
707+
try {
708+
Field mActivityContextField = context.getClass().getDeclaredField("mActivityContext");
709+
mActivityContextField.setAccessible(true);
710+
//noinspection unchecked
711+
return ((WeakReference<Activity>) mActivityContextField.get(context)).get();
712+
} catch (Exception e) {
713+
e.printStackTrace();
714+
}
715+
}
704716
while (context instanceof ContextWrapper) {
705717
if (context instanceof Activity) {
706718
return (Activity) context;
707719
}
708720
context = ((ContextWrapper) context).getBaseContext();
709721
}
710-
Log.e("BarUtils", "the view's Context is not an Activity.");
711722
return null;
712723
}
713724
}

lib/utilcode/src/main/java/com/blankj/utilcode/util/ClickUtils.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,12 @@ private static boolean isValid(@NonNull final View view, final long duration) {
447447
return true;
448448
}
449449
long preTime = (Long) tag;
450-
if (curTime - preTime <= duration) return false;
450+
if (curTime - preTime < 0) {
451+
view.setTag(DEBOUNCING_TAG, curTime);
452+
return false;
453+
} else if (curTime - preTime <= duration) {
454+
return false;
455+
}
451456
view.setTag(DEBOUNCING_TAG, curTime);
452457
return true;
453458
}

0 commit comments

Comments
 (0)