* refactor: invert 'if'
* refactor: extract logic to BackgroundImage
* fix: large bitmap crashes DeckPicker
An image < 10MB can decompress to >100MB, which crashes
Example was: 4 * 4921 * 6983 = 137453372 bytes
This call-stack did not include our code
```
java.lang.RuntimeException: Canvas: trying to draw too large(137453372bytes) bitmap.
at android.graphics.RecordingCanvas.throwIfCannotDraw(RecordingCanvas.java:280)
at android.graphics.BaseRecordingCanvas.drawBitmap(BaseRecordingCanvas.java:88)
at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:548)
at android.widget.ImageView.onDraw(ImageView.java:1436)
```
Fixes 15450
* crash fix for background image too large
The check internally is `> MAX_BITMAP_SIZE`
Issue 15450
We want to be able to map joystick/trigger inputs to commands
This only handles them as button presses, not yet allowing scrolling
1) Define a screen which listens for motion events and adds a visual
selector to the screen if these are detected
2) Define an Axis: the Android MotionEvent works on a historical basis
allowing us to specify an axis and obtain the historical values
of the MotionEvent
3) Define a threshold: some MotionEvents are unidirectional
(pedals/triggers), others are bidirectional X-Axis on a joystick
this can either be -1.0 or 1.0 (displayed as "[+]" or "[-]")
4) An AxisButtonBinding is defined as the tuple (Axis, Threshold)
5) Ensure the listener screen only allows selecting an Axis if
the threshold has been reached (to stop a user selecting [-] on
a pedal/trigger
6) Check for duplicates and save
7) Load + detect the events in the Reviewer, call a ViewerCommand
Fixes 14282
With the changes in this PR it will only be possible to import a single
package. Also fixed some minor IDE reported issues.
The progress during the import operation is handled by the backend UI.
Once the native progress dialog was removed we have to call
backend.setWantsAbort() on back button press. This required
implementing the newer predictive back navigation with callbacks that
are enabled/disabled AHEAD of the time of the actual BACK button press.
Notes:
- @KotlinCleanup("timeQuantity methods: single source line per return")
was deleted as there are no time related methods in the class anymore
- add a TODO for entsToTxt to remove the reference to HtmlCompat
- transform the KotlinCleanup for splitFields() into a todo, I'm not sure
what it was about
- remove all KotlinCleanups from getCustomFonts() as that method will
be removed when #14343 is fixed
- fixed all the IDE grammar issues by manually adding the words to one of
the dictionaries
Example: 'values-af'
* This removes them from the search/index
* This marks them in the IDE in a different color,
making it less likely a new user will modify them
* Files also now contain IDE errors
We go against JetBrains advice as we want these files in Gradle:
> Items you may want to exclude from sharing:
>
> .iml files and .idea/modules.xml file for the Gradle or Maven based
> projects since these files will be generated on import
https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems
Tested and languages are still switchable
I did test `Editor > File Types > Ignored files and folders`
This removes the files from the IDE completely
but I could not find a way to share this with other team members
We need a media sync before a storage migration.
If this has been disabled, it is the user's responsibility
to perform a sync before this migration occurs
There are currently two reasons:
Fetch media on Sync is set to:
* 'Only if unmetered' & connection is metered
* Never
Issue 5304
During a storage migration, we have some media in an old folder
and others in the collection media folder.
Instead of handling the possibility of 2 folders, we immediately
migrate requested files when requested by the reviewer/previewers
When an image/sound file is requested, and is:
* not found
* inside the collection
* available for migration
Add a new task to prioritise it in the storage migration
Much better UX than missing images
Image migration: needs to be performed in `shouldInterceptRequest`
as WebClient error handlers do not provide enough control to
recover from
Sound: performed in the error handler to avoid impacting the fast path
The migration performance hit is not noticeable in my testing
Issue 5304
We're losing a lot of time due to flaky tests in CI.
It's better to ignore these to improve velocity
Class caches values for speed
This is implemented as a Rule as we can't modify the JUnit4 runner
This PR enables the new backend for viewing and changing notetypes. With the new implementation:
- add new activity for new backend implementation, ManageNotetypes(the old activity ModelBrowser should be deleted)
- full support for coroutines(and with progress) with all backend calls
- improve UI for the notes types list by using CardView(ideally we would use the material cards but we don't
currently inherit from the material themes)
- fix some of the UX reported issues, like providing a uniform add action(by using the platform FloatingActionButton)
and stop using the hard to discover context menu in favor of in layout actions for each item
- enable some checks for the notes types names when renaming or adding new entries
- introduce some UI model classes to better isolate the backend from the UI code
- other changes to streamline the UI and avoid pitfalls of the previous code(like double dialogs, issues with backstack,
performance)
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
Fixes a `ConcurrentModificationException`: the wrong list was modified
* Create copy of list when filtering
* Optimize containsFilterString
* Add error catching
* Remove whitespace
* Add comment and better naming
* Rename usage of childrenCopy variable I forgot to rename
* Change to more efficient solution
* Remove unecessary comment
* Add unit tests for DeckFilter
* Remove unused imports
* Add copywrite
* Remove whitespace
* Format fixes
* Add last name to dictionary
* Flipped actual and expected in assert statement
* Removed try/catch block in publishResults()
* Remove unused import
* Added null check
* Revert "Optimize containsFilterString"
This reverts commit 5b617b03f6.
* Reverting to using !! operator on results
* Rename test method
* lint: note editor warnings
* Redundant SAM-constructor
* onActivityResult overrides deprecated member but not marked as deprecated itself.
* 'getCurrentMultimediaEditableNote' always returns non-null type
* Explicitly given type is redundant here
* Function "getFieldByIndex" is never used
* Function "previewNextClozeDeletion" is never used
* Class "Field" is never used
* Unnecessary non-null assertion (!!) on a non-null receiver
* lint: note editor 'infos'
* Boolean literal argument without a parameter name
* Cascade 'if' should be replaced with 'when'
* lint: note editor 'weak warnings' and 'typos'
* Use of setter method instead of property access syntax
* Replace negated 'isEmpty' with 'isNotEmpty'
* Should be replaced with Kotlin function
* Can be joined with assignment
* Local variable names should not contain underscores
* Size check can be replaced with 'isNotEmpty()'
* Size zero check can be replaced with 'isEmpty()'
* Replaceable with operator-assignment
We can't lock the database via file locking on macOS under Robolectric
So instead, we lock the database in code.
This is better than locking via `CollectionHelper` as it's not opt in
So, we use `Storage`, where the Collection is created
Throws `SQLiteDatabaseLockedException` if an attempt to access the DB
is made when the database is locked.
This adds 4 user dictionaries:
* anki.xml - Anki Desktop specific terminology: 'did'
* android.xml - Android and dependencies: 'miui.securitycenter'
* usernames.xml - Usernames in copyright declarations
* davidallison.xml - Anything else.
* Each user has their own dictionary to avoid merge conflicts
* But this is shared within the project
https://www.jetbrains.com/help/idea/spellchecking.htmlhttps://stackoverflow.com/a/36256338
Fixes 10713
code style itself was imported to Android Studio via Checkstyle plugin
using the file docs/code_conventions/eclipse/ankidroid.checkstyle.xml,
with the only alterations being to implement blank line rules from
/docs/code_conventions/AnkiDroid_code_conventions.html