summaryrefslogtreecommitdiff
path: root/src/se/leap/bitmaskclient
diff options
context:
space:
mode:
authorcyBerta <richy@cyborgsociety.org>2013-11-30 23:56:16 +0100
committercyBerta <richy@cyborgsociety.org>2013-11-30 23:56:16 +0100
commita4a2ed01e4f74abe30382ae737a9e145c8a41807 (patch)
tree21946497ff94e251367d7f930db0a8ee68441a5a /src/se/leap/bitmaskclient
parente34201c8a936e1cfc2021b4ec78ef072f0895544 (diff)
parentcd0433f7448307ac9067d4f112bc074f643b4698 (diff)
Merge branch 'develop' of ssh://leap.se:22/bitmask_android into develop
Diffstat (limited to 'src/se/leap/bitmaskclient')
-rw-r--r--src/se/leap/bitmaskclient/NewProviderDialog.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/se/leap/bitmaskclient/NewProviderDialog.java b/src/se/leap/bitmaskclient/NewProviderDialog.java
index f77cb6d4..a0b8a763 100644
--- a/src/se/leap/bitmaskclient/NewProviderDialog.java
+++ b/src/se/leap/bitmaskclient/NewProviderDialog.java
@@ -22,6 +22,7 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
+import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -38,7 +39,7 @@ import android.widget.Toast;
public class NewProviderDialog extends DialogFragment {
final public static String TAG = "newProviderDialog";
-
+
public interface NewProviderDialogInterface {
public void saveAndSelectProvider(String url_provider, boolean danger_on);
}
@@ -71,13 +72,15 @@ public class NewProviderDialog extends DialogFragment {
View new_provider_dialog_view = inflater.inflate(R.layout.new_provider_dialog, null);
final EditText url_input_field = (EditText)new_provider_dialog_view.findViewById(R.id.new_provider_url);
final CheckBox danger_checkbox = (CheckBox)new_provider_dialog_view.findViewById(R.id.danger_checkbox);
-
builder.setView(new_provider_dialog_view)
.setMessage(R.string.introduce_new_provider)
.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
String entered_url = url_input_field.getText().toString().trim();
if(!entered_url.startsWith("https://")) {
+ if (entered_url.startsWith("http://")){
+ entered_url = entered_url.substring("http://".length());
+ }
entered_url = "https://".concat(entered_url);
}
boolean danger_on = danger_checkbox.isChecked();
@@ -86,7 +89,8 @@ public class NewProviderDialog extends DialogFragment {
Toast.makeText(getActivity().getApplicationContext(), R.string.valid_url_entered, Toast.LENGTH_LONG).show();
} else {
url_input_field.setText("");
- Toast.makeText(getActivity().getApplicationContext(), R.string.not_valid_url_entered, Toast.LENGTH_LONG).show();
+ danger_checkbox.setChecked(false);
+ Toast.makeText(getActivity().getApplicationContext(), R.string.not_valid_url_entered, Toast.LENGTH_LONG).show();;
}
}
})
@@ -105,6 +109,7 @@ public class NewProviderDialog extends DialogFragment {
* @return true if it's not empty nor contains only the protocol.
*/
boolean validURL(String entered_url) {
- return !entered_url.isEmpty() && entered_url.matches("http[s]?://.+") && !entered_url.replaceFirst("http[s]?://", "").isEmpty();
+ //return !entered_url.isEmpty() && entered_url.matches("http[s]?://.+") && !entered_url.replaceFirst("http[s]?://", "").isEmpty();
+ return android.util.Patterns.WEB_URL.matcher(entered_url).matches();
}
}