Fix node info

This commit is contained in:
Thomas 2020-09-30 11:14:05 +02:00
parent 49ee6f59c0
commit 2d03983b21
4 changed files with 18 additions and 7 deletions

View File

@ -118,6 +118,14 @@ public class MainActivity extends AppCompatActivity {
} }
} }
@Override
public void onBackPressed() {
if( main_webview.canGoBack()){
main_webview.goBack();
} else {
super.onBackPressed();
}
}
@SuppressLint("ApplySharedPref") @SuppressLint("ApplySharedPref")
private void showRadioButtonDialogFullInstances() { private void showRadioButtonDialogFullInstances() {
@ -143,6 +151,7 @@ public class MainActivity extends AppCompatActivity {
editor.commit(); editor.commit();
runOnUiThread(() -> { runOnUiThread(() -> {
dialog.dismiss(); dialog.dismiss();
main_webview.clearHistory();
main_webview.loadUrl("https://"+instance); main_webview.loadUrl("https://"+instance);
}); });
} else { } else {

View File

@ -14,6 +14,6 @@ interface MobilizonService {
Call<WellKnownNodeinfo> getWellKnownNodeinfo(); Call<WellKnownNodeinfo> getWellKnownNodeinfo();
@GET("{nodeInfoPath}") @GET("{nodeInfoPath}")
Call<WellKnownNodeinfo.NodeInfo> getNodeinfo(@Path("nodeInfoPath") String nodeInfoPath); Call<WellKnownNodeinfo.NodeInfo> getNodeinfo(@Path(value = "nodeInfoPath", encoded = true) String nodeInfoPath);
} }

View File

@ -15,7 +15,6 @@ package app.fedilab.mobilizon.client;
* see <http://www.gnu.org/licenses>. */ * see <http://www.gnu.org/licenses>. */
import android.content.Context; import android.content.Context;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
@ -34,16 +33,18 @@ public class RetrofitMobilizonAPI {
private String instance; private String instance;
public RetrofitMobilizonAPI(Context context) { public RetrofitMobilizonAPI(Context context) {
_context = context; _context = context;
instance = Helper.getLiveInstance(context); instance = Helper.getLiveInstance(context);
finalUrl = "https://" + Helper.getLiveInstance(context) + "/api/v1/"; finalUrl = "https://" + Helper.getLiveInstance(context) + "/api/v1/";
} }
public RetrofitMobilizonAPI(Context context, String instance) { public RetrofitMobilizonAPI(Context context, String instance) {
_context = context; _context = context;
this.instance = instance; this.instance = instance;
finalUrl = "https://" + instance + "/api/v1/"; finalUrl = "https://" + instance.toLowerCase() + "/";
} }
private MobilizonService init() { private MobilizonService init() {
@ -55,13 +56,13 @@ public class RetrofitMobilizonAPI {
} }
/** /**
* Get NodeInfo * Get NodeInfo
* *
* @return APIResponse * @return APIResponse
*/ */
public WellKnownNodeinfo.NodeInfo getNodeInfo() { public WellKnownNodeinfo.NodeInfo getNodeInfo() {
finalUrl = "https://" + instance+"/";
MobilizonService mobilizonService = init(); MobilizonService mobilizonService = init();
try { try {
Call<WellKnownNodeinfo> wellKnownNodeinfoCall = mobilizonService.getWellKnownNodeinfo(); Call<WellKnownNodeinfo> wellKnownNodeinfoCall = mobilizonService.getWellKnownNodeinfo();
@ -70,8 +71,9 @@ public class RetrofitMobilizonAPI {
int size = response.body().getLinks().size(); int size = response.body().getLinks().size();
String url = response.body().getLinks().get(size-1).getHref(); String url = response.body().getLinks().get(size-1).getHref();
if (size > 0 && url != null) { if (size > 0 && url != null) {
mobilizonService = init();
String path = new URL(url).getPath(); String path = new URL(url).getPath();
path = path.replaceFirst("/", ""); path = path.replaceFirst("/", "").trim();
Call<WellKnownNodeinfo.NodeInfo> nodeinfo = mobilizonService.getNodeinfo(path); Call<WellKnownNodeinfo.NodeInfo> nodeinfo = mobilizonService.getNodeinfo(path);
Response<WellKnownNodeinfo.NodeInfo> responseNodeInfo = nodeinfo.execute(); Response<WellKnownNodeinfo.NodeInfo> responseNodeInfo = nodeinfo.execute();
return responseNodeInfo.body(); return responseNodeInfo.body();

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="colorPrimary">#474467</color> <color name="colorPrimary">#474467</color>
<color name="colorPrimaryDark">#1e7d97</color> <color name="colorPrimaryDark">#ffd599</color>
<color name="colorAccent">#ffd599</color> <color name="colorAccent">#1e7d97</color>
</resources> </resources>