Example usage for android.preference PreferenceActivity findPreference

List of usage examples for android.preference PreferenceActivity findPreference

Introduction

In this page you can find the example usage for android.preference PreferenceActivity findPreference.

Prototype

@Deprecated
public Preference findPreference(CharSequence key) 

Source Link

Document

Finds a Preference based on its key.

Usage

From source file:Main.java

@SuppressWarnings("deprecation")
public static Preference findPreference(PreferenceActivity activity, CharSequence key) {
    return activity.findPreference(key);
}

From source file:paulscode.android.mupen64plusae.util.PrefUtil.java

@SuppressWarnings("deprecation")
public static void enablePreference(PreferenceActivity activity, String key, boolean enabled) {
    Preference preference = activity.findPreference(key);
    if (preference != null)
        preference.setEnabled(enabled);// www.ja v a  2 s  . com
}

From source file:paulscode.android.mupen64plusae.util.PrefUtil.java

@SuppressWarnings("deprecation")
public static void removePreference(PreferenceActivity activity, String keyParent, String keyChild) {
    Preference parent = activity.findPreference(keyParent);
    Preference child = activity.findPreference(keyChild);
    if (parent instanceof PreferenceGroup && child != null)
        ((PreferenceGroup) parent).removePreference(child);
}

From source file:paulscode.android.mupen64plusae.util.PrefUtil.java

@SuppressWarnings("deprecation")
public static void setOnPreferenceClickListener(PreferenceActivity activity, String key,
        OnPreferenceClickListener listener) {
    Preference preference = activity.findPreference(key);
    if (preference != null)
        preference.setOnPreferenceClickListener(listener);
}

From source file:com.quarterfull.newsAndroid.SettingsActivity.java

private static void bindNotificationPreferences(PreferenceFragment prefFrag, PreferenceActivity prefAct) {
    if (prefFrag != null) {
        bindPreferenceBooleanToValue(prefFrag.findPreference(CB_SHOW_NOTIFICATION_NEW_ARTICLES_STRING));
    } else {// w w w  .  j a va2 s  .c o m
        bindPreferenceBooleanToValue(prefAct.findPreference(CB_SHOW_NOTIFICATION_NEW_ARTICLES_STRING));
    }
}

From source file:com.quarterfull.newsAndroid.SettingsActivity.java

@SuppressWarnings("deprecation")
private static void bindDisplayPreferences(PreferenceFragment prefFrag, PreferenceActivity prefAct) {
    if (prefFrag != null) {
        bindPreferenceSummaryToValue(prefFrag.findPreference(SP_APP_THEME));
        bindPreferenceSummaryToValue(prefFrag.findPreference(SP_FEED_LIST_LAYOUT));
        bindPreferenceSummaryToValue(prefFrag.findPreference(SP_TITLE_LINES_COUNT));
    } else {//from w  w w.j  a v a2s. c o  m
        bindPreferenceSummaryToValue(prefAct.findPreference(SP_APP_THEME));
        bindPreferenceSummaryToValue(prefAct.findPreference(SP_FEED_LIST_LAYOUT));
        bindPreferenceSummaryToValue(prefAct.findPreference(SP_TITLE_LINES_COUNT));
    }
}

From source file:de.luhmer.owncloudnewsreader.SettingsActivity.java

@SuppressWarnings("deprecation")
private static void bindDataSyncPreferences(PreferenceFragment prefFrag, PreferenceActivity prefAct) {
    String[] authorities = { "de.luhmer.owncloudnewsreader" };
    Intent intentSyncSettings = new Intent(Settings.ACTION_SYNC_SETTINGS);
    intentSyncSettings.putExtra(Settings.EXTRA_AUTHORITIES, authorities);

    if (prefFrag != null) {
        prefFrag.findPreference(PREF_SYNC_SETTINGS).setIntent(intentSyncSettings);
        //bindPreferenceSummaryToValue(prefFrag.findPreference(SP_MAX_ITEMS_SYNC));
        clearCachePref = (EditTextPreference) prefFrag.findPreference(EDT_CLEAR_CACHE);
        bindPreferenceSummaryToValue(prefFrag.findPreference(LV_CACHE_IMAGES_OFFLINE_STRING));
        bindPreferenceSummaryToValue(prefFrag.findPreference(SP_MAX_CACHE_SIZE));
    } else {//from w  w w  .  j a  v  a2s  .  c o m
        prefAct.findPreference(PREF_SYNC_SETTINGS).setIntent(intentSyncSettings);
        //bindPreferenceSummaryToValue(prefAct.findPreference(SP_MAX_ITEMS_SYNC));
        clearCachePref = (EditTextPreference) prefAct.findPreference(EDT_CLEAR_CACHE);
        bindPreferenceSummaryToValue(prefAct.findPreference(LV_CACHE_IMAGES_OFFLINE_STRING));
        bindPreferenceSummaryToValue(prefAct.findPreference(SP_MAX_CACHE_SIZE));

    }

    clearCachePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {

            ((EditTextPreference) preference).getDialog().dismiss();

            checkForUnsycedChangesInDatabaseAndResetDatabase(_mActivity);
            return false;
        }
    });
}

