// 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;

    @SuppressWarnings("deprecation")
    @Override
    public void onDisplayPreferenceDialog(Preference preference) {
        if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
            final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
            fragment.setTargetFragment(this, 0);
            fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
        } else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
            final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
            fragment.setTargetFragment(this, 0);
            fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
        } else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) {
            final ProviderPreferenceDialogFragment fragment = ProviderPreferenceDialogFragment.newInstance(preference.getKey());
            fragment.setTargetFragment(this, 0);
            fragment.show(getParentFragmentManager(), "ProviderPreferenceDialogFragment");
        } else if (preference instanceof ListPreference) {
            final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
            fragment.setTargetFragment(this, 0);
            fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
        } else {
            super.onDisplayPreferenceDialog(preference);
        }
    }

    /**
     * Set various listeners
     */
    private void setListeners() {
        final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
// 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;


    @SuppressWarnings("deprecation")
    @Override
    public void onDisplayPreferenceDialog(Preference preference) {
        if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
            final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
            fragment.setTargetFragment(this, 0);
            fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
        } else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
            final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
            fragment.setTargetFragment(this, 0);
            fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
        } else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) {
            final ProviderPreferenceDialogFragment fragment = ProviderPreferenceDialogFragment.newInstance(preference.getKey());
            fragment.setTargetFragment(this, 0);
            fragment.show(getParentFragmentManager(), "ProviderPreferenceDialogFragment");
        } else if (preference instanceof ListPreference) {
            final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
            fragment.setTargetFragment(this, 0);
            fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
        } else {
            super.onDisplayPreferenceDialog(preference);
        }
    }

    /**
     * Set various listeners
     */
    private void setListeners() {
        final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
        final Preference prefUsername = findPreference(KEY_USERNAME);