This commit is contained in:
Thomas 2020-12-12 14:58:28 +01:00
parent 88b5a83fb1
commit dedf7b0163
1 changed files with 8 additions and 1 deletions

View File

@ -54,6 +54,7 @@ import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
@ -133,6 +134,12 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
(dialog, which) -> new Thread(() -> {
try {
String newInstance = input.getText().toString().trim();
if (!newInstance.startsWith("http")) {
newInstance = "http://" + newInstance;
}
URL url = new URL(newInstance);
newInstance = url.getHost();
WellKnownNodeinfo.NodeInfo instanceNodeInfo = new RetrofitPeertubeAPI(activity, newInstance, null).getNodeInfo();
if (instanceNodeInfo.getSoftware() != null && instanceNodeInfo.getSoftware().getName().trim().toLowerCase().compareTo("peertube") == 0) {
SharedPreferences.Editor editor = sharedpreferences.edit();
@ -906,7 +913,7 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.PREF_INSTANCE, String.valueOf(data.getData()));
editor.commit();
finish();
recreate();
}
}
}