// 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();
// }


import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
                distance *= KM_MILE;
                unitName = getString(R.string.unit_mile);
            } else if (activity.preferenceUnits.equals(getString(R.string.pref_units_nautical))) {
                distance *= KM_NMILE;
                unitName = getString(R.string.unit_nmile);
            }
            final NumberFormat nf = NumberFormat.getInstance();
            nf.setMaximumFractionDigits(2);
            final String distanceString = nf.format(distance);
            if (summaryDistance != null) {
                summaryDistance.setText(getString(R.string.summary_distance, distanceString, unitName));
            }
            final long h = summary.getDuration() / 3600;
            final long m = summary.getDuration() % 3600 / 60;
            if (summaryDuration != null) {
                summaryDuration.setText(getString(R.string.summary_duration, h, m));
            }
            int positionsCount = (int) summary.getPositionsCount();
            if (summaryPositions != null) {
                summaryPositions.setText(getResources().getQuantityString(R.plurals.summary_positions, positionsCount, positionsCount));
            }
        }
    }

    /**
     * Display warning before deleting not synchronized track
     */
    private void showNotSyncedWarning() {
        Context context = getContext();
        if (context != null) {
// 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/MainFragment.java
import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;

                distance *= KM_MILE;
                unitName = getString(R.string.unit_mile);
            } else if (activity.preferenceUnits.equals(getString(R.string.pref_units_nautical))) {
                distance *= KM_NMILE;
                unitName = getString(R.string.unit_nmile);
            }
            final NumberFormat nf = NumberFormat.getInstance();
            nf.setMaximumFractionDigits(2);
            final String distanceString = nf.format(distance);
            if (summaryDistance != null) {
                summaryDistance.setText(getString(R.string.summary_distance, distanceString, unitName));
            }
            final long h = summary.getDuration() / 3600;
            final long m = summary.getDuration() % 3600 / 60;
            if (summaryDuration != null) {
                summaryDuration.setText(getString(R.string.summary_duration, h, m));
            }
            int positionsCount = (int) summary.getPositionsCount();
            if (summaryPositions != null) {
                summaryPositions.setText(getResources().getQuantityString(R.plurals.summary_positions, positionsCount, positionsCount));
            }
        }
    }

    /**
     * Display warning before deleting not synchronized track
     */
    private void showNotSyncedWarning() {
        Context context = getContext();
        if (context != null) {
            showConfirm(context,