Skip to content

Commit

Permalink
Updating to iink 3.2 and introducing the keyboard input sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
yannchevalier committed Oct 22, 2024
1 parent 73986fb commit fdf68b8
Show file tree
Hide file tree
Showing 31 changed files with 1,024 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -480,15 +480,15 @@ public boolean isExtraBrushSupported(@NonNull String brushName)
}

@Override
public void drawStrokeWithExtraBrush(@NonNull InkPoints inkPoints, int temporaryPoints,
public void drawStrokeWithExtraBrush(@NonNull InkPoints[] vInkPoints, int temporaryPoints,
float strokeWidth, @NonNull String brushName, boolean fullStroke, long id)
{
Objects.requireNonNull(canvas);

if (!isExtraBrushSupported(brushName))
return;

if (inkPoints.x.length == 0 || strokeWidth <= 0.f || android.graphics.Color.alpha(fillPaint.getColor()) == 0)
if (vInkPoints.length == 0 || vInkPoints[0].x.length == 0 || strokeWidth <= 0.f || android.graphics.Color.alpha(fillPaint.getColor()) == 0)
return;

if (!glRenderer.isInitialized())
Expand All @@ -503,14 +503,14 @@ public void drawStrokeWithExtraBrush(@NonNull InkPoints inkPoints, int temporary
canvas.setMatrix(null); // GLRenderer works with pixels
fillPaint.setXfermode(xferModeSrcOver);

PointF strokeOrigin = glRenderer.drawStroke(inkPoints, temporaryPoints, transformValues, brushName, fullStroke, id, strokeWidth, fillPaint);
PointF strokeOrigin = glRenderer.drawStroke(vInkPoints, temporaryPoints, transformValues, brushName, fullStroke, id, strokeWidth, fillPaint);
Bitmap strokeBitmap = glRenderer.saveStroke();
if (strokeBitmap != null)
canvas.drawBitmap(strokeBitmap, strokeOrigin.x, strokeOrigin.y, fillPaint);

if (temporaryPoints > 0)
if (temporaryPoints > 0 && vInkPoints.length == 1)
{
PointF temporaryOrigin = glRenderer.drawTemporary(inkPoints, temporaryPoints, transformValues, brushName, strokeWidth, fillPaint);
PointF temporaryOrigin = glRenderer.drawTemporary(vInkPoints, temporaryPoints, transformValues, brushName, strokeWidth, fillPaint);
Bitmap temporaryBitmap = glRenderer.saveTemporary();
if (temporaryBitmap != null)
canvas.drawBitmap(temporaryBitmap, temporaryOrigin.x, temporaryOrigin.y, fillPaint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public final void invalidate(@NonNull Renderer renderer, int x, int y, int width

if (layerView != null)
{
layerView.update(renderer, x, y, width, height, layers);
layerView.update(renderer, x, y, width, height);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.core.view.GestureDetectorCompat;

public class InputController implements View.OnTouchListener, GestureDetector.OnGestureListener, ScaleGestureDetector.OnScaleGestureListener
{
Expand All @@ -47,7 +46,7 @@ public interface ViewListener
private final EditorView editorView;
private final Editor editor;
private int _inputMode;
private final GestureDetectorCompat gestureDetector;
private final GestureDetector gestureDetector;
private final ScaleGestureDetector scaleGestureDetector;
private IInputControllerListener _listener;
private final long eventTimeOffset;
Expand All @@ -69,7 +68,7 @@ public InputController(Context context, EditorView editorView, Editor editor)
_listener = null;
_inputMode = INPUT_MODE_AUTO;
scaleGestureDetector = new ScaleGestureDetector(context, this);
gestureDetector = new GestureDetectorCompat(context, this);
gestureDetector = new GestureDetector(context, this);

long rel_t = SystemClock.uptimeMillis();
long abs_t = System.currentTimeMillis();
Expand Down Expand Up @@ -106,6 +105,11 @@ public final synchronized IInputControllerListener getListener()
return _listener;
}

public final synchronized int getPreviousPointerId()
{
return previousPointerId;
}

private boolean handleOnTouchForPointer(MotionEvent event, int actionMask, int pointerIndex)
{
final int pointerId = event.getPointerId(pointerIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private void restore(android.graphics.Canvas canvas)
canvas.restore();
}

public final void update(Renderer renderer, int x, int y, int width, int height, EnumSet<LayerType> layers)
public final void update(Renderer renderer, int x, int y, int width, int height)
{
boolean emptyArea;

Expand Down
5 changes: 2 additions & 3 deletions samples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ subprojects {
abortOnError false
}
android {
// Needed until AGP 8.1.0 is out
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}

ndkVersion Versions.ndk
Expand Down
8 changes: 4 additions & 4 deletions samples/buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright MyScript. All rights reserved.

object Versions {
const val android_gradle_plugin = "8.0.2"
const val android_gradle_plugin = "8.7.1"

const val kotlin = "1.8.21"
const val kotlin = "1.9.23"

// configure versions used by dependencies to harmonize and update easily across all components
const val compileSdk = 33
const val compileSdk = 34
const val minSdk = 23
const val targetSdk = 33
const val targetSdk = 34

// native build tools
const val ndk = "21.4.7075529"
Expand Down
Binary file modified samples/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion samples/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit fdf68b8

Please sign in to comment.