Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53210252 authored by Christian Göllner's avatar Christian Göllner Committed by Android (Google) Code Review
Browse files

Merge "Improve visual debugging for NotificationStackScrollLayout" into sc-v2-dev

parents f1ecb267 c65ac2cd
Loading
Loading
Loading
Loading
+45 −23
Original line number Original line Diff line number Diff line
@@ -119,6 +119,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Comparator;
import java.util.HashSet;
import java.util.HashSet;
import java.util.List;
import java.util.List;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Consumer;


@@ -726,36 +727,57 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        }
        }


        if (DEBUG) {
        if (DEBUG) {
            onDrawDebug(canvas);
        }
    }

    /** Used to track the Y positions that were already used to draw debug text labels. */
    private static final Set<Integer> DEBUG_TEXT_USED_Y_POSITIONS =
            DEBUG ? new HashSet<>() : Collections.emptySet();

    private void onDrawDebug(Canvas canvas) {
        DEBUG_TEXT_USED_Y_POSITIONS.clear();

        int y = mTopPadding;
        int y = mTopPadding;
            mDebugPaint.setColor(Color.RED);
        drawDebugInfo(canvas, y, Color.RED, /* label= */ "mTopPadding");
            canvas.drawLine(0, y, getWidth(), y, mDebugPaint);


        y = getLayoutHeight();
        y = getLayoutHeight();
            mDebugPaint.setColor(Color.YELLOW);
        drawDebugInfo(canvas, y, Color.YELLOW, /* label= */ "getLayoutHeight()");
            canvas.drawLine(0, y, getWidth(), y, mDebugPaint);


        y = (int) mMaxLayoutHeight;
        y = (int) mMaxLayoutHeight;
            mDebugPaint.setColor(Color.MAGENTA);
        drawDebugInfo(canvas, y, Color.MAGENTA, /* label= */ "mMaxLayoutHeight");
            canvas.drawLine(0, y, getWidth(), y, mDebugPaint);


        if (mKeyguardBottomPadding >= 0) {
        if (mKeyguardBottomPadding >= 0) {
            y = getHeight() - (int) mKeyguardBottomPadding;
            y = getHeight() - (int) mKeyguardBottomPadding;
                mDebugPaint.setColor(Color.GRAY);
            drawDebugInfo(canvas, y, Color.GRAY,
                canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
                    /* label= */ "getHeight() - mKeyguardBottomPadding");
        }
        }


        y = getHeight() - getEmptyBottomMargin();
        y = getHeight() - getEmptyBottomMargin();
            mDebugPaint.setColor(Color.GREEN);
        drawDebugInfo(canvas, y, Color.GREEN, /* label= */ "getHeight() - getEmptyBottomMargin()");
            canvas.drawLine(0, y, getWidth(), y, mDebugPaint);


        y = (int) (mAmbientState.getStackY());
        y = (int) (mAmbientState.getStackY());
            mDebugPaint.setColor(Color.CYAN);
        drawDebugInfo(canvas, y, Color.CYAN, /* label= */ "mAmbientState.getStackY()");
            canvas.drawLine(0, y, getWidth(), y, mDebugPaint);


        y = (int) (mAmbientState.getStackY() + mAmbientState.getStackHeight());
        y = (int) (mAmbientState.getStackY() + mAmbientState.getStackHeight());
            mDebugPaint.setColor(Color.BLUE);
        drawDebugInfo(canvas, y, Color.BLUE,
            canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
                /* label= */ "mAmbientState.getStackY() + mAmbientState.getStackHeight()");
    }

    private void drawDebugInfo(Canvas canvas, int y, int color, String label) {
        mDebugPaint.setColor(color);
        canvas.drawLine(/* startX= */ 0, /* startY= */ y, /* stopX= */ getWidth(), /* stopY= */ y,
                mDebugPaint);
        canvas.drawText(label, /* x= */ 0, /* y= */ computeDebugYTextPosition(y), mDebugPaint);
    }

    private int computeDebugYTextPosition(int lineY) {
        int textY = lineY;
        while (DEBUG_TEXT_USED_Y_POSITIONS.contains(textY)) {
            textY = (int) (textY + mDebugPaint.getTextSize());
        }
        }
        DEBUG_TEXT_USED_Y_POSITIONS.add(textY);
        return textY;
    }
    }


    @ShadeViewRefactor(RefactorComponent.DECORATOR)
    @ShadeViewRefactor(RefactorComponent.DECORATOR)