Java Code Examples for de.mrapp.android.util.ThemeUtil#getColor()
The following examples show how to use
de.mrapp.android.util.ThemeUtil#getColor() .
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: TabSwitcherDrawable.java From ChromeLikeTabSwitcher with Apache License 2.0 | 6 votes |
/** * Creates a new drawable, which allows to display the number of tabs, which are currently * contained by a {@link TabSwitcher}. * * @param context * The context, which should be used by the drawable, as an instance of the class {@link * Context}. The context may not be null */ public TabSwitcherDrawable(@NonNull final Context context) { Condition.INSTANCE.ensureNotNull(context, "The context may not be null"); Resources resources = context.getResources(); size = resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_size); textSizeNormal = resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_normal); textSizeSmall = resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_small); background = ContextCompat.getDrawable(context, R.drawable.tab_switcher_drawable_background) .mutate(); paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(Color.WHITE); paint.setTextAlign(Align.CENTER); paint.setTextSize(textSizeNormal); paint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD)); label = Integer.toString(0); int tint = ThemeUtil.getColor(context, android.R.attr.textColorPrimary); setColorFilter(tint, PorterDuff.Mode.MULTIPLY); }
Example 2
Source File: ThemeHelper.java From ChromeLikeTabSwitcher with Apache License 2.0 | 6 votes |
/** * Returns the color, which corresponds to a specific theme attribute, regarding the theme, * which is used when using a specific layout. * * @param layout * The layout as a value of the enum {@link Layout}. The layout may not be null * @param resourceId * The resource id of the theme attribute, the color should be obtained from, as an * {@link Integer} value. The resource id must correspond to a valid theme attribute * @return The color, which has been obtained, as an {@link Integer} value */ @ColorInt public int getColor(@NonNull final Layout layout, @AttrRes final int resourceId) { try { return ThemeUtil.getColor(context, resourceId); } catch (NotFoundException e1) { int themeResourceId = getThemeResourceId(layout); try { return ThemeUtil.getColor(context, themeResourceId, resourceId); } catch (NotFoundException e) { themeResourceId = obtainThemeFromThemeAttributes(layout, themeResourceId); return ThemeUtil.getColor(context, themeResourceId, resourceId); } } }
Example 3
Source File: PreferenceFragment.java From AndroidPreferenceActivity with Apache License 2.0 | 6 votes |
/** * Obtains the background of the button bar from the activity's current theme. */ private void obtainButtonBarBackground() { try { int color = ThemeUtil.getColor(getActivity(), R.attr.restoreDefaultsButtonBarBackground); setButtonBarBackgroundColor(color); } catch (NotFoundException e) { int resourceId = ThemeUtil .getResId(getActivity(), R.attr.restoreDefaultsButtonBarBackground, -1); if (resourceId != -1) { setButtonBarBackground(resourceId); } else { setButtonBarBackgroundColor( ContextCompat.getColor(getActivity(), R.color.button_bar_background_light)); } } }
Example 4
Source File: AbstractPreferenceFragment.java From AndroidPreferenceActivity with Apache License 2.0 | 5 votes |
/** * Obtains the appearance of the dividers, which are shown above preference categories, from the * activity's theme. */ private void obtainDividerDecoration() { int dividerColor; try { dividerColor = ThemeUtil.getColor(getActivity(), R.attr.dividerColor); } catch (NotFoundException e) { dividerColor = ContextCompat.getColor(getActivity(), R.color.preference_divider_color_light); } this.dividerDecoration.setDividerColor(dividerColor); this.dividerDecoration.setDividerHeight(DisplayUtil.dpToPixels(getActivity(), 1)); }
Example 5
Source File: PreferenceActivity.java From AndroidPreferenceActivity with Apache License 2.0 | 5 votes |
/** * Obtains the background color of the card view, which contains the currently shown preference * fragment, when using the split screen layout, from the activity's theme. */ private void obtainCardViewBackgroundColor() { int color; try { color = ThemeUtil.getColor(this, R.attr.cardViewBackgroundColor); } catch (NotFoundException e) { color = ContextCompat.getColor(this, R.color.card_view_background_light); } setCardViewBackgroundColor(color); }
Example 6
Source File: PreferenceActivity.java From AndroidPreferenceActivity with Apache License 2.0 | 5 votes |
/** * Obtains the background color of the toolbar, which is used to show the bread crumb of the * currently selected navigation preference, when using the split screen layout, from the * activity's theme. */ private void obtainBreadCrumbBackgroundColor() { int color; try { color = ThemeUtil.getColor(this, R.attr.breadCrumbBackgroundColor); } catch (NotFoundException e) { color = ContextCompat.getColor(this, R.color.bread_crumb_background_light); } setBreadCrumbBackgroundColor(color); }
Example 7
Source File: PreferenceActivity.java From AndroidPreferenceActivity with Apache License 2.0 | 5 votes |
/** * Obtains the background color of the currently selected navigation preference from the * activity's theme. */ private void obtainNavigationSelectionColor() { int color; try { color = ThemeUtil.getColor(this, R.attr.navigationSelectionColor); } catch (NotFoundException e) { color = ContextCompat.getColor(this, R.color.preference_selection_color_light); } setNavigationSelectionColor(color); }
Example 8
Source File: PreferenceActivity.java From AndroidPreferenceActivity with Apache License 2.0 | 5 votes |
/** * Obtains the color of the dividers, which are contained by the navigation. */ private void obtainNavigationDividerColor() { int color; try { color = ThemeUtil.getColor(this, R.attr.navigationDividerColor); } catch (NotFoundException e) { color = ContextCompat.getColor(this, R.color.preference_divider_color_light); } setNavigationDividerColor(color); }
Example 9
Source File: WizardDialog.java From AndroidMaterialDialog with Apache License 2.0 | 5 votes |
/** * Obtains the color of the tab indicator from a specific theme. * * @param themeResourceId * The resource id of the theme, the color should be obtained from, as an {@link * Integer} value */ private void obtainTabIndicatorColor(@StyleRes final int themeResourceId) { TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId, new int[]{R.attr.materialDialogTabIndicatorColor}); int defaultColor = ThemeUtil.getColor(getContext(), themeResourceId, R.attr.colorAccent); setTabIndicatorColor(typedArray.getColor(0, defaultColor)); }
Example 10
Source File: WizardDialog.java From AndroidMaterialDialog with Apache License 2.0 | 5 votes |
/** * Obtains the text color of the tabs from a specific theme. * * @param themeResourceId * The resource id of the theme, the text color should be obtained from, as an * {@link Integer} value */ private void obtainTabTextColor(@StyleRes final int themeResourceId) { TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId, new int[]{R.attr.materialDialogTabTextColor}); int defaultColor = ThemeUtil .getColor(getContext(), themeResourceId, android.R.attr.textColorSecondary); setTabTextColor(typedArray.getColor(0, defaultColor)); }
Example 11
Source File: WizardDialog.java From AndroidMaterialDialog with Apache License 2.0 | 5 votes |
/** * Obtains the selected text color of the tabs from a specific theme. * * @param themeResourceId * The resource id of the theme, the text color should be obtained from, as an * {@link Integer} value */ private void obtainTabSelectedTextColor(@StyleRes final int themeResourceId) { TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId, new int[]{R.attr.materialDialogTabSelectedTextColor}); int defaultColor = ThemeUtil .getColor(getContext(), themeResourceId, android.R.attr.textColorSecondary); setTabSelectedTextColor(typedArray.getColor(0, defaultColor)); }
Example 12
Source File: WizardDialog.java From AndroidMaterialDialog with Apache License 2.0 | 5 votes |
/** * Obtains the button text color from a specific theme. * * @param themeResourceId * The resource id of the theme, the text color should be obtained from, as an * {@link Integer} value */ private void obtainButtonTextColor(@StyleRes final int themeResourceId) { TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId, new int[]{R.attr.materialDialogButtonTextColor}); int defaultColor = ThemeUtil.getColor(getContext(), themeResourceId, R.attr.colorAccent); setButtonTextColor(typedArray.getColor(0, defaultColor)); }
Example 13
Source File: ProgressDialog.java From AndroidMaterialDialog with Apache License 2.0 | 5 votes |
/** * Obtains the color of the dialog's progress bar from a specific theme. * * @param themeResourceId * The resource id of the theme, the color should be obtained from, as an {@link * Integer} value */ private void obtainProgressBarColor(@StyleRes final int themeResourceId) { TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId, new int[]{R.attr.materialDialogProgressBarColor}); int defaultColor = ThemeUtil.getColor(getContext(), themeResourceId, R.attr.colorAccent); setProgressBarColor(typedArray.getColor(0, defaultColor)); }
Example 14
Source File: AbstractMaterialDialogBuilder.java From AndroidMaterialDialog with Apache License 2.0 | 5 votes |
/** * Obtains the message color from a specific theme. * * @param themeResourceId * The resource id of the theme, the message color should be obtained from, as an {@link * Integer} value */ private void obtainMessageColor(@StyleRes final int themeResourceId) { TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId, new int[]{R.attr.materialDialogMessageColor}); int defaultColor = ThemeUtil .getColor(getContext(), themeResourceId, android.R.attr.textColorSecondary); setMessageColor(typedArray.getColor(0, defaultColor)); }
Example 15
Source File: AbstractMaterialDialogBuilder.java From AndroidMaterialDialog with Apache License 2.0 | 5 votes |
/** * Obtains the title color from a specific theme. * * @param themeResourceId * The resource id of the theme, the title color should be obtained from, as an {@link * Integer} value */ private void obtainTitleColor(@StyleRes final int themeResourceId) { TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId, new int[]{R.attr.materialDialogTitleColor}); int defaultColor = ThemeUtil.getColor(getContext(), themeResourceId, android.R.attr.textColorPrimary); setTitleColor(typedArray.getColor(0, defaultColor)); }