Search in sources :

Example 41 with ListPreference

use of android.preference.ListPreference in project Taskbar by farmerbb.

the class RecentAppsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    finishedLoadingPrefs = false;
    super.onCreate(savedInstanceState);
    // Add preferences
    addPreferencesFromResource(R.xml.pref_recent_apps);
    // Set OnClickListeners for certain preferences
    findPreference("enable_recents").setOnPreferenceClickListener(this);
    findPreference("max_num_of_recents").setOnPreferenceClickListener(this);
    findPreference("refresh_frequency").setOnPreferenceClickListener(this);
    if (showRunningAppsOnly()) {
        ListPreference recentsAmountPref = ((ListPreference) findPreference("recents_amount"));
        recentsAmountPref.setEntries(getResources().getStringArray(R.array.pref_recents_amount_alt));
        recentsAmountPref.setEntryValues(getResources().getStringArray(R.array.pref_recents_amount_values_alt));
        SharedPreferences pref = U.getSharedPreferences(getActivity());
        if (pref.getString("recents_amount", "past_day").equals("running_apps_only")) {
            ListPreference sortOrderPref = ((ListPreference) findPreference("sort_order"));
            sortOrderPref.setEntries(getResources().getStringArray(R.array.pref_sort_order_alt));
            sortOrderPref.setEntryValues(getResources().getStringArray(R.array.pref_sort_order_values_alt));
        }
    }
    bindPreferenceSummaryToValue(findPreference("recents_amount"));
    bindPreferenceSummaryToValue(findPreference("sort_order"));
    bindPreferenceSummaryToValue(findPreference("disable_scrolling_list"));
    bindPreferenceSummaryToValue(findPreference("full_length"));
    updateMaxNumOfRecents(false);
    updateRefreshFrequency(false);
    finishedLoadingPrefs = true;
}
Also used : SharedPreferences(android.content.SharedPreferences) ListPreference(android.preference.ListPreference)

Example 42 with ListPreference

use of android.preference.ListPreference in project PhoneProfilesPlus by henrichg.

the class EventPreferencesBluetooth method setSummary.

@Override
void setSummary(PreferenceManager prefMng, String key, String value, Context context) {
    if (key.equals(PREF_EVENT_BLUETOOTH_APP_SETTINGS)) {
        Preference preference = prefMng.findPreference(key);
        if (preference != null) {
            if (!ApplicationPreferences.applicationEventBluetoothEnableScannig(context))
                preference.setSummary(context.getResources().getString(R.string.phone_profiles_pref_applicationEventScanningDisabled) + "\n" + context.getResources().getString(R.string.phone_profiles_pref_eventBluetoothAppSettings_summary));
            else
                preference.setSummary(context.getResources().getString(R.string.phone_profiles_pref_eventBluetoothAppSettings_summary));
        }
    }
    if (key.equals(PREF_EVENT_BLUETOOTH_ADAPTER_NAME)) {
        Preference preference = prefMng.findPreference(key);
        if (preference != null) {
            /*if (!ApplicationPreferences.applicationEventBluetoothEnableScannig(context.getApplicationContext())) {
                    preference.setSummary(context.getResources().getString(R.string.profile_preferences_device_not_allowed)+
                            ": "+context.getResources().getString(R.string.preference_not_allowed_reason_not_enabled_scanning));
                }
                else {*/
            String[] splits = value.split("\\|");
            for (String _bluetoothName : splits) {
                if (_bluetoothName.isEmpty()) {
                    preference.setSummary(R.string.applications_multiselect_summary_text_not_selected);
                } else if (splits.length == 1) {
                    if (value.equals(ALL_BLUETOOTH_NAMES_VALUE))
                        preference.setSummary(R.string.bluetooth_name_pref_dlg_all_bt_names_chb);
                    else if (value.equals(CONFIGURED_BLUETOOTH_NAMES_VALUE))
                        preference.setSummary(R.string.bluetooth_name_pref_dlg_configured_bt_names_chb);
                    else
                        preference.setSummary(_bluetoothName);
                } else {
                    String selectedBluetoothNames = context.getString(R.string.applications_multiselect_summary_text_selected);
                    selectedBluetoothNames = selectedBluetoothNames + " " + splits.length;
                    preference.setSummary(selectedBluetoothNames);
                    break;
                }
            }
            // }
            GlobalGUIRoutines.setPreferenceTitleStyle(preference, false, true, false, false);
        }
    }
    if (key.equals(PREF_EVENT_BLUETOOTH_CONNECTION_TYPE)) {
        ListPreference listPreference = (ListPreference) prefMng.findPreference(key);
        if (listPreference != null) {
            int index = listPreference.findIndexOfValue(value);
            CharSequence summary = (index >= 0) ? listPreference.getEntries()[index] : null;
            listPreference.setSummary(summary);
        }
        boolean btLESupported = WifiBluetoothScanner.bluetoothLESupported(context);
        listPreference = (ListPreference) prefMng.findPreference(PREF_EVENT_BLUETOOTH_DEVICES_TYPE);
        if (listPreference != null) {
            if ((!btLESupported) || value.equals("0") || value.equals("2"))
                listPreference.setEnabled(false);
            else
                listPreference.setEnabled(true);
        }
    }
    if (key.equals(PREF_EVENT_BLUETOOTH_DEVICES_TYPE)) {
        ListPreference listPreference = (ListPreference) prefMng.findPreference(key);
        if (listPreference != null) {
            boolean btLESupported = WifiBluetoothScanner.bluetoothLESupported(context);
            if (!btLESupported) {
                listPreference.setSummary(context.getString(R.string.profile_preferences_device_not_allowed) + ": " + context.getString(R.string.preference_not_allowed_reason_no_hardware));
            } else {
                int index = listPreference.findIndexOfValue(value);
                CharSequence summary = (index >= 0) ? listPreference.getEntries()[index] : null;
                listPreference.setSummary(summary);
            }
        }
    }
}
Also used : ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) ListPreference(android.preference.ListPreference)

