Search in sources :

Example 36 with PreferenceGroup

use of android.preference.PreferenceGroup in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class CustomInputStyleSettingsFragment method onRemoveCustomInputStyle.

@Override
public void onRemoveCustomInputStyle(final CustomInputStylePreference stylePref) {
    mIsAddingNewSubtype = false;
    final PreferenceGroup group = getPreferenceScreen();
    group.removePreference(stylePref);
    mRichImm.setAdditionalInputMethodSubtypes(getSubtypes());
}
Also used : PreferenceGroup(android.preference.PreferenceGroup)

Example 37 with PreferenceGroup

use of android.preference.PreferenceGroup in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class DebugSettingsFragment method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.prefs_screen_debug);
    if (!Settings.SHOULD_SHOW_LXX_SUGGESTION_UI) {
        removePreference(DebugSettings.PREF_SHOULD_SHOW_LXX_SUGGESTION_UI);
    }
    final PreferenceGroup dictDumpPreferenceGroup = (PreferenceGroup) findPreference(PREF_KEY_DUMP_DICTS);
    for (final String dictName : DictionaryFacilitatorImpl.DICT_TYPE_TO_CLASS.keySet()) {
        final Preference pref = new DictDumpPreference(getActivity(), dictName);
        pref.setOnPreferenceClickListener(this);
        dictDumpPreferenceGroup.addPreference(pref);
    }
    final Resources res = getResources();
    setupKeyPreviewAnimationDuration(DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_DURATION, res.getInteger(R.integer.config_key_preview_show_up_duration));
    setupKeyPreviewAnimationDuration(DebugSettings.PREF_KEY_PREVIEW_DISMISS_DURATION, res.getInteger(R.integer.config_key_preview_dismiss_duration));
    final float defaultKeyPreviewShowUpStartScale = ResourceUtils.getFloatFromFraction(res, R.fraction.config_key_preview_show_up_start_scale);
    final float defaultKeyPreviewDismissEndScale = ResourceUtils.getFloatFromFraction(res, R.fraction.config_key_preview_dismiss_end_scale);
    setupKeyPreviewAnimationScale(DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_START_X_SCALE, defaultKeyPreviewShowUpStartScale);
    setupKeyPreviewAnimationScale(DebugSettings.PREF_KEY_PREVIEW_SHOW_UP_START_Y_SCALE, defaultKeyPreviewShowUpStartScale);
    setupKeyPreviewAnimationScale(DebugSettings.PREF_KEY_PREVIEW_DISMISS_END_X_SCALE, defaultKeyPreviewDismissEndScale);
    setupKeyPreviewAnimationScale(DebugSettings.PREF_KEY_PREVIEW_DISMISS_END_Y_SCALE, defaultKeyPreviewDismissEndScale);
    setupKeyboardHeight(DebugSettings.PREF_KEYBOARD_HEIGHT_SCALE, SettingsValues.DEFAULT_SIZE_SCALE);
    mServiceNeedsRestart = false;
    mDebugMode = (TwoStatePreference) findPreference(DebugSettings.PREF_DEBUG_MODE);
    updateDebugMode();
}
Also used : TwoStatePreference(android.preference.TwoStatePreference) Preference(android.preference.Preference) PreferenceGroup(android.preference.PreferenceGroup) Resources(android.content.res.Resources)

Example 38 with PreferenceGroup

use of android.preference.PreferenceGroup in project AndroidChromium by JackyAndroid.

the class SingleCategoryPreferences method configureGlobalToggles.

