android.preference.PreferenceGroup Java Examples

The following examples show how to use android.preference.PreferenceGroup. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Settings.java    From SpeedMeter with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.pref_general);

    for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); ++i) {
        Preference preference = getPreferenceScreen().getPreference(i);
        if (preference instanceof PreferenceGroup) {
            PreferenceGroup preferenceGroup = (PreferenceGroup) preference;
            for (int j = 0; j < preferenceGroup.getPreferenceCount(); ++j) {
                updatePreference(preferenceGroup.getPreference(j));
            }
        } else {
            updatePreference(preference);
        }
    }
}
 
Example #2
Source File: CustomInputStyleSettingsFragment.java    From openboard with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onAddCustomInputStyle(final CustomInputStylePreference stylePref) {
    mIsAddingNewSubtype = false;
    final InputMethodSubtype subtype = stylePref.getSubtype();
    if (findDuplicatedSubtype(subtype) == null) {
        mRichImm.setAdditionalInputMethodSubtypes(getSubtypes());
        mSubtypePreferenceKeyForSubtypeEnabler = stylePref.getKey();
        mSubtypeEnablerNotificationDialog = createDialog();
        mSubtypeEnablerNotificationDialog.show();
        return;
    }

    // Newly added subtype is duplicated.
    final PreferenceGroup group = getPreferenceScreen();
    group.removePreference(stylePref);
    showSubtypeAlreadyExistsToast(subtype);
}
 
Example #3
Source File: TwoStatePreferenceHelper.java    From openboard with GNU General Public License v3.0 6 votes vote down vote up
static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox,
        final PreferenceGroup group) {
    final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext());
    switchPref.setTitle(checkBox.getTitle());
    switchPref.setKey(checkBox.getKey());
    switchPref.setOrder(checkBox.getOrder());
    switchPref.setPersistent(checkBox.isPersistent());
    switchPref.setEnabled(checkBox.isEnabled());
    switchPref.setChecked(checkBox.isChecked());
    switchPref.setSummary(checkBox.getSummary());
    switchPref.setSummaryOn(checkBox.getSummaryOn());
    switchPref.setSummaryOff(checkBox.getSummaryOff());
    switchPref.setSwitchTextOn(EMPTY_TEXT);
    switchPref.setSwitchTextOff(EMPTY_TEXT);
    group.addPreference(switchPref);
    switchPref.setDependency(checkBox.getDependency());
}
 
Example #4
Source File: TwoStatePreferenceHelper.java    From openboard with GNU General Public License v3.0 6 votes vote down vote up
private static void replaceAllCheckBoxPreferencesBySwitchPreferences(
        final PreferenceGroup group) {
    final ArrayList<Preference> preferences = new ArrayList<>();
    final int count = group.getPreferenceCount();
    for (int index = 0; index < count; index++) {
        preferences.add(group.getPreference(index));
    }
    group.removeAll();
    for (int index = 0; index < count; index++) {
        final Preference preference = preferences.get(index);
        if (preference instanceof CheckBoxPreference) {
            addSwitchPreferenceBasedOnCheckBoxPreference((CheckBoxPreference)preference, group);
        } else {
            group.addPreference(preference);
            if (preference instanceof PreferenceGroup) {
                replaceAllCheckBoxPreferencesBySwitchPreferences((PreferenceGroup)preference);
            }
        }
    }
}
 
Example #5
Source File: AbstractChanModule.java    From Overchan-Android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Добавить в группу параметров (на экран/в категорию) параметр задания пароля для удаления постов/файлов
 * @param group группа, на которую добавляется параметр
 */
protected void addPasswordPreference(PreferenceGroup group) {
    final Context context = group.getContext();
    EditTextPreference passwordPref = new EditTextPreference(context) {
        @Override
        protected void showDialog(Bundle state) {
            if (createPassword()) {
                setText(getDefaultPassword());
            }
            super.showDialog(state);
        }
    };
    passwordPref.setTitle(R.string.pref_password_title);
    passwordPref.setDialogTitle(R.string.pref_password_title);
    passwordPref.setSummary(R.string.pref_password_summary);
    passwordPref.setKey(getSharedKey(PREF_KEY_PASSWORD));
    passwordPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
    passwordPref.getEditText().setSingleLine();
    passwordPref.getEditText().setFilters(new InputFilter[] { new InputFilter.LengthFilter(255) });
    group.addPreference(passwordPref);
}
 
