Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

fix(new study screen): finish current stroke before changing pen color

Open Amitesh-exp opened this issue 3 months ago • 13 comments

https://github.com/user-attachments/assets/be9af5a2-d37d-4c83-b6fd-daeb9b82caa1

Purpose / Description

When drawing, if the user tapped with another finger to change the brush color, the stroke would continue instead of ending. This caused unexpected merging of strokes with the wrong color.

Fixes

  • Fixes #19236

Approach

  • Added handling for ACTION_POINTER_DOWN in onTouchEvent
  • Now, whenever a second finger touches the screen while drawing, the current stroke is finalized (drawFinish()), isCurrentlyDrawing is reset, and the brush change is applied cleanly.
  • This ensures multi-touch interactions stop the ongoing stroke before switching brush color.

How Has This Been Tested?

  • Tested on Physical Device
  • Drew with one finger, then tapped another finger to change color.
  • Verified that the stroke ended before color switch.
  • Confirmed new strokes started fresh with the new brush color.

Checklist

Please, go through these checks before submitting the PR.

  • [x] You have a descriptive commit message with a short title (first line, max 50 chars).
  • [x] You have commented your code, particularly in hard-to-understand areas
  • [x] You have performed a self-review of your own code
  • [x] UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • [ ] UI Changes: You have tested your change using the Google Accessibility Scanner

Amitesh-exp avatar Sep 21 '25 05:09 Amitesh-exp

not allowing to change tools if the user is drawing.

Currently, you can also press other buttons (like the answer buttons) while drawing. Consider whether to disallow that too.

ZornHadNoChoice avatar Sep 21 '25 18:09 ZornHadNoChoice

Currently, you can also press other buttons (like the answer buttons) while drawing. Consider whether to disallow that too.

For now, disable only the whiteboard buttons. Disabling the others will be more complex, and I prefer to stabilize the screen first.

BrayanDSO avatar Sep 21 '25 23:09 BrayanDSO

The commits got a bit messy Let me know if this will work or do I need to create a new pr with a new branch with single commit

Amitesh-exp avatar Sep 22 '25 18:09 Amitesh-exp

Please don't create a new PR. Rebase it

BrayanDSO avatar Sep 22 '25 21:09 BrayanDSO

e: file:///D:/a/Anki-Android/Anki-Android/AnkiDroid/src/main/java/com/ichi2/anki/ui/windows/reviewer/whiteboard/WhiteboardFragment.kt:86:24 Unresolved reference 'isDrawing'.

Test fails

sanjaysargam avatar Sep 23 '25 17:09 sanjaysargam

@Amitesh-exp rebase it

sanjaysargam avatar Sep 28 '25 11:09 sanjaysargam

https://github.com/user-attachments/assets/56b23ffb-ffa0-4564-aef0-139a45e38952

New Fix: Restricts the user from changing color while drawing

Amitesh-exp avatar Sep 28 '25 12:09 Amitesh-exp

https://github.com/user-attachments/assets/42cf05e9-d7ae-45d6-ae0d-dd9e55c9140f

This type of feature where toolbar disappears is available in many apps where drawing screen is present. Doesn't look unusual too. @BrayanDSO @thedroiddiv

Amitesh-exp avatar Oct 09 '25 08:10 Amitesh-exp

Hey, sorry for the long waiting, I was away the time. I think it's a totally subjective choice My comment was mostly was around how the the disabling was being handled earlier seemed a bit of place. Which looks good to me now.

Will let @BrayanDSO to tak the call here.

This could be something like if(isDrawing) disableButtons() else enableButtons()

or

if(isDrawing) showToolbar() else hideToolbar()

thedroiddiv avatar Oct 23 '25 08:10 thedroiddiv

Still think that hiding the toolbar is distracting and unproductive

BrayanDSO avatar Oct 31 '25 22:10 BrayanDSO

@BrayanDSO Take a look Simply disabled it while drawing

Amitesh-exp avatar Nov 12 '25 05:11 Amitesh-exp

Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

github-actions[bot] avatar Nov 26 '25 05:11 github-actions[bot]

@thedroiddiv @BrayanDSO Please take a look and let me know if any other changes needed

Amitesh-exp avatar Nov 26 '25 05:11 Amitesh-exp

Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

github-actions[bot] avatar Dec 11 '25 20:12 github-actions[bot]