Search in sources :

Example 66 with ListPreference

use of android.preference.ListPreference in project Xposed-Tinted-Status-Bar by MohammadAG.

the class SettingsActivity method onPostCreate.

@SuppressWarnings({ "deprecation" })
@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    getPreferenceManager().setSharedPreferencesMode(MODE_WORLD_READABLE);
    addPreferencesFromResource(R.xml.pref_general);
    Preference copyrightPreference = findPreference("copyright_key");
    copyrightPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            AlertDialog.Builder builder = new AlertDialog.Builder(SettingsActivity.this);
            builder.setTitle("").setItems(R.array.my_apps, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    Uri uri = null;
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    switch(which) {
                        case 0:
                            uri = Uri.parse(URL_MY_APPS);
                            intent.setPackage("com.android.vending");
                            break;
                        case 1:
                            uri = Uri.parse(URL_MY_MODULES);
                            break;
                        case 2:
                            uri = Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KGGZ5C3AVC8ZU");
                            break;
                    }
                    startActivity(intent.setData(uri));
                }
            });
            builder.create().show();
            return false;
        }
    });
    Preference donatePreference = findPreference("donate_key");
    donatePreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference arg0) {
            Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(URL_DONATION_PACKAGE));
            intent.setPackage("com.android.vending");
            startActivity(intent);
            return false;
        }
    });
    if (Utils.isDonateVersionInstalled(getApplicationContext())) {
        copyrightPreference.setTitle(R.string.app_name_donate_version);
        donatePreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                Toast.makeText(SettingsActivity.this, R.string.thank_you, Toast.LENGTH_SHORT).show();
                return false;
            }
        });
        donatePreference.setTitle(R.string.thank_you);
        donatePreference.setSummary(R.string.thank_you_summary);
    }
    String[] colorKeys = { SettingsKeys.DEFAULT_STATUS_BAR_TINT, SettingsKeys.DEFAULT_STATUS_BAR_ICON_TINT, SettingsKeys.DEFAULT_STATUS_BAR_INVERTED_ICON_TINT, SettingsKeys.DEFAULT_NAV_BAR_TINT, SettingsKeys.DEFAULT_NAV_BAR_ICON_TINT, SettingsKeys.DEFAULT_NAV_BAR_IM_TINT, SettingsKeys.DEFAULT_NAV_BAR_ICON_IM_TINT };
    intializeColorPreferences(colorKeys);
    findPreference(SettingsKeys.LINK_PANEL_VIEW_COLORS).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            sendBroadcast(new Intent(Common.INTENT_SETTINGS_UPDATED));
            return true;
        }
    });
    ListPreference overlayTypePreference = (ListPreference) findPreference("pref_overlay_type");
    final Preference overlayTransparencyPreference = findPreference("pref_semi_transparent_overlay_opacity");
    if (overlayTypePreference.getValue().equals("semi_transparent"))
        overlayTransparencyPreference.setEnabled(true);
    overlayTypePreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (newValue.equals("semi_transparent"))
                overlayTransparencyPreference.setEnabled(true);
            else
                overlayTransparencyPreference.setEnabled(false);
            return true;
        }
    });
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener) ListPreference(android.preference.ListPreference) Uri(android.net.Uri) OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) ListPreference(android.preference.ListPreference) ColorPreference(com.mohammadag.colouredstatusbar.preferences.ColorPreference) Preference(android.preference.Preference)

Example 67 with ListPreference

use of android.preference.ListPreference in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class AdvancedSettingsFragment method onCreate.

