Support for zipped icon packs
- Added support for zipped icon pack files (iconpack*.zip) - Added support for multiple appnames*.txt files
This commit is contained in:
@@ -7,11 +7,18 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.FeatureInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
|
||||
@@ -88,4 +95,46 @@ public class AppInfo extends UnityPlayerActivity {
|
||||
byte[] byteArray = stream.toByteArray();
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
public static void unzip(String zipFileName, String targetPath) {
|
||||
|
||||
File outDir = new File(targetPath);
|
||||
|
||||
// Create target path if not exist
|
||||
createDirIfNotExist(outDir);
|
||||
|
||||
byte[] buffer = new byte[8192];
|
||||
try (FileInputStream fis = new FileInputStream(zipFileName);
|
||||
BufferedInputStream bis = new BufferedInputStream(fis);
|
||||
ZipInputStream stream = new ZipInputStream(bis)) {
|
||||
|
||||
ZipEntry entry = null;
|
||||
while ((entry = stream.getNextEntry()) != null) {
|
||||
|
||||
File filePath = new File(outDir, entry.getName());
|
||||
Log.v(TAG, "Unzipping " + filePath);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
// Create dir if required while unzipping
|
||||
createDirIfNotExist(filePath);
|
||||
} else {
|
||||
try (FileOutputStream fos = new FileOutputStream(filePath);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(fos, buffer.length)) {
|
||||
int len;
|
||||
while ((len = stream.read(buffer)) > 0) {
|
||||
bos.write(buffer, 0, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void createDirIfNotExist(File path) {
|
||||
if (!path.exists()) {
|
||||
path.mkdirs();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user