Skip to content

Commit 0f57709

Browse files
committed
Merge branch 'master' of https://github.com/Blankj/AndroidUtilCode into origin-master
2 parents ece339f + 3dfa55e commit 0f57709

File tree

76 files changed

+6357
-1908
lines changed

Some content is hidden

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

76 files changed

+6357
-1908
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
**Describe the bug**
2+
A clear and concise description of what the bug is.
3+
4+
**The version of utilcode: [e.g. 1.16.3]**
5+
6+
**The device: [e.g. Nexus 5X]**
7+
8+
**The version of device: [e.g. API 27]**
9+
10+
**The code:**
11+
[e.g.
12+
```java
13+
CrashUtils.init();
14+
```
15+
]
16+
17+
**The stack of crash:**
18+
[e.g.
19+
```
20+
Caused by: java.lang.NullPointerException: u should init first
21+
at com.blankj.utilcode.util.Utils.getApp(Utils.java:98)
22+
at com.blankj.utilcode.util.CrashUtils.<clinit>(CrashUtils.java:55)
23+
at com.blankj.utilcode.util.CrashUtils.init(CrashUtils.java:168) 
24+
at com.blankj.androidutilcode.UtilsApp.initCrash(UtilsApp.java:71) 
25+
at com.blankj.androidutilcode.UtilsApp.onCreate(UtilsApp.java:33) 
26+
```
27+
]
28+
29+
**Screenshots**
30+
If applicable, add screenshots to help explain your problem.
31+
32+
33+
Please delete the current line and the followings.
34+
35+
Thank you for supporting [AndroidUtilCode](https://github.com/Blankj/AndroidUtilCode).

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

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

app/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ dependencies {
5353
implementation "com.android.support:appcompat-v7:$support_version"
5454
implementation "com.android.support:design:$support_version"
5555
implementation 'com.r0adkll:slidableactivity:2.0.5'
56+
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
5657
// LeakCanary
5758
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
5859
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version"
59-
// implementation 'com.blankj:utilcode:1.15.1'
60+
// implementation 'com.blankj:utilcode:1.17.2'
6061
}
61-
62-

app/src/main/AndroidManifest.xml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,44 @@
33
package="com.blankj.androidutilcode">
44

55
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
6-
76
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
87

9-
<!--bar-->
8+
<!-- bar -->
109
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
1110

12-
<!--读写内存-->
11+
<!-- 读写内存 -->
1312
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
1413
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
1514

16-
<!--network-->
15+
<!-- network -->
1716
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
1817
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
1918
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
2019
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
2120
<uses-permission android:name="android.permission.INTERNET" />
2221

23-
<!--permission-->
22+
<!-- permission -->
2423
<uses-permission android:name="android.permission.READ_CALENDAR" />
2524
<uses-permission android:name="android.permission.RECORD_AUDIO" />
2625

27-
<!--phone-->
26+
<!-- phone -->
2827
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
2928
<uses-permission android:name="android.permission.CALL_PHONE" />
3029
<uses-permission android:name="android.permission.SEND_SMS" />
3130
<uses-permission android:name="android.permission.READ_SMS" />
3231
<uses-permission android:name="android.permission.READ_CONTACTS" />
3332

34-
<!--process-->
33+
<!-- process -->
3534
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
3635

37-
<!--screen-->
36+
<!-- screen -->
3837
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
3938

40-
<!--flashlight-->
39+
<!-- flashlight -->
4140
<uses-permission android:name="android.permission.CAMERA" />
4241
<uses-permission android:name="android.permission.FLASHLIGHT" />
4342

44-
<!--location-->
43+
<!-- location -->
4544
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
4645
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
4746

@@ -53,15 +52,16 @@
5352
android:theme="@style/AppTheme">
5453
<activity
5554
android:name=".MainActivity"
56-
android:launchMode="singleTop"
55+
android:screenOrientation="user"
5756
android:windowSoftInputMode="stateHidden|adjustPan">
5857
<intent-filter>
5958
<action android:name="android.intent.action.MAIN" />
59+
6060
<category android:name="android.intent.category.LAUNCHER" />
6161
</intent-filter>
6262
</activity>
6363

64-
<!--core-->
64+
<!-- core -->
6565
<activity
6666
android:name=".feature.core.CoreUtilActivity"
6767
android:launchMode="singleTop" />
@@ -120,8 +120,7 @@
120120
android:launchMode="singleTop" />
121121
<activity
122122
android:name=".feature.core.keyboard.KeyboardActivity"
123-
android:launchMode="singleTop"
124-
android:windowSoftInputMode="stateHidden|adjustPan" />
123+
android:launchMode="singleTop" />
125124
<activity
126125
android:name=".feature.core.log.LogActivity"
127126
android:launchMode="singleTop" />
@@ -162,7 +161,7 @@
162161
android:name=".feature.core.toast.ToastActivity"
163162
android:launchMode="singleTop" />
164163

165-
<!--sub-->
164+
<!-- sub -->
166165
<activity
167166
android:name=".feature.sub.SubUtilActivity"
168167
android:launchMode="singleTop" />

app/src/main/java/com/blankj/androidutilcode/base/BaseActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.blankj.androidutilcode.base;
22

3+
import android.annotation.SuppressLint;
34
import android.app.Activity;
45
import android.os.Bundle;
56
import android.support.annotation.LayoutRes;
@@ -37,6 +38,7 @@ protected void onCreate(Bundle savedInstanceState) {
3738
doBusiness();
3839
}
3940

41+
@SuppressLint("ResourceType")
4042
protected void setBaseView(@LayoutRes int layoutId) {
4143
if (layoutId <= 0) return;
4244
setContentView(mContentView = LayoutInflater.from(this).inflate(layoutId, null));

app/src/main/java/com/blankj/androidutilcode/feature/core/app/AppActivity.java

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
import com.blankj.androidutilcode.Config;
1111
import com.blankj.androidutilcode.R;
1212
import com.blankj.androidutilcode.base.BaseBackActivity;
13-
import com.blankj.androidutilcode.helper.AssertHelper;
1413
import com.blankj.androidutilcode.helper.PermissionHelper;
1514
import com.blankj.utilcode.util.AppUtils;
15+
import com.blankj.utilcode.util.FileUtils;
16+
import com.blankj.utilcode.util.LogUtils;
1617
import com.blankj.utilcode.util.SpanUtils;
1718
import com.blankj.utilcode.util.ToastUtils;
19+
import com.blankj.utilcode.util.Utils;
1820

1921
/**
2022
* <pre>
@@ -27,14 +29,31 @@
2729

2830
public class AppActivity extends BaseBackActivity {
2931

32+
private final OnReleasedListener listener = new OnReleasedListener() {
33+
@Override
34+
public void onReleased() {
35+
AppUtils.installApp(Config.TEST_APK_PATH);
36+
}
37+
};
38+
3039
public static void start(Context context) {
3140
Intent starter = new Intent(context, AppActivity.class);
3241
context.startActivity(starter);
3342
}
3443

3544
@Override
3645
public void initData(@Nullable Bundle bundle) {
46+
AppUtils.registerAppStatusChangedListener(this, new Utils.OnAppStatusChangedListener() {
47+
@Override
48+
public void onForeground() {
49+
ToastUtils.showShort("foreground");
50+
}
3751

52+
@Override
53+
public void onBackground() {
54+
ToastUtils.showShort("background");
55+
}
56+
});
3857
}
3958

4059
@Override
@@ -86,12 +105,12 @@ public void onWidgetClick(View view) {
86105
PermissionHelper.requestStorage(new PermissionHelper.OnPermissionGrantedListener() {
87106
@Override
88107
public void onPermissionGranted() {
89-
AssertHelper.releaseInstallApk(new AssertHelper.OnReleasedListener() {
90-
@Override
91-
public void onReleased() {
92-
AppUtils.installApp(Config.TEST_APK_PATH);
93-
}
94-
});
108+
if (!FileUtils.isFileExists(Config.TEST_APK_PATH)) {
109+
new ReleaseInstallApkTask(listener).execute();
110+
} else {
111+
listener.onReleased();
112+
LogUtils.d("test apk existed.");
113+
}
95114
}
96115
});
97116
}
@@ -139,4 +158,10 @@ public void onReleased() {
139158
break;
140159
}
141160
}
161+
162+
@Override
163+
protected void onDestroy() {
164+
AppUtils.unregisterAppStatusChangedListener(this);
165+
super.onDestroy();
166+
}
142167
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.blankj.androidutilcode.feature.core.app;
2+
3+
/**
4+
* <pre>
5+
* author: Blankj
6+
* blog : http://blankj.com
7+
* time : 2018/05/23
8+
* desc :
9+
* </pre>
10+
*/
11+
public interface OnReleasedListener {
12+
void onReleased();
13+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.blankj.androidutilcode.feature.core.app;
2+
3+
import com.blankj.androidutilcode.Config;
4+
import com.blankj.utilcode.util.ResourceUtils;
5+
import com.blankj.utilcode.util.ThreadUtils;
6+
7+
/**
8+
* <pre>
9+
* author: Blankj
10+
* blog : http://blankj.com
11+
* time : 2018/05/23
12+
* desc :
13+
* </pre>
14+
*/
15+
public class ReleaseInstallApkTask extends ThreadUtils.SimpleTask<Void> {
16+
17+
private OnReleasedListener mListener;
18+
19+
public ReleaseInstallApkTask(final OnReleasedListener listener) {
20+
mListener = listener;
21+
}
22+
23+
@Override
24+
public Void doInBackground() {
25+
ResourceUtils.copyFileFromAssets("test_install", Config.TEST_APK_PATH);
26+
return null;
27+
}
28+
29+
@Override
30+
public void onSuccess(Void result) {
31+
if (mListener != null) {
32+
mListener.onReleased();
33+
}
34+
}
35+
36+
public void execute() {
37+
ThreadUtils.executeByIo(this);
38+
}
39+
}

app/src/main/java/com/blankj/androidutilcode/feature/core/fragment/FragmentActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ public void onWidgetClick(View view) {
7878

7979
// @Override
8080
// public void onBackPressed() {
81-
//// if (!FragmentUtils.dispatchBackPress(getSupportFragmentManager())) {
82-
//// super.onBackPressed();
83-
//// }
81+
// if (!FragmentUtils.dispatchBackPress(getSupportFragmentManager())) {
82+
// super.onBackPressed();
83+
// }
8484
// }
8585

8686
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener

0 commit comments

Comments
 (0)