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

Commit 236928c5 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka Committed by Android (Google) Code Review
Browse files

Merge "Make Spacer as extended Key class"

parents 293db087 18453d69
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -150,8 +150,8 @@
             area between the nearest key on the left hand side and the right edge of the keyboard.
             -->
        <attr name="keyWidth" format="dimension|fraction|enum">
            <enum name="fillRight" value="0" />
            <enum name="fillBoth" value="-1" />
            <enum name="fillRight" value="-1" />
            <enum name="fillBoth" value="-2" />
        </attr>
        <!-- Default height of a row (key height + vertical gap), in pixels or percentage of
             keyboard height. -->
+1 −1
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@
        <Key
            latin:keyStyle="nonSpecialBackgroundSpaceKeyStyle"
            latin:keyXPos="15.625%p"
            latin:keyWidth="18.67%p" />
            latin:keyWidth="18.50%p" />
        <Key
            latin:keyStyle="numStarKeyStyle"
            latin:keyXPos="38.867%p" />
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@
        </switch>
        <Spacer
            latin:keyXPos="15.157%p"
            latin:keyWidth="fillRight" />
            latin:keyWidth="0%p" />
        <switch>
            <case
                latin:mode="url"
+27 −8
Original line number Diff line number Diff line
@@ -115,9 +115,10 @@ public class Key {
    /** Whether this key needs to show the "..." popup hint for special purposes */
    private boolean mNeedsSpecialPopupHint;

    // keyWidth constants
    private static final int KEYWIDTH_FILL_RIGHT = 0;
    private static final int KEYWIDTH_FILL_BOTH = -1;
    // keyWidth enum constants
    private static final int KEYWIDTH_NOT_ENUM = 0;
    private static final int KEYWIDTH_FILL_RIGHT = -1;
    private static final int KEYWIDTH_FILL_BOTH = -2;

    private final static int[] KEY_STATE_NORMAL_ON = {
        android.R.attr.state_checkable,
@@ -249,15 +250,17 @@ public class Key {
     */
    public Key(Resources res, KeyboardParams params, KeyboardBuilder.Row row,
            XmlResourceParser parser, KeyStyles keyStyles) {

        final TypedArray keyboardAttr = res.obtainAttributes(Xml.asAttributeSet(parser),
                R.styleable.Keyboard);
        mHeight = (int)KeyboardBuilder.getDimensionOrFraction(keyboardAttr,
                R.styleable.Keyboard_rowHeight, params.mHeight, row.mRowHeight)
                - params.mVerticalGap;
        final float horizontalGap = KeyboardBuilder.getDimensionOrFraction(keyboardAttr,
        final float horizontalGap = isSpacer() ? 0
                : KeyboardBuilder.getDimensionOrFraction(keyboardAttr,
                        R.styleable.Keyboard_horizontalGap, params.mWidth, params.mHorizontalGap);
        mVerticalGap = params.mVerticalGap;
        final int widthType = KeyboardBuilder.getEnumValue(keyboardAttr,
                R.styleable.Keyboard_keyWidth, KEYWIDTH_NOT_ENUM);
        float keyWidth = KeyboardBuilder.getDimensionOrFraction(keyboardAttr,
                R.styleable.Keyboard_keyWidth, params.mWidth, row.mDefaultKeyWidth);
        keyboardAttr.recycle();
@@ -288,11 +291,11 @@ public class Key {
                keyXPos = x;
            }
        }
        if (keyWidth == KEYWIDTH_FILL_RIGHT) {
        if (widthType == KEYWIDTH_FILL_RIGHT) {
            // If keyWidth is zero, the actual key width will be determined to fill out the
            // area up to the right edge of the keyboard.
            keyWidth = keyboardWidth - keyXPos;
        } else if (keyWidth <= KEYWIDTH_FILL_BOTH) {
        } else if (widthType == KEYWIDTH_FILL_BOTH) {
            // If keyWidth is negative, the actual key width will be determined to fill out the
            // area between the nearest key on the left hand side and the right edge of the
            // keyboard.
@@ -367,6 +370,10 @@ public class Key {
        mEdgeFlags |= flags;
    }

    public boolean isSpacer() {
        return false;
    }

    public Typeface selectTypeface(Typeface defaultTypeface) {
        // TODO: Handle "bold" here too?
        if ((mLabelOption & LABEL_OPTION_FONT_NORMAL) != 0) {
@@ -559,4 +566,16 @@ public class Key {
        }
        return states;
    }

    public static class Spacer extends Key {
        public Spacer(Resources res, KeyboardParams params, KeyboardBuilder.Row row,
                XmlResourceParser parser, KeyStyles keyStyles) {
            super(res, params, row, parser, keyStyles);
        }

        @Override
        public boolean isSpacer() {
            return true;
        }
    }
}
+19 −17
Original line number Diff line number Diff line
@@ -510,6 +510,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
            Paint paint, KeyDrawParams params, boolean isManualTemporaryUpperCase) {
        final boolean debugShowAlign = LatinImeLogger.sVISUALDEBUG;
        // Draw key background.
        if (!key.isSpacer()) {
            final int bgWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight
                    + params.mPadding.left + params.mPadding.right;
            final int bgHeight = key.mHeight + params.mPadding.top + params.mPadding.bottom;
@@ -528,6 +529,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
                drawRectangle(canvas, 0, 0, bgWidth, bgHeight, 0x80c00000, new Paint());
            }
            canvas.translate(-bgX, -bgY);
        }

        // Draw key top visuals.
        final int keyWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight;
Loading