Make PreviewPlacerView final
This is a groundwork for the bug. Bug: 6883053 Change-Id: I51e9235d3bc7021790a88a44596c4314125a1ab3main
parent
42e7a1e5c1
commit
1057670881
|
@ -106,7 +106,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
protected final KeyPreviewDrawParams mKeyPreviewDrawParams;
|
protected final KeyPreviewDrawParams mKeyPreviewDrawParams;
|
||||||
private boolean mShowKeyPreviewPopup = true;
|
private boolean mShowKeyPreviewPopup = true;
|
||||||
private int mDelayAfterPreview;
|
private int mDelayAfterPreview;
|
||||||
private PreviewPlacerView mPreviewPlacer;
|
private final PreviewPlacerView mPreviewPlacerView;
|
||||||
|
|
||||||
/** True if {@link KeyboardView} should handle gesture events. */
|
/** True if {@link KeyboardView} should handle gesture events. */
|
||||||
protected boolean mShouldHandleGesture;
|
protected boolean mShouldHandleGesture;
|
||||||
|
@ -376,6 +376,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
mDelayAfterPreview = mKeyPreviewDrawParams.mLingerTimeout;
|
mDelayAfterPreview = mKeyPreviewDrawParams.mLingerTimeout;
|
||||||
|
|
||||||
mPaint.setAntiAlias(true);
|
mPaint.setAntiAlias(true);
|
||||||
|
|
||||||
|
mPreviewPlacerView = new PreviewPlacerView(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read fraction value in TypedArray as float.
|
// Read fraction value in TypedArray as float.
|
||||||
|
@ -876,39 +878,35 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addKeyPreview(TextView keyPreview) {
|
private void addKeyPreview(TextView keyPreview) {
|
||||||
if (mPreviewPlacer == null) {
|
locatePreviewPlacerView();
|
||||||
createPreviewPlacer();
|
mPreviewPlacerView.addView(
|
||||||
}
|
keyPreview, ViewLayoutUtils.newLayoutParam(mPreviewPlacerView, 0, 0));
|
||||||
mPreviewPlacer.addView(
|
|
||||||
keyPreview, ViewLayoutUtils.newLayoutParam(mPreviewPlacer, 0, 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createPreviewPlacer() {
|
private void locatePreviewPlacerView() {
|
||||||
mPreviewPlacer = new PreviewPlacerView(getContext());
|
if (mPreviewPlacerView.getParent() != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final int[] viewOrigin = new int[2];
|
final int[] viewOrigin = new int[2];
|
||||||
getLocationInWindow(viewOrigin);
|
getLocationInWindow(viewOrigin);
|
||||||
mPreviewPlacer.setOrigin(viewOrigin[0], viewOrigin[1]);
|
mPreviewPlacerView.setOrigin(viewOrigin[0], viewOrigin[1]);
|
||||||
final ViewGroup windowContentView =
|
final ViewGroup windowContentView =
|
||||||
(ViewGroup)getRootView().findViewById(android.R.id.content);
|
(ViewGroup)getRootView().findViewById(android.R.id.content);
|
||||||
windowContentView.addView(mPreviewPlacer);
|
windowContentView.addView(mPreviewPlacerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showGesturePreviewText(String gesturePreviewText) {
|
public void showGesturePreviewText(String gesturePreviewText) {
|
||||||
// TDOD: Add user settings option to control drawing gesture trail.
|
// TDOD: Add user settings option to control drawing gesture trail.
|
||||||
if (mPreviewPlacer == null) {
|
locatePreviewPlacerView();
|
||||||
createPreviewPlacer();
|
mPreviewPlacerView.setGesturePreviewText(gesturePreviewText);
|
||||||
}
|
mPreviewPlacerView.invalidate();
|
||||||
mPreviewPlacer.setGesturePreviewText(gesturePreviewText);
|
|
||||||
mPreviewPlacer.invalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showGestureTrail(PointerTracker tracker) {
|
public void showGestureTrail(PointerTracker tracker) {
|
||||||
// TDOD: Add user settings option to control drawing gesture trail.
|
// TDOD: Add user settings option to control drawing gesture trail.
|
||||||
if (mPreviewPlacer == null) {
|
locatePreviewPlacerView();
|
||||||
createPreviewPlacer();
|
mPreviewPlacerView.invalidatePointer(tracker);
|
||||||
}
|
|
||||||
mPreviewPlacer.invalidatePointer(tracker);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") // setBackgroundDrawable is replaced by setBackground in API16
|
@SuppressWarnings("deprecation") // setBackgroundDrawable is replaced by setBackground in API16
|
||||||
|
@ -1051,9 +1049,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
|
||||||
protected void onDetachedFromWindow() {
|
protected void onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
closing();
|
closing();
|
||||||
if (mPreviewPlacer != null) {
|
mPreviewPlacerView.removeAllViews();
|
||||||
mPreviewPlacer.removeAllViews();
|
|
||||||
}
|
|
||||||
if (mBuffer != null) {
|
if (mBuffer != null) {
|
||||||
mBuffer.recycle();
|
mBuffer.recycle();
|
||||||
mBuffer = null;
|
mBuffer = null;
|
||||||
|
|
Loading…
Reference in New Issue