Example #6
Source File: TwoStatePreferenceHelper.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox,
        final PreferenceGroup group) {
    final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext());
    switchPref.setTitle(checkBox.getTitle());
    switchPref.setKey(checkBox.getKey());
    switchPref.setOrder(checkBox.getOrder());
    switchPref.setPersistent(checkBox.isPersistent());
    switchPref.setEnabled(checkBox.isEnabled());
    switchPref.setChecked(checkBox.isChecked());
    switchPref.setSummary(checkBox.getSummary());
    switchPref.setSummaryOn(checkBox.getSummaryOn());
    switchPref.setSummaryOff(checkBox.getSummaryOff());
    switchPref.setSwitchTextOn(EMPTY_TEXT);
    switchPref.setSwitchTextOff(EMPTY_TEXT);
    group.addPreference(switchPref);
    switchPref.setDependency(checkBox.getDependency());
}
 
Example #7
Source File: GameSettingsActivity.java    From opensudoku with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    ThemeUtils.setThemeFromPreferences(this);
    mTimestampWhenApplyingTheme = System.currentTimeMillis();
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.game_settings);

    findPreference("show_hints").setOnPreferenceChangeListener(mShowHintsChanged);
    findPreference("theme").setOnPreferenceChangeListener(((preference, newValue) -> { recreate(); return true; }));

    ListPreference themePreference = (ListPreference) findPreference("theme");
    mScreenCustomTheme = (PreferenceGroup)findPreference("screen_custom_theme");
    enableScreenCustomTheme(themePreference.getValue());
    mScreenCustomTheme.setOnPreferenceChangeListener((preference, newValue) -> { recreate(); return true; });

    mHighlightSimilarNotesPreference = (CheckBoxPreference)findPreference("highlight_similar_notes");
    CheckBoxPreference highlightSimilarCellsPreference = (CheckBoxPreference)findPreference("highlight_similar_cells");
    highlightSimilarCellsPreference.setOnPreferenceChangeListener(mHighlightSimilarCellsChanged);
    mHighlightSimilarNotesPreference.setEnabled(highlightSimilarCellsPreference.isChecked());
}
 
Example #8
Source File: AutofillPreferences.java    From delion with Apache License 2.0 6 votes vote down vote up
private void rebuildCreditCardList() {
    PreferenceGroup profileCategory =
            (PreferenceGroup) findPreference(PREF_AUTOFILL_CREDIT_CARDS);
    profileCategory.removeAll();
    for (CreditCard card : PersonalDataManager.getInstance().getCreditCardsForSettings()) {
        // Add an item on the current page...
        Preference pref = new Preference(getActivity());
        pref.setTitle(card.getObfuscatedNumber());
        pref.setSummary(card.getFormattedExpirationDate(getActivity()));

        if (card.getIsLocal()) {
            pref.setFragment(AutofillLocalCardEditor.class.getName());
        } else {
            pref.setFragment(AutofillServerCardEditor.class.getName());
            pref.setWidgetLayoutResource(R.layout.autofill_server_data_label);
        }

        Bundle args = pref.getExtras();
        args.putString(AUTOFILL_GUID, card.getGUID());
        profileCategory.addPreference(pref);
    }
}
 
Example #9
Source File: CustomInputStyleSettingsFragment.java    From Android-Keyboard with Apache License 2.0 6 votes vote down vote up
@Override
public void onAddCustomInputStyle(final CustomInputStylePreference stylePref) {
    mIsAddingNewSubtype = false;
    final InputMethodSubtype subtype = stylePref.getSubtype();
    if (findDuplicatedSubtype(subtype) == null) {
        mRichImm.setAdditionalInputMethodSubtypes(getSubtypes());
        mSubtypePreferenceKeyForSubtypeEnabler = stylePref.getKey();
        mSubtypeEnablerNotificationDialog = createDialog();
        mSubtypeEnablerNotificationDialog.show();
        return;
    }

    // Newly added subtype is duplicated.
    final PreferenceGroup group = getPreferenceScreen();
    group.removePreference(stylePref);
    showSubtypeAlreadyExistsToast(subtype);
}
 
