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

Commit 6c63f712 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Add standard view constructors of PrevewPlacerView

Change-Id: I00d7ae4d2330804c342a5e51cf8c0df6ed8a85d6
parent 522e1266
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -362,9 +362,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {

        final TypedArray a = context.obtainStyledAttributes(
                attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView);

        mKeyDrawParams = new KeyDrawParams(a);
        mKeyPreviewDrawParams = new KeyPreviewDrawParams(a, mKeyDrawParams);
        mDelayAfterPreview = mKeyPreviewDrawParams.mLingerTimeout;
        mKeyPreviewLayoutId = a.getResourceId(R.styleable.KeyboardView_keyPreviewLayout, 0);
        if (mKeyPreviewLayoutId == 0) {
            mShowKeyPreviewPopup = false;
@@ -373,11 +373,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
                R.styleable.KeyboardView_verticalCorrection, 0);
        mMoreKeysLayout = a.getResourceId(R.styleable.KeyboardView_moreKeysLayout, 0);
        mBackgroundDimAlpha = a.getInt(R.styleable.KeyboardView_backgroundDimAlpha, 0);
        mPreviewPlacerView = new PreviewPlacerView(context, a);
        a.recycle();

        mDelayAfterPreview = mKeyPreviewDrawParams.mLingerTimeout;

        mPreviewPlacerView = new PreviewPlacerView(context, attrs);
        mPaint.setAntiAlias(true);
    }

@@ -462,12 +460,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
        if (bufferNeedsUpdates || mOffscreenBuffer == null) {
            if (maybeAllocateOffscreenBuffer()) {
                mInvalidateAllKeys = true;
                // TODO: Stop using the offscreen canvas even when in software rendering
                if (mOffscreenCanvas != null) {
                    mOffscreenCanvas.setBitmap(mOffscreenBuffer);
                } else {
                    mOffscreenCanvas = new Canvas(mOffscreenBuffer);
                }
                maybeCreateOffscreenCanvas();
            }
            onDrawKeyboard(mOffscreenCanvas);
        }
@@ -496,6 +489,15 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
        }
    }

    private void maybeCreateOffscreenCanvas() {
        // TODO: Stop using the offscreen canvas even when in software rendering
        if (mOffscreenCanvas != null) {
            mOffscreenCanvas.setBitmap(mOffscreenBuffer);
        } else {
            mOffscreenCanvas = new Canvas(mOffscreenBuffer);
        }
    }

    private void onDrawKeyboard(final Canvas canvas) {
        if (mKeyboard == null) return;

+9 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.os.Message;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.widget.RelativeLayout;

@@ -89,10 +90,16 @@ public class PreviewPlacerView extends RelativeLayout {
        }
    }

    public PreviewPlacerView(Context context, TypedArray keyboardViewAttr) {
    public PreviewPlacerView(Context context, AttributeSet attrs) {
        this(context, attrs, R.attr.keyboardViewStyle);
    }

    public PreviewPlacerView(Context context, AttributeSet attrs, int defStyle) {
        super(context);
        setWillNotDraw(false);

        final TypedArray keyboardViewAttr = context.obtainStyledAttributes(
                attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView);
        final int gestureFloatingPreviewTextSize = keyboardViewAttr.getDimensionPixelSize(
                R.styleable.KeyboardView_gestureFloatingPreviewTextSize, 0);
        mGestureFloatingPreviewTextColor = keyboardViewAttr.getColor(
@@ -117,6 +124,7 @@ public class PreviewPlacerView extends RelativeLayout {
                R.styleable.KeyboardView_gesturePreviewTrailColor, 0);
        final int gesturePreviewTrailWidth = keyboardViewAttr.getDimensionPixelSize(
                R.styleable.KeyboardView_gesturePreviewTrailWidth, 0);
        keyboardViewAttr.recycle();

        mGesturePaint = new Paint();
        mGesturePaint.setAntiAlias(true);