// Path: app/src/main/java/com/koma/filemanager/FileManagerApplication.java
// public class FileManagerApplication extends Application {
//     private static Context sContext;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         sContext = getApplicationContext();
//         enabledStrictMode();
//         if (LeakCanary.isInAnalyzerProcess(this)) {
//             // This process is dedicated to LeakCanary for heap analysis.
//             // You should not init your app in this process.
//             return;
//         }
//         LeakCanary.install(this);
//     }
// 
//     public static synchronized Context getContext() {
//         return sContext;
//     }
// 
//     private void enabledStrictMode() {
//         if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) {
// 
//             //线程监控，会弹出对话框
//             StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
//                     .detectAll()
//                     .penaltyLog()
//                     .penaltyDialog()
//                     .build());
// 
//             //VM监控
//             StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
//                     .detectAll()
//                     .penaltyLog()
//                     .build());
//         }
// 
//     }
// }
// 
// Path: app/src/main/java/com/koma/filemanager/data/model/Disk.java
// public class Disk {
//     private String mMountPoint, mDescription;
//     private long mTotalSpace, mVailableSpace;
// 
//     public Disk() {
//         this("", "", 0, 0);
//     }
// 
//     public Disk(String mountPoint, String description, long total, long vailableSpace) {
//         mMountPoint = mountPoint;
//         mDescription = description;
//         mTotalSpace = total;
//         mVailableSpace = vailableSpace;
//     }
// 
//     public void setMountPoint(String mountPoint) {
//         mMountPoint = mountPoint;
//     }
// 
//     public String getMountPoint() {
//         return mMountPoint;
//     }
// 
//     public void setDescription(String description) {
//         mDescription = description;
//     }
// 
//     public String getDescription() {
//         return mDescription;
//     }
// 
//     public void setTotalSpace(long totalSpace) {
//         mTotalSpace = totalSpace;
//     }
// 
//     public long getTotalSpace() {
//         return mTotalSpace;
//     }
// 
//     public void setAvailableSpace(long availableSpace) {
//         mVailableSpace = availableSpace;
//     }
// 
//     public long getAvailavleSpace() {
//         return mVailableSpace;
//     }
// }


import android.content.Context;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Environment;
import android.os.StatFs;
import android.os.storage.StorageManager;
import android.provider.MediaStore;
import android.util.Log;
import com.koma.filemanager.FileManagerApplication;
import com.koma.filemanager.R;
import com.koma.filemanager.data.model.Disk;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
        String[] mimeTypes;
        String[] suffixOffice;
        Resources resources = FileManagerApplication.getContext().getResources();
        mimeTypes = resources.getStringArray(R.array.doc_mime_types);
        suffixOffice = resources.getStringArray(R.array.doc_office_suffix);
        for (int i = 0; i < mimeTypes.length; i++) {
            selection.append("(" + MediaStore.Files.FileColumns.MIME_TYPE + "=='" + mimeTypes[i] + "') OR ");
        }
        for (int i = 0; i < suffixOffice.length; i++) {
            selection.append("(" + MediaStore.Files.FileColumns.DATA + " LIKE '%." + suffixOffice[i] + "') OR ");
        }
        return selection.substring(0, selection.lastIndexOf(")") + 1);
    }

    public static String buildZipSelection() {
        StringBuilder selection = new StringBuilder();
        Resources resources = FileManagerApplication.getContext().getResources();
        String[] Suffix = resources.getStringArray(R.array.zip_suffix);
        for (int i = 0; i < Suffix.length; i++) {
            selection.append("(" + MediaStore.Files.FileColumns.DATA + " LIKE '%." + Suffix[i] + "') OR ");
        }
        return selection.substring(0, selection.lastIndexOf(")") + 1);
    }

    public static String buildApkSelection() {
        StringBuilder selection = new StringBuilder(MediaStore.Files.FileColumns.DATA);
        selection.append(" LIKE '%.apk'");
        return selection.toString();
    }