private void configureGlobalToggles() {
    // Only some have a global toggle at the top.
    ChromeSwitchPreference globalToggle = (ChromeSwitchPreference) getPreferenceScreen().findPreference(READ_WRITE_TOGGLE_KEY);
    // Configure/hide the third-party cookie toggle, as needed.
    Preference thirdPartyCookies = getPreferenceScreen().findPreference(THIRD_PARTY_COOKIES_TOGGLE_KEY);
    if (mCategory.showCookiesSites()) {
        thirdPartyCookies.setOnPreferenceChangeListener(this);
        updateThirdPartyCookiesCheckBox();
    } else {
        getPreferenceScreen().removePreference(thirdPartyCookies);
    }
    // Configure/hide the notifications vibrate toggle, as needed.
    Preference notificationsVibrate = getPreferenceScreen().findPreference(NOTIFICATIONS_VIBRATE_TOGGLE_KEY);
    if (mCategory.showNotificationsSites()) {
        notificationsVibrate.setOnPreferenceChangeListener(this);
        updateNotificationsVibrateCheckBox();
    } else {
        getPreferenceScreen().removePreference(notificationsVibrate);
    }
    // Show/hide the link that explains protected media settings, as needed.
    if (!mCategory.showProtectedMediaSites()) {
        getPreferenceScreen().removePreference(getPreferenceScreen().findPreference(EXPLAIN_PROTECTED_MEDIA_KEY));
    }
    if (mCategory.showAllSites() || mCategory.showStorageSites()) {
        getPreferenceScreen().removePreference(globalToggle);
        getPreferenceScreen().removePreference(getPreferenceScreen().findPreference(ALLOWED_GROUP));
        getPreferenceScreen().removePreference(getPreferenceScreen().findPreference(BLOCKED_GROUP));
    } else {
        // When this menu opens, make sure the Blocked list is collapsed.
        if (!mGroupByAllowBlock) {
            mBlockListExpanded = false;
            mAllowListExpanded = true;
        }
        mGroupByAllowBlock = true;
        PreferenceGroup allowedGroup = (PreferenceGroup) getPreferenceScreen().findPreference(ALLOWED_GROUP);
        PreferenceGroup blockedGroup = (PreferenceGroup) getPreferenceScreen().findPreference(BLOCKED_GROUP);
        if (mCategory.showPermissionBlockedMessage(getActivity())) {
            getPreferenceScreen().removePreference(globalToggle);
            getPreferenceScreen().removePreference(allowedGroup);
            getPreferenceScreen().removePreference(blockedGroup);
            // Show the link to system settings since permission is disabled.
            ChromeBasePreference osWarning = new ChromeBasePreference(getActivity(), null);
            ChromeBasePreference osWarningExtra = new ChromeBasePreference(getActivity(), null);
            mCategory.configurePermissionIsOffPreferences(osWarning, osWarningExtra, getActivity(), true);
            if (osWarning.getTitle() != null) {
                getPreferenceScreen().addPreference(osWarning);
            }
            if (osWarningExtra.getTitle() != null) {
                getPreferenceScreen().addPreference(osWarningExtra);
            }
        } else {
            allowedGroup.setOnPreferenceClickListener(this);
            blockedGroup.setOnPreferenceClickListener(this);
            // Determine what toggle to use and what it should display.
            int contentType = mCategory.toContentSettingsType();
            globalToggle.setOnPreferenceChangeListener(this);
            globalToggle.setTitle(ContentSettingsResources.getTitle(contentType));
            if (mCategory.showGeolocationSites() && PrefServiceBridge.getInstance().isLocationAllowedByPolicy()) {
                globalToggle.setSummaryOn(ContentSettingsResources.getGeolocationAllowedSummary());
            } else {
                globalToggle.setSummaryOn(ContentSettingsResources.getEnabledSummary(contentType));
            }
            globalToggle.setSummaryOff(ContentSettingsResources.getDisabledSummary(contentType));
            if (mCategory.isManaged() && !mCategory.isManagedByCustodian()) {
                globalToggle.setIcon(R.drawable.controlled_setting_mandatory);
            }
            if (mCategory.showAutoplaySites()) {
                globalToggle.setChecked(PrefServiceBridge.getInstance().isAutoplayEnabled());
            } else if (mCategory.showBackgroundSyncSites()) {
                globalToggle.setChecked(PrefServiceBridge.getInstance().isBackgroundSyncAllowed());
            } else if (mCategory.showCameraSites()) {
                globalToggle.setChecked(PrefServiceBridge.getInstance().isCameraEnabled());
            } else if (mCategory.showCookiesSites()) {
                globalToggle.setChecked(PrefServiceBridge.getInstance().isAcceptCookiesEnabled());
            } else if (mCategory.showGeolocationSites()) {
                globalToggle.setChecked(LocationSettings.getInstance().isChromeLocationSettingEnabled());
            } else if (mCategory.showJavaScriptSites()) {
                globalToggle.setChecked(PrefServiceBridge.getInstance().javaScriptEnabled());
            } else if (mCategory.showMicrophoneSites()) {
                globalToggle.setChecked(PrefServiceBridge.getInstance().isMicEnabled());
            } else if (mCategory.showNotificationsSites()) {
                globalToggle.setChecked(PrefServiceBridge.getInstance().isNotificationsEnabled());
            } else if (mCategory.showPopupSites()) {
                globalToggle.setChecked(PrefServiceBridge.getInstance().popupsEnabled());
            } else if (mCategory.showProtectedMediaSites()) {
                globalToggle.setChecked(PrefServiceBridge.getInstance().isProtectedMediaIdentifierEnabled());
            }
        }
    }
}
Also used : ChromeBasePreference(org.chromium.chrome.browser.preferences.ChromeBasePreference) ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference) ChromeBasePreference(org.chromium.chrome.browser.preferences.ChromeBasePreference) ChromeBaseCheckBoxPreference(org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference) Preference(android.preference.Preference) ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference) ExpandablePreferenceGroup(org.chromium.chrome.browser.preferences.ExpandablePreferenceGroup) PreferenceGroup(android.preference.PreferenceGroup)

Aggregations

PreferenceGroup (android.preference.PreferenceGroup)38 Preference (android.preference.Preference)26 ListPreference (android.preference.ListPreference)7 SharedPreferences (android.content.SharedPreferences)6 CheckBoxPreference (android.preference.CheckBoxPreference)6 PreferenceScreen (android.preference.PreferenceScreen)6 Intent (android.content.Intent)5 Bundle (android.os.Bundle)4 TwoStatePreference (android.preference.TwoStatePreference)4 ArrayList (java.util.ArrayList)4 EditTextPreference (android.preference.EditTextPreference)3 MultiSelectListPreference (android.preference.MultiSelectListPreference)3 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)3 ChromeSwitchPreference (org.chromium.chrome.browser.preferences.ChromeSwitchPreference)3 Point (android.graphics.Point)2 DialogPreference (android.preference.DialogPreference)2 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)2 PreferenceCategory (android.preference.PreferenceCategory)2 SpannableString (android.text.SpannableString)2 View (android.view.View)2