// Path: app/src/main/java/eu/basicairdata/graziano/gpslogger/GPSApplication.java
// public static final int NOT_AVAILABLE = -100000;
// 
// Path: app/src/main/java/eu/basicairdata/graziano/gpslogger/GPSApplication.java
// public static GPSApplication getInstance(){
//     return singleton;
// }


import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import java.util.concurrent.ArrayBlockingQueue;
import static eu.basicairdata.graziano.gpslogger.GPSApplication.NOT_AVAILABLE;
import static eu.basicairdata.graziano.gpslogger.GPSApplication.getInstance;
import androidx.documentfile.provider.DocumentFile;
import android.net.Uri;
import android.util.Log;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;

    /**
     * Converts a String in a format suitable for the CDATA fields on KML files,
     * by replacing the invalid characters with the corresponding HTML sequences.
     *
     * @param str The input String
     * @return the string formatted for CDATA fields of KML files
     */
    private String stringToCDATA(String str) {
        if (str == null) return "";
        return str.replace("[","(")
                .replace("]",")")
                .replace("<","(")
                .replace(">",")");
    }

    /**
     * Creates the files that will be written by the Exporter.
     * The method try to assign the name specified as input,
     *
     * @param fName The file name (without path and .extension)
     * @return true if the operation succeed
     */
    private boolean tryToInitFiles(String fName) {
        // Create files, deleting old version if exists

        try {
            DocumentFile pickedDir;
            if (saveIntoFolder.startsWith("content")) {
                Uri uri = Uri.parse(saveIntoFolder);
// Path: app/src/main/java/eu/basicairdata/graziano/gpslogger/GPSApplication.java
// public static final int NOT_AVAILABLE = -100000;
// 
// Path: app/src/main/java/eu/basicairdata/graziano/gpslogger/GPSApplication.java
// public static GPSApplication getInstance(){
//     return singleton;
// }


// Path: app/src/main/java/eu/basicairdata/graziano/gpslogger/Exporter.java
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import java.util.concurrent.ArrayBlockingQueue;
import static eu.basicairdata.graziano.gpslogger.GPSApplication.NOT_AVAILABLE;
import static eu.basicairdata.graziano.gpslogger.GPSApplication.getInstance;
import androidx.documentfile.provider.DocumentFile;
import android.net.Uri;
import android.util.Log;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;


    /**
     * Converts a String in a format suitable for the CDATA fields on KML files,
     * by replacing the invalid characters with the corresponding HTML sequences.
     *
     * @param str The input String
     * @return the string formatted for CDATA fields of KML files
     */
    private String stringToCDATA(String str) {
        if (str == null) return "";
        return str.replace("[","(")
                .replace("]",")")
                .replace("<","(")
                .replace(">",")");
    }

    /**
     * Creates the files that will be written by the Exporter.
     * The method try to assign the name specified as input,
     *
     * @param fName The file name (without path and .extension)
     * @return true if the operation succeed
     */
    private boolean tryToInitFiles(String fName) {
        // Create files, deleting old version if exists

        try {
            DocumentFile pickedDir;
            if (saveIntoFolder.startsWith("content")) {
                Uri uri = Uri.parse(saveIntoFolder);
                pickedDir = DocumentFile.fromTreeUri(getInstance(), uri);