android.support.v7.appcompat.R Java Examples

The following examples show how to use android.support.v7.appcompat.R. 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: JDrawerArrowDrawable.java    From jus with Apache License 2.0 6 votes vote down vote up
/**
 * @param context used to get the configuration for the drawable from
 */
JDrawerArrowDrawable(Context context) {
    final TypedArray typedArray = context.getTheme()
            .obtainStyledAttributes(null, R.styleable.DrawerArrowToggle,
                    R.attr.drawerArrowStyle,
                    R.style.Base_Widget_AppCompat_DrawerArrowToggle);
    mPaint.setAntiAlias(true);
    mPaint.setColor(typedArray.getColor(R.styleable.DrawerArrowToggle_color, 0));
    mSize = typedArray.getDimensionPixelSize(R.styleable.DrawerArrowToggle_drawableSize, 0);
    mBarSize = typedArray.getDimension(R.styleable.DrawerArrowToggle_barLength, 0);
    mTopBottomArrowSize = typedArray
            .getDimension(R.styleable.DrawerArrowToggle_arrowHeadLength, 0);
    mBarThickness = typedArray.getDimension(R.styleable.DrawerArrowToggle_thickness, 0);
    mBarGap = typedArray.getDimension(R.styleable.DrawerArrowToggle_gapBetweenBars, 0);
    mSpin = typedArray.getBoolean(R.styleable.DrawerArrowToggle_spinBars, true);
    mMiddleArrowSize = typedArray
            .getDimension(R.styleable.DrawerArrowToggle_arrowShaftLength, 0);
    typedArray.recycle();
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.SQUARE);
    mPaint.setStrokeWidth(mBarThickness);
}
 
Example #2
Source File: DrawerArrowDrawable.java    From browser with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param context
 *            used to get the configuration for the drawable from
 */
public DrawerArrowDrawable(Context context) {
	final TypedArray typedArray = context.getTheme().obtainStyledAttributes(null,
			R.styleable.DrawerArrowToggle, R.attr.drawerArrowStyle,
			R.style.Base_Widget_AppCompat_DrawerArrowToggle);
	mPaint.setAntiAlias(true);
	mPaint.setColor(typedArray.getColor(R.styleable.DrawerArrowToggle_color, 0));
	mSize = typedArray.getDimensionPixelSize(R.styleable.DrawerArrowToggle_drawableSize, 0);
	mBarSize =0;// typedArray.getDimension(R.styleable.DrawerArrowToggle_barSize, 0);
	mTopBottomArrowSize = //typedArray.getDimension(R.styleable.DrawerArrowToggle_topBottomBarArrowSize, 0);
	mBarThickness = typedArray.getDimension(R.styleable.DrawerArrowToggle_thickness, 0);
	mBarGap = typedArray.getDimension(R.styleable.DrawerArrowToggle_gapBetweenBars, 0);
	mSpin = typedArray.getBoolean(R.styleable.DrawerArrowToggle_spinBars, true);
	mMiddleArrowSize =0;// typedArray.getDimension(R.styleable.DrawerArrowToggle_middleBarArrowSize, 0);
	typedArray.recycle();
	mPaint.setStyle(Paint.Style.STROKE);
	mPaint.setStrokeJoin(Paint.Join.ROUND);
	mPaint.setStrokeCap(Paint.Cap.SQUARE);
	mPaint.setStrokeWidth(mBarThickness);
}
 
Example #3
Source File: ActionBarDrawerToggle.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Drawable getThemeUpIndicator() {
    final TypedArray a = getActionBarThemedContext().obtainStyledAttributes(null,
            new int[]{android.R.attr.homeAsUpIndicator}, android.R.attr.actionBarStyle, 0);
    final Drawable result = a.getDrawable(0);
    a.recycle();
    return result;
}
 
Example #4
Source File: SkinCompatDrawableManager.java    From Android-skin-support with MIT License 5 votes vote down vote up
static PorterDuff.Mode getTintMode(final int resId) {
    PorterDuff.Mode mode = null;

    if (resId == R.drawable.abc_switch_thumb_material) {
        mode = PorterDuff.Mode.MULTIPLY;
    }

    return mode;
}
 
