From 3d0e30f12a00882d99d66954cd1b6e46fd466bf8 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Thu, 5 Jul 2018 02:38:05 +0200 Subject: #8886 disable save button if url validation fails --- .../se/leap/bitmaskclient/AddProviderBaseActivity.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'app/src/main/java') 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); } } }); -- cgit v1.2.3