diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterView.java b/shell/platform/android/io/flutter/embedding/android/FlutterView.java index a1eaed6da7f03..36e9c84e192a0 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterView.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterView.java @@ -24,6 +24,7 @@ import android.util.SparseArray; import android.view.Display; import android.view.DisplayCutout; +import android.view.InputDevice; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.PointerIcon; @@ -846,6 +847,20 @@ public InputConnection onCreateInputConnection(@NonNull EditorInfo outAttrs) { return textInputPlugin.createInputConnection(this, keyboardManager, outAttrs); } + @Override + public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) { + // TODO(justinmc): Also need to check if over a valid field and if stylus + // input is supported. + // Maybe have to do this in the framework and show a Flutter icon? + final int toolType = event.getToolType(pointerIndex); + if (!event.isFromSource(InputDevice.SOURCE_MOUSE) + && event.isFromSource(InputDevice.SOURCE_STYLUS) + && toolType == MotionEvent.TOOL_TYPE_STYLUS) { + return PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_HANDWRITING); + } + return super.onResolvePointerIcon(event, pointerIndex); + } + /** * Allows a {@code View} that is not currently the input connection target to invoke commands on * the {@link android.view.inputmethod.InputMethodManager}, which is otherwise disallowed.