Example #5
Source File: SkinCompatDrawableManager.java    From Android-skin-support with MIT License 5 votes vote down vote up
ColorStateList getTintList(@NonNull Context context, @DrawableRes int resId) {
    // Try the cache first (if it exists)
    ColorStateList tint = getTintListFromCache(context, resId);

    if (tint == null) {
        // ...if the cache did not contain a color state list, try and create one
        if (resId == R.drawable.abc_edit_text_material) {
            tint = SkinCompatResources.getColorStateList(context, R.color.abc_tint_edittext);
        } else if (resId == R.drawable.abc_switch_track_mtrl_alpha) {
            tint = SkinCompatResources.getColorStateList(context, R.color.abc_tint_switch_track);
        } else if (resId == R.drawable.abc_switch_thumb_material) {
            tint = createSwitchThumbColorStateList(context);
        } else if (resId == R.drawable.abc_btn_default_mtrl_shape) {
            tint = createDefaultButtonColorStateList(context);
        } else if (resId == R.drawable.abc_btn_borderless_material) {
            tint = createBorderlessButtonColorStateList(context);
        } else if (resId == R.drawable.abc_btn_colored_material) {
            tint = createColoredButtonColorStateList(context);
        } else if (resId == R.drawable.abc_spinner_mtrl_am_alpha
                || resId == R.drawable.abc_spinner_textfield_background_material) {
            tint = SkinCompatResources.getColorStateList(context, R.color.abc_tint_spinner);
        } else if (arrayContains(TINT_COLOR_CONTROL_NORMAL, resId)) {
            tint = getThemeAttrColorStateList(context, R.attr.colorControlNormal);
        } else if (arrayContains(TINT_COLOR_CONTROL_STATE_LIST, resId)) {
            tint = SkinCompatResources.getColorStateList(context, R.color.abc_tint_default);
        } else if (arrayContains(TINT_CHECKABLE_BUTTON_LIST, resId)) {
            tint = SkinCompatResources.getColorStateList(context, R.color.abc_tint_btn_checkable);
        } else if (resId == R.drawable.abc_seekbar_thumb_material) {
            tint = SkinCompatResources.getColorStateList(context, R.color.abc_tint_seek_thumb);
        }

        if (tint != null) {
            addTintListToCache(context, resId, tint);
        }
    }
    return tint;
}
 
Example #6
Source File: SkinCompatDrawableManager.java    From Android-skin-support with MIT License 5 votes vote down vote up
private ColorStateList createButtonColorStateList(@NonNull final Context context,
                                                  @ColorInt final int baseColor) {
    final int[][] states = new int[4][];
    final int[] colors = new int[4];
    int i = 0;

    final int colorControlHighlight = getThemeAttrColor(context, R.attr.colorControlHighlight);
    final int disabledColor = getDisabledThemeAttrColor(context, R.attr.colorButtonNormal);

    // Disabled state
    states[i] = SkinCompatThemeUtils.DISABLED_STATE_SET;
    colors[i] = disabledColor;
    i++;

    states[i] = SkinCompatThemeUtils.PRESSED_STATE_SET;
    colors[i] = compositeColors(colorControlHighlight, baseColor);
    i++;

    states[i] = SkinCompatThemeUtils.FOCUSED_STATE_SET;
    colors[i] = compositeColors(colorControlHighlight, baseColor);
    i++;

    // Default enabled state
    states[i] = SkinCompatThemeUtils.EMPTY_STATE_SET;
    colors[i] = baseColor;
    i++;

    return new ColorStateList(states, colors);
}
 
Example #7
Source File: SkinCompatDrawableManager.java    From Android-skin-support with MIT License 5 votes vote down vote up
private void checkVectorDrawableSetup(@NonNull Context context) {
    if (mHasCheckedVectorDrawableSetup) {
        // We've already checked so return now...
        return;
    }
    // Here we will check that a known Vector drawable resource inside AppCompat can be
    // correctly decoded
    mHasCheckedVectorDrawableSetup = true;
    final Drawable d = getDrawable(context, R.drawable.abc_vector_test);
    if (d == null || !isVectorDrawable(d)) {
        mHasCheckedVectorDrawableSetup = false;
        throw new IllegalStateException("This app has been built with an incorrect "
                + "configuration. Please configure your build for VectorDrawableCompat.");
    }
}
 
