Skip to content

Commit 99465ed

Browse files
committed
fix login dialog
1 parent 54627dd commit 99465ed

3 files changed

Lines changed: 38 additions & 23 deletions

File tree

app/src/localeMv/res/values-fr/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,4 +482,5 @@
482482
<string name="pay_type_cash">Cash</string>
483483
<string name="pay_type_mobile_phone">Téléphone portable</string>
484484
<string name="pay_type_bank_transfer">Virement banquaire</string>
485+
<string name="Close">Fermer</string>
485486
</resources>

app/src/localeMv/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,4 +477,5 @@
477477
<string name="CurrentResourceLanguage">Current resource language: %1$s</string>
478478
<string name="SystemLanguageNotSupported">Current system language is not supported. The app will use the default language.</string>
479479
<string name="SupportedLanguages">Supported languages:\n%1$s</string>
480+
<string name="Close">Close</string>
480481
</resources>

app/src/main/java/org/openimis/imispolicies/ClientAndroidInterface.java

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import android.view.View;
5151
import android.view.WindowManager;
5252
import android.webkit.JavascriptInterface;
53+
import android.widget.Button;
5354
import android.widget.TextView;
5455
import android.widget.Toast;
5556

@@ -5146,32 +5147,44 @@ public void showLoginDialogBox(@Nullable final Runnable onSuccess, @Nullable fin
51465147
alertDialogBuilder.setView(promptsView);
51475148
alertDialogBuilder
51485149
.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+
});
51725154

51735155
// create alert dialog
51745156
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+
});
51755188

51765189
// show it
51775190
alertDialog.show();

0 commit comments

Comments
 (0)