diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/BackendBackups.kt b/AnkiDroid/src/main/java/com/ichi2/anki/BackendBackups.kt index 114374f0b283..3ad8c4880b51 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/BackendBackups.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/BackendBackups.kt @@ -17,9 +17,10 @@ package com.ichi2.anki import com.ichi2.anki.CollectionManager.withCol -import com.ichi2.libanki.awaitBackupCompletion import com.ichi2.libanki.createBackup -import kotlinx.coroutines.* +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay +import kotlinx.coroutines.withContext fun DeckPicker.performBackupInBackground() { launchCatchingTask { diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/IntroductionActivity.kt b/AnkiDroid/src/main/java/com/ichi2/anki/IntroductionActivity.kt index 020802b03a66..711cf0ac64f1 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/IntroductionActivity.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/IntroductionActivity.kt @@ -59,7 +59,7 @@ class IntroductionActivity : AnkiActivity() { handleCollectionSetupOption { option -> when (option) { - CollectionSetupOption.DeckPickerWithNewCollection -> startDeckPicker(RESULT_START_NEW) + CollectionSetupOption.DeckPickerWithNewCollection -> startDeckPicker() CollectionSetupOption.SyncFromExistingAccount -> openLoginDialog() } } diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/cardviewer/TypeAnswer.kt b/AnkiDroid/src/main/java/com/ichi2/anki/cardviewer/TypeAnswer.kt index 82156951d238..e06968090365 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/cardviewer/TypeAnswer.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/cardviewer/TypeAnswer.kt @@ -86,7 +86,7 @@ class TypeAnswer( */ fun updateInfo(card: Card, res: Resources) { correct = null - val q = card.question(false) + val q = card.question() val m = PATTERN.matcher(q) var clozeIdx = 0 if (!m.find()) { diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/tags/TagsList.kt b/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/tags/TagsList.kt index e04da65ef22b..5ddaaecd2504 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/tags/TagsList.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/tags/TagsList.kt @@ -33,7 +33,7 @@ import java.util.* * @param checkedTags a list containing the currently selected tags. Any duplicates will be ignored. * @param uncheckedTags a list containing the currently unselected tags. Any duplicates will be ignored. */ -class TagsList constructor( +class TagsList( allTags: List, checkedTags: List, uncheckedTags: List? = null diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/exception/StorageAccessException.kt b/AnkiDroid/src/main/java/com/ichi2/anki/exception/StorageAccessException.kt index 46543c8e2682..3a5eba61bd95 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/exception/StorageAccessException.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/exception/StorageAccessException.kt @@ -16,7 +16,7 @@ package com.ichi2.anki.exception -class StorageAccessException constructor( +class StorageAccessException( msg: String? = null, e: Throwable? = null ) : Exception(msg, e) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/multimediacard/MediaPlayer.kt b/AnkiDroid/src/main/java/com/ichi2/anki/multimediacard/MediaPlayer.kt index 68d7b8066dee..95ecfe6854e1 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/multimediacard/MediaPlayer.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/multimediacard/MediaPlayer.kt @@ -32,7 +32,7 @@ import java.net.HttpCookie * because android doesn't have a non-private getter for its MediaPlayer state */ class MediaPlayer : - android.media.MediaPlayer(), + MediaPlayer(), OnPreparedListener, MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener { diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/multimediacard/activity/MultimediaEditFieldActivity.kt b/AnkiDroid/src/main/java/com/ichi2/anki/multimediacard/activity/MultimediaEditFieldActivity.kt index b5f7c45a0e94..9cbd90898d17 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/multimediacard/activity/MultimediaEditFieldActivity.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/multimediacard/activity/MultimediaEditFieldActivity.kt @@ -423,8 +423,6 @@ class MultimediaEditFieldActivity : AnkiActivity(), OnRequestPermissionsResultCa } private fun createControllerForField(field: IField): IFieldController { - @Suppress("WHEN_ENUM_CAN_BE_NULL_IN_JAVA") - // the return of field.type is non nullable return when (field.type) { EFieldType.TEXT -> BasicTextFieldController() EFieldType.IMAGE -> BasicImageFieldController() diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/preferences/CustomButtonsSettingsFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/preferences/CustomButtonsSettingsFragment.kt index 5fb164564d8d..5d954bec2ce2 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/preferences/CustomButtonsSettingsFragment.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/preferences/CustomButtonsSettingsFragment.kt @@ -46,7 +46,7 @@ class CustomButtonsSettingsFragment : SettingsFragment() { // #9263: refresh the screen to display the changes refreshScreen() } - negativeButton(R.string.dialog_cancel, null) + negativeButton(R.string.dialog_cancel) } true } diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/preferences/Preferences.kt b/AnkiDroid/src/main/java/com/ichi2/anki/preferences/Preferences.kt index 0671f2f22101..46d13d3c8da9 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/preferences/Preferences.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/preferences/Preferences.kt @@ -36,8 +36,12 @@ import com.bytehamster.lib.preferencesearch.SearchPreferenceResult import com.bytehamster.lib.preferencesearch.SearchPreferenceResultListener import com.google.android.material.appbar.AppBarLayout import com.google.android.material.appbar.CollapsingToolbarLayout -import com.ichi2.anki.* +import com.ichi2.anki.AnkiActivity +import com.ichi2.anki.CollectionManager import com.ichi2.anki.CollectionManager.withCol +import com.ichi2.anki.DeckPicker +import com.ichi2.anki.R +import com.ichi2.anki.launchCatchingTask import com.ichi2.anki.services.BootService.Companion.scheduleNotification import com.ichi2.libanki.utils.TimeManager import com.ichi2.themes.setTransparentStatusBar diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/PeripheralKeymap.kt b/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/PeripheralKeymap.kt index ded5de20f7e0..becbe218c11b 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/PeripheralKeymap.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/PeripheralKeymap.kt @@ -25,7 +25,6 @@ import com.ichi2.anki.reviewer.Binding.Companion.possibleKeyBindings import com.ichi2.anki.reviewer.CardSide.Companion.fromAnswer import com.ichi2.anki.reviewer.MappableBinding.* import com.ichi2.anki.reviewer.MappableBinding.Companion.fromPreference -import java.util.HashMap /** Accepts peripheral input, mapping via various keybinding strategies, * and converting them to commands for the Reviewer. */ diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/scopedstorage/migrateuserdata/MigrateUserData.kt b/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/scopedstorage/migrateuserdata/MigrateUserData.kt index 459f6fbece34..31ec18d2a146 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/scopedstorage/migrateuserdata/MigrateUserData.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/scopedstorage/migrateuserdata/MigrateUserData.kt @@ -151,7 +151,7 @@ open class MigrateUserData protected constructor(val source: Directory, val dest * If the number of retries was exceeded when resolving a file conflict via moving it to the * /conflict/ folder. */ - class FileConflictResolutionFailedException(val sourceFile: DiskFile, private val attemptedDestination: File) : MigrationException("Failed to move $sourceFile to $attemptedDestination") + class FileConflictResolutionFailedException(val sourceFile: DiskFile, attemptedDestination: File) : MigrationException("Failed to move $sourceFile to $attemptedDestination") /** * Context for an [Operation], allowing a change of execution behavior and @@ -600,11 +600,7 @@ open class MigrateUserData protected constructor(val source: Directory, val dest } // don't move the "conflict" directory - if (file.name == MoveConflictedFile.CONFLICT_DIRECTORY) { - return false - } - - return true + return file.name != MoveConflictedFile.CONFLICT_DIRECTORY } /** diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/services/ServiceUtils.kt b/AnkiDroid/src/main/java/com/ichi2/anki/services/ServiceUtils.kt index 0065459395d4..c1212236cfff 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/services/ServiceUtils.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/services/ServiceUtils.kt @@ -23,7 +23,6 @@ import android.os.Binder import android.os.IBinder import androidx.annotation.CallSuper import androidx.lifecycle.LifecycleCoroutineScope -import com.ichi2.anki.* import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.cancel diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/workarounds/FullDraggableContainerFix.kt b/AnkiDroid/src/main/java/com/ichi2/anki/workarounds/FullDraggableContainerFix.kt index 88a7f9f694ed..d05828a0705c 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/workarounds/FullDraggableContainerFix.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/workarounds/FullDraggableContainerFix.kt @@ -56,7 +56,7 @@ import com.drakeet.drawer.FullDraggableContainer * and finger travel distance is usually much higher than the usual threshold of about 8 dp.) */ -class FullDraggableContainerFix constructor(context: Context, attrs: AttributeSet? = null) : +class FullDraggableContainerFix(context: Context, attrs: AttributeSet? = null) : FullDraggableContainer(context, attrs) { private var childRequestedNoTouchInterception = false diff --git a/AnkiDroid/src/main/java/com/ichi2/async/CollectionOperations.kt b/AnkiDroid/src/main/java/com/ichi2/async/CollectionOperations.kt index c5c93a8945e8..f156b2e0f724 100644 --- a/AnkiDroid/src/main/java/com/ichi2/async/CollectionOperations.kt +++ b/AnkiDroid/src/main/java/com/ichi2/async/CollectionOperations.kt @@ -170,6 +170,6 @@ fun saveModel( // required for Rust: the modified time can't go backwards, and we updated the model by adding fields // This could be done better notetype.put("mod", oldModel!!.getLong("mod")) - col.notetypes.save(notetype, true) + col.notetypes.save(notetype) col.notetypes.update(notetype) } diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/BackendImportExport.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/BackendImportExport.kt index 9e7201b7f138..e7b76f015b8a 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/BackendImportExport.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/BackendImportExport.kt @@ -82,13 +82,13 @@ fun Collection.exportCollectionPackage( includeMedia: Boolean, legacy: Boolean = true ) { - close(downgrade = false, forFullSync = true) + close(forFullSync = true) backend.exportCollectionPackage( outPath = outPath, includeMedia = includeMedia, legacy = legacy ) - reopen(afterFullSync = false) + reopen() } fun Collection.importAnkiPackageRaw(input: ByteArray): ByteArray { diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/Card.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/Card.kt index 5574a6e16182..c5763d1f1c7a 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/Card.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/Card.kt @@ -281,7 +281,7 @@ open class Card : Cloneable { * *********************************************************** */ fun qSimple(): String { - return renderOutput(false).questionText + return renderOutput().questionText } /* @@ -289,7 +289,7 @@ open class Card : Cloneable { */ val pureAnswer: String get() { - val s = renderOutput(false).answerText + val s = renderOutput().answerText for (target in arrayOf("
", "
")) { val pos = s.indexOf(target) if (pos == -1) continue diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/Tags.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/Tags.kt index 6749de27ac14..78aee46fc589 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/Tags.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/Tags.kt @@ -20,8 +20,7 @@ package com.ichi2.libanki import androidx.annotation.WorkerThread import anki.collection.OpChangesWithCount import com.ichi2.libanki.utils.join -import com.ichi2.libanki.utils.set -import java.util.* +import java.util.AbstractSet /** * Anki maintains a cache of used tags so it can quickly present a list of tags @@ -93,7 +92,7 @@ class Tags(private val col: Collection) { /** {@inheritDoc} */ // this is now a no-op - the tags are canonified when the note is saved - fun canonify(tagList: List): java.util.AbstractSet { + fun canonify(tagList: List): AbstractSet { // libAnki difference: tagList was returned directly return HashSet(tagList) } diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/TemplateManager.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/TemplateManager.kt index 9560fa926b8c..94a51f339e9f 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/TemplateManager.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/TemplateManager.kt @@ -223,15 +223,13 @@ class TemplateManager { aoutText = LaTeX.mungeQA(aoutText, _col, svg) } - val output = TemplateRenderOutput( + return TemplateRenderOutput( questionText = qoutText, answerText = aoutText, questionAvTags = avTagsToNative(qout.avTagsList), answerAvTags = avTagsToNative(aout.avTagsList), css = noteType().getString("css") ) - - return output } fun partiallyRender(): PartiallyRenderedCard { diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/backend/model/SortOrderUtil.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/backend/model/SortOrderUtil.kt index 2c94bda09e0e..0960db594fe3 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/backend/model/SortOrderUtil.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/backend/model/SortOrderUtil.kt @@ -13,9 +13,6 @@ * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ - -@file:Suppress("deprecation") // BuiltinSortKind - is a valid choice - package com.ichi2.libanki.backend.model import com.ichi2.libanki.SortOrder diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/sched/Counts.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/sched/Counts.kt index d1c76eb1537a..652fe9d6ac8a 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/sched/Counts.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/sched/Counts.kt @@ -21,7 +21,7 @@ import androidx.annotation.CheckResult /** * Represents the three counts shown in deck picker and reviewer. Semantically more meaningful than int[] */ -class Counts constructor(var new: Int = 0, var lrn: Int = 0, var rev: Int = 0) { +class Counts(var new: Int = 0, var lrn: Int = 0, var rev: Int = 0) { enum class Queue { NEW, LRN, REV } diff --git a/AnkiDroid/src/main/java/com/ichi2/preferences/IncrementerNumberRangePreferenceCompat.kt b/AnkiDroid/src/main/java/com/ichi2/preferences/IncrementerNumberRangePreferenceCompat.kt index bda61d59fe82..af409ee3f0b2 100644 --- a/AnkiDroid/src/main/java/com/ichi2/preferences/IncrementerNumberRangePreferenceCompat.kt +++ b/AnkiDroid/src/main/java/com/ichi2/preferences/IncrementerNumberRangePreferenceCompat.kt @@ -41,7 +41,7 @@ class IncrementerNumberRangePreferenceCompat : NumberRangePreferenceCompat, Dial @Suppress("unused") constructor(context: Context) : super(context) - class IncrementerNumberRangeDialogFragmentCompat : NumberRangePreferenceCompat.NumberRangeDialogFragmentCompat() { + class IncrementerNumberRangeDialogFragmentCompat : NumberRangeDialogFragmentCompat() { private var mLastValidEntry = 0 /** diff --git a/AnkiDroid/src/main/java/com/ichi2/ui/ButtonItemAdapter.kt b/AnkiDroid/src/main/java/com/ichi2/ui/ButtonItemAdapter.kt index 85be35c097e1..8ce56fb9917e 100644 --- a/AnkiDroid/src/main/java/com/ichi2/ui/ButtonItemAdapter.kt +++ b/AnkiDroid/src/main/java/com/ichi2/ui/ButtonItemAdapter.kt @@ -59,7 +59,7 @@ class ButtonItemAdapter( override fun getItemCount() = items.size - inner class ButtonVH constructor(itemView: View, private val adapter: ButtonItemAdapter) : RecyclerView.ViewHolder(itemView), View.OnClickListener { + inner class ButtonVH(itemView: View, private val adapter: ButtonItemAdapter) : RecyclerView.ViewHolder(itemView), View.OnClickListener { val title: TextView = itemView.findViewById(R.id.card_browser_my_search_name_textview) val button: ImageButton = itemView.findViewById(R.id.card_browser_my_search_remove_button).apply { setOnClickListener(this@ButtonVH) diff --git a/AnkiDroid/src/main/java/com/ichi2/ui/GesturePicker.kt b/AnkiDroid/src/main/java/com/ichi2/ui/GesturePicker.kt index c6cc754a4907..ae5487782d74 100644 --- a/AnkiDroid/src/main/java/com/ichi2/ui/GesturePicker.kt +++ b/AnkiDroid/src/main/java/com/ichi2/ui/GesturePicker.kt @@ -37,8 +37,7 @@ import timber.log.Timber * Current use is via [com.ichi2.anki.dialogs.GestureSelectionDialogBuilder] */ // This class exists as elements resized when adding in the spinner to GestureDisplay.kt -class GesturePicker -constructor(ctx: Context, attributeSet: AttributeSet? = null, defStyleAttr: Int = 0) : +class GesturePicker(ctx: Context, attributeSet: AttributeSet? = null, defStyleAttr: Int = 0) : ConstraintLayout(ctx, attributeSet, defStyleAttr) { private val mGestureSpinner: Spinner @@ -97,9 +96,7 @@ constructor(ctx: Context, attributeSet: AttributeSet? = null, defStyleAttr: Int other as GestureWrapper - if (gesture != other.gesture) return false - - return true + return gesture == other.gesture } override fun hashCode() = gesture?.hashCode() ?: 0 diff --git a/AnkiDroid/src/main/java/com/ichi2/ui/RtlCompliantActionProvider.kt b/AnkiDroid/src/main/java/com/ichi2/ui/RtlCompliantActionProvider.kt index eeb2af2c670e..e549dd0ba32a 100644 --- a/AnkiDroid/src/main/java/com/ichi2/ui/RtlCompliantActionProvider.kt +++ b/AnkiDroid/src/main/java/com/ichi2/ui/RtlCompliantActionProvider.kt @@ -21,7 +21,6 @@ import android.widget.ImageButton import androidx.annotation.VisibleForTesting import androidx.appcompat.widget.TooltipCompat import com.ichi2.anki.ActionProviderCompat -import com.ichi2.anki.R /** * An Rtl version of a normal action view, where the drawable is mirrored diff --git a/AnkiDroid/src/main/java/com/ichi2/utils/LanguageUtil.kt b/AnkiDroid/src/main/java/com/ichi2/utils/LanguageUtil.kt index bf8e0f00256b..894e5f9f8a48 100644 --- a/AnkiDroid/src/main/java/com/ichi2/utils/LanguageUtil.kt +++ b/AnkiDroid/src/main/java/com/ichi2/utils/LanguageUtil.kt @@ -26,7 +26,8 @@ import com.ichi2.anki.AnkiDroidApp import com.ichi2.anki.preferences.sharedPrefs import net.ankiweb.rsdroid.BackendFactory import java.text.DateFormat -import java.util.* +import java.util.Date +import java.util.Locale /** * Utility call for proving language related functionality. diff --git a/AnkiDroid/src/main/java/com/ichi2/utils/NetworkUtils.kt b/AnkiDroid/src/main/java/com/ichi2/utils/NetworkUtils.kt index 28b979bd6d09..4b7a7f6c7b86 100644 --- a/AnkiDroid/src/main/java/com/ichi2/utils/NetworkUtils.kt +++ b/AnkiDroid/src/main/java/com/ichi2/utils/NetworkUtils.kt @@ -41,7 +41,7 @@ object NetworkUtils { /** * @return whether is possible to access the internet */ - @Suppress("DEPRECATION") // activeNetworkInfo deprecation, only used for SDK < 23 + // activeNetworkInfo deprecation, only used for SDK < 23 val isOnline: Boolean get() { val cm = connectivityManager ?: return false diff --git a/api/src/main/java/com/ichi2/anki/api/AddContentApi.kt b/api/src/main/java/com/ichi2/anki/api/AddContentApi.kt index 0f78e37ee187..a49f43342205 100644 --- a/api/src/main/java/com/ichi2/anki/api/AddContentApi.kt +++ b/api/src/main/java/com/ichi2/anki/api/AddContentApi.kt @@ -541,7 +541,6 @@ public class AddContentApi(context: Context) { * * @return the spec version number or -1 if AnkiDroid is not installed. */ - @Suppress("deprecation") // API33 symbol required until minSdkVersion >= 33 public val apiHostSpecVersion: Int get() { // PackageManager#resolveContentProvider docs suggest flags should be 0 (but that gives null metadata) @@ -767,7 +766,6 @@ public class AddContentApi(context: Context) { * @param context a Context that can be used to get the PackageManager * @return packageId of AnkiDroid if a supported version is not installed, otherwise null */ - @Suppress("deprecation") // deprecated symbol until minSdkVersion >= 33 @JvmStatic // required for API public fun getAnkiDroidPackageName(context: Context): String? { val manager = context.packageManager