@@ -0,0 +1,3657 @@
+package com.boundlessgeo.spatialconnect.jsbridge;%0A%0Aimport android.content.Context;%0A%0Aimport org.apache.commons.io.IOUtils;%0A%0Aimport java.io.File;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.OutputStream;%0Aimport java.util.ArrayList;%0Aimport java.util.Enumeration;%0Aimport java.util.zip.ZipEntry;%0Aimport java.util.zip.ZipFile;%0A%0A%0Apublic class WebBundleUtil %7B%0A%0A    private static final String BUNDLE_DIRECTORY_NAME = %22bundles%22;%0A    private File rootBundlesDir;%0A%0A    public WebBundleUtil(Context context) %7B%0A        this.rootBundlesDir = context.getExternalFilesDir(BUNDLE_DIRECTORY_NAME);%0A    %7D%0A%0A    /**%0A     * Helper method to unzip any zip files in the bundle directory and return a List File objects for the%0A     * unzipped web bundle directories.%0A     */%0A    public ArrayList%3CFile%3E getWebBundleFiles() %7B%0A%0A        ArrayList%3CFile%3E bundleList = new ArrayList%3C%3E();%0A%0A        if (!rootBundlesDir.exists()) %7B%0A            rootBundlesDir.mkdir();%0A        %7D%0A%0A        // if the zip file isn't already unzipped in the bundles directory, then unzip it.%0A        // this is to support bundles that are packaged with the application as well as zip files (bundles) that have%0A        // been downloaded since the last time the WebBundleAdapter has been notified of an update%0A        for (File f : rootBundlesDir.listFiles()) %7B%0A            unzipFile(f);%0A        %7D%0A%0A        // add all unzipped bundles%0A        for (File f : rootBundlesDir.listFiles()) %7B%0A            if (f.isDirectory() && !f.getName().equals(%22__MACOSX%22)) %7B%0A                bundleList.add(f);%0A            %7D%0A        %7D%0A%0A        return bundleList;%0A    %7D%0A%0A    /**%0A     * Unzips a file into the root bundles directory.%0A     *%0A     * @param f%0A     */%0A    public void unzipFile(File f) %7B%0A        if (f.isFile() && !bundleIsUnzipped(f)) %7B%0A            ZipFile zipFile = null;%0A            File bundleDir = new File(rootBundlesDir, f.getName().replace(%22.zip%22, %22%22));%0A            try %7B%0A                zipFile = new ZipFile(f);%0A                Enumeration%3C? extends ZipEntry%3E entries = zipFile.entries();%0A                while (entries.hasMoreElements()) %7B%0A                    ZipEntry entry = entries.nextElement();%0A                    File entryDestination = new File(bundleDir, entry.getName());%0A                    if (entry.isDirectory()) %7B%0A                        entryDestination.mkdirs();%0A                    %7D%0A                    else %7B%0A                        entryDestination.getParentFile().mkdirs();%0A                        InputStream in = zipFile.getInputStream(entry);%0A                        OutputStream out = new FileOutputStream(entryDestination);%0A                        IOUtils.copy(in, out);%0A                        IOUtils.closeQuietly(in);%0A                        out.close();%0A                    %7D%0A                %7D%0A            %7D catch (IOException e) %7B%0A                e.printStackTrace();%0A            %7D finally %7B%0A                try %7B%0A                    zipFile.close();%0A                %7D catch (IOException e) %7B%0A                    e.printStackTrace();%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%0A    /**%0A     * Helper method to determine if a web bundle has been unzipped in the bundles directory.%0A     *%0A     * @param bundle - a file that may or may not have been unziped%0A     * @return true if a directory with the bundle name exists in the bundles directory%0A     */%0A    private boolean bundleIsUnzipped(File bundle) %7B%0A        String bundleName = bundle.getName().replace(%22.zip%22, %22%22);%0A        return new File(rootBundlesDir, bundleName).exists();%0A    %7D%0A%0A    public File getRootBundlesDir() %7B%0A        return rootBundlesDir;%0A    %7D%0A%7D%0A

add bridge util to library SPACON-61