// 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;
/*
 * Copyright (c) 2018 Bartek Fabiszewski
 * http://www.fabiszewski.net
 *
 * This file is part of μlogger-android.
 * Licensed under GPL, either version 3, or any later.
 * See <http://www.gnu.org/licenses/>
 */

package net.fabiszewski.ulogger;





@SuppressWarnings("WeakerAccess")
public class SettingsFragment extends PreferenceFragmentCompat {

    private static final String TAG = SettingsFragment.class.getSimpleName();

    @Override
    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
        setPreferencesFromResource(R.xml.preferences, rootKey);
        setListeners();
    }

    @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");
// 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;

/*
 * Copyright (c) 2018 Bartek Fabiszewski
 * http://www.fabiszewski.net
 *
 * This file is part of μlogger-android.
 * Licensed under GPL, either version 3, or any later.
 * See <http://www.gnu.org/licenses/>
 */

package net.fabiszewski.ulogger;





@SuppressWarnings("WeakerAccess")
public class SettingsFragment extends PreferenceFragmentCompat {

    private static final String TAG = SettingsFragment.class.getSimpleName();

    @Override
    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
        setPreferencesFromResource(R.xml.preferences, rootKey);
        setListeners();
    }

    @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())) {