GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — merge · RlonLL11FE/AndroidUtilCode@1b99535

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • README-CN.md
  • README.md
  • update_log.md
  • utilcode/src
    • androidTest/java/com/blankj/utilcode
      • ApplicationTest.java
    • main
      • AndroidManifest.xml
      • java/com/blankj/utilcode/utils
        • ActivityUtils.java
        • AppUtils.java
        • ConstUtils.java
        • CrashUtils.java
        • ImageUtils.java
        • IntentUtils.java
        • KeyboardUtils.java
        • LogUtils.java
        • NetworkUtils.java
        • PhoneUtils.java
        • SDCardUtils.java
        • SPUtils.java
        • ShellUtils.java
        • SizeUtils.java
        • ThreadPoolUtils.java
    • test/java/com/blankj/utilcode/utils
      • TestUtils.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README-CN.md‎

Copy file name to clipboardExpand all lines: README-CN.md
+381-312Lines changed: 381 additions & 312 deletions
  • Display the source diff
  • Display the rich diff
Large diffs are not rendered by default.
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+374-308Lines changed: 374 additions & 308 deletions
  • Display the source diff
  • Display the rich diff
Large diffs are not rendered by default.
Collapse file

‎update_log.md‎

Copy file name to clipboardExpand all lines: update_log.md
+2Lines changed: 2 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
###
2+
#### 16/10/14 README-CN排版变化(强迫症一定要对齐)
3+
#### 16/10/13 优化测试中
24
#### 16/10/12 LogUtils新增建造者模式,新增获取星期,发布版本1.3.0,cheer
35
#### 16/10/11 新增Hmac系列加密
46
#### 16/10/10 完善LogUtils
Collapse file

‎utilcode/src/androidTest/java/com/blankj/utilcode/ApplicationTest.java‎

Copy file name to clipboardExpand all lines: utilcode/src/androidTest/java/com/blankj/utilcode/ApplicationTest.java
-13Lines changed: 0 additions & 13 deletions
This file was deleted.
Collapse file

‎utilcode/src/main/AndroidManifest.xml‎

Copy file name to clipboardExpand all lines: utilcode/src/main/AndroidManifest.xml
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
<application android:allowBackup="true"
44
android:label="@string/app_name"
55
android:supportsRtl="true">
6-
76
</application>
8-
97
</manifest>
Collapse file

‎utilcode/src/main/java/com/blankj/utilcode/utils/ActivityUtils.java‎

