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

Commit 5620c75c authored by Shan Huang's avatar Shan Huang
Browse files

Updated launcher text shadow values.

Also update the way we compute shadow alpha so that it combines both text
alpha and shadow color alpha.

Test: Manually checked text appearances in launcher.
Bug: 185890335

Change-Id: I720a97bbaf21de86a5c446529109ce5b9ac5f6f7
parent fbea50d8
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -79,7 +79,8 @@
        <attr name="ambientShadowBlur" format="dimension" />
        <attr name="keyShadowColor" format="color" />
        <attr name="keyShadowBlur" format="dimension" />
        <attr name="keyShadowOffset" format="dimension" />
        <attr name="keyShadowOffsetX" format="dimension" />
        <attr name="keyShadowOffsetY" format="dimension" />
    </declare-styleable>

    <!-- PagedView specific attributes. These attributes are used to customize
+5 −4
Original line number Diff line number Diff line
@@ -42,8 +42,8 @@
        <item name="isWorkspaceDarkText">false</item>
        <item name="workspaceTextColor">@color/workspace_text_color_light</item>
        <item name="workspaceShadowColor">#B0000000</item>
        <item name="workspaceAmbientShadowColor">#33000000</item>
        <item name="workspaceKeyShadowColor">#44000000</item>
        <item name="workspaceAmbientShadowColor">#00000000</item>
        <item name="workspaceKeyShadowColor">#89000000</item>
        <item name="workspaceStatusBarScrim">@drawable/workspace_bg</item>
        <item name="widgetsTheme">@style/WidgetContainerTheme</item>
        <item name="folderDotColor">?android:attr/colorPrimary</item>
@@ -243,8 +243,9 @@
        <item name="ambientShadowColor">?attr/workspaceAmbientShadowColor</item>
        <item name="ambientShadowBlur">2.5dp</item>
        <item name="keyShadowColor">?attr/workspaceKeyShadowColor</item>
        <item name="keyShadowBlur">1dp</item>
        <item name="keyShadowOffset">.5dp</item>
        <item name="keyShadowBlur">.5dp</item>
        <item name="keyShadowOffsetX">.5dp</item>
        <item name="keyShadowOffsetY">.5dp</item>
    </style>

    <!-- Theme for the popup container -->
+27 −12
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public class DoubleShadowBubbleTextView extends BubbleTextView {

        // We enhance the shadow by drawing the shadow twice
        getPaint().setShadowLayer(mShadowInfo.ambientShadowBlur, 0, 0,
                setColorAlphaBound(mShadowInfo.ambientShadowColor, alpha));
                getTextShadowColor(mShadowInfo.ambientShadowColor, alpha));

        drawWithoutDot(canvas);
        canvas.save();
@@ -68,8 +68,11 @@ public class DoubleShadowBubbleTextView extends BubbleTextView {
                getScrollX() + getWidth(),
                getScrollY() + getHeight());

        getPaint().setShadowLayer(mShadowInfo.keyShadowBlur, 0.0f, mShadowInfo.keyShadowOffset,
                setColorAlphaBound(mShadowInfo.keyShadowColor, alpha));
        getPaint().setShadowLayer(
                mShadowInfo.keyShadowBlur,
                mShadowInfo.keyShadowOffsetX,
                mShadowInfo.keyShadowOffsetY,
                getTextShadowColor(mShadowInfo.keyShadowColor, alpha));
        drawWithoutDot(canvas);
        canvas.restore();

@@ -81,7 +84,8 @@ public class DoubleShadowBubbleTextView extends BubbleTextView {
        public final int ambientShadowColor;

        public final float keyShadowBlur;
        public final float keyShadowOffset;
        public final float keyShadowOffsetX;
        public final float keyShadowOffsetY;
        public final int keyShadowColor;

        public ShadowInfo(Context c, AttributeSet attrs, int defStyle) {
@@ -89,11 +93,13 @@ public class DoubleShadowBubbleTextView extends BubbleTextView {
            TypedArray a = c.obtainStyledAttributes(
                    attrs, R.styleable.ShadowInfo, defStyle, 0);

            ambientShadowBlur = a.getDimension(R.styleable.ShadowInfo_ambientShadowBlur, 0);
            ambientShadowBlur = a.getDimensionPixelSize(
                    R.styleable.ShadowInfo_ambientShadowBlur, 0);
            ambientShadowColor = a.getColor(R.styleable.ShadowInfo_ambientShadowColor, 0);

            keyShadowBlur = a.getDimension(R.styleable.ShadowInfo_keyShadowBlur, 0);
            keyShadowOffset = a.getDimension(R.styleable.ShadowInfo_keyShadowOffset, 0);
            keyShadowBlur = a.getDimensionPixelSize(R.styleable.ShadowInfo_keyShadowBlur, 0);
            keyShadowOffsetX = a.getDimensionPixelSize(R.styleable.ShadowInfo_keyShadowOffsetX, 0);
            keyShadowOffsetY = a.getDimensionPixelSize(R.styleable.ShadowInfo_keyShadowOffsetY, 0);
            keyShadowColor = a.getColor(R.styleable.ShadowInfo_keyShadowColor, 0);
            a.recycle();
        }
@@ -105,17 +111,26 @@ public class DoubleShadowBubbleTextView extends BubbleTextView {
            if (textAlpha == 0 || (keyShadowAlpha == 0 && ambientShadowAlpha == 0)) {
                textView.getPaint().clearShadowLayer();
                return true;
            } else if (ambientShadowAlpha > 0) {
            } else if (ambientShadowAlpha > 0 && keyShadowAlpha == 0) {
                textView.getPaint().setShadowLayer(ambientShadowBlur, 0, 0,
                        setColorAlphaBound(ambientShadowColor, textAlpha));
                        getTextShadowColor(ambientShadowColor, textAlpha));
                return true;
            } else if (keyShadowAlpha > 0) {
                textView.getPaint().setShadowLayer(keyShadowBlur, 0.0f, keyShadowOffset,
                        setColorAlphaBound(keyShadowColor, textAlpha));
            } else if (keyShadowAlpha > 0 && ambientShadowAlpha == 0) {
                textView.getPaint().setShadowLayer(
                        keyShadowBlur,
                        keyShadowOffsetX,
                        keyShadowOffsetY,
                        getTextShadowColor(keyShadowColor, textAlpha));
                return true;
            } else {
                return false;
            }
        }
    }

    // Multiplies the alpha of shadowColor by textAlpha.
    private static int getTextShadowColor(int shadowColor, int textAlpha) {
        return setColorAlphaBound(shadowColor,
                Math.round(Color.alpha(shadowColor) * textAlpha / 255f));
    }
}