// Path: app/src/main/java/com/koma/filemanager/FileManagerApplication.java
// public class FileManagerApplication extends Application {
//     private static Context sContext;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         sContext = getApplicationContext();
//         enabledStrictMode();
//         if (LeakCanary.isInAnalyzerProcess(this)) {
//             // This process is dedicated to LeakCanary for heap analysis.
//             // You should not init your app in this process.
//             return;
//         }
//         LeakCanary.install(this);
//     }
// 
//     public static synchronized Context getContext() {
//         return sContext;
//     }
// 
//     private void enabledStrictMode() {
//         if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) {
// 
//             //线程监控，会弹出对话框
//             StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
//                     .detectAll()
//                     .penaltyLog()
//                     .penaltyDialog()
//                     .build());
// 
//             //VM监控
//             StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
//                     .detectAll()
//                     .penaltyLog()
//                     .build());
//         }
// 
//     }
// }
// 
// Path: app/src/main/java/com/koma/filemanager/data/model/Disk.java
// public class Disk {
//     private String mMountPoint, mDescription;
//     private long mTotalSpace, mVailableSpace;
// 
//     public Disk() {
//         this("", "", 0, 0);
//     }
// 
//     public Disk(String mountPoint, String description, long total, long vailableSpace) {
//         mMountPoint = mountPoint;
//         mDescription = description;
//         mTotalSpace = total;
//         mVailableSpace = vailableSpace;
//     }
// 
//     public void setMountPoint(String mountPoint) {
//         mMountPoint = mountPoint;
//     }
// 
//     public String getMountPoint() {
//         return mMountPoint;
//     }
// 
//     public void setDescription(String description) {
//         mDescription = description;
//     }
// 
//     public String getDescription() {
//         return mDescription;
//     }
// 
//     public void setTotalSpace(long totalSpace) {
//         mTotalSpace = totalSpace;
//     }
// 
//     public long getTotalSpace() {
//         return mTotalSpace;
//     }
// 
//     public void setAvailableSpace(long availableSpace) {
//         mVailableSpace = availableSpace;
//     }
// 
//     public long getAvailavleSpace() {
//         return mVailableSpace;
//     }
// }


// Path: app/src/main/java/com/koma/filemanager/util/FileCategoryUtils.java
import android.content.Context;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Environment;
import android.os.StatFs;
import android.os.storage.StorageManager;
import android.provider.MediaStore;
import android.util.Log;
import com.koma.filemanager.FileManagerApplication;
import com.koma.filemanager.R;
import com.koma.filemanager.data.model.Disk;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

        String[] mimeTypes;
        String[] suffixOffice;
        Resources resources = FileManagerApplication.getContext().getResources();
        mimeTypes = resources.getStringArray(R.array.doc_mime_types);
        suffixOffice = resources.getStringArray(R.array.doc_office_suffix);
        for (int i = 0; i < mimeTypes.length; i++) {
            selection.append("(" + MediaStore.Files.FileColumns.MIME_TYPE + "=='" + mimeTypes[i] + "') OR ");
        }
        for (int i = 0; i < suffixOffice.length; i++) {
            selection.append("(" + MediaStore.Files.FileColumns.DATA + " LIKE '%." + suffixOffice[i] + "') OR ");
        }
        return selection.substring(0, selection.lastIndexOf(")") + 1);
    }

    public static String buildZipSelection() {
        StringBuilder selection = new StringBuilder();
        Resources resources = FileManagerApplication.getContext().getResources();
        String[] Suffix = resources.getStringArray(R.array.zip_suffix);
        for (int i = 0; i < Suffix.length; i++) {
            selection.append("(" + MediaStore.Files.FileColumns.DATA + " LIKE '%." + Suffix[i] + "') OR ");
        }
        return selection.substring(0, selection.lastIndexOf(")") + 1);
    }

    public static String buildApkSelection() {
        StringBuilder selection = new StringBuilder(MediaStore.Files.FileColumns.DATA);
        selection.append(" LIKE '%.apk'");
        return selection.toString();
    }

    public static ArrayList<Disk> getDisks() {