0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 03:52:15 +02:00
Commit Graph

19510 Commits

Author SHA1 Message Date
CLIDragon
2c7c0c5bda Replace CRLF with LF 2024-07-23 09:54:01 +00:00
CLIDragon
1feb8b31b8 Prevent CRLF line endings
* 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
2024-07-23 09:54:01 +00:00
snowtimeglass
ece272e7af Make "Gallery" labels translatable from Crowdin
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
2024-07-22 11:39:32 +00:00
SanjaySargam
b9aacdee33 Unify imagePath and audioPath into a single mediaPath 2024-07-21 22:28:03 +00:00
MorenoTropical
17565b99e2 improve deleted deck message 2024-07-21 22:04:19 +00:00
Ashish Yadav
73dde8aef5 feature: enable instant editor for public use 2024-07-21 06:15:56 +00:00
MorenoTropical
f3e8b497d1 fix: Processing... popup in app startup
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.
2024-07-21 05:43:29 +00:00
jainv4156
88d4a983d4 Dynamicaly set in sentence case... Flag,Toggle Witeboard,Abort Learning
fdasdf

asdfasfd

sfad
2024-07-21 03:41:38 +00:00
AnkiDroid Translations
972b12af7c Updated strings from Crowdin 2024-07-20 09:49:52 +00:00
Ashish Yadav
bb85307f88 feat: setup new multimedia bottom sheet
* feat: added multimedia activity and base fragment
* enhancement: setup the gallery and camera options
2024-07-20 07:58:30 +00:00
Ashish Yadav
c7a2488a72 feat: add multimedia UI dev option 2024-07-20 07:58:30 +00:00
Sumit Singh
9f45f58390 Update the snackbar to show a due date card 2024-07-20 07:36:57 +00:00
AnkiDroid Translations
987a925060 Updated strings from Crowdin 2024-07-20 04:56:27 +00:00
David Allison
93333ed57c fix: "MissingDefaultResource" lint: iw
This should only be checked on `/values`

