Fix gesture trail rendering on tablet.

Bug: 6867837
Change-Id: I54dceee1c83679f78462104d6cee1f2300a0cfc2
main
Tom Ouyang 2012-07-24 19:46:24 -07:00 committed by Tadashi G. Takaoka
parent 0657b9698a
commit e68385871a
1 changed files with 13 additions and 8 deletions

View File

@ -888,23 +888,26 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
mDrawingHandler.dismissKeyPreview(mDelayAfterPreview, tracker); mDrawingHandler.dismissKeyPreview(mDelayAfterPreview, tracker);
} }
private static class PreviewView extends RelativeLayout { private static class PreviewPlacerView extends RelativeLayout {
KeyPreviewDrawParams mParams; private final Paint mGesturePaint;
Paint mGesturePaint; final int mCoordinateX;
final int mCoordinateY;
public PreviewView(Context context, KeyPreviewDrawParams params, Paint gesturePaint) { public PreviewPlacerView(Context context, int coordinateX, int coordinateY,
Paint gesturePaint) {
super(context); super(context);
setWillNotDraw(false); setWillNotDraw(false);
mParams = params;
mGesturePaint = gesturePaint; mGesturePaint = gesturePaint;
mCoordinateX = coordinateX;
mCoordinateY = coordinateY;
} }
@Override @Override
public void onDraw(Canvas canvas) { public void onDraw(Canvas canvas) {
super.onDraw(canvas); super.onDraw(canvas);
canvas.translate(mParams.mCoordinates[0], mParams.mCoordinates[1]); canvas.translate(mCoordinateX, mCoordinateY);
PointerTracker.drawGestureTrailForAllPointerTrackers(canvas, mGesturePaint); PointerTracker.drawGestureTrailForAllPointerTrackers(canvas, mGesturePaint);
canvas.translate(-mParams.mCoordinates[0], -mParams.mCoordinates[1]); canvas.translate(-mCoordinateX, -mCoordinateY);
} }
} }
@ -917,7 +920,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
} }
private void createPreviewPlacer() { private void createPreviewPlacer() {
mPreviewPlacer = new PreviewView(getContext(), mKeyPreviewDrawParams, mGesturePaint); getLocationInWindow(mKeyPreviewDrawParams.mCoordinates);
mPreviewPlacer = new PreviewPlacerView(getContext(), mKeyPreviewDrawParams.mCoordinates[0],
mKeyPreviewDrawParams.mCoordinates[1], mGesturePaint);
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(mPreviewPlacer);