Skip to content

Commit 836a8d0

Browse files
authored
Merge branch 'main' into cardBrowser2
2 parents 4080f43 + d2f499b commit 836a8d0

File tree

319 files changed

+3871
-1398
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

319 files changed

+3871
-1398
lines changed

AnkiDroid/build.gradle

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ android {
8585
//
8686
// This ensures the correct ordering between the various types of releases (dev < alpha < beta < release) which is
8787
// needed for upgrades to be offered correctly.
88-
versionCode=22100105
89-
versionName="2.21alpha5"
88+
versionCode=22100108
89+
versionName="2.21alpha8"
9090
minSdk libs.versions.minSdk.get().toInteger()
9191

9292
// After #13695: change .tests_emulator.yml
@@ -256,6 +256,30 @@ android {
256256
play {
257257
serviceAccountCredentials.set(file("${homePath}/src/AnkiDroid-GCP-Publish-Credentials.json"))
258258
track.set('alpha')
259+
260+
// any time we bump minSdk we want Play Store to retain the old artifacts by version code,
261+
// so that they remain available for older devices
262+
retain {
263+
artifacts.set([
264+
20700300L, // (2.7, minSdk 10, universal APK)
265+
20804300L, // (2.8.4, minSdk 10, universal APK)
266+
21004300L, // (2.10.4, minSdk 15, universal APK)
267+
// release-2.14 minSdk 16: missing and not re-publishable, see issue 17791
268+
121603300L, // (2.16.3, minSdk 21, ABI armeabi-v7a)
269+
221603300L, // (2.16.3, minSdk 21, ABI x86)
270+
321603300L, // (2.16.3, minSdk 21, ABI arm64-v8a)
271+
421603300L, // (2.16.3, minSdk 21, ABI x86_64)
272+
121904300L, // (2.19.4, minSdk 23, ABI armeabi-v7a)
273+
221904300L, // (2.19.4, minSdk 23, ABI x86)
274+
321904300L, // (2.19.4, minSdk 23, ABI arm64-v8a)
275+
421904300L, // (2.19.4, minSdk 23, ABI x86_64)
276+
])
277+
}
278+
279+
// If you retain APKs in a release with different names as we do above,
280+
// the plugin + Play Store has no idea how to name the release except by date.
281+
// release name is developer only, but sane names really help, so set one
282+
releaseName.set(android.defaultConfig.versionName)
259283
}
260284

261285
// Install Git pre-commit hook for Ktlint

AnkiDroid/jacoco.gradle

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ else
9999
classDir += "Debug"
100100

101101
// Our merge report task
102-
def testReport = tasks.register('jacocoTestReport', JacocoReport) {
102+
tasks.register('jacocoTestReport', JacocoReport) {
103103
def htmlOutDir = project.layout.buildDirectory.dir("reports/jacoco/$name/html").get().asFile
104104

105105
doLast {
@@ -120,14 +120,12 @@ def testReport = tasks.register('jacocoTestReport', JacocoReport) {
120120
'**/*.exec',
121121
'**/*.ec'
122122
])
123-
}
124-
testReport.configure {
125123
dependsOn('testPlayDebugUnitTest')
126124
dependsOn("connectedPlay${rootProject.androidTestVariantName}AndroidTest")
127125
}
128126

129127
// A unit-test only report task
130-
def unitTestReport = tasks.register('jacocoUnitTestReport', JacocoReport) {
128+
tasks.register('jacocoUnitTestReport', JacocoReport) {
131129
def htmlOutDir = layout.buildDirectory.dir("reports/jacoco/$name/html").get().asFile
132130

133131
doLast {
@@ -148,11 +146,11 @@ def unitTestReport = tasks.register('jacocoUnitTestReport', JacocoReport) {
148146
'**/*.exec'
149147

150148
])
149+
dependsOn('testPlayDebugUnitTest')
151150
}
152-
unitTestReport.configure { dependsOn('testPlayDebugUnitTest') }
153151

154152
// A connected android tests only report task
155-
def androidTestReport = tasks.register('jacocoAndroidTestReport', JacocoReport) {
153+
tasks.register('jacocoAndroidTestReport', JacocoReport) {
156154
def htmlOutDir = layout.buildDirectory.dir("reports/jacoco/$name/html").get().asFile
157155

158156
doLast {
@@ -172,10 +170,9 @@ def androidTestReport = tasks.register('jacocoAndroidTestReport', JacocoReport)
172170
executionData.from = fileTree(dir: project.layout.buildDirectory, includes: [
173171
'**/*.ec'
174172
])
173+
dependsOn("connectedPlay${rootProject.androidTestVariantName}AndroidTest")
175174
}
176175

177-
androidTestReport.configure { dependsOn("connectedPlay${rootProject.androidTestVariantName}AndroidTest") }
178-
179176
// Issue 16640 - some emulators run, but register zero coverage
180177
tasks.register('assertNonzeroAndroidTestCoverage') {
181178
doLast {

AnkiDroid/src/androidTest/java/com/ichi2/anki/tests/ContentProviderTest.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import com.ichi2.anki.FlashCardsContract
3030
import com.ichi2.anki.provider.pureAnswer
3131
import com.ichi2.anki.testutil.DatabaseUtils.cursorFillWindow
3232
import com.ichi2.anki.testutil.GrantStoragePermission.storagePermission
33+
import com.ichi2.anki.testutil.addNote
3334
import com.ichi2.anki.testutil.grantPermissions
3435
import com.ichi2.libanki.Card
3536
import com.ichi2.libanki.DeckId
@@ -569,10 +570,10 @@ class ContentProviderTest : InstrumentedTest() {
569570
val noteTypeUri = cr.insert(FlashCardsContract.Model.CONTENT_URI, cv)
570571
assertNotNull("Check inserted note type isn't null", noteTypeUri)
571572
assertNotNull("Check last path segment exists", noteTypeUri!!.lastPathSegment)
572-
val mid = noteTypeUri.lastPathSegment!!.toLong()
573+
val noteTypeId = noteTypeUri.lastPathSegment!!.toLong()
573574
var col = reopenCol()
574575
try {
575-
var noteType = col.notetypes.get(mid)
576+
var noteType = col.notetypes.get(noteTypeId)
576577
assertNotNull("Check note type", noteType)
577578
assertEquals("Check note type name", TEST_NOTE_TYPE_NAME, noteType!!.getString("name"))
578579
assertEquals(
@@ -601,7 +602,7 @@ class ContentProviderTest : InstrumentedTest() {
601602
greaterThan(0),
602603
)
603604
col = reopenCol()
604-
noteType = col.notetypes.get(mid)
605+
noteType = col.notetypes.get(noteTypeId)
605606
assertNotNull("Check note type", noteType)
606607
assertEquals("Check css", TEST_NOTE_TYPE_CSS, noteType!!.getString("css"))
607608
// Update each of the templates in note type (to test updating NOTE_TYPES_ID_TEMPLATES_ID Uri)
@@ -625,7 +626,7 @@ class ContentProviderTest : InstrumentedTest() {
625626
greaterThan(0),
626627
)
627628
col = reopenCol()
628-
noteType = col.notetypes.get(mid)
629+
noteType = col.notetypes.get(noteTypeId)
629630
assertNotNull("Check note type", noteType)
630631
val template = noteType!!.tmpls[i]
631632
assertEquals(
@@ -642,7 +643,7 @@ class ContentProviderTest : InstrumentedTest() {
642643
// Delete the note type (this will force a full-sync)
643644
col.modSchemaNoCheck()
644645
try {
645-
val noteType = col.notetypes.get(mid)
646+
val noteType = col.notetypes.get(noteTypeId)
646647
assertNotNull("Check note type", noteType)
647648
col.notetypes.rem(noteType!!)
648649
} catch (e: ConfirmModSchemaException) {

AnkiDroid/src/androidTest/java/com/ichi2/anki/tests/InstrumentedTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import androidx.test.platform.app.InstrumentationRegistry
2525
import androidx.test.uiautomator.UiDevice
2626
import androidx.test.uiautomator.UiSelector
2727
import com.ichi2.anki.CollectionManager
28+
import com.ichi2.anki.testutil.addNote
2829
import com.ichi2.anki.utils.EnsureAllFilesAccessRule
2930
import com.ichi2.annotations.DuplicatedCode
3031
import com.ichi2.libanki.Card

AnkiDroid/src/androidTest/java/com/ichi2/anki/tests/libanki/MediaTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
1919
import com.ichi2.anki.BackupManager
2020
import com.ichi2.anki.tests.InstrumentedTest
2121
import com.ichi2.anki.testutil.GrantStoragePermission
22+
import com.ichi2.anki.testutil.addNote
2223
import com.ichi2.libanki.Collection
2324
import com.ichi2.libanki.Media
2425
import com.ichi2.libanki.exception.EmptyMediaException
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2025 David Allison <davidallisongithub@gmail.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under
5+
* the terms of the GNU General Public License as published by the Free Software
6+
* Foundation; either version 3 of the License, or (at your option) any later
7+
* version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
10+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11+
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License along with
14+
* this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
17+
package com.ichi2.anki.testutil
18+
19+
import com.ichi2.libanki.Collection
20+
import com.ichi2.libanki.Note
21+
22+
// todo: duplicated & used in unit tests
23+
fun Collection.addNote(note: Note): Int {
24+
addNote(note, note.notetype.did)
25+
return note.numberOfCards(this)
26+
}

AnkiDroid/src/main/java/com/ichi2/anim/ActivityTransitionAnimation.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object ActivityTransitionAnimation {
3131
}
3232
Direction.RIGHT -> activity.overridePendingTransition(R.anim.slide_right_in, R.anim.slide_right_out)
3333
Direction.LEFT -> activity.overridePendingTransition(R.anim.slide_left_in, R.anim.slide_left_out)
34-
Direction.FADE -> activity.overridePendingTransition(R.anim.fade_out, R.anim.fade_in)
34+
Direction.FADE -> activity.overridePendingTransition(R.anim.fade_in, R.anim.fade_out)
3535
Direction.UP -> activity.overridePendingTransition(R.anim.slide_up_in, R.anim.slide_up_out)
3636
Direction.DOWN -> activity.overridePendingTransition(R.anim.slide_down_in, R.anim.slide_down_out)
3737
Direction.NONE -> activity.overridePendingTransition(R.anim.none, R.anim.none)
@@ -73,7 +73,7 @@ object ActivityTransitionAnimation {
7373
}
7474
Direction.RIGHT -> ActivityOptionsCompat.makeCustomAnimation(activity, R.anim.slide_right_in, R.anim.slide_right_out)
7575
Direction.LEFT -> ActivityOptionsCompat.makeCustomAnimation(activity, R.anim.slide_left_in, R.anim.slide_left_out)
76-
Direction.FADE -> ActivityOptionsCompat.makeCustomAnimation(activity, R.anim.fade_out, R.anim.fade_in)
76+
Direction.FADE -> ActivityOptionsCompat.makeCustomAnimation(activity, R.anim.fade_in, R.anim.fade_out)
7777
Direction.UP -> ActivityOptionsCompat.makeCustomAnimation(activity, R.anim.slide_up_in, R.anim.slide_up_out)
7878
Direction.DOWN -> ActivityOptionsCompat.makeCustomAnimation(activity, R.anim.slide_down_in, R.anim.slide_down_out)
7979
Direction.NONE -> ActivityOptionsCompat.makeCustomAnimation(activity, R.anim.none, R.anim.none)

AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ import com.ichi2.anki.reviewer.MotionEventHandler
121121
import com.ichi2.anki.reviewer.PreviousAnswerIndicator
122122
import com.ichi2.anki.servicelayer.LanguageHintService.applyLanguageHint
123123
import com.ichi2.anki.servicelayer.NoteService.isMarked
124+
import com.ichi2.anki.settings.Prefs
124125
import com.ichi2.anki.snackbar.BaseSnackbarBuilderProvider
125126
import com.ichi2.anki.snackbar.SnackbarBuilder
126127
import com.ichi2.anki.snackbar.showSnackbar
@@ -1226,7 +1227,7 @@ abstract class AbstractFlashcardViewer :
12261227
// mDeckFilename = preferences.getString("deckFilename", "");
12271228
minimalClickSpeed = preferences.getInt("showCardAnswerButtonTime", 0)
12281229
fullscreenMode = fromPreference(preferences)
1229-
relativeButtonSize = preferences.getInt("answerButtonSize", 100)
1230+
relativeButtonSize = Prefs.answerButtonsSize
12301231
tts.enabled = preferences.getBoolean("tts", false)
12311232
doubleScrolling = preferences.getBoolean("double_scrolling", false)
12321233
prefShowTopbar = preferences.getBoolean("showTopbar", true)

0 commit comments

Comments
 (0)