@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.prefs_screen_advanced);
    final Resources res = getResources();
    final Context context = getActivity();
    // When we are called from the Settings application but we are not already running, some
    // singleton and utility classes may not have been initialized.  We have to call
    // initialization method of these classes here. See {@link LatinIME#onCreate()}.
    AudioAndHapticFeedbackManager.init(context);
    final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
    if (!Settings.isInternal(prefs)) {
        removePreference(Settings.SCREEN_DEBUG);
    }
    if (!AudioAndHapticFeedbackManager.getInstance().hasVibrator()) {
        removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS);
    }
    // TODO: consolidate key preview dismiss delay with the key preview animation parameters.
    if (!Settings.readFromBuildConfigIfToShowKeyPreviewPopupOption(res)) {
        removePreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
    } else {
        // TODO: Cleanup this setup.
        final ListPreference keyPreviewPopupDismissDelay = (ListPreference) findPreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
        final String popupDismissDelayDefaultValue = Integer.toString(res.getInteger(R.integer.config_key_preview_linger_timeout));
        keyPreviewPopupDismissDelay.setEntries(new String[] { res.getString(R.string.key_preview_popup_dismiss_no_delay), res.getString(R.string.key_preview_popup_dismiss_default_delay) });
        keyPreviewPopupDismissDelay.setEntryValues(new String[] { "0", popupDismissDelayDefaultValue });
        if (null == keyPreviewPopupDismissDelay.getValue()) {
            keyPreviewPopupDismissDelay.setValue(popupDismissDelayDefaultValue);
        }
        keyPreviewPopupDismissDelay.setEnabled(Settings.readKeyPreviewPopupEnabled(prefs, res));
    }
    setupKeypressVibrationDurationSettings();
    setupKeypressSoundVolumeSettings();
    setupKeyLongpressTimeoutSettings();
    refreshEnablingsOfKeypressSoundAndVibrationSettings();
}
Also used : Context(android.content.Context) SharedPreferences(android.content.SharedPreferences) Resources(android.content.res.Resources) ListPreference(android.preference.ListPreference)

Example 68 with ListPreference

use of android.preference.ListPreference in project MyJapanese by 54wall.

the class SettingFragment method initPreference.

private void initPreference() {
    mUpdatePreference = getPreferenceManager().findPreference("setting_update");
    mUpdatePreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            Log.e(TAG, "mUpdatePreference");
            // 检查自动更新,默认UI
            return false;
        }
    });
    mTTSListPreference = (ListPreference) getPreferenceManager().findPreference("setting_tts");
    mTTSListPreference.setEntries(R.array.tts_entries);
    mTTSListPreference.setEntryValues(R.array.tts_values);
    mTTSListPreference.setValue(tts_type);
    mTTSListPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            SharedPreferenceManager.getInstance().putString(Constants.TTS_TYPE, (String) newValue);
            JpTTSUtils.getInstance().updateTtsType();
            RxBus.getDefault().post(new EventContainer(EventContainer.TYPE_SETTING, new SettingEvent(R.string.setting_effect)));
            return true;
        }
    });
    mThemesListPreference = (ListPreference) getPreferenceManager().findPreference("setting_theme");
    mThemesListPreference.setEntries(R.array.themes_entries);
    mThemesListPreference.setEntryValues(R.array.themes_values);
    mThemesListPreference.setValue(mode_theme);
    mThemesListPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            SharedPreferenceManager.getInstance().putString(Constants.MODE_THEME, (String) newValue);
            RxBus.getDefault().post(new EventContainer(EventContainer.TYPE_SETTING, new SettingEvent(R.string.reboot_to_take_effect)));
            return true;
        }
    });
}
Also used : ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) EventContainer(pri.weiqaing.common.rxbus.event.EventContainer) SettingEvent(pri.weiqaing.common.rxbus.event.SettingEvent)

Example 69 with ListPreference

use of android.preference.ListPreference in project Klyph by jonathangerbaud.

the class PreferencesActivity method refreshInterval.

private void refreshInterval() {
    ListPreference p = (ListPreference) findPreference(KlyphPreferences.PREFERENCE_NOTIFICATIONS_INTERVAL);
    p.setSummary(p.getEntry());
}
Also used : ListPreference(android.preference.ListPreference)

Example 70 with ListPreference

use of android.preference.ListPreference in project Klyph by jonathangerbaud.

the class PreferencesActivity method refreshFbLanguage.

private void refreshFbLanguage() {
    ListPreference p = (ListPreference) findPreference(KlyphPreferences.PREFERENCE_FB_LANGUAGE);
    p.setSummary(p.getEntry());
}
Also used : ListPreference(android.preference.ListPreference)

Aggregations

ListPreference (android.preference.ListPreference)167 Preference (android.preference.Preference)80 CheckBoxPreference (android.preference.CheckBoxPreference)50 EditTextPreference (android.preference.EditTextPreference)35 PreferenceScreen (android.preference.PreferenceScreen)21 SharedPreferences (android.content.SharedPreferences)20 ArrayList (java.util.ArrayList)19 Intent (android.content.Intent)16 PreferenceCategory (android.preference.PreferenceCategory)16 SuppressLint (android.annotation.SuppressLint)13 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)9 MultiSelectListPreference (android.preference.MultiSelectListPreference)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