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

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
This commit is contained in:
David Allison 2022-09-05 01:03:09 +01:00 committed by Mike Hardy
parent 76ffedfed8
commit 3e07d87ff8
221 changed files with 47 additions and 497 deletions

View File

@ -1296,7 +1296,7 @@ class ContentProviderTest : InstrumentedTest() {
companion object {
@Parameterized.Parameters
@JvmStatic
@JvmStatic // required for initParameters
fun initParameters(): Collection<Array<Any>> {
// This does one run with schedVersion injected as 1, and one run as 2
return Arrays.asList(*arrayOf(arrayOf(1), arrayOf(2)))

View File

@ -49,7 +49,6 @@ abstract class InstrumentedTest {
* https://github.com/react-native-community/react-native-device-info/blob/bb505716ff50e5900214fcbcc6e6434198010d95/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java#L185
* @return boolean true if the execution environment is most likely an emulator
*/
@JvmStatic
fun isEmulator(): Boolean {
return (
Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic") ||

View File

@ -83,7 +83,7 @@ class LayoutValidationTest : InstrumentedTest() {
InvocationTargetException::class,
InstantiationException::class
)
@JvmStatic
@JvmStatic // required for initParameters
fun initParameters(): Collection<Array<Any>> {
val ctor: Constructor<*> = com.ichi2.anki.R.layout::class.java.declaredConstructors[0]
ctor.isAccessible = true // Required for at least API 16, maybe later.

View File

@ -48,7 +48,6 @@ object DatabaseUtils {
* @param positionParam The start position for filling the window.
* @param window The window to fill.
*/
@JvmStatic
fun cursorFillWindow(
cursor: Cursor,
positionParam: Int,

View File

@ -29,7 +29,6 @@ class MockReviewerUi : ReviewerUi {
}
companion object {
@JvmStatic
fun displayingAnswer(): ReviewerUi {
val mockReviewerUi = MockReviewerUi()
mockReviewerUi.isDisplayingAnswer = true

View File

@ -18,7 +18,6 @@ package com.ichi2.anki.testutil
import java.util.*
object TestEnvironment {
@JvmStatic
fun isDisplayingDefaultEnglishStrings(): Boolean {
return "en-US" == Locale.getDefault().toLanguageTag()
}

View File

@ -16,7 +16,6 @@
package com.ichi2.anki.testutil
object ThreadUtils {
@JvmStatic
fun sleep(timeMs: Int) {
try {
Thread.sleep(timeMs.toLong())

View File

@ -11,7 +11,6 @@ import com.ichi2.anki.R
import kotlinx.parcelize.Parcelize
object ActivityTransitionAnimation {
@JvmStatic
fun slide(activity: Activity, direction: Direction?) {
when (direction) {
Direction.START -> if (isRightToLeft(activity)) {
@ -38,7 +37,6 @@ object ActivityTransitionAnimation {
}
}
@JvmStatic
fun getAnimationOptions(activity: Activity, direction: Direction?): ActivityOptionsCompat {
return when (direction) {
Direction.START -> if (isRightToLeft(activity)) ActivityOptionsCompat.makeCustomAnimation(activity, R.anim.slide_right_in, R.anim.slide_right_out) else ActivityOptionsCompat.makeCustomAnimation(activity, R.anim.slide_left_in, R.anim.slide_left_out)

View File

@ -80,7 +80,6 @@ object ViewAnimation {
FADE_IN(0f),
FADE_OUT(1f);
}
@JvmStatic
fun fade(type: Fade, duration: Int, offset: Int) =
AlphaAnimation(type.originalAlpha, 1.0f - type.originalAlpha).apply {
this.duration = duration.toLong()

View File

@ -2198,7 +2198,6 @@ abstract class AbstractFlashcardViewer :
const val ANSWER_ORDINAL_2 = 6
const val ANSWER_ORDINAL_3 = 7
const val ANSWER_ORDINAL_4 = 8
@JvmStatic
fun getSignalFromUrl(url: String): Int {
when (url) {
"signal:typefocus" -> return TYPE_FOCUS
@ -2635,7 +2634,6 @@ abstract class AbstractFlashcardViewer :
const val INITIAL_HIDE_DELAY = 200
// I don't see why we don't do this by intent.
/** to be sent to and from the card editor */
@JvmStatic
@set:VisibleForTesting(otherwise = VisibleForTesting.NONE)
var editorCard: Card? = null
@JvmField

View File

@ -315,7 +315,6 @@ open class AnkiDroidApp : Application() {
// Singleton instance of this class.
// Note: this may not be initialized if AnkiDroid is run via BackupManager
@KotlinCleanup("replace comment with javadoc")
@JvmStatic
lateinit var instance: AnkiDroidApp
private set
@ -369,14 +368,12 @@ open class AnkiDroidApp : Application() {
* @return A SharedPreferences object for this instance of the app.
*/
@Suppress("deprecation") // TODO Tracked in https://github.com/ankidroid/Anki-Android/issues/5019
@JvmStatic
fun getSharedPrefs(context: Context?): SharedPreferences {
return android.preference.PreferenceManager.getDefaultSharedPreferences(context)
}
val cacheStorageDirectory: String
get() = instance.cacheDir.absolutePath
@JvmStatic
val appResources: Resources
get() = instance.resources
val isSdCardMounted: Boolean
@ -389,7 +386,6 @@ open class AnkiDroidApp : Application() {
* @param remoteContext The base context offered by attachBase() to be passed to super.attachBase().
* Can be modified here to set correct GUI language.
*/
@JvmStatic
fun updateContextWithLanguage(remoteContext: Context): Context {
return try {
val preferences: SharedPreferences

View File

@ -59,7 +59,6 @@ class AnkiFont private constructor(val name: String, private val family: String,
* @param fromAssets True if the font is to be found in assets of application
* @return A new AnkiFont object or null if the file can't be interpreted as typeface.
*/
@JvmStatic
fun createAnkiFont(ctx: Context, filePath: String, fromAssets: Boolean): AnkiFont? {
var path = filePath
val fontFile = File(path)
@ -114,7 +113,6 @@ class AnkiFont private constructor(val name: String, private val family: String,
return createdFont
}
@JvmStatic
fun getTypeface(ctx: Context, path: String): Typeface? {
return try {
if (path.startsWith(fAssetPathPrefix)) {

View File

@ -26,7 +26,6 @@ object AnkiSerialization {
/**
* @return singleton of {@link ObjectMapper} used to bind json to java classes
*/
@JvmStatic
val objectMapper: ObjectMapper by lazy {
ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
}
@ -34,7 +33,6 @@ object AnkiSerialization {
/**
* @return singleton of {@link JsonFactory} used for json stream processing
*/
@JvmStatic
val factory: JsonFactory
get() = objectMapper.factory
}

View File

@ -197,7 +197,6 @@ open class BackupManager {
val isActivated: Boolean
get() = true
@JvmStatic
fun getBackupDirectory(ankidroidDir: File): File {
val directory = File(ankidroidDir, BACKUP_SUFFIX)
if (!directory.isDirectory && !directory.mkdirs()) {
@ -218,7 +217,6 @@ open class BackupManager {
return directory
}
@JvmStatic
fun performBackupInBackground(path: String, time: Time): Boolean {
return BackupManager().performBackupInBackground(path, BACKUP_INTERVAL, time)
}
@ -232,7 +230,6 @@ open class BackupManager {
return colFile.length() + MIN_FREE_SPACE * 1024 * 1024
}
@JvmStatic
fun enoughDiscSpace(path: String?): Boolean {
return getFreeDiscSpace(path) >= MIN_FREE_SPACE * 1024 * 1024
}
@ -255,7 +252,6 @@ open class BackupManager {
* @param col Collection
* @return whether the repair was successful
*/
@JvmStatic
fun repairCollection(col: Collection): Boolean {
val deckPath = col.path
val deckFile = File(deckPath)
@ -336,7 +332,6 @@ open class BackupManager {
* @param fileName String with pattern "collection-yyyy-MM-dd-HH-mm.colpkg"
* @return Its dateformat parsable string or null if it doesn't match naming pattern
*/
@JvmStatic
fun getBackupTimeString(fileName: String): String? {
return backupNameRegex.matchEntire(fileName)?.groupValues?.get(1)
}
@ -344,7 +339,6 @@ open class BackupManager {
/**
* @return date in string if it matches backup naming pattern or null if not
*/
@JvmStatic
fun parseBackupTimeString(timeString: String): Date? {
return try {
legacyDateFormat.parse(timeString)
@ -360,7 +354,6 @@ open class BackupManager {
/**
* @return date in fileName if it matches backup naming pattern or null if not
*/
@JvmStatic
fun getBackupDate(fileName: String): Date? {
return getBackupTimeString(fileName)?.let { parseBackupTimeString(it) }
}
@ -368,7 +361,6 @@ open class BackupManager {
/**
* @return filename with pattern collection-yyyy-MM-dd-HH-mm based on given time parameter
*/
@JvmStatic
fun getNameForNewBackup(time: Time): String? {
/** Changes in the file name pattern should be updated as well in
* [getBackupTimeString] and [com.ichi2.anki.dialogs.DatabaseErrorDialog.onCreateDialog] */
@ -382,7 +374,6 @@ open class BackupManager {
return backupFilename
}
@JvmStatic
/**
* @return Array of files with names which matches the backup name pattern,
* in order of creation.
@ -405,7 +396,6 @@ open class BackupManager {
*
* @return the most recent backup, or null if no backups exist
*/
@JvmStatic
fun getLatestBackup(colFile: File): File? = getBackups(colFile).lastOrNull()
/**
@ -413,7 +403,6 @@ open class BackupManager {
* @param colPath Path of collection file whose backups should be deleted
* @param keepNumber How many files to keep
*/
@JvmStatic
fun deleteDeckBackups(colPath: String, keepNumber: Int): Boolean {
return deleteDeckBackups(getBackups(File(colPath)), keepNumber)
}
@ -429,7 +418,6 @@ open class BackupManager {
return true
}
@JvmStatic
fun removeDir(dir: File): Boolean {
if (dir.isDirectory) {
val files = dir.listFiles()
@ -440,7 +428,6 @@ open class BackupManager {
return dir.delete()
}
@JvmStatic
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
fun createInstance(): BackupManager {
return BackupManager()

View File

@ -2660,7 +2660,6 @@ open class CardBrowser :
private const val LAST_DECK_ID_KEY = "lastDeckId"
const val CARD_NOT_AVAILABLE = -1
@KotlinCleanup(".edit { }")
@JvmStatic
fun clearLastDeckId() {
val context: Context = AnkiDroidApp.instance
context.getSharedPreferences(PERSISTENT_STATE_FILE, 0).edit().remove(LAST_DECK_ID_KEY).apply()
@ -2681,7 +2680,6 @@ open class CardBrowser :
* @param showFileNames Whether [sound:foo.mp3] should be rendered as " foo.mp3 " or " "
* @return The formatted string
*/
@JvmStatic
@VisibleForTesting
@CheckResult
fun formatQAInternal(txt: String, showFileNames: Boolean): String {

View File

@ -292,7 +292,6 @@ class CardInfo : AnkiActivity() {
}
companion object {
@JvmStatic
@CheckResult
fun create(c: Card, collection: Collection): CardInfoModel {
val addedDate = c.id

View File

@ -183,7 +183,6 @@ class CardTemplateBrowserAppearanceEditor : AnkiActivity() {
}
companion object {
@JvmStatic
@Contract("null -> null")
fun fromIntent(intent: Intent?): Result? {
return if (intent == null) {
@ -206,7 +205,6 @@ class CardTemplateBrowserAppearanceEditor : AnkiActivity() {
/** Specified the card browser should use the default template formatter */
const val VALUE_USE_DEFAULT = ""
@JvmStatic
@CheckResult
fun getIntentFromTemplate(context: Context, template: JSONObject): Intent {
val browserQuestionTemplate = template.getString("bqfmt")

View File

@ -14,7 +14,6 @@ object CardUtils {
/**
* @return List of corresponding notes without duplicates, even if the input list has multiple cards of the same note.
*/
@JvmStatic
fun getNotes(cards: Collection<Card>): Set<Note> {
val notes: MutableSet<Note> = HashSetInit(cards.size)
for (card in cards) {
@ -26,7 +25,6 @@ object CardUtils {
/**
* @return All cards of all notes
*/
@JvmStatic
fun getAllCards(notes: Set<Note>): List<Card> {
val allCards: MutableList<Card> = ArrayList(notes.size)
for (note in notes) {
@ -35,7 +33,6 @@ object CardUtils {
return allCards
}
@JvmStatic
fun markAll(notes: List<Note>, mark: Boolean) {
for (note in notes) {
if (mark) {

View File

@ -282,7 +282,6 @@ open class CollectionHelper {
}
companion object {
@JvmStatic
var instance: CollectionHelper = CollectionHelper()
private set

View File

@ -235,7 +235,6 @@ object CollectionManager {
}
}
@JvmStatic
fun closeCollectionBlocking(save: Boolean = true) {
runBlocking { ensureClosed(save = save) }
}
@ -246,7 +245,6 @@ object CollectionManager {
* the collection while the reference is held. [withCol]
* is a better alternative.
*/
@JvmStatic
fun getColUnsafe(): Collection {
return logUIHangs {
blockForQueue {
@ -293,7 +291,6 @@ object CollectionManager {
/**
* True if the collection is open. Unsafe, as it has the potential to race.
*/
@JvmStatic
fun isOpenUnsafe(): Boolean {
return logUIHangs {
blockForQueue {
@ -310,7 +307,6 @@ object CollectionManager {
Use [col] as collection in tests.
This collection persists only up to the next (direct or indirect) call to `ensureClosed`
*/
@JvmStatic
fun setColForTests(col: Collection?) {
blockForQueue {
if (col == null) {

View File

@ -57,7 +57,6 @@ object CrashReportService {
* Temporary method to access the CoreConfigurationBuilder until all classes that require access
* to the CoreConfigurationBuilder are migrated to kotlin.
*/
@JvmStatic
@KotlinCleanup("once EVERY class using this method gets migrated to kotlin remove it and expose mAcraCoreConfigBuilder with a private setter")
fun getAcraCoreConfigBuilder(): CoreConfigurationBuilder {
return mAcraCoreConfigBuilder
@ -68,7 +67,6 @@ object CrashReportService {
* The ACRA process needs a WebView for optimal UsageAnalytics values but it can't have the same
* data directory. Analytics falls back to a sensible default if this is not set.
*/
@JvmStatic
fun initialize(application: Application) {
mApplication = application
// Setup logging and crash reporting
@ -141,7 +139,6 @@ object CrashReportService {
* Set the reporting mode for ACRA based on the value of the FEEDBACK_REPORT_KEY preference
* @param value value of FEEDBACK_REPORT_KEY preference
*/
@JvmStatic
fun setAcraReportingMode(value: String) {
val editor = AnkiDroidApp.getSharedPrefs(mApplication).edit()
// Set the ACRA disable value
@ -171,7 +168,6 @@ object CrashReportService {
*
* @param prefs SharedPreferences object the reporting state is persisted in
*/
@JvmStatic
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
fun setDebugACRAConfig(prefs: SharedPreferences) {
// Disable crash reporting
@ -187,7 +183,6 @@ object CrashReportService {
*
* @param prefs SharedPreferences object the reporting state is persisted in
*/
@JvmStatic
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
fun setProductionACRAConfig(prefs: SharedPreferences) {
// Enable or disable crash reporting based on user setting
@ -224,22 +219,18 @@ object CrashReportService {
}
/** Used when we don't have an exception to throw, but we know something is wrong and want to diagnose it */
@JvmStatic
fun sendExceptionReport(message: String?, origin: String?) {
sendExceptionReport(ManuallyReportedException(message), origin, null)
}
@JvmStatic
fun sendExceptionReport(e: Throwable, origin: String?) {
sendExceptionReport(e, origin, null)
}
@JvmStatic
fun sendExceptionReport(e: Throwable, origin: String?, additionalInfo: String?) {
sendExceptionReport(e, origin, additionalInfo, false)
}
@JvmStatic
fun sendExceptionReport(e: Throwable, origin: String?, additionalInfo: String?, onlyIfSilent: Boolean) {
sendAnalyticsException(e, false)
AnkiDroidApp.sentExceptionReportHack = true
@ -255,12 +246,10 @@ object CrashReportService {
ACRA.getErrorReporter().handleException(e)
}
@JvmStatic
fun isProperServiceProcess(): Boolean {
return ACRA.isACRASenderServiceProcess()
}
@JvmStatic
fun isAcraEnabled(context: Context, defaultValue: Boolean): Boolean {
if (!AnkiDroidApp.getSharedPrefs(context).contains(ACRA.PREF_DISABLE_ACRA)) {
// we shouldn't use defaultValue below, as it would be inverted which complicated understanding.
@ -275,7 +264,6 @@ object CrashReportService {
*
* @param context the context leading to the directory with ACRA limiter data
*/
@JvmStatic
fun deleteACRALimiterData(context: Context) {
try {
LimiterData().store(context)
@ -284,7 +272,6 @@ object CrashReportService {
}
}
@JvmStatic
fun onPreferenceChanged(ctx: Context, newValue: String) {
setAcraReportingMode(newValue)
// If the user changed error reporting, make sure future reports have a chance to post
@ -297,7 +284,6 @@ object CrashReportService {
* @return the status of the report, true if the report was sent, false if the report is already
* submitted
*/
@JvmStatic
fun sendReport(ankiActivity: AnkiActivity): Boolean {
val preferences = AnkiDroidApp.getSharedPrefs(ankiActivity)
val reportMode = preferences.getString(FEEDBACK_REPORT_KEY, "")

View File

@ -27,7 +27,6 @@ import timber.log.Timber
/** Utilities for launching the first activity (currently the DeckPicker) */
object InitialActivity {
/** Returns null on success */
@JvmStatic
@CheckResult
fun getStartupFailureType(context: Context): StartupFailure? {
@ -59,7 +58,6 @@ object InitialActivity {
/** @return Whether any preferences were upgraded
*/
@JvmStatic
fun upgradePreferences(context: Context?, previousVersionCode: Long): Boolean {
return PreferenceUpgradeService.upgradePreferences(context, previousVersionCode)
}
@ -76,7 +74,6 @@ object InitialActivity {
* in practice, this doesn't occur due to CollectionHelper.getCol creating a new collection, and it's called before
* this in the startup script
*/
@JvmStatic
@CheckResult
fun performSetupFromFreshInstallOrClearedPreferences(preferences: SharedPreferences): Boolean {
if (!wasFreshInstall(preferences)) {
@ -98,7 +95,6 @@ object InitialActivity {
"" == preferences.getString("lastVersion", "")
/** Sets the preference stating that the latest version has been applied */
@JvmStatic
fun setUpgradedToLatestVersion(preferences: SharedPreferences) {
Timber.i("Marked prefs as upgraded to latest version: %s", pkgVersionName)
preferences.edit().putString("lastVersion", pkgVersionName).apply()
@ -109,7 +105,6 @@ object InitialActivity {
* This is not called in the case of performSetupFromFreshInstall returning true.
* So this should not use the default value
*/
@JvmStatic
fun isLatestVersion(preferences: SharedPreferences): Boolean {
return preferences.getString("lastVersion", "") == pkgVersionName
}

View File

@ -149,7 +149,6 @@ class IntentHandler : Activity() {
return !isInvalidViewIntent(intent)
}
@JvmStatic
@VisibleForTesting
@CheckResult
fun getLaunchType(intent: Intent): LaunchType {

View File

@ -28,7 +28,6 @@ object LanguageUtils {
* Returns a Locale object constructed from an empty string if the input string is null, empty
* or contains more than 3 fields separated by underscores.
*/
@JvmStatic
fun localeFromStringIgnoringScriptAndExtensions(localeCodeStr: String): Locale {
val localeCode = stripScriptAndExtensions(localeCodeStr)
val fields = localeCode.split("_".toRegex()).toTypedArray()

View File

@ -27,7 +27,6 @@ object LeakCanaryConfiguration {
/**
* Disable LeakCanary.
*/
@JvmStatic
fun disable() {
config = config.copy(
dumpHeap = false,
@ -42,7 +41,6 @@ object LeakCanaryConfiguration {
* Sets the initial configuration for LeakCanary. This method can be used to match known library
* leaks or leaks which have been already reported previously.
*/
@JvmStatic
fun setInitialConfigFor(application: Application, knownMemoryLeaks: List<ReferenceMatcher> = emptyList()) {
config = config.copy(referenceMatchers = AndroidReferenceMatchers.appDefaults + knownMemoryLeaks)
// AppWatcher manual install if not already installed

View File

@ -22,7 +22,6 @@ import android.content.res.Resources
import com.ichi2.compat.CompatHelper
object NotificationChannels {
@JvmStatic
fun getId(channel: Channel?): String {
return when (channel) {
Channel.SYNC -> "Synchronization"
@ -49,7 +48,6 @@ object NotificationChannels {
* TODO should be called in response to {@link android.content.Intent#ACTION_LOCALE_CHANGED}
* @param context the context for access to localized strings for channel names
*/
@JvmStatic
fun setup(context: Context) {
val res = context.resources
val compat = CompatHelper.compat

View File

@ -38,7 +38,6 @@ import java.util.*
object ReadText {
@get:VisibleForTesting(otherwise = VisibleForTesting.NONE)
@get:JvmStatic
var textToSpeech: TextToSpeech? = null
private set
private val availableTtsLocales = ArrayList<Locale>()
@ -245,7 +244,6 @@ object ReadText {
TextToSpeech.LANG_AVAILABLE
}
@JvmStatic
fun initializeTts(context: Context, listener: ReadTextListener) {
// Store weak reference to Activity to prevent memory leak
flashCardViewer = WeakReference(context)
@ -321,7 +319,6 @@ object ReadText {
* No-op if the current instance of TextToSpeech was initialized by another Context
* @param context The context used during [.initializeTts]
*/
@JvmStatic
fun releaseTts(context: Context) {
if (textToSpeech != null && flashCardViewer.get() === context) {
textToSpeech!!.stop()
@ -329,14 +326,12 @@ object ReadText {
}
}
@JvmStatic
fun stopTts() {
if (textToSpeech != null) {
textToSpeech!!.stop()
}
}
@JvmStatic
fun closeForTests() {
if (textToSpeech != null) {
textToSpeech!!.shutdown()

View File

@ -714,7 +714,6 @@ class StudyOptionsFragment : Fragment(), Toolbar.OnMenuItemClickListener {
* which shows the current deck's options. Set to true when programmatically
* opening a new filtered deck for the first time.
*/
@JvmStatic
fun newInstance(withDeckOptions: Boolean): StudyOptionsFragment {
val f = StudyOptionsFragment()
val args = Bundle()
@ -723,7 +722,6 @@ class StudyOptionsFragment : Fragment(), Toolbar.OnMenuItemClickListener {
return f
}
@JvmStatic
@VisibleForTesting
fun formatDescription(desc: String?): Spanned {
// #5715: In deck description, ignore what is in style and script tag

View File

@ -315,7 +315,6 @@ class TemporaryModel(model: Model) {
* @param bundle a Bundle that should contain persisted JSON under INTENT_MODEL_FILENAME key
* @return re-hydrated TemporaryModel or null if there was a problem, null means should reload from database
*/
@JvmStatic
fun fromBundle(bundle: Bundle): TemporaryModel? {
val editedModelFileName = bundle.getString(INTENT_MODEL_FILENAME)
// Bundle.getString is @Nullable, so we have to check.
@ -339,7 +338,6 @@ class TemporaryModel(model: Model) {
* Save the current model to a temp file in the application internal cache directory
* @return String representing the absolute path of the saved file, or null if there was a problem
*/
@JvmStatic
fun saveTempModel(context: Context, tempModel: JSONObject): String? {
Timber.d("saveTempModel() saving tempModel")
var tempModelFile: File
@ -360,7 +358,6 @@ class TemporaryModel(model: Model) {
* @return JSONObject holding the model, or null if there was a problem
*/
@Throws(IOException::class)
@JvmStatic
fun getTempModel(tempModelFileName: String): Model {
Timber.d("getTempModel() fetching tempModel %s", tempModelFileName)
try {
@ -377,7 +374,6 @@ class TemporaryModel(model: Model) {
/** Clear any temp model files saved into internal cache directory */
@Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
@KotlinCleanup("handle the nullability issue of listing files from cache dir")
@JvmStatic
fun clearTempModelFiles(): Int {
var deleteCount = 0
for (c in AnkiDroidApp.instance.cacheDir.listFiles()) {
@ -400,7 +396,6 @@ class TemporaryModel(model: Model) {
* @param ord int representing an ordinal in the model, that might be an unsaved addition
* @return boolean true if it is a pending addition from this editing session
*/
@JvmStatic
fun isOrdinalPendingAdd(model: TemporaryModel, ord: Int): Boolean {
for (i in model.templateChanges.indices) {
// commented out to make the code compile, why is this unused?

View File

@ -22,7 +22,6 @@ object TtsParser {
* elements; in that case the function returns a single LocalisedText object containing the
* text extracted from the whole HTML fragment, with the localeCode set to an empty string.
*/
@JvmStatic
fun getTextsToRead(html: String, clozeReplacement: String): List<TTSTag> {
val textsToRead: MutableList<TTSTag> = ArrayList()
val elem = Jsoup.parseBodyFragment(html).body()

View File

@ -14,27 +14,22 @@ import timber.log.Timber
import java.util.*
object UIUtils {
@JvmStatic
fun showThemedToast(context: Context?, text: String?, shortLength: Boolean) {
Toast.makeText(context, text, if (shortLength) Toast.LENGTH_SHORT else Toast.LENGTH_LONG).show()
}
@JvmStatic
fun showThemedToast(context: Context?, text: CharSequence?, shortLength: Boolean) {
showThemedToast(context, text.toString(), shortLength)
}
@JvmStatic
fun showThemedToast(context: Context?, @StringRes textResource: Int, shortLength: Boolean) {
Toast.makeText(context, textResource, if (shortLength) Toast.LENGTH_SHORT else Toast.LENGTH_LONG).show()
}
@JvmStatic
fun getDensityAdjustedValue(context: Context, value: Float): Float {
return context.resources.displayMetrics.density * value
}
@JvmStatic
fun getDayStart(time: Time): Long {
val cal = time.calendar()
if (cal[Calendar.HOUR_OF_DAY] < 4) {
@ -47,7 +42,6 @@ object UIUtils {
return cal.timeInMillis
}
@JvmStatic
fun saveCollectionInBackground(syncIgnoresDatabaseModification: Boolean = false) {
if (CollectionHelper.instance.colIsOpen()) {
val listener: TaskListener<Void?, Void?> = object : TaskListener<Void?, Void?>() {
@ -70,7 +64,6 @@ object UIUtils {
* @param context Context to get resources and device specific display metrics.
* @return A float value to represent px value which is equivalent to the passed dp value.
*/
@JvmStatic
fun convertDpToPixel(dp: Float, context: Context): Float {
return dp * (context.resources.displayMetrics.densityDpi.toFloat() / DisplayMetrics.DENSITY_DEFAULT)
}

View File

@ -517,7 +517,6 @@ class Whiteboard(activity: AnkiActivity, handleMultiTouch: Boolean, inverted: Bo
companion object {
private const val TOUCH_TOLERANCE = 4f
private var mWhiteboardMultiTouchMethods: WhiteboardMultiTouchMethods? = null
@JvmStatic
fun createInstance(context: AnkiActivity, handleMultiTouch: Boolean, whiteboardMultiTouchMethods: WhiteboardMultiTouchMethods?): Whiteboard {
val whiteboard = Whiteboard(context, handleMultiTouch, currentTheme.isNightMode)
mWhiteboardMultiTouchMethods = whiteboardMultiTouchMethods

View File

@ -53,7 +53,6 @@ object UsageAnalytics {
*
* @param context required to look up the analytics codes for the app
*/
@JvmStatic
@Synchronized
fun initialize(context: Context): GoogleAnalytics? {
Timber.i("initialize()")
@ -165,7 +164,6 @@ object UsageAnalytics {
*
* @param dryRun set to true if you want to log analytics hit but not dispatch
*/
@JvmStatic
@Synchronized
fun setDryRun(dryRun: Boolean) {
Timber.i("setDryRun(): %s, warning dryRun is experimental", dryRun)
@ -192,7 +190,6 @@ object UsageAnalytics {
* @param object the result of Object.getClass().getSimpleName() will be used as the screen tag
*/
@KotlinCleanup("rename object")
@JvmStatic
fun sendAnalyticsScreenView(`object`: Any) {
sendAnalyticsScreenView(`object`.javaClass.simpleName)
}
@ -218,7 +215,6 @@ object UsageAnalytics {
* @param action the action the user performed
*/
@KotlinCleanup("remove when all callers are Kotlin")
@JvmStatic
fun sendAnalyticsEvent(category: String, action: String) {
sendAnalyticsEvent(category, action, Integer.MIN_VALUE, null)
}
@ -231,7 +227,6 @@ object UsageAnalytics {
* @param value A value for the event, Integer.MIN_VALUE signifies caller shouldn't send the value
* @param label A label for the event, may be null
*/
@JvmStatic
fun sendAnalyticsEvent(category: String, action: String, value: Int = Int.MIN_VALUE, label: String? = null) {
Timber.d("sendAnalyticsEvent() category/action/value/label: %s/%s/%s/%s", category, action, value, label)
if (!optIn) {
@ -253,12 +248,10 @@ object UsageAnalytics {
* @param t Throwable to send for analysis
* @param fatal whether it was fatal or not
*/
@JvmStatic
fun sendAnalyticsException(t: Throwable, fatal: Boolean) {
sendAnalyticsException(getCause(t).toString(), fatal)
}
@JvmStatic
@KotlinCleanup("convert to sequence")
fun getCause(t: Throwable): Throwable {
var cause: Throwable?
@ -308,7 +301,6 @@ object UsageAnalytics {
.apply()
}
@JvmStatic
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
fun resetForTests() {
sAnalytics = null

View File

@ -77,7 +77,6 @@ class CardAppearance(private val customFonts: ReviewerCustomFonts, private val c
companion object {
private val nightModeClassRegex = Regex("\\.night(?:_m|M)ode\\b")
@JvmStatic
fun create(customFonts: ReviewerCustomFonts, preferences: SharedPreferences): CardAppearance {
val cardZoom = preferences.getInt("cardZoom", 100)
val imageZoom = preferences.getInt("imageZoom", 100)
@ -85,7 +84,6 @@ class CardAppearance(private val customFonts: ReviewerCustomFonts, private val c
return CardAppearance(customFonts, cardZoom, imageZoom, centerVertically)
}
@JvmStatic
fun fixBoldStyle(content: String): String {
// In order to display the bold style correctly, we have to change
// font-weight to 700

View File

@ -201,7 +201,6 @@ class CardHtml(
* @param answerContent The content from which to remove front side audio.
* @return The content stripped of audio due to {{FrontSide}} inclusion.
*/
@JvmStatic
fun removeFrontSideAudio(card: Card, answerContent: String): String {
val answerFormat = getAnswerFormat(card)
var newAnswerContent = answerContent
@ -216,7 +215,6 @@ class CardHtml(
return newAnswerContent
}
@JvmStatic
fun legacyGetTtsTags(card: Card, cardSide: Sound.SoundSide, context: Context): List<TTSTag>? {
val cardSideContent: String = when {
Sound.SoundSide.QUESTION == cardSide -> card.q(true)

View File

@ -83,7 +83,6 @@ enum class TapGestureMode {
NINE_POINT;
companion object {
@JvmStatic
fun fromPreference(preferences: SharedPreferences): TapGestureMode =
when (preferences.getBoolean("gestureCornerTouch", false)) {
true -> NINE_POINT

View File

@ -52,7 +52,6 @@ class HtmlGenerator(
}
companion object {
@JvmStatic
fun createInstance(context: Context, typeAnswer: TypeAnswer, baseUrl: String): HtmlGenerator {
val preferences = AnkiDroidApp.getSharedPrefs(context)
val cardAppearance = CardAppearance.create(ReviewerCustomFonts(context), preferences)

View File

@ -74,7 +74,6 @@ class PreviewLayout(
}
companion object {
@JvmStatic
fun createAndDisplay(activity: AnkiActivity, toggleAnswerHandler: View.OnClickListener): PreviewLayout {
val buttonsLayout = activity.findViewById<FrameLayout>(R.id.preview_buttons_layout)
val prevCard = activity.findViewById<ImageView>(R.id.preview_previous_flashcard)

View File

@ -46,7 +46,6 @@ class SoundPlayer {
class CardSoundConfig(val replayQuestion: Boolean, val autoplay: Boolean) {
companion object {
@JvmStatic
fun create(col: Collection, card: Card): CardSoundConfig {
val deckConfig = col.decks.confForDid(CardUtils.getDeckIdForCard(card))

View File

@ -231,7 +231,6 @@ class TypeAnswer(
/** Regular expression in card data for a 'type answer' after processing has occurred */
val PATTERN: Pattern = Pattern.compile("\\[\\[type:(.+?)]]")
@JvmStatic
fun createInstance(preferences: SharedPreferences): TypeAnswer {
return TypeAnswer(
useInputTag = preferences.getBoolean("useInputTag", false),
@ -250,7 +249,6 @@ class TypeAnswer(
* @param answer The content of the field the text typed by the user is compared to.
* @return The correct answer text, with actual HTML and media references removed, and HTML entities unescaped.
*/
@JvmStatic
fun cleanCorrectAnswer(answer: String?): String {
if (answer.isNullOrEmpty()) return ""

View File

@ -22,7 +22,6 @@ class AnkiCardContextMenu(context: Context) : SystemContextMenu(context) {
get() = "com.ichi2.anki.AnkiCardContextMenuAction"
companion object {
@JvmStatic
fun ensureConsistentStateWithPreferenceStatus(context: Context, preferenceStatus: Boolean) {
AnkiCardContextMenu(context).ensureConsistentStateWithPreferenceStatus(preferenceStatus)
}

View File

@ -22,7 +22,6 @@ class CardBrowserContextMenu(context: Context) : SystemContextMenu(context) {
get() = "com.ichi2.anki.CardBrowserContextMenuAction"
companion object {
@JvmStatic
fun ensureConsistentStateWithPreferenceStatus(context: Context, preferenceStatus: Boolean) {
CardBrowserContextMenu(context).ensureConsistentStateWithPreferenceStatus(preferenceStatus)
}

View File

@ -102,7 +102,7 @@ class CardBrowserMySearchesDialog : AnalyticsDialogFragment() {
const val CARD_BROWSER_MY_SEARCHES_TYPE_LIST = 0 // list searches dialog
const val CARD_BROWSER_MY_SEARCHES_TYPE_SAVE = 1 // save searches dialog
private var mySearchesDialogListener: MySearchesDialogListener? = null
@JvmStatic
fun newInstance(
savedFilters: HashMap<String, String>?,
mySearchesDialogListener: MySearchesDialogListener?,

View File

@ -56,7 +56,7 @@ class CardBrowserOrderDialog : AnalyticsDialogFragment() {
companion object {
private var orderSingleChoiceDialogListener: SingleChoiceListener = null
@JvmStatic
fun newInstance(
order: Int,
isOrderAsc: Boolean,

View File

@ -455,7 +455,6 @@ class DatabaseErrorDialog : AsyncDialogFragment() {
*
* @param dialogType An integer which specifies which of the sub-dialogs to show
*/
@JvmStatic
fun newInstance(dialogType: Int): DatabaseErrorDialog {
val f = DatabaseErrorDialog()
val args = Bundle()

View File

@ -42,7 +42,6 @@ class DeckPickerAnalyticsOptInDialog : AnalyticsDialogFragment() {
}
companion object {
@JvmStatic
fun newInstance(): DeckPickerAnalyticsOptInDialog {
return DeckPickerAnalyticsOptInDialog()
}

View File

@ -41,7 +41,6 @@ class DeckPickerBackupNoSpaceLeftDialog : AnalyticsDialogFragment() {
}
companion object {
@JvmStatic
fun newInstance(): DeckPickerBackupNoSpaceLeftDialog {
return DeckPickerBackupNoSpaceLeftDialog()
}

View File

@ -47,7 +47,6 @@ class DeckPickerConfirmDeleteDeckDialog : AnalyticsDialogFragment() {
}
companion object {
@JvmStatic
fun newInstance(dialogMessage: String?, deckId: DeckId): DeckPickerConfirmDeleteDeckDialog {
val f = DeckPickerConfirmDeleteDeckDialog()
val args = Bundle()

View File

@ -37,7 +37,6 @@ class DeckPickerNoSpaceLeftDialog : AnalyticsDialogFragment() {
}
companion object {
@JvmStatic
fun newInstance(): DeckPickerNoSpaceLeftDialog {
return DeckPickerNoSpaceLeftDialog()
}

View File

@ -50,7 +50,6 @@ class DeckPickerNoSpaceToDowngradeDialog(private val formatter: FileSizeFormatte
}
companion object {
@JvmStatic
fun newInstance(formatter: FileSizeFormatter, collectionFile: File): DeckPickerNoSpaceToDowngradeDialog {
return DeckPickerNoSpaceToDowngradeDialog(formatter, collectionFile)
}

View File

@ -356,7 +356,6 @@ open class DeckSelectionDialog : AnalyticsDialogFragment() {
* @param filter A method deciding which deck to add
* @return the list of all SelectableDecks from the collection satisfying filter
*/
@JvmStatic
fun fromCollection(c: Collection, filter: FunctionalInterfaces.Filter<Deck> = FunctionalInterfaces.Filters.allowAll()): List<SelectableDeck> {
val all = c.decks.all()
val ret: MutableList<SelectableDeck> = ArrayList(all.size)
@ -384,7 +383,6 @@ open class DeckSelectionDialog : AnalyticsDialogFragment() {
/**
* A dialog which handles selecting a deck
*/
@JvmStatic
fun newInstance(title: String, summaryMessage: String?, keepRestoreDefaultButton: Boolean, decks: List<SelectableDeck>): DeckSelectionDialog {
val f = DeckSelectionDialog()
val args = Bundle()

View File

@ -149,7 +149,6 @@ class DialogHandler(activity: AnkiActivity) : Handler(getDefaultLooper()) {
* Store a persistent message to static variable
* @param message Message to store
*/
@JvmStatic
fun storeMessage(message: Message?) {
Timber.d("Storing persistent message")
sStoredMessage = message

View File

@ -21,7 +21,6 @@ import com.ichi2.anki.R
class DiscardChangesDialog {
companion object {
@JvmStatic
fun showDialog(context: Context?, positiveMethod: () -> Unit): MaterialDialog {
return MaterialDialog(context!!).show {
message(R.string.discard_unsaved_changes)

View File

@ -47,7 +47,6 @@ object HelpDialog {
ankiActivity.openUrl(Uri.parse(AnkiDroidApp.feedbackUrl))
}
@JvmStatic
fun createInstance(): DialogFragment {
val exceptionReportItem = ExceptionReportItem(R.string.help_title_send_exception, R.drawable.ic_round_assignment_24, UsageAnalytics.Actions.EXCEPTION_REPORT)
UsageAnalytics.sendAnalyticsEvent(UsageAnalytics.Category.LINK_CLICKED, UsageAnalytics.Actions.OPENED_HELPDIALOG)
@ -97,7 +96,6 @@ object HelpDialog {
return createInstance(ArrayList(listOf(*allItems)), R.string.help)
}
@JvmStatic
fun createInstanceForSupportAnkiDroid(context: Context?): DialogFragment {
UsageAnalytics.sendAnalyticsEvent(UsageAnalytics.Category.LINK_CLICKED, UsageAnalytics.Actions.OPENED_SUPPORT_ANKIDROID)
val rateAppItem = RateAppItem(R.string.help_item_support_rate_ankidroid, R.drawable.ic_star_black_24, UsageAnalytics.Actions.OPENED_RATE)

View File

@ -101,7 +101,6 @@ class ImportDialog : AsyncDialogFragment() {
* @param dialogMessageList An optional ArrayList of string(s) which can be used to show a custom message
* or specify import path
*/
@JvmStatic
fun newInstance(dialogType: Int, dialogMessageList: ArrayList<String>): ImportDialog {
val f = ImportDialog()
val args = Bundle()

View File

@ -32,7 +32,6 @@ import timber.log.Timber
@NeedsTest("Restore backup dialog does not allow multiple files")
class ImportFileSelectionFragment {
companion object {
@JvmStatic
@KotlinCleanup("convert importItems to java ArrayList")
fun createInstance(@Suppress("UNUSED_PARAMETER") context: DeckPicker): RecursivePictureMenu {
// this needs a deckPicker for now. See use of PICK_APKG_FILE
@ -83,7 +82,6 @@ class ImportFileSelectionFragment {
}
// needs to be static for serialization
@JvmStatic
fun openImportFilePicker(
activity: AnkiActivity,
requestCode: Int,

View File

@ -176,7 +176,6 @@ class LocaleSelectionDialog : AnalyticsDialogFragment() {
/**
* @param handler Marker interface to enforce the convention the caller implementing LocaleSelectionDialogHandler
*/
@JvmStatic
fun newInstance(handler: LocaleSelectionDialogHandler): LocaleSelectionDialog {
return LocaleSelectionDialog().apply {
mDialogHandler = handler

View File

@ -144,7 +144,6 @@ class MediaCheckDialog : AsyncDialogFragment() {
companion object {
const val DIALOG_CONFIRM_MEDIA_CHECK = 0
const val DIALOG_MEDIA_CHECK_RESULTS = 1
@JvmStatic
fun newInstance(dialogType: Int): MediaCheckDialog {
val f = MediaCheckDialog()
val args = Bundle()
@ -153,7 +152,6 @@ class MediaCheckDialog : AsyncDialogFragment() {
return f
}
@JvmStatic
fun newInstance(dialogType: Int, checkList: List<List<String?>?>): MediaCheckDialog {
val f = MediaCheckDialog()
val args = Bundle()

View File

@ -31,7 +31,6 @@ class ModelBrowserContextMenu : AnalyticsDialogFragment() {
companion object {
private const val KEY_LABEL = "key_label"
@JvmStatic
fun newInstance(label: String?): ModelBrowserContextMenu = ModelBrowserContextMenu().apply {
arguments = bundleOf(KEY_LABEL to label)
}

View File

@ -62,7 +62,6 @@ open class ModelEditorContextMenu : AnalyticsDialogFragment() {
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
const val KEY_LABEL = "key_label"
@JvmStatic
fun newInstance(label: String): ModelEditorContextMenu = ModelEditorContextMenu().apply {
arguments = bundleOf(KEY_LABEL to label)
}

View File

@ -193,7 +193,6 @@ class RecursivePictureMenu : DialogFragment() {
}
companion object {
@JvmStatic
@CheckResult
fun createInstance(itemList: ArrayList<Item?>?, @StringRes title: Int): RecursivePictureMenu {
val helpDialog = RecursivePictureMenu()
@ -204,7 +203,6 @@ class RecursivePictureMenu : DialogFragment() {
return helpDialog
}
@JvmStatic
fun removeFrom(allItems: List<Item>, toRemove: Item?) {
// Note: currently doesn't remove the top-level elements.
for (i in allItems) {

View File

@ -23,7 +23,6 @@ import com.ichi2.libanki.sched.SchedV2
import java.util.function.Consumer
object RescheduleDialog : IntegerDialog() {
@JvmStatic
@CheckResult
fun rescheduleSingleCard(
resources: Resources,
@ -44,7 +43,6 @@ object RescheduleDialog : IntegerDialog() {
return rescheduleDialog
}
@JvmStatic
@CheckResult
fun rescheduleMultipleCards(resources: Resources, consumer: Consumer<Int>?, cardCount: Int): RescheduleDialog {
val rescheduleDialog = RescheduleDialog

View File

@ -48,7 +48,6 @@ typealias OpenUri = (Uri) -> Unit
object ScopedStorageMigrationDialog {
@Suppress("Deprecation") // Material dialog neutral button deprecation
@SuppressLint("CheckResult")
@JvmStatic
fun showDialog(ctx: Context, openUri: OpenUri, initiateScopedStorage: Runnable): Dialog {
return MaterialDialog(ctx).show {
title(R.string.scoped_storage_title)

View File

@ -268,7 +268,6 @@ class SyncErrorDialog : AsyncDialogFragment() {
* @param dialogType An integer which specifies which of the sub-dialogs to show
* @param dialogMessage A string which can be optionally used to set the dialog message
*/
@JvmStatic
fun newInstance(dialogType: Int, dialogMessage: String?): SyncErrorDialog {
val f = SyncErrorDialog()
val args = Bundle()

View File

@ -29,7 +29,6 @@ class WhiteboardPenColor(val lightPenColor: Int?, val darkPenColor: Int?) {
}
companion object {
@JvmStatic
@get:CheckResult
val default: WhiteboardPenColor
get() = WhiteboardPenColor(null, null)

View File

@ -336,7 +336,6 @@ class AudioView private constructor(context: Context, resPlay: Int, resPause: In
}
companion object {
@JvmStatic
fun createRecorderInstance(
context: Context,
resPlay: Int,
@ -359,7 +358,6 @@ class AudioView private constructor(context: Context, resPlay: Int, resPause: In
}
}
@JvmStatic
fun generateTempAudioFile(context: Context): String? {
val tempAudioPath: String?
tempAudioPath = try {

View File

@ -37,7 +37,6 @@ object BeolingusParser {
* @param html HTML page from beolingus, with translation of the word we search
* @return `"no"` or the pronunciation URL
*/
@JvmStatic
@KotlinCleanup("AFTER fixing @KotlinCleanup in LoadPronunciationActivity see if wordToSearchFor can be made non null")
fun getPronunciationAddressFromTranslation(@Language("HTML") html: String, wordToSearchFor: String?): String {
val m = PRONUNCIATION_PATTERN.matcher(html)
@ -57,7 +56,6 @@ object BeolingusParser {
/**
* @return `"no"`, or the http address of the mp3 file
*/
@JvmStatic
fun getMp3AddressFromPronunciation(@Language("HTML") pronunciationPageHtml: String): String {
// Only log the page if you need to work with the regex
// Timber.d("pronunciationPageHtml is %s", pronunciationPageHtml);

View File

@ -48,7 +48,6 @@ class CustomToolbarButton(var index: Int, var buttonText: ButtonText, val prefix
return CustomToolbarButton(index, fields[1], fields[2], fields[3])
}
@JvmStatic
fun fromStringSet(hs: Set<String?>): ArrayList<CustomToolbarButton> {
val buttons = ArrayList<CustomToolbarButton>(hs.size)
for (s in hs) {
@ -64,7 +63,6 @@ class CustomToolbarButton(var index: Int, var buttonText: ButtonText, val prefix
return buttons
}
@JvmStatic
fun toStringSet(buttons: ArrayList<CustomToolbarButton>): Set<String> {
val ret = HashSetInit<String>(buttons.size)
for (b in buttons) {

View File

@ -127,7 +127,6 @@ class FieldState private constructor(private val editor: NoteEditor) {
var newModel: Model? = null
companion object {
@JvmStatic
fun refreshWithMap(newModel: Model?, modelChangeFieldMap: Map<Int, Int>?, replaceNewlines: Boolean): FieldChangeType {
val typeClass = FieldChangeType(Type.REFRESH_WITH_MAP, replaceNewlines)
typeClass.newModel = newModel
@ -135,22 +134,18 @@ class FieldState private constructor(private val editor: NoteEditor) {
return typeClass
}
@JvmStatic
fun refresh(replaceNewlines: Boolean): FieldChangeType {
return fromType(Type.REFRESH, replaceNewlines)
}
@JvmStatic
fun refreshWithStickyFields(replaceNewlines: Boolean): FieldChangeType {
return fromType(Type.CLEAR_KEEP_STICKY, replaceNewlines)
}
@JvmStatic
fun changeFieldCount(replaceNewlines: Boolean): FieldChangeType {
return fromType(Type.CHANGE_FIELD_COUNT, replaceNewlines)
}
@JvmStatic
fun onActivityCreation(replaceNewlines: Boolean): FieldChangeType {
return fromType(Type.INIT, replaceNewlines)
}
@ -170,7 +165,6 @@ class FieldState private constructor(private val editor: NoteEditor) {
return oldFields.size > 2
}
@JvmStatic
fun fromEditor(editor: NoteEditor): FieldState {
return FieldState(editor)
}

View File

@ -308,7 +308,6 @@ class Preferences : AnkiActivity(), SearchPreferenceResultListener {
const val INITIAL_FRAGMENT_EXTRA = "initial_fragment"
/** Returns the hour that the collection rolls over to the next day */
@JvmStatic
fun getDayOffset(col: Collection): Int {
return when (col.schedVer()) {
2 -> col.get_config("rollover", DEFAULT_ROLLOVER_VALUE)!!

View File

@ -80,7 +80,7 @@ abstract class SettingsFragment : PreferenceFragmentCompat() {
}
companion object {
@JvmStatic
@JvmStatic // Using protected members which are not @JvmStatic in the superclass companion is unsupported yet
protected fun getSubscreenIntent(context: Context, fragmentClass: KClass<out SettingsFragment>): Intent {
return Intent(context, Preferences::class.java)
.putExtra(Preferences.INITIAL_FRAGMENT_EXTRA, fragmentClass.jvmName)

View File

@ -101,7 +101,6 @@ enum class AnswerButtons {
fun canAnswerHard(numberOfButtons: Int): Boolean = numberOfButtons == 4
fun canAnswerEasy(numberOfButtons: Int): Boolean = numberOfButtons >= 3
@JvmStatic
fun getBackgroundColors(ctx: AnkiActivity): IntArray {
val backgroundIds: IntArray =
if (ctx.animationEnabled()) {
@ -122,7 +121,6 @@ enum class AnswerButtons {
return Themes.getResFromAttr(ctx, backgroundIds)
}
@JvmStatic
fun getTextColors(ctx: Context): IntArray {
return Themes.getColorFromAttr(
ctx,

View File

@ -193,13 +193,11 @@ class AutomaticAnswer(
}
companion object {
@JvmStatic
@CheckResult
fun defaultInstance(target: AutomaticallyAnswered): AutomaticAnswer {
return AutomaticAnswer(target, AutomaticAnswerSettings())
}
@JvmStatic
@CheckResult
fun createInstance(target: AutomaticallyAnswered, preferences: SharedPreferences, col: Collection): AutomaticAnswer {
val settings = AutomaticAnswerSettings.createInstance(preferences, col)
@ -244,7 +242,6 @@ class AutomaticAnswerSettings(
* @return null if the deck is dynamic (use global settings),
* or if "useGeneralTimeoutSettings" is set
*/
@JvmStatic
fun queryDeckSpecificOptions(
action: AutomaticAnswerAction,
col: Collection,
@ -269,7 +266,6 @@ class AutomaticAnswerSettings(
return AutomaticAnswerSettings(action, useTimer, waitQuestionSecond, waitAnswerSecond)
}
@JvmStatic
fun queryFromPreferences(preferences: SharedPreferences, action: AutomaticAnswerAction): AutomaticAnswerSettings {
val prefUseTimer: Boolean = preferences.getBoolean("timeoutAnswer", false)
val prefWaitQuestionSecond: Int = preferences.getInt("timeoutQuestionSeconds", 60)
@ -277,7 +273,6 @@ class AutomaticAnswerSettings(
return AutomaticAnswerSettings(action, prefUseTimer, prefWaitQuestionSecond, prefWaitAnswerSecond)
}
@JvmStatic
fun createInstance(preferences: SharedPreferences, col: Collection): AutomaticAnswerSettings {
// deck specific options take precedence over general (preference-based) options.
// the action can only be set via preferences (but is stored in the collection).

View File

@ -135,13 +135,10 @@ class Binding private constructor(val modifierKeys: ModifierKeys?, val keycode:
companion object {
fun none(): ModifierKeys = ModifierKeys(shift = false, ctrl = false, alt = false)
@JvmStatic
fun ctrl(): ModifierKeys = ModifierKeys(shift = false, ctrl = true, alt = false)
@JvmStatic
fun shift(): ModifierKeys = ModifierKeys(shift = true, ctrl = false, alt = false)
@JvmStatic
fun alt(): ModifierKeys = ModifierKeys(shift = false, ctrl = false, alt = true)
/**
@ -204,7 +201,6 @@ class Binding private constructor(val modifierKeys: ModifierKeys?, val keycode:
const val GAMEPAD_PREFIX = "🎮"
/** This returns multiple bindings due to the "default" implementation not knowing what the keycode for a button is */
@JvmStatic
fun key(event: KeyEvent): List<Binding> {
val modifiers = ModifierKeys(event.isShiftPressed, event.isCtrlPressed, event.isAltPressed)
val ret: MutableList<Binding> = ArrayList()
@ -231,7 +227,6 @@ class Binding private constructor(val modifierKeys: ModifierKeys?, val keycode:
* Specifies a unicode binding from an unknown input device
* See [AppDefinedModifierKeys]
*/
@JvmStatic
fun unicode(unicodeChar: Char): Binding =
unicode(AppDefinedModifierKeys.allowShift(), unicodeChar)
@ -240,10 +235,8 @@ class Binding private constructor(val modifierKeys: ModifierKeys?, val keycode:
return Binding(modifierKeys, null, unicodeChar, null)
}
@JvmStatic
fun keyCode(keyCode: Int): Binding = keyCode(ModifierKeys.none(), keyCode)
@JvmStatic
fun keyCode(modifiers: ModifierKeys?, keyCode: Int): Binding =
Binding(modifiers, keyCode, null, null)

View File

@ -22,7 +22,6 @@ enum class CardSide {
BOTH;
companion object {
@JvmStatic
fun fromAnswer(displayingAnswer: Boolean): CardSide =
if (displayingAnswer) ANSWER else QUESTION
}

View File

@ -33,20 +33,16 @@ enum class FullScreenMode(private val prefValue: String) {
companion object {
const val PREF_KEY = "fullscreenMode"
@JvmStatic
val DEFAULT = BUTTONS_AND_MENU
@JvmStatic
fun fromPreference(prefs: SharedPreferences): FullScreenMode {
val value = prefs.getString(PREF_KEY, DEFAULT.prefValue)
return enumValues<FullScreenMode>().firstOrNull { it.prefValue == value } ?: DEFAULT
}
@JvmStatic
fun isFullScreenReview(prefs: SharedPreferences): Boolean =
fromPreference(prefs).isFullScreenReview()
@JvmStatic
fun upgradeFromLegacyPreference(preferences: SharedPreferences) {
if (!preferences.contains("fullscreenReview")) return
@ -59,7 +55,6 @@ enum class FullScreenMode(private val prefValue: String) {
preferences.edit().remove("fullscreenReview").apply()
}
@JvmStatic
fun setPreference(prefs: SharedPreferences, mode: FullScreenMode) {
prefs.edit().putString(PREF_KEY, mode.getPreferenceValue()).apply()
}

View File

@ -201,14 +201,12 @@ class MappableBinding(val binding: Binding, private val screen: Screen) {
}
@CheckResult
@JvmStatic
fun fromPreference(prefs: SharedPreferences, command: ViewerCommand): MutableList<MappableBinding> {
val value = prefs.getString(command.preferenceKey, null) ?: return command.defaultValue.toMutableList()
return fromPreferenceString(value)
}
@CheckResult
@JvmStatic
fun allMappings(prefs: SharedPreferences): MutableList<Pair<ViewerCommand, MutableList<MappableBinding>>> {
return ViewerCommand.values().map {
Pair(it, fromPreference(prefs, it))

View File

@ -27,7 +27,6 @@ import timber.log.Timber
import java.util.function.Supplier
object DebugInfoService {
@JvmStatic
fun getDebugInfo(info: Context, col: Supplier<Collection>): String {
var schedName = "Not found"
try {

View File

@ -23,7 +23,6 @@ import com.ichi2.libanki.Utils
import java.util.*
object DeckService {
@JvmStatic
fun shouldShowDefaultDeck(col: Collection): Boolean =
defaultDeckHasCards(col) || hasChildren(col, Consts.DEFAULT_DECK_ID)
@ -31,7 +30,6 @@ object DeckService {
private fun hasChildren(col: Collection, did: DeckId) =
col.decks.children(did).size > 0
@JvmStatic
fun defaultDeckHasCards(col: Collection) =
col.db.queryScalar("select 1 from cards where did = 1") != 0
@ -44,7 +42,6 @@ object DeckService {
* @param did Id of the deck to search
* @return the number of cards in the supplied deck and child decks
*/
@JvmStatic
fun countCardsInDeckTree(col: Collection, did: DeckId): Int {
val children: TreeMap<String, Long> = col.decks.children(did)
val dids = LongArray(children.size + 1)

View File

@ -36,7 +36,6 @@ import java.util.*
typealias LanguageHint = Locale
object LanguageHintService {
@JvmStatic
@CheckResult
fun getLanguageHintForField(field: JSONObject): LanguageHint? {
if (!field.has("ad-hint-locale")) {
@ -45,7 +44,6 @@ object LanguageHintService {
return Locale.forLanguageTag(field.getString("ad-hint-locale"))
}
@JvmStatic
fun setLanguageHintForField(models: ModelManager, model: Model, fieldPos: Int, selectedLocale: Locale) {
val field = model.getField(fieldPos)
field.put("ad-hint-locale", selectedLocale.toLanguageTag())
@ -54,7 +52,6 @@ object LanguageHintService {
Timber.i("Set field locale to %s", selectedLocale)
}
@JvmStatic
fun EditText.applyLanguageHint(languageHint: LanguageHint?) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return
this.imeHintLocales = if (languageHint != null) LocaleList(languageHint) else null

View File

@ -45,7 +45,6 @@ object NoteService {
* @param model the model in JSOBObject format
* @return a new note instance
*/
@JvmStatic
fun createEmptyNote(model: JSONObject): MultimediaEditableNote? {
try {
val fieldsArray = model.getJSONArray("flds")
@ -70,7 +69,6 @@ object NoteService {
return null
}
@JvmStatic
fun updateMultimediaNoteFromFields(col: com.ichi2.libanki.Collection, fields: Array<String>, modelId: NoteTypeId, mmNote: MultimediaEditableNote) {
for (i in fields.indices) {
val value = fields[i]
@ -99,7 +97,6 @@ object NoteService {
* @param noteSrc
* @param editorNoteDst
*/
@JvmStatic
fun updateJsonNoteFromMultimediaNote(noteSrc: IMultimediaEditableNote?, editorNoteDst: Note) {
if (noteSrc is MultimediaEditableNote) {
val mmNote = noteSrc
@ -118,7 +115,6 @@ object NoteService {
*
* @param field
*/
@JvmStatic
fun importMediaToDirectory(col: com.ichi2.libanki.Collection, field: IField?) {
var tmpMediaPath: String? = null
when (field!!.type) {
@ -157,7 +153,6 @@ object NoteService {
/**
* @param replaceNewlines Converts [FieldEditText.NEW_LINE] to HTML linebreaks
*/
@JvmStatic
@VisibleForTesting
@CheckResult
fun getFieldsAsBundleForPreview(editFields: Collection<NoteField?>?, replaceNewlines: Boolean): Bundle {
@ -177,7 +172,6 @@ object NoteService {
return fields
}
@JvmStatic
fun convertToHtmlNewline(fieldData: String, replaceNewlines: Boolean): String {
return if (!replaceNewlines) {
fieldData
@ -200,7 +194,6 @@ object NoteService {
}
}
@JvmStatic
fun isMarked(note: Note): Boolean {
return note.hasTag("marked")
}

View File

@ -40,7 +40,6 @@ private typealias VersionIdentifier = Int
private typealias LegacyVersionIdentifier = Long
object PreferenceUpgradeService {
@JvmStatic
fun upgradePreferences(context: Context?, previousVersionCode: LegacyVersionIdentifier): Boolean =
upgradePreferences(AnkiDroidApp.getSharedPrefs(context), previousVersionCode)
@ -60,7 +59,7 @@ object PreferenceUpgradeService {
* Typically because the app has been run for the first time, or the preferences
* have been deleted
*/
@JvmStatic
@JvmStatic // reqired for mockito for now
fun setPreferencesUpToDate(preferences: SharedPreferences) {
Timber.i("Marking preferences as up to date")
PreferenceUpgrade.setPreferenceToLatestVersion(preferences)

View File

@ -37,7 +37,7 @@ class SearchService {
companion object {
@RustCleanup("error checking")
@RustCleanup("i18n - we use an error message from the Rust")
@JvmStatic fun error(e: Exception): SearchCardsResult {
fun error(e: Exception): SearchCardsResult {
if (e !is InvalidSearchException) {
// temporary check to see we haven't missed a backend exception
CrashReportService.sendExceptionReport(e, "unexpected error type")
@ -45,8 +45,8 @@ class SearchService {
val error = e.localizedMessage?.replace("net.ankiweb.rsdroid.exceptions.BackendInvalidInputException: ", "")
return SearchCardsResult(null, error)
}
@JvmStatic fun success(result: List<CardBrowser.CardCache>) = SearchCardsResult(result, null)
@JvmStatic fun invalidResult() = SearchCardsResult(null, null)
fun success(result: List<CardBrowser.CardCache>) = SearchCardsResult(result, null)
fun invalidResult() = SearchCardsResult(null, null)
}
}
}

View File

@ -106,7 +106,6 @@ class BootService : BroadcastReceiver() {
*/
private var sWasRun = false
@JvmStatic
fun scheduleNotification(time: Time, context: Context) {
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
val sp = AnkiDroidApp.getSharedPrefs(context)

View File

@ -37,7 +37,6 @@ class NotificationService : BroadcastReceiver() {
/** The id of the notification for due cards. */
private const val WIDGET_NOTIFY_ID = 1
@JvmStatic
fun triggerNotificationFor(context: Context) {
Timber.i("NotificationService: OnStartCommand")
val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager

View File

@ -174,7 +174,6 @@ class ReminderService : BroadcastReceiver() {
const val EXTRA_DECK_OPTION_ID = "EXTRA_DECK_OPTION_ID"
const val EXTRA_DECK_ID = "EXTRA_DECK_ID"
@JvmStatic
fun getReviewDeckIntent(context: Context, deckId: DeckId): Intent {
return Intent(context, IntentHandler::class.java).putExtra(EXTRA_DECK_ID, deckId)
}

View File

@ -110,11 +110,9 @@ class AnkiStatsTaskHandler private constructor(
}
companion object {
@JvmStatic
var instance: AnkiStatsTaskHandler? = null
private set
private val mutex = Mutex()
@JvmStatic
@Synchronized
fun getInstance(
collection: Collection,
@ -127,7 +125,6 @@ class AnkiStatsTaskHandler private constructor(
return instance!!
}
@JvmStatic
suspend fun createReviewSummaryStatistics(
col: Collection,
view: TextView,

View File

@ -31,7 +31,6 @@ import java.util.*
/** Setup for a spinner which displays all note types */
object NoteTypeSpinnerUtils {
@JvmStatic
fun setupNoteTypeSpinner(context: Context, noteTypeSpinner: Spinner, col: com.ichi2.libanki.Collection): ArrayList<Long> {
val models: List<Model> = col.models.all()
Collections.sort(models, NamedJSONComparator.INSTANCE)

View File

@ -21,7 +21,6 @@ import com.ichi2.anki.AnkiDroidApp
import com.ichi2.libanki.sync.HostNum
object HostNumFactory {
@JvmStatic
fun getInstance(context: Context?): HostNum {
return PreferenceBackedHostNum.fromPreferences(AnkiDroidApp.getSharedPrefs(context))
}

View File

@ -50,7 +50,6 @@ object HttpFetcher {
* @param fakeUserAgent true if we should issue "fake" User-Agent header 'Mozilla/5.0' for compatibility
* @return OkHttpClient.Builder ready for use or further configuration
*/
@JvmStatic
fun getOkHttpBuilder(fakeUserAgent: Boolean): OkHttpClient.Builder {
val clientBuilder = OkHttpClient.Builder()
Tls12SocketFactory.enableTls12OnPreLollipop(clientBuilder)
@ -85,7 +84,6 @@ object HttpFetcher {
return clientBuilder
}
@JvmStatic
fun fetchThroughHttp(address: String?, encoding: String? = "utf-8"): String {
Timber.d("fetching %s", address)
var response: Response? = null
@ -123,7 +121,6 @@ object HttpFetcher {
}
}
@JvmStatic
fun downloadFileToSdCard(UrlToFile: String, context: Context, prefix: String?): String {
var str = downloadFileToSdCardMethod(UrlToFile, context, prefix, "GET")
if (str.startsWith("FAIL")) {
@ -132,7 +129,6 @@ object HttpFetcher {
return str
}
@JvmStatic
private fun downloadFileToSdCardMethod(UrlToFile: String, context: Context, prefix: String?, method: String): String {
var response: Response? = null
return try {

View File

@ -43,7 +43,6 @@ class PreferenceBackedHostNum(hostNum: Int?, private val preferences: SharedPref
}
companion object {
@JvmStatic
fun fromPreferences(preferences: SharedPreferences): PreferenceBackedHostNum {
val hostNum = getHostNum(preferences)
return PreferenceBackedHostNum(hostNum, preferences)

View File

@ -34,7 +34,6 @@ import timber.log.Timber
* Reported as fixed in Firefox Preview
*/
object FirefoxSnackbarWorkaround {
@JvmStatic
fun handledLaunchFromWebBrowser(intent: Intent?, context: Context): Boolean {
if (intent == null) {
Timber.w("FirefoxSnackbarWorkaround: No intent provided")

View File

@ -24,7 +24,6 @@ fun interface CancelListener {
* @param cancelListener Either null or a cancel listener
* @return whether the listener exists and is cancelled
*/
@JvmStatic
fun isCancelled(cancelListener: CancelListener?): Boolean {
return cancelListener != null && cancelListener.isCancelled()
}

View File

@ -33,7 +33,6 @@ object CollectionLoader {
fun execute(col: Collection?)
}
@JvmStatic
fun load(lifecycleOwner: LifecycleOwner, callback: Callback) {
lifecycleOwner.lifecycleScope.launch {
val col = withContext(Dispatchers.IO) {

View File

@ -1189,7 +1189,6 @@ open class CollectionTask<Progress, Result>(val task: TaskDelegateBase<Progress,
}
companion object {
@JvmStatic
@VisibleForTesting
fun nonTaskUndo(col: Collection): Card? {
val sched = col.sched

View File

@ -548,7 +548,6 @@ class Connection : BaseAsyncTask<Connection.Payload, Any, Connection.Payload>()
return sInstance
}
@JvmStatic
fun login(listener: TaskListener, data: Payload): Connection? {
data.taskType = LOGIN
return launchConnectionTask(listener, data)

View File

@ -20,7 +20,6 @@ fun interface ProgressSender<T> {
fun doProgress(value: T?)
companion object {
@JvmStatic
fun <T> publishProgress(progress: ProgressSender<T>?, value: T) {
progress?.doProgress(value)
}

View File

@ -78,7 +78,6 @@ abstract class TaskManager {
return previous
}
@JvmStatic
fun removeTask(task: CollectionTask<*, *>): Boolean {
return sTaskManager.removeTaskConcrete(task)
}
@ -95,12 +94,10 @@ abstract class TaskManager {
* @param task the task to execute
* @return the newly created task
*/
@JvmStatic
fun setLatestInstance(task: CollectionTask<*, *>) {
sTaskManager.setLatestInstanceConcrete(task)
}
@JvmStatic
fun <Progress, Result> launchCollectionTask(task: TaskDelegateBase<Progress, Result>): Cancellable {
return sTaskManager.launchCollectionTaskConcrete(task)
}
@ -128,7 +125,6 @@ abstract class TaskManager {
/**
* Block the current thread until the currently running CollectionTask instance (if any) has finished.
*/
@JvmStatic
fun waitToFinish() {
sTaskManager.waitToFinishConcrete()
}
@ -138,7 +134,6 @@ abstract class TaskManager {
* @param timeoutSeconds timeout in seconds (or null to wait indefinitely)
* @return whether or not the previous task was successful or not, OR if an exception occurred (for example: timeout)
*/
@JvmStatic
fun waitToFinish(timeoutSeconds: Int?): Boolean {
return sTaskManager.waitToFinishConcrete(timeoutSeconds)
}

View File

@ -45,19 +45,16 @@ class CompatHelper private constructor() {
private val instance by lazy { CompatHelper() }
/** Get the current Android API level. */
@JvmStatic
val sdkVersion: Int
get() = Build.VERSION.SDK_INT
/** Determine if the device is running API level 23 or higher. */
@JvmStatic
val isMarshmallow: Boolean
get() = sdkVersion >= Build.VERSION_CODES.M
/**
* Main public method to get the compatibility class
*/
@JvmStatic
val compat get() = instance.compatValue
val isChromebook: Boolean
@ -65,7 +62,6 @@ class CompatHelper private constructor() {
"chromium".equals(Build.BRAND, ignoreCase = true) || "chromium".equals(Build.MANUFACTURER, ignoreCase = true) ||
"novato_cheets".equals(Build.DEVICE, ignoreCase = true)
)
@JvmStatic
val isKindle: Boolean
get() = "amazon".equals(Build.BRAND, ignoreCase = true) || "amazon".equals(Build.MANUFACTURER, ignoreCase = true)

View File

@ -146,7 +146,6 @@ class CustomTabActivityHelper : ServiceConnectionCallback {
* @param uri the Uri to be opened.
* @param fallback a CustomTabFallback to be used if Custom Tabs is not available.
*/
@JvmStatic
fun openCustomTab(
activity: Activity,
customTabsIntent: CustomTabsIntent,
@ -169,7 +168,6 @@ class CustomTabActivityHelper : ServiceConnectionCallback {
}
}
@JvmStatic
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
fun resetFailed() {
sCustomTabsFailed = false

Some files were not shown because too many files have changed in this diff Show More