Clean up several UX interactions with proxy entry.

This commit is contained in:
Greyson Parrelli
2021-02-03 13:45:40 -05:00
parent e798f3f276
commit 64fe78ff9a
8 changed files with 82 additions and 16 deletions

View File

@@ -213,7 +213,7 @@ public class CommunicationActions {
* Otherwise returns false, indicating was not a proxy link.
*/
public static boolean handlePotentialProxyLinkUrl(@NonNull FragmentActivity activity, @NonNull String potentialProxyLinkUrl) {
String proxy = SignalProxyUtil.parseHostFromProxyLink(potentialProxyLinkUrl);
String proxy = SignalProxyUtil.parseHostFromProxyDeepLink(potentialProxyLinkUrl);
if (proxy != null) {
ProxyBottomSheetFragment.showForProxy(activity.getSupportFragmentManager(), proxy);

View File

@@ -100,10 +100,10 @@ public final class SignalProxyUtil {
}
/**
* If this is a valid proxy link, this will return the embedded host. If not, it will return
* If this is a valid proxy deep link, this will return the embedded host. If not, it will return
* null.
*/
public static @Nullable String parseHostFromProxyLink(@NonNull String proxyLink) {
public static @Nullable String parseHostFromProxyDeepLink(@NonNull String proxyLink) {
try {
URI uri = new URI(proxyLink);
@@ -130,4 +130,24 @@ public final class SignalProxyUtil {
return null;
}
}
/**
* Takes in an address that could be in various formats, and converts it to the format we should
* be storing and connecting to.
*/
public static @NonNull String convertUserEnteredAddressToHost(@NonNull String host) {
String parsedHost = SignalProxyUtil.parseHostFromProxyDeepLink(host);
return parsedHost != null ? parsedHost : host;
}
public static @NonNull String generateProxyUrl(@NonNull String link) {
String host = link;
String parsed = parseHostFromProxyDeepLink(link);
if (parsed != null) {
host = parsed;
}
return "https://" + PROXY_LINK_HOST + "/#" + host;
}
}