// Path: FileManager/src/main/java/org/openintents/filemanager/files/FileHolder.java
// public class FileHolder implements Parcelable, Comparable<FileHolder> {
//     public static final Parcelable.Creator<FileHolder> CREATOR = new Parcelable.Creator<FileHolder>() {
//         public FileHolder createFromParcel(Parcel in) {
//             return new FileHolder(in);
//         }
// 
//         public FileHolder[] newArray(int size) {
//             return new FileHolder[size];
//         }
//     };
//     private File mFile;
//     private Drawable mIcon;
//     private String mMimeType = "";
//     private String mExtension;
//     private Boolean mIsDirectory;
// 
//     public FileHolder(File f) {
//         mFile = f;
//         mExtension = parseExtension();
//         mMimeType = MimeTypes.getInstance().getMimeType(f.getName());
//     }
// 
//     public FileHolder(File f, boolean isDirectory) {
//         mFile = f;
//         mExtension = parseExtension();
//         mMimeType = MimeTypes.getInstance().getMimeType(f.getName());
//         mIsDirectory = isDirectory;
//     }
// 
//     /**
//      * Fastest constructor as it takes everything ready.
//      */
//     public FileHolder(File f, String m, Drawable i, boolean isDirectory) {
//         mFile = f;
//         mIcon = i;
//         mExtension = parseExtension();
//         mMimeType = m;
//         mIsDirectory = isDirectory;
//     }
// 
//     public FileHolder(Parcel in) {
//         mFile = new File(in.readString());
//         mMimeType = in.readString();
//         mExtension = in.readString();
//         byte directoryFlag = in.readByte();
//         if (directoryFlag == -1) {
//             mIsDirectory = null;
//         } else {
//             mIsDirectory = (directoryFlag == 1);
//         }
//     }
// 
//     public File getFile() {
//         return mFile;
//     }
// 
//     /**
//      * Gets the icon representation of this file. In case of loss through parcel-unparcel.
//      *
//      * @return The icon.
//      */
//     public Drawable getIcon() {
//         return mIcon;
//     }
// 
//     public void setIcon(Drawable icon) {
//         mIcon = icon;
//     }
// 
//     /**
//      * Shorthand for getFile().getName().
//      *
//      * @return This file's name.
//      */
//     public String getName() {
//         return mFile.getName();
//     }
// 
//     /**
//      * Get the contained file's extension.
//      */
//     public String getExtension() {
//         return mExtension;
//     }
// 
//     /**
//      * @return The held item's mime type.
//      */
//     public String getMimeType() {
//         return mMimeType;
//     }
// 
//     public String getFormattedModificationDate(Context c) {
//         DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(c);
//         DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(c);
//         Date date = new Date(mFile.lastModified());
//         return dateFormat.format(date) + " " + timeFormat.format(date);
//     }
// 
//     /**
//      * @param recursive Whether to return size of the whole tree below this file (Directories only).
//      */
//     public String getFormattedSize(Context c, boolean recursive) {
//         return Formatter.formatFileSize(c, getSizeInBytes(recursive));
//     }
// 
//     private long getSizeInBytes(boolean recursive) {
//         if (recursive && mFile.isDirectory())
//             return FileUtils.folderSize(mFile);
//         else
//             return mFile.length();
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeString(mFile.getAbsolutePath());
//         dest.writeString(mMimeType);
//         dest.writeString(mExtension);
//         dest.writeByte((byte) (mIsDirectory == null ? -1 : (mIsDirectory ? 1 : 0)));
//     }
// 
//     @Override
//     public int compareTo(FileHolder another) {
//         return mFile.compareTo(another.getFile());
//     }
// 
//     /**
//      * Parse the extension from the filename of the mFile member.
//      */
//     private String parseExtension() {
//         return FileUtils.getExtension(mFile.getName()).toLowerCase(Locale.ROOT);
//     }
// 
//     @Override
//     public String toString() {
//         return super.toString() + "-" + getName();
//     }
// 
//     public Boolean isDirectory() {
//         return mIsDirectory;
//     }
// }


