Java Code Examples for android.support.v7.preference.Preference#setIcon()
The following examples show how to use
android.support.v7.preference.Preference#setIcon() .
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: GsPreferenceFragmentCompat.java From memetastic with GNU General Public License v3.0 | 6 votes |
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); } } } } }
Example 2
Source File: GsPreferenceFragmentCompat.java From memetastic with GNU General Public License v3.0 | 6 votes |
@Nullable @SuppressWarnings("SameParameterValue") protected Preference updatePreference(@StringRes int keyResId, @DrawableRes Integer iconRes, CharSequence title, CharSequence summary, Boolean visible) { Preference pref = findPreference(getString(keyResId)); if (pref != null) { if (summary != null) { pref.setSummary(summary); } if (title != null) { pref.setTitle(title); } if (iconRes != null && iconRes != 0) { if (isAllowedToTint(pref)) { pref.setIcon(_cu.tintDrawable(iconRes, getIconTintColor())); } else { pref.setIcon(iconRes); } } if (visible != null) { pref.setVisible(visible); } } return pref; }
Example 3
Source File: GsPreferenceFragmentCompat.java From openlauncher with Apache License 2.0 | 6 votes |
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); } } } } }
Example 4
Source File: GsPreferenceFragmentCompat.java From openlauncher with Apache License 2.0 | 6 votes |
@Nullable @SuppressWarnings("SameParameterValue") protected Preference updatePreference(@StringRes int keyResId, @DrawableRes Integer iconRes, CharSequence title, CharSequence summary, Boolean visible) { Preference pref = findPreference(getString(keyResId)); if (pref != null) { if (summary != null) { pref.setSummary(summary); } if (title != null) { pref.setTitle(title); } if (iconRes != null && iconRes != 0) { if (isAllowedToTint(pref)) { pref.setIcon(_cu.tintDrawable(iconRes, getIconTintColor())); } else { pref.setIcon(iconRes); } } if (visible != null) { pref.setVisible(visible); } } return pref; }
Example 5
Source File: GsPreferenceFragmentCompat.java From Stringlate with MIT License | 6 votes |
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); } } } } }
Example 6
Source File: GsPreferenceFragmentCompat.java From Stringlate with MIT License | 6 votes |
@Nullable @SuppressWarnings("SameParameterValue") protected Preference updatePreference(@StringRes int keyResId, @DrawableRes Integer iconRes, CharSequence title, CharSequence summary, Boolean visible) { Preference pref = findPreference(getString(keyResId)); if (pref != null) { if (summary != null) { pref.setSummary(summary); } if (title != null) { pref.setTitle(title); } if (iconRes != null && iconRes != 0) { if (isAllowedToTint(pref)) { pref.setIcon(_cu.tintDrawable(iconRes, getIconTintColor())); } else { pref.setIcon(iconRes); } } if (visible != null) { pref.setVisible(visible); } } return pref; }
Example 7
Source File: GsPreferenceFragmentCompat.java From kimai-android with MIT License | 6 votes |
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); } } } } }
Example 8
Source File: GsPreferenceFragmentCompat.java From kimai-android with MIT License | 6 votes |
@Nullable @SuppressWarnings("SameParameterValue") protected Preference updatePreference(@StringRes int keyResId, @DrawableRes Integer iconRes, CharSequence title, CharSequence summary, Boolean visible) { Preference pref = findPreference(getString(keyResId)); if (pref != null) { if (summary != null) { pref.setSummary(summary); } if (title != null) { pref.setTitle(title); } if (iconRes != null && iconRes != 0) { if (isAllowedToTint(pref)) { pref.setIcon(_cu.tintDrawable(iconRes, getIconTintColor())); } else { pref.setIcon(iconRes); } } if (visible != null) { pref.setVisible(visible); } } return pref; }
Example 9
Source File: PreferencesChannelsSystemFragment.java From notification-channel-compat with Apache License 2.0 | 5 votes |
@Override public void onCreatePreferences(Bundle savedInstance, String rootPreferenceKey) { Context activityContext = getActivity(); PreferenceManager preferenceManager = getPreferenceManager(); preferenceManager.setSharedPreferencesName(NotificationChannelManagerHelper.SHARED_PREFERENCE_NAME); PreferenceScreen preferenceScreen = preferenceManager.createPreferenceScreen(activityContext); setPreferenceScreen(preferenceScreen); ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(activityContext, R.style.PreferenceThemeOverlay); // We instance each Preference using our ContextThemeWrapper object PreferenceCategory preferenceCategory = new PreferenceCategory(contextThemeWrapper); getPreferenceScreen().addPreference(preferenceCategory); Preference systemPref = new Preference(contextThemeWrapper); systemPref.setTitle(R.string.notification_importance_blocked); systemPref.setSummary(R.string.write_settings); systemPref.setLayoutResource(R.layout.preference_goto_target); systemPref.setIcon(R.drawable.ic_error_outline); systemPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { NotificationChannelPreference.launchSystemNotificationsSettings(getContext(), null); return true; } }); preferenceCategory.addPreference(systemPref); }
Example 10
Source File: GsPreferenceFragmentCompat.java From memetastic with GNU General Public License v3.0 | 5 votes |
/** * 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); }
Example 11
Source File: GsPreferenceFragmentCompat.java From openlauncher with Apache License 2.0 | 5 votes |
/** * 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); }
Example 12
Source File: GsPreferenceFragmentCompat.java From Stringlate with MIT License | 5 votes |
/** * 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); }
Example 13
Source File: GsPreferenceFragmentCompat.java From kimai-android with MIT License | 5 votes |
/** * 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); }
Example 14
Source File: MoreInfoFragment.java From memetastic with GNU General Public License v3.0 | 4 votes |
@Override public synchronized void doUpdatePreferences() { super.doUpdatePreferences(); Context context = getContext(); if (context == null) { return; } Locale locale = Locale.getDefault(); String tmp; Preference pref; updateSummary(R.string.pref_key__more_info__project_license, getString(R.string.app_license_name)); // Basic app info if ((pref = findPreference(R.string.pref_key__more_info__app)) != null && pref.getSummary() == null) { pref.setIcon(R.drawable.ic_launcher); pref.setSummary(String.format(locale, "%s\nVersion v%s (%d)", _cu.getPackageIdReal(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0))); } // Extract some build information and publish in summary if ((pref = findPreference(R.string.pref_key__more_info__copy_build_information)) != null && pref.getSummary() == null) { String summary = String.format(locale, "\n<b>Package:</b> %s\n<b>Version:</b> v%s (%d)", _cu.getPackageIdReal(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0)); summary += (tmp = _cu.bcstr("FLAVOR", "")).isEmpty() ? "" : ("\n<b>Flavor:</b> " + tmp.replace("flavor", "")); summary += (tmp = _cu.bcstr("BUILD_TYPE", "")).isEmpty() ? "" : (" (" + tmp + ")"); summary += (tmp = _cu.bcstr("BUILD_DATE", "")).isEmpty() ? "" : ("\n<b>Build date:</b> " + tmp); summary += (tmp = _cu.getAppInstallationSource()).isEmpty() ? "" : ("\n<b>ISource:</b> " + tmp); summary += (tmp = _cu.bcstr("GITHASH", "")).isEmpty() ? "" : ("\n<b>VCS Hash:</b> " + tmp); pref.setSummary(_cu.htmlToSpanned(summary.trim().replace("\n", "<br/>"))); } // Extract project team from raw ressource, where 1 person = 4 lines // 1) Name/Title, 2) Description/Summary, 3) Link/View-Intent, 4) Empty line if ((pref = findPreference(R.string.pref_key__more_info__project_team)) != null && ((PreferenceGroup) pref).getPreferenceCount() == 0) { String[] data = (_cu.readTextfileFromRawRes(R.raw.project_team, "", "").trim() + "\n\n").split("\n"); for (int i = 0; i + 2 < data.length; i += 4) { Preference person = new Preference(context); person.setTitle(data[i]); person.setSummary(data[i + 1]); person.setIcon(R.drawable.ic_person_black_24dp); try { Uri uri = Uri.parse(data[i + 2]); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); person.setIntent(intent); } catch (Exception ignored) { } appendPreference(person, (PreferenceGroup) pref); } } if ((pref = findPreference(R.string.pref_key__more_info__help)) != null) { pref.setTitle(getString(R.string.help) + " / FAQ"); } }
Example 15
Source File: SettingsAboutFragment.java From openlauncher with Apache License 2.0 | 4 votes |
@Override public synchronized void doUpdatePreferences() { super.doUpdatePreferences(); Context context = getContext(); if (context == null) { return; } Locale locale = Locale.getDefault(); String tmp; Preference pref; updateSummary(R.string.pref_key__more_info__project_license, getString(R.string.app_license_name)); // Basic app info if ((pref = findPreference(R.string.pref_key__more_info__app)) != null && pref.getSummary() == null) { pref.setIcon(R.mipmap.ic_launcher); pref.setSummary(String.format(locale, "%s\nVersion v%s (%d)", _cu.getPackageIdReal(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0))); } // Extract some build information and publish in summary if ((pref = findPreference(R.string.pref_key__more_info__copy_build_information)) != null && pref.getSummary() == null) { String summary = String.format(locale, "\n<b>Package:</b> %s\n<b>Version:</b> v%s (%d)", _cu.getPackageIdReal(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0)); summary += (tmp = _cu.bcstr("FLAVOR", "")).isEmpty() ? "" : ("\n<b>Flavor:</b> " + tmp.replace("flavor", "")); summary += (tmp = _cu.bcstr("BUILD_TYPE", "")).isEmpty() ? "" : (" (" + tmp + ")"); summary += (tmp = _cu.bcstr("BUILD_DATE", "")).isEmpty() ? "" : ("\n<b>Build date:</b> " + tmp); summary += (tmp = _cu.getAppInstallationSource()).isEmpty() ? "" : ("\n<b>ISource:</b> " + tmp); summary += (tmp = _cu.bcstr("GITHASH", "")).isEmpty() ? "" : ("\n<b>VCS Hash:</b> " + tmp); pref.setSummary(_cu.htmlToSpanned(summary.trim().replace("\n", "<br/>"))); } // Extract project team from raw resource, where 1 person = 4 lines // 1) Name/Title, 2) Description/Summary, 3) Link/View-Intent, 4) Empty line if ((pref = findPreference(R.string.pref_key__more_info__project_team)) != null && ((PreferenceGroup) pref).getPreferenceCount() == 0) { String[] data = (_cu.readTextfileFromRawRes(R.raw.project, "", "").trim() + "\n\n").split("\n"); for (int i = 0; i + 2 < data.length; i += 4) { Preference person = new Preference(context); person.setTitle(data[i]); person.setSummary(data[i + 1]); person.setIcon(R.drawable.ic_person); try { Uri uri = Uri.parse(data[i + 2]); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); person.setIntent(intent); } catch (Exception ignored) { } appendPreference(person, (PreferenceGroup) pref); } } }
Example 16
Source File: MoreInfoFragment.java From Stringlate with MIT License | 4 votes |
@Override public synchronized void doUpdatePreferences() { super.doUpdatePreferences(); Context context = getContext(); if (context == null) { return; } Locale locale = Locale.getDefault(); String tmp; Preference pref; updateSummary(R.string.pref_key__more_info__project_license, getString(R.string.app_license_name)); // Basic app info if ((pref = findPreference(R.string.pref_key__more_info__app)) != null && pref.getSummary() == null) { pref.setIcon(R.drawable.ic_launcher); pref.setSummary(String.format(locale, "%s\nVersion v%s (%d)", _cu.getPackageName(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0))); } // Extract some build information and publish in summary if ((pref = findPreference(R.string.pref_key__more_info__copy_build_information)) != null && pref.getSummary() == null) { String summary = String.format(locale, "\n<b>Package:</b> %s\n<b>Version:</b> v%s (%d)", _cu.getPackageName(), _cu.getAppVersionName(), _cu.bcint("VERSION_CODE", 0)); summary += (tmp = _cu.bcstr("FLAVOR", "")).isEmpty() ? "" : ("\n<b>Flavor:</b> " + tmp.replace("flavor", "")); summary += (tmp = _cu.bcstr("BUILD_TYPE", "")).isEmpty() ? "" : (" (" + tmp + ")"); summary += (tmp = _cu.bcstr("BUILD_DATE", "")).isEmpty() ? "" : ("\n<b>Build date:</b> " + tmp); summary += (tmp = _cu.getAppInstallationSource()).isEmpty() ? "" : ("\n<b>ISource:</b> " + tmp); summary += (tmp = _cu.bcstr("GITHASH", "")).isEmpty() ? "" : ("\n<b>VCS Hash:</b> " + tmp); pref.setSummary(_cu.htmlToSpanned(summary.trim().replace("\n", "<br/>"))); } // Extract project team from raw ressource, where 1 person = 4 lines // 1) Name/Title, 2) Description/Summary, 3) Link/View-Intent, 4) Empty line if ((pref = findPreference(R.string.pref_key__more_info__project_team)) != null && ((PreferenceGroup) pref).getPreferenceCount() == 0) { String[] data = (_cu.readTextfileFromRawRes(R.raw.project_team, "", "").trim() + "\n\n").split("\n"); for (int i = 0; i + 2 < data.length; i += 4) { Preference person = new Preference(context); person.setTitle(data[i]); person.setSummary(data[i + 1]); person.setIcon(R.drawable.ic_person_black_24dp); try { Uri uri = Uri.parse(data[i + 2]); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); person.setIntent(intent); } catch (Exception ignored) { } appendPreference(person, (PreferenceGroup) pref); } } }