Skip to content

Commit bdb7769

Browse files
committed
see 01/22 log
1 parent 39edebd commit bdb7769

File tree

75 files changed

+1905
-2688
lines changed

Some content is hidden

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

75 files changed

+1905
-2688
lines changed

config.gradle

Lines changed: 2 additions & 2 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_000
9-
versionName = '1.23.0'// E.g. 1.9.72 => 1,009,072
8+
versionCode = 1_023_001
9+
versionName = '1.23.1'// E.g. 1.9.72 => 1,009,072
1010

1111
bus = [
1212
isDebug: false,

utilcode/README-CN.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,7 @@ getCaptureIntent : 获取拍照的意图
445445
* ### 键盘相关 -> [KeyboardUtils.java][keyboard.java] -> [Demo][keyboard.demo]
446446
```
447447
showSoftInput : 显示软键盘
448-
showSoftInputUsingToggle : 显示软键盘用 toggle
449448
hideSoftInput : 隐藏软键盘
450-
hideSoftInputUsingToggle : 隐藏软键盘用 toggle
451449
toggleSoftInput : 切换键盘显示与否状态
452450
isSoftInputVisible : 判断软键盘是否可见
453451
registerSoftInputChangedListener : 注册软键盘改变监听器

utilcode/app/__bus__.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"CoreUtilActivity#start": "void com.blankj.utilcode.pkg.feature.CoreUtilActivity.start(android.content.Context)"
2+
"CoreUtilActivity#start": "void com.blankj.utilcode.pkg.feature.CoreUtilActivity.Companion.start(android.content.Context)"
33
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,10 +969,11 @@ private static Intent getInstallAppIntent(final File file, final boolean isNewTa
969969
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
970970
data = Uri.fromFile(file);
971971
} else {
972-
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
973972
String authority = Utils.getApp().getPackageName() + ".utilcode.provider";
974973
data = FileProvider.getUriForFile(Utils.getApp(), authority, file);
974+
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
975975
}
976+
Utils.getApp().grantUriPermission(Utils.getApp().getPackageName(), data, Intent.FLAG_GRANT_READ_URI_PERMISSION);
976977
intent.setDataAndType(data, type);
977978
return isNewTask ? intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) : intent;
978979
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ public static void setNavBarVisibility(@NonNull final Window window, boolean isV
476476

477477
/**
478478
* Return whether the navigation bar visible.
479+
* <p>Call it in onWindowFocusChanged will get right result.</p>
479480
*
480481
* @param activity The activity.
481482
* @return {@code true}: yes<br>{@code false}: no
@@ -486,6 +487,7 @@ public static boolean isNavBarVisible(@NonNull final Activity activity) {
486487

487488
/**
488489
* Return whether the navigation bar visible.
490+
* <p>Call it in onWindowFocusChanged will get right result.</p>
489491
*
490492
* @param window The window.
491493
* @return {@code true}: yes<br>{@code false}: no

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

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,15 @@ public static void showSoftInput(final Activity activity) {
5050
* Show the soft input.
5151
*
5252
* @param activity The activity.
53+
* @param flags Provides additional operating flags. Currently may be
54+
* 0 or have the {@link InputMethodManager#SHOW_IMPLICIT} bit set.
5355
*/
5456
public static void showSoftInput(final Activity activity, final int flags) {
55-
InputMethodManager imm =
56-
(InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
57-
if (imm == null) return;
5857
View view = activity.getCurrentFocus();
5958
if (view == null) {
6059
view = new View(activity);
61-
view.setFocusable(true);
62-
view.setFocusableInTouchMode(true);
63-
view.requestFocus();
6460
}
65-
imm.showSoftInput(view, flags, new ResultReceiver(new Handler()) {
66-
@Override
67-
protected void onReceiveResult(int resultCode, Bundle resultData) {
68-
LogUtils.e(resultCode);
69-
}
70-
});
61+
showSoftInput(view, flags);
7162
}
7263

7364
/**
@@ -82,26 +73,26 @@ public static void showSoftInput(final View view) {
8273
/**
8374
* Show the soft input.
8475
*
85-
* @param view The view.
76+
* @param view The view.
77+
* @param flags Provides additional operating flags. Currently may be
78+
* 0 or have the {@link InputMethodManager#SHOW_IMPLICIT} bit set.
8679
*/
8780
public static void showSoftInput(final View view, final int flags) {
8881
InputMethodManager imm =
8982
(InputMethodManager) Utils.getApp().getSystemService(Context.INPUT_METHOD_SERVICE);
83+
if (imm == null) return;
9084
view.setFocusable(true);
9185
view.setFocusableInTouchMode(true);
9286
view.requestFocus();
93-
//noinspection ConstantConditions
94-
imm.showSoftInput(view, flags);
95-
}
96-
97-
/**
98-
* Show the soft input using toggle.
99-
*
100-
* @param activity The activity.
101-
*/
102-
public static void showSoftInputUsingToggle(final Activity activity) {
103-
if (isSoftInputVisible(activity)) return;
104-
toggleSoftInput();
87+
imm.showSoftInput(view, flags, new ResultReceiver(new Handler()) {
88+
@Override
89+
protected void onReceiveResult(int resultCode, Bundle resultData) {
90+
if (resultCode == InputMethodManager.RESULT_UNCHANGED_HIDDEN
91+
|| resultCode == InputMethodManager.RESULT_HIDDEN) {
92+
toggleSoftInput();
93+
}
94+
}
95+
});
10596
}
10697

10798
/**
@@ -110,12 +101,11 @@ public static void showSoftInputUsingToggle(final Activity activity) {
110101
* @param activity The activity.
111102
*/
112103
public static void hideSoftInput(final Activity activity) {
113-
InputMethodManager imm =
114-
(InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
115-
if (imm == null) return;
116104
View view = activity.getCurrentFocus();
117-
if (view == null) view = new View(activity);
118-
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
105+
if (view == null) {
106+
view = new View(activity);
107+
}
108+
hideSoftInput(view);
119109
}
120110

121111
/**
@@ -126,18 +116,16 @@ public static void hideSoftInput(final Activity activity) {
126116
public static void hideSoftInput(final View view) {
127117
InputMethodManager imm =
128118
(InputMethodManager) Utils.getApp().getSystemService(Context.INPUT_METHOD_SERVICE);
129-
//noinspection ConstantConditions
130-
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
131-
}
132-
133-
/**
134-
* Hide the soft input.
135-
*
136-
* @param activity The activity.
137-
*/
138-
public static void hideSoftInputUsingToggle(final Activity activity) {
139-
if (!isSoftInputVisible(activity)) return;
140-
toggleSoftInput();
119+
if (imm == null) return;
120+
imm.hideSoftInputFromWindow(view.getWindowToken(), 0, new ResultReceiver(new Handler()) {
121+
@Override
122+
protected void onReceiveResult(int resultCode, Bundle resultData) {
123+
if (resultCode == InputMethodManager.RESULT_UNCHANGED_SHOWN
124+
|| resultCode == InputMethodManager.RESULT_SHOWN) {
125+
toggleSoftInput();
126+
}
127+
}
128+
});
141129
}
142130

143131
/**

0 commit comments

Comments
 (0)