Skip to content
Snippets Groups Projects
Verified Commit 3d0e30f1 authored by cyberta's avatar cyberta
Browse files

#8886 disable save button if url validation fails

parent ba94657b
Branches
No related tags found
No related merge requests found
package se.leap.bitmaskclient; package se.leap.bitmaskclient;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TextInputEditText; import android.support.design.widget.TextInputEditText;
import android.support.design.widget.TextInputLayout; import android.support.design.widget.TextInputLayout;
import android.text.Editable; import android.text.Editable;
...@@ -10,6 +11,8 @@ import android.widget.Button; ...@@ -10,6 +11,8 @@ import android.widget.Button;
import butterknife.InjectView; import butterknife.InjectView;
import static se.leap.bitmaskclient.ProviderListBaseActivity.EXTRAS_KEY_INVALID_URL;
/** /**
* Created by cyberta on 30.06.18. * Created by cyberta on 30.06.18.
*/ */
...@@ -27,10 +30,15 @@ public abstract class AddProviderBaseActivity extends ConfigWizardBaseActivity { ...@@ -27,10 +30,15 @@ public abstract class AddProviderBaseActivity extends ConfigWizardBaseActivity {
@InjectView(R.id.button_cancel) @InjectView(R.id.button_cancel)
Button cancelButton; Button cancelButton;
@InjectView(R.id.button_save)
Button saveButton;
protected void init() { protected void init() {
if (this.getIntent().getExtras() != null) { Bundle extras = this.getIntent().getExtras();
editUrl.setText(this.getIntent().getExtras().getString(ProviderListBaseActivity.EXTRAS_KEY_INVALID_URL)); if (extras != null && extras.containsKey(EXTRAS_KEY_INVALID_URL)) {
editUrl.setText(extras.getString(EXTRAS_KEY_INVALID_URL));
saveButton.setEnabled(true);
} }
setupSaveButton(); setupSaveButton();
...@@ -82,8 +90,11 @@ public abstract class AddProviderBaseActivity extends ConfigWizardBaseActivity { ...@@ -82,8 +90,11 @@ public abstract class AddProviderBaseActivity extends ConfigWizardBaseActivity {
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
if (!validURL(getURL())) { if (!validURL(getURL())) {
urlError.setError(getString(R.string.not_valid_url_entered)); urlError.setError(getString(R.string.not_valid_url_entered));
saveButton.setEnabled(false);
} else { } else {
urlError.setError(null); urlError.setError(null);
saveButton.setEnabled(true);
} }
} }
}); });
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/add_button_margin" android:layout_marginLeft="@dimen/add_button_margin"
android:layout_marginStart="@dimen/add_button_margin" android:layout_marginStart="@dimen/add_button_margin"
android:enabled="false"
android:text="@string/save" /> android:text="@string/save" />
</LinearLayout> </LinearLayout>
......
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
android:minWidth="80dp" android:minWidth="80dp"
android:layout_marginLeft="@dimen/add_button_margin" android:layout_marginLeft="@dimen/add_button_margin"
android:layout_marginStart="@dimen/add_button_margin" android:layout_marginStart="@dimen/add_button_margin"
android:enabled="false"
android:text="@string/save" /> android:text="@string/save" />
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment