|
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 |
|
@@ -5179,32 +5180,44 @@ public void showLoginDialogBox(@Nullable final Runnable onSuccess, @Nullable fin |
5179 | 5180 | alertDialogBuilder.setView(promptsView); |
5180 | 5181 | alertDialogBuilder |
5181 | 5182 | .setCancelable(false) |
5182 | | - .setPositiveButton( |
5183 | | - R.string.Ok, |
5184 | | - (dialog, id) -> { |
5185 | | - if (!username.getText().toString().equals("") || !password.getText().toString().equals("")) { |
5186 | | - boolean isUserLogged = LoginToken(username.getText().toString(), password.getText().toString()); |
5187 | | - if (isUserLogged) { |
5188 | | - if (onSuccess != null) { |
5189 | | - onSuccess.run(); |
5190 | | - } |
5191 | | - } else { |
5192 | | - AndroidUtils.showConfirmDialog( |
5193 | | - activity, R.string.LoginFail, |
5194 | | - (d, w) -> { |
5195 | | - if (onError != null) { |
5196 | | - onError.run(); |
5197 | | - } |
5198 | | - } |
5199 | | - ); |
5200 | | - } |
5201 | | - } else { |
5202 | | - Toast.makeText(activity, "Please enter user name and password", Toast.LENGTH_LONG).show(); |
5203 | | - } |
5204 | | - }); |
| 5183 | + .setPositiveButton(R.string.Ok,null) |
| 5184 | + .setNegativeButton(R.string.Close, (d, which) -> { |
| 5185 | + activity.finish(); |
| 5186 | + }); |
5205 | 5187 |
|
5206 | 5188 | // create alert dialog |
5207 | 5189 | AlertDialog alertDialog = alertDialogBuilder.create(); |
| 5190 | + alertDialog.setOnShowListener(d -> { |
| 5191 | + Button okButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); |
| 5192 | + okButton.setOnClickListener(v -> { |
| 5193 | + String user = username.getText().toString().trim(); |
| 5194 | + String pass = password.getText().toString().trim(); |
| 5195 | + if (user.isEmpty() || pass.isEmpty()) { |
| 5196 | + Toast.makeText(activity, |
| 5197 | + "Please enter user name and password", |
| 5198 | + Toast.LENGTH_LONG).show(); |
| 5199 | + return; |
| 5200 | + } |
| 5201 | + |
| 5202 | + boolean isUserLogged = LoginToken(user, pass); |
| 5203 | + if (isUserLogged) { |
| 5204 | + alertDialog.dismiss(); |
| 5205 | + if (onSuccess != null) { |
| 5206 | + onSuccess.run(); |
| 5207 | + } |
| 5208 | + } else { |
| 5209 | + AndroidUtils.showConfirmDialog( |
| 5210 | + activity, |
| 5211 | + R.string.LoginFail, |
| 5212 | + (d2, w) -> { |
| 5213 | + if (onError != null) { |
| 5214 | + onError.run(); |
| 5215 | + } |
| 5216 | + } |
| 5217 | + ); |
| 5218 | + } |
| 5219 | + }); |
| 5220 | + }); |
5208 | 5221 |
|
5209 | 5222 | // show it |
5210 | 5223 | alertDialog.show(); |
|
0 commit comments