Fix node info
This commit is contained in:
parent
49ee6f59c0
commit
2d03983b21
|
@ -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")
|
||||
private void showRadioButtonDialogFullInstances() {
|
||||
|
@ -143,6 +151,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
editor.commit();
|
||||
runOnUiThread(() -> {
|
||||
dialog.dismiss();
|
||||
main_webview.clearHistory();
|
||||
main_webview.loadUrl("https://"+instance);
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -14,6 +14,6 @@ interface MobilizonService {
|
|||
Call<WellKnownNodeinfo> getWellKnownNodeinfo();
|
||||
|
||||
@GET("{nodeInfoPath}")
|
||||
Call<WellKnownNodeinfo.NodeInfo> getNodeinfo(@Path("nodeInfoPath") String nodeInfoPath);
|
||||
Call<WellKnownNodeinfo.NodeInfo> getNodeinfo(@Path(value = "nodeInfoPath", encoded = true) String nodeInfoPath);
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ package app.fedilab.mobilizon.client;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
import android.content.Context;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -34,16 +33,18 @@ public class RetrofitMobilizonAPI {
|
|||
private String instance;
|
||||
|
||||
|
||||
|
||||
public RetrofitMobilizonAPI(Context context) {
|
||||
_context = context;
|
||||
instance = Helper.getLiveInstance(context);
|
||||
finalUrl = "https://" + Helper.getLiveInstance(context) + "/api/v1/";
|
||||
}
|
||||
|
||||
|
||||
public RetrofitMobilizonAPI(Context context, String instance) {
|
||||
_context = context;
|
||||
this.instance = instance;
|
||||
finalUrl = "https://" + instance + "/api/v1/";
|
||||
finalUrl = "https://" + instance.toLowerCase() + "/";
|
||||
}
|
||||
|
||||
private MobilizonService init() {
|
||||
|
@ -55,13 +56,13 @@ public class RetrofitMobilizonAPI {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get NodeInfo
|
||||
*
|
||||
* @return APIResponse
|
||||
*/
|
||||
public WellKnownNodeinfo.NodeInfo getNodeInfo() {
|
||||
finalUrl = "https://" + instance+"/";
|
||||
MobilizonService mobilizonService = init();
|
||||
try {
|
||||
Call<WellKnownNodeinfo> wellKnownNodeinfoCall = mobilizonService.getWellKnownNodeinfo();
|
||||
|
@ -70,8 +71,9 @@ public class RetrofitMobilizonAPI {
|
|||
int size = response.body().getLinks().size();
|
||||
String url = response.body().getLinks().get(size-1).getHref();
|
||||
if (size > 0 && url != null) {
|
||||
mobilizonService = init();
|
||||
String path = new URL(url).getPath();
|
||||
path = path.replaceFirst("/", "");
|
||||
path = path.replaceFirst("/", "").trim();
|
||||
Call<WellKnownNodeinfo.NodeInfo> nodeinfo = mobilizonService.getNodeinfo(path);
|
||||
Response<WellKnownNodeinfo.NodeInfo> responseNodeInfo = nodeinfo.execute();
|
||||
return responseNodeInfo.body();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#474467</color>
|
||||
<color name="colorPrimaryDark">#1e7d97</color>
|
||||
<color name="colorAccent">#ffd599</color>
|
||||
<color name="colorPrimaryDark">#ffd599</color>
|
||||
<color name="colorAccent">#1e7d97</color>
|
||||
</resources>
|
Loading…
Reference in New Issue