Skip to content

Commit 63941ed

Browse files
committed
see 08/23 log
1 parent d7d3403 commit 63941ed

File tree

30 files changed

+293
-66
lines changed

30 files changed

+293
-66
lines changed

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

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

app/src/main/java/com/blankj/androidutilcode/UtilsApp.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.blankj.androidutilcode;
22

33
import android.annotation.SuppressLint;
4+
import android.content.Context;
45

56
import com.blankj.androidutilcode.base.BaseApplication;
67
import com.blankj.utilcode.util.AppUtils;
78
import com.blankj.utilcode.util.CrashUtils;
89
import com.blankj.utilcode.util.LogUtils;
10+
import com.blankj.utilcode.util.ToastUtils;
911
import com.squareup.leakcanary.LeakCanary;
1012

1113
import java.util.ArrayList;
@@ -26,11 +28,16 @@ public static UtilsApp getInstance() {
2628
return sInstance;
2729
}
2830

31+
@Override
32+
protected void attachBaseContext(Context base) {
33+
super.attachBaseContext(base);
34+
}
35+
2936
@Override
3037
public void onCreate() {
3138
super.onCreate();
39+
LogUtils.e();
3240
sInstance = this;
33-
com.blankj.utilcode.util.Utils.init(this);
3441
com.blankj.subutil.util.Utils.init(this);
3542
initLeakCanary();
3643
initLog();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.blankj.androidutilcode.feature.core.sp.SPActivity;
3030
import com.blankj.androidutilcode.feature.core.span.SpanActivity;
3131
import com.blankj.androidutilcode.feature.core.toast.ToastActivity;
32+
import com.blankj.utilcode.util.Utils;
3233

3334
/**
3435
* <pre>
@@ -57,6 +58,7 @@ public int bindLayout() {
5758

5859
@Override
5960
public void initView(Bundle savedInstanceState, View contentView) {
61+
Utils.getApp();
6062
getToolBar().setTitle(getString(R.string.core_util));
6163
}
6264

app/src/main/java/com/blankj/androidutilcode/feature/core/keyboard/KeyboardActivity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public int bindLayout() {
4747
@Override
4848
public void initView(Bundle savedInstanceState, View contentView) {
4949
KeyboardUtils.fixAndroidBug5497(this);
50-
// getToolBar().setTitle(getString(R.string.demo_keyboard));
5150
etInput = findViewById(R.id.et_input);
5251
findViewById(R.id.btn_hide_soft_input).setOnClickListener(this);
5352
findViewById(R.id.btn_show_soft_input).setOnClickListener(this);

app/src/main/java/com/blankj/androidutilcode/feature/core/screen/ScreenAdaptActivity.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
import android.support.annotation.Nullable;
77
import android.view.View;
88
import android.widget.TextView;
9+
import android.widget.Toast;
910

1011
import com.blankj.androidutilcode.R;
1112
import com.blankj.androidutilcode.base.BaseActivity;
13+
import com.blankj.androidutilcode.helper.DialogHelper;
1214
import com.blankj.utilcode.util.ScreenUtils;
15+
import com.blankj.utilcode.util.ToastUtils;
1316

1417
/**
1518
* <pre>
@@ -46,7 +49,12 @@ public int bindLayout() {
4649

4750
@Override
4851
public void initView(Bundle savedInstanceState, View contentView) {
49-
52+
if (ScreenUtils.isPortrait()) {
53+
findViewById(R.id.btn_show_system_toast).setOnClickListener(this);
54+
findViewById(R.id.btn_show_util_toast).setOnClickListener(this);
55+
findViewById(R.id.btn_system_dialog).setOnClickListener(this);
56+
findViewById(R.id.btn_system_dialog_without_adapt).setOnClickListener(this);
57+
}
5058
}
5159

5260
@Override
@@ -56,12 +64,27 @@ public void doBusiness() {
5664

5765
@Override
5866
public void onWidgetClick(View view) {
59-
67+
switch (view.getId()) {
68+
case R.id.btn_show_system_toast:
69+
Toast.makeText(this, "System Toast", Toast.LENGTH_SHORT).show();
70+
break;
71+
case R.id.btn_show_util_toast:
72+
ToastUtils.showShort("Util Toast");
73+
break;
74+
case R.id.btn_system_dialog:
75+
DialogHelper.showAdaptScreenDialog();
76+
break;
77+
case R.id.btn_system_dialog_without_adapt:
78+
ScreenUtils.cancelAdaptScreen(this);
79+
DialogHelper.showAdaptScreenDialog();
80+
ScreenUtils.adaptScreen4VerticalSlide(this, 720);
81+
break;
82+
}
6083
}
6184

6285
@Override
6386
protected void onDestroy() {
64-
ScreenUtils.cancelAdaptScreen(this);
87+
// ScreenUtils.cancelAdaptScreen(this);
6588
super.onDestroy();
6689
}
6790
}

app/src/main/java/com/blankj/androidutilcode/feature/core/toast/ToastActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import android.support.v4.content.ContextCompat;
99
import android.view.Gravity;
1010
import android.view.View;
11-
import android.widget.Toast;
1211

1312
import com.blankj.androidutilcode.R;
1413
import com.blankj.androidutilcode.base.BaseBackActivity;
14+
import com.blankj.utilcode.util.SizeUtils;
1515
import com.blankj.utilcode.util.SpanUtils;
1616
import com.blankj.utilcode.util.ToastUtils;
1717

app/src/main/java/com/blankj/androidutilcode/helper/DialogHelper.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,29 @@ public void onClick(DialogInterface dialog, int which) {
7070
.show();
7171
}
7272

73+
public static void showAdaptScreenDialog() {
74+
Activity topActivity = ActivityUtils.getTopActivity();
75+
if (topActivity == null) return;
76+
new AlertDialog.Builder(topActivity)
77+
.setTitle(android.R.string.dialog_alert_title)
78+
.setMessage("Message!")
79+
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
80+
@Override
81+
public void onClick(DialogInterface dialog, int which) {
82+
83+
}
84+
})
85+
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
86+
@Override
87+
public void onClick(DialogInterface dialog, int which) {
88+
89+
}
90+
})
91+
.setCancelable(false)
92+
.create()
93+
.show();
94+
}
95+
7396
public static void showKeyboardDialog() {
7497
Activity topActivity = ActivityUtils.getTopActivity();
7598
if (topActivity == null) return;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<resources xmlns:tools="http://schemas.android.com/tools">
2+
3+
<!-- Base application theme. -->
4+
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
5+
<!-- Customize your theme here. -->
6+
<item name="colorPrimary">@color/colorPrimary</item>
7+
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8+
<item name="colorAccent">@color/colorAccent</item>
9+
<item name="android:windowAnimationStyle">@style/AnimationActivity</item>
10+
<item name="android:windowActionBar">false</item>
11+
<!--slider-->
12+
<item name="android:windowIsTranslucent">true</item>
13+
<item name="android:windowBackground">@android:color/transparent</item>
14+
</style>
15+
16+
<style name="TextStyle">
17+
<item name="android:textSize">@dimen/font_24</item>
18+
<item name="android:textColor">@color/light_black</item>
19+
</style>
20+
21+
<style name="WideBtnStyle">
22+
<item name="android:textSize">@dimen/font_24</item>
23+
<item name="android:textColor">@color/light_black</item>
24+
<item name="android:textAllCaps">false</item>
25+
</style>
26+
27+
<style name="AnimationActivity" parent="@android:style/Animation.Translucent">
28+
<item name="android:activityOpenEnterAnimation">@anim/slide_in_left</item>
29+
<item name="android:activityOpenExitAnimation">@anim/slide_out_left</item>
30+
<item name="android:activityCloseEnterAnimation">@anim/slide_in_right</item>
31+
<item name="android:activityCloseExitAnimation">@anim/slide_out_right</item>
32+
</style>
33+
</resources>

app/src/main/res_core/layout-port/activity_screen_adapt.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,48 @@
88
android:layout_width="match_parent"
99
android:layout_height="2000dp">
1010

11+
<LinearLayout
12+
android:id="@+id/ll_container"
13+
android:layout_width="match_parent"
14+
android:layout_height="wrap_content"
15+
android:orientation="vertical">
16+
17+
<Button
18+
android:id="@+id/btn_show_system_toast"
19+
style="@style/WideBtnStyle"
20+
android:layout_width="match_parent"
21+
android:layout_height="wrap_content"
22+
android:text="@string/adapt_screen_system_toast" />
23+
24+
<Button
25+
android:id="@+id/btn_show_util_toast"
26+
style="@style/WideBtnStyle"
27+
android:layout_width="match_parent"
28+
android:layout_height="wrap_content"
29+
android:text="@string/adapt_screen_util_toast" />
30+
31+
<Button
32+
android:id="@+id/btn_system_dialog"
33+
style="@style/WideBtnStyle"
34+
android:layout_width="match_parent"
35+
android:layout_height="wrap_content"
36+
android:text="@string/adapt_screen_system_dialog" />
37+
38+
<Button
39+
android:id="@+id/btn_system_dialog_without_adapt"
40+
style="@style/WideBtnStyle"
41+
android:layout_width="match_parent"
42+
android:layout_height="wrap_content"
43+
android:text="@string/adapt_screen_system_dialog_without_adapt" />
44+
45+
</LinearLayout>
46+
1147
<TextView
1248
style="@style/TextStyle"
1349
android:layout_width="360dp"
1450
android:layout_height="2000dp"
1551
android:layout_alignParentLeft="true"
52+
android:layout_below="@id/ll_container"
1653
android:background="@color/colorAccentHalfTrans"
1754
android:gravity="center_horizontal"
1855
android:text="360dp" />
@@ -22,6 +59,7 @@
2259
android:layout_width="360dp"
2360
android:layout_height="2000dp"
2461
android:layout_alignParentRight="true"
62+
android:layout_below="@id/ll_container"
2563
android:background="@color/colorPrimaryHalfTrans"
2664
android:gravity="center_horizontal"
2765
android:text="360dp" />

app/src/main/res_core/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@
225225
<string name="screen_screenshot">Screenshot</string>
226226
<string name="screen_set_sleep_duration">Set Sleep Duration</string>
227227
<string name="screen_test_adapt_screen">Test Adapt Screen</string>
228+
<string name="adapt_screen_system_toast">System Toast</string>
229+
<string name="adapt_screen_util_toast">Util Toast</string>
230+
<string name="adapt_screen_system_dialog">System Dialog</string>
231+
<string name="adapt_screen_system_dialog_without_adapt">System Dialog Without Adapt</string>
228232

229233
<!--SnackBar 相关-->
230234
<string name="snackbar_show_short">Show Short Snackbar</string>

config.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ ext {
66
compileSdkVersion: 27,
77
minSdkVersion : 14,
88
targetSdkVersion : 27,
9-
versionCode : 1_019_000,
10-
versionName : '1.19.0'// E.g 1.9.72 => 1,009,072
9+
versionCode : 1_019_001,
10+
versionName : '1.19.1'// E.g 1.9.72 => 1,009,072
1111
]
1212

1313
versionConfig = [
@@ -157,7 +157,7 @@ def configLibAndroidDomain(Project pro) {
157157

158158
def configAppDependencies(Project pro) {
159159
pro.dependencies {
160-
implementation fileTree(include: ['*.jar'], dir: 'libs')
160+
implementation fileTree(include: ['*.jar'], dir: 'app/libs')
161161
implementation project(':utilcode')
162162
implementation project(':subutil')
163163

@@ -167,7 +167,7 @@ def configAppDependencies(Project pro) {
167167
// LeakCanary
168168
debugImplementation depConfig.leakcanary.android
169169
releaseImplementation depConfig.leakcanary.android_no_op
170-
// implementation 'com.blankj:utilcode:1.18.7'
170+
// implementation 'com.blankj:utilcode:1.19.1'
171171
}
172172
}
173173

subutil/src/main/java/com/blankj/subutil/util/Utils.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ private Utils() {
4141
*
4242
* @param context context
4343
*/
44-
public static void init(@NonNull final Context context) {
44+
public static void init(final Context context) {
45+
if (context == null) {
46+
init(getApplicationByReflect());
47+
return;
48+
}
4549
init((Application) context.getApplicationContext());
4650
}
4751

@@ -51,8 +55,14 @@ public static void init(@NonNull final Context context) {
5155
*
5256
* @param app application
5357
*/
54-
public static void init(@NonNull final Application app) {
55-
Utils.sApplication = app;
58+
public static void init(final Application app) {
59+
if (sApplication == null) {
60+
if (app == null) {
61+
Utils.sApplication = getApplicationByReflect();
62+
} else {
63+
Utils.sApplication = app;
64+
}
65+
}
5666
}
5767

5868
/**
@@ -62,9 +72,13 @@ public static void init(@NonNull final Application app) {
6272
*/
6373
public static Application getApp() {
6474
if (sApplication != null) return sApplication;
75+
return getApplicationByReflect();
76+
}
77+
78+
private static Application getApplicationByReflect() {
6579
try {
6680
@SuppressLint("PrivateApi")
67-
Class<?> activityThread = Class.forName("android.app.activityThread");
81+
Class<?> activityThread = Class.forName("android.app.ActivityThread");
6882
Object at = activityThread.getMethod("currentActivityThread").invoke(null);
6983
Object app = activityThread.getMethod("getApplication").invoke(at);
7084
if (app == null) {

update_log.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* 18/08/23 修复适配后 ToastUtils 原生 Toast 尺寸发生改变的问题,修复 KeyboardUtils#fixSoftInputLeaks,发布 1.19.1
12
* 18/08/10 修复 ScreenUtils#adaptxx 导致获取状态栏和导航栏尺寸不对问题,发布 1.19.0
23
* 18/08/09 新增 IntentUtils#isIntentAvailable,ToastUtils 传入空显示 null,发布 1.18.6
34
* 18/08/08 修复 ScreenUtils#adaptxx 在第三方 SDK 会出现的问题,发布 1.18.5

utilcode/README-CN.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.19.0'
5+
implementation 'com.blankj:utilcode:1.19.1'
66
```
77

88

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.19.0'
5+
implementation 'com.blankj:utilcode:1.19.1'
66
```
77

88

utilcode/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ apply {
1111
from('readme.gradle')
1212
from("../bintrayUpload.gradle")
1313
}
14-
//gradle bintrayUpload
14+
//./gradlew bintrayUpload

utilcode/src/main/AndroidManifest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
android:windowSoftInputMode="stateHidden|stateAlwaysHidden" />
1111

1212
<provider
13-
android:name="android.support.v4.content.FileProvider4Util"
13+
android:name=".util.Utils$FileProvider4Util"
1414
android:authorities="${applicationId}.utilcode.provider"
1515
android:exported="false"
16-
android:grantUriPermissions="true">
16+
android:grantUriPermissions="true"
17+
android:multiprocess="true">
1718
<meta-data
1819
android:name="android.support.FILE_PROVIDER_PATHS"
1920
android:resource="@xml/util_code_provider_paths" />

0 commit comments

Comments
 (0)