diff --git a/README.md b/README.md
index 203b1e4656e6a4f05b5dbd7bd15378b8c0a17321..1e2bc95cb16f94ba71f54ea33519a9ef83a8e49f 100644
--- a/README.md
+++ b/README.md
@@ -6,8 +6,11 @@
- 所属系列:openharmony的第三方组件适配移植
- 功能:web端与app端文件传输
- 项目移植状态:完成
-- 调用差异:因网络库限制 暂不支持断点续传功能以及文件传输速度无法控制。
-
+- 调用差异:因网络库限制 暂不支持断点续传功能以及文件传输速度无法控制
+- 开发版本:sdk5,DevEco Studio2.1 Release
+- 基线版本:Master
+#### 效果演示
+
#### 使用说明:
该文件传输Demo基于AndServer服务器开发,分别依赖
diff --git a/entry/src/main/java/com/yanzhenjie/andserver/util/FileUtils.java b/entry/src/main/java/com/yanzhenjie/andserver/util/FileUtils.java
index eac75e676196bbad81e6ac992a0e85c928455914..88bcc647ace97252e63f383b686da0ca83863e21 100644
--- a/entry/src/main/java/com/yanzhenjie/andserver/util/FileUtils.java
+++ b/entry/src/main/java/com/yanzhenjie/andserver/util/FileUtils.java
@@ -45,19 +45,14 @@ public class FileUtils {
* @return file object.
*/
public static File createRandomFile(MultipartFile file) {
-// String extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(file.getContentType().toString());
-// if (extension.isEmpty()) {
-// extension = MimeTypeMap.getFileExtensionFromUrl(file.getFilename());
-// }
-// String uuid = UUID.randomUUID().toString();
return new File(MainAbilitySlice.path, file.getFilename());
}
/**
- * +
* SD is available.
*
- * @return true, otherwise is false.
+ * @param context 上下文
+ * @return true otherwise is false.
*/
public static boolean storageAvailable(Context context) {
File sdDir = context.getDistributedDir();
@@ -67,14 +62,6 @@ public class FileUtils {
File sd = new File(sdDir.getAbsolutePath());
return sd.canWrite();
-
-
-// if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
-// File sd = new File(context.getDistributedDir().getAbsolutePath());
-// return sd.canWrite();
-// } else {
-// return false;
-// }
}
@@ -92,7 +79,7 @@ public class FileUtils {
/**
* 创建目录
*
- * @param dir_path
+ * @param dir_path 创建路径
*/
public static void mkDir(String dir_path) {
File myFolderPath = new File(dir_path);
@@ -109,16 +96,17 @@ public class FileUtils {
* 判断指定的文件是否存在。
*
* @param fileName
- * @return
+ * @return File(fileName).isFile() 返回布尔
*/
public static boolean isFileExist(String fileName) {
return new File(fileName).isFile();
}
- /* 得到文件后缀名
+ /**
+ * 得到文件后缀名
*
- * @param fileName
- * @return
+ * @param fileName 文件名
+ * @return fileNam 返回后缀名
*/
public static String getFileExt(String fileName) {
int point = fileName.lastIndexOf('.');
@@ -133,8 +121,8 @@ public class FileUtils {
/**
* 删除文件夹及其下面的子文件夹
*
- * @param dir
- * @throws IOException
+ * @param dir dir
+ * @throws IOException IOException
*/
public static void deleteDir(File dir) throws IOException {
if (dir.isFile())
@@ -154,8 +142,10 @@ public class FileUtils {
}
/**
+ * 文件大小
+ *
* @param fileS 文件长度
- * @return 文件大小
+ * @return fileSizeString 文件大小
*/
public static String FormetFileSize(long fileS) {
DecimalFormat df = new DecimalFormat("#.00");
@@ -179,9 +169,9 @@ public class FileUtils {
/**
* 复制文件
*
- * @param src
- * @param dst
- * @throws Exception
+ * @param src src
+ * @param dst dst
+ * @throws Exception Exception
*/
public static void copy(File src, File dst) throws Exception {
int BUFFER_SIZE = 4096;
@@ -218,8 +208,10 @@ public class FileUtils {
}
/**
- * @param strPath
- * @return
+ * 返回文件列表
+ *
+ * @param strPath strPath
+ * @return filelist 文件列表
*/
public static List getSortFileList(String strPath) {
List filelist = new ArrayList<>();
@@ -262,8 +254,10 @@ public class FileUtils {
}
/**
- * @param strPath
- * @return
+ * 返回文件列表
+ *
+ * @param strPath strPath
+ * @return filelist filelist
*/
public static List getFileList(String strPath) {
List filelist = new ArrayList<>();
@@ -322,7 +316,6 @@ public class FileUtils {
public static int copySdcardFile(InputStream fosfrom, String toFile) {
try {
-// InputStream fosfrom = new FileInputStream(fromFile);
OutputStream fosto = new FileOutputStream(toFile);
byte bt[] = new byte[1024];
int c;
@@ -336,16 +329,4 @@ public class FileUtils {
return -1;
}
}
-// /**
-// * 获得文件的 uri
-// *
-// * @param context context
-// * @param filePath 文件路径
-// * @return uri
-// */
-// public static Uri getFileUri(Context context, String filePath) {
-// File file = new File(filePath);
-// return FileProvider.getUriForFile(context, context.getPackageName() + "" +
-// ".fileprovider", file);
-// }
}
\ No newline at end of file
diff --git a/entry/src/main/java/com/yanzhenjie/andserver/util/NetUtils.java b/entry/src/main/java/com/yanzhenjie/andserver/util/NetUtils.java
index 09432fd7576e3a348bc26ea3aa93965cb100fdb3..202c828207e6978ebe3015c6a2676c73d920bc35 100644
--- a/entry/src/main/java/com/yanzhenjie/andserver/util/NetUtils.java
+++ b/entry/src/main/java/com/yanzhenjie/andserver/util/NetUtils.java
@@ -30,23 +30,17 @@ public class NetUtils {
* Ipv4 address check.
*/
private static final Pattern IPV4_PATTERN = Pattern.compile(
- "^(" + "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}" +
- "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$");
+ "^(" + "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}" +
+ "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$");
- /**
- * Check if valid IPV4 address.
- *
- * @param input the address string to check for validity.
- *
- * @return True if the input parameter is a valid IPv4 address.
- */
public static boolean isIPv4Address(String input) {
return IPV4_PATTERN.matcher(input).matches();
}
/**
* 获取本地ip地址
- * Get local Ip address.
+ *
+ * @return inetAddress Get local Ip address.
*/
public static InetAddress getLocalIPAddress() {
Enumeration enumeration = null;
diff --git a/entry/src/main/java/com/yanzhenjie/swipelayout/SwipeLayout.java b/entry/src/main/java/com/yanzhenjie/swipelayout/SwipeLayout.java
index 94ee1fe7ece14c6239c1c08b0777a906d6815417..91a6ebcb3f515f9bbde48f094064c36cc07edc97 100644
--- a/entry/src/main/java/com/yanzhenjie/swipelayout/SwipeLayout.java
+++ b/entry/src/main/java/com/yanzhenjie/swipelayout/SwipeLayout.java
@@ -84,26 +84,19 @@ public class SwipeLayout extends PositionLayout {
super(context, attrs, styleName);
setDraggedListener(DRAG_HORIZONTAL, new DraggedListener() {
- /**
- * 按下
- */
+
@Override
public void onDragDown(Component component, DragInfo dragInfo) {
// HiLog.info(label, "Log_onDragDown" + "downPoint:" + dragInfo.downPoint);
isCloseBeforeDrag = myStatus == Status.Close;
}
- /**
- * 开始拖拽
- */
+
@Override
public void onDragStart(Component component, DragInfo dragInfo) {
myDragStartPoint = dragInfo.startPoint;
}
- /**
- * 拖拽信息更新
- */
@Override
public void onDragUpdate(Component component, DragInfo dragInfo) {
//根据第一次拖拽信息的更新来决定本次拖拽收视以哪种方向被响应,直到再次成为关闭状态作为一次操作完成。
@@ -127,9 +120,6 @@ public class SwipeLayout extends PositionLayout {
}
}
- /**
- * 拖拽结束
- */
@Override
public void onDragEnd(Component component, DragInfo dragInfo) {
if (getCurrentBottomView() == null) {
@@ -162,26 +152,21 @@ public class SwipeLayout extends PositionLayout {
}
}
- /**
- * 拖拽取消
- */
+
+
@Override
public void onDragCancel(Component component, DragInfo dragInfo) {
// HiLog.info(label, "Log_onDragCancel" + "Tag:" + component.getTag());
}
- /**
- * 是否响应
- */
+
@Override
public boolean onDragPreAccept(Component component, int dragDirection) {
// HiLog.info(label, "Log_onDragPreAccept" + "dragDirection:" + dragDirection);
return true;
}
});
- /**
- * touch监听
- */
+
setTouchEventListener(new TouchEventListener() {
@Override
public boolean onTouchEvent(Component component, TouchEvent touchEvent) {
@@ -195,9 +180,6 @@ public class SwipeLayout extends PositionLayout {
}
- /**
- * 初始化
- */
public void initializeSwipe() {
setCurrentDragEdge(null);
myDragEdges.put(DragEdge.Left, null);
@@ -223,11 +205,7 @@ public class SwipeLayout extends PositionLayout {
super.setTouchEventListener(listener);
}
- /**
- * 添加滑动方向对应的底部视图
- *
- * @param child 对应的视图
- */
+
public void addDrag(Component child) {
myDragEdges.put(DragEdge.Left, child);
child.setContentPosition(getWidth(), 0);
@@ -243,11 +221,7 @@ public class SwipeLayout extends PositionLayout {
super.addComponent(childComponent, index);
}
- /**
- * 设置当前拖拽方向
- *
- * @param currentDragEdge currentDragEdge
- */
+
private void setCurrentDragEdge(DragEdge currentDragEdge) {
// HiLog.info(label, "Log_setCurrentDragEdge" + currentDragEdge);
if (myDragEdges.get(currentDragEdge) == null) {
@@ -263,29 +237,18 @@ public class SwipeLayout extends PositionLayout {
}
}
- /**
- * 获取表层视图
- *
- * @return Component
- */
+
private Component getSurfaceView() {
// return getComponentAt(getChildCount() - 1);
return getComponentAt(0);
}
- /**
- * 获取当前展示的底层视图
- *
- * @return Component
- */
private Component getCurrentBottomView() {
// HiLog.info(label, "Log_getCurrentBottomView" + myCurrentDragEdge);
return myDragEdges.get(myCurrentDragEdge);
}
- /**
- * 关闭侧滑
- */
+
private void close() {
getSurfaceView().setContentPositionX(0);
getCurrentBottomView().setContentPositionX(getWidth());
@@ -293,9 +256,7 @@ public class SwipeLayout extends PositionLayout {
myStatus = Status.Close;
}
- /**
- * 侧滑打开
- */
+
private void open() {
getSurfaceView().setContentPositionX(-getBottomViewWidth());
getCurrentBottomView().setContentPositionX(DeviceUtils.getscreenW(getContext()) - getBottomViewWidth());
@@ -303,31 +264,18 @@ public class SwipeLayout extends PositionLayout {
myStatus = Status.Open;
}
- /**
- * 侧滑状态
- */
public enum Status {
- /**
- * 中间
- */
+
Middle,
- /**
- * 打开
- */
+
Open,
- /**
- * 关闭
- */
+
Close
}
- /**
- * 拖拽方向
- */
+
public enum DragEdge {
- /**
- * 左
- */
+
Left,
/*上*/
Top,
@@ -339,11 +287,7 @@ public class SwipeLayout extends PositionLayout {
Bottom
}
- /**
- * 获取底部视图的宽度
- *
- * @return int
- */
+
private int getBottomViewWidth() {
return getCurrentBottomView().getWidth();
}
diff --git a/img/demo.gif b/img/demo.gif
new file mode 100644
index 0000000000000000000000000000000000000000..87c218588551f0d3d33e5aea5dbe7d91cfc5d62d
Binary files /dev/null and b/img/demo.gif differ