Copy file name to clipboardExpand all lines: utilcode/src/main/java/com/blankj/utilcode/utils/ActivityUtils.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private ActivityUtils() {
2929
* @param className activity全路径类名
3030
* @return {@code true}: 是<br>{@code false}: 否
3131
*/
32-
public static boolean isExistActivity(Context context, String packageName, String className) {
32+
public static boolean isActivityExists(Context context, String packageName, String className) {
3333
Intent intent = new Intent();
3434
intent.setClassName(packageName, className);
3535
return !(context.getPackageManager().resolveActivity(intent, 0) == null ||
Collapse file

‎utilcode/src/main/java/com/blankj/utilcode/utils/AppUtils.java‎

Copy file name to clipboardExpand all lines: utilcode/src/main/java/com/blankj/utilcode/utils/AppUtils.java
+49-55Lines changed: 49 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@
99
import android.content.pm.Signature;
1010
import android.graphics.drawable.Drawable;
1111

12-
import java.security.MessageDigest;
13-
import java.security.NoSuchAlgorithmException;
14-
import java.io.BufferedReader;
1512
import java.io.File;
16-
import java.io.IOException;
17-
import java.io.InputStreamReader;
18-
import java.io.OutputStream;
1913
import java.util.ArrayList;
2014
import java.util.Arrays;
2115
import java.util.List;
@@ -342,6 +336,35 @@ public static int getAppVersionCode(Context context, String packageName) {
342336
}
343337
}
344338

339+
/**
340+
* 判断App是否是系统应用
341+
*
342+
* @param context 上下文
343+
* @return {@code true}: 是<br>{@code false}: 否
344+
*/
345+
public static boolean isSystemApp(Context context) {
346+
return isSystemApp(context, context.getPackageName());
347+
}
348+
349+
/**
350+
* 判断App是否是系统应用
351+
*
352+
* @param context 上下文
353+
* @param packageName 包名
354+
* @return {@code true}: 是<br>{@code false}: 否
355+
*/
356+
public static boolean isSystemApp(Context context, String packageName) {
357+
if (StringUtils.isSpace(packageName)) return false;
358+
try {
359+
PackageManager pm = context.getPackageManager();
360+
ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
361+
return ai != null && (ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
362+
} catch (PackageManager.NameNotFoundException e) {
363+
e.printStackTrace();
364+
}
365+
return false;
366+
}
367+
345368
/**
346369
* 获取App签名
347370
*
@@ -397,35 +420,6 @@ public static String getAppSignatureSHA1(Context context, String packageName) {
397420
replaceAll("(?<=[0-9A-F]{2})[0-9A-F]{2}", ":$0");
398421
}
399422

400-
/**
401-
* 判断App是否是系统应用
402-
*
403-
* @param context 上下文
404-
* @return {@code true}: 是<br>{@code false}: 否
405-
*/
406-
public static boolean isSystemApp(Context context) {
407-
return isSystemApp(context, context.getPackageName());
408-
}
409-
410-
/**
411-
* 判断App是否是系统应用
412-
*
413-
* @param context 上下文
414-
* @param packageName 包名
415-
* @return {@code true}: 是<br>{@code false}: 否
416-
*/
417-
public static boolean isSystemApp(Context context, String packageName) {
418-
if (StringUtils.isSpace(packageName)) return false;
419-
try {
420-
PackageManager pm = context.getPackageManager();
421-
ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
422-
return ai != null && (ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
423-
} catch (PackageManager.NameNotFoundException e) {
424-
e.printStackTrace();
425-
}
426-
return false;
427-
}
428-
429423
/**
430424
* 判断App是否处于前台
431425
*
@@ -467,13 +461,13 @@ public String getForegroundApp(Context context) {
467461
*/
468462
public static class AppInfo {
469463

470-
private String name;
464+
private String name;
471465
private Drawable icon;
472-
private String packageName;
473-
private String packagePath;
474-
private String versionName;
475-
private int versionCode;
476-
private boolean isSystem;
466+
private String packageName;
467+
private String packagePath;
468+
private String versionName;
469+
private int versionCode;
470+
private boolean isSystem;
477471

478472
public Drawable getIcon() {
479473
return icon;
@@ -537,10 +531,10 @@ public void setVersionName(String versionName) {
537531
* @param packageName 包名
538532
* @param packagePath 包路径
539533
* @param versionName 版本号
540-
* @param versionCode 版本Code
534+
* @param versionCode 版本码
541535
* @param isSystem 是否系统应用
542536
*/
543-
public AppInfo(String name, Drawable icon, String packageName, String packagePath,
537+
public AppInfo(String packageName, String name, Drawable icon, String packagePath,
544538
String versionName, int versionCode, boolean isSystem) {
545539
this.setName(name);
546540
this.setIcon(icon);
@@ -551,16 +545,16 @@ public AppInfo(String name, Drawable icon, String packageName, String packagePat
551545
this.setSystem(isSystem);
552546
}
553547

554-
// @Override
555-
// public String toString() {
556-
// return getName() + "\n"
557-
// + getIcon() + "\n"
558-
// + getPackageName() + "\n"
559-
// + getPackagePath() + "\n"
560-
// + getVersionName() + "\n"
561-
// + getVersionCode() + "\n"
562-
// + isSystem() + "\n"
563-
// }
548+
@Override
549+
public String toString() {
550+
return "App包名:" + getPackageName() + "\n" +
551+
"App名称:" + getName() + "\n" +
552+
"App图标:" + getIcon() + "\n" +
553+
"App路径:" + getPackagePath() + "\n" +
554+
"App版本号:" + getVersionName() + "\n" +
555+
"App版本码:" + getVersionCode() + "\n" +
556+
"是否系统App:" + isSystem() + "\n";
557+
}
564558
}
565559

566560
/**
@@ -603,14 +597,14 @@ public static AppInfo getAppInfo(Context context, String packageName) {
603597
private static AppInfo getBean(PackageManager pm, PackageInfo pi) {
604598
if (pm == null || pi == null) return null;
605599
ApplicationInfo ai = pi.applicationInfo;
600+
String packageName = pi.packageName;
606601
String name = ai.loadLabel(pm).toString();
607602
Drawable icon = ai.loadIcon(pm);
608-
String packageName = pi.packageName;
609603
String packagePath = ai.sourceDir;
610604
String versionName = pi.versionName;
611605
int versionCode = pi.versionCode;
612606
boolean isSystem = (ApplicationInfo.FLAG_SYSTEM & ai.flags) != 0;
613-
return new AppInfo(name, icon, packageName, packagePath, versionName, versionCode, isSystem);
607+
return new AppInfo(packageName, name, icon, packagePath, versionName, versionCode, isSystem);
614608
}
615609

616610
/**
Collapse file

‎utilcode/src/main/java/com/blankj/utilcode/utils/ConstUtils.java‎

Copy file name to clipboardExpand all lines: utilcode/src/main/java/com/blankj/utilcode/utils/ConstUtils.java
+16-16Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ private ConstUtils() {
2222
/**
2323
* KB与Byte的倍数
2424
*/
25-
public static final int KB = 1024;
25+
public static final int KB = 1024;
2626
/**
2727
* MB与Byte的倍数
2828
*/
29-
public static final int MB = 1048576;
29+
public static final int MB = 1048576;
3030
/**
3131
* GB与Byte的倍数
3232
*/
33-
public static final int GB = 1073741824;
33+
public static final int GB = 1073741824;
3434

3535
public enum MemoryUnit {
3636
BYTE,
@@ -47,19 +47,19 @@ public enum MemoryUnit {
4747
/**
4848
* 秒与毫秒的倍数
4949
*/
50-
public static final int SEC = 1000;
50+
public static final int SEC = 1000;
5151
/**
5252
* 分与毫秒的倍数
5353
*/
54-
public static final int MIN = 60000;
54+
public static final int MIN = 60000;
5555
/**
5656
* 时与毫秒的倍数
5757
*/
5858
public static final int HOUR = 3600000;
5959
/**
6060
* 天与毫秒的倍数
6161
*/
62-
public static final int DAY = 86400000;
62+
public static final int DAY = 86400000;
6363

6464
public enum TimeUnit {
6565
MSEC,
@@ -82,41 +82,41 @@ public enum TimeUnit {
8282
* <p>全球星:1349</p>
8383
* <p>虚拟运营商:170</p>
8484
*/
85-
public static final String REGEX_MOBILE_EXACT = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|(147))\\d{8}$";
85+
public static final String REGEX_MOBILE_EXACT = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|(147))\\d{8}$";
8686
/**
8787
* 正则:电话号码
8888
*/
89-
public static final String REGEX_TEL = "^0\\d{2,3}[- ]?\\d{7,8}";
89+
public static final String REGEX_TEL = "^0\\d{2,3}[- ]?\\d{7,8}";
9090
/**
9191
* 正则:身份证号码15位
9292
*/
93-
public static final String REGEX_IDCARD15 = "^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$";
93+
public static final String REGEX_IDCARD15 = "^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$";
9494
/**
9595
* 正则:身份证号码18位
9696
*/
97-
public static final String REGEX_IDCARD18 = "^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9Xx])$";
97+
public static final String REGEX_IDCARD18 = "^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9Xx])$";
9898
/**
9999
* 正则:邮箱
100100
*/
101-
public static final String REGEX_EMAIL = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
101+
public static final String REGEX_EMAIL = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
102102
/**
103103
* 正则:URL
104104
*/
105-
public static final String REGEX_URL = "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?";
105+
public static final String REGEX_URL = "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?";
106106
/**
107107
* 正则:汉字
108108
*/
109-
public static final String REGEX_CHZ = "^[\\u4e00-\\u9fa5]+$";
109+
public static final String REGEX_CHZ = "^[\\u4e00-\\u9fa5]+$";
110110
/**
111111
* 正则:用户名,取值范围为a-z,A-Z,0-9,"_",汉字,不能以"_"结尾,用户名必须是6-20位
112112
*/
113-
public static final String REGEX_USERNAME = "^[\\w\\u4e00-\\u9fa5]{6,20}(?<!_)$";
113+
public static final String REGEX_USERNAME = "^[\\w\\u4e00-\\u9fa5]{6,20}(?<!_)$";
114114
/**
115115
* 正则:yyyy-MM-dd格式的日期校验,已考虑平闰年
116116
*/
117-
public static final String REGEX_DATE = "^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$";
117+
public static final String REGEX_DATE = "^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$";
118118
/**
119119
* 正则:IP地址
120120
*/
121-
public static final String REGEX_IP = "((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)";
121+
public static final String REGEX_IP = "((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)";
122122
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.