import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.Toast;
import org.openintents.filemanager.R;
import org.openintents.filemanager.files.FileHolder;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

                        @Override
                        public void onClick(DialogInterface progressDialog,
                                            int which) {
                            progressDialog.dismiss();
                            Log.e(TAG, "Dialog Dismiss Detected");
                        }
                    });
            progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            progressDialog.setMessage(mContext.getString(R.string.compressing));
            progressDialog.show();
            progressDialog.setProgress(0);
            try {
                out = new FileOutputStream(zipDirectory);
                zos = new ZipOutputStream(new BufferedOutputStream(out));
            } catch (FileNotFoundException e) {
                Log.e(TAG, "error while creating ZipOutputStream");
            }
        }

        @Override
        protected Integer doInBackground(List<FileHolder>... params) {
            if (zos == null) {
                return ERROR;
            }
            List<FileHolder> list = params[0];
            for (FileHolder file : list) {
                if (cancelCompression) {
                    return ERROR;
                }
                try {

// Path: FileManager/src/main/java/org/openintents/filemanager/files/FileHolder.java
// public class FileHolder implements Parcelable, Comparable<FileHolder> {
//     public static final Parcelable.Creator<FileHolder> CREATOR = new Parcelable.Creator<FileHolder>() {
//         public FileHolder createFromParcel(Parcel in) {
//             return new FileHolder(in);
//         }
// 
//         public FileHolder[] newArray(int size) {
//             return new FileHolder[size];
//         }
//     };
//     private File mFile;
//     private Drawable mIcon;
//     private String mMimeType = "";
//     private String mExtension;
//     private Boolean mIsDirectory;
// 
//     public FileHolder(File f) {
//         mFile = f;
//         mExtension = parseExtension();
//         mMimeType = MimeTypes.getInstance().getMimeType(f.getName());
//     }
// 
//     public FileHolder(File f, boolean isDirectory) {
//         mFile = f;
//         mExtension = parseExtension();
//         mMimeType = MimeTypes.getInstance().getMimeType(f.getName());
//         mIsDirectory = isDirectory;
//     }
// 
//     /**
//      * Fastest constructor as it takes everything ready.
//      */
//     public FileHolder(File f, String m, Drawable i, boolean isDirectory) {
//         mFile = f;
//         mIcon = i;
//         mExtension = parseExtension();
//         mMimeType = m;
//         mIsDirectory = isDirectory;
//     }
// 
//     public FileHolder(Parcel in) {
//         mFile = new File(in.readString());
//         mMimeType = in.readString();
//         mExtension = in.readString();
//         byte directoryFlag = in.readByte();
//         if (directoryFlag == -1) {
//             mIsDirectory = null;
//         } else {
//             mIsDirectory = (directoryFlag == 1);
//         }
//     }
// 
//     public File getFile() {
//         return mFile;
//     }
// 
//     /**
//      * Gets the icon representation of this file. In case of loss through parcel-unparcel.
//      *
//      * @return The icon.
//      */
//     public Drawable getIcon() {
//         return mIcon;
//     }
// 
//     public void setIcon(Drawable icon) {
//         mIcon = icon;
//     }
// 
//     /**
//      * Shorthand for getFile().getName().
//      *
//      * @return This file's name.
//      */
//     public String getName() {
//         return mFile.getName();
//     }
// 
//     /**
//      * Get the contained file's extension.
//      */
//     public String getExtension() {
//         return mExtension;
//     }
// 
//     /**
//      * @return The held item's mime type.
//      */
//     public String getMimeType() {
//         return mMimeType;
//     }
// 
//     public String getFormattedModificationDate(Context c) {
//         DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(c);
//         DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(c);
//         Date date = new Date(mFile.lastModified());
//         return dateFormat.format(date) + " " + timeFormat.format(date);
//     }
// 
//     /**
//      * @param recursive Whether to return size of the whole tree below this file (Directories only).
//      */
//     public String getFormattedSize(Context c, boolean recursive) {
//         return Formatter.formatFileSize(c, getSizeInBytes(recursive));
//     }
// 
//     private long getSizeInBytes(boolean recursive) {
//         if (recursive && mFile.isDirectory())
//             return FileUtils.folderSize(mFile);
//         else
//             return mFile.length();
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeString(mFile.getAbsolutePath());
//         dest.writeString(mMimeType);
//         dest.writeString(mExtension);
//         dest.writeByte((byte) (mIsDirectory == null ? -1 : (mIsDirectory ? 1 : 0)));
//     }
// 
//     @Override
//     public int compareTo(FileHolder another) {
//         return mFile.compareTo(another.getFile());
//     }
// 
//     /**
//      * Parse the extension from the filename of the mFile member.
//      */
//     private String parseExtension() {
//         return FileUtils.getExtension(mFile.getName()).toLowerCase(Locale.ROOT);
//     }
// 
//     @Override
//     public String toString() {
//         return super.toString() + "-" + getName();
//     }
// 
//     public Boolean isDirectory() {
//         return mIsDirectory;
//     }
// }


// Path: FileManager/src/main/java/org/openintents/filemanager/util/CompressManager.java
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.Toast;
import org.openintents.filemanager.R;
import org.openintents.filemanager.files.FileHolder;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

                        @Override
                        public void onClick(DialogInterface progressDialog,
                                            int which) {
                            progressDialog.dismiss();
                            Log.e(TAG, "Dialog Dismiss Detected");
                        }
                    });
            progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            progressDialog.setMessage(mContext.getString(R.string.compressing));
            progressDialog.show();
            progressDialog.setProgress(0);
            try {
                out = new FileOutputStream(zipDirectory);
                zos = new ZipOutputStream(new BufferedOutputStream(out));
            } catch (FileNotFoundException e) {
                Log.e(TAG, "error while creating ZipOutputStream");
            }
        }

        @Override
        protected Integer doInBackground(List<FileHolder>... params) {
            if (zos == null) {
                return ERROR;
            }
            List<FileHolder> list = params[0];
            for (FileHolder file : list) {
                if (cancelCompression) {
                    return ERROR;
                }
                try {

                    compressFile(file.getFile(), "");
