Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GSoC'24] Feature: Instant Note Editor to allow adding cloze card #16393

Merged
merged 3 commits into from
Jun 3, 2024

Conversation

criticalAY
Copy link
Contributor

@criticalAY criticalAY commented May 14, 2024

Purpose / Description

GSOC

On top of:

This PR aims to provide basic functionality for the instant note editor i.e. allowing the user to add cloze card without actually opening AnkiDroid application, to achieve this we utilize a transparent activity with custom theme.

  • The activity has intent filter to register and receive text when user taps share button after selecting text
  • Instant card label used for the activity
  • EditTextGestureHelper allows user to single tap and turn words to cloze
  • User can also long press and select multiple words/text and turn it to cloze
  • Deck spinner allows user to change deck
  • User can tap in/out manual mode if wanted
  • Cloze increment button allows user to increment cloze number

How Has This Been Tested?

OnePlus Nord CE:
Current UI:

Record_2024-06-02-02-02-58.mp4

Learning (optional, can help others)

How we can use transparent activities [Google and Stackoverflow but didn't save links to them]

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • 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

Copy link
Contributor

Message to maintainers, this PR contains strings changes.

  1. Before merging this PR, it is best to run the "Sync Translations" GitHub action, then make and merge a PR from the i18n_sync branch to get translations cleaned out.
  2. Then merge this PR, and immediately do another translation PR so the huge change made by this PR's key changes are all by themselves.

Read more about updating strings on the wiki,

@criticalAY criticalAY changed the title Feature: Instant Note Editor to allow adding cloze card [GSOC'24] Feature: Instant Note Editor to allow adding cloze card May 14, 2024
@criticalAY criticalAY added Needs Review GSoC Pull requests authored by a Google Summer of Code participant [Candidate/Selected], for GSoC mentors labels May 14, 2024
Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brief thoughts, not a thorough review

AnkiDroid/src/main/AndroidManifest.xml Outdated Show resolved Hide resolved
}

private fun changeToClozeType() {
val model = getColUnsafe.notetypes.all().first { noteType ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A user may have more than one 'cloze' note type

Probably needs an option to select the desired one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First select the note type (cloze) then editor dialog or should we allow that from the dialog itself?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pick a reasonable default, and have an 'options' menu where power users can change it

@criticalAY criticalAY changed the title [GSOC'24] Feature: Instant Note Editor to allow adding cloze card [GSoC'24] Feature: Instant Note Editor to allow adding cloze card May 14, 2024
@criticalAY
Copy link
Contributor Author

I have extracted the long press callback here:

@criticalAY criticalAY force-pushed the instant-note-editor branch 2 times, most recently from 182ab0e to 0912aa3 Compare May 15, 2024 18:43
).apply {
initializeNoteEditorDeckSpinner(col)
launchCatchingTask {
selectDeckById(deckId, true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if deckId isn't loaded yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't happen but just in case it happens then deck with index 1 will be loaded i.e.
i.e. config.get(Decks.CURRENT_DECK) ?: 1L

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking really good!

Comment on lines +511 to +509
/** Allows to keep track of the current cloze number, reset to 0 when activity is destroyed **/
var currentClozeNumber: Int = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this exist in the ViewModel?

This shouldn't be global

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is also used in the custom text helper to track and put clozes hence not in viewModel

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be global

* Activity to support adding notes without opening AnkiDroid
* Text surround helper to tap and turn to cloze
* unitTest: InstantEdtitorViewModel unit test
@criticalAY criticalAY added Needs Second Approval Has one approval, one more approval to merge and removed Needs Review labels Jun 1, 2024
Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm /REALLY/ happy, either last, or penultimate review.

The aim of TODOs is to add them and not block the review on code changes

If they seem to be trivial, feel free to do them

Comment on lines +511 to +509
/** Allows to keep track of the current cloze number, reset to 0 when activity is destroyed **/
var currentClozeNumber: Int = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be global

* added TODOs to the viewModel and activity
Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, some TODOs to be handled later

Congrats! It's happening 🎊

@david-allison david-allison added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Second Approval Has one approval, one more approval to merge labels Jun 2, 2024
@david-allison
Copy link
Member

@lukstbit lukstbit added this pull request to the merge queue Jun 3, 2024
Merged via the queue into ankidroid:main with commit dfe33b6 Jun 3, 2024
8 checks passed
Copy link
Contributor

github-actions bot commented Jun 3, 2024

Maintainers: Please Sync Translations to produce a commit with only the automated changes from this PR.

Read more about updating strings on the wiki,

@github-actions github-actions bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Jun 3, 2024
@github-actions github-actions bot added this to the 2.19 release milestone Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GSoC Pull requests authored by a Google Summer of Code participant [Candidate/Selected], for GSoC mentors Strings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants