Example usage for android.preference ListPreference setDialogTitle

List of usage examples for android.preference ListPreference setDialogTitle

Introduction

In this page you can find the example usage for android.preference ListPreference setDialogTitle.

Prototype

public void setDialogTitle(CharSequence dialogTitle) 

Source Link

Document

Sets the title of the dialog.

Usage

From source file:com.airflo.preferences.ListPreferenceActivity.java

@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
@Override// w w w  .  j  av a  2 s.com
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        getActionBar().setDisplayHomeAsUpEnabled(true);
    }

    root = getPreferenceManager().createPreferenceScreen(this);

    //Array of sorting preference keys to be included. 
    //SortType must be specified in bookitems.xml!
    String[] sortValues = new String[] { "number", "date;starttime", "site;date;starttime", "duration",
            "maxheight", "maxvario", "starttype;date;starttime" };
    //Generate according Entry Strings.
    String[] sortEntries = new String[sortValues.length];
    for (int i = 0; i < sortEntries.length; i++)
        sortEntries[i] = sortKeyToString(sortValues[i]);

    //Make sorting category
    PreferenceCategory cat = new PreferenceCategory(this);
    cat.setTitle(R.string.list_pref_cat_sort_title);
    root.addPreference(cat);
    final ListPreference listPref = new ListPreference(this);
    listPref.setKey("list_pref_sort");
    listPref.setEntries(sortEntries);
    listPref.setEntryValues(sortValues);
    listPref.setDialogTitle(R.string.list_pref_sort_criterium);
    listPref.setSummary(sortKeyToString(root.getSharedPreferences().getString("list_pref_sort", "number")));
    listPref.setTitle(R.string.list_pref_sort_criterium);
    cat.addPreference(listPref);
    listPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            listPref.setSummary(sortKeyToString((String) newValue));
            return true;
        }
    });
    final ListPreference orderPref = new ListPreference(this);
    orderPref.setKey("list_pref_order");
    orderPref.setEntries(new String[] { OnlyContext.rString("list_pref_sort_ascending"),
            OnlyContext.rString("list_pref_sort_decending") });
    orderPref.setEntryValues(new String[] { "list_pref_sort_ascending", "list_pref_sort_decending" });
    orderPref.setDialogTitle(R.string.list_pref_sort_sequence);
    orderPref.setSummary(OnlyContext
            .rString(root.getSharedPreferences().getString("list_pref_order", "list_pref_sort_decending")));
    orderPref.setTitle(R.string.list_pref_sort_sequence);
    cat.addPreference(orderPref);
    orderPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            orderPref.setSummary(OnlyContext.rString((String) newValue));
            return true;
        }
    });

    //Make item categories
    addManyListItems(R.string.list_pref_cat1_title, "listhead", 3);
    addManyListItems(R.string.list_pref_cat2_title, "listsub", 3);

    this.setPreferenceScreen(root);
}

From source file:com.airflo.preferences.ListPreferenceActivity.java

/**
 * Add one slider preference to the category.
 * @param cat/*ww  w  . j  av  a  2  s  .  com*/
 * @param key
 * @param title
 */
private void addOneListItem(PreferenceCategory cat, String key, String title) {
    final ListPreference listPref = new ListPreference(this);
    listPref.setKey(key);
    listPref.setEntries(FlightData.identis.getPrefListChars(true));
    listPref.setEntryValues(FlightData.identis.getPrefListChars(false));
    listPref.setDialogTitle(title);
    listPref.setSummary(
            FlightData.identis.getIdenti(root.getSharedPreferences().getString(key, "empty")).getStringRep());
    listPref.setTitle(title);
    cat.addPreference(listPref);
    listPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            listPref.setSummary(FlightData.identis.getIdenti((String) newValue).getStringRep());
            return true;
        }
    });
}

From source file:com.nttec.everychan.chans.synch.SynchModule.java

@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    Context context = preferenceGroup.getContext();
    ListPreference domainPref = new LazyPreferences.ListPreference(context);
    domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
    domainPref.setTitle(R.string.pref_domain);
    domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT));
    domainPref.setDialogTitle(R.string.pref_domain);
    domainPref.setEntries(DOMAINS);/*from   w  w w  .j  a  v a  2 s. c  o  m*/
    domainPref.setEntryValues(DOMAINS);
    domainPref.setDefaultValue(DOMAINS[0]);
    preferenceGroup.addPreference(domainPref);
    super.addPreferencesOnScreen(preferenceGroup);
}

From source file:com.nttec.everychan.chans.allchan.AllchanModule.java

