Skip to content

Commit f6367ba

Browse files
committed
see 05/03 log
1 parent 93315a6 commit f6367ba

File tree

43 files changed

+728
-1160
lines changed

Some content is hidden

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

43 files changed

+728
-1160
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
* `20/05/03` [add] Publish bus plugin v2.5. Publish api plugin v1.3. Publish. Publish 1.28.4.
2+
* `20/04/30` [add] BaseItem support partialUpdate.
3+
* `20/04/29` [add] Publish plugin lib com.blankj:base-transform:1.0.
4+
* `20/04/28` [fix] LanguageUtils#applyLanguage.
5+
* `20/04/27` [fix] BarUtils#isNavBarVisible.
16
* `20/04/26` [fix] Utils#init fit tinker. Publish 1.28.3.
27
* `20/04/25` [fix] UriUtils#uri2File Unknown URI. Publish 1.28.2.
38
* `20/04/24` [add] SnackbarUtils support show on the top; UriUtils#uri2InputStream.

buildSrc/src/main/groovy/Config.groovy

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Config {
1515
static minSdkVersion = 14
1616
static targetSdkVersion = 29
1717
static versionCode = 1_028_002
18-
static versionName = '1.28.3'// E.g. 1.9.72 => 1,009,072
18+
static versionName = '1.28.4'// E.g. 1.9.72 => 1,009,072
1919

2020
// lib version
2121
static gradlePluginVersion = '3.5.0'
@@ -25,8 +25,9 @@ class Config {
2525
static depConfig = [
2626
/*Never delete this line*/
2727
/*Generated by "config.json"*/
28-
plugin_api_gradle_plugin : new DepConfig(true , true , ":plugin:api-gradle-plugin"),
29-
plugin_bus_gradle_plugin : new DepConfig(true , true , ":plugin:bus-gradle-plugin"),
28+
plugin_api_gradle_plugin : new DepConfig(false, true , ":plugin:api-gradle-plugin"),
29+
plugin_bus_gradle_plugin : new DepConfig(false, true , ":plugin:bus-gradle-plugin"),
30+
plugin_lib_base_transform : new DepConfig(false, true , ":plugin:lib:base-transform", "com.blankj:base-transform:1.0"),
3031
feature_mock : new DepConfig(false, true , ":feature:mock"),
3132
feature_launcher_app : new DepConfig(true , true , ":feature:launcher:app"),
3233
feature_main_app : new DepConfig(false, true , ":feature:main:app"),
@@ -52,12 +53,12 @@ class Config {
5253

5354
// 上传新版本插件更新 pluginPath 中的版本号,并设置 isApply = false
5455
// 通过 mavenLocal 上传本地版本,设置 isApply = true 即可应用插件来调试,最后通过 bintrayUpload 来发布插件
55-
plugin_api : new DepConfig(isApply: true, useLocal: false, pluginPath: "com.blankj:api-gradle-plugin:1.2", pluginId: "com.blankj.api"),
56-
//./gradlew plugin:plugin_api-gradle-plugin:mavenLocal // 上传到本地 mavenLocal
57-
//./gradlew plugin:plugin_api-gradle-plugin:bintrayUpload // 上传到 jcenter
58-
plugin_bus : new DepConfig(isApply: true, useLocal: false, pluginPath: "com.blankj:bus-gradle-plugin:2.4", pluginId: "com.blankj.bus"),
59-
//./gradlew plugin:plugin_bus-gradle-plugin:mavenLocal // 上传到本地 mavenLocal
60-
//./gradlew plugin:plugin_bus-gradle-plugin:bintrayUpload // 上传到 jcenter
56+
plugin_api : new DepConfig(isApply: true, useLocal: false, pluginPath: "com.blankj:api-gradle-plugin:1.3", pluginId: "com.blankj.api"),
57+
//./gradlew clean plugin:plugin_api-gradle-plugin:mavenLocal // 上传到本地 mavenLocal
58+
//./gradlew clean plugin:plugin_api-gradle-plugin:bintrayUpload // 上传到 jcenter
59+
plugin_bus : new DepConfig(isApply: true, useLocal: false, pluginPath: "com.blankj:bus-gradle-plugin:2.5", pluginId: "com.blankj.bus"),
60+
//./gradlew clean plugin:plugin_bus-gradle-plugin:mavenLocal // 上传到本地 mavenLocal
61+
//./gradlew clean plugin:plugin_bus-gradle-plugin:bintrayUpload // 上传到 jcenter
6162

6263
support_appcompat_v7 : new DepConfig("com.android.support:appcompat-v7:$supportVersion"),
6364
support_design : new DepConfig("com.android.support:design:$supportVersion"),

buildSrc/src/main/groovy/ConfigUtils.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ConfigUtils {
4747
void beforeEvaluate(Project project) {
4848
// 在 project 的 build.gradle 前 do sth.
4949
if (project.subprojects.isEmpty()) {
50-
if (project.name.startsWith("plugin")) {
50+
if (project.path.startsWith(":plugin")) {
5151
return
5252
}
5353
if (project.name.endsWith("_app")) {

buildSrc/src/main/groovy/TaskDurationUtils.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TaskDurationUtils {
3232
@Override
3333
void afterExecute(Task task, TaskState state) {
3434
def exeDuration = System.currentTimeMillis() - task.ext.startTime
35-
if (exeDuration >= 100) {
35+
if (exeDuration >= 500) {
3636
taskInfoList.add(new TaskInfo(task: task, exeDuration: exeDuration))
3737
}
3838
}

config.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
"pkgConfig": [],
66
"proConfigDesc": "proConfig 配置的是使用本地还是仓库,优先级低于 appConfig 和 pkgConfig",
77
"proConfig": [
8-
{"isApply": true, "useLocal": true, "localPath": ":plugin:api-gradle-plugin"},
9-
{"isApply": true, "useLocal": true, "localPath": ":plugin:bus-gradle-plugin"},
8+
{"isApply": false, "useLocal": true, "localPath": ":plugin:api-gradle-plugin"},
9+
{"isApply": false, "useLocal": true, "localPath": ":plugin:bus-gradle-plugin"},
10+
{"isApply": false, "useLocal": true, "localPath": ":plugin:lib:base-transform", "remotePath": "com.blankj:base-transform:1.0"},
1011
{"isApply": true, "useLocal": true, "localPath": ":feature:mock"},
1112
{"isApply": true, "useLocal": true, "localPath": ":feature:launcher:app"},
1213
{"isApply": true, "useLocal": true, "localPath": ":feature:main:app"},

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ object DialogHelper {
8686

8787
dialog.dialog.setOnShowListener(DialogInterface.OnShowListener {
8888
KeyboardUtils.fixAndroidBug5497(dialog.dialog.window!!)
89+
KeyboardUtils.showSoftInput()
8990
})
9091
}
9192

gradle/publish.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def configMaven(Project project, PublishExtension ext) {
5454
}
5555

5656
project.tasks.create("mavenLocal", Upload) {
57+
group("publishing")
5758
configuration = project.configurations.archives
5859

5960
repositories.mavenDeployer {

lib/base/src/main/java/com/blankj/base/rv/BaseItem.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ static ItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType
3838

3939
public abstract void bind(@NonNull final ItemViewHolder holder, final int position);
4040

41+
public void partialUpdate(List<Object> payloads) {
42+
}
43+
4144
void bindViewHolder(@NonNull final ItemViewHolder holder, final int position) {
4245
if (mOnItemClickListener != null) {
4346
holder.itemView.setOnClickListener(new View.OnClickListener() {

lib/base/src/main/java/com/blankj/base/rv/BaseItemAdapter.java

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ public final void onBindViewHolder(@NonNull ItemViewHolder holder, int position)
5353
mItems.get(position).bindViewHolder(holder, position);
5454
}
5555

56+
@Override
57+
public void onBindViewHolder(@NonNull ItemViewHolder holder, int position, @NonNull List<Object> payloads) {
58+
if (payloads.isEmpty()) {
59+
super.onBindViewHolder(holder, position, payloads);
60+
return;
61+
}
62+
mItems.get(position).partialUpdate(payloads);
63+
}
64+
5665
@Override
5766
public int getItemCount() {
5867
return mItems.size();
@@ -151,14 +160,41 @@ public int removeItemById(final long id, boolean notifyRemoved) {
151160
///////////////////////////////////////////////////////////////////////////
152161

153162
public void updateItem(@NonNull final Item item) {
163+
updateItems(item, 1, null);
164+
}
165+
166+
public void updateItem(@IntRange(from = 0) final int index) {
167+
updateItems(index, 1, null);
168+
}
169+
170+
public void updateItem(@NonNull final Item item, Object payload) {
171+
updateItems(item, 1, payload);
172+
}
173+
174+
public void updateItem(@IntRange(from = 0) final int index, Object payload) {
175+
updateItems(index, 1, payload);
176+
}
177+
178+
public void updateItems(@NonNull final Item item, int itemCount) {
154179
int itemIndex = mItems.indexOf(item);
155180
if (itemIndex != -1) {
156-
notifyItemChanged(itemIndex);
181+
updateItems(itemIndex, itemCount);
157182
}
158183
}
159184

160-
public void updateItem(@IntRange(from = 0) final int index) {
161-
notifyItemChanged(index);
185+
public void updateItems(@IntRange(from = 0) final int index, int itemCount) {
186+
updateItems(index, itemCount, null);
187+
}
188+
189+
public void updateItems(@NonNull final Item item, int itemCount, Object payload) {
190+
int itemIndex = mItems.indexOf(item);
191+
if (itemIndex != -1) {
192+
updateItems(itemIndex, itemCount, payload);
193+
}
194+
}
195+
196+
public void updateItems(@IntRange(from = 0) final int index, int itemCount, Object payload) {
197+
notifyItemRangeChanged(index, itemCount, payload);
162198
}
163199

164200
public void addItem(@NonNull final Item item) {

lib/utilcode/README-CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.28.3'
5+
implementation 'com.blankj:utilcode:1.28.4'
66
77
// if u use AndroidX, use the following
8-
implementation 'com.blankj:utilcodex:1.28.3'
8+
implementation 'com.blankj:utilcodex:1.28.4'
99
```
1010

1111

lib/utilcode/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.28.3'
5+
implementation 'com.blankj:utilcode:1.28.4'
66
77
// if u use AndroidX, use the following
8-
implementation 'com.blankj:utilcodex:1.28.3'
8+
implementation 'com.blankj:utilcodex:1.28.4'
99
```
1010

1111

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ public static void setNavBarVisibility(@NonNull final Window window, boolean isV
515515
final View child = decorView.getChildAt(i);
516516
final int id = child.getId();
517517
if (id != View.NO_ID) {
518-
String resourceEntryName = Resources.getSystem().getResourceEntryName(id);
518+
String resourceEntryName = getResNameById(id);
519519
if ("navigationBarBackground".equals(resourceEntryName)) {
520520
child.setVisibility(isVisible ? View.VISIBLE : View.INVISIBLE);
521521
}
@@ -556,7 +556,7 @@ public static boolean isNavBarVisible(@NonNull final Window window) {
556556
final View child = decorView.getChildAt(i);
557557
final int id = child.getId();
558558
if (id != View.NO_ID) {
559-
String resourceEntryName = Resources.getSystem().getResourceEntryName(id);
559+
String resourceEntryName = getResNameById(id);
560560
if ("navigationBarBackground".equals(resourceEntryName)
561561
&& child.getVisibility() == View.VISIBLE) {
562562
isVisible = true;
@@ -571,6 +571,14 @@ public static boolean isNavBarVisible(@NonNull final Window window) {
571571
return isVisible;
572572
}
573573

574+
private static String getResNameById(int id) {
575+
try {
576+
return Utils.getApp().getResources().getResourceEntryName(id);
577+
} catch (Exception ignore) {
578+
return "";
579+
}
580+
}
581+
574582
/**
575583
* Set the navigation bar's color.
576584
*

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,23 @@ protected void onReceiveResult(int resultCode, Bundle resultData) {
9797
* @param activity The activity.
9898
*/
9999
public static void hideSoftInput(@NonNull final Activity activity) {
100-
View view = activity.getCurrentFocus();
100+
hideSoftInput(activity.getWindow());
101+
}
102+
103+
/**
104+
* Hide the soft input.
105+
*
106+
* @param window The window.
107+
*/
108+
public static void hideSoftInput(@NonNull final Window window) {
109+
View view = window.getCurrentFocus();
101110
if (view == null) {
102-
View decorView = activity.getWindow().getDecorView();
111+
View decorView = window.getDecorView();
103112
View focusView = decorView.findViewWithTag("keyboardTagView");
104113
if (focusView == null) {
105-
view = new EditText(activity);
114+
view = new EditText(window.getContext());
106115
view.setTag("keyboardTagView");
107-
((ViewGroup) decorView).addView(view, 1, 1);
116+
((ViewGroup) decorView).addView(view, 0, 0);
108117
} else {
109118
view = focusView;
110119
}

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

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static void applySystemLanguage(final String activityClassName) {
6969
* @param locale The language of locale.
7070
*/
7171
public static void applyLanguage(@NonNull final Locale locale) {
72-
if (isAppliedLanguage()) return;
72+
if (isAppliedLanguage(locale)) return;
7373
applyLanguage(locale, "", false, false);
7474
}
7575

@@ -115,9 +115,7 @@ private static void applyLanguage(@NonNull final Locale locale,
115115
if (isFollowSystem) {
116116
UtilsBridge.getSpUtils4Utils().put(KEY_LOCALE, VALUE_FOLLOW_SYSTEM);
117117
} else {
118-
String localLanguage = locale.getLanguage();
119-
String localCountry = locale.getCountry();
120-
UtilsBridge.getSpUtils4Utils().put(KEY_LOCALE, localLanguage + "$" + localCountry);
118+
UtilsBridge.getSpUtils4Utils().put(KEY_LOCALE, locale2String(locale));
121119
}
122120

123121
updateLanguage(Utils.getApp(), locale);
@@ -149,6 +147,25 @@ public static boolean isAppliedLanguage() {
149147
return !TextUtils.isEmpty(UtilsBridge.getSpUtils4Utils().getString(KEY_LOCALE));
150148
}
151149

150+
/**
151+
* Return whether applied the language by {@link LanguageUtils}.
152+
*
153+
* @param locale The locale.
154+
* @return {@code true}: yes<br>{@code false}: no
155+
*/
156+
public static boolean isAppliedLanguage(Locale locale) {
157+
final String spLocale = UtilsBridge.getSpUtils4Utils().getString(KEY_LOCALE);
158+
if (TextUtils.isEmpty(spLocale)) {
159+
return false;
160+
}
161+
if (VALUE_FOLLOW_SYSTEM.equals(spLocale)) {
162+
return false;
163+
}
164+
Locale settingLocale = string2Locale(spLocale);
165+
if (settingLocale == null) return false;
166+
return isSameLocale(settingLocale, locale);
167+
}
168+
152169
/**
153170
* Return the locale.
154171
*
@@ -159,7 +176,7 @@ public static Locale getCurrentLocale() {
159176
}
160177

161178
static void applyLanguage(@NonNull final Activity activity) {
162-
final String spLocale = UtilsBridge.getSpUtils4Utils().getString(KEY_LOCALE);
179+
String spLocale = UtilsBridge.getSpUtils4Utils().getString(KEY_LOCALE);
163180
if (TextUtils.isEmpty(spLocale)) {
164181
return;
165182
}
@@ -171,17 +188,28 @@ static void applyLanguage(@NonNull final Activity activity) {
171188
return;
172189
}
173190

174-
String[] language_country = spLocale.split("\\$");
175-
if (language_country.length != 2) {
176-
Log.e("LanguageUtils", "The string of " + spLocale + " is not in the correct format.");
177-
return;
178-
}
179-
180-
Locale settingLocale = new Locale(language_country[0], language_country[1]);
191+
Locale settingLocale = string2Locale(spLocale);
192+
if (settingLocale == null) return;
181193
updateLanguage(Utils.getApp(), settingLocale);
182194
updateLanguage(activity, settingLocale);
183195
}
184196

197+
private static String locale2String(Locale locale) {
198+
String localLanguage = locale.getLanguage();
199+
String localCountry = locale.getCountry();
200+
return localLanguage + "$" + localCountry;
201+
}
202+
203+
private static Locale string2Locale(String str) {
204+
String[] language_country = str.split("\\$");
205+
if (language_country.length != 2) {
206+
Log.e("LanguageUtils", "The string of " + str + " is not in the correct format.");
207+
return null;
208+
}
209+
return new Locale(language_country[0], language_country[1]);
210+
}
211+
212+
185213
private static void updateLanguage(final Context context, Locale locale) {
186214
Resources resources = context.getResources();
187215
Configuration config = resources.getConfiguration();
@@ -207,8 +235,8 @@ private static void updateLanguage(final Context context, Locale locale) {
207235
resources.updateConfiguration(config, dm);
208236
}
209237

210-
private static boolean isSameLocale(Locale locale, Locale contextLocale) {
211-
return UtilsBridge.equals(contextLocale.getLanguage(), locale.getLanguage())
212-
&& UtilsBridge.equals(contextLocale.getCountry(), locale.getCountry());
238+
private static boolean isSameLocale(Locale l0, Locale l1) {
239+
return UtilsBridge.equals(l1.getLanguage(), l0.getLanguage())
240+
&& UtilsBridge.equals(l1.getCountry(), l0.getCountry());
213241
}
214242
}

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,6 @@ public boolean dispatchTouchEvent(UtilsTransActivity activity, MotionEvent ev) {
447447

448448
@Override
449449
public void onDestroy(final UtilsTransActivity activity) {
450-
//如果是unity调用,app从后台切回,当前activity会被强制关闭,此时正常流程不会触发,所以在这里检测
451450
if (currentRequestCode != -1) {
452451
checkRequestCallback(currentRequestCode);
453452
currentRequestCode = -1;
@@ -471,17 +470,12 @@ private void checkRequestCallback(int requestCode) {
471470
sSimpleCallback4WriteSettings = null;
472471
} else if (requestCode == TYPE_DRAW_OVERLAYS) {
473472
if (sSimpleCallback4DrawOverlays == null) return;
474-
UtilsBridge.runOnUiThreadDelayed(new Runnable() {
475-
@Override
476-
public void run() {
477-
if (isGrantedDrawOverlays()) {
478-
sSimpleCallback4DrawOverlays.onGranted();
479-
} else {
480-
sSimpleCallback4DrawOverlays.onDenied();
481-
}
482-
sSimpleCallback4DrawOverlays = null;
483-
}
484-
}, 100);
473+
if (isGrantedDrawOverlays()) {
474+
sSimpleCallback4DrawOverlays.onGranted();
475+
} else {
476+
sSimpleCallback4DrawOverlays.onDenied();
477+
}
478+
sSimpleCallback4DrawOverlays = null;
485479
}
486480
}
487481
}

plugin/api-gradle-plugin/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Change Log
22

3-
## v1.2(2020/11/30)
3+
## v1.3(2020/04/29)
4+
重构使用 base-transform
5+
6+
## v1.2(2019/11/30)
47
去除 gradle 版本依赖的问题
58

69
## v1.1(2019/10/30)

0 commit comments

Comments
 (0)