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

188 Commits

Author SHA1 Message Date
David Allison
b4c5baf3f0 build: update targetSdkVersion to 31 2023-04-21 17:22:28 +03:00
David Allison
56a195bf46 Bump to API 30 & enable MANAGE_EXTERNAL_STORAGE
MANAGE_EXTERNAL_STORAGE is for non-Google Play builds.

Google won't let us have the permission, but there's no reason
other stores + users have to suffer this decision.

This allows a Google Play user to restore their data if they uninstall
(uninstall, then download the APK and data is available again)

* Remove MANAGE_EXTERNAL_STORAGE from the manifest if targeting `play`

Version Codes & Outcomes:

1 < Q - force storage permissions as done previously (incl. Play Store)
2   Q - Users are unsafe and need a storage migration
        * MANAGE_EXTERNAL_STORAGE is unavailable
        * READ/WRITE_EXTERNAL_STORAGE is unavailable
3 > Q - Non-Play-Store users need MANAGE_EXTERNAL_STORAGE (*)
4 > Q - Play Store users are unsafe and need a storage migration

If a user is starting out and may request 'safe' permissions (1) (3)
Then we keep `deckPath` as a legacy path.

1) & 3) We do not allow access to the app until they give permission

----

Storage can be re-enabled after this change via:

```
adb shell am compat disable DEFAULT_SCOPED_STORAGE com.ichi2.anki.debug
adb shell am compat disable FORCE_ENABLE_SCOPED_STORAGE com.ichi2.anki.debug
adb shell pm grant com.ichi2.anki.debug android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant com.ichi2.anki.debug android.permission.WRITE_EXTERNAL_STORAGE
```

on an API 30 emulator (or a non-AOSP emulator)