@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    Context context = preferenceGroup.getContext();
    addOnlyNewPostsPreference(preferenceGroup, true);
    final ListPreference captchaPreference = new LazyPreferences.ListPreference(context); //captcha_type
    captchaPreference.setTitle(R.string.pref_captcha_type);
    captchaPreference.setDialogTitle(R.string.pref_captcha_type);
    captchaPreference.setKey(getSharedKey(PREF_KEY_CAPTCHA_TYPE));
    captchaPreference.setEntryValues(CAPTCHA_TYPES_KEYS);
    captchaPreference.setEntries(CAPTCHA_TYPES);
    captchaPreference.setDefaultValue(CAPTCHA_TYPE_DEFAULT);
    int i = Arrays.asList(CAPTCHA_TYPES_KEYS)
            .indexOf(preferences.getString(getSharedKey(PREF_KEY_CAPTCHA_TYPE), CAPTCHA_TYPE_DEFAULT));
    if (i >= 0)
        captchaPreference.setSummary(CAPTCHA_TYPES[i]);
    preferenceGroup.addPreference(captchaPreference);
    addHttpsPreference(preferenceGroup, true);
    addCloudflareRecaptchaFallbackPreference(preferenceGroup);
    addProxyPreferences(preferenceGroup);

    final CheckBoxPreference proxyPreference = (CheckBoxPreference) preferenceGroup
            .findPreference(getSharedKey(PREF_KEY_USE_PROXY));
    proxyPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override/*from w w w  .j  ava 2 s.c  o m*/
        public boolean onPreferenceClick(Preference preference) {
            if (proxyPreference.isChecked() && captchaPreference.getValue().equals("recaptcha")) {
                captchaPreference.setValue("recaptcha-fallback");
            }
            return false;
        }
    });
    captchaPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (proxyPreference.isChecked() && newValue.equals("recaptcha")) {
                captchaPreference.setValue("recaptcha-fallback");
                return false;
            }
            return true;
        }
    });
}

From source file:nya.miku.wishmaster.chans.tumbach.TumbachModule.java

@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    Context context = preferenceGroup.getContext();
    addOnlyNewPostsPreference(preferenceGroup, true);
    final ListPreference captchaPreference = new LazyPreferences.ListPreference(context); //captcha_type
    captchaPreference.setTitle(R.string.pref_captcha_type);
    captchaPreference.setDialogTitle(R.string.pref_captcha_type);
    captchaPreference.setKey(getSharedKey(PREF_KEY_CAPTCHA_TYPE));
    captchaPreference.setEntryValues(CAPTCHA_TYPES_KEYS);
    captchaPreference.setEntries(CAPTCHA_TYPES);
    captchaPreference.setDefaultValue(CAPTCHA_TYPE_DEFAULT);
    int i = Arrays.asList(CAPTCHA_TYPES_KEYS)
            .indexOf(preferences.getString(getSharedKey(PREF_KEY_CAPTCHA_TYPE), CAPTCHA_TYPE_DEFAULT));
    if (i >= 0)
        captchaPreference.setSummary(CAPTCHA_TYPES[i]);
    preferenceGroup.addPreference(captchaPreference);
    addPasswordPreference(preferenceGroup);
    addHttpsPreference(preferenceGroup, true);
    addCloudflareRecaptchaFallbackPreference(preferenceGroup);
    addProxyPreferences(preferenceGroup);

    final CheckBoxPreference proxyPreference = (CheckBoxPreference) preferenceGroup
            .findPreference(getSharedKey(PREF_KEY_USE_PROXY));
    proxyPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override//from w ww  .  j av a2s  .co m
        public boolean onPreferenceClick(Preference preference) {
            if (proxyPreference.isChecked() && captchaPreference.getValue().equals("recaptcha")) {
                captchaPreference.setValue("recaptcha-fallback");
            }
            return false;
        }
    });
    captchaPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (proxyPreference.isChecked() && newValue.equals("recaptcha")) {
                captchaPreference.setValue("recaptcha-fallback");
                return false;
            }
            return true;
        }
    });
}

From source file:com.nttec.everychan.chans.ponyach.PonyachModule.java

