diff options
| author | cyBerta <cyberta@riseup.net> | 2024-10-26 01:54:45 +0200 |
|---|---|---|
| committer | cyberta <cyberta@riseup.net> | 2024-12-11 00:09:34 +0000 |
| commit | c0da385377c22f445bef0b70aa8da52e1fda1037 (patch) | |
| tree | 1ccb9734d5bb54cdf5477c3b8fc6e18416a15f15 /app/src/main/java/se/leap/bitmaskclient/providersetup | |
| parent | 980b0038ac33ea650450fe70025f2a72402307c3 (diff) | |
Improve setting valid URL as main URL string. Fixes parceling exception of Provider objects
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/providersetup')
| -rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/viewmodel/ProviderSelectionViewModel.java | 8 |
1 files changed, 5 insertions, 3 deletions
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 00117336..5f9a0f3d 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 @@ -1,11 +1,13 @@ package se.leap.bitmaskclient.providersetup.fragments.viewmodel; +import static se.leap.bitmaskclient.base.utils.ConfigHelper.isDomainName; +import static se.leap.bitmaskclient.base.utils.ConfigHelper.isNetworkUrl; + import android.content.Context; import android.content.res.AssetManager; import android.text.InputType; import android.util.Patterns; import android.view.View; -import android.webkit.URLUtil; import androidx.lifecycle.ViewModel; @@ -51,7 +53,7 @@ public class ProviderSelectionViewModel extends ViewModel { public boolean isValidConfig() { if (selected == ADD_PROVIDER) { - return customUrl != null && (Patterns.DOMAIN_NAME.matcher(customUrl).matches() || (URLUtil.isNetworkUrl(customUrl) && Patterns.WEB_URL.matcher(customUrl).matches())); + return isNetworkUrl(customUrl) || isDomainName(customUrl); } if (selected == INVITE_CODE_PROVIDER) { try { @@ -121,7 +123,7 @@ public class ProviderSelectionViewModel extends ViewModel { } public String getCustomUrl() { - if (customUrl != null && Patterns.DOMAIN_NAME.matcher(customUrl).matches()) { + if (isDomainName(customUrl)) { return "https://" + customUrl; } return customUrl; |
