Minor fixes in mock HandwritingIme

1. Fix position of Ink based on top inset
2. Add a textView

Bug: 217957587
Test: manual
Change-Id: Ia0330e5e3f2129c3daae44ae1d279067e74f1557
diff --git a/tests/HandwritingIme/src/com/google/android/test/handwritingime/HandwritingIme.java b/tests/HandwritingIme/src/com/google/android/test/handwritingime/HandwritingIme.java
index 18f9623..bf8bd14 100644
--- a/tests/HandwritingIme/src/com/google/android/test/handwritingime/HandwritingIme.java
+++ b/tests/HandwritingIme/src/com/google/android/test/handwritingime/HandwritingIme.java
@@ -18,11 +18,13 @@
 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 @@
         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;
diff --git a/tests/HandwritingIme/src/com/google/android/test/handwritingime/InkView.java b/tests/HandwritingIme/src/com/google/android/test/handwritingime/InkView.java
index 4ffdc92..87a5b90 100644
--- a/tests/HandwritingIme/src/com/google/android/test/handwritingime/InkView.java
+++ b/tests/HandwritingIme/src/com/google/android/test/handwritingime/InkView.java
@@ -33,6 +33,7 @@
     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 @@
         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 @@
     }
 
     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()) {