use of android.preference.PreferenceCategory in project afwall by ukanth.
the class MultiProfilePreferenceFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.profiles_preferences);
Preference button = (Preference) findPreference("manage_profiles");
button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
// code for what you want it to do
startActivity(new Intent(getActivity(), ProfileActivity.class));
return true;
}
});
final PreferenceCategory mCategory = (PreferenceCategory) findPreference("promigrate");
final PreferenceCategory mCategory2 = (PreferenceCategory) findPreference("oldprofile_pref");
final Preference migrate = (Preference) findPreference("migrate_profile");
if (!G.isProfileMigrated()) {
migrate.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Context ctx = getActivity();
ProfileHelper.migrateProfiles(ctx);
if (ctx != null) {
Api.toast(getActivity(), ctx.getString(R.string.profile_migrate_msg));
mCategory.removePreference(migrate);
Preference migrate = (Preference) findPreference("profile1");
mCategory2.removePreference(migrate);
migrate = (Preference) findPreference("profile2");
mCategory2.removePreference(migrate);
migrate = (Preference) findPreference("profile3");
mCategory2.removePreference(migrate);
}
return true;
}
});
} else {
mCategory.removePreference(migrate);
Preference migrate2 = (Preference) findPreference("profile1");
mCategory2.removePreference(migrate2);
migrate2 = (Preference) findPreference("profile2");
mCategory2.removePreference(migrate2);
migrate2 = (Preference) findPreference("profile3");
mCategory2.removePreference(migrate2);
}
}
use of android.preference.PreferenceCategory in project ultrasonic by ultrasonic.
the class SettingsFragment method setupGaplessControlSettingsV14.
private void setupGaplessControlSettingsV14() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
PreferenceCategory playbackControlSettings = (PreferenceCategory) findPreference(Constants.PREFERENCES_KEY_PLAYBACK_CONTROL_SETTINGS);
CheckBoxPreference gaplessPlaybackEnabled = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_GAPLESS_PLAYBACK);
if (gaplessPlaybackEnabled != null) {
gaplessPlaybackEnabled.setChecked(false);
gaplessPlaybackEnabled.setEnabled(false);
if (playbackControlSettings != null) {
playbackControlSettings.removePreference(gaplessPlaybackEnabled);
}
}
}
}
use of android.preference.PreferenceCategory in project android-edittext-validator by vekexasia.
the class SettingsActivity method setupSimplePreferencesScreen.
/**
* Shows the simplified settings UI if the device configuration if the device configuration dictates that a
* simplified, single-pane UI should be shown.
*/
@SuppressWarnings("deprecation")
private void setupSimplePreferencesScreen() {
if (!SettingsActivity.isSimplePreferences(this)) {
return;
}
// Class<ContactPreferenceFragment> a = ContactPreferenceFragment.class;
// In the simplified UI, fragments are not used at all and we instead
// use the older PreferenceActivity APIs.
// Add 'general' preferences.
PreferenceCategory fakeHeader = new PreferenceCategory(this);
addPreferencesFromResource(R.xml.pref_contact);
SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_FULL_NAME));
SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_ADDRESS));
SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_PHONE_NUMBER));
SettingsActivity.bindPreferenceSummaryToValue(findPreference(SettingsActivity.PREF_KEY_EMAIL));
}
use of android.preference.PreferenceCategory in project Android-Terminal-Emulator by jackpal.
the class TermPreferences method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
// Remove the action bar pref on older platforms without an action bar
if (AndroidCompat.SDK < 11) {
Preference actionBarPref = findPreference(ACTIONBAR_KEY);
PreferenceCategory screenCategory = (PreferenceCategory) findPreference(CATEGORY_SCREEN_KEY);
if ((actionBarPref != null) && (screenCategory != null)) {
screenCategory.removePreference(actionBarPref);
}
}
// Display up indicator on action bar home button
if (AndroidCompat.V11ToV20) {
ActionBarCompat bar = ActivityCompat.getActionBar(this);
if (bar != null) {
bar.setDisplayOptions(ActionBarCompat.DISPLAY_HOME_AS_UP, ActionBarCompat.DISPLAY_HOME_AS_UP);
}
}
}
use of android.preference.PreferenceCategory in project KeepScore by nolanlawson.
the class SettingsActivity method getPreferenceCategoryPosition.
@SuppressWarnings("deprecation")
private int getPreferenceCategoryPosition(int titleId) {
PreferenceScreen screen = getPreferenceScreen();
String titleToFind = getString(titleId);
for (int i = 0; i < screen.getPreferenceCount(); i++) {
Preference preference = screen.getPreference(i);
if (!(preference instanceof PreferenceCategory)) {
continue;
}
if (titleToFind.equals(((PreferenceCategory) preference).getTitle())) {
return i;
}
}
return -1;
}
Aggregations