|
|
@ -22,9 +22,12 @@ import org.json.JSONArray;
|
|
|
|
import org.json.JSONException;
|
|
|
|
import org.json.JSONException;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.pm.PackageInfo;
|
|
|
|
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
|
|
import com.timsu.astrid.R;
|
|
|
|
import com.timsu.astrid.R;
|
|
|
|
|
|
|
|
import com.todoroo.aacenc.ContextManager;
|
|
|
|
import com.todoroo.andlib.service.Autowired;
|
|
|
|
import com.todoroo.andlib.service.Autowired;
|
|
|
|
import com.todoroo.andlib.service.DependencyInjectionService;
|
|
|
|
import com.todoroo.andlib.service.DependencyInjectionService;
|
|
|
|
import com.todoroo.andlib.service.RestClient;
|
|
|
|
import com.todoroo.andlib.service.RestClient;
|
|
|
@ -183,6 +186,23 @@ public class ActFmInvoker {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String clientVersion = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getClientVersion() {
|
|
|
|
|
|
|
|
if (clientVersion == null) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
PackageManager pm = ContextManager.getContext().getPackageManager();
|
|
|
|
|
|
|
|
PackageInfo pi = pm.getPackageInfo(Constants.PACKAGE, PackageManager.GET_META_DATA);
|
|
|
|
|
|
|
|
int version = pi.versionCode;
|
|
|
|
|
|
|
|
String versionName = pi.versionName;
|
|
|
|
|
|
|
|
clientVersion = "android-" + versionName + "-" + version;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return clientVersion;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public JSONObject postSync(JSONArray data, MultipartEntity entity, String token) throws IOException,
|
|
|
|
public JSONObject postSync(JSONArray data, MultipartEntity entity, String token) throws IOException,
|
|
|
|
ActFmServiceException {
|
|
|
|
ActFmServiceException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -196,6 +216,10 @@ public class ActFmInvoker {
|
|
|
|
entity.addPart("data", new StringBody(data.toString()));
|
|
|
|
entity.addPart("data", new StringBody(data.toString()));
|
|
|
|
entity.addPart("time", new StringBody(timeString));
|
|
|
|
entity.addPart("time", new StringBody(timeString));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String version = getClientVersion();
|
|
|
|
|
|
|
|
if (version != null)
|
|
|
|
|
|
|
|
entity.addPart("client_version", new StringBody(version));
|
|
|
|
|
|
|
|
|
|
|
|
String response = restClient.post(request, entity);
|
|
|
|
String response = restClient.post(request, entity);
|
|
|
|
JSONObject object = new JSONObject(response);
|
|
|
|
JSONObject object = new JSONObject(response);
|
|
|
|
|
|
|
|
|
|
|
|