diff --git a/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java b/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java index 068ccdc6..c7c5968a 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java +++ b/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java @@ -111,7 +111,7 @@ import org.xml.sax.SAXException; * * Aria.get(this).getUploadConfig().setQueueMod(mod.tag) * - *
+   * 
* * @param mod {@link QueueMod} * @deprecated 后续版本会删除该api @@ -128,7 +128,7 @@ import org.xml.sax.SAXException; * * Aria.get(this).getDownloadConfig().setQueueMod(mod.tag) * - *
+   * 
* * @param mod {@link QueueMod} * @deprecated 后续版本会删除该api diff --git a/Aria/src/main/java/com/arialyy/aria/core/delegate/ParamContainer.java b/Aria/src/main/java/com/arialyy/aria/core/delegate/ParamContainer.java new file mode 100644 index 00000000..a9cbca87 --- /dev/null +++ b/Aria/src/main/java/com/arialyy/aria/core/delegate/ParamContainer.java @@ -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 header = new HashMap<>(); + + // ftp 相关的 + public String userName, userPw, userAccount; + public boolean needLogin; +} diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/BaseNormalTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/BaseNormalTarget.java index d2daf220..af02d37b 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/BaseNormalTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/BaseNormalTarget.java @@ -147,7 +147,7 @@ abstract class BaseNormalTarget File file = new File(filePath); if (file.isDirectory()) { if (getTargetType() == HTTP) { - ALog.e(TAG, "保存路径【" + filePath + "】不能为文件夹,路径需要是完整的文件路径,如:/mnt/sdcard/game.zip"); + ALog.e(TAG, "下载失败,保存路径【" + filePath + "】不能为文件夹,路径需要是完整的文件路径,如:/mnt/sdcard/game.zip"); return false; } else if (getTargetType() == FTP) { filePath += mEntity.getFileName(); @@ -157,7 +157,7 @@ abstract class BaseNormalTarget if (!filePath.equals(mEntity.getDownloadPath())) { if (!mTaskEntity.refreshInfo && DbEntity.checkDataExist(DownloadEntity.class, "downloadPath=?", filePath)) { - ALog.e(TAG, "保存路径【" + filePath + "】已经被其它任务占用,请设置其它保存路径"); + ALog.e(TAG, "下载失败,保存路径【" + filePath + "】已经被其它任务占用,请设置其它保存路径"); return false; } File oldFile = new File(mEntity.getDownloadPath()); @@ -192,13 +192,6 @@ abstract class BaseNormalTarget 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); - mEntity.setUrl(temp); - mEntity.update(); - } return true; } } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java index 6dc2d36f..07ef9efb 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java @@ -200,7 +200,6 @@ public class DownloadGroupTarget extends BaseGroupTarget { } Set delItem = new HashSet<>(); - Map reSetUrl = new WeakHashMap<>(); int i = 0; for (String url : mUrls) { if (TextUtils.isEmpty(url)) { @@ -220,20 +219,9 @@ public class DownloadGroupTarget extends BaseGroupTarget { 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++; } - Set keys = reSetUrl.keySet(); - for (Integer index : keys) { - mUrls.set(index, reSetUrl.get(index)); - } - for (int index : delItem) { mUrls.remove(index); if (mSubNameTemp != null && !mSubNameTemp.isEmpty()) { diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/FtpDirDownloadTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/FtpDirDownloadTarget.java index 04b09e5c..b71c8b35 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/FtpDirDownloadTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/FtpDirDownloadTarget.java @@ -77,14 +77,6 @@ public class FtpDirDownloadTarget extends BaseGroupTarget 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); - mGroupName = temp; - mEntity.setGroupName(temp); - mEntity.update(); - } return true; } diff --git a/Aria/src/main/java/com/arialyy/aria/core/inf/IFtpTarget.java b/Aria/src/main/java/com/arialyy/aria/core/inf/IFtpTarget.java index 5f5a68fd..519b4393 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/inf/IFtpTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/inf/IFtpTarget.java @@ -26,7 +26,6 @@ public interface IFtpTarget { /** * ftp 用户登录信。 - * 设置登录信息需要在设置上传链接之后{@link #setUploadUrl(String)} * * @param userName ftp用户名 * @param password ftp用户密码 @@ -35,7 +34,6 @@ public interface IFtpTarget { /** * ftp 用户登录信息 - * 设置登录信息需要在设置上传链接之后{@link #setUploadUrl(String)} * * @param userName ftp用户名 * @param password ftp用户密码 diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/BaseNormalTarget.java b/Aria/src/main/java/com/arialyy/aria/core/upload/BaseNormalTarget.java index 9a2a31b4..a7014c98 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/BaseNormalTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/BaseNormalTarget.java @@ -98,13 +98,6 @@ abstract class BaseNormalTarget ALog.e(TAG, "上传失败,文件【" + filePath + "】不能死文件夹"); return false; } - - if (filePath.contains("//")) { - filePath = filePath.replaceAll("//", "/"); - ALog.w(TAG, "url中含有//,//将转换为/,转换后的url为:" + filePath); - mEntity.setFilePath(filePath); - mEntity.update(); - } return true; } @@ -127,13 +120,6 @@ abstract class BaseNormalTarget 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); - mEntity.setUrl(temp); - mEntity.update(); - } return true; } } diff --git a/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java b/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java index 1f67935c..65cd9b53 100644 --- a/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java @@ -100,43 +100,9 @@ public class CheckUtil { if (index == -1) { 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 {@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 */ diff --git a/DEV_LOG.md b/DEV_LOG.md index a35dc6c3..8b93501f 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -3,6 +3,7 @@ - 修复一个activity启动多次,无法进行回掉的bug https://github.com/AriaLyy/Aria/issues/200 - 优化target代码结构,移除路径被占用的提示 - 添加支持chunked模式的下载 + - 去掉上一个版本"//"的限制 + v_3.3.14 - 修复ftp上传和下载的兼容性问题 - 如果url中的path有"//"将替换为"/" diff --git a/app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java b/app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java index 9fc20cc0..0e6e7b32 100644 --- a/app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java @@ -37,7 +37,7 @@ import java.io.File; public class FtpDownloadActivity extends BaseActivity { //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://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"; @Override protected void init(Bundle savedInstanceState) { @@ -59,10 +59,10 @@ public class FtpDownloadActivity extends BaseActivity { @@ -49,22 +46,9 @@ public class SingleTaskActivity extends BaseActivity { //"http://kotlinlang.org/docs/kotlin-docs.pdf"; //"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe"; //"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://down2.xiaoshuofuwuqi.com/d/file/filetxt/20170608/14/%BA%DA%CE%D7%CA%A6%E1%C8%C6%F0.txt"; - //"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"; + //不支持断点的链接 + "http://58.210.9.131/tpk/sipgt//TDLYZTGH.tpk"; //chunked 下载 + //"https://static.donguo.me//video/ip/course/pfys_1.mp4"; @Bind(R.id.start) Button mStart; @Bind(R.id.stop) Button mStop; @Bind(R.id.cancel) Button mCancel; @@ -234,7 +218,7 @@ public class SingleTaskActivity extends BaseActivity { //.addHeader("Cookie", "BAIDUID=648E5FF020CC69E8DD6F492D1068AAA9:FG=1; BIDUPSID=648E5FF020CC69E8DD6F492D1068AAA9; PSTM=1519099573; BD_UPN=12314753; locale=zh; BDSVRTM=0") .setRequestMode(RequestEnum.GET) .setFilePath(Environment.getExternalStorageDirectory().getPath() + "/ggsg1.apk") - .resetState() + //.resetState() .start(); //.add(); } diff --git a/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java b/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java index 368e9131..21f8927c 100644 --- a/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java +++ b/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java @@ -35,8 +35,8 @@ import java.io.File; * Ftp 文件上传demo */ public class FtpUploadActivity extends BaseActivity { - private final String FILE_PATH = "/mnt/sdcard/AriaPrj.zip"; - private final String URL = "ftp://192.168.1.6:21/aa/你好"; + private final String FILE_PATH = "/mnt/sdcard/sql.rar"; + private final String URL = "ftp://192.168.1.7:21/aa//你好"; @Override protected void init(Bundle savedInstanceState) { setTile("D_FTP 文件上传"); diff --git a/build.gradle b/build.gradle index 9d7946bb..2a1181a0 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ task clean(type: Delete) { ext { userOrg = 'arialyy' groupId = 'com.arialyy.aria' - publishVersion = '3.3.16_dev' + publishVersion = '3.3.16_dev2' // publishVersion = '1.0.3' //FTP插件 repoName='maven' desc = 'android 下载框架'