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

17570 Commits

Author SHA1 Message Date
Brayan Oliveira
3f6d8a6b4b nf: make theme_black parent be theme_dark
so any common properties between the two of them don't have to be duplicated
2023-06-22 09:14:21 -05:00
Brayan Oliveira
e426fd9599 nf: remove com.ichi2.ui.SeekBarPreference
unused
2023-06-22 09:14:21 -05:00
AnkiDroid Translations
c1dcf40a2f Updated strings from Crowdin 2023-06-21 15:07:52 -05:00
Mike Hardy
f8788d30b4
Dependency updates 20230621 (#14009)
* 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>
2023-06-21 13:50:38 -05:00
Brayan Oliveira
b03a36b4f1 fix: StudyOptionsFragment not having storage permission 2023-06-21 13:27:31 -05:00
Arthur Milchior
d610446cbd NF: Correct typing of getBundleEditFields
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.
2023-06-21 13:26:37 -05:00
Brayan Oliveira
1a2ca3068b fix: gesture_display.xml simmetry 2023-06-21 13:24:00 -05:00
Brayan Oliveira
1c8a48f81d fix: gesture display in landscape mode
onMeasure override isn't necessary anymore because the display square ratio is now configured correctly in the layout
2023-06-21 13:24:00 -05:00
Brayan Oliveira
a5086e0bd4 Revert "orientation lock for gesture picker dialog"
This reverts commit 165c74ee6d.

It was supposed to partially fix #13432, but it didn't
2023-06-21 13:24:00 -05:00
Brayan Oliveira
33fbb16f80 remove FAB rotation and change duration 2023-06-21 13:19:28 -05:00
lukstbit
b3edad08bc Fix background image distort for DeckPicker
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.
2023-06-21 12:52:25 -05:00
lukstbit
b91bb02b43 Update androidx fragments library to 1.6.0
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.
2023-06-21 12:27:23 -05:00
AnkiDroid Translations
ff2646fa3a Updated strings from Crowdin 2023-06-18 12:34:50 +03:00
Arthur Milchior
1711e56c2b NF: move selectDeckFomExtra to onCollectionLoaded
This function uses the collection; so it would crash if collection was not
loaded.
2023-06-12 17:14:35 -03:00
Arthur Milchior
80d4922c3e NF: MetaDB should run on worker thread 2023-06-12 17:04:19 -03:00
AnkiDroid Translations
713abfb0ca Updated strings from Crowdin 2023-06-11 15:30:05 +03:00
Ashish Yadav
6ff78ddec0
checking for null result to avoid class cast exception (#13979)
* 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
2023-06-11 14:58:55 +03:00
Robozinho
4405493173
Migrate the FindEmptyCards task to coroutines (#13971)
* 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
2023-06-11 14:06:09 +03:00
Robozinho
de2537ffa0 Migrate CardBrowserOrderDialog 2023-06-11 13:34:27 +03:00
AnkiDroid Translations
23b01baf94 Updated strings from Crowdin 2023-06-11 13:04:13 +03:00
Mohd Raghib
2662e8b937
Update FAB UI for more intuitive double tapping (#12280)
* 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
2023-06-10 13:43:50 -03:00
Damien Elmes
4fae454803 Fix Windows failure 2023-06-10 17:01:40 +03:00
Damien Elmes
8f9982b6fb Refactor essential file migration; use CollectionManager
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.
2023-06-10 17:01:40 +03:00
Damien Elmes
af81b8002a Remove a couple of TODOs from CollectionManager
- 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.
2023-06-10 17:01:40 +03:00
Damien Elmes
b9f90f3416 Remove unused transformAlgo
Makes the code slightly simpler to follow.
2023-06-10 17:01:40 +03:00
Damien Elmes
0b248cda39 userMigrationIsInProgress -> mediaMigrationIsInProgress
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.
2023-06-10 17:01:40 +03:00
Damien Elmes
23ede08ab7 Increase logcat lines in crash reports
100 lines is barely enough for 2 stacktraces, and the extra context may
be helpful for diagnosing scoped storage issues.
2023-06-10 17:01:40 +03:00
Arthur Milchior
2d4ed29a13 NF: Makes non-null in CardQueue 2023-06-10 07:09:56 -03:00
Arthur Milchior
614b31434e NF: makes CardQueue non null 2023-06-10 07:09:56 -03:00
Ashish Yadav
83e697210c send exception report if exception in saveCollectionInBackground 2023-06-10 07:02:30 -03:00
Prince kushwaha
6534f726a7 Changed Material Dialog with Alert Dialog for ModelBrowserContextMenu.kt 2023-06-09 12:11:12 -03:00
Arthur Milchior
fcb4e251fe
NF: document that withCol and withQueue executes in IO (#13950)
* 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>
2023-06-09 10:41:50 -03:00
lukstbit
afcaf4520b
Migrate the ImportAdd task to coroutine (#12799)
* 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
2023-06-09 08:07:50 -03:00
Arthur Milchior
9aa7585ed6
Adding develepor options to add fake media (#13854)
* 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>
2023-06-08 11:28:09 -03:00
Brayan Oliveira
c84da56d09 Change preference category title color on the light theme
The dark shade it had wasn't very attractive

Contrast ratio of new text is over 4.5, i.e. good enough
2023-06-08 12:52:59 +03:00
Sanjaykumar Sargam
2604feba96 move cursor to end 2023-06-05 17:49:56 -03:00
Damien Elmes
043ded7876 Catch some attempts to access UI inside withCol, and col within UI thread
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
2023-06-04 07:00:16 -03:00
Damien Elmes
52a3ea9d33 Remove launchWithCol()
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.
2023-06-03 21:10:39 -03:00
lukstbit
d39436da73 Fix parent config not being applied on child decks in deck options 2023-06-02 15:41:47 -03:00
Ashish Yadav
4bf2084191 ellipsize the deck name if too lengthy 2023-05-31 19:15:54 -03:00
Sanjaykumar Sargam
ddce7e40de immediate dialog after selecting note type 2023-05-30 17:42:41 -03:00
AnkiDroid Translations
84c126381f Updated strings from Crowdin 2023-05-30 19:53:53 +03:00
Robozinho
56da7fae2c
NF: clean study options nulls (#13877)
* 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
2023-05-30 04:26:36 -03:00
Prince kushwaha
6c5c663917 Changed Material Dialog with Alert Dialog for ModelEditorContextMenu.kt 2023-05-26 12:52:52 -03:00
sargamgayatri0803@gmail.com
dcebd49032 IntegerDialog showing keyboard 2023-05-26 12:50:36 -03:00
Ashish Yadav
5dd9ebacdc using activity.package to fix the authority issue while exporting col 2023-05-25 23:40:38 +01:00
snowtimeglass
10812cea19 Use "Finish" as Timebox negative button label
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.
2023-05-24 10:50:14 -03:00
AnkiDroid Translations
c25579a645 Updated strings from Crowdin 2023-05-22 06:33:00 +03:00
Sanjaykumar Sargam
2076bcb698 Replaced Toast with Snackbar in AnkiDroidJSAPI.kt 2023-05-20 08:48:37 -03:00
David Allison
f27dc86645 hack: workaround .nomedia being mutated
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
2023-05-18 18:00:14 +03:00