Skip to content

Commit 2ee43f1

Browse files
authored
Merge pull request Blankj#812 from Blankj/1.23.1
1.23.1
2 parents cb6283c + 33339d3 commit 2ee43f1

File tree

158 files changed

+3053
-4383
lines changed

Some content is hidden

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

158 files changed

+3053
-4383
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* `19/01/23` [add] Modify the demo of utilcode use kotlin. Publish v1.23.1.
2+
* `19/01/22` [fix] AppUtils#installApp.
13
* `19/01/17` [fix] Publish v1.23.0.
24
* `19/01/16` [fix] BarUtils get Activity from view and delete the function of set status bar alpha.
35
* `19/01/15` [add] ColorUtils.

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.23.0-brightgreen.svg
44+
[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.23.1-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.23.0-brightgreen.svg
44+
[aucSvg]: https://img.shields.io/badge/AndroidUtilCode-v1.23.1-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

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

config.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ ext {
55
compileSdkVersion = 27
66
minSdkVersion = 14
77
targetSdkVersion = 27
8-
versionCode = 1_023_000
9-
versionName = '1.23.0'// E.g. 1.9.72 => 1,009,072
8+
versionCode = 1_023_001
9+
versionName = '1.23.1'// E.g. 1.9.72 => 1,009,072
1010

1111
bus = [
1212
isDebug: false,

launcher/app/__bus__.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"SubUtilActivity#start": "void com.blankj.subutil.pkg.feature.SubUtilActivity.start(android.content.Context)",
3-
"CoreUtilActivity#start": "void com.blankj.utilcode.pkg.feature.CoreUtilActivity.start(android.content.Context)"
3+
"CoreUtilActivity#start": "void com.blankj.utilcode.pkg.feature.CoreUtilActivity.Companion.start(android.content.Context)"
44
}

lib/base/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ dependencies {
1515
api dep.free_proguard
1616
api 'com.r0adkll:slidableactivity:2.0.5'
1717
compileOnly dep.leakcanary.android_no_op
18-
// api 'com.blankj:utilcode:1.23.0'
18+
// api 'com.blankj:utilcode:1.23.1'
1919
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ open class BaseApplication : Application() {
8383
}
8484
}
8585

86-
protected fun isDebug(): Boolean {
86+
fun isDebug(): Boolean {
8787
if (isDebug == null) isDebug = AppUtils.isAppDebug()
8888
return isDebug!!
8989
}

subutil/lib/src/main/java/com/blankj/subutil/util/HttpsUtil renamed to subutil/lib/src/main/java/com/blankj/subutil/util/HttpsUtil.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
public class HttpsUtil {
1414

1515
private static final int CONNECT_TIMEOUT_TIME = 15000;
16-
private static final int READ_TIMEOUT_TIME = 19000;
16+
private static final int READ_TIMEOUT_TIME = 19000;
1717

1818
/**
1919
* POST + JSON
2020
*
2121
* @param data send data
22-
* @param url target url
22+
* @param url target url
2323
* @return data receive from server
2424
* @author MilkZS
2525
*/
@@ -31,7 +31,7 @@ public static String postJson(String data, String url) {
3131
* POST + FORM
3232
*
3333
* @param data send data
34-
* @param url target url
34+
* @param url target url
3535
* @return data receive from serv
3636
* @author MilkZS
3737
*/
@@ -43,7 +43,7 @@ public static String postForm(String data, String url) {
4343
* GET + JSON
4444
*
4545
* @param data send data
46-
* @param url target url
46+
* @param url target url
4747
* @return data receive from server
4848
* @author MilkZS
4949
*/
@@ -55,7 +55,7 @@ public static String getJson(String data, String url) {
5555
* GET + FORM
5656
*
5757
* @param data send data
58-
* @param url target url
58+
* @param url target url
5959
* @return data receive from server
6060
* @author MilkZS
6161
*/

utilcode/README-CN.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.23.0'
5+
implementation 'com.blankj:utilcode:1.23.1'
66
```
77

88

@@ -445,9 +445,7 @@ getCaptureIntent : 获取拍照的意图
445445
* ### 键盘相关 -> [KeyboardUtils.java][keyboard.java] -> [Demo][keyboard.demo]
446446
```
447447
showSoftInput : 显示软键盘
448-
showSoftInputUsingToggle : 显示软键盘用 toggle
449448
hideSoftInput : 隐藏软键盘
450-
hideSoftInputUsingToggle : 隐藏软键盘用 toggle
451449
toggleSoftInput : 切换键盘显示与否状态
452450
isSoftInputVisible : 判断软键盘是否可见
453451
registerSoftInputChangedListener : 注册软键盘改变监听器

utilcode/README-STATIC-BUS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ apply plugin: "com.blankj.bus"
2727
给 base 模块添加 [AndroidUtilCode](https://github.com/Blankj/AndroidUtilCode) 依赖:
2828

2929
```groovy
30-
api "com.blankj:utilcode:1.23.0"
30+
api "com.blankj:utilcode:1.23.1"
3131
```
3232

3333
比如 module0 中存在的 `Module0Activity.java`,我们通常都是在它内部写一个 `start` 函数来启动它,现在我们给它添加 `@BusUtils.Subscribe` 注解,并给注解的 `name` 赋唯一值,要注意,函数务必要 `public static` 哦:

utilcode/README.md

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

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.23.0'
5+
implementation 'com.blankj:utilcode:1.23.1'
66
```
77

88

utilcode/app/__bus__.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"CoreUtilActivity#start": "void com.blankj.utilcode.pkg.feature.CoreUtilActivity.start(android.content.Context)"
2+
"CoreUtilActivity#start": "void com.blankj.utilcode.pkg.feature.CoreUtilActivity.Companion.start(android.content.Context)"
33
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,10 +969,11 @@ private static Intent getInstallAppIntent(final File file, final boolean isNewTa
969969
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
970970
data = Uri.fromFile(file);
971971
} else {
972-
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
973972
String authority = Utils.getApp().getPackageName() + ".utilcode.provider";
974973
data = FileProvider.getUriForFile(Utils.getApp(), authority, file);
974+
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
975975
}
976+
Utils.getApp().grantUriPermission(Utils.getApp().getPackageName(), data, Intent.FLAG_GRANT_READ_URI_PERMISSION);
976977
intent.setDataAndType(data, type);
977978
return isNewTask ? intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) : intent;
978979
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ public static void setNavBarVisibility(@NonNull final Window window, boolean isV
476476

477477
/**
478478
* Return whether the navigation bar visible.
479+
* <p>Call it in onWindowFocusChanged will get right result.</p>
479480
*
480481
* @param activity The activity.
481482
* @return {@code true}: yes<br>{@code false}: no
@@ -486,6 +487,7 @@ public static boolean isNavBarVisible(@NonNull final Activity activity) {
486487

487488
/**
488489
* Return whether the navigation bar visible.
490+
* <p>Call it in onWindowFocusChanged will get right result.</p>
489491
*
490492
* @param window The window.
491493
* @return {@code true}: yes<br>{@code false}: no

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public static int getRandomColor() {
201201
* @return the random color
202202
*/
203203
public static int getRandomColor(final boolean supportAlpha) {
204-
int high = supportAlpha ? (int) (Math.random() * 0xFF) << 24 : 0xFF000000;
205-
return high | (int) (Math.random() * 0xFFFFFF);
204+
int high = supportAlpha ? (int) (Math.random() * 0x100) << 24 : 0xFF000000;
205+
return high | (int) (Math.random() * 0x1000000);
206206
}
207207
}

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ public static String getMacAddress() {
120120
*/
121121
@RequiresPermission(allOf = {ACCESS_WIFI_STATE, INTERNET})
122122
public static String getMacAddress(final String... excepts) {
123-
String macAddress = getMacAddressByWifiInfo();
123+
String macAddress = getMacAddressByNetworkInterface();
124124
if (isAddressNotInExcepts(macAddress, excepts)) {
125125
return macAddress;
126126
}
127-
macAddress = getMacAddressByNetworkInterface();
127+
macAddress = getMacAddressByInetAddress();
128128
if (isAddressNotInExcepts(macAddress, excepts)) {
129129
return macAddress;
130130
}
131-
macAddress = getMacAddressByInetAddress();
131+
macAddress = getMacAddressByWifiInfo();
132132
if (isAddressNotInExcepts(macAddress, excepts)) {
133133
return macAddress;
134134
}
@@ -151,12 +151,13 @@ private static boolean isAddressNotInExcepts(final String address, final String.
151151
return true;
152152
}
153153

154-
@SuppressLint({"HardwareIds", "MissingPermission", "WifiManagerLeak"})
154+
@SuppressLint({"MissingPermission", "HardwareIds"})
155155
private static String getMacAddressByWifiInfo() {
156156
try {
157-
WifiManager wifi = (WifiManager) Utils.getApp().getSystemService(Context.WIFI_SERVICE);
157+
final WifiManager wifi = (WifiManager) Utils.getApp()
158+
.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
158159
if (wifi != null) {
159-
WifiInfo info = wifi.getConnectionInfo();
160+
final WifiInfo info = wifi.getConnectionInfo();
160161
if (info != null) return info.getMacAddress();
161162
}
162163
} catch (Exception e) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import java.io.IOException;
1111
import java.io.InputStream;
1212
import java.io.OutputStream;
13-
import java.net.HttpURLConnection;
1413
import java.net.URL;
1514
import java.security.DigestInputStream;
1615
import java.security.MessageDigest;
@@ -19,6 +18,8 @@
1918
import java.util.List;
2019
import java.util.Locale;
2120

21+
import javax.net.ssl.HttpsURLConnection;
22+
2223
/**
2324
* <pre>
2425
* author: Blankj
@@ -993,7 +994,7 @@ public static long getFileLength(final String filePath) {
993994
boolean isURL = filePath.matches("[a-zA-z]+://[^\\s]*");
994995
if (isURL) {
995996
try {
996-
HttpURLConnection conn = (HttpURLConnection) new URL(filePath).openConnection();
997+
HttpsURLConnection conn = (HttpsURLConnection) new URL(filePath).openConnection();
997998
conn.setRequestProperty("Accept-Encoding", "identity");
998999
conn.connect();
9991000
if (conn.getResponseCode() == 200) {

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

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,15 @@ public static void showSoftInput(final Activity activity) {
5050
* Show the soft input.
5151
*
5252
* @param activity The activity.
53+
* @param flags Provides additional operating flags. Currently may be
54+
* 0 or have the {@link InputMethodManager#SHOW_IMPLICIT} bit set.
5355
*/
5456
public static void showSoftInput(final Activity activity, final int flags) {
55-
InputMethodManager imm =
56-
(InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
57-
if (imm == null) return;
5857
View view = activity.getCurrentFocus();
5958
if (view == null) {
6059
view = new View(activity);
61-
view.setFocusable(true);
62-
view.setFocusableInTouchMode(true);
63-
view.requestFocus();
6460
}
65-
imm.showSoftInput(view, flags, new ResultReceiver(new Handler()) {
66-
@Override
67-
protected void onReceiveResult(int resultCode, Bundle resultData) {
68-
LogUtils.e(resultCode);
69-
}
70-
});
61+
showSoftInput(view, flags);
7162
}
7263

7364
/**
@@ -82,26 +73,26 @@ public static void showSoftInput(final View view) {
8273
/**
8374
* Show the soft input.
8475
*
85-
* @param view The view.
76+
* @param view The view.
77+
* @param flags Provides additional operating flags. Currently may be
78+
* 0 or have the {@link InputMethodManager#SHOW_IMPLICIT} bit set.
8679
*/
8780
public static void showSoftInput(final View view, final int flags) {
8881
InputMethodManager imm =
8982
(InputMethodManager) Utils.getApp().getSystemService(Context.INPUT_METHOD_SERVICE);
83+
if (imm == null) return;
9084
view.setFocusable(true);
9185
view.setFocusableInTouchMode(true);
9286
view.requestFocus();
93-
//noinspection ConstantConditions
94-
imm.showSoftInput(view, flags);
95-
}
96-
97-
/**
98-
* Show the soft input using toggle.
99-
*
100-
* @param activity The activity.
101-
*/
102-
public static void showSoftInputUsingToggle(final Activity activity) {
103-
if (isSoftInputVisible(activity)) return;
104-
toggleSoftInput();
87+
imm.showSoftInput(view, flags, new ResultReceiver(new Handler()) {
88+
@Override
89+
protected void onReceiveResult(int resultCode, Bundle resultData) {
90+
if (resultCode == InputMethodManager.RESULT_UNCHANGED_HIDDEN
91+
|| resultCode == InputMethodManager.RESULT_HIDDEN) {
92+
toggleSoftInput();
93+
}
94+
}
95+
});
10596
}
10697

10798
/**
@@ -110,12 +101,11 @@ public static void showSoftInputUsingToggle(final Activity activity) {
110101
* @param activity The activity.
111102
*/
112103
public static void hideSoftInput(final Activity activity) {
113-
InputMethodManager imm =
114-
(InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
115-
if (imm == null) return;
116104
View view = activity.getCurrentFocus();
117-
if (view == null) view = new View(activity);
118-
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
105+
if (view == null) {
106+
view = new View(activity);
107+
}
108+
hideSoftInput(view);
119109
}
120110

121111
/**
@@ -126,18 +116,16 @@ public static void hideSoftInput(final Activity activity) {
126116
public static void hideSoftInput(final View view) {
127117
InputMethodManager imm =
128118
(InputMethodManager) Utils.getApp().getSystemService(Context.INPUT_METHOD_SERVICE);
129-
//noinspection ConstantConditions
130-
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
131-
}
132-
133-
/**
134-
* Hide the soft input.
135-
*
136-
* @param activity The activity.
137-
*/
138-
public static void hideSoftInputUsingToggle(final Activity activity) {
139-
if (!isSoftInputVisible(activity)) return;
140-
toggleSoftInput();
119+
if (imm == null) return;
120+
imm.hideSoftInputFromWindow(view.getWindowToken(), 0, new ResultReceiver(new Handler()) {
121+
@Override
122+
protected void onReceiveResult(int resultCode, Bundle resultData) {
123+
if (resultCode == InputMethodManager.RESULT_UNCHANGED_SHOWN
124+
|| resultCode == InputMethodManager.RESULT_SHOWN) {
125+
toggleSoftInput();
126+
}
127+
}
128+
});
141129
}
142130

143131
/**

0 commit comments

Comments
 (0)