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

215 Commits

Author SHA1 Message Date
andriusezerskis
c63e93a09f Remove wildcard from imports 2024-07-17 09:16:28 +00:00
Shruti Gitte
b2f24d95de fix: use android import for crash report dialog 2024-06-18 05:04:21 +00:00
Sumit Singh
5c89baba40 lint to avoid using android.app.AlertDialog 2024-06-05 15:04:40 +00:00
Robozinho
701b5582de remove chromeos release files 2024-06-01 16:48:01 -05:00
David Allison
95624d8760 refactor: Kotlin 2.0 prep
## Deprecations

* `@Deprecated`/ `@Suppress("OVERRIDE_DEPRECATION")`

====

This declaration overrides a deprecated member but is not marked as deprecated itself.
Please add the '@Deprecated' annotation or suppress the diagnostic.
See https://youtrack.jetbrains.com/issue/KT-47902 for details

## `LinkedList.first`

* `LinkedList.first` to `LinkedList.first()`

----

'val first' is deprecated. This declaration will be renamed in a future version of Kotlin.
Please consider using the 'first()' stdlib extension if the collection supports fast random access.

## `kotlinOptions`

* `kotlinOptions` -> `compilerOptions`

 'kotlinOptions(KotlinJvmOptionsDeprecated /* = KotlinJvmOptions */.() -> Unit): Unit' is deprecated.
 Please migrate to the compilerOptions DSL. More details are here: https://kotl.in/u1r8ln
2024-05-21 15:28:50 +00:00
David Allison
47f4d91e60 fix: 'iw' is a RTL language
Alias for Hebrew, Android needs both 'iw' and 'heb'