@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    final Context context = preferenceGroup.getContext();
    ListPreference captchaLevel = new LazyPreferences.ListPreference(context);
    captchaLevel.setTitle(R.string.ponyach_prefs_captcha);
    captchaLevel.setDialogTitle(R.string.ponyach_prefs_captcha);
    captchaLevel.setKey(getSharedKey(PREF_KEY_CAPTCHA_LEVEL));
    captchaLevel.setEntryValues(new String[] { "3", "2", "1" });
    captchaLevel.setEntries(new String[] { "Easy", "Easy++", "Medium" });
    captchaLevel.setDefaultValue("1");
    preferenceGroup.addPreference(captchaLevel);

    EditTextPreference passcodePref = new EditTextPreference(context);
    passcodePref.setTitle(R.string.ponyach_prefs_passcode);
    passcodePref.setDialogTitle(R.string.ponyach_prefs_passcode);
    passcodePref.getEditText().setFilters(new InputFilter[] { new InputFilter.LengthFilter(6) });
    passcodePref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override/*from ww  w.j  a va 2  s . c om*/
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            final String newPasscode = (String) newValue;
            final CancellableTask passAuthTask = new CancellableTask.BaseCancellableTask();
            final ProgressDialog passAuthProgressDialog = new ProgressDialog(context);
            passAuthProgressDialog.setMessage("Logging in");
            passAuthProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    passAuthTask.cancel();
                }
            });
            passAuthProgressDialog.setCanceledOnTouchOutside(false);
            passAuthProgressDialog.show();
            Async.runAsync(new Runnable() {
                @Override
                public void run() {
                    try {
                        if (passAuthTask.isCancelled())
                            return;
                        String url = getUsingUrl() + "passcode.php";
                        List<BasicNameValuePair> pairs = Collections
                                .singletonList(new BasicNameValuePair("passcode_just_set", newPasscode));
                        HttpRequestModel request = HttpRequestModel.builder()
                                .setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).build();
                        HttpStreamer.getInstance().getStringFromUrl(url, request, httpClient, null,
                                passAuthTask, false);
                        savePhpCookies();
                    } catch (final Exception e) {
                        if (context instanceof Activity) {
                            ((Activity) context).runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    String message = e.getMessage() == null
                                            ? resources.getString(R.string.error_unknown)
                                            : e.getMessage();
                                    Toast.makeText(context, message, Toast.LENGTH_LONG).show();
                                }
                            });
                        }
                    } finally {
                        passAuthProgressDialog.dismiss();
                    }
                }
            });
            return false;
        }
    });
    preferenceGroup.addPreference(passcodePref);

    ListPreference domainPref = new LazyPreferences.ListPreference(context);
    domainPref.setTitle(R.string.pref_domain);
    domainPref.setDialogTitle(R.string.pref_domain);
    domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
    domainPref.setEntryValues(DOMAINS);
    domainPref.setEntries(DOMAINS);
    domainPref.setDefaultValue(DEFAULT_DOMAIN);
    domainPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            loadPhpCookies((String) newValue);
            return true;
        }
    });
    preferenceGroup.addPreference(domainPref);

    addHttpsPreference(preferenceGroup, useHttpsDefaultValue());
    addProxyPreferences(preferenceGroup);
    captchaLevel.setSummary(captchaLevel.getEntry());
    domainPref.setSummary(domainPref.getEntry());
}

