// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
//     @SuppressLint("InflateParams")
//     View view = context.getLayoutInflater().inflate(layoutResource, null, false);
//     AlertDialog alertDialog = new AlertDialog.Builder(context).create();
//     alertDialog.setTitle(title);
//     alertDialog.setView(view);
//     if (iconResource > 0) {
//         alertDialog.setIcon(iconResource);
//     }
//     alertDialog.show();
//     return alertDialog;
// }
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
//                                DialogInterface.OnClickListener yesCallback) {
//     AlertDialog alertDialog = initDialog(context, title, message);
//     alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
//     alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
//             (dialog, which) -> dialog.dismiss());
//     alertDialog.show();
// }
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/GpxExportTask.java
// public static final String GPX_EXTENSION = ".gpx";


import static androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult;
import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import static net.fabiszewski.ulogger.GpxExportTask.GPX_EXTENSION;
import static java.util.concurrent.Executors.newCachedThreadPool;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.text.HtmlCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.preference.PreferenceManager;
import java.util.concurrent.ExecutorService;
    }

    /**
     * Open file picker to get exported file URI, then run export task
     */
    final ActivityResultLauncher<String> getExportUri = registerForActivityResult(new CreateGpxDocument(), uri -> {
        if (uri != null) {
            runGpxExportTask(uri);
        }
    });

    /**
     * Open settings activity, update preferences on return
     */
    final ActivityResultLauncher<Intent> settingsLauncher = registerForActivityResult(new StartActivityForResult(), result -> {
        if (result.getResultCode() == Activity.RESULT_OK) {
            // Preferences updated
            updatePreferences();
            if (LoggerService.isRunning()) {
                // restart logging
                Intent intent = new Intent(MainActivity.this, LoggerService.class);
                intent.putExtra(UPDATED_PREFS, true);
                startService(intent);
            }
        }
    });

    /**
     * Called whenever the contents of the back stack change.
     */
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
//     @SuppressLint("InflateParams")
//     View view = context.getLayoutInflater().inflate(layoutResource, null, false);
//     AlertDialog alertDialog = new AlertDialog.Builder(context).create();
//     alertDialog.setTitle(title);
//     alertDialog.setView(view);
//     if (iconResource > 0) {
//         alertDialog.setIcon(iconResource);
//     }
//     alertDialog.show();
//     return alertDialog;
// }
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
//                                DialogInterface.OnClickListener yesCallback) {
//     AlertDialog alertDialog = initDialog(context, title, message);
//     alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
//     alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
//             (dialog, which) -> dialog.dismiss());
//     alertDialog.show();
// }
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/GpxExportTask.java
// public static final String GPX_EXTENSION = ".gpx";


// Path: app/src/main/java/net/fabiszewski/ulogger/MainActivity.java
import static androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult;
import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import static net.fabiszewski.ulogger.GpxExportTask.GPX_EXTENSION;
import static java.util.concurrent.Executors.newCachedThreadPool;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.text.HtmlCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.preference.PreferenceManager;
import java.util.concurrent.ExecutorService;

    }

    /**
     * Open file picker to get exported file URI, then run export task
     */
    final ActivityResultLauncher<String> getExportUri = registerForActivityResult(new CreateGpxDocument(), uri -> {
        if (uri != null) {
            runGpxExportTask(uri);
        }
    });

    /**
     * Open settings activity, update preferences on return
     */
    final ActivityResultLauncher<Intent> settingsLauncher = registerForActivityResult(new StartActivityForResult(), result -> {
        if (result.getResultCode() == Activity.RESULT_OK) {
            // Preferences updated
            updatePreferences();
            if (LoggerService.isRunning()) {
                // restart logging
                Intent intent = new Intent(MainActivity.this, LoggerService.class);
                intent.putExtra(UPDATED_PREFS, true);
                startService(intent);
            }
        }
    });

    /**
     * Called whenever the contents of the back stack change.
     */
    @Override