Related: Issue 5304
Fixes 13051 - targetSdkVersion 30 fixes this
2023-03-20 12:44:59 -05:00
Mike Hardy
6444f97dae
Dependency updates 20220228 (#13364)
* Bump com.github.triplet.play from 3.7.0 to 3.8.1

Bumps com.github.triplet.play from 3.7.0 to 3.8.1.

---
updated-dependencies:
- dependency-name: com.github.triplet.play
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* Bump org.jsoup:jsoup from 1.15.3 to 1.15.4

Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.15.3 to 1.15.4.
- [Release notes](https://github.com/jhy/jsoup/releases)
- [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES)
- [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.15.3...jsoup-1.15.4)

---
updated-dependencies:
- dependency-name: org.jsoup:jsoup
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* Bump androidx.annotation:annotation from 1.5.0 to 1.6.0

Bumps androidx.annotation:annotation from 1.5.0 to 1.6.0.

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

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

* Bump lint_version from 30.4.1 to 30.4.2

Bumps `lint_version` from 30.4.1 to 30.4.2.

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

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

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

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

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

* Bump com.android.tools.build:gradle from 7.4.1 to 7.4.2

Bumps com.android.tools.build:gradle from 7.4.1 to 7.4.2.

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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>
2023-02-28 09:25:18 -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
David Allison
60a823d9c2 AGP: Move package from Android manifest to build files
AGP 7.4.1

Automated step by Android Gradle Plugin

Declaration of a project's namespace using the package attribute of
the Android manifest is deprecated in favour of a namespace declaration
 in build files.

https://developer.android.com/studio/past-releases/past-agp-releases/agp-7-3-0-release-notes#package-deprecated
2023-02-16 10:37:06 -05:00
David Allison
ff72a861be ci: debug identifier -> 'com.ichi2.anki.debug'
Since we're moving to scoped storage, uninstalling the app will very likely
delete user data.

In Debug/Dev, we want this to impact the dev's workflow as little as possible
So we change the applicationId. This relays the expectation that a 'stable'
anki should be using 'com.ichi2.anki' and an 'unstable/dev' AnkiDroid should be
'com.ichi2.anki.debug'. A developer should have two copies of the app, each with
their own storage location.

API:

As previously, define the API permissions/authority using the applicationId:
permission: 'com.ichi2.anki.debug.permission'
authority: 'com.ichi2.anki.debug.flashcards'

androidTest needs to access 'com.ichi2.anki.debug.flashcards' and have
'com.ichi2.anki.debug.permission'.

To resolve this, if the API is built in debug mode, the constants are modified:

(api/build.gradle)
* AUTHORITY = "com.ichi2.anki.debug.flashcards"
* READ_WRITE_PERMISSION = "com.ichi2.anki.debug.permission.READ_WRITE_DATABASE"

Implementation:

High level:
* Define variables in build.gradle
* Handle modifying them via parallel-package-name.sh

Low level:
* Use 'applicationIdSuffix' for this

* Modifies '<provider android:authorities>' in AndroidManifest.xml
  * Required for installation on device
  * Use 'applicationId'
* Modifies '<permission android:name' in AndroidManifest.xml
  * Not required - cleanup on parallel-package-name.sh
* Modifies preferences_sync.xml
  * via resValue in build.gradle
  * Fixes crash

Source for both: https://developer.android.com/studio/build/build-variants#build-types

applicationIdSuffix:
https://developer.android.com/reference/tools/gradle-api/7.3/com/android/build/api/dsl/ApplicationVariantDimension#applicationIdSuffix()

@string/applicationId
* syntax ref: https://stackoverflow.com/questions/27954215/changing-resvalue-in-variant

manifestPlaceholders/${applicationId}
https://developer.android.com/studio/build/manage-manifests

Learning:
> By default, the build tools also provide your app's application ID in the ${applicationId} placeholder. The value always matches the final application ID for the current build, including changes by build variants. This is useful when you want to use a unique namespace for identifiers such as an intent action, even between your build variants.

https://developer.android.com/studio/build/manage-manifests
2023-01-14 12:15:12 +02:00
David Allison
7471cd084a chore(api): extract constants to build.gradle
These values will be changed when enabling API tests for 'com.ichi2.anki.debug'
2023-01-14 12:15:12 +02:00
Aditya kumar
105134d957
TextUtils.join and .isEmpty changed to kotlin methods (#13039)
* TextUtils.join and .isEmpty changed to kotlin methods

* Card Browser Changes Reverted

* TextUtils Review

* Update LangaugeUtils

* Reviewed Finder file

* Readme review

* TemplateFilters revert

* isEmpty() to isNotEmpty()

Co-authored-by: AdityaKumar <adi54321kumar@outlook.com>
2023-01-06 20:05:36 -03:00
criticalAY
21886e1a9a TODO updated for contract 2022-12-13 07:41:12 +02:00
Sanjaykumar Sargam
c2ad8ac703
Used """ instead of " to avoid \" (#12839) 2022-11-18 09:06:07 -05:00
Mike Hardy
e3ebea137c refactor(deps): extract robolectric version 2022-11-15 16:38:00 -05:00
Ashish Yadav
00cd08090c
kotlin code cleanup AnkiActivity et al (#12735) 2022-11-09 16:03:25 -05:00
lukstbit
40e261b1ac
Improve nullability for methods in the api module (#12450)
* Fix nullability for Note.getTags()

The returned property from this method is of type Array<String>, also the property is initialiazed with non null strings.

* Fix nullability for AddContentApi.addNote()

Changed the type of tags parameter from Set<String?>? to Set<String>? because:
- it doesn't make sense to have a null tag(what would that mean)
- the method addNotes() below uses a List<Set<String>?>? so either this method is incorrect or that one
- our current code would crash with a null tag string as Utils.joinTags() uses !! to reference the string tags when
doing its work

As a future todo maybe we can change parameter to a default one seeing that the database structure for notes specifies
this column as not null(use an empty String?).

* Fix nullability for AddContentApi.addNotes()

Changed the type of parameter fieldsList from List<Array<String>?> to List<Array<String>> because:
- it doesn't make sense to have null fields for a note(it is possible?)
- it would crash as with a null fields array, Utils.joinFields would return null and we would insert null in a
 non null declared column flds

* Fix nullability for AddContentApi.updateNoteTags()

Changed the type of parameter tags from Set<String?>? to Set<String> because:
- same issue with null tag strings which doesn't make sense and it would crash our code in Utils.joinTags
- the tags parameter was made non null, this is an update call so using null(which would result in no tags update)
doesn't make sense

* Fix nullability for AddContentApi.updateNoteFields()

Made the parameter type non null because this is an update call and using null would do no update so the call would be
useless(why do it?).

* Fix nullability for AddContentApi.addNewBasicModel()

Made the name non null, can the model have a null name?

* Fix nullability for AddContentApi.addNewBasic2Model()

Made name non null(can the model have null as name?)

* Fix nullability for AddContentApi.addNewCustomModel()

Made name non null (can the model have null as name?)
Also silenced a silly IDE reported issue.

* Fix nullability for AddContentApi.addNewDeck()

Made the name parameter as non null, does it make sense to have adeck with null for name?!

* Fix nullability for AddContentApi.findDuplicateNotes()

Made the keys parameter as List<String> from List<String?>. What duplicates to find for a null key?

* Remove todo about nullability in AddContentApi
2022-10-30 19:41:40 -05: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
Mike Hardy
5f8c2f7938
Dependency updates 20220929 (#12533)
* Bump junit_version from 5.9.0 to 5.9.1

Bumps `junit_version` from 5.9.0 to 5.9.1.

Updates `junit-jupiter` from 5.9.0 to 5.9.1
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.9.0...r5.9.1)

Updates `junit-vintage-engine` from 5.9.0 to 5.9.1
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.9.0...r5.9.1)

Updates `junit-jupiter-params` from 5.9.0 to 5.9.1
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.9.0...r5.9.1)

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

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

* Bump annotation from 1.4.0 to 1.5.0

Bumps annotation from 1.4.0 to 1.5.0.

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

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

* Bump mockk from 1.12.8 to 1.13.1

Bumps [mockk](https://github.com/mockk/mockk) from 1.12.8 to 1.13.1.
- [Release notes](https://github.com/mockk/mockk/releases)
- [Commits](https://github.com/mockk/mockk/commits)

---
updated-dependencies:
- dependency-name: io.mockk:mockk
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* Bump activity-ktx from 1.5.1 to 1.6.0

Bumps activity-ktx from 1.5.1 to 1.6.0.

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

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

* Bump fragments_version from 1.5.2 to 1.5.3

Bumps `fragments_version` from 1.5.2 to 1.5.3.

Updates `fragment-ktx` from 1.5.2 to 1.5.3

Updates `fragment-testing` from 1.5.2 to 1.5.3

---
updated-dependencies:
- dependency-name: androidx.fragment:fragment-ktx
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: androidx.fragment:fragment-testing
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* Bump mockk from 1.13.1 to 1.13.2

Bumps [mockk](https://github.com/mockk/mockk) from 1.13.1 to 1.13.2.
- [Release notes](https://github.com/mockk/mockk/releases)
- [Commits](https://github.com/mockk/mockk/compare/1.13.1...1.13.2)

---
updated-dependencies:
- dependency-name: io.mockk:mockk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* Bump kotlin_version from 1.7.10 to 1.7.20

Bumps `kotlin_version` from 1.7.10 to 1.7.20.

Updates `kotlin-gradle-plugin` from 1.7.10 to 1.7.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `kotlin-stdlib` from 1.7.10 to 1.7.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `kotlin-test` from 1.7.10 to 1.7.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `kotlin-reflect` from 1.7.10 to 1.7.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `kotlin-test-junit5` from 1.7.10 to 1.7.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Updates `kotlin-test-junit` from 1.7.10 to 1.7.20
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

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

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>
2022-09-29 12:04:39 -05:00
Jalin Wang
5524bf1b83 [KotlinCleanup] use kotlin.test.* for asserting 2022-09-21 13:45:52 -03:00
lukstbit
915f11b552 Enable strict mode for api module 2022-09-19 14:44:09 -03:00
lukstbit
bfeb1cbbbd Make ApiUtilsTest as internal to fix visibility error
Apparently visbility modifiers requirements apply to all classes in the module, even test classes.
2022-09-19 14:44:09 -03:00
lukstbit
a7e83909fe Cleanup FlashCardContract for new api release
This cleanup includes:

- fixing ide lint issues
- adding extra @JvmField annotations to replicate the initial static fields in java, the targets were Uris and the
projection arrays(without the annotations these would have ended in the final bytecode as private static field + getter
method)
- enabled the explicit api mode as this is a library project and I think would be a good addition going forward. I made
the violations as warnings for now( to be able to suppress them for the other api classes) and fixed them for
FlashCardContract. When we finish cleaning up the api module we should move from warning to strict.
See https://kotlinlang.org/docs/whatsnew14.html#explicit-api-mode-for-library-authors
This included specifying the visibility modifiers and the actual properties types(nothing to note here as we have only
strings, not null Uris and not null arrays of not null strings)
- adding some @ Suppress annotations for naming(_ID) and properties not being used(but part of the default projection)

This PR also adds two return types in AddContentApi which I missed in the cleanup of that file.
2022-09-18 07:32:53 -05:00
lukstbit
a8d34e5b36 Add the proper visibility modifiers in AddContentApi
This is required before enabling explicitApi() mode in the build file of the api module.
Also adds the @JvmStatic annotation for one of the methods to follow the original method signature.
2022-09-17 22:06:56 -05:00
lukstbit
2da11b26bd Fix last TODOs for member properties in AddContentApi
The original todos pointed at using @JvmField but this is not applicable as there's no backing field to use.
Also the changes in this commit replicate the java api(visibility and appearance(they were functions)). See last commit
as java file in f39b7fa10f
2022-09-17 22:06:56 -05:00
lukstbit
457ba52044 Cleanup NoteInfo for api release 2022-09-17 19:27:41 +01:00
Mike Hardy
46a4f564d6
Dependency updates 20220917 (#12427)
* build(deps): bump mockk from 1.12.7 to 1.12.8

Bumps [mockk](https://github.com/mockk/mockk) from 1.12.7 to 1.12.8.
- [Release notes](https://github.com/mockk/mockk/releases)
- [Commits](https://github.com/mockk/mockk/compare/1.12.7...v1.12.8)

---
updated-dependencies:
- dependency-name: io.mockk:mockk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* build(deps): bump protobuf-kotlin from 3.21.5 to 3.21.6

Bumps protobuf-kotlin from 3.21.5 to 3.21.6.

---
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 gradle from 7.2.2 to 7.3.0

Bumps gradle from 7.2.2 to 7.3.0.

Note: api minSdkVersion bumped to 16, new gradle version uncovered this NewApi failure
This is another item queued up for API breaking change list

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

* build(deps): bump lint_version from 30.2.2 to 30.3.0

Bumps `lint_version` from 30.2.2 to 30.3.0.

Updates `lint-api` from 30.2.2 to 30.3.0

Updates `lint` from 30.2.2 to 30.3.0

Updates `lint-tests` from 30.2.2 to 30.3.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>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-09-17 12:54:23 -05:00
lukstbit
2b150470e2 Cleanup for AddContentApi for new API release
Note that there are several TODOs still present, these will be addressed in another PR as they are related
more to the visibility and type system.
2022-09-15 21:52:08 -03:00
lukstbit
989b63ec94 Set Basic2Model as internal to follow original visibility 2022-09-14 18:25:28 -03:00
Mike Hardy
2eeed6570e build: bump compileSdkVersion to 33 2022-09-09 21:03:19 -03: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
ba3ba03e4a chore: remove kotlinMigration-api.gradle
No longer necessary. API has been converted to Kotlin
2022-09-05 00:34:28 +02:00
David Allison
cbba9e3b6f refactor!: Convert AddContentApi to Kotlin
com.ichi2.anki.api.AddContentApi

The conversion caused breaking changes WRT nullability of parameters
AND changing `fun` to `val`

This is NOT the final nullability which we desire, we perform the conversion
in a single commit to reduce the chance of bugs being introduced

Changes from a 'pure' conversion':

- addNotes:
  - fieldsList: changed to List<Array<String>?>
  - tagsList: changed to List<Set<String>?>?

- addNewCustomModel changed from auto conversion:
  - fields: -> Array<String>
  - cards -> Array<String>
  - qfmt -> Array<String>
  - afmt -> Array<String>

- splitFields(flds).length -> splitFields(flds).size

suppress lint for name shadowing:
  - `var preferredName = preferredName`

add `!!`
  - `val fname = File(returnUri!!.path).toString()`
  - `val fname = File(returnUri!!.path!!).toString()`

remove `private`:
  - `private get() = if (apiHostSpecVersion < 2) CompatV1() else CompatV2()`
  - `get() = if (apiHostSpecVersion < 2) CompatV1() else CompatV2()`

remove imports:
 - NoteInfo.Companion.buildFromCursor
 - Utils.fieldChecksum
 - Utils.joinFields
 - Utils.joinTags
 - Utils.splitFields

add imports: FlashCardsContract
 - Card
 - CardTemplate
 - Deck
 - Model
 - Note

many spacing changes:
  - sample: values.put(Note.TAGS, Utils.joinTags(tagsList[i]))
    - moved back to a single line

Moved api docs from <pre> to ```

----

Converted with disabled git hooks + tested manually
2022-09-04 15:42:51 -03:00
David Allison
fe9892704b refactor: Rename AddContentApi.java to .kt
com.ichi2.anki.api.AddContentApi
2022-09-04 15:42:51 -03:00
lukstbit
033c51f47b Migrate FlashCardsContract.java to kotlin 2022-09-02 11:55:14 -05:00
lukstbit
3bfa59fe6c Rename FlashCardsContract.java to .kt 2022-09-02 11:55:14 -05:00
David Allison
0364d9376f refactor: Convert ApiUtilsTest to Kotlin
com.ichi2.anki.api.ApiUtilsTest

Git hooks were disabled for this commit due to the extra commit for the
java -> kt rename

(irrelevant) Issue with conversion file was listed: 12209

added kotlin-test for null-safe: `assertNull` required for lint
2022-09-02 07:39:21 -03:00
David Allison
e9a56c59b9 refactor: Rename ApiUtilsTest.java to .kt
com.ichi2.anki.api.ApiUtilsTest

Git hooks were disabled for this commit due to the extra commit for the
java -> kt rename

Tested manually

(irrelevant) Issue with conversion file was listed: 12209
2022-09-02 07:39:21 -03:00
Nishant Bhandari
7003afaa25
Made joinFields accept not null arr string in list (#12250)
* Made joinFields accept not null string in array.

* Added todo for contract.
2022-09-01 07:05:59 +03:00
Nishant
298c5e6b94 Replaced Character.toString with kotlin function toString. 2022-08-31 13:33:58 +01:00
Mike Hardy
67533b62bc
Dependency updates 20220825 (#12170)
* build(deps): bump robolectric from 4.8.1 to 4.8.2

Bumps [robolectric](https://github.com/robolectric/robolectric) from 4.8.1 to 4.8.2.
- [Release notes](https://github.com/robolectric/robolectric/releases)
- [Commits](https://github.com/robolectric/robolectric/compare/robolectric-4.8.1...robolectric-4.8.2)

---
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>

* build(deps): bump mockk from 1.12.5 to 1.12.7

Bumps [mockk](https://github.com/mockk/mockk) from 1.12.5 to 1.12.7.
- [Release notes](https://github.com/mockk/mockk/releases)
- [Commits](https://github.com/mockk/mockk/compare/1.12.5...1.12.7)

---
updated-dependencies:
- dependency-name: io.mockk:mockk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* build(deps): bump ktlint-gradle from 10.3.0 to 11.0.0

Bumps ktlint-gradle from 10.3.0 to 11.0.0.

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

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

* build(deps): bump jsoup from 1.15.2 to 1.15.3

Bumps [jsoup](https://github.com/jhy/jsoup) from 1.15.2 to 1.15.3.
- [Release notes](https://github.com/jhy/jsoup/releases)
- [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES)
- [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.15.2...jsoup-1.15.3)

---
updated-dependencies:
- dependency-name: org.jsoup:jsoup
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

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

* build(deps): bump webkit from 1.4.0 to 1.5.0

Bumps webkit from 1.4.0 to 1.5.0.

---
updated-dependencies:
- dependency-name: androidx.webkit:webkit
  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>
2022-08-25 11:06:33 -05:00
Mike Hardy
f919d7af0a build: bump compileSdkVersion to 32 2022-08-25 09:17:37 -05:00
Arthur Milchior
bc78279662 Remove splitFieldsShouldReturnNullWhenStringIsNull
This method do not take nullable value anymore. And it seems that even from
java's code, it can't be called with nullable value, since it's only called from
either literals or result of Cursor. I.e. strings that are not null by
assumption about the database.
2022-07-24 14:40:34 -05:00
Arthur Milchior
fb385b8647 Remove splitTagsShouldReturnNullWhenStringIsNull
This method do not take nullable value anymore. And it seems that even from
java's code, it can't be called with nullable value, since it's only called from
result of Cursor. I.e. strings that are not null by assumption about the database.
2022-07-24 14:40:34 -05:00
Arthur Milchior
2442dfc882 ApiUtilsTest: remove override ambiguity
This test failed to compile because it did not know whether to use (Object,
Object) or (long, long).
2022-07-24 14:40:34 -05:00
dependabot[bot]
02c444bade Bump annotation from 1.3.0 to 1.4.0
Bumps annotation from 1.3.0 to 1.4.0.

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-04 22:34:37 -05:00
Nishant
9024e6629b Migrate Utils to Kotlin 2022-05-24 10:35:58 -05:00
Nishant
f5b3844854 Rename .java to .kt 2022-05-24 10:35:58 -05:00
Nishant
5fcae3dfe2 Migrate Basic2Model to Kotlin 2022-05-18 14:29:18 -05:00
Nishant
a1378533ba Rename .java to .kt 2022-05-18 14:29:18 -05:00
Nishant
2445e6d99f Migrate NoteInfo to Kotlin 2022-05-18 12:41:39 -05:00
Nishant
ecd530f8dd Rename .java to .kt 2022-05-18 12:41:39 -05:00