Example usage for android.content Context getTheme

List of usage examples for android.content Context getTheme

Introduction

In this page you can find the example usage for android.content Context getTheme.

Prototype

@ViewDebug.ExportedProperty(deepExport = true)
public abstract Resources.Theme getTheme();

Source Link

Document

Return the Theme object associated with this Context.

Usage

From source file:com.grarak.kerneladiutor.utils.ViewUtils.java

public static int getTextSecondaryColor(Context context) {
    TypedValue value = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.textColorSecondary, value, true);
    return value.data;
}

From source file:com.grarak.kerneladiutor.utils.ViewUtils.java

public static int getColorPrimaryColor(Context context) {
    TypedValue value = new TypedValue();
    context.getTheme().resolveAttribute(R.attr.colorPrimary, value, true);
    return value.data;
}

From source file:com.grarak.kerneladiutor.utils.ViewUtils.java

public static int getColorPrimaryDarkColor(Context context) {
    TypedValue value = new TypedValue();
    context.getTheme().resolveAttribute(R.attr.colorPrimaryDark, value, true);
    return value.data;
}

From source file:com.grarak.kerneladiutor.utils.ViewUtils.java

public static int getThemeAccentColor(Context context) {
    TypedValue value = new TypedValue();
    context.getTheme().resolveAttribute(R.attr.colorAccent, value, true);
    return value.data;
}

From source file:com.agenmate.lollipop.util.ViewUtils.java

public static int getActionBarSize(@NonNull Context context) {
    TypedValue value = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.actionBarSize, value, true);
    int actionBarSize = TypedValue.complexToDimensionPixelSize(value.data,
            context.getResources().getDisplayMetrics());
    return actionBarSize;
}

From source file:com.nadmm.airports.utils.UiUtils.java

static public Drawable getDefaultTintedDrawable(Context context, int resid) {
    TypedValue value = new TypedValue();
    ColorStateList tintList = null;//from  w  w w . j av a 2 s. co m
    if (context.getTheme().resolveAttribute(android.R.attr.textColorSecondary, value, true)) {
        tintList = context.getResources().getColorStateList(value.resourceId);
    }

    return getTintedDrawable(context, resid, tintList);
}

From source file:com.android.datetimepicker.Utils.java

/**
 * Gets the colorAccent from the current context, if possible/available
 * @param context The context to use as reference for the color
 * @return the accent color of the current context
 *//*www . j  a  v  a  2  s  .  c  o  m*/
// Source from MDTP
public static int getAccentColorFromThemeIfAvailable(Context context) {
    TypedValue typedValue = new TypedValue();
    // First, try the android:colorAccent
    if (Build.VERSION.SDK_INT >= 21) {
        context.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true);
        return typedValue.data;
    }
    // Next, try colorAccent from support lib
    int colorAccentResId = context.getResources().getIdentifier("colorAccent", "attr",
            context.getPackageName());
    if (colorAccentResId != 0 && context.getTheme().resolveAttribute(colorAccentResId, typedValue, true)) {
        return typedValue.data;
    }

    return ContextCompat.getColor(context, R.color.accent_color);
}

From source file:android.support.v7ox.app.AppCompatDialog.java

private static int getThemeResId(Context context, int themeId) {
    if (themeId == 0) {
        // If the provided theme is 0, then retrieve the dialogTheme from our theme
        TypedValue outValue = new TypedValue();
        context.getTheme().resolveAttribute(R.attr.dialogTheme_ox, outValue, true);
        themeId = outValue.resourceId;// www. ja v  a  2 s.c o  m
    }
    return themeId;
}

From source file:com.doctoror.fuckoffmusicplayer.presentation.util.BindingAdapters.java

@NonNull
private static ColorStateList activatedTint(@NonNull final Context context, @ColorInt final int tintNormal) {

    final int[][] states = new int[][] { new int[] { android.R.attr.state_activated }, new int[0] };

    final int[] colors = new int[] { ThemeUtils.getColor(context.getTheme(), R.attr.colorAccent), tintNormal };

    return new ColorStateList(states, colors);
}

From source file:com.flexible.flexibleadapter.utils.DrawableUtils.java

/**
 * Helper to get the default selectableItemBackground drawable of the
 * {@code R.attr.selectableItemBackground} attribute of the overridden style.
 *
 * @param context the context/* www  .  ja  v a2  s  . c  o  m*/
 * @return Default selectable item background drawable
 * @since 5.0.0-rc1
 */
public static Drawable getSelectableItemBackground(Context context) {
    TypedValue outValue = new TypedValue();
    // It's important to not use the android.R because this wouldn't add the overridden drawable
    context.getTheme().resolveAttribute(R.attr.selectableItemBackground, outValue, true);
    return getDrawableCompat(context, outValue.resourceId);
}