It was agreed we use camelCase consistently and
that snake_case was to be applied by `@LibAnkiAlias`
A few legacy methods would have conflicted
rename:
* addField -> addFieldLegacy
* renameField -> renameFieldLegacy
* remField -> remFieldLegacy
* moveField -> moveFieldLegacy
implementation:
search for `fun.*_` inside `libAnki`
Fixes 11582
It was agreed we use camelCase consistently and
that snake_case was to be applied by `@LibAnkiAlias`
implementation:
search for `fun.*_` inside `libAnki`
inline:
* _addTemplate
* _addField
A few legacy methods in `Notetypes.kt` weren't handled
Fixes 11582
Implemented keyboard shortcuts to enhance the user experience by providing quick access to commonly used functionalitie. The following shortcuts have been added:
T: Opens Statistics.
D: Creates a Deck
C: Check database
F: Creates a Filtered Deck.
Del: Deletes the currently focused Deck (on large screen only) with
confirmation dialog.
Shift+Del: Deletes deck without confirmation dialog (on large screen
only)
R: Renames the Deck (on large screen only)
P: Opens Settings.
M: Checks Media.
Ctrl+ E: triggers the Export Collection dialog.
Ctrl + Shift + I: Opens the Import dialog.
Ctrl + Shift + N: Opens Manage Note Types.
Ctrl+B: Restore from backup
* refactor: viewModel to use generic media terms and livedata
* refactor: use reselect string instead of restart
* refactor: extract MenuProvider class
* refactor: show multimedia bottomsheet in case result is cancelled
-Added right-click support for all existing long click listeners.
-Created an OnContextAndLongClickListener interface to handle both context click and long click events consistently.
-This interface includes an onAction method to define the common action (context and long click).
-The interface ensures that both listeners are set without duplicating code.
-Applied the OnContextAndLongClickListener interface to handle right-click and long-click events uniformly.
* Set .gitattributes to automatically detect text files, enabling git to
remove CRLF.
* Keep CRLF for .bat files
* Use .editorconfig to avoid further introduction of CRLF
Use the existing "Gallery" string which is translatable in Crowdin for:
- the "Gallery" option label in the menu of "Select image" in "Image Occlusion" note type
- the "Gallery" option label in the menu of multimedia file attachment in the note editor
8e0b537b1d introduced a call to `updateMenuState()` at the
loadDeckCounts job to update the undo label state when the deck is
reloaded.
Following the method name, the whole menu is updated instead of only the
undo label, which includes checking if there are changes to sync
remotely, and that takes time, so it shouldn't be done if not necessary.
The plugin hasn't been updated for quite some time and it currently
breaks the build and apk publishing. This PR removes it along its
configuration and any additional setup code.
The plugin was already removed from the publishing process as it
didn't work anymore. See https://github.com/ankidroid/Anki-Android/issues/14161
Refactored NoteEditor integration with NoteEditorLauncher interface to centralize configuration for various entry points.
Introduced NoteEditorLauncher as a sealed interface to streamline and unify configurations for opening NoteEditor from different contexts. Provides clear and standardized methods (e.g., AddNote, EditCard) for invoking NoteEditor with specific behaviors and data, improving code clarity and reducing potential errors in bundle creation. Promotes modularization by consolidating NoteEditor-related logic into a single location (noteeditor folder), enhancing maintainability and reducing redundancy across fragments and activities.
- ImageOcclusion: Handles opening NoteEditor with an image URI for creating an image occlusion.
- PassArguments: Directly passes arguments to the NoteEditor for scenarios like sharing text or processing text.
- AddNote: Opens NoteEditor from DeckPicker with optional deck ID.
- AddNoteFromCardBrowser: Opens NoteEditor from CardBrowser, optionally passing search terms and last deck ID.
- AddNoteFromReviewer: Opens NoteEditor from Reviewer, optionally specifying activity transition animation.
- AddInstantNote: Opens NoteEditor for instant note creation with shared text.
- EditCard: Edits a card in NoteEditor, specifying card ID and animation direction.
- EditNoteFromPreviewer: Edits a note in NoteEditor from Previewer, using the card ID.
- CopyNote: Copies a note in NoteEditor, optionally specifying deck ID, field texts, and tags.
1. AnkiFragment:
- Introduced a base class for fragments (`AnkiFragment`) with a `@param layout` documentation referencing `CardViewerFragment`. This base class consolidates common functionality and methods for all future fragments by inheriting `AnkiFragment`.
- Extracted methods from NoteEditor to AnkiFragment for potential reuse in other fragments.
2. NoteEditor Fragment:
- Implemented `OnMenuItemClickListener` to handle toolbar menu item clicks.
- Implemented `DispatchKeyEventListener` to manage key events.
- Initialized Onboarding after the view is created to prevent initialization errors.
- Split `onCreate()` into `onCreate()` and `onViewCreated()` to accommodate differences between activities and fragments in Android. In fragments, the view hierarchy setup (`onViewCreated()`) occurs separately from initialization (`onCreate()`), ensuring operations requiring access to the fragment's view are correctly handled post-creation.
- Replaced `IntentCompat` with `BundleCompat` to handle null data scenarios.
- Utilized `Bundle` instead of `Intent` in `openNewNoteEditor()` to avoid null data issues with `intent.extras`.
5. Intent Handling:
- Updated `SingleFragmentActivity.getIntent()` to support optional `intentAction` parameters, enabling dynamic intent actions like sharing text, images, and processing text.
- Created `IntentHandler2` for:
- Sharing text to NoteEditor
- Sharing image to NoteEditor
- Sharing process text to NoteEditor
- `Add Note` shortcut
- Created AbstractIntentHandler:
- Extract common initialization from IntentHandler and IntentHandler2 into AbstractIntentHandler.
6. NavigationDrawerActivity:
- Resolved error triggering when opening NoteEditor from a shortcut (`Long press AnkiDroid App -> Add`) by redirecting the intent target from NoteEditor to IntentHandler2.
7. ManifestFile:
- Removed NoteEditor from the manifest file due to its transition from an Activity to a Fragment.
- Moved `NoteEditor` specific intent filters from `NoteEditor` to `IntentHandler2`
8. Testing:
- Updated test files under the guidance of David in discord channel and feedback to ensure comprehensive test coverage aligns with the updated architecture and intent handling in AnkiDroid.
- CardBrowserTest: The addIntent returns both SingleFragmentActivity.FRAGMENT_NAME_EXTRA and SingleFragmentActivity.FRAGMENT_ARGS_EXTRA. Since NoteEditor.EXTRA_DID is located within SingleFragmentActivity.FRAGMENT_ARGS_EXTRA, the assertions needed to be adjusted to extract and verify the arguments bundle directly.
This commit refactors NoteEditor into a Fragment, improves intent handling across activities, and enhances fragment lifecycle management for consistent behavior and performance in AnkiDroid.
Used requireContext() when a method or parameter specifically requires a Context
Used requireActivity() when a method or parameter needs to interact with the hosting Activity is required
Used requireArguments() to retrieve fragment arguments. Replaced intent.extras with requireArguments because intent.extras returns both SingleFragmentActivity.FRAGMENT_NAME_EXTRA and SingleFragmentAcitivity.FRAGMENT_ARGS_EXTRA but we need only SingleFragmentAcitivity.FRAGMENT_ARGS_EXTRA
requireContext() and requireActivity() ensure that the Fragment is currently attached and prevent null pointer exceptions, providing safer access to the Context or Activity