|
|
|
@ -24,23 +24,6 @@ import android.os.Bundle;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.HttpResponse;
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.client.ClientProtocolException;
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.client.CookieStore;
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.client.config.RequestConfig;
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.client.methods.HttpGet;
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.client.methods.HttpPost;
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.client.protocol.HttpClientContext;
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.cookie.Cookie;
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.impl.client.BasicCookieStore;
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.impl.client.CloseableHttpClient;
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.impl.client.DefaultHttpClient;
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.impl.client.HttpClients;
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.message.BasicNameValuePair;
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.params.BasicHttpParams;
|
|
|
|
|
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.http.params.HttpProtocolParams;
|
|
|
|
|
|
|
|
|
|
import net.micode.notes.gtask.data.Node;
|
|
|
|
|
import net.micode.notes.gtask.data.Task;
|
|
|
|
|
import net.micode.notes.gtask.data.TaskList;
|
|
|
|
@ -49,8 +32,20 @@ import net.micode.notes.gtask.exception.NetworkFailureException;
|
|
|
|
|
import net.micode.notes.tool.GTaskStringUtils;
|
|
|
|
|
import net.micode.notes.ui.NotesPreferenceActivity;
|
|
|
|
|
|
|
|
|
|
import org.apache.http.params.HttpConnectionParams;
|
|
|
|
|
import org.apache.http.params.HttpParams;
|
|
|
|
|
import org.apache.hc.client5.http.ClientProtocolException;
|
|
|
|
|
import org.apache.hc.client5.http.classic.methods.HttpGet;
|
|
|
|
|
import org.apache.hc.client5.http.classic.methods.HttpPost;
|
|
|
|
|
import org.apache.hc.client5.http.config.RequestConfig;
|
|
|
|
|
import org.apache.hc.client5.http.cookie.BasicCookieStore;
|
|
|
|
|
import org.apache.hc.client5.http.cookie.Cookie;
|
|
|
|
|
import org.apache.hc.client5.http.cookie.CookieStore;
|
|
|
|
|
import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
|
|
|
|
|
import org.apache.hc.client5.http.impl.classic.BasicHttpClientResponseHandler;
|
|
|
|
|
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
|
|
|
|
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
|
|
|
|
import org.apache.hc.client5.http.protocol.HttpClientContext;
|
|
|
|
|
import org.apache.hc.core5.http.message.BasicNameValuePair;
|
|
|
|
|
import org.apache.hc.core5.util.Timeout;
|
|
|
|
|
import org.json.JSONArray;
|
|
|
|
|
import org.json.JSONException;
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
@ -238,6 +233,7 @@ public class GTaskClient {
|
|
|
|
|
.setResponseTimeout(Timeout.ofMilliseconds(timeoutResponse))
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// login gtask
|
|
|
|
|
try {
|
|
|
|
|
String loginUrl = mGetUrl + "?auth=" + authToken;
|
|
|
|
@ -246,8 +242,9 @@ public class GTaskClient {
|
|
|
|
|
httpGet.setConfig(requestConfig);
|
|
|
|
|
// 创建Cookie存储器
|
|
|
|
|
CookieStore cookieStore=new BasicCookieStore();
|
|
|
|
|
HttpClientContext httpClientContext= HttpClientContext.create();
|
|
|
|
|
HttpClientContext httpClientContext=HttpClientContext.create();
|
|
|
|
|
httpClientContext.setCookieStore(cookieStore);
|
|
|
|
|
String resString = mHttpClient.execute(httpGet, httpClientContext,new BasicHttpClientResponseHandler());
|
|
|
|
|
|
|
|
|
|
// get the cookie now
|
|
|
|
|
List<Cookie> cookies = cookieStore.getCookies();
|
|
|
|
@ -262,7 +259,6 @@ public class GTaskClient {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get the client version
|
|
|
|
|
String resString = getResponseContent(response.getEntity());
|
|
|
|
|
String jsBegin = "_setup(";
|
|
|
|
|
String jsEnd = ")}</script>";
|
|
|
|
|
int begin = resString.indexOf(jsBegin);
|
|
|
|
@ -312,9 +308,7 @@ public class GTaskClient {
|
|
|
|
|
httpPost.setEntity(entity);
|
|
|
|
|
|
|
|
|
|
// execute the post
|
|
|
|
|
// String jsString = mHttpClient.execute(httpPost,new BasicHttpClientResponseHandler());
|
|
|
|
|
HttpResponse response = mHttpClient.execute(httpPost);
|
|
|
|
|
String jsString = getResponseContent(response.getEntity());
|
|
|
|
|
String jsString = mHttpClient.execute(httpPost,new BasicHttpClientResponseHandler());
|
|
|
|
|
return new JSONObject(jsString);
|
|
|
|
|
|
|
|
|
|
} catch (ClientProtocolException e) {
|
|
|
|
@ -495,8 +489,7 @@ public class GTaskClient {
|
|
|
|
|
HttpGet httpGet = new HttpGet(mGetUrl);
|
|
|
|
|
|
|
|
|
|
// get the task list
|
|
|
|
|
// String resString = mHttpClient.execute(httpGet,new BasicHttpClientResponseHandler());
|
|
|
|
|
String resString = getResponseContent(response.getEntity());
|
|
|
|
|
String resString = mHttpClient.execute(httpGet,new BasicHttpClientResponseHandler());
|
|
|
|
|
String jsBegin = "_setup(";
|
|
|
|
|
String jsEnd = ")}</script>";
|
|
|
|
|
int begin = resString.indexOf(jsBegin);
|
|
|
|
|