本文整理汇总了Java中android.preference.PreferenceGroup.removePreference方法的典型用法代码示例。如果您正苦于以下问题:Java PreferenceGroup.removePreference方法的具体用法?Java PreferenceGroup.removePreference怎么用?Java PreferenceGroup.removePreference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.PreferenceGroup
的用法示例。
在下文中一共展示了PreferenceGroup.removePreference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSaveCustomInputStyle
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
@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);
}
示例2: onAddCustomInputStyle
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
@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);
}
示例3: restoreDefaults
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
* Restores the default preferences, which are contained by a specific preference group.
*
* @param preferenceGroup
* The preference group, whose preferences should be restored, as an instance of the
* class {@link PreferenceGroup}. The preference group may not be null
* @param sharedPreferences
* The shared preferences, which should be used to restore the preferences, as an
* instance of the type {@link SharedPreferences}. The shared preferences may not be
* null
*/
private void restoreDefaults(@NonNull final PreferenceGroup preferenceGroup,
@NonNull final SharedPreferences sharedPreferences) {
for (int i = 0; i < preferenceGroup.getPreferenceCount(); i++) {
Preference preference = preferenceGroup.getPreference(i);
if (preference instanceof PreferenceGroup) {
restoreDefaults((PreferenceGroup) preference, sharedPreferences);
} else if (preference.getKey() != null && !preference.getKey().isEmpty()) {
Object oldValue = sharedPreferences.getAll().get(preference.getKey());
if (notifyOnRestoreDefaultValueRequested(preference, oldValue)) {
sharedPreferences.edit().remove(preference.getKey()).apply();
preferenceGroup.removePreference(preference);
preferenceGroup.addPreference(preference);
Object newValue = sharedPreferences.getAll().get(preference.getKey());
notifyOnRestoredDefaultValue(preference, oldValue, newValue);
} else {
preferenceGroup.removePreference(preference);
preferenceGroup.addPreference(preference);
}
}
}
}
示例4: hideAdvancedPreferences
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private void hideAdvancedPreferences(PreferenceGroup group) {
if(mAdvancedSettings.showAll()) {
return;
}
int c = 0;
while(c < group.getPreferenceCount()) {
Preference pref = group.getPreference(c);
if(!mAdvancedSettings.isVisible(group, pref)) {
group.removePreference(pref);
} else {
if(pref instanceof PreferenceGroup) {
hideAdvancedPreferences((PreferenceGroup)pref);
}
c++;
}
}
}
示例5: recursiveDelete
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
* Recursively traverses the tree from the given group as the route and
* tries to delete the preference. Traversal stops once the preference
* was found and removed.
*/
private boolean recursiveDelete(PreferenceGroup group, Preference preference) {
if (group == null) {
Log.d(TAG, "attempting to delete from null preference group");
return false;
}
if (preference == null) {
Log.d(TAG, "attempting to delete null preference");
return false;
}
if (group.removePreference(preference)) {
// Removal was successful.
return true;
}
for (int i = 0; i < group.getPreferenceCount(); ++i) {
Preference pref = group.getPreference(i);
if (pref instanceof PreferenceGroup) {
if (recursiveDelete((PreferenceGroup) pref, preference)) {
return true;
}
}
}
return false;
}
示例6: assignPlayStoreIntentToPreference
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private void assignPlayStoreIntentToPreference(int preferenceId, String url) {
final PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(
R.string.pref_category_miscellaneous_key);
final Preference pref = findPreferenceByResId(preferenceId);
if (pref == null) {
return;
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
if (!canHandleIntent(intent)) {
category.removePreference(pref);
return;
}
pref.setIntent(intent);
}
示例7: assignTtsSettingsIntent
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
* Assigns the intent to open text-to-speech settings.
*/
private void assignTtsSettingsIntent() {
PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(
R.string.pref_category_when_to_speak_key);
Preference ttsSettingsPreference =
findPreferenceByResId(R.string.pref_tts_settings_key);
if (category == null || ttsSettingsPreference == null) {
return;
}
Intent ttsSettingsIntent = new Intent(TalkBackService.INTENT_TTS_SETTINGS);
ttsSettingsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (!canHandleIntent(ttsSettingsIntent)) {
// Need to remove preference item if no TTS Settings intent filter in settings app.
category.removePreference(ttsSettingsPreference);
}
ttsSettingsPreference.setIntent(ttsSettingsIntent);
}
示例8: assignLabelManagerIntent
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
* Assigns the appropriate intent to the label manager preference.
*/
private void assignLabelManagerIntent() {
final PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(
R.string.pref_category_touch_exploration_key);
final Preference prefManageLabels = findPreferenceByResId(
R.string.pref_manage_labels_key);
if ((category == null) || (prefManageLabels == null)) {
return;
}
if (Build.VERSION.SDK_INT < LabelManagerSummaryActivity.MIN_API_LEVEL) {
category.removePreference(prefManageLabels);
return;
}
Activity activity = getActivity();
if (activity != null) {
final Intent labelManagerIntent = new Intent(
activity, LabelManagerSummaryActivity.class);
labelManagerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
labelManagerIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
prefManageLabels.setIntent(labelManagerIntent);
}
}
示例9: assignKeyboardShortcutIntent
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
* Assigns the appropriate intent to the keyboard shortcut preference.
*/
private void assignKeyboardShortcutIntent() {
final PreferenceGroup category =
(PreferenceGroup) findPreferenceByResId(
R.string.pref_category_miscellaneous_key);
final Preference keyboardShortcutPref = findPreferenceByResId(
R.string.pref_category_manage_keyboard_shortcut_key);
if ((category == null) || (keyboardShortcutPref == null)) {
return;
}
if (Build.VERSION.SDK_INT < KeyComboManager.MIN_API_LEVEL) {
category.removePreference(keyboardShortcutPref);
return;
}
Activity activity = getActivity();
if (activity != null) {
final Intent labelManagerIntent = new Intent(activity,
TalkBackKeyboardShortcutPreferencesActivity.class);
labelManagerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
labelManagerIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
keyboardShortcutPref.setIntent(labelManagerIntent);
}
}
示例10: updateTalkBackShortcutStatus
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private void updateTalkBackShortcutStatus() {
final TwoStatePreference preference = (TwoStatePreference) findPreferenceByResId(
R.string.pref_two_volume_long_press_key);
if (preference == null) {
return;
}
if (Build.VERSION.SDK_INT >= ProcessorVolumeStream.MIN_API_LEVEL) {
preference.setEnabled(
TalkBackService.getInstance() != null || preference.isChecked());
} else {
final PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(
R.string.pref_category_miscellaneous_key);
if (category == null) {
return;
}
category.removePreference(preference);
}
}
示例11: checkVibrationSupport
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
* Ensure that the vibration setting does not appear on devices without a
* vibrator.
*/
private void checkVibrationSupport() {
Activity activity = getActivity();
if (activity == null) {
return;
}
final Vibrator vibrator = (Vibrator) activity.getSystemService(VIBRATOR_SERVICE);
if (vibrator != null && vibrator.hasVibrator()) {
return;
}
final PreferenceGroup category =
(PreferenceGroup) findPreferenceByResId(R.string.pref_category_feedback_key);
final TwoStatePreference prefVibration =
(TwoStatePreference) findPreferenceByResId(R.string.pref_vibration_key);
if (prefVibration != null) {
prefVibration.setChecked(false);
category.removePreference(prefVibration);
}
}
示例12: checkProximitySupport
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
* Ensure that the proximity sensor setting does not appear on devices
* without a proximity sensor.
*/
private void checkProximitySupport() {
Activity activity = getActivity();
if (activity == null) {
return;
}
final SensorManager manager = (SensorManager) activity.getSystemService(SENSOR_SERVICE);
final Sensor proximity = manager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
if (proximity != null) {
return;
}
final PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(
R.string.pref_category_when_to_speak_key);
final TwoStatePreference prefProximity =
(TwoStatePreference) findPreferenceByResId(R.string.pref_proximity_key);
if (prefProximity != null) {
prefProximity.setChecked(false);
category.removePreference(prefProximity);
}
}
示例13: removeCookie
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private boolean removeCookie(String cookie, boolean preferenceOnly) {
if (!preferenceOnly) {
configuration.storeCookie(cookie, null, null);
configuration.commit();
}
CookiePreference preference = (CookiePreference) findPreference(cookie);
if (preference != null) {
PreferenceGroup preferenceGroup = getParentGroup(preference);
preferenceGroup.removePreference(preference);
cookies.remove(cookie);
if (preferenceGroup.getPreferenceCount() == 0) {
getActivity().finish();
return true;
}
}
return false;
}
示例14: onCreate
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.battery_light_settings);
PreferenceScreen prefSet = getPreferenceScreen();
PreferenceGroup mGeneralPrefs = (PreferenceGroup) prefSet.findPreference("general_section");
mLightEnabledPref = (CMSystemSettingSwitchPreference) prefSet.findPreference(LIGHT_ENABLED_PREF);
mPulseEnabledPref = (CMSystemSettingSwitchPreference) prefSet.findPreference(PULSE_ENABLED_PREF);
if (!getResources().getBoolean(com.android.internal.R.bool.config_ledCanPulse) ||
getResources().getBoolean(org.cyanogenmod.platform.internal.R.bool.config_useSegmentedBatteryLed)) {
mGeneralPrefs.removePreference(mPulseEnabledPref);
}
// Does the Device support changing battery LED colors?
if (getResources().getBoolean(com.android.internal.R.bool.config_multiColorBatteryLed)) {
setHasOptionsMenu(true);
// Low, Medium and full color preferences
mLowColorPref = (ApplicationLightPreference) prefSet.findPreference(LOW_COLOR_PREF);
mLowColorPref.setOnPreferenceChangeListener(this);
mMediumColorPref = (ApplicationLightPreference) prefSet.findPreference(MEDIUM_COLOR_PREF);
mMediumColorPref.setOnPreferenceChangeListener(this);
mFullColorPref = (ApplicationLightPreference) prefSet.findPreference(FULL_COLOR_PREF);
mFullColorPref.setOnPreferenceChangeListener(this);
} else {
prefSet.removePreference(prefSet.findPreference("colors_list"));
resetColors();
}
}
示例15: removeAdvancePreference
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private void removeAdvancePreference(Preference preference) {
// these null checks are to fix a crash due to an NPE on 4.4.4
if (preference != null) {
PreferenceGroup group =
(PreferenceGroup) findPreference(Constants.PREF_QURAN_SETTINGS);
if (group != null) {
group.removePreference(preference);
}
}
}