Skip to content

Commit 357968d

Browse files
committed
Fix keyboard setSoftInputMode
1 parent cc06a96 commit 357968d

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

library/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ android {
1616
lintOptions {
1717
abortOnError false
1818
}
19+
compileOptions {
20+
sourceCompatibility = 1.8
21+
targetCompatibility = 1.8
22+
}
1923
}
2024

2125
dependencies {

library/src/main/java/com/developer/kalert/KAlertDialog.java

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import android.widget.ImageView;
1616
import android.widget.TextView;
1717

18-
import com.developer.progressx.ProgressWheel;
19-
2018
import java.util.Objects;
2119

2220
/**
@@ -29,7 +27,7 @@ public class KAlertDialog extends Dialog implements View.OnClickListener {
2927
public static final int WARNING_TYPE = 3;
3028
public static final int CUSTOM_IMAGE_TYPE = 4;
3129
public static final int PROGRESS_TYPE = 5;
32-
public static final int EDIT_TEXT_TYPE = 6;
30+
public static final int INPUT_TYPE = 6;
3331
private static final int NORMAL_TYPE = 0;
3432
private final AnimationSet mModalInAnim, mModalOutAnim, mErrorXInAnim, mSuccessLayoutAnimSet;
3533
private final Animation mOverlayOutAnim, mErrorInAnim, mSuccessBowAnim;
@@ -73,14 +71,11 @@ public void onAnimationStart(Animation animation) {
7371
@Override
7472
public void onAnimationEnd(Animation animation) {
7573
mDialogView.setVisibility(View.GONE);
76-
mDialogView.post(new Runnable() {
77-
@Override
78-
public void run() {
79-
if (mCloseFromCancel) {
80-
KAlertDialog.super.cancel();
81-
} else {
82-
KAlertDialog.super.dismiss();
83-
}
74+
mDialogView.post(() -> {
75+
if (mCloseFromCancel) {
76+
KAlertDialog.super.cancel();
77+
} else {
78+
KAlertDialog.super.dismiss();
8479
}
8580
});
8681
}
@@ -98,6 +93,8 @@ protected void applyTransformation(float interpolatedTime, Transformation t) {
9893
}
9994
};
10095
mOverlayOutAnim.setDuration(120);
96+
97+
Objects.requireNonNull(this.getWindow()).setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
10198
}
10299

103100
protected void onCreate(Bundle savedInstanceState) {
@@ -110,7 +107,7 @@ protected void onCreate(Bundle savedInstanceState) {
110107
mTitleTextView = findViewById(R.id.title_text);
111108
mContentTextView = findViewById(R.id.content_text);
112109
mErrorFrame = findViewById(R.id.error_frame);
113-
mErrorX = mErrorFrame.findViewById(R.id.error_x);
110+
mErrorX = Objects.requireNonNull(mErrorFrame).findViewById(R.id.error_x);
114111
mSuccessFrame = findViewById(R.id.success_frame);
115112
mProgressFrame = findViewById(R.id.progress_dialog);
116113
mSuccessTick = mSuccessFrame.findViewById(R.id.success_tick);
@@ -119,7 +116,7 @@ protected void onCreate(Bundle savedInstanceState) {
119116
mCustomImage = findViewById(R.id.custom_image);
120117
mWarningFrame = findViewById(R.id.warning_frame);
121118
mEditTextFrame = findViewById(R.id.edit_text_frame);
122-
mProgressHelper.setProgressWheel((ProgressWheel) findViewById(R.id.progressWheel));
119+
mProgressHelper.setProgressWheel(findViewById(R.id.progressWheel));
123120

124121
mConfirmButton = findViewById(R.id.custom_confirm_button);
125122
mCancelButton = findViewById(R.id.cancel_button);
@@ -192,7 +189,7 @@ private void changeAlertType(int alertType, boolean fromCreate) {
192189
mConfirmButton.setVisibility(View.GONE);
193190
setConfirmButtonColor(mColor);
194191
break;
195-
case EDIT_TEXT_TYPE:
192+
case INPUT_TYPE:
196193
mEditText.requestFocus();
197194
mEditTextFrame.setVisibility(View.VISIBLE);
198195
setConfirmButtonColor(mColor);
@@ -323,6 +320,14 @@ public KAlertDialog setContentText(String text) {
323320
return this;
324321
}
325322

323+
public String getInputText() {
324+
return mEditText.getText().toString();
325+
}
326+
327+
public void setInputText(String text) {
328+
mEditText.setText(text);
329+
}
330+
326331
public boolean isShowCancelButton() {
327332
return mShowCancel;
328333
}
@@ -356,14 +361,6 @@ public KAlertDialog setConfirmText(String text) {
356361
return this;
357362
}
358363

359-
public String getInputText() {
360-
return mEditText.getText().toString();
361-
}
362-
363-
public void setInputText(String text) {
364-
mEditText.setText(text);
365-
}
366-
367364
public KAlertDialog confirmButtonColor(int color) {
368365
return setConfirmButtonColor(getContext().getResources().getDrawable(color));
369366
}

library/src/main/res/layout/alert_dialog.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@
150150
android:id="@+id/edit_text"
151151
android:layout_width="match_parent"
152152
android:layout_height="match_parent">
153-
154-
<requestFocus />
155153
</EditText>
156154

157155
</FrameLayout>

0 commit comments

Comments
 (0)