/** * @see #getIcon(Preference) */ @Deprecated @Nullable public static Drawable getSupportIcon(final @NonNull Preference preference) { if (preference instanceof CustomIconPreference) { return ((CustomIconPreference) preference).getSupportIcon(); } final PreferenceIconHelper iconHelper = PREFERENCE_ICON_HELPERS.get(preference); if (iconHelper != null) { return iconHelper.getIcon(); } return preference.getIcon(); }
/** * Append a pref to given {@code target}. If target is null, the current screen is taken * The pref icon is tint according to color * * @param pref Preference to add * @param target The target to add the pref to, or null for current screen * @return true if successfully added */ protected boolean appendPreference(Preference pref, @Nullable PreferenceGroup target) { if (target == null) { if ((target = getPreferenceScreen()) == null) { return false; } } if (getIconTintColor() != null && pref.getIcon() != null && isAllowedToTint(pref)) { pref.setIcon(_cu.tintDrawable(pref.getIcon(), getIconTintColor())); } return target.addPreference(pref); } }
private static void tintIcons(final Context c, Preference preference) { if (preference instanceof PreferenceGroup) { PreferenceGroup group = ((PreferenceGroup) preference); for (int i = 0; i < group.getPreferenceCount(); i++) { tintIcons(c, group.getPreference(i)); } } else { CompatUtils.setDrawableColorAttr(c, preference.getIcon(), android.R.attr.textColorSecondary); } }
private void tintPrefIconsRecursive(PreferenceGroup prefGroup, @ColorInt int iconColor) { if (prefGroup != null && isAdded()) { int prefCount = prefGroup.getPreferenceCount(); for (int i = 0; i < prefCount; i++) { Preference pref = prefGroup.getPreference(i); if (pref != null) { if (isAllowedToTint(pref)) { pref.setIcon(_cu.tintDrawable(pref.getIcon(), iconColor)); } if (pref instanceof PreferenceGroup) { tintPrefIconsRecursive((PreferenceGroup) pref, iconColor); } } } } }
originalIcon = mBuildFingerprint.getIcon(); mBuildFingerprint.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override