|
50 | 50 | import android.view.View; |
51 | 51 | import android.view.WindowManager; |
52 | 52 | import android.webkit.JavascriptInterface; |
| 53 | +import android.widget.Button; |
53 | 54 | import android.widget.TextView; |
54 | 55 | import android.widget.Toast; |
55 | 56 |
|
@@ -5146,32 +5147,44 @@ public void showLoginDialogBox(@Nullable final Runnable onSuccess, @Nullable fin |
5146 | 5147 | alertDialogBuilder.setView(promptsView); |
5147 | 5148 | alertDialogBuilder |
5148 | 5149 | .setCancelable(false) |
5149 | | - .setPositiveButton( |
5150 | | - R.string.Ok, |
5151 | | - (dialog, id) -> { |
5152 | | - if (!username.getText().toString().isEmpty() || !password.getText().toString().isEmpty()) { |
5153 | | - boolean isUserLogged = LoginToken(username.getText().toString(), password.getText().toString()); |
5154 | | - if (isUserLogged) { |
5155 | | - if (onSuccess != null) { |
5156 | | - onSuccess.run(); |
5157 | | - } |
5158 | | - } else { |
5159 | | - AndroidUtils.showConfirmDialog( |
5160 | | - activity, R.string.LoginFail, |
5161 | | - (d, w) -> { |
5162 | | - if (onError != null) { |
5163 | | - onError.run(); |
5164 | | - } |
5165 | | - } |
5166 | | - ); |
5167 | | - } |
5168 | | - } else { |
5169 | | - Toast.makeText(activity, "Please enter user name and password", Toast.LENGTH_LONG).show(); |
5170 | | - } |
5171 | | - }); |
| 5150 | + .setPositiveButton(R.string.Ok,null) |
| 5151 | + .setNegativeButton(R.string.Close, (d, which) -> { |
| 5152 | + activity.finish(); |
| 5153 | + }); |
5172 | 5154 |
|
5173 | 5155 | // create alert dialog |
5174 | 5156 | AlertDialog alertDialog = alertDialogBuilder.create(); |
| 5157 | + alertDialog.setOnShowListener(d -> { |
| 5158 | + Button okButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); |
| 5159 | + okButton.setOnClickListener(v -> { |
| 5160 | + String user = username.getText().toString().trim(); |
| 5161 | + String pass = password.getText().toString().trim(); |
| 5162 | + if (user.isEmpty() || pass.isEmpty()) { |
| 5163 | + Toast.makeText(activity, |
| 5164 | + "Please enter user name and password", |
| 5165 | + Toast.LENGTH_LONG).show(); |
| 5166 | + return; |
| 5167 | + } |
| 5168 | + |
| 5169 | + boolean isUserLogged = LoginToken(user, pass); |
| 5170 | + if (isUserLogged) { |
| 5171 | + alertDialog.dismiss(); |
| 5172 | + if (onSuccess != null) { |
| 5173 | + onSuccess.run(); |
| 5174 | + } |
| 5175 | + } else { |
| 5176 | + AndroidUtils.showConfirmDialog( |
| 5177 | + activity, |
| 5178 | + R.string.LoginFail, |
| 5179 | + (d2, w) -> { |
| 5180 | + if (onError != null) { |
| 5181 | + onError.run(); |
| 5182 | + } |
| 5183 | + } |
| 5184 | + ); |
| 5185 | + } |
| 5186 | + }); |
| 5187 | + }); |
5175 | 5188 |
|
5176 | 5189 | // show it |
5177 | 5190 | alertDialog.show(); |
|
0 commit comments