Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eeed0f28 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Minor fixes in mock HandwritingIme" into tm-dev

parents b645442e 7ab0f87b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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;
+4 −0
Original line number Diff line number Diff line
@@ -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()) {