Example #8
Source File: SkinCompatDrawableManager.java    From Android-skin-support with MIT License 4 votes vote down vote up
private ColorStateList createSwitchThumbColorStateList(Context context) {
    final int[][] states = new int[3][];
    final int[] colors = new int[3];
    int i = 0;

    final ColorStateList thumbColor = SkinCompatThemeUtils.getThemeAttrColorStateList(context,
            R.attr.colorSwitchThumbNormal);

    if (thumbColor != null && thumbColor.isStateful()) {
        // If colorSwitchThumbNormal is a valid ColorStateList, extract the default and
        // disabled colors from it

        // Disabled state
        states[i] = SkinCompatThemeUtils.DISABLED_STATE_SET;
        colors[i] = thumbColor.getColorForState(states[i], 0);
        i++;

        states[i] = SkinCompatThemeUtils.CHECKED_STATE_SET;
        colors[i] = SkinCompatThemeUtils.getThemeAttrColor(context, R.attr.colorControlActivated);
        i++;

        // Default enabled state
        states[i] = SkinCompatThemeUtils.EMPTY_STATE_SET;
        colors[i] = thumbColor.getDefaultColor();
        i++;
    } else {
        // Else we'll use an approximation using the default disabled alpha

        // Disabled state
        states[i] = SkinCompatThemeUtils.DISABLED_STATE_SET;
        colors[i] = SkinCompatThemeUtils.getDisabledThemeAttrColor(context, R.attr.colorSwitchThumbNormal);
        i++;

        states[i] = SkinCompatThemeUtils.CHECKED_STATE_SET;
        colors[i] = SkinCompatThemeUtils.getThemeAttrColor(context, R.attr.colorControlActivated);
        i++;

        // Default enabled state
        states[i] = SkinCompatThemeUtils.EMPTY_STATE_SET;
        colors[i] = SkinCompatThemeUtils.getThemeAttrColor(context, R.attr.colorSwitchThumbNormal);
        i++;
    }

    return new ColorStateList(states, colors);
}
 
Example #9
Source File: DrawerArrowDrawable.java    From Overchan-Android with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param context used to get the configuration for the drawable from
 */
DrawerArrowDrawable(Context context) {
    /*final TypedArray typedArray = context.getTheme()
            .obtainStyledAttributes(null, R.styleable.DrawerArrowToggle,
                    R.attr.drawerArrowStyle,
                    R.style.Base_Widget_AppCompat_DrawerArrowToggle);
    mPaint.setAntiAlias(true);
    mPaint.setColor(typedArray.getColor(R.styleable.DrawerArrowToggle_color, 0));
    mSize = typedArray.getDimensionPixelSize(R.styleable.DrawerArrowToggle_drawableSize, 0);
    mBarSize = typedArray.getDimension(R.styleable.DrawerArrowToggle_barSize, 0);
    mTopBottomArrowSize = typedArray
            .getDimension(R.styleable.DrawerArrowToggle_topBottomBarArrowSize, 0);
    mBarThickness = typedArray.getDimension(R.styleable.DrawerArrowToggle_thickness, 0);
    mBarGap = typedArray.getDimension(R.styleable.DrawerArrowToggle_gapBetweenBars, 0);
    mSpin = typedArray.getBoolean(R.styleable.DrawerArrowToggle_spinBars, true);
    mMiddleArrowSize = typedArray
            .getDimension(R.styleable.DrawerArrowToggle_middleBarArrowSize, 0);
    typedArray.recycle();*/
    
    TypedValue typedValue = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.textColorSecondary, typedValue, true);
    int color;
    if (typedValue.type >= TypedValue.TYPE_FIRST_COLOR_INT && typedValue.type <= TypedValue.TYPE_LAST_COLOR_INT) {
        color = typedValue.data;
    } else {
        try {
            color = CompatibilityUtils.getColor(context.getResources(), typedValue.resourceId);
        } catch (Exception e) {
            color = 0;
        }
    }
    
    mPaint.setAntiAlias(true);
    mPaint.setColor(color);
    mSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24.0f, context.getResources().getDisplayMetrics());
    mBarSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 18.0f, context.getResources().getDisplayMetrics());
    mTopBottomArrowSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 11.31f, context.getResources().getDisplayMetrics());
    mBarThickness = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2.0f, context.getResources().getDisplayMetrics());
    mBarGap = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3.0f, context.getResources().getDisplayMetrics());
    mSpin = true;
    mMiddleArrowSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16.0f, context.getResources().getDisplayMetrics());

    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.SQUARE);
    mPaint.setStrokeWidth(mBarThickness);
}
 
Example #10
Source File: SkinMaterialTextInputEditText.java    From Android-skin-support with MIT License 4 votes vote down vote up
public SkinMaterialTextInputEditText(Context context, AttributeSet attrs) {
    this(context, attrs, R.attr.editTextStyle);
}
 
Example #11
Source File: SkinCompatButton.java    From Android-skin-support with MIT License 4 votes vote down vote up
public SkinCompatButton(Context context, AttributeSet attrs) {
    this(context, attrs, R.attr.buttonStyle);
}
 
Example #12
Source File: SkinCompatImageButton.java    From Android-skin-support with MIT License 4 votes vote down vote up
public SkinCompatImageButton(Context context, AttributeSet attrs) {
    this(context, attrs, R.attr.imageButtonStyle);
}
 
