From a61c42e5720dca98cab0a0dfdbf12f0179ac2e87 Mon Sep 17 00:00:00 2001 From: MorenoTropicano2000 <154519856+MorenoTropicano2000@users.noreply.github.com> Date: Thu, 21 Dec 2023 11:43:13 -0300 Subject: [PATCH] fix ide issues (#15042) * ide issue in CardTemplatePreviewer * ide issue in CollectionManager * ide issue in CustomMaterialTapTargetPromptBuilder * ide issue in DeckSpinnerSelection * ide issue in Preferences * ide issue in MediaRegistration * ide issue in SharedDecksActivity * ide issue in StudyOptionsActivity * ide issue in Whiteboard --- .../java/com/ichi2/anki/CardTemplatePreviewer.kt | 14 ++++++-------- .../main/java/com/ichi2/anki/CollectionManager.kt | 2 +- .../anki/CustomMaterialTapTargetPromptBuilder.kt | 4 ++-- .../java/com/ichi2/anki/DeckSpinnerSelection.kt | 5 ++--- .../main/java/com/ichi2/anki/MediaRegistration.kt | 2 +- .../java/com/ichi2/anki/SharedDecksActivity.kt | 1 + .../java/com/ichi2/anki/StudyOptionsActivity.kt | 1 + .../src/main/java/com/ichi2/anki/Whiteboard.kt | 2 +- .../java/com/ichi2/anki/preferences/Preferences.kt | 1 - 9 files changed, 15 insertions(+), 17 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/CardTemplatePreviewer.kt b/AnkiDroid/src/main/java/com/ichi2/anki/CardTemplatePreviewer.kt index 8f5bf26a75e2..cc7b99bdc39c 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/CardTemplatePreviewer.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/CardTemplatePreviewer.kt @@ -120,7 +120,8 @@ open class CardTemplatePreviewer : AbstractFlashcardViewer() { finishWithAnimation(ActivityTransitionAnimation.Direction.END) } - @Suppress("DEPRECATION", "Deprecated in API34+dependencies for predictive back feature") + @Deprecated("Deprecated in Java") + @Suppress("Deprecated in API34+dependencies for predictive back feature") override fun onBackPressed() { Timber.i("CardTemplatePreviewer:: onBackPressed()") super.onBackPressed() @@ -392,14 +393,11 @@ open class CardTemplatePreviewer : AbstractFlashcardViewer() { } /** Override certain aspects of Card behavior so we may display unsaved data */ - inner class PreviewerCard : Card { - private val mNote: Note? + inner class PreviewerCard(col: Collection, id: Long) : Card(col, id) { + private val mNote: Note? = null - constructor(col: Collection, id: Long) : super(col, id) { - mNote = null - } - - /* if we have an unsaved note saved, use it instead of a collection lookup */ override fun note( + /* if we have an unsaved note saved, use it instead of a collection lookup */ + override fun note( reload: Boolean ): Note { return mNote ?: super.note(reload) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/CollectionManager.kt b/AnkiDroid/src/main/java/com/ichi2/anki/CollectionManager.kt index 4e05d41e496b..db407a49bd20 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/CollectionManager.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/CollectionManager.kt @@ -149,7 +149,7 @@ object CollectionManager { } fun compareAnswer(expected: String, given: String): String { - // bypass the lock, as the type answer code is heavily nested in non-suspend funs + // bypass the lock, as the type answer code is heavily nested in non-suspend functions return getBackend().compareAnswer(expected, given) } diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/CustomMaterialTapTargetPromptBuilder.kt b/AnkiDroid/src/main/java/com/ichi2/anki/CustomMaterialTapTargetPromptBuilder.kt index e805e797c3da..ff24a6070be1 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/CustomMaterialTapTargetPromptBuilder.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/CustomMaterialTapTargetPromptBuilder.kt @@ -27,9 +27,9 @@ import uk.co.samuelwall.materialtaptargetprompt.extras.backgrounds.RectangleProm import uk.co.samuelwall.materialtaptargetprompt.extras.focals.CirclePromptFocal import uk.co.samuelwall.materialtaptargetprompt.extras.focals.RectanglePromptFocal -class CustomMaterialTapTargetPromptBuilder(val activity: Activity, val featureIdentifier: T) : MaterialTapTargetPrompt.Builder(activity) where T : Enum, T : OnboardingFlag { +class CustomMaterialTapTargetPromptBuilder(val activity: Activity, private val featureIdentifier: T) : MaterialTapTargetPrompt.Builder(activity) where T : Enum, T : OnboardingFlag { - fun createRectangle(): CustomMaterialTapTargetPromptBuilder { + private fun createRectangle(): CustomMaterialTapTargetPromptBuilder { promptFocal = RectanglePromptFocal() return this } diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/DeckSpinnerSelection.kt b/AnkiDroid/src/main/java/com/ichi2/anki/DeckSpinnerSelection.kt index de27b9f05152..8659652604e1 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/DeckSpinnerSelection.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/DeckSpinnerSelection.kt @@ -62,8 +62,7 @@ class DeckSpinnerSelection( private val mFragmentManagerSupplier: FragmentManagerSupplier = context.asFragmentManagerSupplier() - lateinit var dropDownDecks: List - private set + private lateinit var dropDownDecks: List private var mDeckDropDownAdapter: DeckDropDownAdapter? = null fun initializeActionBarDeckSpinner(actionBar: ActionBar) { @@ -116,7 +115,7 @@ class DeckSpinnerSelection( return collection.decks.allNamesAndIds(includeFiltered = includeFiltered) } - fun setSpinnerListener() { + private fun setSpinnerListener() { spinner.setOnTouchListener { _: View?, motionEvent: MotionEvent -> if (motionEvent.action == MotionEvent.ACTION_UP) { displayDeckSelectionDialog(collection) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/MediaRegistration.kt b/AnkiDroid/src/main/java/com/ichi2/anki/MediaRegistration.kt index e4748686173c..22461cbb634b 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/MediaRegistration.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/MediaRegistration.kt @@ -177,7 +177,7 @@ class MediaRegistration(private val context: Context) { companion object { private const val MEDIA_MAX_SIZE = 5 * 1000 * 1000 private const val COLOR_GREY = 0 - const val COLOR_TRUE = 2 + private const val COLOR_TRUE = 2 private const val COLOR_INDEX = 3 private const val COLOR_GREY_ALPHA = 4 private const val COLOR_TRUE_ALPHA = 6 diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/SharedDecksActivity.kt b/AnkiDroid/src/main/java/com/ichi2/anki/SharedDecksActivity.kt index e1cfdd72f01a..86a04af99efc 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/SharedDecksActivity.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/SharedDecksActivity.kt @@ -150,6 +150,7 @@ class SharedDecksActivity : AnkiActivity() { * If user can go back in WebView, navigate to previous webpage. * Otherwise, close the WebView. */ + @Deprecated("Deprecated in Java") @Suppress("deprecation") // onBackPressed override fun onBackPressed() { when { diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/StudyOptionsActivity.kt b/AnkiDroid/src/main/java/com/ichi2/anki/StudyOptionsActivity.kt index ce792a12e832..0d9457a28a6d 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/StudyOptionsActivity.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/StudyOptionsActivity.kt @@ -73,6 +73,7 @@ class StudyOptionsActivity : NavigationDrawerActivity(), StudyOptionsListener, C finishWithAnimation(ActivityTransitionAnimation.Direction.END) } + @Deprecated("Deprecated in Java") override fun onBackPressed() { if (isDrawerOpen) { super.onBackPressed() diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/Whiteboard.kt b/AnkiDroid/src/main/java/com/ichi2/anki/Whiteboard.kt index 839023c959a1..81f54b45ff14 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/Whiteboard.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/Whiteboard.kt @@ -75,7 +75,7 @@ class Whiteboard(activity: AnkiActivity, handleMultiTouch: Boolean, inverted: Bo private val mColorPalette: LinearLayout private val mHandleMultiTouch: Boolean = handleMultiTouch private var mOnPaintColorChangeListener: OnPaintColorChangeListener? = null - val currentStrokeWidth: Int + private val currentStrokeWidth: Int get() = mAnkiActivity.sharedPrefs().getInt("whiteBoardStrokeWidth", 6) override fun onDraw(canvas: Canvas) { 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 d27014e5f736..0671f2f22101 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/preferences/Preferences.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/preferences/Preferences.kt @@ -43,7 +43,6 @@ import com.ichi2.libanki.utils.TimeManager import com.ichi2.themes.setTransparentStatusBar import com.ichi2.utils.getInstanceFromClassName import timber.log.Timber -import java.util.* import kotlin.reflect.jvm.jvmName class Preferences :