* fix API < 24 build by using compatible jackson-databind version
this effectively reverts a dependabot PR that I approved, not realizing
I was breaking API<24
* build(deps): configure dependeabot to ignore jackson-databind for now
used stategy similar to that used for
org.apache.commons:commons-compress so we stay informed of new updates
but are not tempted to slide out of compatible range yet
* build(deps): bump org.jetbrains.kotlinx:kotlinx-coroutines-test from 1.6.4 to 1.7.1 (#13847)
* build(deps): bump org.jetbrains.kotlinx:kotlinx-coroutines-test
Bumps [org.jetbrains.kotlinx:kotlinx-coroutines-test](https://github.com/Kotlin/kotlinx.coroutines) from 1.6.4 to 1.7.1.
- [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.6.4...1.7.1)
---
updated-dependencies:
- dependency-name: org.jetbrains.kotlinx:kotlinx-coroutines-test
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* Fix deprecation for coroutines library version 1.7.1
The new version introduces an API change:
- runTest now takes a duration instead of Long(fixed with the extension Long.milliseconds)
- the previous parameter "dispatchTimeout" which handled the timeout for a coroutine inside runTest is now "timeout" which represents
the total amount of time allowed for runTest. Kept it as it is now, we might want to increase it if tests start to timeout.
---------
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 com.google.protobuf:protobuf-kotlin from 3.23.0 to 3.23.3
Bumps com.google.protobuf:protobuf-kotlin from 3.23.0 to 3.23.3.
---
updated-dependencies:
- dependency-name: com.google.protobuf:protobuf-kotlin
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump com.squareup.leakcanary:leakcanary-android
Bumps [com.squareup.leakcanary:leakcanary-android](https://github.com/square/leakcanary) from 2.10 to 2.11.
- [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.10...v2.11)
---
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>
* build(deps): bump org.robolectric:robolectric from 4.10.2 to 4.10.3
Bumps [org.robolectric:robolectric](https://github.com/robolectric/robolectric) from 4.10.2 to 4.10.3.
- [Release notes](https://github.com/robolectric/robolectric/releases)
- [Commits](https://github.com/robolectric/robolectric/compare/robolectric-4.10.2...robolectric-4.10.3)
---
updated-dependencies:
- dependency-name: org.robolectric:robolectric
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump commons-io:commons-io from 2.11.0 to 2.13.0
Bumps commons-io:commons-io from 2.11.0 to 2.13.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>
---------
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>
IntelliJ keeps removing `import java.util.*`. Which changes `ArrayList` from
java to kotlin and creates compilation error due to nullable string typing.
I'd wish this to be merged just so that I don't have to fight with IntelliJ.
Switched from setting the background as a background for the top view to using a dedicated ImageView with scaleType set to centerCrop.
This will scale the image's dimensions uniformly so they are at least or greater than the available width/height while centering the image.
This update required some manual changes as the old way of using the
"fragment-test" artifact with "debugImplementation" was deprecated
in favor of a new artifact for better separation of libraries and
dependencies.
* checking for null result to avoid class cast exception
* checking for null result to avoid class cast exception
* checking for null result to avoid class cast exception
* checking for null result to avoid class cast exception
* Inline the FindEmptyCards task
* rename remCards to removeCards
and change ids type to Iterable<Long>
* Migrate handleEmptyCards to coroutines
* Rename method to match python code
* animate FAB
* remove all instances of add note layout
* update animations for `create deck` and `get shared deck`
* fix FAB to show completely during Rise animation
Add `8dp` margin top to make the FAB show completely when it undergoes Rise Animation where we increase the size of FAB on pressed.
Also decreases the translation values for Create Deck and Get Shared Decks after removal of Add Note Layout
* pressing fab opens the add note
also removed unwanted closing of FAB upon choosing Add Note, Create Deck or GetShared Deck
* function for closing FAB when chosen `Create Deck` option
This new function is same to the already present closeFloatingActionMenu() function but the only difference is that this function does not scale the FAB due to which we don't see the scaling up/down animation on FAB which makes the FAB animation smooth.
Otherwise when we click `Create Deck` the FAB undergoes the scaling up/down animation in the background which does not looks nice.
* fixes abrupt closing of FAB upon choosing `Get Shared Decks`
* add label for add note
* add colors by accessing them from attributes
* hide `add` label when choosing create deck
* fix unit test crash
Remove instances of add_note_layout from DeckPickerFloatingActionMenuTest.kt because it has been removed as a layout from DeckPickerFloatingActionMenu.kt
* fix: FAB animation when opening side drawer
As we were using closeFloatingActionMenu in DeckPicker while overriding onCreateOptionsMenu we were doing the rise and shrink animation of FAB which looks weird.
To avoid that we use the new function `closeFloatingActionMenuCaseTwo` which doesn't do the rise and shrink animation
* refactor: remove extra function for closing FAB
* remove un-necessary else-if condition
* improve animation
Improved the movement of animation for FAB by changing animation values for translations and alphas. Also matching the duration of different layouts to make the animation more smoother.
* make add note drawable animation smooth
rotate the add note drawable icon by 180 (basically inverting the image to X-axis) and while rotating the icon in FAB just rotate it 180f instead of 360f which makes the rotation animation more smooth and clean
* fix: halogen shadow artifact inside FAB on plain themes
* fix: unit test crash
Fixed unit test crash and updated addNoteLabel to follow the lifecycle of FAB in DeckPickerFloatingActionMenu
* pressing on Add Label opens AddNote screen
* fix color of FAB on pressing Get Shared Deck label
Color of FAB was changing to blue on pressing Add Shared deck label which will now sync with the color of theme
* fix : failing instrumented test
* fix: lint error
Lint error "Declarations and declarations with comments should have an empty space between."
* fix: maintain FAB color and functionality if safe display mode in on
If we are using the app in Safe display mode then clicking the fab would change the icon to note icon but there won't be any change in the color of the button as in case of (when animation is enabled).
Secondly on pressing back button or choosing any options we make the icon to change back to (add icon) without any animations
* fix: prevents FAB from changing color if any of the system animation is disabled
* add comment for the function and remove unnecessary testing code
* fix: abrupt changes in FAB icon when selecting an option
By performing the essential migration inside the CollectionManager
queue, we ensure that it has exclusive access to the collection files
for the duration of the call. This should hold even for legacy code, as
CollectionHelper.getCol() blocks until the queue is free.
I found the current code somewhat hard to follow, due in large part to
its Java origins, so I've also tried to tidy it up a fair bit. I think one
of the main reasons scoped storage has stalled so long is that people were
a bit intimidated by the code (I was at least!), and I hope that by making
it a bit simpler, people will feel more comfortable jumping in and helping
to get it over the line.
Notable changes:
- The validation and copying steps were intermixed and spread through
multiple files, which made it hard to follow. The source/dest folders are
now determined/validated separately, and then the actual copying
is done in a CollectionManager method. The chain starts in deckpicker.kt:migrate(),
as before.
- The typealiases and newtypes have been removed, as I felt they made
the code harder to follow. The newtype also served to validate the folder
was a scoped storage folder, but that's now done in our validation routine.
Instead, the variable names have been renamed to be clearer, eg
destinationDirectory: ScopedAnkiDroidDirectory -> scopedDestinationDirectory: Directory
- -wal are now copied if found. Usually they would get
removed when the collection is closed, but if there is a stale -wal file,
SQLite won't clean it up until a write action is performed on the DB, so it's
safer to include it.
- The corruption check before and after migration has been removed. For one,
it was only checking some referential integrity issues, and not actually checking
if the SQLite DB was corrupt. We could change the code to fix this, but I don't
see the point - we're already confirming the bytes of the copied files exactly match
the bytes of the source files, so the extra checks seem superfluous. Doing a full
integrity check on large collections is also quite slow, and risks hanging the
UI if legacy code happens to try access the collection.
- Removed the CollectionHelper code that was opening another instance of the backend.
- Removed the LockedCollection machinery, as CollectionManager takes its place.
- Removed the RetriableException code, as it only existed to deal with concurrent
access that can not happen with CollectionManager.
Tentatively closes#13870. The first report looked like migration being
launched twice in parallel, and the second appears to have been caused by
StudyOptionsFragment refreshing the screen (perhaps in onResume),
which called withCol.
- I think suspendable blocks/locking is a bad idea. This was discussed
briefly on https://github.com/ankidroid/Anki-Android/pull/13886#issuecomment-1553554314,
and probably belongs in an issue for discussion instead of a todo comment.
- withQueue is private, so users only need to be concerned with maintaining
invariants when they're editing that file, and outside callers get a safe
interface.
The name did not reflect what it actually did. The check in
migrationEssentialFiles() has been removed, as it's already checked
in the deck picker earlier, and it cannot start unless the routine
completes successfully.
* NF: document that `withCol` and `withQueue` executes in IO
I had some doubt about which function moves to IO dispatcher, whether it was
launch method or withCol. I expect this documentation may save a minute to other
devs too.
* Update AnkiDroid/src/main/java/com/ichi2/anki/CollectionManager.kt
---------
Co-authored-by: Brayan Oliveira <69634269+BrayanDSO@users.noreply.github.com>
* Migrate the ImportAdd task to a coroutine
The visibility of the withProgressDialog method from CoroutineHelpers was changed in order to use it in the coroutine for
ImportAdd task as we need access to the progress dialog(which withProgress doesn't provide).
Showing the progress was done through a Channel which basically replaces the previous ProgressCallback class. Because
awaiting for values on a Channel suspends we need to listen for progress updates in a new coroutine.
* Add latest review requests
* Add a dev setting to add medias
* fix some issues with the "Create fake media" dev options
fixes:
1. the preferences should be persistent in order to have their values saved so `Create the files` can work
2. A toast is shown instead of a snackbar because it is more visible if a dialog is active
3. Use `numberOfFiles` instead of `numberOfFilePreference` in the dialog message
the rest of the changes are nitpicks
* Fix minor issues
Append _key to the new preferences key names to be similar to other
keys.
Fix number of files shown in the success toast.
---------
Co-authored-by: Brayan Oliveira <69634269+brayandso@users.noreply.github.com>
Co-authored-by: lukstbit <52494258+lukstbit@users.noreply.github.com>
If detected, shows an IDE lint.
- Catches calls to col.* inside AnkiActivity contexts.
- Catches calls to methods of classes derived from AnkiActivity, eg
```
withCol {
someDeckPickerMethod()
}
```
- UI classes that don't inherit from AnkiActivity are not caught unless
they are also annotated with @UiThread. Eg SetNotetypeListener in
NoteEditor references col, but is not caught without an extra annotation.
It might be best to wait until 2.16 is out (and any quick follow-up
releases to address the inevitable regressions) before we start addressing
these issues in bulk; for now the code might be better left as-is unless
it's to address a known bug someone has reported.
Related: #13944, #13942, #13936
Code inside a withCol() block should not modify the UI, as it runs on
a background thread. withCol() should fetch and/or mutate collection
data, and then UI operations/program state changes should be performed
outside the withCol block, so they're serialized on the main thread and
the risk of race conditions is minimized. Recently mentioned on
https://github.com/ankidroid/Anki-Android/pull/13886#issuecomment-1555407973
launchWithCol() makes it a bit too easy to accidentally run UI code in
the background thread, as it provides both an async context and a collection
at the same time, and the user will be tempted to do both fetch-from-col
and update-UI steps inside the block. Removing it means a few extra characters
at each call site, but I think it's a bit less error-prone.
* lateinit textDeckname
* lateinit deckInfoLayout
* lateinit textETA
* lateinit textCongrats
* lateinit buttonStart
* lateinit textDeckDescription
* lateinit more variables
* make col null safe
* make mFullNewCountThread call safer
* remove null early return
inflate() takes a nullable "root" argument so there is no reason to early return
the documentation says that the root argument is an "*******Optional******* view to be the parent of the generated hierarchy (if attachToRoot is true), or else simply an object that provides a set of LayoutParams values for root of the returned hierarchy (if attachToRoot is false.)"
so the view is inflated anyway if you give a null root (or container)
Asked by @Arthur-Milchior
The current label of the negative button of "Timebox reached" dialog is "Close",
but it misleads as if it merely closes the dialog.
(It actually finishes the review session and shows the deck picker screen.)
This commit will replace the label with "Finish",
which is used on the counterpart dialog in Anki Desktop.
The string is reused from Anki Desktop.
Incidentally, this commit will also add the title comment
to the section of Timebox in 02-string.xml, for organization.
During a storage migration, we had a case where `.nomedia` failed the
content equality checks.
We do not know why, could not reproduce this and could not see it in
any further crash reports.
To work around this case, log and ignore the failure.
We log to further understand the issue.
Fixes 13807