Added in 0f795cea36
2024-07-19 15:38:08 -03:00
AnkiDroid Translations
bc26f7fd62 Updated strings from Crowdin 2024-07-19 11:43:32 +00:00
Mike Hardy
4afa7ec41e Bumped version to 2.19alpha10 2024-07-19 11:19:21 +00:00
lukstbit
8c352ec3de Remove "app.brant.amazonappstorepublisher" plugin
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
2024-07-19 06:18:30 -05:00
SanjaySargam
336736faec NoteEditor intent creation using NoteEditorLauncher interface
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.
2024-07-19 10:13:04 +00:00
SanjaySargam
ba341fc788 Convert NoteEditor to Fragment
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.
2024-07-19 10:13:04 +00:00
SanjaySargam
698a74236f Refactor NoteEditor
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
2024-07-19 10:13:04 +00:00
Ashish Yadav
2e429bc009 enhancement: add long press listener on cloze chips 2024-07-19 10:11:29 +00:00
AnkiDroid Translations
8167b20d35 Updated strings from Crowdin 2024-07-19 09:19:57 +00:00
Mike Hardy
fab5a8caad
Dependency updates 20240718 (#16755)
* build(deps): bump lint from 31.5.0 to 31.5.1 (#16724)

Bumps `lint` from 31.5.0 to 31.5.1.

Updates `com.android.tools.lint:lint-api` from 31.5.0 to 31.5.1

Updates `com.android.tools.lint:lint` from 31.5.0 to 31.5.1

Updates `com.android.tools.lint:lint-tests` from 31.5.0 to 31.5.1

---
updated-dependencies:
- dependency-name: com.android.tools.lint:lint-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.android.tools.lint:lint
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.android.tools.lint:lint-tests
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump androidGradlePlugin from 8.5.0 to 8.5.1

Bumps `androidGradlePlugin` from 8.5.0 to 8.5.1.

Updates `com.android.application` from 8.5.0 to 8.5.1

Updates `com.android.library` from 8.5.0 to 8.5.1

---
updated-dependencies:
- dependency-name: com.android.application
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.android.library
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update Gradle Wrapper from 8.8 to 8.9.

Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>

* build(deps): bump io.mockk:mockk from 1.13.11 to 1.13.12 (#16743)

Bumps [io.mockk:mockk](https://github.com/mockk/mockk) from 1.13.11 to 1.13.12.
- [Release notes](https://github.com/mockk/mockk/releases)
- [Commits](https://github.com/mockk/mockk/compare/1.13.11...1.13.12)

---
updated-dependencies:
- dependency-name: io.mockk:mockk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2024-07-18 17:57:13 -05:00
Ashish Yadav
a7811e4a4a improvement(instant-editor): punctuation handling
Primarily dashes and underscores

unitTest: create unit test for connecting punctuation
2024-07-18 21:19:53 +00:00
Arthur Milchior
f62471c71a refactor: small code cleanups
First, I wanted to replace
`isEmpty` by `containsNoCard`. It seems interesting to note that this
may still contains non-default note-type and decks, and still consider
the collection empty.

This makes me look at Pairs, and found that, often, destructing the
Pair seems more readable to me than using `.first` and
`.second`. Especially when it eiher allows to have a single non-null
assertion, or allows to have name value instead.

I also added some `@NotLibAnki` instead of comments, as I just
dicovered that annotation.
2024-07-18 21:13:11 +00:00
AnkiDroid Translations
b1692c5f75 Updated strings from Crowdin 2024-07-18 18:55:40 +00:00
Brayan Oliveira
4f47106675 feat(new reviewer): hide answer buttons 2024-07-18 15:11:41 +00:00
Brayan Oliveira
712f9fa752 feat(new reviewer): ignore display cutout
https://developer.android.com/develop/ui/views/layout/edge-to-edge#cutout-insets
2024-07-18 15:11:41 +00:00
Brayan Oliveira
a4bd5d0395 feat(new reviewer): immersive mode
https://developer.android.com/develop/ui/views/layout/immersive

magic numbers are used for the preferences values because they can be reported in analytics
2024-07-18 15:11:41 +00:00
Brayan Oliveira
0a0b2dd6a9 feat: new reviewer settings page
dev-only
2024-07-18 15:11:41 +00:00
lukstbit
f73708acd4 Change conflicts workflow to allow more PRs to be checked
The workflow was fetching the opened pull requests in the repository
but the returned results were per page with the default page value(30)
being used. This meant that the worflow would check only the oldest 30
opened pull requests. The per page value was changed to the maximum
value of 100.

See https://octokit.github.io/rest.js/v20#pulls-list

This still means the workflow doesn't handle over 100 opened pull
requests, but we shouldn't get there anyway.
2024-07-18 15:05:34 +00:00
David Allison
94f614900b refactor(note-editor): improve nullability
for `startMultimediaFieldEditor`

Kotlin Cleanup - parameter should not have been nullable

Split out from a review comment
2024-07-18 14:31:26 +00:00
andriusezerskis
e74abb7bc8 Adding commit of wildcards removal in ignore-revs 2024-07-18 13:18:01 +00:00
AnkiDroid Translations
3db9fedbdf Updated strings from Crowdin 2024-07-18 07:26:56 +00:00
lukstbit
fae022aa0d Show progress for the initial part of importing a collection
Adds a withProgress call for the initial part of importing a collection
(where the file to import is copied). This was done on a background
thread so the UI wasn't blocked but the user also didn't know that
something was happening related to the import he just initiated.
2024-07-18 05:31:58 +00:00
lukstbit
c7cbea0b53 Move exported file saving to a background thread
This avoids the UI being "blocked" while saving the exported collection or
apkg, issue which becomes "visible" to the user when dealing with bigger
collections.
2024-07-18 05:31:58 +00:00
lukstbit
a73f17330e Remove StdModels related code
Used only in tests.

The initializer functions code used to create the models in StdModels
were refactored as standalone functions to be used by interested tests.

Note: StdModels were both used in unit and instrumented tests. As
there's only one usage in an instrumented test I duplicated the code
to avoid the use of the testlib.

The strings for the model names were removed because we don't need
translations for strings used in tests. The "front" and "back" names
are used in CardTemplateEditor, should probably be moved to one of
the other files to not have a strings file with just two strings in
it.
2024-07-18 05:31:41 +00:00
AnkiDroid Translations
1f7fc288d8 Updated strings from Crowdin 2024-07-18 04:17:20 +00:00
andriusezerskis
c63e93a09f Remove wildcard from imports 2024-07-17 09:16:28 +00:00
andriusezerskis
1a3c1a1ab0 Removed rule that allowed wildcard imports 2024-07-17 09:16:28 +00:00
Ashish Yadav
4bdef4764c refactor: use prefill value in integer dialog 2024-07-17 07:38:12 +00:00
Arthur Milchior
dbf737a647 Fixes null pointer exception
After reproducing #16702, I discovered that actually, the part of the
code where the NPE occurred should not have been reached.

newModel and oldModel are two distinct objects representing the same
note type. And JSonObject's equality is defined as pointer
equality. Using id instead of actual note type repair the bug.

Since, in AnkiDroid, editing the note type through the reviewer, can't
lead to adding or removing field, this is safe to consider that if the
id is equal, the objects are equal as far as the list of field is concerned.

I fear I don't see how to test it easily. It seems it require
AndroidTest and not unit tests, and I can't find example of note editor
test. Furthermore note editor will be replaced soon, so I don't expect
it's such a big deal.

* Fixed #16702
2024-07-17 05:29:36 +00:00
jainv4156
93c2f68429 Fix Android Studio warnings in several files 2024-07-17 05:12:54 +00:00
Robozinho
7f1317245d restrict deck option links 2024-07-16 05:51:39 +00:00
Arthur Milchior
8ad0a63caa NotType related code cleaning
While searching for other uses of == instead of comparing id of note
type, I did some code cleaning.
* renaming some `m` to `notetype`
* deleting a unused constructor
* correcting a wrong documentation
* remove `deepcopy` (as it's the same result as `deepClone`)
2024-07-15 12:46:50 +00:00
AnkiDroid Translations
ec2792792a Updated strings from Crowdin 2024-07-14 10:22:07 +00:00
Mike Hardy
703e6487ae
release: manual bump to 2.19alpha9
required me to build release with production signing key locally
for upload vs on CI so I could manually work through foreground
service justification process on Play Console
2024-07-13 17:31:02 -06:00
Arthur Milchior
d771d752a9 NF: NoteEditor onKeyUp return true
I don't expect it was causing a bug, but `onKeyUp` almost always
returned false, even when the key press was handled.

This is now corrected.

I had trouble understanding the `selectFieldIndex` part. I hope I
improved it. Also added a unit test, given the simplicity of this part
of the code.

I wanted to test the remaining of KeyUtils, but got error messages,
telling me

java.lang.RuntimeException: Method getUnicodeChar in android.view.KeyEvent not mocked. See https://developer.android.com/r/studio-ui/build/not-mocked for details.
	at android.view.KeyEvent.getUnicodeChar(KeyEvent.java)
	at com.ichi2.utils.KeyUtils.getDigit(KeyUtils.kt:30)

I'd be interested in help if it's quick to do. But otherwise, it's not
worth losing time on it.
2024-07-13 22:22:25 +00:00
Robozinho
848e0dcfc9 improve SliderPreference value display 2024-07-13 21:01:43 +00:00
Rishav Kumar
2c959dcfdf
Fixed keyboard done button during creation or renaming of deck (#16704)
* added on done click listener

* defined singleline is true and maxLine is 1 for Text input field

* added on done click listener
2024-07-12 16:06:34 -03:00