2019-02-17 16:53:25 +01:00
|
|
|
plugins {
|
2023-06-14 12:31:02 +02:00
|
|
|
// Gradle plugin portal
|
2024-03-27 01:53:28 +01:00
|
|
|
alias(libs.plugins.tripletPlay)
|
|
|
|
alias(libs.plugins.android.application)
|
|
|
|
alias(libs.plugins.kotlin.android)
|
|
|
|
alias(libs.plugins.kotlin.parcelize)
|
|
|
|
alias(libs.plugins.kotlin.serialization)
|
2024-06-25 20:43:02 +02:00
|
|
|
alias(libs.plugins.keeper)
|
2023-06-14 12:31:02 +02:00
|
|
|
id 'idea'
|
2019-02-17 16:53:25 +01:00
|
|
|
}
|
|
|
|
|
2018-11-24 21:11:48 +01:00
|
|
|
repositories {
|
|
|
|
google()
|
2021-04-16 04:00:57 +02:00
|
|
|
mavenCentral()
|
2021-03-06 19:05:53 +01:00
|
|
|
maven { url "https://jitpack.io" }
|
2018-11-24 21:11:48 +01:00
|
|
|
}
|
2021-01-22 06:50:34 +01:00
|
|
|
|
2024-06-25 20:43:02 +02:00
|
|
|
keeper {
|
|
|
|
traceReferences {
|
|
|
|
// Silence missing definitions
|
|
|
|
arguments.set(["--map-diagnostics:MissingDefinitionsDiagnostic", "error", "none"])
|
|
|
|
}
|
|
|
|
}
|
2021-01-22 06:50:34 +01:00
|
|
|
|
|
|
|
idea {
|
|
|
|
module {
|
|
|
|
downloadJavadoc = System.getenv("CI") != "true"
|
|
|
|
downloadSources = System.getenv("CI") != "true"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-09 18:02:29 +01:00
|
|
|
def homePath = System.properties['user.home']
|
2023-08-27 11:04:11 +02:00
|
|
|
/**
|
|
|
|
* @return the current git hash
|
|
|
|
* @example edf739d95bad7b370a6ed4398d46723f8219b3cd
|
|
|
|
*/
|
|
|
|
static def gitCommitHash() {
|
|
|
|
"git rev-parse HEAD".execute().text.trim()
|
|
|
|
}
|
|
|
|
|
2014-11-09 18:02:29 +01:00
|
|
|
android {
|
2023-04-30 08:43:32 +02:00
|
|
|
namespace "com.ichi2.anki"
|
|
|
|
|
2024-06-14 16:25:25 +02:00
|
|
|
compileSdk libs.versions.compileSdk.get().toInteger()
|
2014-11-09 18:02:29 +01:00
|
|
|
|
2023-07-01 17:09:10 +02:00
|
|
|
buildFeatures {
|
|
|
|
buildConfig = true
|
|
|
|
aidl = true
|
|
|
|
}
|
|
|
|
|
2024-06-25 20:43:02 +02:00
|
|
|
if (rootProject.testReleaseBuild) {
|
|
|
|
testBuildType "release"
|
|
|
|
} else {
|
|
|
|
testBuildType "debug"
|
|
|
|
}
|
|
|
|
|
2014-11-09 18:02:29 +01:00
|
|
|
defaultConfig {
|
|
|
|
applicationId "com.ichi2.anki"
|
2021-07-20 01:17:44 +02:00
|
|
|
buildConfigField "Boolean", "CI", (System.getenv("CI") == "true").toString()
|
2022-06-28 07:27:32 +02:00
|
|
|
buildConfigField "String", "ACRA_URL", '"https://ankidroid.org/acra/report"'
|
2024-04-03 08:36:54 +02:00
|
|
|
buildConfigField "String", "BACKEND_VERSION", "\"${libs.versions.ankiBackend.get()}\""
|
2022-12-10 23:35:57 +01:00
|
|
|
buildConfigField "Boolean", "ENABLE_LEAK_CANARY", "false"
|
2023-02-18 04:40:48 +01:00
|
|
|
buildConfigField "Boolean", "ALLOW_UNSAFE_MIGRATION", "false"
|
2023-08-27 11:04:11 +02:00
|
|
|
buildConfigField "String", "GIT_COMMIT_HASH", "\"${gitCommitHash()}\""
|
2023-11-13 16:54:10 +01:00
|
|
|
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis().toString()
|
2023-01-15 10:57:04 +01:00
|
|
|
resValue "string", "app_name", "AnkiDroid"
|
2020-06-15 03:38:52 +02:00
|
|
|
|
|
|
|
// The version number is of the form:
|
|
|
|
// <major>.<minor>.<maintenance>[dev|alpha<build>|beta<build>|]
|
|
|
|
// The <build> is only present for alpha and beta releases (e.g., 2.0.4alpha2 or 2.0.4beta4), developer builds do
|
|
|
|
// not have a build number (e.g., 2.0.4dev) and official releases only have three components (e.g., 2.0.4).
|
|
|
|
//
|
|
|
|
// The version code is derived from the version name as follows:
|
|
|
|
// AbbCCtDD
|
|
|
|
// A: 1-digit decimal number representing the major version
|
|
|
|
// bb: 2-digit decimal number representing the minor version
|
|
|
|
// CC: 2-digit decimal number representing the maintenance version
|
|
|
|
// t: 1-digit decimal number representing the type of the build
|
|
|
|
// 0: developer build
|
|
|
|
// 1: alpha release
|
|
|
|
// 2: beta release
|
|
|
|
// 3: public release
|
|
|
|
// DD: 2-digit decimal number representing the build
|
|
|
|
// 00 for internal builds and public releases
|
|
|
|
// alpha/beta build number for alpha/beta releases
|
|
|
|
//
|
|
|
|
// This ensures the correct ordering between the various types of releases (dev < alpha < beta < release) which is
|
|
|
|
// needed for upgrades to be offered correctly.
|
2024-08-23 23:18:32 +02:00
|
|
|
versionCode=21900201
|
|
|
|
versionName="2.19beta1"
|
2024-06-14 16:25:25 +02:00
|
|
|
minSdk libs.versions.minSdk.get().toInteger()
|
2024-06-25 20:43:02 +02:00
|
|
|
|
|
|
|
// Stays until this is in a release: https://github.com/google/desugar_jdk_libs/commit/c01a5446ca13586b801dbba4d83c6821337b3cc2
|
|
|
|
if (testReleaseBuild && minSdk < 24) {
|
|
|
|
minSdk 24
|
|
|
|
}
|
|
|
|
|
2023-08-18 20:26:01 +02:00
|
|
|
// After #13695: change .tests_emulator.yml
|
2024-06-14 16:25:25 +02:00
|
|
|
targetSdk libs.versions.targetSdk.get().toInteger()
|
2014-11-10 13:10:07 +01:00
|
|
|
testApplicationId "com.ichi2.anki.tests"
|
2016-05-27 09:25:12 +02:00
|
|
|
vectorDrawables.useSupportLibrary = true
|
2021-10-26 10:58:37 +02:00
|
|
|
testInstrumentationRunner 'com.ichi2.testutils.NewCollectionPathTestRunner'
|
2014-11-09 18:02:29 +01:00
|
|
|
}
|
|
|
|
signingConfigs {
|
2015-10-27 03:23:05 +01:00
|
|
|
release {
|
2024-06-22 16:50:01 +02:00
|
|
|
storeFile file(System.getenv("KEYSTOREPATH") ?: "${homePath}/src/android-keystore")
|
|
|
|
storePassword System.getenv("KEYSTOREPWD") ?: System.getenv("KSTOREPWD")
|
|
|
|
keyAlias System.getenv("KEYALIAS") ?: "nrkeystorealias"
|
2015-10-27 03:23:05 +01:00
|
|
|
keyPassword System.getenv("KEYPWD")
|
|
|
|
}
|
2014-11-09 18:02:29 +01:00
|
|
|
}
|
|
|
|
buildTypes {
|
2023-11-30 22:01:31 +01:00
|
|
|
named('debug') {
|
2023-01-14 12:16:48 +01:00
|
|
|
versionNameSuffix "-debug"
|
2018-08-28 17:21:35 +02:00
|
|
|
debuggable true
|
2023-01-10 01:01:02 +01:00
|
|
|
applicationIdSuffix ".debug"
|
2023-10-27 02:01:58 +02:00
|
|
|
splits.abi.universalApk = true // Build universal APK for debug always
|
2018-08-28 17:21:35 +02:00
|
|
|
// Check Crash Reports page on developer wiki for info on ACRA testing
|
2022-06-28 07:27:32 +02:00
|
|
|
// buildConfigField "String", "ACRA_URL", '"https://918f7f55-f238-436c-b34f-c8b5f1331fe5-bluemix.cloudant.com/acra-ankidroid/_design/acra-storage/_update/report"'
|
2020-04-15 22:42:31 +02:00
|
|
|
if (project.rootProject.file('local.properties').exists()) {
|
|
|
|
Properties localProperties = new Properties()
|
|
|
|
localProperties.load(project.rootProject.file('local.properties').newDataInputStream())
|
2022-06-28 07:27:32 +02:00
|
|
|
// #6009 Allow optional disabling of JaCoCo for general build (assembleDebug).
|
|
|
|
// jacocoDebug task was slow, hung, and wasn't required unless I wanted coverage
|
2020-04-15 22:42:31 +02:00
|
|
|
testCoverageEnabled localProperties['enable_coverage'] != "false"
|
2021-10-22 07:41:59 +02:00
|
|
|
// not profiled: optimization for build times
|
|
|
|
if (localProperties['enable_languages'] == "false") {
|
|
|
|
android.defaultConfig.resConfigs "en"
|
|
|
|
}
|
2023-02-18 04:40:48 +01:00
|
|
|
// allows the scoped storage migration when the user is not logged in
|
|
|
|
if (localProperties["allow_unsafe_migration"] != null) {
|
|
|
|
buildConfigField "Boolean", "ALLOW_UNSAFE_MIGRATION", localProperties["allow_unsafe_migration"]
|
|
|
|
}
|
2022-12-10 23:35:57 +01:00
|
|
|
// allow disabling leak canary
|
|
|
|
if (localProperties["enable_leak_canary"] != null) {
|
|
|
|
buildConfigField "Boolean", "ENABLE_LEAK_CANARY", localProperties["enable_leak_canary"]
|
|
|
|
} else {
|
|
|
|
buildConfigField "Boolean", "ENABLE_LEAK_CANARY", "true"
|
|
|
|
}
|
2020-04-15 22:42:31 +02:00
|
|
|
} else {
|
|
|
|
testCoverageEnabled true
|
|
|
|
}
|
|
|
|
|
2021-04-01 07:52:24 +02:00
|
|
|
// make the icon red if in debug mode
|
|
|
|
resValue 'color', 'anki_foreground_icon_color_0', "#FFFF0000"
|
|
|
|
resValue 'color', 'anki_foreground_icon_color_1', "#FFFF0000"
|
2023-01-10 01:01:02 +01:00
|
|
|
resValue "string", "applicationId", "${defaultConfig.applicationId}${applicationIdSuffix}"
|
2018-08-28 17:21:35 +02:00
|
|
|
}
|
2023-11-30 22:01:31 +01:00
|
|
|
named('release') {
|
2024-06-25 20:43:02 +02:00
|
|
|
testCoverageEnabled = testReleaseBuild
|
2015-12-03 18:16:05 +01:00
|
|
|
minifyEnabled true
|
2024-06-25 20:43:02 +02:00
|
|
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
|
|
testProguardFile 'proguard-test-rules.pro'
|
2020-06-15 22:11:12 +02:00
|
|
|
splits.abi.universalApk = universalApkEnabled // Build universal APK for release with `-Duniversal-apk=true`
|
2014-11-09 18:02:29 +01:00
|
|
|
signingConfig signingConfigs.release
|
2023-01-15 10:57:04 +01:00
|
|
|
|
|
|
|
// syntax: assembleRelease -PcustomSuffix="suffix" -PcustomName="New name"
|
|
|
|
if (project.hasProperty("customSuffix")) {
|
2023-04-26 01:20:33 +02:00
|
|
|
// the suffix needs a '.' at the start
|
|
|
|
applicationIdSuffix project.property("customSuffix").replaceFirst(/^\.*/, ".")
|
2023-03-05 01:48:43 +01:00
|
|
|
resValue "string", "applicationId", "${defaultConfig.applicationId}${applicationIdSuffix}"
|
|
|
|
} else {
|
|
|
|
resValue "string", "applicationId", defaultConfig.applicationId
|
2023-01-15 10:57:04 +01:00
|
|
|
}
|
|
|
|
if (project.hasProperty("customName")) {
|
|
|
|
resValue "string", "app_name", project.property("customName")
|
|
|
|
}
|
|
|
|
|
2021-04-01 07:52:24 +02:00
|
|
|
resValue 'color', 'anki_foreground_icon_color_0', "#FF29B6F6"
|
|
|
|
resValue 'color', 'anki_foreground_icon_color_1', "#FF0288D1"
|
2014-11-09 18:02:29 +01:00
|
|
|
}
|
|
|
|
}
|
2016-03-11 23:45:45 +01:00
|
|
|
|
2021-04-20 05:39:06 +02:00
|
|
|
/**
|
|
|
|
* Product Flavors are used for Amazon App Store and Google Play Store.
|
|
|
|
* This is because we cannot use Camera Permissions in Amazon App Store (for FireTv etc...)
|
|
|
|
* Therefore, different AndroidManifest for Camera Permissions is used in Amazon flavor.
|
2024-02-01 18:38:00 +01:00
|
|
|
*
|
|
|
|
* This flavor block must stay in sync with the same block in testlib/build.gradle.kts
|
2021-04-20 05:39:06 +02:00
|
|
|
*/
|
2023-11-30 22:01:31 +01:00
|
|
|
flavorDimensions += "appStore"
|
2021-04-20 05:39:06 +02:00
|
|
|
productFlavors {
|
2023-11-30 22:01:31 +01:00
|
|
|
create('play') {
|
2021-04-20 05:39:06 +02:00
|
|
|
dimension "appStore"
|
|
|
|
}
|
2023-11-30 22:01:31 +01:00
|
|
|
create('amazon') {
|
2021-04-20 05:39:06 +02:00
|
|
|
dimension "appStore"
|
|
|
|
}
|
2023-03-27 01:56:28 +02:00
|
|
|
// A 'full' build has no restrictions on storage/camera. Distributed on GitHub/F-Droid
|
2023-11-30 22:01:31 +01:00
|
|
|
create('full') {
|
2023-03-27 01:56:28 +02:00
|
|
|
dimension "appStore"
|
|
|
|
}
|
2021-04-20 05:39:06 +02:00
|
|
|
}
|
|
|
|
|
2023-10-27 02:01:58 +02:00
|
|
|
/**
|
|
|
|
* Set this to true to create five separate APKs instead of one:
|
|
|
|
* - 2 APKs that only work on ARM/ARM64 devices
|
|
|
|
* - 2 APKs that only works on x86/x86_64 devices
|
|
|
|
* - a universal APK that works on all devices
|
|
|
|
* The advantage is the size of most APKs is reduced by about 2.5MB.
|
|
|
|
* Upload all the APKs to the Play Store and people will download
|
|
|
|
* the correct one based on the CPU architecture of their device.
|
|
|
|
*/
|
|
|
|
def enableSeparateBuildPerCPUArchitecture = true
|
|
|
|
|
2020-06-15 03:38:52 +02:00
|
|
|
splits {
|
|
|
|
abi {
|
|
|
|
reset()
|
|
|
|
enable enableSeparateBuildPerCPUArchitecture
|
2020-06-15 22:11:12 +02:00
|
|
|
//universalApk enableUniversalApk // set in debug + release config blocks above
|
2020-06-15 03:38:52 +02:00
|
|
|
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// applicationVariants are e.g. debug, release
|
2023-11-30 22:01:31 +01:00
|
|
|
applicationVariants.configureEach { variant ->
|
2021-03-04 19:56:07 +01:00
|
|
|
// We want the same version stream for all ABIs in debug but for release we can split them
|
2020-06-15 03:38:52 +02:00
|
|
|
if (variant.buildType.name == 'release') {
|
2023-11-30 22:01:31 +01:00
|
|
|
variant.outputs.configureEach { output ->
|
2021-03-04 19:56:07 +01:00
|
|
|
|
2020-06-15 03:38:52 +02:00
|
|
|
// For each separate APK per architecture, set a unique version code as described here:
|
|
|
|
// https://developer.android.com/studio/build/configure-apk-splits.html
|
|
|
|
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
|
2021-03-04 19:56:07 +01:00
|
|
|
def outputFile = output.outputFile
|
|
|
|
if (outputFile != null && outputFile.name.endsWith('.apk')) {
|
|
|
|
def abi = output.getFilter("ABI")
|
|
|
|
if (abi != null) { // null for the universal-debug, universal-release variants
|
|
|
|
// From: https://developer.android.com/studio/publish/versioning#appversioning
|
|
|
|
// "Warning: The greatest value Google Play allows for versionCode is 2100000000"
|
|
|
|
// AnkiDroid versionCodes have a budget 8 digits (through AnkiDroid 9)
|
|
|
|
// This style does ABI version code ranges with the 9th digit as 0-4.
|
|
|
|
// This consumes ~20% of the version range space, w/50 years of versioning at our major-version pace
|
|
|
|
output.versionCodeOverride =
|
|
|
|
// ex: 321200106 = 3 * 100000000 + 21200106
|
|
|
|
versionCodes.get(abi) * 100000000 + defaultConfig.versionCode
|
|
|
|
}
|
2020-06-15 03:38:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-03 10:02:27 +02:00
|
|
|
testOptions {
|
|
|
|
animationsDisabled true
|
2023-07-12 07:47:39 +02:00
|
|
|
kotlinOptions {
|
|
|
|
freeCompilerArgs += [
|
|
|
|
'-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi',
|
|
|
|
]
|
|
|
|
}
|
2018-09-03 10:02:27 +02:00
|
|
|
}
|
|
|
|
|
2018-08-28 17:21:35 +02:00
|
|
|
compileOptions {
|
2023-06-28 18:06:44 +02:00
|
|
|
sourceCompatibility JavaVersion.VERSION_11
|
|
|
|
targetCompatibility JavaVersion.VERSION_11
|
2021-03-31 22:21:09 +02:00
|
|
|
coreLibraryDesugaringEnabled true
|
2018-08-28 17:21:35 +02:00
|
|
|
}
|
2023-02-17 13:34:53 +01:00
|
|
|
kotlinOptions {
|
2023-06-28 18:06:44 +02:00
|
|
|
jvmTarget = JavaVersion.VERSION_11
|
2023-02-17 13:34:53 +01:00
|
|
|
}
|
2023-07-12 07:47:39 +02:00
|
|
|
|
|
|
|
packagingOptions {
|
|
|
|
resources {
|
|
|
|
excludes += ['META-INF/DEPENDENCIES']
|
|
|
|
}
|
|
|
|
}
|
2018-11-24 21:11:48 +01:00
|
|
|
}
|
2015-10-27 03:23:05 +01:00
|
|
|
|
|
|
|
play {
|
2020-11-11 15:39:32 +01:00
|
|
|
serviceAccountCredentials.set(file("${homePath}/src/AnkiDroid-GCP-Publish-Credentials.json"))
|
2024-08-23 19:33:51 +02:00
|
|
|
track.set('beta')
|
2015-10-27 03:23:05 +01:00
|
|
|
}
|
2023-07-12 07:47:39 +02:00
|
|
|
|
2021-05-31 15:50:12 +02:00
|
|
|
// Install Git pre-commit hook for Ktlint
|
2023-11-30 22:01:31 +01:00
|
|
|
tasks.register('installGitHook', Copy) {
|
2021-05-31 15:50:12 +02:00
|
|
|
from new File(rootProject.rootDir, 'pre-commit')
|
|
|
|
into { new File(rootProject.rootDir, '.git/hooks') }
|
|
|
|
fileMode 0755
|
|
|
|
}
|
2024-02-29 13:09:49 +01:00
|
|
|
// to run manually: `./gradlew installGitHook`
|
2023-11-30 22:01:31 +01:00
|
|
|
tasks.named('preBuild').configure { dependsOn('installGitHook') }
|
2021-05-31 15:50:12 +02:00
|
|
|
|
2024-06-24 06:38:36 +02:00
|
|
|
tasks.register('copyTestLibIntoAndroidTest', Copy) {
|
|
|
|
into new File(rootProject.rootDir, 'AnkiDroid/src/androidTest/java/com/ichi2/testutils')
|
|
|
|
from new File(rootProject.rootDir, 'testlib/src/main/java/com/ichi2/testutils')
|
|
|
|
into ('common') {
|
|
|
|
from 'common'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tasks.named('preBuild').configure { dependsOn('copyTestLibIntoAndroidTest') }
|
|
|
|
tasks.named('runKtlintCheckOverAndroidTestSourceSet').configure { mustRunAfter('copyTestLibIntoAndroidTest') }
|
|
|
|
|
2022-04-25 22:03:45 +02:00
|
|
|
// Issue 11078 - some emulators run, but run zero tests, and still report success
|
2023-11-30 22:01:31 +01:00
|
|
|
tasks.register('assertNonzeroAndroidTests') {
|
2022-04-25 22:03:45 +02:00
|
|
|
doLast {
|
|
|
|
// androidTest currently creates one .xml file per emulator with aggregate results in this dir
|
|
|
|
File folder = file("./build/outputs/androidTest-results/connected/flavors/play")
|
|
|
|
File[] listOfFiles = folder.listFiles({ d, f -> f ==~ /.*.xml/ } as FilenameFilter)
|
|
|
|
for (File file : listOfFiles) {
|
|
|
|
// The aggregate results file currently contains a line with this pattern holding test count
|
|
|
|
String[] matches = file.readLines().findAll { it.contains('<testsuite') }
|
|
|
|
if (matches.length != 1) {
|
|
|
|
throw new GradleScriptException("Unable to determine count of tests executed for " + file.name + ". Regex pattern out of date?", null)
|
|
|
|
}
|
|
|
|
if (!(matches[0] ==~ /.* tests="\d+" .*/) || matches[0].contains('tests="0"')) {
|
|
|
|
throw new GradleScriptException("androidTest executed 0 tests for " + file.name + " - Probably a bug with the emulator. Try another image.", null)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
afterEvaluate {
|
2024-06-25 20:43:02 +02:00
|
|
|
tasks.named(androidTestName).configure { finalizedBy('assertNonzeroAndroidTests') }
|
2022-04-25 22:03:45 +02:00
|
|
|
}
|
|
|
|
|
2020-08-20 23:40:33 +02:00
|
|
|
apply from: "./robolectricDownloader.gradle"
|
2019-11-04 04:42:37 +01:00
|
|
|
apply from: "./jacoco.gradle"
|
2020-05-15 18:16:59 +02:00
|
|
|
apply from: "../lint.gradle"
|
2018-11-24 22:15:16 +01:00
|
|
|
|
2014-11-09 18:02:29 +01:00
|
|
|
dependencies {
|
2023-11-30 22:01:31 +01:00
|
|
|
configurations.configureEach {
|
2020-07-16 00:19:36 +02:00
|
|
|
resolutionStrategy {
|
2023-11-18 21:44:10 +01:00
|
|
|
// Timber has this as a dependency but they are not up to date. We want to force our version.
|
|
|
|
force 'org.jetbrains:annotations:24.1.0'
|
2020-07-16 00:19:36 +02:00
|
|
|
}
|
|
|
|
}
|
2023-07-12 07:47:39 +02:00
|
|
|
api project(":api")
|
2024-03-27 01:53:28 +01:00
|
|
|
implementation libs.androidx.work.runtime
|
2021-07-11 03:03:24 +02:00
|
|
|
lintChecks project(":lint-rules")
|
2024-03-27 01:53:28 +01:00
|
|
|
coreLibraryDesugaring libs.desugar.jdk.libs.nio
|
|
|
|
|
|
|
|
compileOnly libs.jetbrains.annotations
|
|
|
|
compileOnly libs.auto.service.annotations
|
|
|
|
annotationProcessor libs.auto.service
|
|
|
|
|
2024-05-29 15:42:43 +02:00
|
|
|
// modules
|
|
|
|
implementation project(":common")
|
|
|
|
|
2024-05-02 19:59:34 +02:00
|
|
|
implementation libs.androidx.activity
|
2024-03-27 01:53:28 +01:00
|
|
|
implementation libs.androidx.annotation
|
|
|
|
implementation libs.androidx.appcompat
|
|
|
|
implementation libs.androidx.browser
|
|
|
|
implementation libs.androidx.core.ktx
|
2024-07-24 07:04:24 +02:00
|
|
|
implementation libs.androidx.draganddrop
|
2024-03-27 01:53:28 +01:00
|
|
|
implementation libs.androidx.exifinterface
|
|
|
|
implementation libs.androidx.fragment.ktx
|
|
|
|
implementation libs.androidx.media
|
|
|
|
implementation libs.androidx.preference.ktx
|
|
|
|
implementation libs.androidx.recyclerview
|
|
|
|
implementation libs.androidx.sqlite.framework
|
|
|
|
implementation libs.androidx.swiperefreshlayout
|
|
|
|
implementation libs.androidx.viewpager2
|
|
|
|
implementation libs.androidx.constraintlayout
|
|
|
|
implementation libs.androidx.webkit
|
|
|
|
implementation libs.google.material
|
|
|
|
implementation libs.android.image.cropper
|
|
|
|
implementation libs.nanohttpd
|
|
|
|
implementation libs.kotlinx.serialization.json
|
|
|
|
implementation libs.seismic
|
|
|
|
|
|
|
|
debugImplementation libs.androidx.fragment.testing.manifest
|
2021-06-27 16:26:09 +02:00
|
|
|
|
2022-06-11 07:14:13 +02:00
|
|
|
// Backend libraries
|
|
|
|
|
2024-03-27 01:53:28 +01:00
|
|
|
implementation libs.protobuf.kotlin.lite // This is required when loading from a file
|
2022-06-11 07:14:13 +02:00
|
|
|
|
2022-06-28 07:27:32 +02:00
|
|
|
Properties localProperties = new Properties()
|
|
|
|
if (project.rootProject.file('local.properties').exists()) {
|
|
|
|
localProperties.load(project.rootProject.file('local.properties').newDataInputStream())
|
|
|
|
}
|
|
|
|
if (localProperties['local_backend'] == "true") {
|
|
|
|
implementation files("../../Anki-Android-Backend/rsdroid/build/outputs/aar/rsdroid-release.aar")
|
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-30 23:44:03 +02:00
|
|
|
testImplementation files("../../Anki-Android-Backend/rsdroid-testing/build/libs/rsdroid-testing.jar")
|
2022-06-28 07:27:32 +02:00
|
|
|
} else {
|
2024-03-27 01:53:28 +01:00
|
|
|
implementation libs.ankiBackend.backend
|
2024-06-20 16:25:06 +02:00
|
|
|
testImplementation libs.ankiBackend.testing
|
2022-06-28 07:27:32 +02:00
|
|
|
}
|
2022-06-11 07:14:13 +02:00
|
|
|
|
2018-10-05 19:41:05 +02:00
|
|
|
// May need a resolution strategy for support libs to our versions
|
2024-03-27 01:53:28 +01:00
|
|
|
implementation libs.acra.limiter
|
|
|
|
implementation libs.acra.toast
|
|
|
|
implementation libs.acra.dialog
|
|
|
|
implementation libs.acra.http
|
|
|
|
|
|
|
|
implementation libs.commons.compress
|
|
|
|
implementation libs.commons.collections4 // SetUniqueList
|
|
|
|
implementation libs.commons.io // FileUtils.contentEquals
|
|
|
|
implementation libs.mikehardy.google.analytics.java7
|
|
|
|
implementation libs.okhttp
|
|
|
|
implementation libs.slf4j.timber
|
|
|
|
implementation libs.jakewharton.timber
|
|
|
|
implementation libs.jsoup
|
|
|
|
implementation libs.java.semver // For AnkiDroid JS API Versioning
|
|
|
|
implementation libs.drakeet.drawer
|
|
|
|
implementation libs.tapTargetPrompt
|
|
|
|
implementation libs.colorpicker
|
|
|
|
implementation libs.kotlin.reflect
|
|
|
|
implementation libs.kotlin.test
|
|
|
|
implementation libs.search.preference
|
2022-06-16 21:54:47 +02:00
|
|
|
|
2022-01-02 19:42:20 +01:00
|
|
|
// Cannot use debugImplementation since classes need to be imported in AnkiDroidApp
|
|
|
|
// and there's no no-op version for release build. Usage has been disabled for release
|
|
|
|
// build via AnkiDroidApp.
|
2024-03-27 01:53:28 +01:00
|
|
|
implementation libs.leakcanary.android
|
2022-01-02 19:42:20 +01:00
|
|
|
|
2024-02-01 18:38:00 +01:00
|
|
|
testImplementation project(':testlib')
|
|
|
|
|
2023-07-12 07:47:39 +02:00
|
|
|
// A path for a testing library which provide Parameterized Test
|
2024-03-27 01:53:28 +01:00
|
|
|
testImplementation libs.junit.jupiter
|
|
|
|
testImplementation libs.junit.jupiter.params
|
|
|
|
testImplementation libs.junit.vintage.engine
|
|
|
|
testImplementation libs.mockito.inline
|
|
|
|
testImplementation libs.mockito.kotlin
|
|
|
|
testImplementation libs.hamcrest
|
2021-12-04 19:29:52 +01:00
|
|
|
// robolectricDownloader.gradle *may* need a new SDK jar entry if they release one or if we change targetSdk. Instructions in that gradle file.
|
2024-03-27 01:53:28 +01:00
|
|
|
testImplementation libs.robolectric
|
|
|
|
testImplementation libs.androidx.test.core
|
|
|
|
testImplementation libs.androidx.test.junit
|
|
|
|
testImplementation libs.kotlin.reflect
|
|
|
|
testImplementation libs.kotlin.test
|
|
|
|
testImplementation libs.kotlin.test.junit5
|
|
|
|
testImplementation libs.kotlinx.coroutines.test
|
|
|
|
testImplementation libs.mockk
|
|
|
|
testImplementation libs.commons.exec // obtaining the OS
|
|
|
|
testImplementation libs.androidx.fragment.testing
|
2023-11-21 04:46:49 +01:00
|
|
|
// in a JvmTest we need org.json.JSONObject to not be mocked
|
2024-03-27 01:53:28 +01:00
|
|
|
testImplementation libs.json
|
|
|
|
testImplementation libs.ivanshafran.shared.preferences.mock
|
|
|
|
testImplementation libs.androidx.test.runner
|
|
|
|
testImplementation libs.androidx.test.rules
|
|
|
|
testImplementation libs.androidx.espresso.core
|
|
|
|
testImplementation(libs.androidx.espresso.contrib) {
|
2024-01-08 07:02:01 +01:00
|
|
|
exclude module: "protobuf-lite"
|
|
|
|
}
|
2024-04-21 15:19:43 +02:00
|
|
|
testImplementation libs.androidx.work.testing
|
2024-05-27 01:37:26 +02:00
|
|
|
// for testing flows
|
|
|
|
testImplementation libs.cashapp.turbine
|
2024-02-01 18:38:00 +01:00
|
|
|
|
2024-06-24 06:38:36 +02:00
|
|
|
// we should depend directly on the common testlib for androidTest, but we cannot
|
|
|
|
// until coverage-breaking issue is fixed https://issuetracker.google.com/issues/332746900
|
|
|
|
// androidTestImplementation project(':testlib')
|
2024-02-01 18:38:00 +01:00
|
|
|
|
2018-10-05 19:41:05 +02:00
|
|
|
// May need a resolution strategy for support libs to our versions
|
2024-03-27 01:53:28 +01:00
|
|
|
androidTestImplementation libs.androidx.espresso.core
|
|
|
|
androidTestImplementation(libs.androidx.espresso.contrib) {
|
Update to Anki 2.1.54 backend
Squashes a few commits:
Move the legacy schema toggle into BackendFactory
Simplify backend handling; rework collection instantiation
When the Rust code was initially introduced, it was not clear whether
it would be usable on all devices, or whether it would need to be removed
for some reason. This no doubt influenced the design of the existing API,
which tries to make it easy to swap the Rust code out with something else.
Unfortunately this approach has some downsides:
- It makes it somewhat harder to follow, as method calls jump through
multiple interfaces before they're actually sent to the backend.
- It makes utilizing new methods considerably more cumbersome.
For example, take the extract_av_tags() call. It follows the following
path:
collection method or method in related helper class:
https://github.com/ankidroid/Anki-Android/blob/cea79e1b077bc30e7eed8f37529002aae416d34d/AnkiDroid/src/main/java/com/ichi2/libanki/TemplateManager.kt#L242
to generic interface:
https://github.com/ankidroid/Anki-Android/blob/cea79e1b077bc30e7eed8f37529002aae416d34d/AnkiDroid/src/main/java/com/ichi2/libanki/backend/DroidBackend.kt#L83
to specific implementation:
https://github.com/ankidroid/Anki-Android/blob/cea79e1b077bc30e7eed8f37529002aae416d34d/AnkiDroid/src/main/java/com/ichi2/libanki/backend/RustDroidV16Backend.kt#L57
and if it's unusable with the legacy schema (which I don't believe is
actually true in this case), it also needs to be added to the other
implementation:
https://github.com/ankidroid/Anki-Android/blob/cea79e1b077bc30e7eed8f37529002aae416d34d/AnkiDroid/src/main/java/com/ichi2/libanki/backend/RustDroidBackend.kt#L87
and then finally, a method in the backend module is invoked.
The backend module has code generation so that invoking a backend method
is as simple as making a method call, but currently you have to weave
the call through 3 or so levels of indirection before you can actually
use it. With something like 170 available methods, that's a fair amount
of extra work required.
Rather than trying to insulate libanki from the backend code, this PR
drops some of the indirection in favour of the approach the desktop takes:
libanki is the insulation layer; it can call freely into the backend methods,
but consumers (eg the GUI code) are expected to only call methods on the
collection, and not access the backend directly.
In addition to the above, collection initialization has been reworked
to be more similar to the computer version. Instead of the collection
being created from a database object, a backend is passed into the
collection creation, and the collection takes care of creating a DB
instance that wraps the backend.
Remove always-on isUsingRustBackend
Drop the legacy upgrade/initialization code
Schema 11 was introduced in 2012, and decks that still are <11 are very
rare. The desktop dropped support for schema 10 back in early 2020.
This also removes the need to modify SCHEMA_VERSION when switching
between TESTING_USE_V16_BACKEND.
Remove DOWNGRADE_REQUIRED and slightly simplify startup error handling
- The backend automatically downgrades when required, and possible. No
backup is required, as the downgrade happens in a single transaction,
and the downgrade code has proven itself over time.
- Store the type of failure in getColSafe(), so it can be checked later.
Update to work with desktop 2.1.53 code
Depends on https://github.com/ankidroid/Anki-Android-Backend/pull/202
Due to the removal and change of a few backend methods, syncing, importing
and the card templates screen will not work when the schema16 setting is
active (actually schema18 now). To get them working again, those code
paths will need to switch to the backend implementations.
A few notes:
- Downgrading happens automatically when loading the collection in schema11
mode, so the extra code dealing with downgrades & "can downgrade" reporting
can be stripped.
- Added the ability to run col.set_config("key", JSONObject.NULL), as
unit tests were attempting to write the entire collection config, which is
no longer supported.
- All tests pass on both old and new backends, though the latter required
disabling a few failed tests when running with the new schema
(eg notetype updating).
Integrates, and thus closes #11579 and closes #11581
Remove the time argument to Storage.collection()
Collection does not currently take a time argument, and relies on the
global object instead, so this change brings Storage in line with it.
Reuse the backend when closing+reopening a collection
Avoids having to re-initialize the translations, and reduces leaks
(the import + export code leaks backends still)
2022-06-28 08:03:17 +02:00
|
|
|
exclude module: "protobuf-lite"
|
|
|
|
}
|
2024-03-27 01:53:28 +01:00
|
|
|
androidTestImplementation libs.androidx.test.core
|
|
|
|
androidTestImplementation libs.androidx.test.junit
|
|
|
|
androidTestImplementation libs.androidx.test.rules
|
|
|
|
androidTestImplementation libs.androidx.uiautomator
|
|
|
|
androidTestImplementation libs.kotlin.test
|
|
|
|
androidTestImplementation libs.kotlin.test.junit
|
|
|
|
androidTestImplementation libs.androidx.fragment.testing
|
2024-07-21 10:19:51 +02:00
|
|
|
|
|
|
|
implementation libs.androidx.media3.exoplayer
|
|
|
|
implementation libs.androidx.media3.exoplayer.dash
|
|
|
|
implementation libs.androidx.media3.ui
|
2014-11-09 18:02:29 +01:00
|
|
|
}
|