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

Commit 9892bebd authored by Justin Ghan's avatar Justin Ghan
Browse files

Fix ink position in test handwriting IME

Bug: 217957587
Test: m HandwritingIme
Change-Id: Ie8f7dc2802d5de97b4b7561f0896a61d34bf237e
parent 78975396
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -19,13 +19,11 @@ package com.google.android.test.handwritingime;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Insets;
import android.graphics.Paint;
import android.graphics.Path;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.WindowMetrics;

@@ -33,9 +31,8 @@ class InkView extends View {
    private static final long FINISH_TIMEOUT = 1500;
    private final HandwritingIme.HandwritingFinisher mHwCanceller;
    private final HandwritingIme.StylusConsumer mConsumer;
    private final int mTopInset;
    private Paint mPaint;
    private Path  mPath;
    private final Paint mPaint;
    private final Path mPath;
    private float mX, mY;
    private static final float STYLUS_MOVE_TOLERANCE = 1;
    private Runnable mFinishRunnable;
@@ -59,12 +56,8 @@ class InkView extends View {

        WindowManager wm = context.getSystemService(WindowManager.class);
        WindowMetrics metrics =  wm.getCurrentWindowMetrics();
        Insets insets = metrics.getWindowInsets()
                .getInsetsIgnoringVisibility(WindowInsets.Type.systemBars());
        setLayoutParams(new ViewGroup.LayoutParams(
                metrics.getBounds().width() - insets.left - insets.right,
                metrics.getBounds().height() - insets.top - insets.bottom));
        mTopInset = insets.top;
                metrics.getBounds().width(), metrics.getBounds().height()));
    }

    @Override
@@ -76,14 +69,12 @@ 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()) {