use of com.ushahidi.java.sdk.net.UshahidiHttpClient in project Ushahidi_Android by ushahidi.
the class ApiUtils method updateDomain.
/**
* Check if an ushahidi deployment has changed it's HTTP protocol to HTTPS
* or not. Then update if it has.
*
* @param context
* - the calling activity.
*/
public static void updateDomain(Context context) {
UshahidiHttpClient client = new UshahidiHttpClient();
Preferences.loadSettings(context);
StringBuilder uriBuilder = new StringBuilder(Preferences.domain);
uriBuilder.append("/api?task=version");
uriBuilder.append("&resp=json");
try {
if (client != null) {
String jsonString = client.sendGetRequest(uriBuilder.toString());
UshahidiApiVersion ver = BaseTask.fromString(jsonString, UshahidiApiVersion.class);
String domain = ver.getDomain();
new Util().log(String.format("%s %s ", "Update domain", domain));
Preferences.domain = domain;
String ogsVer = client.sendGetRequest(Preferences.domain + "/opengeosms/version");
Preferences.ogsPluginVersion = ogsVer == null ? "" : trimVersion(ogsVer);
String sms = ver.getSms();
Preferences.phonenumber = sms != null ? sms : "";
// save changes
Preferences.saveSettings(context);
}
} catch (UshahidiException e) {
new Util().log(CLASS_TAG, e);
} catch (JsonSyntaxException e) {
e.getMessage();
}
}
Aggregations