Java Code Examples for android.preference.Preference#setShouldDisableView()

The following examples show how to use android.preference.Preference#setShouldDisableView() . 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: ManagedPreferenceDelegate.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the Preference based on the state of any policies that may affect it,
 * e.g. by showing a managed icon or disabling clicks on the preference.
 *
 * This should be called once, before the preference is displayed.
 */
public void initPreference(Preference preference) {
    if (isPreferenceControlledByPolicy(preference)) {
        preference.setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId());

        if (isPreferenceClickDisabledByPolicy(preference)) {
            // Disable the views and prevent the Preference from mucking with the enabled state.
            preference.setShouldDisableView(false);

            // Prevent default click behavior.
            preference.setFragment(null);
            preference.setIntent(null);
            preference.setOnPreferenceClickListener(null);
        }
    }
}
 
Example 2
Source File: ManagedPreferenceDelegate.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the Preference based on the state of any policies that may affect it,
 * e.g. by showing a managed icon or disabling clicks on the preference.
 *
 * This should be called once, before the preference is displayed.
 */
public void initPreference(Preference preference) {
    if (isPreferenceControlledByPolicy(preference)) {
        preference.setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId());

        if (isPreferenceClickDisabledByPolicy(preference)) {
            // Disable the views and prevent the Preference from mucking with the enabled state.
            preference.setShouldDisableView(false);

            // Prevent default click behavior.
            preference.setFragment(null);
            preference.setIntent(null);
            preference.setOnPreferenceClickListener(null);
        }
    }
}
 
Example 3
Source File: ManagedPreferenceDelegate.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the Preference based on the state of any policies that may affect it,
 * e.g. by showing a managed icon or disabling clicks on the preference.
 *
 * This should be called once, before the preference is displayed.
 */
public void initPreference(Preference preference) {
    if (isPreferenceControlledByPolicy(preference)) {
        preference.setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId());
    } else if (isPreferenceControlledByCustodian(preference)) {
        preference.setIcon(R.drawable.ic_account_child_grey600_36dp);
    }

    if (isPreferenceClickDisabledByPolicy(preference)) {
        // Disable the views and prevent the Preference from mucking with the enabled state.
        preference.setShouldDisableView(false);

        // Prevent default click behavior.
        preference.setFragment(null);
        preference.setIntent(null);
        preference.setOnPreferenceClickListener(null);
    }
}
 
Example 4
Source File: AutofillAndPaymentsPreferences.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferenceUtils.addPreferencesFromResource(this, R.xml.autofill_and_payments_preferences);
    getActivity().setTitle(R.string.prefs_autofill_and_payments);

    ChromeSwitchPreference autofillSwitch =
            (ChromeSwitchPreference) findPreference(PREF_AUTOFILL_SWITCH);
    autofillSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            PersonalDataManager.setAutofillEnabled((boolean) newValue);
            return true;
        }
    });

    if (ChromeFeatureList.isEnabled(ChromeFeatureList.ANDROID_PAYMENT_APPS)) {
        Preference pref = new Preference(getActivity());
        pref.setTitle(getActivity().getString(R.string.payment_apps_title));
        pref.setFragment(AndroidPaymentAppsFragment.class.getCanonicalName());
        pref.setShouldDisableView(true);
        pref.setKey(PREF_ANDROID_PAYMENT_APPS);
        getPreferenceScreen().addPreference(pref);
    }
}
 
Example 5
Source File: AdvancedSettingsActivity.java    From prevent with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    changed = true;
    // tricky to fix for android 2.3
    preference.setShouldDisableView(true);
    return true;
}