Example #13
Source File: SkinCompatEditText.java    From Android-skin-support with MIT License 4 votes vote down vote up
public SkinCompatEditText(Context context, AttributeSet attrs) {
    this(context, attrs, R.attr.editTextStyle);
}
 
Example #14
Source File: SkinCompatEditText.java    From AndroidSkinAnimator with MIT License 4 votes vote down vote up
public SkinCompatEditText(Context context, AttributeSet attrs) {
    this(context, attrs, R.attr.editTextStyle);
}
 
Example #15
Source File: SkinCompatDrawableManager.java    From Android-skin-support with MIT License 4 votes vote down vote up
private ColorStateList createColoredButtonColorStateList(@NonNull Context context) {
    return createButtonColorStateList(context,
            getThemeAttrColor(context, R.attr.colorAccent));
}
 
Example #16
Source File: SkinCompatDrawableManager.java    From Android-skin-support with MIT License 4 votes vote down vote up
private ColorStateList createDefaultButtonColorStateList(@NonNull Context context) {
    return createButtonColorStateList(context,
            getThemeAttrColor(context, R.attr.colorButtonNormal));
}
 
Example #17
Source File: SkinCompatDrawableManager.java    From Android-skin-support with MIT License 4 votes vote down vote up
static boolean tintDrawableUsingColorFilter(@NonNull Context context,
                                            @DrawableRes final int resId, @NonNull Drawable drawable) {
    PorterDuff.Mode tintMode = DEFAULT_MODE;
    boolean colorAttrSet = false;
    int colorAttr = 0;
    int alpha = -1;

    if (arrayContains(COLORFILTER_TINT_COLOR_CONTROL_NORMAL, resId)) {
        colorAttr = R.attr.colorControlNormal;
        colorAttrSet = true;
    } else if (arrayContains(COLORFILTER_COLOR_CONTROL_ACTIVATED, resId)) {
        colorAttr = R.attr.colorControlActivated;
        colorAttrSet = true;
    } else if (arrayContains(COLORFILTER_COLOR_BACKGROUND_MULTIPLY, resId)) {
        colorAttr = android.R.attr.colorBackground;
        colorAttrSet = true;
        tintMode = PorterDuff.Mode.MULTIPLY;
    } else if (resId == R.drawable.abc_list_divider_mtrl_alpha) {
        colorAttr = android.R.attr.colorForeground;
        colorAttrSet = true;
        alpha = Math.round(0.16f * 255);
    } else if (resId == R.drawable.abc_dialog_material_background) {
        colorAttr = android.R.attr.colorBackground;
        colorAttrSet = true;
    }

    if (colorAttrSet) {
        if (SkinCompatDrawableUtils.canSafelyMutateDrawable(drawable)) {
            drawable = drawable.mutate();
        }

        final int color = getThemeAttrColor(context, colorAttr);
        drawable.setColorFilter(getPorterDuffColorFilter(color, tintMode));

        if (alpha != -1) {
            drawable.setAlpha(alpha);
        }

        if (DEBUG) {
            Log.d(TAG, "[tintDrawableUsingColorFilter] Tinted "
                    + context.getResources().getResourceName(resId) +
                    " with color: #" + Integer.toHexString(color));
        }
        return true;
    }
    return false;
}
 
Example #18
Source File: SkinCompatButton.java    From AndroidSkinAnimator with MIT License 4 votes vote down vote up
public SkinCompatButton(Context context, AttributeSet attrs) {
    this(context, attrs, R.attr.buttonStyle);
}
 
Example #19
Source File: SkinCompatImageButton.java    From AndroidSkinAnimator with MIT License 4 votes vote down vote up
public SkinCompatImageButton(Context context, AttributeSet attrs) {
    this(context, attrs, R.attr.imageButtonStyle);
}
 
Example #20
Source File: ActionBarDrawerToggle.java    From Overchan-Android with GNU General Public License v3.0 3 votes vote down vote up
/**
 * This method should be called by your <code>Activity</code>'s
 * {@link Activity#onOptionsItemSelected(android.view.MenuItem) onOptionsItemSelected} method.
 * If it returns true, your <code>onOptionsItemSelected</code> method should return true and
 * skip further processing.
 *
 * @param item the MenuItem instance representing the selected menu item
 * @return true if the event was handled and further processing should not occur
 */
public boolean onOptionsItemSelected(MenuItem item) {
    if (item != null && item.getItemId() == android.R.id.home && mDrawerIndicatorEnabled) {
        toggle();
        return true;
    }
    return false;
}