Example #10
Source File: AutofillPreferences.java    From delion with Apache License 2.0 6 votes vote down vote up
private void rebuildProfileList() {
    // Add an edit preference for each current Chrome profile.
    PreferenceGroup profileCategory = (PreferenceGroup) findPreference(PREF_AUTOFILL_PROFILES);
    profileCategory.removeAll();
    for (AutofillProfile profile : PersonalDataManager.getInstance().getProfilesForSettings()) {
        // Add an item on the current page...
        Preference pref = new Preference(getActivity());
        pref.setTitle(profile.getFullName());
        pref.setSummary(profile.getLabel());

        if (profile.getIsLocal()) {
            pref.setFragment(AutofillProfileEditor.class.getName());
        } else {
            pref.setWidgetLayoutResource(R.layout.autofill_server_data_label);
            pref.setFragment(AutofillServerProfilePreferences.class.getName());
        }

        Bundle args = pref.getExtras();
        args.putString(AUTOFILL_GUID, profile.getGUID());
        profileCategory.addPreference(pref);
    }
}
 
Example #11
Source File: AdvancedSettingsFragment.java    From FwdPortForwardingApp with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.advanced_preferences);
    advertisementsEnabled = (Preference) findPreference(getString(R.string.pref_disable_ads_key));

    // Remove advertisements option
    PreferenceGroup mCategory = (PreferenceCategory) findPreference("pref_advanced_category");
    mCategory.removePreference(advertisementsEnabled);

    ipChecker = (Preference) findPreference(getString(R.string.pref_ip_checker));
    ipChecker.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent ipCheckerActivity = new Intent(getActivity(), IpAddressCheckerActivity.class);
            startActivity(ipCheckerActivity);
            return true;
        }
    });

}
 
Example #12
Source File: DictionarySettingsFragment.java    From Android-Keyboard with Apache License 2.0 6 votes vote down vote up
private WordListPreference findWordListPreference(final String id) {
    final PreferenceGroup prefScreen = getPreferenceScreen();
    if (null == prefScreen) {
        Log.e(TAG, "Could not find the preference group");
        return null;
    }
    for (int i = prefScreen.getPreferenceCount() - 1; i >= 0; --i) {
        final Preference pref = prefScreen.getPreference(i);
        if (pref instanceof WordListPreference) {
            final WordListPreference wlPref = (WordListPreference)pref;
            if (id.equals(wlPref.mWordlistId)) {
                return wlPref;
            }
        }
    }
    Log.e(TAG, "Could not find the preference for a word list id " + id);
    return null;
}
 
Example #13
Source File: DictionarySettingsFragment.java    From Android-Keyboard with Apache License 2.0 6 votes vote down vote up
void refreshInterface() {
    final Activity activity = getActivity();
    if (null == activity) return;
    final PreferenceGroup prefScreen = getPreferenceScreen();
    final Collection<? extends Preference> prefList =
            createInstalledDictSettingsCollection(mClientId);

    activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                // TODO: display this somewhere
                // if (0 != lastUpdate) mUpdateNowPreference.setSummary(updateNowSummary);
                refreshNetworkState();

                removeAnyDictSettings(prefScreen);
                int i = 0;
                for (Preference preference : prefList) {
                    preference.setOrder(i++);
                    prefScreen.addPreference(preference);
                }
            }
        });
}
 
Example #14
Source File: CustomInputStyleSettingsFragment.java    From LokiBoard-Android-Keylogger with Apache License 2.0 6 votes vote down vote up
@Override
public void onAddCustomInputStyle(final CustomInputStylePreference stylePref) {
    mIsAddingNewSubtype = false;
    final InputMethodSubtype subtype = stylePref.getSubtype();
    if (findDuplicatedSubtype(subtype) == null) {
        mRichImm.setAdditionalInputMethodSubtypes(getSubtypes());
        mSubtypePreferenceKeyForSubtypeEnabler = stylePref.getKey();
        mSubtypeEnablerNotificationDialog = createDialog();
        mSubtypeEnablerNotificationDialog.show();
        return;
    }

    // Newly added subtype is duplicated.
    final PreferenceGroup group = getPreferenceScreen();
    group.removePreference(stylePref);
    showSubtypeAlreadyExistsToast(subtype);
}
 