From source file:com.quarterfull.newsAndroid.SettingsActivity.java

@SuppressWarnings("deprecation")
private static void bindDataSyncPreferences(PreferenceFragment prefFrag, PreferenceActivity prefAct) {
    String[] authorities = { "com.quarterfull.newsAndroid" };
    Intent intentSyncSettings = new Intent(Settings.ACTION_SYNC_SETTINGS);
    intentSyncSettings.putExtra(Settings.EXTRA_AUTHORITIES, authorities);

    if (prefFrag != null) {
        prefFrag.findPreference(PREF_SYNC_SETTINGS).setIntent(intentSyncSettings);
        //bindPreferenceSummaryToValue(prefFrag.findPreference(SP_MAX_ITEMS_SYNC));
        clearCachePref = (EditTextPreference) prefFrag.findPreference(EDT_CLEAR_CACHE);
        bindPreferenceSummaryToValue(prefFrag.findPreference(LV_CACHE_IMAGES_OFFLINE_STRING));
        bindPreferenceSummaryToValue(prefFrag.findPreference(SP_MAX_CACHE_SIZE));
    } else {/*from  w  ww .j  av a  2  s  .  c  o m*/
        prefAct.findPreference(PREF_SYNC_SETTINGS).setIntent(intentSyncSettings);
        //bindPreferenceSummaryToValue(prefAct.findPreference(SP_MAX_ITEMS_SYNC));
        clearCachePref = (EditTextPreference) prefAct.findPreference(EDT_CLEAR_CACHE);
        bindPreferenceSummaryToValue(prefAct.findPreference(LV_CACHE_IMAGES_OFFLINE_STRING));
        bindPreferenceSummaryToValue(prefAct.findPreference(SP_MAX_CACHE_SIZE));

    }

    clearCachePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {

            ((EditTextPreference) preference).getDialog().dismiss();

            checkForUnsycedChangesInDatabaseAndResetDatabase(_mActivity);
            return false;
        }
    });
}

From source file:com.quarterfull.newsAndroid.SettingsActivity.java

@SuppressWarnings("deprecation")
private static void bindGeneralPreferences(PreferenceFragment prefFrag, final PreferenceActivity prefAct) {
    if (prefFrag != null) {
        /*/*w  w  w  .  j  a  v  a  2  s . c om*/
        bindPreferenceSummaryToValue(prefFrag.findPreference(EDT_USERNAME_STRING));
        bindPreferenceSummaryToValue(prefFrag.findPreference(EDT_PASSWORD_STRING));
        bindPreferenceSummaryToValue(prefFrag.findPreference(EDT_OWNCLOUDROOTPATH_STRING));
         */
        //bindPreferenceBooleanToValue(prefFrag.findPreference(CB_ALLOWALLSSLCERTIFICATES_STRING));
        bindPreferenceBooleanToValue(prefFrag.findPreference(CB_SYNCONSTARTUP_STRING));
        bindPreferenceBooleanToValue(prefFrag.findPreference(CB_SHOWONLYUNREAD_STRING));
        bindPreferenceBooleanToValue(prefFrag.findPreference(CB_NAVIGATE_WITH_VOLUME_BUTTONS_STRING));
        bindPreferenceBooleanToValue(prefFrag.findPreference(CB_MARK_AS_READ_WHILE_SCROLLING_STRING));
        bindPreferenceBooleanToValue(
                prefFrag.findPreference(CB_SKIP_DETAILVIEW_AND_OPEN_BROWSER_DIRECTLY_STRING));
        bindPreferenceSummaryToValue(prefFrag.findPreference(SP_SORT_ORDER));
    } else {
        /*
        bindPreferenceSummaryToValue(prefAct.findPreference(EDT_USERNAME_STRING));
        bindPreferenceSummaryToValue(prefAct.findPreference(EDT_PASSWORD_STRING));
        bindPreferenceSummaryToValue(prefAct.findPreference(EDT_OWNCLOUDROOTPATH_STRING));
        */
        //bindPreferenceBooleanToValue(prefAct.findPreference(CB_ALLOWALLSSLCERTIFICATES_STRING));
        bindPreferenceBooleanToValue(prefAct.findPreference(CB_SYNCONSTARTUP_STRING));
        bindPreferenceBooleanToValue(prefAct.findPreference(CB_SHOWONLYUNREAD_STRING));
        bindPreferenceBooleanToValue(prefAct.findPreference(CB_NAVIGATE_WITH_VOLUME_BUTTONS_STRING));
        bindPreferenceBooleanToValue(prefAct.findPreference(CB_MARK_AS_READ_WHILE_SCROLLING_STRING));
        bindPreferenceBooleanToValue(
                prefAct.findPreference(CB_SKIP_DETAILVIEW_AND_OPEN_BROWSER_DIRECTLY_STRING));
        bindPreferenceSummaryToValue(prefAct.findPreference(SP_SORT_ORDER));
    }
}