0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-19 19:42:17 +02:00
Commit Graph

56 Commits

Author SHA1 Message Date
Arthur Milchior
d71d315d4d NF: add Sargam to usernames
This way it won't be shown as typo by Intelli-J
2024-07-07 16:57:58 +00:00
David Allison
6c5e46ad21 docs: ensure BrowserColumns are documented 2024-06-15 23:45:16 +00:00
David Allison
80ee0919ae lint: fix typos - usernames
Search:
```
Copyright \(c\) \d\d2\d (?!(David|Brayan|Shridhar|Mike|Mark|Akshay|Norbert|Timothy|Ankitects|Andrew|Nicola|Nicolas|Mani|Ashish|Tushar|Kostas|mikunimaru|Oakkitten|Shai|Brian Da|Akshit|Divyansh|Arthur|Paul|Tim|Edu|Dorrin|Tarek|The|Square|Anish|Vaibhavi|Kael|lukstbit|krmanik|Nicolai|Mrudul))
```
2024-04-01 19:07:14 +00:00
Brayan Oliveira
a135ef1d84 fix: unencoded # in file paths
For "legacy reasons" (https://forums.ankiweb.net/t/ankiweb-and-ankidroid-do-not-display-images-containing-pound-hashtag-sharp-symbol/42444/5), anki accepts unencoded `#` in file paths, although that is an URL syntax breakage.
2024-03-22 16:23:33 +00:00
David Allison
ea8ceeace1
fix: crash if image dimensions are too large (#15452)
* 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
2024-02-08 10:43:45 -05:00
David Allison
6b3cb3c695
refactor: Browser current query text (#15077)
* refactor: extract search query expansion
* refactor: extract query change
* refactor: extract query removal
  makes tempSearchQuery immutable
* refactor: add canSaveSearchFlow
* refactor: inline mTempSearchQuery
* rename: tempSearchQuery -> searchQueryInput
* browser: handle searchQueryExpanded
  Moves the source of truth for expansion to the ViewModel
2024-01-03 14:24:35 -05:00
Ashish Yadav
e87226bc60 adding links to the readme 2023-12-31 09:36:50 +00:00
Ashish Yadav
f921d524f6 added README.md file for project dictionaries 2023-12-31 09:36:50 +00:00
David Allison
7d87b84f2a feat: Joystick event handling
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
2023-12-16 14:55:03 +00:00
lukstbit
f4ea73aeab Enable the backend UI screens for importing an anki package
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.
2023-11-21 18:03:43 -05:00
Brayan Oliveira
4df8df6b8c dev: add IDEA project icon 2023-11-13 17:42:51 -05:00
Mike Hardy
56dec7f8d3 Revert "chore: exclude non-'values' translation files"
This reverts commit 09a5302a44.

It caused an error after upgrade to Android Studio hedgehog, unable to
mix gradle and non-gradle modules
2023-10-30 17:41:34 +00:00
Brayan Oliveira
280ca2cbfe refactor: IDE-lint of SoundKt.kt 2023-10-20 07:56:06 -05:00
lukstbit
a50a884321 Fix IDE/KotlinCleanup in libanki.Utils
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
2023-09-15 07:40:35 -03:00
Vibhu Pandey
4e248f442d
Fix typo errors in card.js / add user spelling dictionary (#14305) 2023-08-26 10:33:13 -05:00
David Allison
09a5302a44 chore: exclude non-'values' translation files
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
2023-08-26 09:42:03 -05:00
Brayan Oliveira
8d52aedfba refactor: Simplify sendAnalyticsEvent 2023-07-26 09:37:29 -07:00
David Allison
4dab1b2f8e Dialog: 'media sync unavailable' before migration
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
2023-03-24 11:12:48 -05:00
David Allison
6400ac1423 refactor: add 'ImportColpkgListener'
Generifies and combines the callback for legacy & new colpkg imports

Removes the strict dependency on `DeckPicker`
2023-03-07 05:59:14 -03:00
David Allison
850d303e91 RobolectricTest: Kotlin Cleanup
Review feedback + IDE Lint
2023-02-28 18:03:42 -05:00
David Allison
3f251cf6dc Reviewer: migrate requested files immediately
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
2023-02-26 07:55:58 -05:00
David Allison
614ba490d1 @Flaky: block flaky tests from CI
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
2023-02-17 08:31:46 -05:00
lukstbit
7691371743 Implement new backend for note types
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)
2022-10-30 19:13:48 -05:00
Arthur Milchior
8c2080cf1f NF: introduce makeLinksClickable
Tested in #12650

Co-authored-by: oakkitten <oakkitten@users.noreply.github.com>
2022-10-30 17:35:37 -05:00
Arthur Milchior
ceed13a8ba NF: Cleanup AnkiDroidApp 2022-10-04 08:08:16 +03:00
David Allison
f352607143
NF: Kotlin Cleanup (#12218) 2022-09-02 11:27:28 -05:00
David Allison
e0f77d10b4 refactor: fix IDE Lint - Collection.kt 2022-09-02 11:17:10 -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
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
shaiguelman
54c8426f8c
Fix crash during deck filtering (#11880)
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
2022-07-21 12:36:37 +01:00
David Allison
d115336264
lint: Note Editor (#11632)
* 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
2022-06-16 13:41:05 +05:30
David Allison
a42802d7e1 refactor: Fix lint weak warnings
one remains: Format string '`studyoptions_congrats_undo`' is not a valid format string
so it should not be passed to `String.format`
2022-05-03 21:06:00 -05:00
David Allison
b6c6b8a19f chore: use recommended Kotlin code style settings
Android Studio Bumblebee | 2021.1.1 Patch 3

From an IDE message:

Update your Kotlin code style settings to the recommended ones?
2022-04-29 08:22:35 -05:00
David Allison
846cd470a5 Add RetryableException
Allows an operation to be retried
2022-04-17 13:18:08 -05:00
David Allison
67bb993785 feat: Lock database
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.
2022-04-14 13:43:17 -05:00
David Allison
1a453679e6 refactor: fix typos
And add non-typos to dictionaries
2022-04-13 10:42:47 -05:00
David Allison
5da9561a29 refactor: typos & related KotlinCleanup 2022-04-07 10:27:03 -05:00
David Allison
a2d2c162fb lint: Add user dictionaries to reduce typos
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.html
https://stackoverflow.com/a/36256338

Fixes 10713
2022-04-05 17:11:56 -05:00
dorrin-sot
f995c189b2 reverted codestyle xml file to normal and added license for dialog xml 2021-08-04 22:09:38 -05:00
dorrin-sot
4829abea8e moved the media check dialog's body to a seperate xml 2021-08-04 22:09:38 -05:00
David Allison
717417950c Project Formatting: default to 'm' prefix
https://github.com/ankidroid/Anki-Android/wiki/Code-style#non-public-non-static-field-names-should-start-with-m
2021-04-14 12:43:52 -05:00
Anadi Kashyap
f083e205a5 fixed some automatic changes made by android studio 2020-10-23 09:06:05 -05:00
Anadi Kashyap
7cbb33c7bb added logic to return exact match for a deck if it exists before a wildcard leads to a regex search in Finder.java 2020-10-23 09:06:05 -05:00
Mike Hardy
00dadedf84 Ingest kotlin-plugin changes w/plugin 1.40+ 2020-08-19 18:27:30 -05:00
Mike Hardy
4391361374 Commit auto-altered codestyle from Android Studio 3.5.x 2019-10-10 16:51:38 +13:00
Mike Hardy
525f4e40e9 Remove Objective-C style section (AndroidStudio 3.4.x change) 2019-04-28 09:20:38 -05:00
Mike Hardy
d7bf29784e Update codestyle, small addition auto-added by AndroidStudio 2018-06-17 11:12:44 +09:00
Mike Hardy
c4377db1e3 Allow Android Studio formatting settings in git as exception
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
2018-06-15 06:09:28 +09:00
Tim Rae
c4c6af20af Bumped version to
@branch-specific
2016-12-13 20:43:22 +09:00
ospalh
9c41a6b58d Use the project encoding UTF-8. It is already used in some files, and not just in comments. 2015-07-06 12:09:53 +02:00