feat: build apk from project(dir) support

This commit is contained in:
hyb1996
2018-01-24 17:29:25 +08:00
parent 316415343f
commit c93c27fcaa
22 changed files with 365 additions and 34 deletions

View File

@@ -278,6 +278,34 @@ public class PFiles {
}
}
public static boolean copyAssetDir(Context context, String assetsDir, String toDir) {
new File(toDir).mkdirs();
AssetManager manager = context.getAssets();
try {
String[] list = manager.list(assetsDir);
if (list == null)
return false;
for (String file : list) {
InputStream stream;
try {
stream = manager.open(join(assetsDir, file));
} catch (IOException e) {
if (!copyAssetDir(context, join(assetsDir, file), join(toDir, file))) {
return false;
}
continue;
}
copyStream(stream, join(toDir, file));
}
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
public static String renameWithoutExtensionAndReturnNewPath(String path, String newName) {
File file = new File(path);
File newFile = new File(file.getParent(), newName + "." + getExtension(file.getName()));
@@ -431,4 +459,5 @@ public class PFiles {
}
return path;
}
}