forked from clearw5/Auto.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): supports changing default script dir path
- Loading branch information
hyb1996
committed
Jun 3, 2018
1 parent
7036fa9
commit 023b8a7
Showing
22 changed files
with
281 additions
and
34 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":56},"path":"inrt-release.apk","properties":{"packageId":"com.stardust.auojs.inrt","split":"","minSdkVersion":"17"}}] | ||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":201},"path":"inrt-release.apk","properties":{"packageId":"com.stardust.auojs.inrt","split":"","minSdkVersion":"17"}}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
app/src/main/java/org/autojs/autojs/storage/file/FileObservable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.autojs.autojs.storage.file; | ||
|
||
import com.stardust.pio.PFiles; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import io.reactivex.Observable; | ||
import io.reactivex.Observer; | ||
|
||
public class FileObservable { | ||
|
||
public static Observable<File> copy(String fromPath, String toPath) { | ||
return copy(fromPath, toPath, false); | ||
} | ||
|
||
public static Observable<File> move(String fromPath, String toPath) { | ||
return copy(fromPath, toPath, true); | ||
} | ||
|
||
private static Observable<File> copy(String fromPath, String toPath, boolean deleteOld) { | ||
return new Observable<File>() { | ||
@Override | ||
protected void subscribeActual(Observer<? super File> observer) { | ||
try { | ||
copy(new File(fromPath), new File(toPath), deleteOld, observer); | ||
observer.onComplete(); | ||
} catch (IOException e) { | ||
observer.onError(e); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
private static void copyDir(File fromDir, File toDir, boolean deleteOld, Observer<? super File> progress) throws IOException { | ||
if (!fromDir.isDirectory()) { | ||
return; | ||
} | ||
File[] files = fromDir.listFiles(); | ||
if (files == null || files.length == 0) { | ||
return; | ||
} | ||
for (File file : files) { | ||
copy(file, new File(toDir, file.getName()), deleteOld, progress); | ||
} | ||
} | ||
|
||
private static void copy(File fromFile, File toFile, boolean deleteOld, Observer<? super File> progress) throws IOException { | ||
progress.onNext(fromFile); | ||
if (fromFile.isDirectory()) { | ||
copyDir(fromFile, toFile, deleteOld, progress); | ||
} else { | ||
PFiles.ensureDir(toFile.getPath()); | ||
FileUtils.copyFile(fromFile, toFile); | ||
} | ||
if (deleteOld) { | ||
fromFile.delete(); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.