From source file:com.cesarsk.say_it.ui.fragments.SettingsFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    // Use an activity context to get the rewarded video instance.
    mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(getActivity());
    mRewardedVideoAd.setRewardedVideoAdListener(this);

    loadRewardedVideoAd();/*from  ww w .j a  v a  2s .  co  m*/

    PackageInfo pInfo = null;
    try {
        pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    String version = pInfo.versionName;
    final Preference app_version = getPreferenceManager().findPreference("app_version");
    app_version.setSummary("Version: " + version + " (Click for Privacy Policy)");

    final Context context = getActivity();

    if (context instanceof Callback) {
        mCallback = (Callback) context;
    } else {
        throw new IllegalStateException("Owner must implement URLCallback interface");
    }

    // add listeners for non-default actions
    Preference preference = findPreference(KEY_1);
    preference.setOnPreferenceClickListener(this);

    Preference open_source_licenses = findPreference(KEY_2);
    open_source_licenses.setOnPreferenceClickListener(this);

    Preference rate_us = getPreferenceManager().findPreference("rate_us");
    rate_us.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            rateUs(getActivity());
            return false;
        }
    });

    Preference contact_us = getPreferenceManager().findPreference("contact_us");
    contact_us.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            shareToMail(emails, "[CONTACT US - SAY IT!]", getActivity());
            return false;
        }
    });

    Preference bug_report = getPreferenceManager().findPreference("bug_report");
    bug_report.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            shareToMail(emails, "[CONTACT US - SAY IT!]", getActivity());
            return false;
        }
    });

    Preference donate_ad = getPreferenceManager().findPreference("donation_ad");
    donate_ad.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            //Launch AD
            if (mRewardedVideoAd.isLoaded()) {
                mRewardedVideoAd.show();
            }
            return false;
        }
    });

    final Preference about_us = getPreferenceManager().findPreference("about_us");
    about_us.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Utility.openURL(getActivity(), "https://lucacesaranoblog.wordpress.com/2017/07/18/about-us/");
            return false;
        }
    });

    final Preference eula = getPreferenceManager().findPreference("eula");
    eula.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Utility.openURL(getActivity(),
                    "https://lucacesaranoblog.wordpress.com/2017/04/28/say-it-eula-agreement/");
            return false;
        }
    });

    /*final Preference github = getPreferenceManager().findPreference("github");
    github.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
    @Override
    public boolean onPreferenceClick(Preference preference) {
        Utility.openURL(getActivity(), "https://github.com/Cesarsk/Say_it");
        return false;
    }
    });*/

    final Preference other_apps = getPreferenceManager().findPreference("other_apps");
    other_apps.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Utility.openURL(getActivity(), "https://play.google.com/store/apps/developer?id=Cesarsk+Dev+Team");
            return false;
        }
    });

    final Preference voice_settings = getPreferenceManager().findPreference("tts_settings");
    voice_settings.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent = new Intent();
            intent.setAction("com.android.settings.TTS_SETTINGS");
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
            return false;
        }
    });

    // compute your public key and store it in base64EncodedPublicKey
    mHelper = new IabHelper(getActivity(), LCSecurity.base64EncodedPublicKey);
    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
        public void onIabSetupFinished(IabResult result) {
            if (!result.isSuccess()) {
                // Oh no, there was a problem.
                if (MainActivity.isLoggingEnabled)
                    Log.d("Say It!", "Problem setting up In-app Billing: " + result);
            }
            // Hooray, IAB is fully set up!
            if (MainActivity.isLoggingEnabled)
                Log.d("Say It!", "Hooray. IAB is fully set up!" + result);
        }
    });

    mIabPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
        @Override
        public void onIabPurchaseFinished(IabResult result, Purchase info) {
            if (result.isFailure()) {
                Toast.makeText(getActivity(), "Purchase Failed! Perhaps have you already purchased the item?",
                        Toast.LENGTH_SHORT).show();
            } else if (info.getSku().equals(PlayActivity.no_ads_in_app)) {
                UtilitySharedPrefs.loadAdsStatus(getActivity());
                UtilitySharedPrefs.savePrefs(getActivity(), true, MainActivity.NO_ADS_STATUS_KEY);
            }
        }
    };

    mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
        public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
            if (result.isFailure()) {
                if (MainActivity.isLoggingEnabled)
                    Toast.makeText(getActivity(), "Query Failed!", Toast.LENGTH_SHORT).show();
                return;
            }

            //Open Purchase Dialog
            try {
                mHelper.flagEndAsync();
                mHelper.launchPurchaseFlow(getActivity(), PlayActivity.no_ads_in_app, 64000,
                        mIabPurchaseFinishedListener);
            } catch (IabHelper.IabAsyncInProgressException e) {
                e.printStackTrace();
            }
        }
    };

    final Preference remove_ads = getPreferenceManager().findPreference("remove_ads");
    if (MainActivity.NO_ADS) {
        remove_ads.setEnabled(false);
        remove_ads.setSummary("Thank you for supporting us ?");
    } else {
        remove_ads.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                //helper to remove ads
                List<String> additionalSkuList = new ArrayList<>();
                additionalSkuList.add(PlayActivity.no_ads_in_app);
                try {
                    mHelper.flagEndAsync();
                    mHelper.queryInventoryAsync(true, additionalSkuList, mQueryFinishedListener);
                } catch (IabHelper.IabAsyncInProgressException e) {
                    e.printStackTrace();
                }
                return false;
            }
        });
    }

    final Preference reset_tutorial = getPreferenceManager().findPreference("reset_showcase");
    reset_tutorial.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Random rand = new Random();
            int randomNum = rand.nextInt((10000 - 10) + 1) + 10; //(max - min) + 1 + min
            MainActivity.id_showcase_playactivity = "" + randomNum;
            Toast.makeText(getActivity(), "Tutorial has been reset", Toast.LENGTH_SHORT).show();
            //MainActivity.id_showcase_fragments = "" + randomNum2;
            //int randomNum2 = rand.nextInt((10000 - 10) + 1) + 10; //(max - min) + 1 + min //These two statements are commented because MaterialShowCase often crashes on fragments and while pressing the back button.
            return false;
        }
    });

    //setting an own Alert Dialog's title color
    final Spannable title = new SpannableString("Delete Recordings");
    title.setSpan(new ForegroundColorSpan(Color.DKGRAY), 0, title.length(), 0);
    final Spannable message = new SpannableString("Are you sure you want to delete all recordings?");
    message.setSpan(new ForegroundColorSpan(Color.GRAY), 0, message.length(), 0);

    final Preference delete_recordings = getPreferenceManager().findPreference("delete_recordings");
    delete_recordings.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            new AlertDialog.Builder(getActivity()).setTitle(title).setMessage(message)
                    .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            Utility.delete_recordings(getActivity());
                            Toast.makeText(getActivity(), "Recordings deleted!", Toast.LENGTH_SHORT).show();
                        }
                    }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            //do nothing
                        }
                    }).show();
            return true;
        }
    });

    final ListPreference button_vibration = (ListPreference) getPreferenceManager()
            .findPreference("button_vibration");
    button_vibration.setSummary(button_vibration.getEntry());
    final Spannable default_vibration_settings_title = new SpannableString("Vibration Settings");
    default_vibration_settings_title.setSpan(new ForegroundColorSpan(Color.DKGRAY), 0,
            default_vibration_settings_title.length(), 0);
    button_vibration.setDialogTitle(default_vibration_settings_title);

    button_vibration.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            String new_value = newValue.toString();
            index_default_vibration = button_vibration.findIndexOfValue(new_value);
            CharSequence[] entries = button_vibration.getEntries();
            UtilitySharedPrefs.savePrefs(getActivity(), new_value, MainActivity.DEFAULT_VIBRATION_KEY);
            button_vibration
                    .setSummary(button_vibration.getEntries()[button_vibration.findIndexOfValue(new_value)]);
            Toast.makeText(getActivity(), String.valueOf(entries[index_default_vibration]), Toast.LENGTH_SHORT)
                    .show();
            UtilitySharedPrefs.loadSettingsPrefs(context);
            return true;
        }
    });

    final ListPreference default_accent = (ListPreference) getPreferenceManager()
            .findPreference("default_accent");
    default_accent.setSummary(default_accent.getEntry());
    final Spannable default_accent_title = new SpannableString("Default Accent");
    default_accent_title.setSpan(new ForegroundColorSpan(Color.DKGRAY), 0, default_accent_title.length(), 0);
    default_accent.setDialogTitle(default_accent_title);

    default_accent.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            String new_value = newValue.toString();
            index_default_accent = default_accent.findIndexOfValue(new_value);
            CharSequence[] entries = default_accent.getEntries();

            UtilitySharedPrefs.savePrefs(getActivity(), new_value, MainActivity.DEFAULT_ACCENT_KEY);
            default_accent.setSummary(default_accent.getEntries()[default_accent.findIndexOfValue(new_value)]);
            //Toast.makeText(getActivity(), String.valueOf(entries[index_default_accent]), Toast.LENGTH_SHORT).show();
            UtilitySharedPrefs.loadSettingsPrefs(context);
            return true;
        }
    });

    final ListPreference theme_selector = (ListPreference) getPreferenceManager()
            .findPreference("theme_selector");
    final Spannable theme_selector_title = new SpannableString("Theme");
    theme_selector_title.setSpan(new ForegroundColorSpan(Color.DKGRAY), 0, theme_selector_title.length(), 0);
    theme_selector.setDialogTitle(theme_selector_title);

    theme_selector.setSummary(theme_selector.getEntry());

    theme_selector.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            String new_value = newValue.toString();
            index_default_theme = theme_selector.findIndexOfValue(new_value);
            CharSequence[] entries = theme_selector.getEntries();
            UtilitySharedPrefs.savePrefs(getActivity(), new_value, MainActivity.DEFAULT_THEME_KEY);
            theme_selector.setSummary(theme_selector.getEntries()[theme_selector.findIndexOfValue(new_value)]);
            //Toast.makeText(getActivity(), String.valueOf(entries[index_default_theme]), Toast.LENGTH_SHORT).show();
            UtilitySharedPrefs.loadSettingsPrefs(context);
            Toast.makeText(getActivity(), "Done! Reboot to see changes.", Toast.LENGTH_SHORT).show();
            return true;
        }
    });

    Preference acknowledgements = getPreferenceManager().findPreference("acknowledgements");
    acknowledgements.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            final Intent preference_intent = new Intent(getActivity(), FileTextActivity.class);
            Bundle args = new Bundle();
            args.putString(FileTextActivity.PREFERENCE, "acknowledgements");
            preference_intent.putExtras(args);
            startActivity(preference_intent,
                    ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle());
            return false;
        }
    });

    app_version.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Utility.openURL(getActivity(), "https://lucacesaranoblog.wordpress.com/2017/04/18/privacy-policy/");
            return false;
        }
    });
}