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

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

Merge "Fix ink position in test handwriting IME"

parents 1ce1c150 9892bebd
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()) {