Merge "Minor fixes in mock HandwritingIme" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
eeed0f28a4
@@ -18,11 +18,13 @@ package com.google.android.test.handwritingime;
|
|||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.inputmethodservice.InputMethodService;
|
import android.inputmethodservice.InputMethodService;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@@ -79,6 +81,14 @@ public class HandwritingIme extends InputMethodService {
|
|||||||
view.setPadding(0, 0, 0, 0);
|
view.setPadding(0, 0, 0, 0);
|
||||||
view.addView(inner, new FrameLayout.LayoutParams(
|
view.addView(inner, new FrameLayout.LayoutParams(
|
||||||
FrameLayout.LayoutParams.MATCH_PARENT, height));
|
FrameLayout.LayoutParams.MATCH_PARENT, height));
|
||||||
|
TextView text = new TextView(this);
|
||||||
|
text.setText("Handwriting IME");
|
||||||
|
text.setTextSize(13f);
|
||||||
|
text.setTextColor(getColor(android.R.color.white));
|
||||||
|
text.setGravity(Gravity.CENTER);
|
||||||
|
text.setLayoutParams(new FrameLayout.LayoutParams(
|
||||||
|
FrameLayout.LayoutParams.MATCH_PARENT, height));
|
||||||
|
view.addView(text);
|
||||||
inner.setBackgroundColor(0xff0110fe); // blue
|
inner.setBackgroundColor(0xff0110fe); // blue
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class InkView extends View {
|
|||||||
private static final long FINISH_TIMEOUT = 2500;
|
private static final long FINISH_TIMEOUT = 2500;
|
||||||
private final HandwritingIme.HandwritingFinisher mHwCanceller;
|
private final HandwritingIme.HandwritingFinisher mHwCanceller;
|
||||||
private final HandwritingIme.StylusConsumer mConsumer;
|
private final HandwritingIme.StylusConsumer mConsumer;
|
||||||
|
private final int mTopInset;
|
||||||
private Paint mPaint;
|
private Paint mPaint;
|
||||||
private Path mPath;
|
private Path mPath;
|
||||||
private float mX, mY;
|
private float mX, mY;
|
||||||
@@ -63,6 +64,7 @@ class InkView extends View {
|
|||||||
setLayoutParams(new ViewGroup.LayoutParams(
|
setLayoutParams(new ViewGroup.LayoutParams(
|
||||||
metrics.getBounds().width() - insets.left - insets.right,
|
metrics.getBounds().width() - insets.left - insets.right,
|
||||||
metrics.getBounds().height() - insets.top - insets.bottom));
|
metrics.getBounds().height() - insets.top - insets.bottom));
|
||||||
|
mTopInset = insets.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -74,12 +76,14 @@ class InkView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void stylusStart(float x, float y) {
|
private void stylusStart(float x, float y) {
|
||||||
|
y = y - mTopInset;
|
||||||
mPath.moveTo(x, y);
|
mPath.moveTo(x, y);
|
||||||
mX = x;
|
mX = x;
|
||||||
mY = y;
|
mY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stylusMove(float x, float y) {
|
private void stylusMove(float x, float y) {
|
||||||
|
y = y - mTopInset;
|
||||||
float dx = Math.abs(x - mX);
|
float dx = Math.abs(x - mX);
|
||||||
float dy = Math.abs(y - mY);
|
float dy = Math.abs(y - mY);
|
||||||
if (mPath.isEmpty()) {
|
if (mPath.isEmpty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user