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 +++++++++++++-- app/src/main/res/layout/a_add_provider.xml | 1 + .../main/res/layout/a_add_provider_tablet_scrollview.xml | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'app/src/main') 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); } } }); diff --git a/app/src/main/res/layout/a_add_provider.xml b/app/src/main/res/layout/a_add_provider.xml index 7d14ea96..c1322bef 100644 --- a/app/src/main/res/layout/a_add_provider.xml +++ b/app/src/main/res/layout/a_add_provider.xml @@ -76,6 +76,7 @@ android:layout_height="wrap_content" android:layout_marginLeft="@dimen/add_button_margin" android:layout_marginStart="@dimen/add_button_margin" + android:enabled="false" android:text="@string/save" /> diff --git a/app/src/main/res/layout/a_add_provider_tablet_scrollview.xml b/app/src/main/res/layout/a_add_provider_tablet_scrollview.xml index 220aabeb..132deba0 100644 --- a/app/src/main/res/layout/a_add_provider_tablet_scrollview.xml +++ b/app/src/main/res/layout/a_add_provider_tablet_scrollview.xml @@ -84,6 +84,7 @@ android:minWidth="80dp" android:layout_marginLeft="@dimen/add_button_margin" android:layout_marginStart="@dimen/add_button_margin" + android:enabled="false" android:text="@string/save" /> -- cgit v1.2.3