* deleted empty string
* removed redundant qualifier name
* fixed warning "Variable is same as 'searchText' and can be inlined"
* removed redundant ‘constructor’ keyword
* removed unnecessary parentheses in function call with lambda
* removed explicit type arguments
* fixed foldable if-then
* replaced java methods with kotlin analog
* moved lambda argument out of parentheses
* replaced negated 'isEmpty' with 'isNotEmpty'
* replaced subsequent checks with 'isNullOrEmpty()' call
* used import statement for max function in Scheduler.kt
* used import statement for ceil function in Scheduler.kt
* reformatted code
* version catalog conflict
solve
* implementing version catalog for stable versioning between modules
* implementing version catalog for stable versioning between modules
---------
Co-authored-by: abdelrahmanesam <abdelrahmanesam>
This requires adding `col` to any function using it, recursively, until finding another function with `col` in its context.
`Reviewer.onResume` has moved to `launchWithCol`, as otherwise tests crash
with the following trace:
```
java.lang.NullPointerException
at com.ichi2.anki.AnkiActivity.getCol(AnkiActivity.kt:151)
at com.ichi2.anki.Reviewer.onResume(Reviewer.kt:191)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1476)
at org.robolectric.android.internal.RoboMonitoringInstrumentation.callActivityOnResume(RoboMonitoringInstrumentation.java:321)
at android.app.Activity.performResume(Activity.java:8191)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.robolectric.shadows._Activity_$$Reflector19.performResume(Unknown Source)
at org.robolectric.android.controller.ActivityController.lambda$resume$5(ActivityController.java:197)
at org.robolectric.shadows.ShadowPausedLooper.runPaused(ShadowPausedLooper.java:204)
at org.robolectric.android.controller.ComponentController.invokeWhilePaused(ComponentController.java:64)
at org.robolectric.android.controller.ActivityController.resume(ActivityController.java:192)
at org.robolectric.android.internal.RoboMonitoringInstrumentation.startActivitySyncInternal(RoboMonitoringInstrumentation.java:121)
at org.robolectric.android.internal.LocalActivityInvoker.startActivity(LocalActivityInvoker.java:35)
at org.robolectric.android.internal.LocalActivityInvoker.startActivity(LocalActivityInvoker.java:40)
at androidx.test.core.app.ActivityScenario.launchInternal(ActivityScenario.java:362)
at androidx.test.core.app.ActivityScenario.launch(ActivityScenario.java:202)
at com.ichi2.anki.ReviewerTest.verifyStartupNoCollection(ReviewerTest.kt:67)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:589)
at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$2(SandboxTestRunner.java:290)
at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:99)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Suppressed:
org.robolectric.android.internal.AndroidTestEnvironment$UnExecutedRunnablesException:
Main looper has queued unexecuted runnables. This might be the cause of
the test failure. You might need a
shadowOf(Looper.getMainLooper()).idle() call.
```
In the worst case, this slightly delays when the time starts again, which is acceptable.
----
Revived from 5f01180be2
Co-authored-by: Arthur Milchior <arthur@milchior.fr>
* Kotlin Cleanup: docs
* removed almost all occurrence of `{@}` in the code
* searched for `<pre>` and removed one more
* and a little extra cleanup on docs strings when I saw them
Learning:
* 4 spaces before a line removes KDoc `[]` links
* KDoc has no way to link to a specific method overload
* Kotlin Cleanup: docs
* Fixed `<` -> `<`
* Fixed `>` -> `>`
* build(deps): ignore commons-compress below 1.25 now
We are still not minSdkVersion >= API26 so we may not advance this
dependency yet, we just notch this forward one version at a time
so we continue to be aware of their releases, but ignore them for now
* build(deps): bump androidx.annotation:annotation from 1.6.0 to 1.7.0
Bumps androidx.annotation:annotation from 1.6.0 to 1.7.0.
---
updated-dependencies:
- dependency-name: androidx.annotation:annotation
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump com.google.protobuf:protobuf-kotlin-lite
Bumps com.google.protobuf:protobuf-kotlin-lite from 3.24.2 to 3.24.3.
---
updated-dependencies:
- dependency-name: com.google.protobuf:protobuf-kotlin-lite
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump org.jlleitschuh.gradle.ktlint from 11.5.1 to 11.6.0
Bumps org.jlleitschuh.gradle.ktlint from 11.5.1 to 11.6.0.
---
updated-dependencies:
- dependency-name: org.jlleitschuh.gradle.ktlint
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump com.google.protobuf:protobuf-kotlin-lite
Bumps com.google.protobuf:protobuf-kotlin-lite from 3.24.3 to 3.24.4.
---
updated-dependencies:
- dependency-name: com.google.protobuf:protobuf-kotlin-lite
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump commons-io:commons-io from 2.13.0 to 2.14.0
Bumps commons-io:commons-io from 2.13.0 to 2.14.0.
---
updated-dependencies:
- dependency-name: commons-io:commons-io
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump io.mockk:mockk from 1.13.7 to 1.13.8
Bumps [io.mockk:mockk](https://github.com/mockk/mockk) from 1.13.7 to 1.13.8.
- [Release notes](https://github.com/mockk/mockk/releases)
- [Commits](https://github.com/mockk/mockk/compare/1.13.7...1.13.8)
---
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>
* Update Gradle Wrapper from 8.3 to 8.4.
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
* Only split APK build by ABI in release builds
This avoids the upstream android gradle plugin issue introduced in
AGPv8.1.2 (and seemingly fixed in AGBv8.3.0-alpha07) where doing
an ABI split while including resources crashes the build:
https://issuetracker.google.com/issues/302961829
If this causes problems or is distasteful, can be reverted when
AGP v8.3+ is adopted, or if they do pick it to AGPv8.2+, at that time
* Adopt android gradle plugin v8.1.2
* ignore dynamic receiver registrations without export-type specified
these receivers *should* specify at registration whether they are for export
or not for export but if that is added (such as in PR 14158) then there is also
a need to add a new permission to the manifest or you get runtime errors, and
we haven't figured that out yet
* build(deps): bump org.jetbrains.dokka from 1.9.0 to 1.9.10
Bumps [org.jetbrains.dokka](https://github.com/Kotlin/dokka) from 1.9.0 to 1.9.10.
- [Release notes](https://github.com/Kotlin/dokka/releases)
- [Commits](https://github.com/Kotlin/dokka/compare/v1.9.0...v1.9.10)
---
updated-dependencies:
- dependency-name: org.jetbrains.dokka
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump com.squareup.okhttp3:okhttp from 4.11.0 to 4.12.0
Bumps [com.squareup.okhttp3:okhttp](https://github.com/square/okhttp) from 4.11.0 to 4.12.0.
- [Changelog](https://github.com/square/okhttp/blob/master/CHANGELOG.md)
- [Commits](https://github.com/square/okhttp/compare/parent-4.11.0...parent-4.12.0)
---
updated-dependencies:
- dependency-name: com.squareup.okhttp3:okhttp
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump org.jlleitschuh.gradle.ktlint from 11.6.0 to 11.6.1
Bumps org.jlleitschuh.gradle.ktlint from 11.6.0 to 11.6.1.
---
updated-dependencies:
- dependency-name: org.jlleitschuh.gradle.ktlint
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump compileSdk to 34, handle new deprecations (#14556)
* Bump compileSdk to 34
* Alter system API overrides to handle newly nullable items in API34
Investigating the various changes led me to conclude that simple null
checks and default returns if null was an adequate response to the
newly-possible null case in the various parameters
* API34 deprecates Class.newInstance, get ctor and newInstance that instead
* use new API34 pixel calc style if available
this apparently allows for finer more dynamic user text sizing
* Temporarily suppress deprecation on animation overrides
API34 adds new predictive back behavior, which implies that the
transition animation overrides for activity stack change animations
now need to know whether the animation override is for activity open or
close, whereas we override both as a unit without thought
This needs a solution before the deprecated methods go away, likely in
the form of plumbing through (via a new parameter) the idea of whether
the call site intended to override open, close, or both animations. For
backwards compatibility this will likely need to be a Compat interface
(or interfaces) to replace the current implementation
* build(deps): bump androidx.webkit:webkit from 1.7.0 to 1.8.0
Bumps androidx.webkit:webkit from 1.7.0 to 1.8.0.
---
updated-dependencies:
- dependency-name: androidx.webkit:webkit
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump androidx.browser:browser from 1.5.0 to 1.6.0
Bumps androidx.browser:browser from 1.5.0 to 1.6.0.
---
updated-dependencies:
- dependency-name: androidx.browser:browser
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump androidx.activity:activity-ktx from 1.7.2 to 1.8.0 (#14515)
* build(deps): bump androidx.activity:activity-ktx from 1.7.2 to 1.8.0
Bumps androidx.activity:activity-ktx from 1.7.2 to 1.8.0.
---
updated-dependencies:
- dependency-name: androidx.activity:activity-ktx
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* call super.onBackPressed in onBackPressed overrides
This is more "predictive back" feature fallout, this commit should be examined,
and the behavior in these 4 objects may need a change, in order to more correctly
deal with API34 predictive back
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Hardy <github@mikehardy.net>
* build(deps): bump androidx.recyclerview:recyclerview from 1.3.1 to 1.3.2
Bumps androidx.recyclerview:recyclerview from 1.3.1 to 1.3.2.
---
updated-dependencies:
- dependency-name: androidx.recyclerview:recyclerview
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump androidx.core:core-ktx from 1.10.1 to 1.12.0 (#14407)
* build(deps): bump androidx.core:core-ktx from 1.10.1 to 1.12.0
Bumps androidx.core:core-ktx from 1.10.1 to 1.12.0.
---
updated-dependencies:
- dependency-name: androidx.core:core-ktx
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* PendingIntentCompat.getBroadcast() is nullable now, wrap use of result in null checks
It will only return null if we specify intent flags which we never specify, so our behavior
does not need to change, but we must respect the type system by wrapping the use of the now-nullable
result in null checks
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Hardy <github@mikehardy.net>
* build(deps): bump androidx.sqlite:sqlite-framework from 2.3.1 to 2.4.0
Bumps androidx.sqlite:sqlite-framework from 2.3.1 to 2.4.0.
---
updated-dependencies:
- dependency-name: androidx.sqlite:sqlite-framework
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump androidx.appcompat:appcompat
Bumps androidx.appcompat:appcompat from 1.7.0-alpha02 to 1.7.0-alpha03.
---
updated-dependencies:
- dependency-name: androidx.appcompat:appcompat
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@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>
See https://kotlinlang.org/docs/dokka-introduction.html
Note: dokka seems to be one version behind the official kotlin version.
The change in FlashCardsContract was done as dokka complained about
that particular ###### combination.
* Hide the Floating Action Button
* Removed the Code of the Floating Action Button in CardBrowser.kt
* fixing lint debug failed problem
* Fixed the Issue:- Deprecation: compileSdkVersion
Ideally we would use
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) to enforce
the repositories declared in settings.gradle.kts but it currently
conflicts with a local maven repository declared in
robolectricDownloader.gradle.
The repositories lambda wasn't deleted from the AnkiDroid module as
the build failed in relation to "com.android.tools:desugar_jdk_libs"(
most likely and issue with the dependency itself) with the error:
Could not resolve all dependencies for configuration ':AnkiDroid:coreLibraryDesugaring'.
The project declares repositories, effectively ignoring the repositories you have declared in the settings.
You can figure out how project repositories are declared by configuring your build to fail on project repositories.
See https://docs.gradle.org/8.1.1/userguide/declaring_repositories.html#sub:fail_build_on_project_repositories for details.
Could not find com.android.tools:desugar_jdk_libs:2.0.3.
Searched in the following locations:
- file:/home/*/.m2/repository/com/android/tools/desugar_jdk_libs/2.0.3/desugar_jdk_libs-2.0.3.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :AnkiDroid
* Update target API to 23
* Update to 2.1.66, and switch to new schema by default
+ Temporarily disable unused resource warnings
* Drop legacy syncing code
* Drop legacy import/export code
* Drop legacy tag handling
* Drop legacy config handling
* Drop legacy database check
* Stub out unused v1 scheduler code
Can't be fully removed, as we still need to be able to open a v1 collection
so the user can upgrade.
moveVersions test has been removed, as backend code is used for moving
outside of unit tests.
* Drop legacy deck handling
* Drop legacy search code
* Drop legacy notetype code
This breaks the card template editor, so I've temporarily disabled it
in the GUI. Getting it working again will require switching to the new
template rendering code in the new backend.
Also breaks an "empty cards" action in CardContentProvider,
as I was not sure what it was trying to accomplish.
* Drop legacy media code
This removes oakkitten's custom media checking code, as keeping it
would require keeping a bunch of the duplicated Kotlin logic. His comment
about cancellation is incorrect: the call can be cancelled with backend.
setWantsAbort() on a background thread. And since the app enforces filenames
are normalized when they're added anyway, I don't think avoiding automatic
normalization is worth the duplicated code.
* Drop legacy Collection/DB code
* Drop most references to defaultLegacySchema
* Remove legacy schema tests from CI
CI won't work yet, because backend version needs updating
* Fix import CSV call
* Remove some unused symbols from anki module
* Drop majority of old stats code
* Remove unused symbols from libanki
* Remove some broken Android tests, and fix one
checkIfStudyOptionsIsDisplayedOnTablet() is also consistently failing,
but was doing so before I started on these changes.
* Move config methods into col.config
* Simplify config API
- Use kotlinx.serialization so that arbitrary typed objects can be
(de)serialized
- There is a single generic get(), that always returns an optional
value, which will be null if the key is missing, is null, or is not the
correct type. There will always be collections that have invalid data,
so the calling code always needs to be prepared to substitute a reasonable
default in such cases.
- Expose the typed getBool() method from the backend.
* Remove unused legacy importer
* Drop jackson
* Models -> Notetypes
* Remove some more unused symbols
* Remove generic type aliases
* Rename Model -> Notetype
I had to leave ModelTest.kt's filename alone, as changing it to Notetype.kt
reorders the unit tests, and causes about 4 tests to start flaking.
* Get card template editor preview working again
* Enable undo on edits; fix test hang
* Use backend for bulk suspend/undo
By default, undoableOp() notifies all screens listening for opExecuted,
so the refreshing happens automatically, and the manual refresh code
at the end of the old routine is no longer required. It is possible to
bypass this when you want to manually update the UI, but this is probably
not worth attempting until the card browser is either switched over to
a recycler view, or reimplemented as a web component.
The LongArrays have been switched to simple lists, as Google's protobuf
code expects Iterable<Long>
* Use backend for marking/undo, and change deck/undo
* Migrate reviewer actions/undo to backend
* Migrate remainder of undo code to backend, apart from v2 undo
Couple of notes:
- The legacy v2 undo no longer returns the undone card, and instead
rebuilds the queue. In some circumstances (eg a learning card has become
due), this can result in a different card being shown after undoing.
This is not ideal, but v2 does not have long to live at this point.
- The reset/reposition tests were reusing the old card cache values,
which have to be reloaded after an operation.
- A test in AbstractSched had to be moved to ReviewerTest so it can have
access to an activity.
- UndoTest has been removed, as it mainly focused on removed code.
* GetCard() -> getNextCardAndRedraw()
* render_output -> renderOutput()
* Drop AsyncTask
Probably the hardest part of AnkiDroid's code base to follow; very
glad to see the end of it.
Closes#7108
* Make note addition undoable
* Make bulk tag update undoable
* Remove remaining explicit transaction handling
The backend automatically wraps backend actions in a transaction,
and removing the explicit calls will allow us to drop the redundant
mutex that rsdroid acquires.
* Remove remaining unused classes/methods/properties
* Remove FunctionalInterfaces
* Switch to backend answer comparison
* Remove unused locking code + legacy storage code
* Switch ContentProviderTest to new schema, and fix bug
* Remove legacy Deck Options settings
* fix: remove minSdkVersion < 23 code
* Use short time in snackbars
People complained about snackbars interrupting their reviews before
* fix: don't duplicate undo label
It were showing a message like `Undo Undo Add Note`
* Remove "Advanced statistics"
* Remove legacy_schema local property
* Leave zip validation up to the backend
The backend takes care of validating the zip file and ensuring files aren't
written outside of the media folder.
I've expanded the mime match to include the zip mime, on the assumption
that's what the mime type is being changed to on some devices. If that
proves to be insufficient, a much simpler approach would be to look
for 50 4B 03 04 at the start of the file to determine if it's a zip file
or not.
This leaves only Mani's add-on code using commons-compression, so you
could potentially switch to a simpler tgz-specific library in the future
if that is easier.
* Disable two flaky tests
They started to flaky reliably after the legacy deck options test
was removed.
* Improve logging of HTTP requests
* Remove ModelBrowser
Replaced by ManageNotetypes
* Remove legacy CardInfo
replaced by com.ichi2.anki.pages.CardInfo
* Change comments at AdvancedSettingsFragment
* test: check if prefs analytics list don't have extra elements
* ContextCompat.getColor -> getColor
that compat method is for implementations in API < 23
* Remove more unused files
* refactor: move SECONDS_PER_DAY to a separate util file
in order to be able to remove Stats.kt later
* refactor: remove Stats and OverviewStatsBuilder
* Access sched.card directly in tests
The helper was adding a 500ms sleep on every fetch, which slowed the
scheduler tests down considerably.
* Make v3 scheduler the default; drop support for v2
The v3 scheduler was originally released in 2021, and we've been waiting
for a stable AnkiDroid release to support it before we could switch users
over to it. Now that 2.16 is out, we can finally push v3 out across the
ecosystem.
While we could theoretically make v3 the default without removing v2,
here are the reasons why I think we're better off switching to v3 only:
- AnkiWeb's review interface will likely switch over to v3-only in the
coming weeks, and AnkiMobile will likely drop v2 around the same time
2.17 comes out.
- v2 and v3 differ in a few ways that makes maintaining the two separate
paths more complicated: things like the different undo paths, counts not
including the current card, and the way the v3 scheduler supports custom
scheduler js. 2.17 is a chance to clean up a lot of old cruft in the
code base, and the old scheduling code is part of that.
- v2 and v3 are compatible with each other, and don't require a full sync
to change, so it doesn't break syncing with old clients (though depending
on settings, due counts may differ, which needs explanation)
I had to disable a couple of tests for this that we'll probably want
to restore in some form:
- corruptVersion16CollectionShowsDatabaseError() needs an update, and
it may be time to rip out the old CollectionHelper colIsOpen(), getColSafe()
and so on, migrating code that uses it over to withCol() instead. The
'collection inaccessible' dialog also needs a rethink - perhaps the various
exceptions could be handled in launchCatchingTask instead.
- testUndoResetsCardCountsToCorrectValue() is failing because initLayout()
creates a gesture listener, which fails with an error about the looper
not being initialized. I am not sure what's going on there - one option
would be to move the test to androidTest.
* Drop v2 sched file; rename files
* Drop AbstractSched and legacy undo code/queue code
* Migrate BaseSched into Scheduler
* More unused symbol removal
* Remove DeckTreeNode
* Remove unused processChildren()
* Remove shouldDisplayCounts(), as counts always available
* Remove manual hashCode()/compareTo() implementations
* Drop AbstractDeckTreeNode
* Turn DeckNode into a wrapper for DeckTreeNode
* Drop TreeNode and simplify filtering
* Remove `New card position` global preference
Overridden by per-deck configuration
Closes#12319
* fix: remove chess.css from card_template_html
* Store current queue state in reviewer
Prerequisite for solving #12620
Also dropped answerButtons(), as it's always 4
* Use local HTTP server for serving flashcard content
Prerequisite for solving #12620
* Implement support for custom JS scheduling
Enables FSRS and closes#12620
* Remove more unused code
* Remove separate Deck(Config)V16 objects and more unused code
* Move some NotetypeJson methods into its file
* Finish tidying Decks.kt
* Drop redundant col property on Collection
* Remove some usages of CollectionGetter
* Rename col->getColUnsafe to encourage migration
* Remove Reviewer.sched
* Handle deck tree not initialized in empty collection
* refactor: move syncStatus() to Collection
to avoid direct calls to the backend
* fix: do not show error when updating the menu if there is no internet
Reproduction steps:
1. have the collection synced
2. disable the device internet connection
3. Restart the app
* Remove unused resources and re-enable lint
* Restore sync cancel strings
* Defer loading webpage until server has initialized
* Ignore translations without a base entry
https://github.com/ankidroid/Anki-Android/pull/14171#issuecomment-1660286342
* Remove the SortOrder deprecation
* Remove the apparently-unused Backup.kt
* Remove last remaining use of Collection's context field
* Stop passing Context to backend
The library loading is now AnkiDroid's responsibility, so the backend
does not require access to an Android context.
Also remove the unused context field from Collection.
* Use backend for rendering next time labels
* Use backend for rendering finished message
The custom study & unbury descriptions are slightly different, but
should suffice until AnkiDroid can start using the Svelte finished
screen.
* Run SchedulerTest without Robolectric
Halves the run time. To do this, I implemented a new JvmTest class
and copied some of the helpers in RobolectricTest into it.
* Remove unused Kotlin implementation of template parsing
* Move Util code dealing with resources out of libanki
* Migrate remaining libanki tests to raw JVM
+ Remove some commented-out tests
Total savings are a drop from about 3m40s to 2m40s, with the scheduler
test class dropping its runtime by about half.
* Lazy-initialize col in tests
* Restore 'experimental' string
* Add comments to update-localizations.py
* Restore AcraAnalyticsInteraction.kt
---------
Co-authored-by: Brayan Oliveira <69634269+brayandso@users.noreply.github.com>
Android 12L (API level 32) is a minor release that makes Android 12 even better on large screens.
There are no breaking changes. Since we have removed support for TVs, this is primarily relevant for
foldable phones and Chromebooks
Since Google has imposed a hard deadline in a couple of weeks, only tested on:
* Large Desktop API 32
Changes: https://developer.android.com/about/versions/12/12L/summary
Issue 14129
* Bump com.squareup.leakcanary:leakcanary-android from 2.11 to 2.12
Bumps [com.squareup.leakcanary:leakcanary-android](https://github.com/square/leakcanary) from 2.11 to 2.12.
- [Release notes](https://github.com/square/leakcanary/releases)
- [Changelog](https://github.com/square/leakcanary/blob/main/docs/changelog.md)
- [Commits](https://github.com/square/leakcanary/compare/v2.11...v2.12)
---
updated-dependencies:
- dependency-name: com.squareup.leakcanary:leakcanary-android
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump org.jetbrains.kotlinx:kotlinx-coroutines-test from 1.7.1 to 1.7.2
Bumps [org.jetbrains.kotlinx:kotlinx-coroutines-test](https://github.com/Kotlin/kotlinx.coroutines) from 1.7.1 to 1.7.2.
- [Release notes](https://github.com/Kotlin/kotlinx.coroutines/releases)
- [Changelog](https://github.com/Kotlin/kotlinx.coroutines/blob/master/CHANGES.md)
- [Commits](https://github.com/Kotlin/kotlinx.coroutines/compare/1.7.1...1.7.2)
---
updated-dependencies:
- dependency-name: org.jetbrains.kotlinx:kotlinx-coroutines-test
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump com.github.triplet.play from 3.8.3 to 3.8.4
Bumps com.github.triplet.play from 3.8.3 to 3.8.4.
---
updated-dependencies:
- dependency-name: com.github.triplet.play
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump com.android.tools.build:gradle from 7.4.2 to 8.0.2 (#13912)
* Bump com.android.tools.build:gradle from 7.4.2 to 8.0.2
Bumps com.android.tools.build:gradle from 7.4.2 to 8.0.2.
---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): forward-port BuildConfig / aidl / default-component to gradle 8
* convert to non-transitive R.attr style
- directly address the attributes via their specific names
- remove an R-containing IntDef since R is no longer constant
(the whole UndoAction class will disappear with new backend anyway)
* Use attrs directly from `android`
Practically, it is a non-functional change, but is is best and more natural to use attrs directly from android instead of using `com.google.android.material` as a intermediate
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Hardy <github@mikehardy.net>
Co-authored-by: Brayan Oliveira <69634269+brayandso@users.noreply.github.com>
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brayan Oliveira <69634269+brayandso@users.noreply.github.com>
MANAGE_EXTERNAL_STORAGE is for non-Google Play builds.
Google won't let us have the permission, but there's no reason
other stores + users have to suffer this decision.
This allows a Google Play user to restore their data if they uninstall
(uninstall, then download the APK and data is available again)
* Remove MANAGE_EXTERNAL_STORAGE from the manifest if targeting `play`
Version Codes & Outcomes:
1 < Q - force storage permissions as done previously (incl. Play Store)
2 Q - Users are unsafe and need a storage migration
* MANAGE_EXTERNAL_STORAGE is unavailable
* READ/WRITE_EXTERNAL_STORAGE is unavailable
3 > Q - Non-Play-Store users need MANAGE_EXTERNAL_STORAGE (*)
4 > Q - Play Store users are unsafe and need a storage migration
If a user is starting out and may request 'safe' permissions (1) (3)
Then we keep `deckPath` as a legacy path.
1) & 3) We do not allow access to the app until they give permission
----
Storage can be re-enabled after this change via:
```
adb shell am compat disable DEFAULT_SCOPED_STORAGE com.ichi2.anki.debug
adb shell am compat disable FORCE_ENABLE_SCOPED_STORAGE com.ichi2.anki.debug
adb shell pm grant com.ichi2.anki.debug android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant com.ichi2.anki.debug android.permission.WRITE_EXTERNAL_STORAGE
```
on an API 30 emulator (or a non-AOSP emulator)
Related: Issue 5304
Fixes 13051 - targetSdkVersion 30 fixes this
* Bump org.jlleitschuh.gradle:ktlint-gradle from 11.1.0 to 11.2.0 (#13265)
* Bump org.jlleitschuh.gradle:ktlint-gradle from 11.1.0 to 11.2.0
Bumps org.jlleitschuh.gradle:ktlint-gradle from 11.1.0 to 11.2.0.
---
updated-dependencies:
- dependency-name: org.jlleitschuh.gradle:ktlint-gradle
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): move ktlint rules to .editorconfig
With new syntax
----
An individual property can be enabled or disabled with a rule property.
The name of the rule property consists of the ktlint_ prefix followed
by the rule set id followed by a _ and the rule id.
> https://pinterest.github.io/ktlint/faq/#why-is-editorconfig-property-disabled_rules-deprecated-and-how-do-i-resolve-this
----
disabled_rules is deprecated:
https://pinterest.github.io/ktlint/faq/#why-is-editorconfig-property-disabled_rules-deprecated-and-how-do-i-resolve-this
ktlint-gradle v11.2.0 resolves a few issues around this
> Fixed disabled_rules set only in editorconfig in ktlint 0.46+
> Fixed disabled_rules warning when using new editorconfig syntax in ktlint 0.48+
https://github.com/JLLeitschuh/ktlint-gradle/releases/tag/v11.2.0
* lint: fix new ktlint errors
Caused when we remove the version specifier in ktlint-gradle
* Argument should be on a separate line (unless all arguments can fit a single line)
* File annotations should be separated from file contents with a blank line
* Declarations and declarations with comments should have an empty space between.
* Multiple annotations should not be placed on the same line as the annotated construct
Removed unused `KotlinCleanup` class rather than fixing lint errors
* build(deps): depend on ktlint-gradle's ktlint
Some lint indentation was reduced due to this.
Fixed it manually as I didn't like the change
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Allison <62114487+david-allison@users.noreply.github.com>
* autoformat squash
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Allison <62114487+david-allison@users.noreply.github.com>
* Bump kotlin_version from 1.7.22 to 1.8.10 (#13196)
* Bump kotlin_version from 1.7.22 to 1.8.10
Bumps `kotlin_version` from 1.7.22 to 1.8.10.
Updates `org.jetbrains.kotlin:kotlin-gradle-plugin` from 1.7.22 to 1.8.10
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.8.10/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.22...v1.8.10)
Updates `org.jetbrains.kotlin:kotlin-stdlib` from 1.7.22 to 1.8.10
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.8.10/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.22...v1.8.10)
Updates `org.jetbrains.kotlin:kotlin-test` from 1.7.22 to 1.8.10
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.8.10/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.22...v1.8.10)
Updates `org.jetbrains.kotlin:kotlin-reflect` from 1.7.22 to 1.8.10
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.8.10/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.22...v1.8.10)
Updates `org.jetbrains.kotlin:kotlin-test-junit5` from 1.7.22 to 1.8.10
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.8.10/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.22...v1.8.10)
Updates `org.jetbrains.kotlin:kotlin-test-junit` from 1.7.22 to 1.8.10
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.8.10/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.22...v1.8.10)
---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
dependency-type: direct:production
update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-stdlib
dependency-type: direct:production
update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-test
dependency-type: direct:production
update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-reflect
dependency-type: direct:production
update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-test-junit5
dependency-type: direct:production
update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-test-junit
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* Enable OptIn(ExperimentalCoroutinesApi) for project
This will eliminate all warnings related to experimental coroutines api usages in the project, with the exception of
the "api" module which was ignored. The reason for this is that the module doesn't currently use coroutines so the library(
and the annotation) isn't available which results in a warning(and a crash as all warnings are fatal) when building.
See: https://youtrack.jetbrains.com/issue/KT-28777/Using-experimental-coroutines-api-causes-unresolved-dependency
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: lukstbit <52494258+lukstbit@users.noreply.github.com>
* Bump androidx.exifinterface:exifinterface from 1.3.5 to 1.3.6
Bumps androidx.exifinterface:exifinterface from 1.3.5 to 1.3.6.
---
updated-dependencies:
- dependency-name: androidx.exifinterface:exifinterface
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump androidx.browser:browser from 1.4.0 to 1.5.0
Bumps androidx.browser:browser from 1.4.0 to 1.5.0.
---
updated-dependencies:
- dependency-name: androidx.browser:browser
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump sqlite-framework from 2.2.0 to 2.3.0 (#13104)
Bumps sqlite-framework from 2.2.0 to 2.3.0.
---
updated-dependencies:
- dependency-name: androidx.sqlite:sqlite-framework
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* Update database related code to match the new release parameter types
Changes in this PR:
- DatabaseChangeDecorator: update of the methods signatures according to the library types changes, safe because we went from non nullable parameter types to more permisive nullable types
- DB: went from nullable query/bindArgs parameters to non null types. Reviewed all usages of the changed methods and verified that the changes are ok. One of the methods was changed
to remove the bindArgs param(which was set to null) because they weren't used and they were breaking the type system.
- Anki2Importer: remove the null bindArgs parameter as it wasn't used and it was breaking the type system.
- Finder: replaced bindArgs parameter value with an emptyArray() if it is null to conform to the new type system(I assumed that a null value represented no bindARgs parameters).
This SHOULD be ok but is difficult to say for sure as the code building the query is complex.
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: lukstbit <52494258+lukstbit@users.noreply.github.com>
* Bump androidx.appcompat:appcompat from 1.6.0-rc01 to 1.7.0-alpha02
Bumps androidx.appcompat:appcompat from 1.6.0-rc01 to 1.7.0-alpha02.
---
updated-dependencies:
- dependency-name: androidx.appcompat:appcompat
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* fix kotlin/java compile target harmony issues
```
* What went wrong:
Execution failed for task ':lint-rules:compileTestKotlin'.
'compileTestJava' task (current target is 11) and 'compileTestKotlin' task (current target is 18) jvm target compatibility should be set to the same Java version.
Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain
```
https://issuetracker.google.com/issues/260059413https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: lukstbit <52494258+lukstbit@users.noreply.github.com>
Since we're moving to scoped storage, uninstalling the app will very likely
delete user data.
In Debug/Dev, we want this to impact the dev's workflow as little as possible
So we change the applicationId. This relays the expectation that a 'stable'
anki should be using 'com.ichi2.anki' and an 'unstable/dev' AnkiDroid should be
'com.ichi2.anki.debug'. A developer should have two copies of the app, each with
their own storage location.
API:
As previously, define the API permissions/authority using the applicationId:
permission: 'com.ichi2.anki.debug.permission'
authority: 'com.ichi2.anki.debug.flashcards'
androidTest needs to access 'com.ichi2.anki.debug.flashcards' and have
'com.ichi2.anki.debug.permission'.
To resolve this, if the API is built in debug mode, the constants are modified:
(api/build.gradle)
* AUTHORITY = "com.ichi2.anki.debug.flashcards"
* READ_WRITE_PERMISSION = "com.ichi2.anki.debug.permission.READ_WRITE_DATABASE"
Implementation:
High level:
* Define variables in build.gradle
* Handle modifying them via parallel-package-name.sh
Low level:
* Use 'applicationIdSuffix' for this
* Modifies '<provider android:authorities>' in AndroidManifest.xml
* Required for installation on device
* Use 'applicationId'
* Modifies '<permission android:name' in AndroidManifest.xml
* Not required - cleanup on parallel-package-name.sh
* Modifies preferences_sync.xml
* via resValue in build.gradle
* Fixes crash
Source for both: https://developer.android.com/studio/build/build-variants#build-types
applicationIdSuffix:
https://developer.android.com/reference/tools/gradle-api/7.3/com/android/build/api/dsl/ApplicationVariantDimension#applicationIdSuffix()
@string/applicationId
* syntax ref: https://stackoverflow.com/questions/27954215/changing-resvalue-in-variant
manifestPlaceholders/${applicationId}
https://developer.android.com/studio/build/manage-manifests
Learning:
> By default, the build tools also provide your app's application ID in the ${applicationId} placeholder. The value always matches the final application ID for the current build, including changes by build variants. This is useful when you want to use a unique namespace for identifiers such as an intent action, even between your build variants.
https://developer.android.com/studio/build/manage-manifests
* Fix nullability for Note.getTags()
The returned property from this method is of type Array<String>, also the property is initialiazed with non null strings.
* Fix nullability for AddContentApi.addNote()
Changed the type of tags parameter from Set<String?>? to Set<String>? because:
- it doesn't make sense to have a null tag(what would that mean)
- the method addNotes() below uses a List<Set<String>?>? so either this method is incorrect or that one
- our current code would crash with a null tag string as Utils.joinTags() uses !! to reference the string tags when
doing its work
As a future todo maybe we can change parameter to a default one seeing that the database structure for notes specifies
this column as not null(use an empty String?).
* Fix nullability for AddContentApi.addNotes()
Changed the type of parameter fieldsList from List<Array<String>?> to List<Array<String>> because:
- it doesn't make sense to have null fields for a note(it is possible?)
- it would crash as with a null fields array, Utils.joinFields would return null and we would insert null in a
non null declared column flds
* Fix nullability for AddContentApi.updateNoteTags()
Changed the type of parameter tags from Set<String?>? to Set<String> because:
- same issue with null tag strings which doesn't make sense and it would crash our code in Utils.joinTags
- the tags parameter was made non null, this is an update call so using null(which would result in no tags update)
doesn't make sense
* Fix nullability for AddContentApi.updateNoteFields()
Made the parameter type non null because this is an update call and using null would do no update so the call would be
useless(why do it?).
* Fix nullability for AddContentApi.addNewBasicModel()
Made the name non null, can the model have a null name?
* Fix nullability for AddContentApi.addNewBasic2Model()
Made name non null(can the model have null as name?)
* Fix nullability for AddContentApi.addNewCustomModel()
Made name non null (can the model have null as name?)
Also silenced a silly IDE reported issue.
* Fix nullability for AddContentApi.addNewDeck()
Made the name parameter as non null, does it make sense to have adeck with null for name?!
* Fix nullability for AddContentApi.findDuplicateNotes()
Made the keys parameter as List<String> from List<String?>. What duplicates to find for a null key?
* Remove todo about nullability in AddContentApi
This cleanup includes:
- fixing ide lint issues
- adding extra @JvmField annotations to replicate the initial static fields in java, the targets were Uris and the
projection arrays(without the annotations these would have ended in the final bytecode as private static field + getter
method)
- enabled the explicit api mode as this is a library project and I think would be a good addition going forward. I made
the violations as warnings for now( to be able to suppress them for the other api classes) and fixed them for
FlashCardContract. When we finish cleaning up the api module we should move from warning to strict.
See https://kotlinlang.org/docs/whatsnew14.html#explicit-api-mode-for-library-authors
This included specifying the visibility modifiers and the actual properties types(nothing to note here as we have only
strings, not null Uris and not null arrays of not null strings)
- adding some @ Suppress annotations for naming(_ID) and properties not being used(but part of the default projection)
This PR also adds two return types in AddContentApi which I missed in the cleanup of that file.
This is required before enabling explicitApi() mode in the build file of the api module.
Also adds the @JvmStatic annotation for one of the methods to follow the original method signature.
The original todos pointed at using @JvmField but this is not applicable as there's no backing field to use.
Also the changes in this commit replicate the java api(visibility and appearance(they were functions)). See last commit
as java file in f39b7fa10f
We're no longer in Java, so only a few annotations are still necessary.
These are mostly test methods (`@Parameter/@Rule`),
This is a potentially flaky commit, hopefully the reduction in code causes a reduction in compile times
It did not modify the API project public classes
We're no longer in Java, so only a few annotations are still necessary.
These are mostly test methods (`@Parameters/@MethodSource`),
a few which are useful for mocks, and a small number which cause tests
to fail if they're removed for no reasonable reason
This is a potentially flaky commit, hopefully the reduction in
code causes a reduction in compile times
This was a mostly automated process, adding comments manually
if removing the annotation failed tests
It did not modify the API project public classes
com.ichi2.anki.api.AddContentApi
The conversion caused breaking changes WRT nullability of parameters
AND changing `fun` to `val`
This is NOT the final nullability which we desire, we perform the conversion
in a single commit to reduce the chance of bugs being introduced
Changes from a 'pure' conversion':
- addNotes:
- fieldsList: changed to List<Array<String>?>
- tagsList: changed to List<Set<String>?>?
- addNewCustomModel changed from auto conversion:
- fields: -> Array<String>
- cards -> Array<String>
- qfmt -> Array<String>
- afmt -> Array<String>
- splitFields(flds).length -> splitFields(flds).size
suppress lint for name shadowing:
- `var preferredName = preferredName`
add `!!`
- `val fname = File(returnUri!!.path).toString()`
- `val fname = File(returnUri!!.path!!).toString()`
remove `private`:
- `private get() = if (apiHostSpecVersion < 2) CompatV1() else CompatV2()`
- `get() = if (apiHostSpecVersion < 2) CompatV1() else CompatV2()`
remove imports:
- NoteInfo.Companion.buildFromCursor
- Utils.fieldChecksum
- Utils.joinFields
- Utils.joinTags
- Utils.splitFields
add imports: FlashCardsContract
- Card
- CardTemplate
- Deck
- Model
- Note
many spacing changes:
- sample: values.put(Note.TAGS, Utils.joinTags(tagsList[i]))
- moved back to a single line
Moved api docs from <pre> to ```
----
Converted with disabled git hooks + tested manually