diff options
author | cyBerta <cyberta@riseup.net> | 2024-02-27 01:30:33 +0100 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2024-02-27 01:45:48 +0100 |
commit | 3a012bbd4bc662be8c0678759dd6a35e7b42204d (patch) | |
tree | 094d817206b81276dd77ff23132cd99686bd71e5 | |
parent | b8adf36cbf732da19dcd100ba89d1b01af6db694 (diff) |
Allow entering valid domains instead of URLs including protocol. Don't allow multi-line, replace enter button with OK button in keyboard layout
3 files changed, 12 insertions, 2 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/ProviderSelectionFragment.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/ProviderSelectionFragment.java index 0b0c5034..f15aaa43 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/ProviderSelectionFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/ProviderSelectionFragment.java @@ -107,7 +107,7 @@ public class ProviderSelectionFragment extends BaseSetupFragment implements Canc if (viewModel.isCustomProviderSelected()) { setupActivityCallback.onSetupStepValidationChanged(viewModel.isValidConfig()); if (viewModel.isValidConfig()) { - setupActivityCallback.onProviderSelected(new Provider(s.toString())); + setupActivityCallback.onProviderSelected(new Provider(viewModel.getCustomUrl())); } } } diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/viewmodel/ProviderSelectionViewModel.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/viewmodel/ProviderSelectionViewModel.java index 53d02b46..29dab98a 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/viewmodel/ProviderSelectionViewModel.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/viewmodel/ProviderSelectionViewModel.java @@ -48,7 +48,7 @@ public class ProviderSelectionViewModel extends ViewModel { public boolean isValidConfig() { if (selected == ADD_PROVIDER) { - return URLUtil.isValidUrl(customUrl) && Patterns.WEB_URL.matcher(customUrl).matches(); + return customUrl != null && (Patterns.DOMAIN_NAME.matcher(customUrl).matches() || (URLUtil.isNetworkUrl(customUrl) && Patterns.WEB_URL.matcher(customUrl).matches())); } return true; } @@ -82,6 +82,13 @@ public class ProviderSelectionViewModel extends ViewModel { customUrl = url; } + public String getCustomUrl() { + if (customUrl != null && Patterns.DOMAIN_NAME.matcher(customUrl).matches()) { + return "https://" + customUrl; + } + return customUrl; + } + public String getProviderName(int pos) { String domain = getProvider(pos).getDomain(); diff --git a/app/src/main/res/layout/f_provider_selection.xml b/app/src/main/res/layout/f_provider_selection.xml index 7c861a14..48d5bdd3 100644 --- a/app/src/main/res/layout/f_provider_selection.xml +++ b/app/src/main/res/layout/f_provider_selection.xml @@ -81,6 +81,9 @@ android:layout_height="wrap_content" android:background="@color/white" android:hint="https://example.org" + android:inputType="textWebEditText" + android:imeOptions="actionDone" + android:maxLines="1" android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textColorHint="@color/black800_transparent" /> |