Java Code Examples for android.preference.PreferenceFragment#findPreference()

The following examples show how to use android.preference.PreferenceFragment#findPreference() . 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: NSClientPlugin.java    From AndroidAPS with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void preprocessPreferences(@NotNull PreferenceFragment preferenceFragment) {
    super.preprocessPreferences(preferenceFragment);

    if (Config.NSCLIENT) {
        PreferenceScreen scrnAdvancedSettings = (PreferenceScreen) preferenceFragment.findPreference(MainApp.gs(R.string.key_advancedsettings));
        if (scrnAdvancedSettings != null) {
            scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(MainApp.gs(R.string.key_statuslights_res_warning)));
            scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(MainApp.gs(R.string.key_statuslights_res_critical)));
            scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(MainApp.gs(R.string.key_statuslights_bat_warning)));
            scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(MainApp.gs(R.string.key_statuslights_bat_critical)));
            scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(MainApp.gs(R.string.key_show_statuslights)));
            scrnAdvancedSettings.removePreference(preferenceFragment.findPreference(MainApp.gs(R.string.key_show_statuslights_extended)));
        }
    }
}
 
Example 2
Source File: SuntimesSettingsActivity.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static void initPref_ui(final PreferenceFragment fragment)
{
    boolean[] showFields = AppSettings.loadShowFieldsPref(fragment.getActivity());
    for (int i = 0; i<AppSettings.NUM_FIELDS; i++)
    {
        CheckBoxPreference field = (CheckBoxPreference)fragment.findPreference(AppSettings.PREF_KEY_UI_SHOWFIELDS + "_" + i);
        if (field != null) {
            initPref_ui_field(field, fragment.getActivity(), i, showFields[i]);
        }
    }

    final ThemePreference overrideTheme_light = (ThemePreference)fragment.findPreference(PREF_KEY_APPEARANCE_THEME_LIGHT);
    initPref_ui_themeOverride(fragment.getActivity(), overrideTheme_light, fragment.getActivity(), PREF_KEY_APPEARANCE_THEME_LIGHT);
    loadPref_ui_themeOverride(fragment.getActivity(), overrideTheme_light, PREF_KEY_APPEARANCE_THEME_LIGHT, fragment.getActivity());

    final ThemePreference overrideTheme_dark = (ThemePreference)fragment.findPreference(AppSettings.PREF_KEY_APPEARANCE_THEME_DARK);
    initPref_ui_themeOverride(fragment.getActivity(), overrideTheme_dark, fragment.getActivity(), AppSettings.PREF_KEY_APPEARANCE_THEME_DARK);
    loadPref_ui_themeOverride(fragment.getActivity(), overrideTheme_dark, AppSettings.PREF_KEY_APPEARANCE_THEME_DARK, fragment.getActivity());

    updatePref_ui_themeOverride(AppSettings.loadThemePref(fragment.getActivity()), overrideTheme_dark, overrideTheme_light);
}
 
Example 3
Source File: MainActivity.java    From SnooperStopper with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Use Toolbar instead of ActionBar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Prepare ProgressBar
    progressBar = (ProgressBar) findViewById(R.id.progress_spinner);

    // Show app icon in Toolbar
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setDisplayUseLogoEnabled(true);
    getSupportActionBar().setLogo(R.mipmap.ic_logo);

    PreferenceFragment preferenceFragment = (PreferenceFragment) getFragmentManager().findFragmentById(R.id.frag_settings);
    switchAdmin = (SwitchPreference) preferenceFragment.findPreference("pref_key_device_admin_enabled");
    switchAdmin.setOnPreferenceChangeListener(switchAdminOnChangeListener);

    // Initialize Device Policy Manager service and our receiver class
    devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    snooperStopperDeviceAdmin = new ComponentName(this, SnooperStopperDeviceAdminReceiver.class);
}
 
Example 4
Source File: UiUtility.java    From SwipeBack with GNU General Public License v3.0 4 votes vote down vote up
public static <T extends Preference> T $(PreferenceFragment preference, String key) {
	return (T) preference.findPreference(key);
}
 
Example 5
Source File: SuntimesSettingsActivity.java    From SuntimesWidget with GNU General Public License v3.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static void initPref_general(PreferenceFragment fragment)
{
    Log.i(LOG_TAG, "initPref_general (fragment)");
    Context context = fragment.getActivity();

    String key_timeFormat = WidgetSettings.PREF_PREFIX_KEY + "0" + WidgetSettings.PREF_PREFIX_KEY_APPEARANCE + WidgetSettings.PREF_KEY_APPEARANCE_TIMEFORMATMODE;
    ListPreference timeformatPref = (ListPreference)fragment.findPreference(key_timeFormat);
    if (timeformatPref != null)
    {
        initPref_timeFormat(fragment.getActivity(), timeformatPref);
        loadPref_timeFormat(fragment.getActivity(), timeformatPref);
    }

    String key_altitudePref = WidgetSettings.PREF_PREFIX_KEY + "0" + WidgetSettings.PREF_PREFIX_KEY_LOCATION + WidgetSettings.PREF_KEY_LOCATION_ALTITUDE_ENABLED;
    CheckBoxPreference altitudePref = (CheckBoxPreference)fragment.findPreference(key_altitudePref);
    if (altitudePref != null)
    {
        initPref_altitude(fragment.getActivity(), altitudePref);
        loadPref_altitude(fragment.getActivity(), altitudePref);
    }

    String key_sunCalc = WidgetSettings.keyCalculatorModePref(0);
    SummaryListPreference calculatorPref = (SummaryListPreference) fragment.findPreference(key_sunCalc);
    if (calculatorPref != null)
    {
        initPref_calculator(context, calculatorPref, WidgetSettings.PREF_DEF_GENERAL_CALCULATOR);
        loadPref_calculator(context, calculatorPref);
    }

    String key_moonCalc = WidgetSettings.keyCalculatorModePref(0, "moon");
    SummaryListPreference moonCalculatorPref = (SummaryListPreference) fragment.findPreference(key_moonCalc);
    if (moonCalculatorPref != null)
    {
        initPref_calculator(context, moonCalculatorPref, new int[] {SuntimesCalculator.FEATURE_MOON}, WidgetSettings.PREF_DEF_GENERAL_CALCULATOR_MOON);
        loadPref_calculator(context, moonCalculatorPref, "moon");
    }

    String key_observerHeight = WidgetSettings.PREF_PREFIX_KEY + "0" + WidgetSettings.PREF_PREFIX_KEY_GENERAL + WidgetSettings.PREF_KEY_GENERAL_OBSERVERHEIGHT;
    LengthPreference observerHeightPref = (LengthPreference) fragment.findPreference(key_observerHeight);
    if (observerHeightPref != null)
    {
        initPref_observerHeight(fragment.getActivity(), observerHeightPref);
        loadPref_observerHeight(fragment.getActivity(), observerHeightPref);
    }
}
 
Example 6
Source File: SuntimesSettingsActivity.java    From SuntimesWidget with GNU General Public License v3.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static void initPref_locale(PreferenceFragment fragment)
{
    ListPreference localePref = (ListPreference)fragment.findPreference(AppSettings.PREF_KEY_LOCALE);
    initPref_locale(fragment.getActivity(), localePref);
}
 
Example 7
Source File: UiUtility.java    From Panoramic-Screenshot with GNU General Public License v3.0 4 votes vote down vote up
public static <T extends Preference> T $(PreferenceFragment pref, String key) {
	return (T) pref.findPreference(key);
}