FileDocCategorySizeDatePackage
DebugOverlayView.javaAPI DocAndroid 5.1 API6186Thu Mar 12 22:22:42 GMT 2015com.android.systemui.recents.views

DebugOverlayView

public class DebugOverlayView extends android.widget.FrameLayout implements SeekBar.OnSeekBarChangeListener
A full screen overlay layer that allows us to draw views from throughout the system on the top most layer.

Fields Summary
static final int
sCornerRectSize
com.android.systemui.recents.RecentsConfiguration
mConfig
DebugOverlayViewCallbacks
mCb
ArrayList
mRects
String
mText
android.graphics.Paint
mDebugOutline
android.graphics.Paint
mTmpPaint
android.graphics.Rect
mTmpRect
boolean
mEnabled
android.widget.SeekBar
mPrimarySeekBar
android.widget.SeekBar
mSecondarySeekBar
Constructors Summary
public DebugOverlayView(android.content.Context context)


       
        this(context, null);
    
public DebugOverlayView(android.content.Context context, android.util.AttributeSet attrs)

        this(context, attrs, 0);
    
public DebugOverlayView(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr)

        this(context, attrs, defStyleAttr, 0);
    
public DebugOverlayView(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes)

        super(context, attrs, defStyleAttr, defStyleRes);
        mConfig = RecentsConfiguration.getInstance();
        mDebugOutline.setColor(0xFFff0000);
        mDebugOutline.setStyle(Paint.Style.STROKE);
        mDebugOutline.setStrokeWidth(8f);
        setWillNotDraw(false);
    
Methods Summary
voidaddRect(android.graphics.Rect r, int color)
Adds a rect to be drawn.

        mRects.add(new Pair<Rect, Integer>(r, color));
        invalidate();
    
voidaddRectRelativeToView(android.view.View v, android.graphics.Rect r, int color)
Adds a rect, relative to a given view to be drawn.

        Rect vr = new Rect();
        v.getGlobalVisibleRect(vr);
        r.offsetTo(vr.left, vr.top);
        mRects.add(new Pair<Rect, Integer>(r, color));
        invalidate();
    
voidaddViewRect(android.view.View v, int color)
Adds a view's global rect to be drawn.

        Rect vr = new Rect();
        v.getGlobalVisibleRect(vr);
        mRects.add(new Pair<Rect, Integer>(vr, color));
        invalidate();
    
public voidclear()
Clears all debug rects.

        mRects.clear();
    
public voiddisable()
Disables the debug overlay drawing.

        mEnabled = false;
        setVisibility(View.GONE);
    
public voidenable()
Enables the debug overlay drawing.

        mEnabled = true;
        setVisibility(View.VISIBLE);
    
protected voidonDraw(android.graphics.Canvas canvas)

        if (mEnabled) {
            // Draw the outline
            canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), mDebugOutline);

            // Draw the rects
            int numRects = mRects.size();
            for (int i = 0; i < numRects; i++) {
                Pair<Rect, Integer> r = mRects.get(i);
                mTmpPaint.setColor(r.second);
                canvas.drawRect(r.first, mTmpPaint);
            }

            // Draw the text
            if (mText != null && mText.length() > 0) {
                mTmpPaint.setColor(0xFFff0000);
                mTmpPaint.setTextSize(60);
                mTmpPaint.getTextBounds(mText, 0, 1, mTmpRect);
                canvas.drawText(mText, 10f, getMeasuredHeight() - mTmpRect.height() - mConfig.systemInsets.bottom, mTmpPaint);
            }
        }
    
protected voidonFinishInflate()

        mPrimarySeekBar = (SeekBar) findViewById(R.id.debug_seek_bar_1);
        mPrimarySeekBar.setOnSeekBarChangeListener(this);
        mSecondarySeekBar = (SeekBar) findViewById(R.id.debug_seek_bar_2);
        mSecondarySeekBar.setOnSeekBarChangeListener(this);
    
protected voidonMeasure(int widthMeasureSpec, int heightMeasureSpec)

        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        addRect(new Rect(0, 0, sCornerRectSize, sCornerRectSize), 0xFFff0000);
        addRect(new Rect(getMeasuredWidth() - sCornerRectSize, getMeasuredHeight() - sCornerRectSize,
                getMeasuredWidth(), getMeasuredHeight()), 0xFFff0000);
    
public voidonProgressChanged(android.widget.SeekBar seekBar, int progress, boolean fromUser)

        if (seekBar == mPrimarySeekBar) {
            mCb.onPrimarySeekBarChanged((float) progress / mPrimarySeekBar.getMax());
        } else if (seekBar == mSecondarySeekBar) {
            mCb.onSecondarySeekBarChanged((float) progress / mSecondarySeekBar.getMax());
        }
    
public voidonStartTrackingTouch(android.widget.SeekBar seekBar)

        // Do nothing
    
public voidonStopTrackingTouch(android.widget.SeekBar seekBar)
SeekBar.OnSeekBarChangeListener Implementation

        // Do nothing
    
public voidsetCallbacks(com.android.systemui.recents.views.DebugOverlayView$DebugOverlayViewCallbacks cb)

        mCb = cb;
    
voidsetText(java.lang.String message)
Sets the debug text at the bottom of the screen.

        mText = message;
        invalidate();