Skip to content

Commit 96e51ef

Browse files
committed
see 01/28 log
1 parent 59fd054 commit 96e51ef

Some content is hidden

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

45 files changed

+493
-420
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* `19/01/28` [fix] KeyboardUtils#fixSoftInputLeaks didn't work on the device of HuaWei.
2+
* `19/01/27` [upd] demo
13
* `19/01/25` [add] CloneUtils, PermissionUtils support request permission of WRITE_SETTINGS and DRAW_OVERLAYS. Publish v1.23.2.
24
* `19/01/24` [add] BrightnessUtils and FlashlightUtils.
35
* `19/01/23` [add] Modify the demo of utilcode use kotlin. Publish v1.23.1.

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

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

config.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ ext {
55
compileSdkVersion = 27
66
minSdkVersion = 14
77
targetSdkVersion = 27
8-
versionCode = 1_023_002
9-
versionName = '1.23.2'// E.g. 1.9.72 => 1,009,072
8+
versionCode = 1_023_003
9+
versionName = '1.23.3'// E.g. 1.9.72 => 1,009,072
1010

1111
bus = [
1212
isDebug: false,
@@ -17,7 +17,7 @@ ext {
1717
// lib version
1818
kotlin_version = '1.3.0'
1919
support_version = '27.1.1'
20-
leakcanary_version = '1.5.4'
20+
leakcanary_version = '1.6.3'
2121

2222
dep = [
2323
plugin : [
@@ -38,8 +38,9 @@ ext {
3838
constraint : "com.android.support.constraint:constraint-layout:1.1.3",
3939
kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version",
4040
leakcanary : [
41-
android : "com.squareup.leakcanary:leakcanary-android:$leakcanary_version",
42-
android_no_op: "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version",
41+
android : "com.squareup.leakcanary:leakcanary-android:$leakcanary_version",
42+
android_no_op : "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version",
43+
support_fragment: "com.squareup.leakcanary:leakcanary-support-fragment:$leakcanary_version"
4344
],
4445
free_proguard: "com.blankj:free-proguard:0.0.7",
4546
adapt_screen : "com.blankj:adapt-screen:0.0.3",

config_app.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ android {
4040
dependencies {
4141
// LeakCanary
4242
debugImplementation dep.leakcanary.android
43+
debugImplementation dep.leakcanary.support_fragment
4344
releaseImplementation dep.leakcanary.android_no_op
4445
}
4546

lib/base/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ dependencies {
1515
api dep.free_proguard
1616
api 'com.r0adkll:slidableactivity:2.0.5'
1717
compileOnly dep.leakcanary.android_no_op
18-
// api 'com.blankj:utilcode:1.23.2'
18+
// api 'com.blankj:utilcode:1.23.3'
1919
}

subutil/pkg/src/main/java/com/blankj/subutil/pkg/feature/location/LocationActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class LocationActivity : BaseBackActivity() {
5151
override fun getLocation(lastLatitude: String, lastLongitude: String, latitude: String,
5252
longitude: String, country: String, locality: String, street: String) {
5353
runOnUiThread {
54-
locationAboutTv.text = SpanUtils()
54+
SpanUtils.with(locationAboutTv)
5555
.appendLine("lastLatitude: $lastLatitude")
5656
.appendLine("lastLongitude: $lastLongitude")
5757
.appendLine("latitude: $latitude")
@@ -77,7 +77,7 @@ class LocationActivity : BaseBackActivity() {
7777
override fun initView(savedInstanceState: Bundle?, contentView: View) {
7878
setTitle(R.string.demo_location)
7979

80-
locationAboutTv.text = SpanUtils()
80+
SpanUtils.with(locationAboutTv)
8181
.appendLine("lastLatitude: unknown")
8282
.appendLine("lastLongitude: unknown")
8383
.appendLine("latitude: unknown")

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

88

utilcode/README-STATIC-BUS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ apply plugin: "com.blankj.bus"
2727
给 base 模块添加 [AndroidUtilCode](https://github.com/Blankj/AndroidUtilCode) 依赖:
2828

2929
```groovy
30-
api "com.blankj:utilcode:1.23.2"
30+
api "com.blankj:utilcode:1.23.3"
3131
```
3232

3333
比如 module0 中存在的 `Module0Activity.java`,我们通常都是在它内部写一个 `start` 函数来启动它,现在我们给它添加 `@BusUtils.Subscribe` 注解,并给注解的 `name` 赋唯一值,要注意,函数务必要 `public static` 哦:

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

88

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ public static AppInfo getAppInfo() {
736736
* </ul>
737737
*
738738
* @param packageName The name of the package.
739-
* @return 当前应用的 AppInfo
739+
* @return the application's information
740740
*/
741741
public static AppInfo getAppInfo(final String packageName) {
742742
try {

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

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ public static void setStatusBarLightMode(@NonNull final Window window,
127127
if (decorView != null) {
128128
int vis = decorView.getSystemUiVisibility();
129129
if (isLightMode) {
130-
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
131130
vis |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
132131
} else {
133132
vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
@@ -137,6 +136,33 @@ public static void setStatusBarLightMode(@NonNull final Window window,
137136
}
138137
}
139138

139+
/**
140+
* Is the status bar light mode.
141+
*
142+
* @param activity The activity.
143+
* @return {@code true}: yes<br>{@code false}: no
144+
*/
145+
public static boolean isStatusBarLightMode(@NonNull final Activity activity) {
146+
return isStatusBarLightMode(activity.getWindow());
147+
}
148+
149+
/**
150+
* Is the status bar light mode.
151+
*
152+
* @param window The window.
153+
* @return {@code true}: yes<br>{@code false}: no
154+
*/
155+
public static boolean isStatusBarLightMode(@NonNull final Window window) {
156+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
157+
View decorView = window.getDecorView();
158+
if (decorView != null) {
159+
int vis = decorView.getSystemUiVisibility();
160+
return (vis & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) != 0;
161+
}
162+
}
163+
return false;
164+
}
165+
140166
/**
141167
* Add the top margin size equals status bar's height for view.
142168
*
@@ -437,9 +463,10 @@ public static int getNavBarHeight() {
437463
* @param activity The activity.
438464
* @param isVisible True to set navigation bar visible, false otherwise.
439465
*/
440-
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
441466
public static void setNavBarVisibility(@NonNull final Activity activity, boolean isVisible) {
467+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
442468
setNavBarVisibility(activity.getWindow(), isVisible);
469+
443470
}
444471

445472
/**
@@ -448,8 +475,8 @@ public static void setNavBarVisibility(@NonNull final Activity activity, boolean
448475
* @param window The window.
449476
* @param isVisible True to set navigation bar visible, false otherwise.
450477
*/
451-
@RequiresApi(Build.VERSION_CODES.KITKAT)
452478
public static void setNavBarVisibility(@NonNull final Window window, boolean isVisible) {
479+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;
453480
final ViewGroup decorView = (ViewGroup) window.getDecorView();
454481
for (int i = 0, count = decorView.getChildCount(); i < count; i++) {
455482
final View child = decorView.getChildAt(i);

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.blankj.utilcode.util;
22

33
import android.annotation.SuppressLint;
4+
import android.content.res.Resources;
45
import android.graphics.Bitmap;
56
import android.graphics.BitmapFactory;
67
import android.graphics.Canvas;
@@ -578,7 +579,7 @@ public static Bitmap view2Bitmap(final View view) {
578579
* @return value of px
579580
*/
580581
public static int dp2px(final float dpValue) {
581-
final float scale = Utils.getApp().getResources().getDisplayMetrics().density;
582+
final float scale = Resources.getSystem().getDisplayMetrics().density;
582583
return (int) (dpValue * scale + 0.5f);
583584
}
584585

@@ -589,7 +590,7 @@ public static int dp2px(final float dpValue) {
589590
* @return value of dp
590591
*/
591592
public static int px2dp(final float pxValue) {
592-
final float scale = Utils.getApp().getResources().getDisplayMetrics().density;
593+
final float scale = Resources.getSystem().getDisplayMetrics().density;
593594
return (int) (pxValue / scale + 0.5f);
594595
}
595596

@@ -600,7 +601,7 @@ public static int px2dp(final float pxValue) {
600601
* @return value of px
601602
*/
602603
public static int sp2px(final float spValue) {
603-
final float fontScale = Utils.getApp().getResources().getDisplayMetrics().scaledDensity;
604+
final float fontScale = Resources.getSystem().getDisplayMetrics().scaledDensity;
604605
return (int) (spValue * fontScale + 0.5f);
605606
}
606607

@@ -611,7 +612,7 @@ public static int sp2px(final float spValue) {
611612
* @return value of sp
612613
*/
613614
public static int px2sp(final float pxValue) {
614-
final float fontScale = Utils.getApp().getResources().getDisplayMetrics().scaledDensity;
615+
final float fontScale = Resources.getSystem().getDisplayMetrics().scaledDensity;
615616
return (int) (pxValue / fontScale + 0.5f);
616617
}
617618

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,28 +259,26 @@ private static int getContentViewInvisibleHeight(final Activity activity) {
259259
* Fix the leaks of soft input.
260260
* <p>Call the function in {@link Activity#onDestroy()}.</p>
261261
*
262-
* @param context The context.
262+
* @param activity The activity.
263263
*/
264-
public static void fixSoftInputLeaks(final Context context) {
265-
if (context == null) return;
264+
public static void fixSoftInputLeaks(final Activity activity) {
265+
if (activity == null) return;
266266
InputMethodManager imm =
267267
(InputMethodManager) Utils.getApp().getSystemService(Context.INPUT_METHOD_SERVICE);
268-
String[] strArr = new String[]{"mCurRootView", "mServedView", "mNextServedView", "mLastSrvView"};
269-
for (int i = 0; i < 4; i++) {
268+
if (imm == null) return;
269+
String[] leakViews = new String[]{"mLastSrvView", "mCurRootView", "mServedView", "mNextServedView"};
270+
for (String leakView : leakViews) {
270271
try {
271-
//noinspection ConstantConditions
272-
Field declaredField = imm.getClass().getDeclaredField(strArr[i]);
272+
Field declaredField = InputMethodManager.class.getDeclaredField(leakView);
273273
if (declaredField == null) continue;
274274
if (!declaredField.isAccessible()) {
275275
declaredField.setAccessible(true);
276276
}
277277
Object obj = declaredField.get(imm);
278278
if (!(obj instanceof View)) continue;
279279
View view = (View) obj;
280-
if (view.getContext() == context) {
280+
if (view.getRootView() == activity.getWindow().getDecorView().getRootView()) {
281281
declaredField.set(imm, null);
282-
} else {
283-
return;
284282
}
285283
} catch (Throwable th) {
286284
th.printStackTrace();

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

Lines changed: 76 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ public static class Config {
626626
private String mFilePrefix = "util";// The file prefix of log.
627627
private boolean mLogSwitch = true; // The switch of log.
628628
private boolean mLog2ConsoleSwitch = true; // The logcat's switch of log.
629-
private String mGlobalTag = null; // The global tag of log.
629+
private String mGlobalTag = ""; // The global tag of log.
630630
private boolean mTagIsSpace = true; // The global tag is space.
631631
private boolean mLogHeadSwitch = true; // The head's switch of log.
632632
private boolean mLog2FileSwitch = false; // The file's switch of log.
@@ -744,22 +744,83 @@ public final <T> Config addFormatter(final IFormatter<T> iFormatter) {
744744
return this;
745745
}
746746

747+
public String getDefaultDir() {
748+
return mDefaultDir;
749+
}
750+
751+
public String getDir() {
752+
return mDir == null ? mDefaultDir : mDir;
753+
}
754+
755+
public String getFilePrefix() {
756+
return mFilePrefix;
757+
}
758+
759+
public boolean isLogSwitch() {
760+
return mLogSwitch;
761+
}
762+
763+
public boolean isLog2ConsoleSwitch() {
764+
return mLog2ConsoleSwitch;
765+
}
766+
767+
public String getGlobalTag() {
768+
if (isSpace(mGlobalTag)) return "null";
769+
return mGlobalTag;
770+
}
771+
772+
public boolean isLogHeadSwitch() {
773+
return mLogHeadSwitch;
774+
}
775+
776+
public boolean isLog2FileSwitch() {
777+
return mLog2FileSwitch;
778+
}
779+
780+
public boolean isLogBorderSwitch() {
781+
return mLogBorderSwitch;
782+
}
783+
784+
public boolean isSingleTagSwitch() {
785+
return mSingleTagSwitch;
786+
}
787+
788+
public char getConsoleFilter() {
789+
return T[mConsoleFilter - V];
790+
}
791+
792+
public char getFileFilter() {
793+
return T[mFileFilter - V];
794+
}
795+
796+
public int getStackDeep() {
797+
return mStackDeep;
798+
}
799+
800+
public int getStackOffset() {
801+
return mStackOffset;
802+
}
803+
804+
public int getSaveDays() {
805+
return mSaveDays;
806+
}
807+
747808
@Override
748809
public String toString() {
749-
return "switch: " + mLogSwitch
750-
+ LINE_SEP + "console: " + mLog2ConsoleSwitch
751-
+ LINE_SEP + "tag: " + (mTagIsSpace ? "null" : mGlobalTag)
752-
+ LINE_SEP + "head: " + mLogHeadSwitch
753-
+ LINE_SEP + "file: " + mLog2FileSwitch
754-
+ LINE_SEP + "dir: " + (mDir == null ? mDefaultDir : mDir)
755-
+ LINE_SEP + "filePrefix: " + mFilePrefix
756-
+ LINE_SEP + "border: " + mLogBorderSwitch
757-
+ LINE_SEP + "singleTag: " + mSingleTagSwitch
758-
+ LINE_SEP + "consoleFilter: " + T[mConsoleFilter - V]
759-
+ LINE_SEP + "fileFilter: " + T[mFileFilter - V]
760-
+ LINE_SEP + "stackDeep: " + mStackDeep
761-
+ LINE_SEP + "stackOffset: " + mStackOffset
762-
+ LINE_SEP + "saveDays: " + mSaveDays
810+
return "switch: " + isLogSwitch()
811+
+ LINE_SEP + "console: " + isLog2ConsoleSwitch()
812+
+ LINE_SEP + "tag: " + getGlobalTag()
813+
+ LINE_SEP + "head: " + isLogHeadSwitch()
814+
+ LINE_SEP + "file: " + isLog2FileSwitch()
815+
+ LINE_SEP + "dir: " + getDir()
816+
+ LINE_SEP + "filePrefix: " + getFilePrefix()
817+
+ LINE_SEP + "border: " + isLogBorderSwitch()
818+
+ LINE_SEP + "singleTag: " + isSingleTagSwitch()
819+
+ LINE_SEP + "consoleFilter: " + getConsoleFilter()
820+
+ LINE_SEP + "fileFilter: " + getFileFilter()
821+
+ LINE_SEP + "stackDeep: " + getStackDeep()
822+
+ LINE_SEP + "stackOffset: " + getStackOffset()
823+
+ LINE_SEP + "saveDays: " + getSaveDays()
763824
+ LINE_SEP + "formatter: " + I_FORMATTER_MAP;
764825
}
765826
}

0 commit comments

Comments
 (0)