pull/330/head
laoyuyu 7 years ago
parent f2e566ba7e
commit fbe3b137e1
  1. 4
      Aria/src/main/java/com/arialyy/aria/core/AriaManager.java
  2. 35
      Aria/src/main/java/com/arialyy/aria/core/delegate/ParamContainer.java
  3. 11
      Aria/src/main/java/com/arialyy/aria/core/download/BaseNormalTarget.java
  4. 12
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java
  5. 8
      Aria/src/main/java/com/arialyy/aria/core/download/FtpDirDownloadTarget.java
  6. 2
      Aria/src/main/java/com/arialyy/aria/core/inf/IFtpTarget.java
  7. 14
      Aria/src/main/java/com/arialyy/aria/core/upload/BaseNormalTarget.java
  8. 34
      Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java
  9. 1
      DEV_LOG.md
  10. 6
      app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java
  11. 24
      app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java
  12. 4
      app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java
  13. 2
      build.gradle

@ -111,7 +111,7 @@ import org.xml.sax.SAXException;
* <code> * <code>
* Aria.get(this).getUploadConfig().setQueueMod(mod.tag) * Aria.get(this).getUploadConfig().setQueueMod(mod.tag)
* </code> * </code>
* <pre/> * </pre>
* *
* @param mod {@link QueueMod} * @param mod {@link QueueMod}
* @deprecated 后续版本会删除该api * @deprecated 后续版本会删除该api
@ -128,7 +128,7 @@ import org.xml.sax.SAXException;
* <code> * <code>
* Aria.get(this).getDownloadConfig().setQueueMod(mod.tag) * Aria.get(this).getDownloadConfig().setQueueMod(mod.tag)
* </code> * </code>
* <pre/> * </pre>
* *
* @param mod {@link QueueMod} * @param mod {@link QueueMod}
* @deprecated 后续版本会删除该api * @deprecated 后续版本会删除该api

@ -0,0 +1,35 @@
/*
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.delegate;
import java.util.HashMap;
import java.util.Map;
/**
* Created by AriaL on 2018/3/17.
* 参数容器用来临时存储链式命令的需要的参数
*/
public class ParamContainer {
public String url;
public String filePath;
public String charSet;
public Map<String, String> header = new HashMap<>();
// ftp 相关的
public String userName, userPw, userAccount;
public boolean needLogin;
}

@ -147,7 +147,7 @@ abstract class BaseNormalTarget<TARGET extends BaseNormalTarget>
File file = new File(filePath); File file = new File(filePath);
if (file.isDirectory()) { if (file.isDirectory()) {
if (getTargetType() == HTTP) { if (getTargetType() == HTTP) {
ALog.e(TAG, "保存路径【" + filePath + "】不能为文件夹,路径需要是完整的文件路径,如:/mnt/sdcard/game.zip"); ALog.e(TAG, "下载失败,保存路径【" + filePath + "】不能为文件夹,路径需要是完整的文件路径,如:/mnt/sdcard/game.zip");
return false; return false;
} else if (getTargetType() == FTP) { } else if (getTargetType() == FTP) {
filePath += mEntity.getFileName(); filePath += mEntity.getFileName();
@ -157,7 +157,7 @@ abstract class BaseNormalTarget<TARGET extends BaseNormalTarget>
if (!filePath.equals(mEntity.getDownloadPath())) { if (!filePath.equals(mEntity.getDownloadPath())) {
if (!mTaskEntity.refreshInfo && DbEntity.checkDataExist(DownloadEntity.class, if (!mTaskEntity.refreshInfo && DbEntity.checkDataExist(DownloadEntity.class,
"downloadPath=?", filePath)) { "downloadPath=?", filePath)) {
ALog.e(TAG, "保存路径【" + filePath + "】已经被其它任务占用,请设置其它保存路径"); ALog.e(TAG, "下载失败,保存路径【" + filePath + "】已经被其它任务占用,请设置其它保存路径");
return false; return false;
} }
File oldFile = new File(mEntity.getDownloadPath()); File oldFile = new File(mEntity.getDownloadPath());
@ -192,13 +192,6 @@ abstract class BaseNormalTarget<TARGET extends BaseNormalTarget>
ALog.e(TAG, "下载失败,url【" + url + "】不合法"); ALog.e(TAG, "下载失败,url【" + url + "】不合法");
return false; return false;
} }
String temp = url.substring(index + 3, url.length());
if (temp.contains("//")) {
temp = url.substring(0, index + 3) + temp.replaceAll("//", "/");
ALog.w(TAG, "url中含有//,//将转换为/,转换后的url为:" + temp);
mEntity.setUrl(temp);
mEntity.update();
}
return true; return true;
} }
} }

