// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";


import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
    private void disableLiveSync(@NonNull Context context) {
        setBooleanPreference(context, KEY_LIVE_SYNC, false);
    }

    /**
     * Enable preference, set checkbox
     * @param context Context
     */
    private void setBooleanPreference(@NonNull Context context, @NonNull String key, boolean isSet) {
        if (Logger.DEBUG) { Log.d(TAG, "[enabling " + key + "]"); }
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        SharedPreferences.Editor editor = prefs.edit();
        editor.putBoolean(key, isSet);
        editor.apply();

        final Preference preference = findPreference(key);
        if (preference instanceof TwoStatePreference) {
            ((TwoStatePreference) preference).setChecked(isSet);
        }
    }

    /**
     * Check whether server setup parameters are set
     * @param context Context
     * @return boolean True if set
     */
    @SuppressWarnings("BooleanMethodIsAlwaysInverted")
    public static boolean isValidServerSetup(@NonNull Context context) {
        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        final String host = prefs.getString(KEY_HOST, null);
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
// 
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";


// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;

    private void disableLiveSync(@NonNull Context context) {
        setBooleanPreference(context, KEY_LIVE_SYNC, false);
    }

    /**
     * Enable preference, set checkbox
     * @param context Context
     */
    private void setBooleanPreference(@NonNull Context context, @NonNull String key, boolean isSet) {
        if (Logger.DEBUG) { Log.d(TAG, "[enabling " + key + "]"); }
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        SharedPreferences.Editor editor = prefs.edit();
        editor.putBoolean(key, isSet);
        editor.apply();

        final Preference preference = findPreference(key);
        if (preference instanceof TwoStatePreference) {
            ((TwoStatePreference) preference).setChecked(isSet);
        }
    }

    /**
     * Check whether server setup parameters are set
     * @param context Context
     * @return boolean True if set
     */
    @SuppressWarnings("BooleanMethodIsAlwaysInverted")
    public static boolean isValidServerSetup(@NonNull Context context) {
        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        final String host = prefs.getString(KEY_HOST, null);
        final String user = prefs.getString(KEY_USERNAME, null);