// Path: app/src/main/java/sbs20/filenotes/ServiceManager.java
// public class ServiceManager {
// 
//     private static ServiceManager instance;
// 
//     private Application application;
//     private Settings settings;
//     private ICloudService cloudService;
//     private NotesManager notesManager;
// 
//     private ServiceManager() {}
// 
//     public static ServiceManager getInstance() {
//         if (instance == null) {
//             throw new NullPointerException("ServiceManager.register(serviceManager) not yet called");
//         }
//         return instance;
//     }
// 
//     public static void register(Application application) {
//         instance = new ServiceManager();
//         instance.application = application;
//     }
// 
//     public NotesManager getNotesManager() {
//         if (this.notesManager == null) {
//             this.notesManager = new NotesManager();
//         }
// 
//         return this.notesManager;
//     }
// 
//     public ICloudService getCloudService() {
//         if (this.cloudService == null) {
//             switch (this.getSettings().getCloudServiceName()) {
//                 case "dropbox":
//                     this.cloudService = new DropboxService();
//                     break;
// 
//                 default:
//                     this.cloudService = new NoopCloudService();
//                     break;
//             }
//         }
// 
//         return this.cloudService;
//     }
// 
//     public void resetCloudSync() {
//         this.cloudService = null;
//     }
// 
//     public Settings getSettings() {
//         if (this.settings == null) {
//             this.settings = new Settings(PreferenceManager.getDefaultSharedPreferences(this.application));
//         }
//         return this.settings;
//     }
// 
//     public void toast(String s) {
//         Toast.makeText(application.getApplicationContext(), s, Toast.LENGTH_LONG).show();
//     }
// 
//     public void toast(int resId) {
//         this.toast(this.string(resId));
//     }
// 
//     public Context getContext() {
//         return this.application.getBaseContext();
//     }
// 
//     public String string(int resId) {
//         return this.application.getString(resId);
//     }
// 
//     public String[] array(int resId) {
//         return this.application.getResources().getStringArray(resId);
//     }
// 
//     public IStringTransform fileReadTransform() {
//         return new IStringTransform() {
//             @Override
//             public String transform(String s) {
//                 return s.replaceAll("\r\n", "\n");
//             }
//         };
//     }
// 
//     public IStringTransform fileWriteTransform() {
//         return new IStringTransform() {
//             @Override
//             public String transform(String s) {
//                 return s.replaceAll("\n", "\r\n");
//             }
//         };
//     }
// }
// 
// Path: app/src/main/java/sbs20/filenotes/model/Logger.java
// public class Logger {
// 
//     private static final String VERBOSE = "Verbose";
//     private static final String DEBUG = "Debug";
//     private static final String INFORMATION = "Info";
//     private static final String WARN = "Warn";
//     private static final String ERROR = "Error";
// 
//     private ServiceManager serviceManager;
// 
//     private Logger() {
//     }
// 
//     private static void log(String level, String tag, String msg) {
//         // TODO - write somewhere better
//         switch (level) {
//             case ERROR:
//                 Log.e(tag, msg);
//                 break;
//             case VERBOSE:
//                 Log.v(tag, msg);
//                 break;
//             case INFORMATION:
//                 Log.i(tag, msg);
//                 break;
//             case DEBUG:
//                 Log.d(tag, msg);
//                 break;
//             case WARN:
//                 Log.w(tag, msg);
//                 break;
//         }
//     }
// 
//     public static void verbose(String tag, String msg) {
//         log(VERBOSE, tag, msg);
//     }
//     public static void debug(String tag, String msg) {
//         log(DEBUG, tag, msg);
//     }
//     public static void info(String tag, String msg) {
//         log(INFORMATION, tag, msg);
//     }
//     public static void warn(String tag, String msg) {
//         log(WARN, tag, msg);
//     }
//     public static void error(String tag, String msg) {
//         log(ERROR, tag, msg);
//     }
// 
//     public static void verbose(Object source, String msg) {
//         log(VERBOSE, source.getClass().getName(), msg);
//     }
//     public static void debug(Object source, String msg) {
//         log(DEBUG, source.getClass().getName(), msg);
//     }
//     public static void info(Object source, String msg) {
//         log(INFORMATION, source.getClass().getName(), msg);
//     }
//     public static void warn(Object source, String msg) {
//         log(WARN, source.getClass().getName(), msg);
//     }
//     public static void error(Object source, String msg) {
//         log(ERROR, source.getClass().getName(), msg);
//     }
// }