Example 43 with ListPreference

use of android.preference.ListPreference in project PhoneProfilesPlus by henrichg.

the class EventPreferencesCall method setSummary.

@Override
void setSummary(PreferenceManager prefMng, String key, String value, Context context) {
    if (key.equals(PREF_EVENT_CALL_EVENT) || key.equals(PREF_EVENT_CALL_CONTACT_LIST_TYPE)) {
        ListPreference listPreference = (ListPreference) prefMng.findPreference(key);
        if (listPreference != null) {
            int index = listPreference.findIndexOfValue(value);
            CharSequence summary = (index >= 0) ? listPreference.getEntries()[index] : null;
            listPreference.setSummary(summary);
        }
    }
    if (key.equals(PREF_EVENT_CALL_CONTACTS)) {
        Preference preference = prefMng.findPreference(key);
        if (preference != null) {
            GlobalGUIRoutines.setPreferenceTitleStyle(preference, false, true, false, false);
        }
    }
    if (key.equals(PREF_EVENT_CALL_CONTACT_GROUPS)) {
        Preference preference = prefMng.findPreference(key);
        if (preference != null) {
            GlobalGUIRoutines.setPreferenceTitleStyle(preference, false, true, false, false);
        }
    }
    if (key.equals(PREF_EVENT_CALL_EVENT)) {
        ListPreference listPreference = (ListPreference) prefMng.findPreference(key);
        if (listPreference != null) {
            Preference preferenceDuration = prefMng.findPreference(PREF_EVENT_CALL_DURATION);
            Preference preferencePermanentRun = prefMng.findPreference(PREF_EVENT_CALL_PERMANENT_RUN);
            if (preferenceDuration != null) {
                boolean enabled = value.equals(String.valueOf(CALL_EVENT_MISSED_CALL));
                SharedPreferences preferences = prefMng.getSharedPreferences();
                enabled = enabled && !preferences.getBoolean(PREF_EVENT_CALL_PERMANENT_RUN, false);
                preferenceDuration.setEnabled(enabled);
            }
            if (preferencePermanentRun != null)
                preferencePermanentRun.setEnabled(value.equals(String.valueOf(CALL_EVENT_MISSED_CALL)));
        }
    }
    if (key.equals(PREF_EVENT_CALL_PERMANENT_RUN)) {
        SharedPreferences preferences = prefMng.getSharedPreferences();
        if (!preferences.getString(PREF_EVENT_CALL_EVENT, "-1").equals(String.valueOf(CALL_EVENT_MISSED_CALL))) {
            Preference preference = prefMng.findPreference(PREF_EVENT_CALL_DURATION);
            if (preference != null) {
                preference.setEnabled(false);
            }
        } else {
            Preference preference = prefMng.findPreference(PREF_EVENT_CALL_DURATION);
            if (preference != null) {
                preference.setEnabled(value.equals("false"));
            }
        }
    }
}
Also used : ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) SharedPreferences(android.content.SharedPreferences) ListPreference(android.preference.ListPreference) SuppressLint(android.annotation.SuppressLint)

Example 44 with ListPreference

