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

The following examples show how to use android.preference.Preference#setSelectable() . 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: AccountManagementFragment.java    From delion with Apache License 2.0 4 votes vote down vote up
private void configureChildAccountPreferences() {
    Preference parentAccounts = findPreference(PREF_PARENT_ACCOUNTS);
    Preference childContent = findPreference(PREF_CHILD_CONTENT);
    Preference childSafeSites = findPreference(PREF_CHILD_SAFE_SITES);
    if (ChildAccountService.isChildAccount()) {
        Resources res = getActivity().getResources();
        PrefServiceBridge prefService = PrefServiceBridge.getInstance();

        String firstParent = prefService.getSupervisedUserCustodianEmail();
        String secondParent = prefService.getSupervisedUserSecondCustodianEmail();
        String parentText;

        if (!secondParent.isEmpty()) {
            parentText = res.getString(R.string.account_management_two_parent_names,
                    firstParent, secondParent);
        } else if (!firstParent.isEmpty()) {
            parentText = res.getString(R.string.account_management_one_parent_name,
                    firstParent);
        } else {
            parentText = res.getString(R.string.account_management_no_parental_data);
        }
        parentAccounts.setSummary(parentText);
        parentAccounts.setSelectable(false);

        final boolean unapprovedContentBlocked =
                prefService.getDefaultSupervisedUserFilteringBehavior()
                == PrefServiceBridge.SUPERVISED_USER_FILTERING_BLOCK;
        final String contentText = res.getString(
                unapprovedContentBlocked ? R.string.account_management_child_content_approved
                        : R.string.account_management_child_content_all);
        childContent.setSummary(contentText);
        childContent.setSelectable(false);

        final String safeSitesText = res.getString(
                prefService.isSupervisedUserSafeSitesEnabled()
                        ? R.string.text_on : R.string.text_off);
        childSafeSites.setSummary(safeSitesText);
        childSafeSites.setSelectable(false);
    } else {
        PreferenceScreen prefScreen = getPreferenceScreen();
        prefScreen.removePreference(findPreference(PREF_PARENTAL_SETTINGS));
        prefScreen.removePreference(parentAccounts);
        prefScreen.removePreference(childContent);
        prefScreen.removePreference(childSafeSites);
    }
}
 
Example 2
Source File: AccountManagementFragment.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private void configureChildAccountPreferences() {
    Preference parentAccounts = findPreference(PREF_PARENT_ACCOUNTS);
    Preference childContent = findPreference(PREF_CHILD_CONTENT);
    Preference childSafeSites = findPreference(PREF_CHILD_SAFE_SITES);
    if (ChildAccountService.isChildAccount()) {
        Resources res = getActivity().getResources();
        PrefServiceBridge prefService = PrefServiceBridge.getInstance();

        String firstParent = prefService.getSupervisedUserCustodianEmail();
        String secondParent = prefService.getSupervisedUserSecondCustodianEmail();
        String parentText;

        if (!secondParent.isEmpty()) {
            parentText = res.getString(R.string.account_management_two_parent_names,
                    firstParent, secondParent);
        } else if (!firstParent.isEmpty()) {
            parentText = res.getString(R.string.account_management_one_parent_name,
                    firstParent);
        } else {
            parentText = res.getString(R.string.account_management_no_parental_data);
        }
        parentAccounts.setSummary(parentText);
        parentAccounts.setSelectable(false);

        final boolean unapprovedContentBlocked =
                prefService.getDefaultSupervisedUserFilteringBehavior()
                == PrefServiceBridge.SUPERVISED_USER_FILTERING_BLOCK;
        final String contentText = res.getString(
                unapprovedContentBlocked ? R.string.account_management_child_content_approved
                        : R.string.account_management_child_content_all);
        childContent.setSummary(contentText);
        childContent.setSelectable(false);

        final String safeSitesText = res.getString(
                prefService.isSupervisedUserSafeSitesEnabled()
                        ? R.string.text_on : R.string.text_off);
        childSafeSites.setSummary(safeSitesText);
        childSafeSites.setSelectable(false);
    } else {
        PreferenceScreen prefScreen = getPreferenceScreen();
        prefScreen.removePreference(findPreference(PREF_PARENTAL_SETTINGS));
        prefScreen.removePreference(parentAccounts);
        prefScreen.removePreference(childContent);
        prefScreen.removePreference(childSafeSites);
    }
}
 
Example 3
Source File: AccountManagementFragment.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private void configureChildAccountPreferences() {
    Preference parentAccounts = findPreference(PREF_PARENT_ACCOUNTS);
    Preference childContent = findPreference(PREF_CHILD_CONTENT);
    if (mProfile.isChild()) {
        Resources res = getActivity().getResources();
        PrefServiceBridge prefService = PrefServiceBridge.getInstance();

        String firstParent = prefService.getSupervisedUserCustodianEmail();
        String secondParent = prefService.getSupervisedUserSecondCustodianEmail();
        String parentText;

        if (!secondParent.isEmpty()) {
            parentText = res.getString(R.string.account_management_two_parent_names,
                    firstParent, secondParent);
        } else if (!firstParent.isEmpty()) {
            parentText = res.getString(R.string.account_management_one_parent_name,
                    firstParent);
        } else {
            parentText = res.getString(R.string.account_management_no_parental_data);
        }
        parentAccounts.setSummary(parentText);
        parentAccounts.setSelectable(false);
        ((ChromeBasePreference) parentAccounts).setUseReducedPadding(true);

        final int childContentSummary;
        int defaultBehavior = prefService.getDefaultSupervisedUserFilteringBehavior();
        if (defaultBehavior == PrefServiceBridge.SUPERVISED_USER_FILTERING_BLOCK) {
            childContentSummary = R.string.account_management_child_content_approved;
        } else if (prefService.isSupervisedUserSafeSitesEnabled()) {
            childContentSummary = R.string.account_management_child_content_filter_mature;
        } else {
            childContentSummary = R.string.account_management_child_content_all;
        }
        childContent.setSummary(childContentSummary);
        // TODO(dgn): made selectable to show the dividers. Find a way to avoid this. A side
        // effect is that it shows a tap ripple on an item that is not interactive.
        // childContent.setSelectable(false);

        Drawable newIcon = ApiCompatibilityUtils.getDrawable(
                getResources(), R.drawable.ic_drive_site_white_24dp);
        newIcon.mutate().setColorFilter(
                ApiCompatibilityUtils.getColor(getResources(), R.color.google_grey_600),
                PorterDuff.Mode.SRC_IN);
        childContent.setIcon(newIcon);
    } else {
        PreferenceScreen prefScreen = getPreferenceScreen();
        prefScreen.removePreference(findPreference(PREF_PARENTAL_SETTINGS));
        prefScreen.removePreference(parentAccounts);
        prefScreen.removePreference(childContent);
    }
}