Skip to content

Commit a255ebc

Browse files
committed
Merge remote-tracking branch 'origin/dev'
2 parents a8c8270 + 5f73931 commit a255ebc

File tree

9 files changed

+74
-19
lines changed

9 files changed

+74
-19
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* `22/10/15` [add] Fix some issue. Publish v1.31.1
12
* `21/12/06` [add] Publish v1.31.0
23
* `21/05/13` [add] Support publish mavenCentral.
34
* `21/02/22` [add] Fix ToastUtils rtl bug. Publish v1.30.6.

buildSrc/src/main/groovy/Config.groovy

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ class Config {
66
static compileSdkVersion = 29
77
static minSdkVersion = 14
88
static targetSdkVersion = 29
9-
static versionCode = 1_030_007
10-
static versionName = '1.31.0'// E.g. 1.9.72 => 1,009,072
9+
static versionCode = 1_031_001
10+
static versionName = '1.31.1'// E.g. 1.9.72 => 1,009,072
1111

1212
// lib version
1313
static gradlePluginVersion = '4.1.0'
@@ -34,7 +34,7 @@ class Config {
3434
lib_base : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/base"),
3535
lib_common : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/common"),
3636
lib_subutil : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/subutil"),
37-
lib_utilcode : new ModuleConfig(isApply: true , useLocal: false, localPath: "./lib/utilcode", remotePath: "com.blankj:utilcodex:$Config.versionName"),
37+
lib_utilcode : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/utilcode", remotePath: "com.blankj:utilcodex:$Config.versionName"),
3838
lib_utildebug : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/utildebug"),
3939
lib_utildebug_no_op : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/utildebug-no-op"),
4040
/*Don't delete this line*/

lib/utilcode/README-CN.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Gradle:
44
```groovy
55
// if u use AndroidX, use the following
6-
implementation 'com.blankj:utilcodex:1.31.0'
6+
implementation 'com.blankj:utilcodex:1.31.1'
77
88
// Not in maintenance
99
implementation 'com.blankj:utilcode:1.30.7'
@@ -1210,10 +1210,11 @@ removeListener: 移除消息监听器
12101210

12111211
* ### URI 相关 -> [UriUtils.java][uri.java]
12121212
```
1213-
res2Uri : res 转 uri
1214-
file2Uri : file 转 uri
1215-
uri2File : uri 转 file
1216-
uri2Bytes: uri 转 bytes
1213+
res2Uri : res 转 uri
1214+
file2Uri : file 转 uri
1215+
uri2File : uri 转 file
1216+
uri2FileNoCacheCopy: uri 转 file 不拷贝缓存
1217+
uri2Bytes : uri 转 bytes
12171218
```
12181219

12191220
* ### UtilsTransActivity -> [UtilsTransActivity.java][trans.java]

lib/utilcode/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Gradle:
44
```groovy
55
// if u use AndroidX, use the following
6-
implementation 'com.blankj:utilcodex:1.31.0'
6+
implementation 'com.blankj:utilcodex:1.31.1'
77
88
// Not in maintenance
99
implementation 'com.blankj:utilcode:1.30.6'
@@ -1212,6 +1212,7 @@ removeListener
12121212
res2Uri
12131213
file2Uri
12141214
uri2File
1215+
uri2FileNoCacheCopy
12151216
uri2Bytes
12161217
```
12171218

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -2013,10 +2013,11 @@ private static boolean startActivity(final Intent intent,
20132013
}
20142014

20152015
private static boolean isIntentAvailable(final Intent intent) {
2016-
return Utils.getApp()
2017-
.getPackageManager()
2018-
.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)
2019-
.size() > 0;
2016+
// return Utils.getApp()
2017+
// .getPackageManager()
2018+
// .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)
2019+
// .size() > 0;
2020+
return true;
20202021
}
20212022

20222023
private static boolean startActivityForResult(final Activity activity,

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private BarUtils() {
5757
* @return the status bar's height
5858
*/
5959
public static int getStatusBarHeight() {
60-
Resources resources = Utils.getApp().getResources();
60+
Resources resources = Resources.getSystem();
6161
int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
6262
return resources.getDimensionPixelSize(resourceId);
6363
}
@@ -483,7 +483,7 @@ private static void invokePanels(final String methodName) {
483483
* @return the navigation bar's height
484484
*/
485485
public static int getNavBarHeight() {
486-
Resources res = Utils.getApp().getResources();
486+
Resources res = Resources.getSystem();
487487
int resourceId = res.getIdentifier("navigation_bar_height", "dimen", "android");
488488
if (resourceId != 0) {
489489
return res.getDimensionPixelSize(resourceId);

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

+43-3
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@
1313
import android.telephony.TelephonyManager;
1414
import android.text.TextUtils;
1515

16-
import androidx.annotation.RequiresApi;
17-
import androidx.annotation.RequiresPermission;
18-
16+
import java.io.BufferedReader;
1917
import java.io.File;
18+
import java.io.IOException;
19+
import java.io.InputStreamReader;
2020
import java.net.InetAddress;
2121
import java.net.NetworkInterface;
2222
import java.net.SocketException;
2323
import java.util.Enumeration;
2424
import java.util.UUID;
2525

26+
import androidx.annotation.RequiresApi;
27+
import androidx.annotation.RequiresPermission;
28+
2629
import static android.Manifest.permission.ACCESS_WIFI_STATE;
2730
import static android.Manifest.permission.CHANGE_WIFI_STATE;
2831
import static android.Manifest.permission.INTERNET;
@@ -382,13 +385,50 @@ public static boolean isEmulator() {
382385
intent.setAction(Intent.ACTION_DIAL);
383386
boolean checkDial = intent.resolveActivity(Utils.getApp().getPackageManager()) == null;
384387
if (checkDial) return true;
388+
if (isEmulatorByCpu()) return true;
385389

386390
// boolean checkDebuggerConnected = Debug.isDebuggerConnected();
387391
// if (checkDebuggerConnected) return true;
388392

389393
return false;
390394
}
391395

396+
/**
397+
* Returns whether is emulator by check cpu info.
398+
* by function of {@link #readCpuInfo}, obtain the device cpu information.
399+
* then compare whether it is intel or amd (because intel and amd are generally not mobile phone cpu), to determine whether it is a real mobile phone
400+
*
401+
* @return {@code true}: yes<br>{@code false}: no
402+
*/
403+
private static boolean isEmulatorByCpu() {
404+
String cpuInfo = readCpuInfo();
405+
return cpuInfo.contains("intel") || cpuInfo.contains("amd");
406+
}
407+
408+
/**
409+
* Return Cpu information
410+
*
411+
* @return Cpu info
412+
*/
413+
private static String readCpuInfo() {
414+
String result = "";
415+
try {
416+
String[] args = {"/system/bin/cat", "/proc/cpuinfo"};
417+
ProcessBuilder cmd = new ProcessBuilder(args);
418+
Process process = cmd.start();
419+
StringBuilder sb = new StringBuilder();
420+
String readLine;
421+
BufferedReader responseReader = new BufferedReader(new InputStreamReader(process.getInputStream(), "utf-8"));
422+
while ((readLine = responseReader.readLine()) != null) {
423+
sb.append(readLine);
424+
}
425+
responseReader.close();
426+
result = sb.toString().toLowerCase();
427+
} catch (IOException ignored) {
428+
}
429+
return result;
430+
}
431+
392432
/**
393433
* Whether user has enabled development settings.
394434
*

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

+11
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ public static File uri2File(final Uri uri) {
7777
return copyUri2Cache(uri);
7878
}
7979

80+
/**
81+
* Uri to file, without creating the cache copy if the path cannot be resolved.
82+
*
83+
* @param uri The uri.
84+
* @return file
85+
*/
86+
public static File uri2FileNoCacheCopy(final Uri uri) {
87+
if (uri == null) return null;
88+
return uri2FileReal(uri);
89+
}
90+
8091
/**
8192
* Uri to file.
8293
*

module_config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
{"name": "lib_base", "isApply": true, "useLocal": true, "localPath": "./lib/base"},
2424
{"name": "lib_common", "isApply": true, "useLocal": true, "localPath": "./lib/common"},
2525
{"name": "lib_subutil", "isApply": true, "useLocal": true, "localPath": "./lib/subutil"},
26-
{"name": "lib_utilcode", "isApply": true, "useLocal": false, "localPath": "./lib/utilcode", "remotePath": "com.blankj:utilcodex:$Config.versionName"},
26+
{"name": "lib_utilcode", "isApply": true, "useLocal": true, "localPath": "./lib/utilcode", "remotePath": "com.blankj:utilcodex:$Config.versionName"},
2727
{"name": "lib_utildebug", "isApply": true, "useLocal": true, "localPath": "./lib/utildebug"},
2828
{"name": "lib_utildebug_no_op", "isApply": true, "useLocal": true, "localPath": "./lib/utildebug-no-op"}
2929
]

0 commit comments

Comments
 (0)