cause: 0f795cea36
2024-05-04 15:59:26 +00:00
Aditya
8a5a9ccd29 lint: Prefer Unicode ellipsis '…' over 3 dots
Fixes 16269
2024-04-28 00:35:43 +00:00
sunmoon
d28a21fb33
refactor: make functions in UIUtils class as top level (#16157)
* refactor: make convertDpToPixel as top level

* refactor: make getDayStart as top level

* refactor: make getDensityAdjustedValue as top level

* refactor: make showThemedToast as top level

* refactor: remove the useless UIUtils object

* doc: update docs related to UIUtils

* fix: error in unit test
2024-04-11 12:07:04 +01:00
AbdelrahmanEsam
bb0c4a85bf
Migrate version catalog (#15966)
* version catalog conflict
 solve

* implementing version catalog for stable versioning between modules

* implementing version catalog for stable versioning between modules

---------

Co-authored-by: abdelrahmanesam <abdelrahmanesam>
2024-03-27 00:53:28 +00:00
David Allison
482b49c47f chore: lint empty strings
This moves a vandalism check from a review to CI

Prompted by PR 15931
2024-03-19 21:42:24 +00:00
David Allison
bded66d073 fix: only run TranslationTypo on strings
It also ran on xiaomi-theme-overlay.xml
2024-03-19 21:42:24 +00:00
David Allison
399e1ebe92 lint: "JavaScript" capitalization
not "javascript" or "Javascript"

Fixes 15755
2024-03-13 16:16:54 +00:00
David Allison
6b98b13e28
Kotlin Cleanup: KDocs (#14852)
* Kotlin Cleanup: docs

* removed almost all occurrence of `{@}` in the code
* searched for `<pre>` and removed one more
* and a little extra cleanup on docs strings when I saw them

Learning:
* 4 spaces before a line removes KDoc `[]` links
* KDoc has no way to link to a specific method overload

* Kotlin Cleanup: docs

* Fixed `&lt;` -> `<`
* Fixed `&gt;` -> `>`
2023-11-30 21:01:01 -05:00
Matteo Macaluso
f5696914ad
Resolved weak warnings: converted objects into data objects (#14774)
* replaced toast with Snackbar in MultimediaEditField.kt

* resolved warnings: converted objects to data objects

* readded toast
2023-11-20 09:52:34 +02:00
lukstbit
c96827ece2
Migrate lint-rules build file to kotlin dsl (#14531)
* Rename lint-rules/build.gradle to lint-rules/build.gradle.kts
* Use kotlin dsl in lint-rules/build.gradle.kts

In order to use the version properties defined in the root build file
the rootProject's extra properties container must be used.
2023-10-12 09:24:06 +03:00
sharkbird
d0e16f7d56 Detect invalid capital letters 2023-09-30 18:54:49 -03:00
lukstbit
7003e0b4d1 Configure dependencies resolution in settings.gradle.kts
Ideally we  would use
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) to enforce
 the repositories declared in settings.gradle.kts but it currently
conflicts with a local maven repository declared in
robolectricDownloader.gradle.

The repositories lambda wasn't deleted from the AnkiDroid module as
the build failed in relation to "com.android.tools:desugar_jdk_libs"(
most likely and issue with the dependency itself) with the error:

Could not resolve all dependencies for configuration ':AnkiDroid:coreLibraryDesugaring'.
The project declares repositories, effectively ignoring the repositories you have declared in the settings.
You can figure out how project repositories are declared by configuring your build to fail on project repositories.
See https://docs.gradle.org/8.1.1/userguide/declaring_repositories.html#sub:fail_build_on_project_repositories for details.
Could not find com.android.tools:desugar_jdk_libs:2.0.3.
Searched in the following locations:
  - file:/home/*/.m2/repository/com/android/tools/desugar_jdk_libs/2.0.3/desugar_jdk_libs-2.0.3.pom
    If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
    project :AnkiDroid
2023-08-31 20:52:04 -05:00
lukstbit
6b65c45386 Use plugins block to declare the plugins used
See https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block
The plugins that are to be used in different modules are added in the
top level build file with apply "false"(doesn't make sense to apply
them on the root project). Then the project modules, from the plugins
already available on the classpath, actually apply the ones they need.

Ktlint plugin was applied directly to all subprojects(initially it
was added through allprojects {} but it doesn't make sense to add it
to the root project as it doesn't contain source code, so
subprojects{} was used instead).

The amazonappstorepublisher plugin also required some custom
configuration as we need the latest versions which are not available
in mavenCentral() but can be fetched from jitpack.io.
2023-08-31 20:52:04 -05:00
Damien Elmes
7a65160e0e
Drop legacy schema, and update to 2.1.66 backend (#14171)
* Update target API to 23

* Update to 2.1.66, and switch to new schema by default

+ Temporarily disable unused resource warnings

* Drop legacy syncing code

* Drop legacy import/export code

* Drop legacy tag handling

* Drop legacy config handling

* Drop legacy database check

* Stub out unused v1 scheduler code

Can't be fully removed, as we still need to be able to open a v1 collection
so the user can upgrade.

moveVersions test has been removed, as backend code is used for moving
outside of unit tests.

* Drop legacy deck handling

* Drop legacy search code

* Drop legacy notetype code

This breaks the card template editor, so I've temporarily disabled it
in the GUI. Getting it working again will require switching to the new
template rendering code in the new backend.

Also breaks an "empty cards" action in CardContentProvider,
as I was not sure what it was trying to accomplish.

* Drop legacy media code

This removes oakkitten's custom media checking code, as keeping it
would require keeping a bunch of the duplicated Kotlin logic. His comment
about cancellation is incorrect: the call can be cancelled with backend.
setWantsAbort() on a background thread. And since the app enforces filenames
are normalized when they're added anyway, I don't think avoiding automatic
normalization is worth the duplicated code.

* Drop legacy Collection/DB code

* Drop most references to defaultLegacySchema

* Remove legacy schema tests from CI

CI won't work yet, because backend version needs updating

* Fix import CSV call

* Remove some unused symbols from anki module

* Drop majority of old stats code

* Remove unused symbols from libanki

* Remove some broken Android tests, and fix one

checkIfStudyOptionsIsDisplayedOnTablet() is also consistently failing,
but was doing so before I started on these changes.

* Move config methods into col.config

* Simplify config API

- Use kotlinx.serialization so that arbitrary typed objects can be
(de)serialized
- There is a single generic get(), that always returns an optional
value, which will be null if the key is missing, is null, or is not the
correct type. There will always be collections that have invalid data,
so the calling code always needs to be prepared to substitute a reasonable
default in such cases.
- Expose the typed getBool() method from the backend.

* Remove unused legacy importer

* Drop jackson

* Models -> Notetypes

* Remove some more unused symbols

* Remove generic type aliases

* Rename Model -> Notetype

I had to leave ModelTest.kt's filename alone, as changing it to Notetype.kt
reorders the unit tests, and causes about 4 tests to start flaking.

* Get card template editor preview working again

* Enable undo on edits; fix test hang

* Use backend for bulk suspend/undo

By default, undoableOp() notifies all screens listening for opExecuted,
so the refreshing happens automatically, and the manual refresh code
at the end of the old routine is no longer required. It is possible to
bypass this when you want to manually update the UI, but this is probably
not worth attempting until the card browser is either switched over to
a recycler view, or reimplemented as a web component.

The LongArrays have been switched to simple lists, as Google's protobuf
code expects Iterable<Long>

* Use backend for marking/undo, and change deck/undo

* Migrate reviewer actions/undo to backend

* Migrate remainder of undo code to backend, apart from v2 undo

Couple of notes:

- The legacy v2 undo no longer returns the undone card, and instead
rebuilds the queue. In some circumstances (eg a learning card has become
due), this can result in a different card being shown after undoing.
This is not ideal, but v2 does not have long to live at this point.
- The reset/reposition tests were reusing the old card cache values,
which have to be reloaded after an operation.
- A test in AbstractSched had to be moved to ReviewerTest so it can have
access to an activity.
- UndoTest has been removed, as it mainly focused on removed code.

* GetCard() -> getNextCardAndRedraw()

* render_output -> renderOutput()

* Drop AsyncTask

Probably the hardest part of AnkiDroid's code base to follow; very
glad to see the end of it.

Closes #7108

* Make note addition undoable

* Make bulk tag update undoable

* Remove remaining explicit transaction handling

The backend automatically wraps backend actions in a transaction,
and removing the explicit calls will allow us to drop the redundant
mutex that rsdroid acquires.

* Remove remaining unused classes/methods/properties

* Remove FunctionalInterfaces

* Switch to backend answer comparison

* Remove unused locking code + legacy storage code

* Switch ContentProviderTest to new schema, and fix bug

* Remove legacy Deck Options settings

* fix: remove minSdkVersion < 23 code

* Use short time in snackbars

People complained about snackbars interrupting their reviews before

* fix: don't duplicate undo label

It were showing a message like `Undo Undo Add Note`

* Remove "Advanced statistics"

* Remove legacy_schema local property

* Leave zip validation up to the backend

The backend takes care of validating the zip file and ensuring files aren't
written outside of the media folder.

I've expanded the mime match to include the zip mime, on the assumption
that's what the mime type is being changed to on some devices. If that
proves to be insufficient, a much simpler approach would be to look
for 50 4B 03 04 at the start of the file to determine if it's a zip file
or not.

This leaves only Mani's add-on code using commons-compression, so you
could potentially switch to a simpler tgz-specific library in the future
if that is easier.

* Disable two flaky tests

They started to flaky reliably after the legacy deck options test
was removed.

* Improve logging of HTTP requests

* Remove ModelBrowser

Replaced by ManageNotetypes

* Remove legacy CardInfo

replaced by com.ichi2.anki.pages.CardInfo

* Change comments at AdvancedSettingsFragment

* test: check if prefs analytics list don't have extra elements

* ContextCompat.getColor -> getColor

that compat method is for implementations in API < 23

* Remove more unused files

* refactor: move SECONDS_PER_DAY to a separate util file

in order to be able to remove Stats.kt later

* refactor: remove Stats and OverviewStatsBuilder

* Access sched.card directly in tests

The helper was adding a 500ms sleep on every fetch, which slowed the
scheduler tests down considerably.

* Make v3 scheduler the default; drop support for v2

The v3 scheduler was originally released in 2021, and we've been waiting
for a stable AnkiDroid release to support it before we could switch users
over to it. Now that 2.16 is out, we can finally push v3 out across the
ecosystem.

While we could theoretically make v3 the default without removing v2,
here are the reasons why I think we're better off switching to v3 only:

- AnkiWeb's review interface will likely switch over to v3-only in the
coming weeks, and AnkiMobile will likely drop v2 around the same time
2.17 comes out.
- v2 and v3 differ in a few ways that makes maintaining the two separate
paths more complicated: things like the different undo paths, counts not
including the current card, and the way the v3 scheduler supports custom
scheduler js. 2.17 is a chance to clean up a lot of old cruft in the
code base, and the old scheduling code is part of that.
- v2 and v3 are compatible with each other, and don't require a full sync
to change, so it doesn't break syncing with old clients (though depending
on settings, due counts may differ, which needs explanation)

I had to disable a couple of tests for this that we'll probably want
to restore in some form:

- corruptVersion16CollectionShowsDatabaseError() needs an update, and
it may be time to rip out the old CollectionHelper colIsOpen(), getColSafe()
and so on, migrating code that uses it over to withCol() instead. The
'collection inaccessible' dialog also needs a rethink - perhaps the various
exceptions could be handled in launchCatchingTask instead.
- testUndoResetsCardCountsToCorrectValue() is failing because initLayout()
creates a gesture listener, which fails with an error about the looper
not being initialized. I am not sure what's going on there - one option
would be to move the test to androidTest.

* Drop v2 sched file; rename files

* Drop AbstractSched and legacy undo code/queue code

* Migrate BaseSched into Scheduler

* More unused symbol removal

* Remove DeckTreeNode

* Remove unused processChildren()

* Remove shouldDisplayCounts(), as counts always available

* Remove manual hashCode()/compareTo() implementations

* Drop AbstractDeckTreeNode

* Turn DeckNode into a wrapper for DeckTreeNode

* Drop TreeNode and simplify filtering

* Remove `New card position` global preference

Overridden by per-deck configuration

Closes #12319

* fix: remove chess.css from card_template_html

* Store current queue state in reviewer

Prerequisite for solving #12620

Also dropped answerButtons(), as it's always 4

* Use local HTTP server for serving flashcard content

Prerequisite for solving #12620

* Implement support for custom JS scheduling

Enables FSRS and closes #12620

* Remove more unused code

* Remove separate Deck(Config)V16 objects and more unused code

* Move some NotetypeJson methods into its file

* Finish tidying Decks.kt

* Drop redundant col property on Collection

* Remove some usages of CollectionGetter

* Rename col->getColUnsafe to encourage migration

* Remove Reviewer.sched

* Handle deck tree not initialized in empty collection

* refactor: move syncStatus() to Collection

to avoid direct calls to the backend

* fix: do not show error when updating the menu if there is no internet

Reproduction steps:
1. have the collection synced
2. disable the device internet connection
3. Restart the app

* Remove unused resources and re-enable lint

* Restore sync cancel strings

* Defer loading webpage until server has initialized

* Ignore translations without a base entry

https://github.com/ankidroid/Anki-Android/pull/14171#issuecomment-1660286342

* Remove the SortOrder deprecation

* Remove the apparently-unused Backup.kt

* Remove last remaining use of Collection's context field

* Stop passing Context to backend

The library loading is now AnkiDroid's responsibility, so the backend
does not require access to an Android context.

Also remove the unused context field from Collection.

* Use backend for rendering next time labels

* Use backend for rendering finished message

The custom study & unbury descriptions are slightly different, but
should suffice until AnkiDroid can start using the Svelte finished
screen.

* Run SchedulerTest without Robolectric

Halves the run time. To do this, I implemented a new JvmTest class
and copied some of the helpers in RobolectricTest into it.

* Remove unused Kotlin implementation of template parsing

* Move Util code dealing with resources out of libanki

* Migrate remaining libanki tests to raw JVM

+ Remove some commented-out tests

Total savings are a drop from about 3m40s to 2m40s, with the scheduler
test class dropping its runtime by about half.

* Lazy-initialize col in tests

* Restore 'experimental' string

* Add comments to update-localizations.py

* Restore AcraAnalyticsInteraction.kt

---------

Co-authored-by: Brayan Oliveira <69634269+brayandso@users.noreply.github.com>
2023-08-31 05:44:03 +08:00
Mike Hardy
d7082677bd
Dependency updates 20230826 (#14306)
* Bump kotlin_version from 1.8.22 to 1.9.0 (#14103)

* Bump kotlin_version from 1.8.22 to 1.9.0

Bumps `kotlin_version` from 1.8.22 to 1.9.0.

Updates `org.jetbrains.kotlin:kotlin-gradle-plugin` from 1.8.22 to 1.9.0
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.8.22...v1.9.0)

Updates `org.jetbrains.kotlin:kotlin-stdlib` from 1.8.22 to 1.9.0
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.8.22...v1.9.0)

Updates `org.jetbrains.kotlin:kotlin-test` from 1.8.22 to 1.9.0
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.8.22...v1.9.0)

Updates `org.jetbrains.kotlin:kotlin-reflect` from 1.8.22 to 1.9.0
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.8.22...v1.9.0)

Updates `org.jetbrains.kotlin:kotlin-test-junit5` from 1.8.22 to 1.9.0
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.8.22...v1.9.0)

Updates `org.jetbrains.kotlin:kotlin-test-junit` from 1.8.22 to 1.9.0
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.8.22...v1.9.0)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-stdlib
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-test
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-reflect
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-test-junit5
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-test-junit
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Use proper imports to fix lint issues when using kotlin 1.9.0

The java.util.* import was removed/replaced by specific calls to avoid
defaulting some calls(like Arrays.forEach) to java methods which will
only be available from API 24 and above.

The org.junit.Assert.* generic imports were replaced with imports from
kotlin.test.* as lint suggested.

---------

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 junit_version from 5.9.3 to 5.10.0

Bumps `junit_version` from 5.9.3 to 5.10.0.

Updates `org.junit.jupiter:junit-jupiter` from 5.9.3 to 5.10.0
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.9.3...r5.10.0)

Updates `org.junit.vintage:junit-vintage-engine` from 5.9.3 to 5.10.0
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.9.3...r5.10.0)

Updates `org.junit.jupiter:junit-jupiter-params` from 5.9.3 to 5.10.0
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.9.3...r5.10.0)

---
updated-dependencies:
- dependency-name: org.junit.jupiter:junit-jupiter
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.junit.vintage:junit-vintage-engine
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.junit.jupiter:junit-jupiter-params
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump org.jlleitschuh.gradle:ktlint-gradle from 11.4.2 to 11.5.1

Bumps org.jlleitschuh.gradle:ktlint-gradle from 11.4.2 to 11.5.1.

---
updated-dependencies:
- dependency-name: org.jlleitschuh.gradle:ktlint-gradle
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump com.google.protobuf:protobuf-kotlin

Bumps com.google.protobuf:protobuf-kotlin from 3.23.3 to 3.24.1.

---
updated-dependencies:
- dependency-name: com.google.protobuf:protobuf-kotlin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump org.jetbrains.kotlinx:kotlinx-coroutines-test from 1.7.2 to 1.7.3

Bumps [org.jetbrains.kotlinx:kotlinx-coroutines-test](https://github.com/Kotlin/kotlinx.coroutines) from 1.7.2 to 1.7.3.
- [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.7.2...1.7.3)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlinx:kotlinx-coroutines-test
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump lint_version from 31.0.2 to 31.1.0 (#14156)

* Bump lint_version from 31.0.2 to 31.1.0

Bumps `lint_version` from 31.0.2 to 31.1.0.

Updates `com.android.tools.lint:lint-api` from 31.0.2 to 31.1.0

Updates `com.android.tools.lint:lint` from 31.0.2 to 31.1.0

Updates `com.android.tools.lint:lint-tests` from 31.0.2 to 31.1.0

---
updated-dependencies:
- dependency-name: com.android.tools.lint:lint-api
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: com.android.tools.lint:lint
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: com.android.tools.lint:lint-tests
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix imports for TestFiles in lint modules

The class was migrated to kotlin and became an object.

---------

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>

* Update Gradle Wrapper from 8.1.1 to 8.3.

Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>

* build(deps): bump acra_version from 5.10.1 to 5.11.1

Bumps `acra_version` from 5.10.1 to 5.11.1.

Updates `ch.acra:acra-http` from 5.10.1 to 5.11.1
- [Release notes](https://github.com/ACRA/acra/releases)
- [Commits](https://github.com/ACRA/acra/compare/acra-5.10.1...acra-5.11.1)

Updates `ch.acra:acra-dialog` from 5.10.1 to 5.11.1
- [Release notes](https://github.com/ACRA/acra/releases)
- [Commits](https://github.com/ACRA/acra/compare/acra-5.10.1...acra-5.11.1)

Updates `ch.acra:acra-toast` from 5.10.1 to 5.11.1
- [Release notes](https://github.com/ACRA/acra/releases)
- [Commits](https://github.com/ACRA/acra/compare/acra-5.10.1...acra-5.11.1)

Updates `ch.acra:acra-limiter` from 5.10.1 to 5.11.1
- [Release notes](https://github.com/ACRA/acra/releases)
- [Commits](https://github.com/ACRA/acra/compare/acra-5.10.1...acra-5.11.1)

---
updated-dependencies:
- dependency-name: ch.acra:acra-http
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: ch.acra:acra-dialog
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: ch.acra:acra-toast
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: ch.acra:acra-limiter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump com.github.AppIntro:AppIntro from 6.2.0 to 6.3.1

Bumps [com.github.AppIntro:AppIntro](https://github.com/AppIntro/AppIntro) from 6.2.0 to 6.3.1.
- [Release notes](https://github.com/AppIntro/AppIntro/releases)
- [Changelog](https://github.com/AppIntro/AppIntro/blob/main/CHANGELOG.md)
- [Commits](https://github.com/AppIntro/AppIntro/compare/6.2.0...6.3.1)

---
updated-dependencies:
- dependency-name: com.github.AppIntro:AppIntro
  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>
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: lukstbit <52494258+lukstbit@users.noreply.github.com>
Co-authored-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2023-08-26 09:35:13 -05:00
Brayan Oliveira
91c173c3f8 Remove DuplicateTextInPreferencesXml lint
Preferences layout previews work well now in Android Studio, so the dev can easily check their changes.

This way, the lint can be removed in order to increase performance
2023-08-18 20:56:30 +01:00
Brayan Oliveira
f8fcf0a4b5 Remove kotlin migration related lint 2023-08-03 06:53:16 +03:00
lukstbit
f32b427aa2 Set kotlin related task in lint-rules module to use JVM 11 2023-03-13 17:02:42 -05:00
Mike Hardy
a06e727f60
Dependency Updates 20220219 (#13305)
* Bump org.jlleitschuh.gradle:ktlint-gradle from 11.1.0 to 11.2.0 (#13265)

* Bump org.jlleitschuh.gradle:ktlint-gradle from 11.1.0 to 11.2.0

Bumps org.jlleitschuh.gradle:ktlint-gradle from 11.1.0 to 11.2.0.

---
updated-dependencies:
- dependency-name: org.jlleitschuh.gradle:ktlint-gradle
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): move ktlint rules to .editorconfig

With new syntax

----

An individual property can be enabled or disabled with a rule property.
The name of the rule property consists of the ktlint_ prefix followed
by the rule set id followed by a _ and the rule id.

> https://pinterest.github.io/ktlint/faq/#why-is-editorconfig-property-disabled_rules-deprecated-and-how-do-i-resolve-this

----

disabled_rules is deprecated:

https://pinterest.github.io/ktlint/faq/#why-is-editorconfig-property-disabled_rules-deprecated-and-how-do-i-resolve-this

ktlint-gradle v11.2.0 resolves a few issues around this

> Fixed disabled_rules set only in editorconfig in ktlint 0.46+
> Fixed disabled_rules warning when using new editorconfig syntax in ktlint 0.48+

https://github.com/JLLeitschuh/ktlint-gradle/releases/tag/v11.2.0

* lint: fix new ktlint errors

Caused when we remove the version specifier in ktlint-gradle

* Argument should be on a separate line (unless all arguments can fit a single line)
* File annotations should be separated from file contents with a blank line
* Declarations and declarations with comments should have an empty space between.
* Multiple annotations should not be placed on the same line as the annotated construct

Removed unused `KotlinCleanup` class rather than fixing lint errors

* build(deps): depend on ktlint-gradle's ktlint

Some lint indentation was reduced due to this.
Fixed it manually as I didn't like the change

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Allison <62114487+david-allison@users.noreply.github.com>

* autoformat squash

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Allison <62114487+david-allison@users.noreply.github.com>
2023-02-19 12:15:26 -05:00
Mike Hardy
625e6c71cb
Dependency updates 20220216 (#13280)
* Bump kotlin_version from 1.7.22 to 1.8.10 (#13196)

* Bump kotlin_version from 1.7.22 to 1.8.10

Bumps `kotlin_version` from 1.7.22 to 1.8.10.

Updates `org.jetbrains.kotlin:kotlin-gradle-plugin` from 1.7.22 to 1.8.10
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.8.10/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.22...v1.8.10)

Updates `org.jetbrains.kotlin:kotlin-stdlib` from 1.7.22 to 1.8.10
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.8.10/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.22...v1.8.10)

Updates `org.jetbrains.kotlin:kotlin-test` from 1.7.22 to 1.8.10
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.8.10/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.22...v1.8.10)

Updates `org.jetbrains.kotlin:kotlin-reflect` from 1.7.22 to 1.8.10
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.8.10/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.22...v1.8.10)

Updates `org.jetbrains.kotlin:kotlin-test-junit5` from 1.7.22 to 1.8.10
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.8.10/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.22...v1.8.10)

Updates `org.jetbrains.kotlin:kotlin-test-junit` from 1.7.22 to 1.8.10
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.8.10/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.22...v1.8.10)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-gradle-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-stdlib
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-test
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-reflect
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-test-junit5
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: org.jetbrains.kotlin:kotlin-test-junit
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Enable OptIn(ExperimentalCoroutinesApi) for project

This will eliminate all warnings related to experimental coroutines api usages in the project, with the exception of
the "api" module which was ignored. The reason for this is that the module doesn't currently use coroutines so the library(
and the annotation) isn't available which results in a warning(and a crash as all warnings are fatal) when building.

See: https://youtrack.jetbrains.com/issue/KT-28777/Using-experimental-coroutines-api-causes-unresolved-dependency

---------

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 androidx.exifinterface:exifinterface from 1.3.5 to 1.3.6

Bumps androidx.exifinterface:exifinterface from 1.3.5 to 1.3.6.

---
updated-dependencies:
- dependency-name: androidx.exifinterface:exifinterface
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump androidx.browser:browser from 1.4.0 to 1.5.0

Bumps androidx.browser:browser from 1.4.0 to 1.5.0.

---
updated-dependencies:
- dependency-name: androidx.browser:browser
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump sqlite-framework from 2.2.0 to 2.3.0 (#13104)

Bumps sqlite-framework from 2.2.0 to 2.3.0.

---
updated-dependencies:
- dependency-name: androidx.sqlite:sqlite-framework
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update database related code to match the new release parameter types

Changes in this PR:
- DatabaseChangeDecorator: update of the methods signatures according to the library types changes, safe because we went from non nullable parameter types to more permisive nullable types
- DB: went from nullable query/bindArgs parameters to non null types. Reviewed all usages of the changed methods and verified that the changes are ok. One of the methods was changed
to remove the bindArgs param(which was set to null) because they weren't used and they were breaking the type system.
- Anki2Importer: remove the null bindArgs parameter as it wasn't used and it was breaking the type system.
- Finder: replaced bindArgs parameter value with an emptyArray() if it is null to conform to the new type system(I assumed that a null value represented no bindARgs parameters).
This SHOULD be ok but is difficult to say for sure as the code building the query is complex.

---------

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 androidx.appcompat:appcompat from 1.6.0-rc01 to 1.7.0-alpha02

Bumps androidx.appcompat:appcompat from 1.6.0-rc01 to 1.7.0-alpha02.

---
updated-dependencies:
- dependency-name: androidx.appcompat:appcompat
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix kotlin/java compile target harmony issues

```
 * What went wrong:
  Execution failed for task ':lint-rules:compileTestKotlin'.
 'compileTestJava' task (current target is 11) and 'compileTestKotlin' task (current target is 18) jvm target compatibility should be set to the same Java version.
  Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain
```

https://issuetracker.google.com/issues/260059413
https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support

---------

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-02-17 07:34:53 -05:00
Mike Hardy
34cef67279
Dependency updates 20230206 (#13208)
* Bump com.fasterxml.jackson.core:jackson-databind from 2.14.1 to 2.14.2

Bumps [com.fasterxml.jackson.core:jackson-databind](https://github.com/FasterXML/jackson) from 2.14.1 to 2.14.2.
- [Release notes](https://github.com/FasterXML/jackson/releases)
- [Commits](https://github.com/FasterXML/jackson/commits)

---
updated-dependencies:
- dependency-name: com.fasterxml.jackson.core:jackson-databind
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump org.jlleitschuh.gradle:ktlint-gradle from 11.0.0 to 11.1.0

Bumps org.jlleitschuh.gradle:ktlint-gradle from 11.0.0 to 11.1.0.

---
updated-dependencies:
- dependency-name: org.jlleitschuh.gradle:ktlint-gradle
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump lint_version from 30.3.1 to 30.4.1 (#13199)

* Bump lint_version from 30.3.1 to 30.4.1

Bumps `lint_version` from 30.3.1 to 30.4.1.

Updates `com.android.tools.lint:lint-api` from 30.3.1 to 30.4.1

Updates `com.android.tools.lint:lint` from 30.3.1 to 30.4.1

Updates `com.android.tools.lint:lint-tests` from 30.3.1 to 30.4.1

---
updated-dependencies:
- dependency-name: com.android.tools.lint:lint-api
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: com.android.tools.lint:lint
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: com.android.tools.lint:lint-tests
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Set kotlin jvm target to 11 for lint-rules module

---------

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>

---------

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-02-06 13:58:59 -05:00
oyeraghib
9eaa9347a7 update: unit test for DuplicateTextInPreferencesXmlTest.kt
Removed Java Strings and added Kotlin Multi-line strings. Also updated Test expected result.
2023-01-10 19:54:52 +02:00
Arthur Milchior
c7376f63b6 NF: remove custom json
it was only required to avoid checked exception. Thanks to Kotlin, it's not a
concern anymore!
2022-10-13 12:23:30 -05:00
curche
c8ea3766b0 Refactor LintUtils.isAnAllowedClass to not use var 2022-10-12 20:15:53 +03:00
Potatoboy9999
6d9e8c7290
Replace usages of String.format in with string templating (#12555)
* Replace usages of String.format in with string templating

* Remove forgotten test code
2022-10-03 00:58:59 +05:30
lukstbit
380715b69f Add copyright to the initial lint rules and the related classes 2022-09-15 14:19:17 +01:00
David Allison
512c86eb8a chore: remove redundant '@JvmField' annotations
We're no longer in Java, so only a few annotations are still necessary.

These are mostly test methods (`@Parameter/@Rule`),
This is a potentially flaky commit, hopefully the reduction in code causes a reduction in compile times

It did not modify the API project public classes
2022-09-09 13:16:30 -03:00
David Allison
3e07d87ff8 chore: remove redundant '@JvmStatic' annotations
We're no longer in Java, so only a few annotations are still necessary.

These are mostly test methods (`@Parameters/@MethodSource`),
a few which are useful for mocks, and a small number which cause tests
to fail if they're removed for no reasonable reason

This is a potentially flaky commit, hopefully the reduction in
code causes a reduction in compile times

This was a mostly automated process, adding comments manually
if removing the annotation failed tests

It did not modify the API project public classes
2022-09-06 08:21:31 -05:00
David Allison
8afed86adf chore: remove Java NonNull/Nullable references
* Remove `InconsistentAnnotationUsage` + Tests
* Remove unnecessary `@NonNull` and `@Nullable` annotations

No longer needed as everything is in Kotlin
2022-09-05 00:34:28 +02:00
David Allison
bf52f14176 chore: remove JavaFieldNamingPatternDetector
reason: No more Java in project

* (Java)NonPublicNonStaticJavaFieldDetector:
  - Lint: NonPublicNonStaticFieldName
* ConstantJavaFieldDetector:
  - Lint: ConstantFieldName
2022-09-05 00:34:28 +02:00
David Allison
b9b82c4cd1 chore: remove PreferIsEmptyOverSizeCheck
No more Java in project

PreferIsEmptyOverSizeCheck is now an IDE Lint
2022-09-05 00:34:28 +02:00
David Allison
8cfc39b850 lint: fix IDE Lint
Handle 'KotlinCleanup'
2022-08-19 07:19:09 -05:00
David Allison
0020421dbc deps: Remove 'java' from lint-rules
No Java files exist in lint-rules so we no longer need this
2022-08-19 07:19:09 -05:00
David Allison
ab84324548 refactor: Convert InconsistentAnnotationUsageTest to Kotlin
com.ichi2.anki.lint.rules.InconsistentAnnotationUsageTest
2022-08-18 21:52:12 -05:00
David Allison
2947fd91a5 refactor: Rename InconsistentAnnotationUsageTest.java to .kt
com.ichi2.anki.lint.rules.InconsistentAnnotationUsageTest
2022-08-18 21:52:12 -05:00
David Allison
2aebc86a51 refactor: Convert JavaConstantFieldDetectorTest to Kotlin
com.ichi2.anki.lint.rules.JavaConstantFieldDetectorTest
2022-08-18 21:50:42 -05:00
David Allison
98964081e0 refactor: Rename JavaConstantFieldDetectorTest.java to .kt
com.ichi2.anki.lint.rules.JavaConstantFieldDetectorTest
2022-08-18 21:50:42 -05:00
David Allison
57fefb71ec refactor: Convert JavaNonPublicNonStaticFieldDetectorTest to Kotlin
com.ichi2.anki.lint.rules.JavaNonPublicNonStaticFieldDetectorTest
2022-08-18 21:49:05 -05:00
David Allison
cae34cbfaa refactor: Rename JavaNonPublicNonStaticFieldDetectorTest.java to .kt
com.ichi2.anki.lint.rules.JavaNonPublicNonStaticFieldDetectorTest
2022-08-18 21:49:05 -05:00
David Allison
7eedb3fff3 refactor: Convert PreferIsEmptyOverSizeCheckTest to Kotlin
com.ichi2.anki.lint.rules.PreferIsEmptyOverSizeCheckTest
2022-08-18 21:47:29 -05:00
David Allison
d15f54d02b refactor: Rename PreferIsEmptyOverSizeCheckTest.java to .kt
com.ichi2.anki.lint.rules.PreferIsEmptyOverSizeCheckTest
2022-08-18 21:47:29 -05:00
David Allison
dce6f40ced refactor: Convert PrintStackTraceUsageTest to Kotlin
com.ichi2.anki.lint.rules.PrintStackTraceUsageTest
2022-08-18 21:46:23 -05:00
David Allison
b8f373eba7 refactor: Rename PrintStackTraceUsageTest.java to .kt
com.ichi2.anki.lint.rules.PrintStackTraceUsageTest
2022-08-18 21:46:23 -05:00
Arthur Milchior
599bcebfb0 NF: Conversion to nullable, then non null simplified 2022-08-18 20:14:12 -05:00
oakkitten
0cf4ff0b7b Streamline snackbar creation
This changes the way snackbars are created. Instead of calling a
function with many arguments, the new methods consistently only take
text, duration, and a builder block--whether it is called on an
activity or a view. I chose builder pattern instead of call chaining as
it makes sure that the snackbar is actually shown in the end.

Note that if showSnackbar is called on an Activity that does not have a
view with id root_layout--which does not allow proper placing and
interaction with snackbars--a runtime exception will be intentionally
thrown in a debug build. Release builds will show a toast with the
contents of the snackbar instead.

Some durations were changed, notably, Card browser's snackbar that allow
searching in all decks now stay until dismissed. This is something user
may want to do at any time later; and if the snackbar is in the way,
they can dismiss it by swiping.

In com.ichi2.anki.CoroutineHelpersKt.launchCatchingTask, a few unrelated
to this change TODO comments were added.
2022-08-18 13:36:36 -05:00