FileDocCategorySizeDatePackage
KeyguardUserSwitcherScrim.javaAPI DocAndroid 5.1 API3713Thu Mar 12 22:22:42 GMT 2015com.android.systemui.statusbar.policy

KeyguardUserSwitcherScrim

public class KeyguardUserSwitcherScrim extends android.graphics.drawable.Drawable implements View.OnLayoutChangeListener
Gradient background for the user switcher on Keyguard.

Fields Summary
private static final float
OUTER_EXTENT
private static final float
INNER_EXTENT
private int
mDarkColor
private int
mTop
private int
mAlpha
private android.graphics.Paint
mRadialGradientPaint
private int
mLayoutWidth
Constructors Summary
public KeyguardUserSwitcherScrim(android.view.View host)


       
        host.addOnLayoutChangeListener(this);
        mDarkColor = host.getResources().getColor(
                R.color.keyguard_user_switcher_background_gradient_color);
    
Methods Summary
public voiddraw(android.graphics.Canvas canvas)

        boolean isLtr = getLayoutDirection() == LayoutDirection.LTR;
        Rect bounds = getBounds();
        float width = bounds.width() * OUTER_EXTENT;
        float height = (mTop + bounds.height()) * OUTER_EXTENT;
        canvas.translate(0, -mTop);
        canvas.scale(1, height / width);
        canvas.drawRect(isLtr ? bounds.right - width : 0, 0,
                isLtr ? bounds.right : bounds.left + width, width, mRadialGradientPaint);
    
public intgetAlpha()

        return mAlpha;
    
public intgetOpacity()

        return PixelFormat.TRANSLUCENT;
    
public voidonLayoutChange(android.view.View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom)

        if (left != oldLeft || top != oldTop || right != oldRight || bottom != oldBottom) {
            mLayoutWidth = right - left;
            mTop = top;
            updatePaint();
        }
    
public voidsetAlpha(int alpha)

        mAlpha = alpha;
        updatePaint();
        invalidateSelf();
    
public voidsetColorFilter(android.graphics.ColorFilter cf)

    
private voidupdatePaint()

        if (mLayoutWidth == 0) {
            return;
        }
        float radius = mLayoutWidth * OUTER_EXTENT;
        boolean isLtr = getLayoutDirection() == LayoutDirection.LTR;
        mRadialGradientPaint.setShader(
                new RadialGradient(isLtr ? mLayoutWidth : 0, 0, radius,
                        new int[] { Color.argb(
                                        (int) (Color.alpha(mDarkColor) * mAlpha / 255f), 0, 0, 0),
                                Color.TRANSPARENT },
                        new float[] { Math.max(0f, mLayoutWidth * INNER_EXTENT / radius), 1f },
                        Shader.TileMode.CLAMP));