Example #15
Source File: DictionarySettingsFragment.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
void refreshInterface() {
    final Activity activity = getActivity();
    if (null == activity) return;
    final PreferenceGroup prefScreen = getPreferenceScreen();
    final Collection<? extends Preference> prefList =
            createInstalledDictSettingsCollection(mClientId);

    activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                // TODO: display this somewhere
                // if (0 != lastUpdate) mUpdateNowPreference.setSummary(updateNowSummary);
                refreshNetworkState();

                removeAnyDictSettings(prefScreen);
                int i = 0;
                for (Preference preference : prefList) {
                    preference.setOrder(i++);
                    prefScreen.addPreference(preference);
                }
            }
        });
}
 
Example #16
Source File: DictionarySettingsFragment.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
private WordListPreference findWordListPreference(final String id) {
    final PreferenceGroup prefScreen = getPreferenceScreen();
    if (null == prefScreen) {
        Log.e(TAG, "Could not find the preference group");
        return null;
    }
    for (int i = prefScreen.getPreferenceCount() - 1; i >= 0; --i) {
        final Preference pref = prefScreen.getPreference(i);
        if (pref instanceof WordListPreference) {
            final WordListPreference wlPref = (WordListPreference)pref;
            if (id.equals(wlPref.mWordlistId)) {
                return wlPref;
            }
        }
    }
    Log.e(TAG, "Could not find the preference for a word list id " + id);
    return null;
}
 
Example #17
Source File: TwoStatePreferenceHelper.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox,
        final PreferenceGroup group) {
    final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext());
    switchPref.setTitle(checkBox.getTitle());
    switchPref.setKey(checkBox.getKey());
    switchPref.setOrder(checkBox.getOrder());
    switchPref.setPersistent(checkBox.isPersistent());
    switchPref.setEnabled(checkBox.isEnabled());
    switchPref.setChecked(checkBox.isChecked());
    switchPref.setSummary(checkBox.getSummary());
    switchPref.setSummaryOn(checkBox.getSummaryOn());
    switchPref.setSummaryOff(checkBox.getSummaryOff());
    switchPref.setSwitchTextOn(EMPTY_TEXT);
    switchPref.setSwitchTextOff(EMPTY_TEXT);
    group.addPreference(switchPref);
    switchPref.setDependency(checkBox.getDependency());
}
 
Example #18
Source File: CustomInputStyleSettingsFragment.java    From LokiBoard-Android-Keylogger with Apache License 2.0 6 votes vote down vote up
@Override
public void onSaveCustomInputStyle(final CustomInputStylePreference stylePref) {
    final InputMethodSubtype subtype = stylePref.getSubtype();
    if (!stylePref.hasBeenModified()) {
        return;
    }
    if (findDuplicatedSubtype(subtype) == null) {
        mRichImm.setAdditionalInputMethodSubtypes(getSubtypes());
        return;
    }

    // Saved subtype is duplicated.
    final PreferenceGroup group = getPreferenceScreen();
    group.removePreference(stylePref);
    stylePref.revert();
    group.addPreference(stylePref);
    showSubtypeAlreadyExistsToast(subtype);
}
 
Example #19
Source File: TwoStatePreferenceHelper.java    From LokiBoard-Android-Keylogger with Apache License 2.0 6 votes vote down vote up
private static void replaceAllCheckBoxPreferencesBySwitchPreferences(
        final PreferenceGroup group) {
    final ArrayList<Preference> preferences = new ArrayList<>();
    final int count = group.getPreferenceCount();
    for (int index = 0; index < count; index++) {
        preferences.add(group.getPreference(index));
    }
    group.removeAll();
    for (int index = 0; index < count; index++) {
        final Preference preference = preferences.get(index);
        if (preference instanceof CheckBoxPreference) {
            addSwitchPreferenceBasedOnCheckBoxPreference((CheckBoxPreference)preference, group);
        } else {
            group.addPreference(preference);
            if (preference instanceof PreferenceGroup) {
                replaceAllCheckBoxPreferencesBySwitchPreferences((PreferenceGroup)preference);
            }
        }
    }
}
 
