0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-19 19:42:17 +02:00
Commit Graph

19394 Commits

Author SHA1 Message Date
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
lukstbit
390a7cd3ac Remove unused calls to updateValuesForDeck()
The calls that were deleted weren't using the method's return type and
as the method just queries for state removing the calls should be safe.
2024-07-12 18:49:42 +00:00
leobugeja
d3c427b746 fix: card preview autoplay audio 2024-07-11 11:26:46 +00:00
Mike Hardy
869f8d8af3
Dependency updates 20240710 (#16718)
* build(deps): bump org.junit.jupiter:junit-jupiter from 5.10.2 to 5.10.3

Bumps [org.junit.jupiter:junit-jupiter](https://github.com/junit-team/junit5) from 5.10.2 to 5.10.3.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.10.2...r5.10.3)

---
updated-dependencies:
- dependency-name: org.junit.jupiter:junit-jupiter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* build(deps): bump org.junit.vintage:junit-vintage-engine

Bumps [org.junit.vintage:junit-vintage-engine](https://github.com/junit-team/junit5) from 5.10.2 to 5.10.3.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.10.2...r5.10.3)

---
updated-dependencies:
- dependency-name: org.junit.vintage:junit-vintage-engine
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* build(deps): bump org.junit.jupiter:junit-jupiter-params

Bumps [org.junit.jupiter:junit-jupiter-params](https://github.com/junit-team/junit5) from 5.10.2 to 5.10.3.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.10.2...r5.10.3)

---
updated-dependencies:
- dependency-name: org.junit.jupiter:junit-jupiter-params
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* build(deps): bump org.robolectric:robolectric from 4.12.2 to 4.13 (#16703)

Bumps [org.robolectric:robolectric](https://github.com/robolectric/robolectric) from 4.12.2 to 4.13.
- [Release notes](https://github.com/robolectric/robolectric/releases)
- [Commits](https://github.com/robolectric/robolectric/compare/robolectric-4.12.2...robolectric-4.13)

---
updated-dependencies:
- dependency-name: org.robolectric:robolectric
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* build(deps): bump org.mockito.kotlin:mockito-kotlin from 5.3.1 to 5.4.0 (#16710)

Bumps [org.mockito.kotlin:mockito-kotlin](https://github.com/mockito/mockito-kotlin) from 5.3.1 to 5.4.0.
- [Release notes](https://github.com/mockito/mockito-kotlin/releases)
- [Commits](https://github.com/mockito/mockito-kotlin/compare/5.3.1...5.4.0)

---
updated-dependencies:
- dependency-name: org.mockito.kotlin:mockito-kotlin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* build(deps): bump org.jsoup:jsoup from 1.17.2 to 1.18.1

Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.17.2 to 1.18.1.
- [Release notes](https://github.com/jhy/jsoup/releases)
- [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES.md)
- [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.17.2...jsoup-1.18.1)

---
updated-dependencies:
- dependency-name: org.jsoup:jsoup
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-10 21:49:06 -06:00
Mike Hardy
82dea2af95 feat: bump targetSdk to 34 2024-07-11 02:45:12 +00:00
David Allison
1de4391fdf fix(broadcast-receivers): specify export behavior (API 34)
In API 34, `registerReceiver` needs to either accept
`RECEIVER_EXPORTED` or `RECEIVER_NOT_EXPORTED`,
otherwise an exception is thrown

So, introduce `Context.registerReceiverCompat` to avoid code
churn, and use it

Issue 16713

https://developer.android.com/about/versions/14/behavior-changes-14#runtime-receivers-exported
2024-07-11 02:45:12 +00:00
AnkiDroid Translations
16de500e9a Updated strings from Crowdin 2024-07-08 15:43:55 +00:00
SanjaySargam
f17e059498 simplify deckpicker with unified menu 2024-07-08 13:53:37 +00:00
SanjaySargam
50832f9816 hide fragment when collection is empty 2024-07-08 13:53:37 +00:00
AnkiDroid Translations
e6eaa5c22e Updated strings from Crowdin 2024-07-08 13:30:57 +00:00
AnkiDroid Translations
1125658c23 Updated strings from Crowdin 2024-07-08 04:54:15 +00:00
Arthur Milchior
016330188f Clarify note type ui model
I found the code slightly unclear and tried to improve it.

* NotetypeBasicUiModel was not related to basic note types
* isStandard and useCount did not seem to me to have a clear meaning in anki lexicon, so must be document
* toUiModel can't be appled to a standard entry as far as I understand it, and is in any case never applied to a standard note type currently, so we can remove the argument.
2024-07-08 03:25:56 +00:00
Arthur Milchior
34263d1c87 NF: delete tools/crashes-data-mining
This folder has not been updated once in 14 years, refers to a
data source that does not exists anymore, and would be used to provide
analytics we can probably get somewhere else.

I don't expect it's worth anyone time to try repairing it.

Closes #16695. Also simplify sligthly bug #16692.
2024-07-07 18:02:14 +00:00
Arthur Milchior
d71d315d4d NF: add Sargam to usernames
This way it won't be shown as typo by Intelli-J
2024-07-07 16:57:58 +00:00
AnkiDroid Translations
5d3960521a Updated strings from Crowdin 2024-07-05 14:29:30 +00:00
Ashish Yadav
74a02eec9a enhancement: show discard change dialog
* fix: share the updated text to note editor
* fix: cloze number to increment only in increment mode

Co-authored-by: David Allison <62114487+david-allison@users.noreply.github.com>
2024-07-05 13:43:07 +00:00
AnkiDroid Translations
e47cc2fe7f Updated strings from Crowdin 2024-07-04 17:53:18 +00:00