Merge "Minor fixes in mock HandwritingIme" into tm-dev am: eeed0f28a4

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17049974

Change-Id: I927ddac50592c6a7c9fa83bf37443a37b6e41487
This commit is contained in:
TreeHugger Robot
2022-03-08 17:02:30 +00:00
committed by Automerger Merge Worker
2 changed files with 14 additions and 0 deletions

View File

@@ -18,11 +18,13 @@ package com.google.android.test.handwritingime;
import android.annotation.Nullable;
import android.inputmethodservice.InputMethodService;
import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
import java.util.Random;
@@ -79,6 +81,14 @@ public class HandwritingIme extends InputMethodService {
view.setPadding(0, 0, 0, 0);
view.addView(inner, new FrameLayout.LayoutParams(
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
return view;

View File

@@ -33,6 +33,7 @@ class InkView extends View {
private static final long FINISH_TIMEOUT = 2500;
private final HandwritingIme.HandwritingFinisher mHwCanceller;
private final HandwritingIme.StylusConsumer mConsumer;
private final int mTopInset;
private Paint mPaint;
private Path mPath;
private float mX, mY;
@@ -63,6 +64,7 @@ class InkView extends View {
setLayoutParams(new ViewGroup.LayoutParams(
metrics.getBounds().width() - insets.left - insets.right,
metrics.getBounds().height() - insets.top - insets.bottom));
mTopInset = insets.top;
}
@Override
@@ -74,12 +76,14 @@ class InkView extends View {
}
private void stylusStart(float x, float y) {
y = y - mTopInset;
mPath.moveTo(x, y);
mX = x;
mY = y;
}
private void stylusMove(float x, float y) {
y = y - mTopInset;
float dx = Math.abs(x - mX);
float dy = Math.abs(y - mY);
if (mPath.isEmpty()) {