mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-27 13:53:57 +01:00
Empty login fields crash fix
This commit resolves the issue where the app crashes on the Login page if one of the mandatory filed is left empty.
This commit is contained in:
parent
4821718407
commit
9fea056063
@ -139,6 +139,8 @@ public class LoginActivity extends BaseActivity {
|
||||
|
||||
loginButton.setOnClickListener(view -> {
|
||||
Log.i("LoginActivity", "Login button clicked");
|
||||
if(!checkFields())
|
||||
return;
|
||||
loginButton.setEnabled(false);
|
||||
progressBar.setVisibility(ProgressBar.VISIBLE);
|
||||
String username = username_input.getText().toString().trim();
|
||||
@ -260,6 +262,26 @@ public class LoginActivity extends BaseActivity {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private boolean checkFields() {
|
||||
boolean result = true;
|
||||
String username = username_input.getText().toString();
|
||||
String password = password_input.getText().toString();
|
||||
String instance = instance_input.getText().toString();
|
||||
if(instance == null || instance.isEmpty()) {
|
||||
instance_input.setError(getString(R.string.instance_cannot_be_empty));
|
||||
result = false;
|
||||
}
|
||||
if(username == null || username.isEmpty()) {
|
||||
username_input.setError(getString(R.string.username_cannot_be_empty));
|
||||
result = false;
|
||||
}
|
||||
if(password == null || password.isEmpty()) {
|
||||
password_input.setError(getString(R.string.password_cannot_be_empty));
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static String correctURL(String url) {
|
||||
if (url == null || url.isEmpty()) {
|
||||
throw new IllegalArgumentException("URL cannot be null or empty");
|
||||
|
@ -1349,4 +1349,7 @@
|
||||
<string name="use_circular_fab">Use Circular FAB</string>
|
||||
<string name="block_community">Block Community\n</string>
|
||||
<string name="not_implemented">Feature not implemented yet :(</string>
|
||||
<string name="instance_cannot_be_empty">The instance field cannot be left empty.</string>
|
||||
<string name="username_cannot_be_empty">The username field cannot be left empty.</string>
|
||||
<string name="password_cannot_be_empty">The password field cannot be left empty.</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user