mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 18:30:20 +01:00
Clean up several UX interactions with proxy entry.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user