diff options
author | cyBerta <cyberta@riseup.net> | 2018-07-05 02:38:05 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2018-07-05 02:38:05 +0200 |
commit | 3d0e30f12a00882d99d66954cd1b6e46fd466bf8 (patch) | |
tree | 6d665273b7360d204a64975e2fa3c45e12f9f946 /app/src/main/java/se | |
parent | ba94657badcc5a05214a057fa938124bdf1ad47a (diff) |
#8886 disable save button if url validation fails
Diffstat (limited to 'app/src/main/java/se')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/AddProviderBaseActivity.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/AddProviderBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/AddProviderBaseActivity.java index 703b6ef0..ca848f2e 100644 --- a/app/src/main/java/se/leap/bitmaskclient/AddProviderBaseActivity.java +++ b/app/src/main/java/se/leap/bitmaskclient/AddProviderBaseActivity.java @@ -1,6 +1,7 @@ package se.leap.bitmaskclient; import android.content.Intent; +import android.os.Bundle; import android.support.design.widget.TextInputEditText; import android.support.design.widget.TextInputLayout; import android.text.Editable; @@ -10,6 +11,8 @@ import android.widget.Button; import butterknife.InjectView; +import static se.leap.bitmaskclient.ProviderListBaseActivity.EXTRAS_KEY_INVALID_URL; + /** * Created by cyberta on 30.06.18. */ @@ -27,10 +30,15 @@ public abstract class AddProviderBaseActivity extends ConfigWizardBaseActivity { @InjectView(R.id.button_cancel) Button cancelButton; + @InjectView(R.id.button_save) + Button saveButton; + protected void init() { - if (this.getIntent().getExtras() != null) { - editUrl.setText(this.getIntent().getExtras().getString(ProviderListBaseActivity.EXTRAS_KEY_INVALID_URL)); + Bundle extras = this.getIntent().getExtras(); + if (extras != null && extras.containsKey(EXTRAS_KEY_INVALID_URL)) { + editUrl.setText(extras.getString(EXTRAS_KEY_INVALID_URL)); + saveButton.setEnabled(true); } setupSaveButton(); @@ -82,8 +90,11 @@ public abstract class AddProviderBaseActivity extends ConfigWizardBaseActivity { public void afterTextChanged(Editable s) { if (!validURL(getURL())) { urlError.setError(getString(R.string.not_valid_url_entered)); + saveButton.setEnabled(false); + } else { urlError.setError(null); + saveButton.setEnabled(true); } } }); |