@ -200,7 +200,6 @@ public class DownloadGroupTarget extends BaseGroupTarget<DownloadGroupTarget> {
} }
Set<Integer> delItem = new HashSet<>(); Set<Integer> delItem = new HashSet<>();
Map<Integer, String> reSetUrl = new WeakHashMap<>();
int i = 0; int i = 0;
for (String url : mUrls) { for (String url : mUrls) {
if (TextUtils.isEmpty(url)) { if (TextUtils.isEmpty(url)) {
@ -220,20 +219,9 @@ public class DownloadGroupTarget extends BaseGroupTarget<DownloadGroupTarget> {
continue; continue;
} }
String temp = url.substring(index + 3, url.length());
if (temp.contains("//")) {
temp = url.substring(0, index + 3) + temp.replaceAll("//", "/");
ALog.w(TAG, "url中含有//,//将转换为/,转换后的url为:" + temp);
reSetUrl.put(i, temp);
}
i++; i++;
} }
Set<Integer> keys = reSetUrl.keySet();
for (Integer index : keys) {
mUrls.set(index, reSetUrl.get(index));
}
for (int index : delItem) { for (int index : delItem) {
mUrls.remove(index); mUrls.remove(index);
if (mSubNameTemp != null && !mSubNameTemp.isEmpty()) { if (mSubNameTemp != null && !mSubNameTemp.isEmpty()) {

@ -77,14 +77,6 @@ public class FtpDirDownloadTarget extends BaseGroupTarget<FtpDirDownloadTarget>
ALog.e(TAG, "下载失败,url【" + url + "】不合法"); ALog.e(TAG, "下载失败,url【" + url + "】不合法");
return false; return false;
} }
String temp = url.substring(index + 3, url.length());
if (temp.contains("//")) {
temp = url.substring(0, index + 3) + temp.replaceAll("//", "/");
ALog.w(TAG, "url中含有//,//将转换为/,转换后的url为:" + temp);
mGroupName = temp;
mEntity.setGroupName(temp);
mEntity.update();
}
return true; return true;
} }

@ -26,7 +26,6 @@ public interface IFtpTarget<TARGET extends ITarget> {
/** /**
* ftp 用户登录信 * ftp 用户登录信
* 设置登录信息需要在设置上传链接之后{@link #setUploadUrl(String)}
* *
* @param userName ftp用户名 * @param userName ftp用户名
* @param password ftp用户密码 * @param password ftp用户密码
@ -35,7 +34,6 @@ public interface IFtpTarget<TARGET extends ITarget> {
/** /**
* ftp 用户登录信息 * ftp 用户登录信息
* 设置登录信息需要在设置上传链接之后{@link #setUploadUrl(String)}
* *
* @param userName ftp用户名 * @param userName ftp用户名
* @param password ftp用户密码 * @param password ftp用户密码

@ -98,13 +98,6 @@ abstract class BaseNormalTarget<TARGET extends AbsUploadTarget>
ALog.e(TAG, "上传失败,文件【" + filePath + "】不能死文件夹"); ALog.e(TAG, "上传失败,文件【" + filePath + "】不能死文件夹");
return false; return false;
} }
if (filePath.contains("//")) {
filePath = filePath.replaceAll("//", "/");
ALog.w(TAG, "url中含有//,//将转换为/,转换后的url为:" + filePath);
mEntity.setFilePath(filePath);
mEntity.update();
}
return true; return true;
} }
@ -127,13 +120,6 @@ abstract class BaseNormalTarget<TARGET extends AbsUploadTarget>
ALog.e(TAG, "上传失败,url【" + url + "】不合法"); ALog.e(TAG, "上传失败,url【" + url + "】不合法");
return false; return false;
} }
String temp = url.substring(index + 3, url.length());
if (temp.contains("//")) {
temp = url.substring(0, index + 3) + temp.replaceAll("//", "/");
ALog.w(TAG, "url中含有//,//将转换为/,转换后的url为:" + temp);
mEntity.setUrl(temp);
mEntity.update();
}
return true; return true;
} }
} }

@ -100,43 +100,9 @@ public class CheckUtil {
if (index == -1) { if (index == -1) {
throw new IllegalArgumentException("url不合法"); throw new IllegalArgumentException("url不合法");
} }
String temp = url.substring(index + 3, url.length());
if (temp.contains("//")) {
temp = url.substring(0, index + 3) + temp.replaceAll("//", "/");
ALog.w(TAG, "url中含有//,//将转换为/,转换后的url为:" + temp);
return temp;
}
return url; return url;
} }
///**
// * 检查普通任务的下载地址
// *
// * @return {@code true}地址合法
// */
//public static boolean checkUrl(DownloadEntity entity, String url) {
// if (TextUtils.isEmpty(url)) {
// ALog.e(TAG, "下载失败,url为null");
// return false;
// } else if (!url.startsWith("http") && !url.startsWith("ftp")) {
// ALog.e(TAG, "下载失败,url【" + url + "】错误");
// return false;
// }
// int index = url.indexOf("://");
// if (index == -1) {
// ALog.e(TAG, "下载失败,url【" + url + "】不合法");
// return false;
// }
// String temp = url.substring(index + 3, url.length());
// if (temp.contains("//")) {
// temp = url.substring(0, index + 3) + temp.replaceAll("//", "/");
// ALog.w(TAG, "url中含有//,//将转换为/,转换后的url为:" + temp);
// entity.setUrl(temp);
// entity.update();
// }
// return true;
//}
/** /**
* 检测下载链接组是否为null * 检测下载链接组是否为null
*/ */

@ -3,6 +3,7 @@
- 修复一个activity启动多次,无法进行回掉的bug https://github.com/AriaLyy/Aria/issues/200 - 修复一个activity启动多次,无法进行回掉的bug https://github.com/AriaLyy/Aria/issues/200
- 优化target代码结构,移除路径被占用的提示 - 优化target代码结构,移除路径被占用的提示
- 添加支持chunked模式的下载 - 添加支持chunked模式的下载
- 去掉上一个版本"//"的限制
+ v_3.3.14 + v_3.3.14
- 修复ftp上传和下载的兼容性问题 - 修复ftp上传和下载的兼容性问题
- 如果url中的path有"//"将替换为"/" - 如果url中的path有"//"将替换为"/"

@ -37,7 +37,7 @@ import java.io.File;
public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding> { public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding> {
//private final String URL = "ftp://192.168.1.9:21/下载/AriaPrj.zip"; //private final String URL = "ftp://192.168.1.9:21/下载/AriaPrj.zip";
//private final String URL = "ftp://182.92.180.213:21/video/572fed5c2ad48_1024.jpg"; //private final String URL = "ftp://182.92.180.213:21/video/572fed5c2ad48_1024.jpg";
private final String URL = "ftp://192.168.1.6:21/download/AriaPrj.zip"; private final String URL = "ftp://192.168.1.7:21/download//AriaPrj.zip";
//private final String URL = "ftp://d:d@dygodj8.com:12311/咖啡风暴HD大陆公映意语中字[飘花www.piaohua.com].mp4"; //private final String URL = "ftp://d:d@dygodj8.com:12311/咖啡风暴HD大陆公映意语中字[飘花www.piaohua.com].mp4";
@Override protected void init(Bundle savedInstanceState) { @Override protected void init(Bundle savedInstanceState) {
@ -59,10 +59,10 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { switch (view.getId()) {
case R.id.start: case R.id.start:
Aria.download(this).loadFtp(URL, true).charSet("gbk") Aria.download(this).loadFtp(URL, true)
//.login("sxf", "B34VdGsJ") //.login("sxf", "B34VdGsJ")
.login("lao", "123456") .login("lao", "123456")
.setDownloadPath("/mnt/sdcard/").start(); .setFilePath("/mnt/sdcard/").start();
break; break;
case R.id.stop: case R.id.stop:
Aria.download(this).loadFtp(URL).stop(); Aria.download(this).loadFtp(URL).stop();

@ -16,7 +16,6 @@
package com.arialyy.simple.download; package com.arialyy.simple.download;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.util.Log; import android.util.Log;
@ -40,8 +39,6 @@ import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseActivity; import com.arialyy.simple.base.BaseActivity;
import com.arialyy.simple.databinding.ActivitySingleBinding; import com.arialyy.simple.databinding.ActivitySingleBinding;
import java.io.File; import java.io.File;
import java.util.HashMap;
import java.util.Map;
public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
@ -49,22 +46,9 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
//"http://kotlinlang.org/docs/kotlin-docs.pdf"; //"http://kotlinlang.org/docs/kotlin-docs.pdf";
//"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe"; //"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe";
//"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk"; //"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
//"http://sitcac.daxincf.cn/wp-content/uploads/swift_vido/01/element.mp4_1"; //不支持断点的链接
//"http://120.25.196.56:8000/filereq?id=15692406294&ipncid=105635&client=android&filename=20170819185541.avi"; "http://58.210.9.131/tpk/sipgt//TDLYZTGH.tpk"; //chunked 下载
//"http://down2.xiaoshuofuwuqi.com/d/file/filetxt/20170608/14/%BA%DA%CE%D7%CA%A6%E1%C8%C6%F0.txt"; //"https://static.donguo.me//video/ip/course/pfys_1.mp4";
//"http://tinghuaapp.oss-cn-shanghai.aliyuncs.com/20170612201739607815";
//"http://static.gaoshouyou.com/d/36/69/2d3699acfa69e9632262442c46516ad8.apk";
//"http://oqcpqqvuf.bkt.clouddn.com/ceshi.txt";
//"http://down8.androidgame-store.com/201706122321/97967927DD4E53D9905ECAA7874C8128/new/game1/19/45319/com.neuralprisma-2.5.2.174-2000174_1494784835.apk?f=web_1";
//不支持断点的链接
//"http://ox.konsung.net:5555/ksdc-web/download/downloadFile/?fileName=ksdc_1.0.2.apk&rRange=0-";
//"http://gdown.baidu.com/data/wisegame/0904344dee4a2d92/QQ_718.apk";
//"http://qudao.5535.cn/one/game.html?game=531&cpsuser=xiaoeryu2";
//"https://bogoe-res.mytbz.com/tbzengsong/If You're Happy.mp3";
//"http://ozr0ucjs5.bkt.clouddn.com/51_box-104_20180131202610.apk";
//"http://kf.lyfz.net/api/v1/we_chat/Business/getMaterial?company_id=51454009d703c86c91353f61011ecf2f&appid=wx88c6052d06eaaf7d&media_id=qpkQb72KqNkZhBNIUw7asF0LuJouXCTBd3A-rS2bYl7H4kvTZstEXD3F-pDVeqA-&type=3";
//"https://www.baidu.com/link?url=_LFCuTPtnzFxVJByJ504QymRywIA1Z_T5xUxe9ZLuxcGM0C_RcdpWyB1eGjbJC-e5wv5wAKM4WmLMAS5KeF6EZJHB8Va3YqZUiaErqK_pxm&wd=&eqid=e8583fe70002d126000000065a99f864";
"http://58.210.9.131/tpk/sipgt/TDLYZTGH.tpk";
@Bind(R.id.start) Button mStart; @Bind(R.id.start) Button mStart;
@Bind(R.id.stop) Button mStop; @Bind(R.id.stop) Button mStop;
@Bind(R.id.cancel) Button mCancel; @Bind(R.id.cancel) Button mCancel;
@ -234,7 +218,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
//.addHeader("Cookie", "BAIDUID=648E5FF020CC69E8DD6F492D1068AAA9:FG=1; BIDUPSID=648E5FF020CC69E8DD6F492D1068AAA9; PSTM=1519099573; BD_UPN=12314753; locale=zh; BDSVRTM=0") //.addHeader("Cookie", "BAIDUID=648E5FF020CC69E8DD6F492D1068AAA9:FG=1; BIDUPSID=648E5FF020CC69E8DD6F492D1068AAA9; PSTM=1519099573; BD_UPN=12314753; locale=zh; BDSVRTM=0")
.setRequestMode(RequestEnum.GET) .setRequestMode(RequestEnum.GET)
.setFilePath(Environment.getExternalStorageDirectory().getPath() + "/ggsg1.apk") .setFilePath(Environment.getExternalStorageDirectory().getPath() + "/ggsg1.apk")
.resetState() //.resetState()
.start(); .start();
//.add(); //.add();
} }

@ -35,8 +35,8 @@ import java.io.File;
* Ftp 文件上传demo * Ftp 文件上传demo
*/ */
public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> { public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> {
private final String FILE_PATH = "/mnt/sdcard/AriaPrj.zip"; private final String FILE_PATH = "/mnt/sdcard/sql.rar";
private final String URL = "ftp://192.168.1.6:21/aa/你好"; private final String URL = "ftp://192.168.1.7:21/aa//你好";
@Override protected void init(Bundle savedInstanceState) { @Override protected void init(Bundle savedInstanceState) {
setTile("D_FTP 文件上传"); setTile("D_FTP 文件上传");

@ -39,7 +39,7 @@ task clean(type: Delete) {
ext { ext {
userOrg = 'arialyy' userOrg = 'arialyy'
groupId = 'com.arialyy.aria' groupId = 'com.arialyy.aria'
publishVersion = '3.3.16_dev' publishVersion = '3.3.16_dev2'
// publishVersion = '1.0.3' //FTP插件 // publishVersion = '1.0.3' //FTP插件
repoName='maven' repoName='maven'
desc = 'android 下载框架' desc = 'android 下载框架'

Loading…
Cancel
Save