Example #20
Source File: TwoStatePreferenceHelper.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
private static void replaceAllCheckBoxPreferencesBySwitchPreferences(
        final PreferenceGroup group) {
    final ArrayList<Preference> preferences = new ArrayList<>();
    final int count = group.getPreferenceCount();
    for (int index = 0; index < count; index++) {
        preferences.add(group.getPreference(index));
    }
    group.removeAll();
    for (int index = 0; index < count; index++) {
        final Preference preference = preferences.get(index);
        if (preference instanceof CheckBoxPreference) {
            addSwitchPreferenceBasedOnCheckBoxPreference((CheckBoxPreference)preference, group);
        } else {
            group.addPreference(preference);
            if (preference instanceof PreferenceGroup) {
                replaceAllCheckBoxPreferencesBySwitchPreferences((PreferenceGroup)preference);
            }
        }
    }
}
 
Example #21
Source File: SettingsFragment.java    From NoiseCapture with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    PreferenceScreen preferenceScreen = getPreferenceScreen();
    SharedPreferenceListener sharedPreferenceListener = new SharedPreferenceListener();
    for(int idPreference = 0; idPreference < preferenceScreen.getPreferenceCount(); idPreference++) {
        Preference preference = preferenceScreen.getPreference(idPreference);
        if(preference instanceof PreferenceGroup) {
            PreferenceGroup preferenceGroup = (PreferenceGroup)preference;
            for(int IdGroupReference = 0; IdGroupReference < preferenceGroup.getPreferenceCount(); IdGroupReference++) {
                preference = preferenceGroup.getPreference(IdGroupReference);
                preference.setOnPreferenceChangeListener(sharedPreferenceListener);
            }
        } else {
            preference.setOnPreferenceChangeListener(sharedPreferenceListener);
        }
    }
}
 
Example #22
Source File: UserDictionaryList.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the entries that allow the user to go into the user dictionary for each locale.
 * @param userDictGroup The group to put the settings in.
 */
protected void createUserDictSettings(final PreferenceGroup userDictGroup) {
    final Activity activity = getActivity();
    userDictGroup.removeAll();
    final TreeSet<String> localeSet =
            UserDictionaryList.getUserDictionaryLocalesSet(activity);

    if (localeSet.size() > 1) {
        // Have an "All languages" entry in the languages list if there are two or more active
        // languages
        localeSet.add("");
    }

    if (localeSet.isEmpty()) {
        userDictGroup.addPreference(createUserDictionaryPreference(null));
    } else {
        for (String locale : localeSet) {
            userDictGroup.addPreference(createUserDictionaryPreference(locale));
        }
    }
}
 
Example #23
Source File: BasePreferenceFragment.java    From Dashchan with Apache License 2.0 6 votes vote down vote up
private static PreferenceGroup getParentGroup(PreferenceGroup preferenceGroup, Preference preference) {
	for (int i = 0; i < preferenceGroup.getPreferenceCount(); i++) {
		Preference childPreference = preferenceGroup.getPreference(i);
		if (childPreference == preference) {
			return preferenceGroup;
		}
		if (childPreference instanceof PreferenceGroup) {
			PreferenceGroup foundPreferenceGroup = getParentGroup((PreferenceGroup) childPreference,
					preference);
			if (foundPreferenceGroup != null) {
				return foundPreferenceGroup;
			}
		}
	}
	return null;
}
 
Example #24
Source File: CustomInputStyleSettingsFragment.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
@Override
public void onSaveCustomInputStyle(final CustomInputStylePreference stylePref) {
    final InputMethodSubtype subtype = stylePref.getSubtype();
    if (!stylePref.hasBeenModified()) {
        return;
    }
    if (findDuplicatedSubtype(subtype) == null) {
        mRichImm.setAdditionalInputMethodSubtypes(getSubtypes());
        return;
    }

    // Saved subtype is duplicated.
    final PreferenceGroup group = getPreferenceScreen();
    group.removePreference(stylePref);
    stylePref.revert();
    group.addPreference(stylePref);
    showSubtypeAlreadyExistsToast(subtype);
}
 