use of android.preference.ListPreference in project PhoneProfilesPlus by henrichg.

the class EventPreferencesOrientation method setSummary.

@Override
void setSummary(PreferenceManager prefMng, String key, String value, Context context) {
    if (key.equals(PREF_EVENT_ORIENTATION_APP_SETTINGS)) {
        Preference preference = prefMng.findPreference(key);
        if (preference != null) {
            if (!ApplicationPreferences.applicationEventOrientationEnableScannig(context))
                preference.setSummary(context.getResources().getString(R.string.phone_profiles_pref_applicationEventScanningDisabled) + "\n" + context.getResources().getString(R.string.phone_profiles_pref_eventOrientationAppSettings_summary));
            else
                preference.setSummary(context.getResources().getString(R.string.phone_profiles_pref_eventOrientationAppSettings_summary));
        }
    }
    if (key.equals(PREF_EVENT_ORIENTATION_DISPLAY)) {
        Preference preference = prefMng.findPreference(key);
        if (preference != null) {
            preference.setSummary(value);
            GlobalGUIRoutines.setPreferenceTitleStyle(preference, false, true, false, false);
        }
    }
    if (key.equals(PREF_EVENT_ORIENTATION_SIDES)) {
        Preference preference = prefMng.findPreference(key);
        if (preference != null) {
            preference.setSummary(value);
            GlobalGUIRoutines.setPreferenceTitleStyle(preference, false, true, false, false);
        }
    }
    if (key.equals(PREF_EVENT_ORIENTATION_DISTANCE)) {
        ListPreference listPreference = (ListPreference) prefMng.findPreference(key);
        if (listPreference != null) {
            int index = listPreference.findIndexOfValue(value);
            CharSequence summary = (index >= 0) ? listPreference.getEntries()[index] : null;
            listPreference.setSummary(summary);
        }
    // GlobalGUIRoutines.setPreferenceTitleStyle(listPreference, false, true, false);
    }
    if (key.equals(PREF_EVENT_ORIENTATION_INSTALL_EXTENDER)) {
        Preference preference = prefMng.findPreference(key);
        if (preference != null) {
            int extenderVersion = AccessibilityServiceBroadcastReceiver.isExtenderInstalled(context);
            if (extenderVersion == 0)
                preference.setSummary(R.string.event_preferences_orientation_PPPExtender_install_summary);
            else if (extenderVersion < PPApplication.VERSION_CODE_EXTENDER)
                preference.setSummary(R.string.event_preferences_applications_PPPExtender_new_version_summary);
            else
                preference.setSummary(R.string.event_preferences_applications_PPPExtender_upgrade_summary);
        }
    }
    if (key.equals(PREF_EVENT_ORIENTATION_IGNORED_APPLICATIONS)) {
        Preference preference = prefMng.findPreference(key);
        GlobalGUIRoutines.setPreferenceTitleStyle(preference, false, false, false, true);
    }
}
Also used : ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) ListPreference(android.preference.ListPreference)

Example 45 with ListPreference

use of android.preference.ListPreference in project PhoneProfilesPlus by henrichg.

the class EventPreferencesScreen method setSummary.

@Override
void setSummary(PreferenceManager prefMng, String key, String value, Context context) {
    if (key.equals(PREF_EVENT_SCREEN_EVENT_TYPE)) {
        ListPreference listPreference = (ListPreference) prefMng.findPreference(key);
        if (listPreference != null) {
            int index = listPreference.findIndexOfValue(value);
            CharSequence summary = (index >= 0) ? listPreference.getEntries()[index] : null;
            listPreference.setSummary(summary);
        }
    }
}
Also used : ListPreference(android.preference.ListPreference)

Aggregations

ListPreference (android.preference.ListPreference)152 Preference (android.preference.Preference)76 CheckBoxPreference (android.preference.CheckBoxPreference)47 EditTextPreference (android.preference.EditTextPreference)32 PreferenceScreen (android.preference.PreferenceScreen)20 ArrayList (java.util.ArrayList)18 SharedPreferences (android.content.SharedPreferences)17 Intent (android.content.Intent)14 PreferenceCategory (android.preference.PreferenceCategory)14 SuppressLint (android.annotation.SuppressLint)13 MultiSelectListPreference (android.preference.MultiSelectListPreference)8 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)8 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)8 File (java.io.File)8 Bundle (android.os.Bundle)7 SwitchPreference (android.preference.SwitchPreference)7 View (android.view.View)7 Context (android.content.Context)6 DialogInterface (android.content.DialogInterface)6 RingtonePreference (android.preference.RingtonePreference)6