Skip to content

Commit 2ba8707

Browse files
committed
* 优化密码页键盘开关逻辑
1 parent ba36263 commit 2ba8707

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

app/src/main/java/com/surcumference/fingerprint/view/PasswordInputView.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ private void initView(Context context) {
5656
mInputView.setFocusable(true);
5757
mInputView.setFocusableInTouchMode(true);
5858
mInputView.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
59+
mInputView.setShowSoftInputOnFocus(true);
5960
String packageName = context.getPackageName();
6061
if (Constant.PACKAGE_NAME_ALIPAY.equals(packageName)
6162
|| Constant.PACKAGE_NAME_TAOBAO.equals(packageName)
@@ -87,6 +88,14 @@ private void initView(Context context) {
8788
this.addView(rootLLayout, rootLLayoutParams);
8889

8990
withPositiveButtonText(Lang.getString(R.id.ok));
91+
withOnPositiveButtonClickListener((dialog, which) -> {
92+
mInputView.clearFocus();
93+
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
94+
imm.hideSoftInputFromWindow(mInputView.getWindowToken(), 0);
95+
post(() -> {
96+
dialog.dismiss();
97+
});
98+
});
9099
}
91100

92101
@NonNull
@@ -107,10 +116,11 @@ public void setDefaultText(String text) {
107116
@Override
108117
protected void onAttachedToWindow() {
109118
super.onAttachedToWindow();
110-
post(() -> {
119+
mInputView.requestFocus();
120+
postDelayed(() -> {
111121
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
112122
imm.showSoftInput(mInputView, InputMethodManager.SHOW_IMPLICIT);
113-
});
123+
}, 200);
114124
}
115125

116126
@Override

0 commit comments

Comments
 (0)