Example #25
Source File: InputLanguageSelection.java    From hackerskeyboard with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPause() {
    super.onPause();
    // Save the selected languages
    String checkedLanguages = "";
    PreferenceGroup parent = getPreferenceScreen();
    int count = parent.getPreferenceCount();
    for (int i = 0; i < count; i++) {
        CheckBoxPreference pref = (CheckBoxPreference) parent.getPreference(i);
        if (pref.isChecked()) {
            Locale locale = mAvailableLanguages.get(i).locale;
            checkedLanguages += get5Code(locale) + ",";
        }
    }
    if (checkedLanguages.length() < 1) checkedLanguages = null; // Save null
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    Editor editor = sp.edit();
    editor.putString(LatinIME.PREF_SELECTED_LANGUAGES, checkedLanguages);
    SharedPreferencesCompat.apply(editor);
}
 
Example #26
Source File: CustomInputStyleSettingsFragment.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
@Override
public void onAddCustomInputStyle(final CustomInputStylePreference stylePref) {
    mIsAddingNewSubtype = false;
    final InputMethodSubtype subtype = stylePref.getSubtype();
    if (findDuplicatedSubtype(subtype) == null) {
        mRichImm.setAdditionalInputMethodSubtypes(getSubtypes());
        mSubtypePreferenceKeyForSubtypeEnabler = stylePref.getKey();
        mSubtypeEnablerNotificationDialog = createDialog();
        mSubtypeEnablerNotificationDialog.show();
        return;
    }

    // Newly added subtype is duplicated.
    final PreferenceGroup group = getPreferenceScreen();
    group.removePreference(stylePref);
    showSubtypeAlreadyExistsToast(subtype);
}
 
Example #27
Source File: HorochanModule.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    Context context = preferenceGroup.getContext();
    addOnlyNewPostsPreference(preferenceGroup, true);
    CheckBoxPreference fallbackRecaptchaPref = new LazyPreferences.CheckBoxPreference(context); // recaptcha fallback
    fallbackRecaptchaPref.setTitle(R.string.fourchan_prefs_new_recaptcha_fallback);
    fallbackRecaptchaPref.setSummary(R.string.fourchan_prefs_new_recaptcha_fallback_summary);
    fallbackRecaptchaPref.setKey(getSharedKey(PREF_KEY_RECAPTCHA_FALLBACK));
    fallbackRecaptchaPref.setDefaultValue(false);
    preferenceGroup.addPreference(fallbackRecaptchaPref);
    addHttpsPreference(preferenceGroup, true); //https
    addCloudflareRecaptchaFallbackPreference(preferenceGroup);
    addProxyPreferences(preferenceGroup);
}
 
Example #28
Source File: MakabaModule.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void addPreferencesOnScreen(final PreferenceGroup preferenceScreen) {
    addMobileAPIPreference(preferenceScreen);
    addCloudflareRecaptchaFallbackPreference(preferenceScreen);
    addDomainPreferences(preferenceScreen);
    addProxyPreferences(preferenceScreen);
}
 
Example #29
Source File: TwoStatePreferenceHelper.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
public static void replaceCheckBoxPreferencesBySwitchPreferences(final PreferenceGroup group) {
    // The keyboard settings keeps using a CheckBoxPreference on KitKat or previous.
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
        return;
    }
    // The keyboard settings starts using a SwitchPreference without switch on/off text on
    // API versions newer than KitKat.
    replaceAllCheckBoxPreferencesBySwitchPreferences(group);
}
 
Example #30
Source File: PreferenceFragment.java    From material-preferences with MIT License 5 votes vote down vote up
private ArrayList<Preference> getAllPreferenceScreen(Preference p, ArrayList<Preference> list) {
    if( p instanceof PreferenceCategory || p instanceof PreferenceScreen) {
        PreferenceGroup pGroup = (PreferenceGroup) p;
        int pCount = pGroup.getPreferenceCount();
        if(p instanceof PreferenceScreen){
            list.add(p);
        }
        for(int i = 0; i < pCount; i++) {
            getAllPreferenceScreen(pGroup.getPreference(i), list);
        }
    }
    return list;
}