Skip to content

Commit

Permalink
fix: some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Blankj committed Oct 14, 2022
1 parent f3449a2 commit 5f73931
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* `22/10/15` [add] Fix some issue. Publish v1.31.1
* `21/12/06` [add] Publish v1.31.0
* `21/05/13` [add] Support publish mavenCentral.
* `21/02/22` [add] Fix ToastUtils rtl bug. Publish v1.30.6.
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/src/main/groovy/Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class Config {
static compileSdkVersion = 29
static minSdkVersion = 14
static targetSdkVersion = 29
static versionCode = 1_030_007
static versionName = '1.31.0'// E.g. 1.9.72 => 1,009,072
static versionCode = 1_031_001
static versionName = '1.31.1'// E.g. 1.9.72 => 1,009,072

// lib version
static gradlePluginVersion = '4.1.0'
Expand All @@ -34,7 +34,7 @@ class Config {
lib_base : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/base"),
lib_common : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/common"),
lib_subutil : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/subutil"),
lib_utilcode : new ModuleConfig(isApply: true , useLocal: false, localPath: "./lib/utilcode", remotePath: "com.blankj:utilcodex:$Config.versionName"),
lib_utilcode : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/utilcode", remotePath: "com.blankj:utilcodex:$Config.versionName"),
lib_utildebug : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/utildebug"),
lib_utildebug_no_op : new ModuleConfig(isApply: true , useLocal: true , localPath: "./lib/utildebug-no-op"),
/*Don't delete this line*/
Expand Down
11 changes: 6 additions & 5 deletions lib/utilcode/README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Gradle:
```groovy
// if u use AndroidX, use the following
implementation 'com.blankj:utilcodex:1.31.0'
implementation 'com.blankj:utilcodex:1.31.1'
// Not in maintenance
implementation 'com.blankj:utilcode:1.30.7'
Expand Down Expand Up @@ -1210,10 +1210,11 @@ removeListener: 移除消息监听器

* ### URI 相关 -> [UriUtils.java][uri.java]
```
res2Uri : res 转 uri
file2Uri : file 转 uri
uri2File : uri 转 file
uri2Bytes: uri 转 bytes
res2Uri : res 转 uri
file2Uri : file 转 uri
uri2File : uri 转 file
uri2FileNoCacheCopy: uri 转 file 不拷贝缓存
uri2Bytes : uri 转 bytes
```

* ### UtilsTransActivity -> [UtilsTransActivity.java][trans.java]
Expand Down
3 changes: 2 additions & 1 deletion lib/utilcode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Gradle:
```groovy
// if u use AndroidX, use the following
implementation 'com.blankj:utilcodex:1.31.0'
implementation 'com.blankj:utilcodex:1.31.1'
// Not in maintenance
implementation 'com.blankj:utilcode:1.30.6'
Expand Down Expand Up @@ -1212,6 +1212,7 @@ removeListener
res2Uri
file2Uri
uri2File
uri2FileNoCacheCopy
uri2Bytes
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2013,10 +2013,11 @@ private static boolean startActivity(final Intent intent,
}

private static boolean isIntentAvailable(final Intent intent) {
return Utils.getApp()
.getPackageManager()
.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)
.size() > 0;
// return Utils.getApp()
// .getPackageManager()
// .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)
// .size() > 0;
return true;
}

private static boolean startActivityForResult(final Activity activity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private BarUtils() {
* @return the status bar's height
*/
public static int getStatusBarHeight() {
Resources resources = Utils.getApp().getResources();
Resources resources = Resources.getSystem();
int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
return resources.getDimensionPixelSize(resourceId);
}
Expand Down Expand Up @@ -483,7 +483,7 @@ private static void invokePanels(final String methodName) {
* @return the navigation bar's height
*/
public static int getNavBarHeight() {
Resources res = Utils.getApp().getResources();
Resources res = Resources.getSystem();
int resourceId = res.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId != 0) {
return res.getDimensionPixelSize(resourceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@
import android.telephony.TelephonyManager;
import android.text.TextUtils;

import androidx.annotation.RequiresApi;
import androidx.annotation.RequiresPermission;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
import java.util.UUID;

import androidx.annotation.RequiresApi;
import androidx.annotation.RequiresPermission;

import static android.Manifest.permission.ACCESS_WIFI_STATE;
import static android.Manifest.permission.CHANGE_WIFI_STATE;
import static android.Manifest.permission.INTERNET;
Expand Down Expand Up @@ -382,13 +385,50 @@ public static boolean isEmulator() {
intent.setAction(Intent.ACTION_DIAL);
boolean checkDial = intent.resolveActivity(Utils.getApp().getPackageManager()) == null;
if (checkDial) return true;
if (isEmulatorByCpu()) return true;

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

return false;
}

/**
* Returns whether is emulator by check cpu info.
* by function of {@link #readCpuInfo}, obtain the device cpu information.
* 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
*
* @return {@code true}: yes<br>{@code false}: no
*/
private static boolean isEmulatorByCpu() {
String cpuInfo = readCpuInfo();
return cpuInfo.contains("intel") || cpuInfo.contains("amd");
}

/**
* Return Cpu information
*
* @return Cpu info
*/
private static String readCpuInfo() {
String result = "";
try {
String[] args = {"/system/bin/cat", "/proc/cpuinfo"};
ProcessBuilder cmd = new ProcessBuilder(args);
Process process = cmd.start();
StringBuilder sb = new StringBuilder();
String readLine;
BufferedReader responseReader = new BufferedReader(new InputStreamReader(process.getInputStream(), "utf-8"));
while ((readLine = responseReader.readLine()) != null) {
sb.append(readLine);
}
responseReader.close();
result = sb.toString().toLowerCase();
} catch (IOException ignored) {
}
return result;
}

/**
* Whether user has enabled development settings.
*
Expand Down
2 changes: 1 addition & 1 deletion module_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{"name": "lib_base", "isApply": true, "useLocal": true, "localPath": "./lib/base"},
{"name": "lib_common", "isApply": true, "useLocal": true, "localPath": "./lib/common"},
{"name": "lib_subutil", "isApply": true, "useLocal": true, "localPath": "./lib/subutil"},
{"name": "lib_utilcode", "isApply": true, "useLocal": false, "localPath": "./lib/utilcode", "remotePath": "com.blankj:utilcodex:$Config.versionName"},
{"name": "lib_utilcode", "isApply": true, "useLocal": true, "localPath": "./lib/utilcode", "remotePath": "com.blankj:utilcodex:$Config.versionName"},
{"name": "lib_utildebug", "isApply": true, "useLocal": true, "localPath": "./lib/utildebug"},
{"name": "lib_utildebug_no_op", "isApply": true, "useLocal": true, "localPath": "./lib/utildebug-no-op"}
]
Expand Down

0 comments on commit 5f73931

Please sign in to comment.