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

16387 Commits

Author SHA1 Message Date
Pratyaksh Khurana
0677ddebcb
Added Anki Forum URL in Readme file in Join Us On section (#12247)
* add anki_forums logo to the folder
* add icon to README.md
2022-08-30 23:29:19 +05:30
Divyansh Kushwaha
8dad97f607 fix: suppressed stack trace when error in coroutine occurs. 2022-08-30 19:08:20 +03:00
Damien Elmes
ee04b0c940 Migrate SearchCards to coroutines
The preloading of the topmost cards has been moved into the browser,
since it's not useful for the JS API, but this makes the
searchCardsNumberOfResultCount() test harder to port. Since the
CardCache should be removed in the future, I don't think it's worth the
effort of getting the test working again.

Closes #12223
2022-08-30 16:23:03 +01:00
Damien Elmes
3e8cfa12d4 Strip out PartialSearch and search cancellation
PartialSearch offers no value anymore, as the entire SQL query is
calculated by the backend before the legacy Kotlin code gets access
to it.

Tweaks were required to the Finder tests, as previously the legacy
code path was being used even when testing with the new schema enabled.
2022-08-30 16:23:03 +01:00
Damien Elmes
c2bc175a78 Fix play icon not appearing in preview screen
Closes #12224
2022-08-30 16:23:03 +01:00
Damien Elmes
2d16c8d68f Use backend method to add/remove mark
Like #12179, this avoids the possibility of the scheduler being presented
with the wrong card.
2022-08-30 16:23:03 +01:00
Damien Elmes
b80a8865be Use backend method to update card flags
Fixes #12179
2022-08-30 16:23:03 +01:00
Damien Elmes
d1ef11c176 Partially convert answerCard() a coroutine; report errors
Easier to follow, and exceptions when calling sched.answerCard() are
now caught, so with issues like #12179 and #12155 will result in a
message being shown to the user instead of an app crash.

The two additional runTest calls take advantage of the unconfined
dispatcher introduced in a previous commit, ensuring the coroutine
completes in time. Without adding them, the two tests fail due to a
race condition.
2022-08-30 16:23:03 +01:00
Damien Elmes
b20d589cfc Get searchDecksIconVisibilityDeckCreationTest working again
When I previously tried to fix this, I ran into the hanging issues.
2022-08-30 16:23:03 +01:00
Damien Elmes
e5a0ed2593 Use runTest() with an unconfined dispatcher instead of awaitJob()
This appears to allow us to avoid explicitly waiting for coroutines in
the common case. See the comment in RobolectricTest for why this and
not StandardTestDispatcher was used.

Also opted in to the coroutines API at the module level, so we don't
have to tag every unit test with @OptIn.
2022-08-30 16:23:03 +01:00
Damien Elmes
65b5aa6d38 Avoid runBlocking() calls in CollectionManager under Robolectric
The recommended way to test coroutines in Kotlin is to wrap tests in
runTest(). Unfortunately, doing so was tending to trigger deadlocks.

It appears to be caused by calls to runBlocking() inside runTest().
These happen fairly frequently, as legacy code fetching the collection
from CollectionHelper end up invoking a runBlocking() call inside
CollectionManager.

To work around this, I've made CollectionManager bypass the runBlocking
call, and access the collection directly.

This change caused the verifyStartupNoCollection() test to start failing,
presumably due to a change in timing. It was calling colIsOpen() and
being told the collection was open, because enableNullCollection() was
closing the collection but not preventing it from being implicitly
reopened.
2022-08-30 16:23:03 +01:00
Arthur Milchior
823555c5f2 NF: simplify UpdateNote
I saw this issue while reviewing #12199. I believe that simplifying code before
moving it will help review the move
2022-08-30 13:20:15 +03:00
Kendall Park
e687746093 fix: replace cloze with blank within <tts> tag
resolves ankidroid/Anki-Android#12233
2022-08-29 19:02:19 -05:00
David Allison
1107d61e97 ci: stop codecov from failing CI
Our code coverage fluctuates, meaning that CI is often shown as failed
even on no-op operations

This is bad for our developer experience: we can't trust CI status to
be reporting correctly, and this slows fixing actual issues

So, we mark codecov as 'informational' so only 'real' CI failures are
shown to users

> If `true` is specified the resulting status will pass no matter what
> the coverage is or what other settings are specified. Informational
> mode is great to use if you want to expose codecov information to
> other developers in your pull request without necessarily gating PRs
> on that information.

https://docs.codecov.com/docs/commit-status#informational

Related issue: 12227 - fixing the flakiness in other ways
2022-08-29 09:22:33 -05:00
shivam-2701
a716c15fa1
Removed "paste as plain text" (#11753)
* test-commit

* Paste as plain

* Paste as plain fixed

* Update AnkiDroid/src/main/java/com/ichi2/anki/NoteEditor.kt

* Update AnkiDroid/src/main/java/com/ichi2/anki/NoteEditor.kt

* Update AnkiDroid/src/main/java/com/ichi2/anki/NoteEditor.kt

Co-authored-by: Mike Hardy <github@mikehardy.net>
2022-08-29 00:44:30 +01:00
Shubham kumar yadav
0fb16b89cd
fixed: deck search not scrolling to current deck in statistics (#12030)
* fixed: deck search not scrolling to current deck in statistics
2022-08-29 00:42:56 +01:00
David Allison
8721e8ac30 fix: improve list of excludes for Kotlin jacoco
Copy/pasted from https://medium.com/jamf-engineering/android-kotlin-code-coverage-with-jacoco-sonar-and-gradle-plugin-6-x-3933ed503a6e
2022-08-28 13:52:44 -05:00
David Allison
e3ce2d7b34 feat: Include Kotlin files in code coverage
Instructions from:
https://medium.com/jamf-engineering/android-kotlin-code-coverage-with-jacoco-sonar-and-gradle-plugin-6-x-3933ed503a6e

Fixes 9432
2022-08-28 13:52:44 -05:00
David Allison
edd488845d refactor: Convert JSONArray to Kotlin
com.ichi2.utils.JSONArray

Note: Switched Java array for Kotlin Array

Removed a number of tests for 'null' handling
2022-08-28 14:45:56 +03:00
David Allison
0be1f1519e refactor: Rename JSONArray.java to .kt
com.ichi2.utils.JSONArray
2022-08-28 14:45:56 +03:00
Mani
902574cc47
Add strings label when i18n files changes (#12186)
* add string label when res/values dir changes

* add comments, check only i18n files change

* update messages
2022-08-28 10:06:55 +01:00
David Allison
9797b7b29d refactor: Convert CollectionGetter to Kotlin
com.ichi2.libanki.CollectionGetter
2022-08-27 10:54:21 -05:00
David Allison
17c496830b refactor: Rename CollectionGetter.java to .kt
com.ichi2.libanki.CollectionGetter
2022-08-27 10:54:21 -05:00
David Allison
0a24e31898
nf: Kotlin Cleanup (#12193)
* refactor: Kotlin Cleanup - ACRATest

* refactor: Kotlin Cleanup - DeckPickerImportTest

* refactor: Kotlin Cleanup - AnkiAssert

* refactor: Kotlin Cleanup - AnkiActivityUtils
2022-08-27 10:40:19 -05:00
David Allison
2e788e62e2
NF: Kotlin Cleanup (#12192)
* refactor: Kotlin Cleanup: CardTemplateEditor

* lint: fix typo 'lukstbit'

* refactor: Kotlin Cleanup: CardTemplateEditor
2022-08-27 10:16:31 -05:00
Arthur Milchior
6a9ba07965
JSONObject nullability cleanup (#11913)
* NF: JSONTokener takes non null string

The original implementation state that a null value would lead to NPO at first
function call.

* NF: JSONObject's copyFrom constructor take non null key

That's a requirement from parent's implementation

* NF: ensure JSONObject's constructor takes a non null tokenizer

It was already enforced with !!

* NF: remove checkName

As indicated, it was always called on nonNull so identity

* NF: numberToString non null

* NF: deepClonedInto: make clone non null
2022-08-27 09:33:53 -05:00
Arthur Milchior
012f118c03 NF: simplify catchingLifecycleScope
My understanding is that this method will often be called either on fragments,
and using the fragment's activity. So it seems to make sense to simplify it,
ensuring that we avoid a parameter that will probably never change.

Actually, since activities are also LifecycleOwner, it may be possible to ensure
this method is even simpler, by defining it on activities instead of defining it
on LifecycleOwner. Unless we have a reason to use an activity distinct from the
LifecycleOwner.

Also cleaning from function I viewed at the same time
2022-08-27 09:23:25 -05:00
David Allison
2cadb48133 refactor: Convert Media to Kotlin
com.ichi2.libanki.Media

This adds functionality to allow nulls to be passed to DB's methods
2022-08-27 09:15:42 -05:00
David Allison
1dfde93ccc refactor: Rename Media.java to .kt
com.ichi2.libanki.Media
2022-08-27 09:15:42 -05:00
David Allison
d980933392 refactor: add MaterialDialog.iconAttr
Shortens repetitive code

Also removed a few unused parameters (required for compilation)

Fixes 11781
2022-08-27 08:05:17 -05:00
Divyansh Kushwaha
0a6c49f7b5 Deleted unused CollectionTask.AddNote
Last usage of this class has been removed in #11952. So it is being used no more.
2022-08-27 15:05:21 +03:00
Mike Hardy
233b88fe6f Bumped version to 2.16alpha82 2022-08-27 05:59:53 +00:00
David Allison
089eeef1f4 refactor: Convert Model to Kotlin
com.ichi2.libanki.Model
2022-08-27 00:29:02 -05:00
David Allison
f2e21130c5 refactor: Rename Model.java to .kt
com.ichi2.libanki.Model
2022-08-27 00:29:02 -05:00
David Allison
850e0fb2c1 refactor: Convert Decks to Kotlin
com.ichi2.libanki.Decks
2022-08-27 00:27:19 -05:00
David Allison
ef3fe1546a refactor: Rename Decks.java to .kt
com.ichi2.libanki.Decks
2022-08-27 00:27:19 -05:00
AnkiDroid Translations
2ab26312a4 Updated strings from Crowdin 2022-08-27 00:22:58 -05:00
David Allison
529bc11db7 feat: implement App Introduction System
* Displays the App Introduction System
* Handles only displaying it once
* Handles syncing if the app intro loads an existing AnkiWeb account
* (special case) Handles an upgrade from 2.15 -> 2.16 where
  the preference for the app intro was unset.
2022-08-26 23:39:35 -05:00
David Allison
b3a138035b feat: App Introduction System
A screen which appears on the first run of the application

Displaying:
* Get Started
* Sync from AnkiWeb

This aims to handle the use case of an existing user.
If they do not sync immediately, then they risk creating
two collections, which are incompatible and cause a sync conflict

Based on 9130 by Shridhar Goel
2022-08-26 23:39:35 -05:00
David Allison
fbe16e5df4 refactor: extract method 'wasFreshInstall'
Will be useful to call from 'DeckPicker'
2022-08-26 23:39:35 -05:00
David Allison
36a992cde0 design: backgrounds for 'introduction' activity
The Introduction activity is the first activity that users see
and therefore should be nicely designed.

* intro_gradient.xml
Contains a background gradient for the top of the introduction:
a blue to white/black gradient

* intro_ankidroid_logo:
Contains the AnkiDroid logo, encircled in a semi-transparent colour

* Due to bugs with `<aapt:attr>` in ankidroid_logo, in v21-23 this is
just the AnkiDroid logo with no transparent circle

Designed to go on top of intro_gradient
2022-08-26 23:39:35 -05:00
David Allison
c138dd5b7a feat: Activity to Login + Sync from AnkiWeb
We do not want to encourage a new AnkiDroid user to create an account

So this only allows a login, not a 'create account'
2022-08-26 23:39:35 -05:00
Brayan Oliveira
9f050a6041 Add option to enable the v3 sched 2022-08-26 23:38:09 -05:00
Brayan Oliveira
78f434e304 Add v3Enabled property to Collection
And override it on CollectionV16.kt
2022-08-26 23:38:09 -05:00
Brayan Oliveira
f67bb496cd Add "Allow sync on metered connections" preference
If disabled, auto-sync isn't triggered on metered connections and the user is asked if they want to continue if they trigger a manual sync

If enabled, sync occurs normally
2022-08-26 23:37:32 -05:00
Brayan Oliveira
100781df2f NF: make DeckPicker.automaticSync() more readable 2022-08-26 23:37:32 -05:00
Brayan Oliveira
e15e8191d4 Create an Advanced category under "Sync" preferences
for better organization
2022-08-26 23:37:32 -05:00
Brayan Oliveira
5d2c141ff8 NF: refactor isActiveNetworkMetered() 2022-08-26 23:37:32 -05:00
Brayan Oliveira
123cf288cf Extract isActiveNetworkMetered() 2022-08-26 23:37:32 -05:00
Brayan Oliveira
7bffd55f23 NF: remove more files from the legacy CSV importer implementation
which aren't used/useful anymore
2022-08-26 23:36:38 -05:00