am 6c63f712: Add standard view constructors of PrevewPlacerView
* commit '6c63f712655efe7e2d72cb2a0af9a0d8fdf0c730': Add standard view constructors of PrevewPlacerViewmain
commit
8c0cab8ef6
|
@ -362,9 +362,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
|
|
||||||
final TypedArray a = context.obtainStyledAttributes(
|
final TypedArray a = context.obtainStyledAttributes(
|
||||||
attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView);
|
attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView);
|
||||||
|
|
||||||
mKeyDrawParams = new KeyDrawParams(a);
|
mKeyDrawParams = new KeyDrawParams(a);
|
||||||
mKeyPreviewDrawParams = new KeyPreviewDrawParams(a, mKeyDrawParams);
|
mKeyPreviewDrawParams = new KeyPreviewDrawParams(a, mKeyDrawParams);
|
||||||
|
mDelayAfterPreview = mKeyPreviewDrawParams.mLingerTimeout;
|
||||||
mKeyPreviewLayoutId = a.getResourceId(R.styleable.KeyboardView_keyPreviewLayout, 0);
|
mKeyPreviewLayoutId = a.getResourceId(R.styleable.KeyboardView_keyPreviewLayout, 0);
|
||||||
if (mKeyPreviewLayoutId == 0) {
|
if (mKeyPreviewLayoutId == 0) {
|
||||||
mShowKeyPreviewPopup = false;
|
mShowKeyPreviewPopup = false;
|
||||||
|
@ -373,11 +373,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
R.styleable.KeyboardView_verticalCorrection, 0);
|
R.styleable.KeyboardView_verticalCorrection, 0);
|
||||||
mMoreKeysLayout = a.getResourceId(R.styleable.KeyboardView_moreKeysLayout, 0);
|
mMoreKeysLayout = a.getResourceId(R.styleable.KeyboardView_moreKeysLayout, 0);
|
||||||
mBackgroundDimAlpha = a.getInt(R.styleable.KeyboardView_backgroundDimAlpha, 0);
|
mBackgroundDimAlpha = a.getInt(R.styleable.KeyboardView_backgroundDimAlpha, 0);
|
||||||
mPreviewPlacerView = new PreviewPlacerView(context, a);
|
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
mDelayAfterPreview = mKeyPreviewDrawParams.mLingerTimeout;
|
mPreviewPlacerView = new PreviewPlacerView(context, attrs);
|
||||||
|
|
||||||
mPaint.setAntiAlias(true);
|
mPaint.setAntiAlias(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,12 +460,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
if (bufferNeedsUpdates || mOffscreenBuffer == null) {
|
if (bufferNeedsUpdates || mOffscreenBuffer == null) {
|
||||||
if (maybeAllocateOffscreenBuffer()) {
|
if (maybeAllocateOffscreenBuffer()) {
|
||||||
mInvalidateAllKeys = true;
|
mInvalidateAllKeys = true;
|
||||||
// TODO: Stop using the offscreen canvas even when in software rendering
|
maybeCreateOffscreenCanvas();
|
||||||
if (mOffscreenCanvas != null) {
|
|
||||||
mOffscreenCanvas.setBitmap(mOffscreenBuffer);
|
|
||||||
} else {
|
|
||||||
mOffscreenCanvas = new Canvas(mOffscreenBuffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
onDrawKeyboard(mOffscreenCanvas);
|
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) {
|
private void onDrawKeyboard(final Canvas canvas) {
|
||||||
if (mKeyboard == null) return;
|
if (mKeyboard == null) return;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.graphics.Paint;
|
||||||
import android.graphics.Paint.Align;
|
import android.graphics.Paint.Align;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.AttributeSet;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.widget.RelativeLayout;
|
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);
|
super(context);
|
||||||
setWillNotDraw(false);
|
setWillNotDraw(false);
|
||||||
|
|
||||||
|
final TypedArray keyboardViewAttr = context.obtainStyledAttributes(
|
||||||
|
attrs, R.styleable.KeyboardView, defStyle, R.style.KeyboardView);
|
||||||
final int gestureFloatingPreviewTextSize = keyboardViewAttr.getDimensionPixelSize(
|
final int gestureFloatingPreviewTextSize = keyboardViewAttr.getDimensionPixelSize(
|
||||||
R.styleable.KeyboardView_gestureFloatingPreviewTextSize, 0);
|
R.styleable.KeyboardView_gestureFloatingPreviewTextSize, 0);
|
||||||
mGestureFloatingPreviewTextColor = keyboardViewAttr.getColor(
|
mGestureFloatingPreviewTextColor = keyboardViewAttr.getColor(
|
||||||
|
@ -117,6 +124,7 @@ public class PreviewPlacerView extends RelativeLayout {
|
||||||
R.styleable.KeyboardView_gesturePreviewTrailColor, 0);
|
R.styleable.KeyboardView_gesturePreviewTrailColor, 0);
|
||||||
final int gesturePreviewTrailWidth = keyboardViewAttr.getDimensionPixelSize(
|
final int gesturePreviewTrailWidth = keyboardViewAttr.getDimensionPixelSize(
|
||||||
R.styleable.KeyboardView_gesturePreviewTrailWidth, 0);
|
R.styleable.KeyboardView_gesturePreviewTrailWidth, 0);
|
||||||
|
keyboardViewAttr.recycle();
|
||||||
|
|
||||||
mGesturePaint = new Paint();
|
mGesturePaint = new Paint();
|
||||||
mGesturePaint.setAntiAlias(true);
|
mGesturePaint.setAntiAlias(true);
|
||||||
|
|
Loading…
Reference in New Issue