import android.os.Environment;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import sbs20.filenotes.R;
import sbs20.filenotes.ServiceManager;
import sbs20.filenotes.model.Logger;
    }

    public File getFile(String name) {
        return new File(this.getFilepath(name));
    }

    private File getStorageDirectory() {
        ServiceManager services = ServiceManager.getInstance();
        if (services.getSettings().internalStorage()) {
            return services.getContext().getFilesDir();
        } else {
            String directoryPath = services.getSettings().getLocalStoragePath();
            return new File(directoryPath);
        }
    }

    private String readFileAsString(File file, IStringTransform transform, int length) {
        StringBuffer stringBuffer = new StringBuffer();
        try {
            FileReader reader = new FileReader(file);
            char[] buffer = new char[1024];
            int read;
            while ((read = reader.read(buffer)) != -1) {
                stringBuffer.append(buffer, 0, read);
                if (length > -1 && stringBuffer.length() > length) {
                    break;
                }
            }
            reader.close();
        } catch (IOException e) {
// Path: app/src/main/java/sbs20/filenotes/ServiceManager.java
// public class ServiceManager {
// 
//     private static ServiceManager instance;
// 
//     private Application application;
//     private Settings settings;
//     private ICloudService cloudService;
//     private NotesManager notesManager;
// 
//     private ServiceManager() {}
// 
//     public static ServiceManager getInstance() {
//         if (instance == null) {
//             throw new NullPointerException("ServiceManager.register(serviceManager) not yet called");
//         }
//         return instance;
//     }
// 
//     public static void register(Application application) {
//         instance = new ServiceManager();
//         instance.application = application;
//     }
// 
//     public NotesManager getNotesManager() {
//         if (this.notesManager == null) {
//             this.notesManager = new NotesManager();
//         }
// 
//         return this.notesManager;
//     }
// 
//     public ICloudService getCloudService() {
//         if (this.cloudService == null) {
//             switch (this.getSettings().getCloudServiceName()) {
//                 case "dropbox":
//                     this.cloudService = new DropboxService();
//                     break;
// 
//                 default:
//                     this.cloudService = new NoopCloudService();
//                     break;
//             }
//         }
// 
//         return this.cloudService;
//     }
// 
//     public void resetCloudSync() {
//         this.cloudService = null;
//     }
// 
//     public Settings getSettings() {
//         if (this.settings == null) {
//             this.settings = new Settings(PreferenceManager.getDefaultSharedPreferences(this.application));
//         }
//         return this.settings;
//     }
// 
//     public void toast(String s) {
//         Toast.makeText(application.getApplicationContext(), s, Toast.LENGTH_LONG).show();
//     }
// 
//     public void toast(int resId) {
//         this.toast(this.string(resId));
//     }
// 
//     public Context getContext() {
//         return this.application.getBaseContext();
//     }
// 
//     public String string(int resId) {
//         return this.application.getString(resId);
//     }
// 
//     public String[] array(int resId) {
//         return this.application.getResources().getStringArray(resId);
//     }
// 
//     public IStringTransform fileReadTransform() {
//         return new IStringTransform() {
//             @Override
//             public String transform(String s) {
//                 return s.replaceAll("\r\n", "\n");
//             }
//         };
//     }
// 
//     public IStringTransform fileWriteTransform() {
//         return new IStringTransform() {
//             @Override
//             public String transform(String s) {
//                 return s.replaceAll("\n", "\r\n");
//             }
//         };
//     }
// }
// 
// Path: app/src/main/java/sbs20/filenotes/model/Logger.java
// public class Logger {
// 
//     private static final String VERBOSE = "Verbose";
//     private static final String DEBUG = "Debug";
//     private static final String INFORMATION = "Info";
//     private static final String WARN = "Warn";
//     private static final String ERROR = "Error";
// 
//     private ServiceManager serviceManager;
// 
//     private Logger() {
//     }
// 
//     private static void log(String level, String tag, String msg) {
//         // TODO - write somewhere better
//         switch (level) {
//             case ERROR:
//                 Log.e(tag, msg);
//                 break;
//             case VERBOSE:
//                 Log.v(tag, msg);
//                 break;
//             case INFORMATION:
//                 Log.i(tag, msg);
//                 break;
//             case DEBUG:
//                 Log.d(tag, msg);
//                 break;
//             case WARN:
//                 Log.w(tag, msg);
//                 break;
//         }
//     }
// 
//     public static void verbose(String tag, String msg) {
//         log(VERBOSE, tag, msg);
//     }
//     public static void debug(String tag, String msg) {
//         log(DEBUG, tag, msg);
//     }
//     public static void info(String tag, String msg) {
//         log(INFORMATION, tag, msg);
//     }
//     public static void warn(String tag, String msg) {
//         log(WARN, tag, msg);
//     }
//     public static void error(String tag, String msg) {
//         log(ERROR, tag, msg);
//     }
// 
//     public static void verbose(Object source, String msg) {
//         log(VERBOSE, source.getClass().getName(), msg);
//     }
//     public static void debug(Object source, String msg) {
//         log(DEBUG, source.getClass().getName(), msg);
//     }
//     public static void info(Object source, String msg) {
//         log(INFORMATION, source.getClass().getName(), msg);
//     }
//     public static void warn(Object source, String msg) {
//         log(WARN, source.getClass().getName(), msg);
//     }
//     public static void error(Object source, String msg) {
//         log(ERROR, source.getClass().getName(), msg);
//     }
// }


// Path: app/src/main/java/sbs20/filenotes/storage/FileSystemService.java
import android.os.Environment;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import sbs20.filenotes.R;
import sbs20.filenotes.ServiceManager;
import sbs20.filenotes.model.Logger;

    }

    public File getFile(String name) {
        return new File(this.getFilepath(name));
    }

    private File getStorageDirectory() {
        ServiceManager services = ServiceManager.getInstance();
        if (services.getSettings().internalStorage()) {
            return services.getContext().getFilesDir();
        } else {
            String directoryPath = services.getSettings().getLocalStoragePath();
            return new File(directoryPath);
        }
    }

    private String readFileAsString(File file, IStringTransform transform, int length) {
        StringBuffer stringBuffer = new StringBuffer();
        try {
            FileReader reader = new FileReader(file);
            char[] buffer = new char[1024];
            int read;
            while ((read = reader.read(buffer)) != -1) {
                stringBuffer.append(buffer, 0, read);
                if (length > -1 && stringBuffer.length() > length) {
                    break;
                }
            }
            reader.close();
        } catch (IOException e) {
            Logger.error(this, e.toString());