diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 54c214f0c..212678a98 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -5,6 +5,7 @@
android:versionName="1.0">
+
+
+
+
diff --git a/docs/README.md b/docs/README.md
index cfc11aed5..74d515a7b 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -2,6 +2,9 @@
title: Android SDK 使用指南
---
+- Android SDK 下载地址:
+- Android SDK 源码地址: (请注意非 master 分支的代码在规格上可能承受变更)
+
此 Android SDK 基于 [七牛云存储官方API](http://docs.qiniu.com/api/index.html) 构建。在开发者的 Android App 工程项目中使用此 SDK 能够非常方便地将 Android 系统里边的文件快速直传到七牛云存储。
出于安全考虑,使用此 SDK 无需设置密钥(AccessKey / SecretKey)。所有涉及到授权的操作,比如生成上传授权凭证(uploadToken)或下载授权凭证(downloadToken)均在业务服务器端进行。
diff --git a/res/layout/main.xml b/res/layout/main.xml
index a1d7c5285..2daa79f41 100644
--- a/res/layout/main.xml
+++ b/res/layout/main.xml
@@ -27,5 +27,11 @@
android:id="@+id/textView1"
android:layout_marginBottom="20dp"
android:layout_centerHorizontal="true" android:layout_above="@+id/button1"/>
+
diff --git a/res/layout/resumable.xml b/res/layout/resumable.xml
new file mode 100644
index 000000000..f60ea3fde
--- /dev/null
+++ b/res/layout/resumable.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5df244b39..2d9875256 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,4 +1,5 @@
android-sdk
+ android-sdk-resumable
diff --git a/src/com/qiniu/auth/CallRet.java b/src/com/qiniu/auth/CallRet.java
index b2a061e0c..3238920bb 100644
--- a/src/com/qiniu/auth/CallRet.java
+++ b/src/com/qiniu/auth/CallRet.java
@@ -1,7 +1,11 @@
package com.qiniu.auth;
-public abstract class CallRet {
+import com.qiniu.utils.IOnProcess;
+
+public abstract class CallRet implements IOnProcess {
+ public void onInit(int flag){}
public abstract void onSuccess(byte[] body);
public abstract void onFailure(Exception ex);
- public void onSuccess(){}
-}
\ No newline at end of file
+ public void onProcess(long current, long total){}
+ public void onPause(Object tag){}
+}
diff --git a/src/com/qiniu/auth/Client.java b/src/com/qiniu/auth/Client.java
index 330399e3a..03917eada 100644
--- a/src/com/qiniu/auth/Client.java
+++ b/src/com/qiniu/auth/Client.java
@@ -2,10 +2,15 @@
import android.os.AsyncTask;
import com.qiniu.conf.Conf;
+import com.qiniu.utils.ICancel;
+import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
@@ -19,86 +24,106 @@
import java.io.IOException;
public class Client {
-
+
protected HttpClient mClient;
-
+
public Client(HttpClient client) {
mClient = client;
}
- public void call(String url, CallRet ret) {
- HttpPost httppost = new HttpPost(url);
- execute(httppost, ret);
+ public static ClientExecutor get(String url, CallRet ret) {
+ Client client = Client.defaultClient();
+ return client.get(client.makeClientExecutor(), url, ret);
}
- public void call(String url, HttpEntity entity, CallRet ret) {
- call(url, entity.getContentType().getValue(), entity, ret);
+ public ClientExecutor call(ClientExecutor client, String url, HttpEntity entity, CallRet ret) {
+ Header header = entity.getContentType();
+ String contentType = "application/octet-stream";
+ if (header != null) {
+ contentType = header.getValue();
+ }
+ return call(client, url, contentType, entity, ret);
}
- public void call(String url, String contentType, HttpEntity entity, CallRet ret) {
+ public ClientExecutor call(ClientExecutor client, String url, String contentType, HttpEntity entity, CallRet ret) {
HttpPost httppost = new HttpPost(url);
httppost.setEntity(entity);
if (contentType != null) {
httppost.setHeader("Content-Type", contentType);
}
- execute(httppost, ret);
+ return execute(client, httppost, ret);
+ }
+
+ public ClientExecutor get(ClientExecutor client, String url, CallRet ret) {
+ return execute(client, new HttpGet(url), ret);
}
- protected void execute(HttpPost httpPost, CallRet ret) {
- new ClientExecuter().execute(httpPost, ret);
+ public ClientExecutor makeClientExecutor() {
+ return new ClientExecutor();
}
- protected HttpResponse roundtrip(HttpPost httpPost) throws IOException {
- httpPost.setHeader("User-Agent", Conf.USER_AGENT);
- return mClient.execute(httpPost);
+ protected ClientExecutor execute(ClientExecutor client, HttpRequestBase httpRequest, final CallRet ret) {
+ client.setup(httpRequest, ret);
+ client.execute();
+ return client;
+ }
+
+ protected HttpResponse roundtrip(HttpRequestBase httpRequest) throws IOException {
+ httpRequest.setHeader("User-Agent", Conf.USER_AGENT);
+ return mClient.execute(httpRequest);
}
- class ClientExecuter extends AsyncTask