-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove usage of Kotlin wildcard imports on the project Codestyle file #11852
Comments
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This has begun to cause issues. My opinion has shifted and I'd be happy with avoiding Unusual mix of High Priority & Good First Issue: this should be simple to solve
|
Hi there @david-allison ! I'd like to work on this issue just to get a little familiar with the codebase ;) |
Sounds good, cheers! |
Hey, me again @david-allison, I've made some progress on this but I've been stuck on FilteredDeckOptions.kt specifically, since it uses deprecated libraries of android and won't build. I noticed that it has already been discussed here #5019 and I'm not sure what to do about that problem (especially since I'm just starting out in this project). |
@andriusezerskis could you push a branch so I can take a look Or post a patch:
|
Index: AnkiDroid/src/main/java/com/ichi2/anki/FilteredDeckOptions.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/FilteredDeckOptions.kt b/AnkiDroid/src/main/java/com/ichi2/anki/FilteredDeckOptions.kt
--- a/AnkiDroid/src/main/java/com/ichi2/anki/FilteredDeckOptions.kt (revision b4a3fc99c59a2afe8e80b8965aaf580ef8c09a24)
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/FilteredDeckOptions.kt (revision ed6b0bccb9809bceffa8f4753f8a5a655f596740)
@@ -19,10 +19,13 @@
import android.content.SharedPreferences
import android.os.Bundle
-import android.preference.*
+import androidx.preference.CheckBoxPreference
+import androidx.preference.EditTextPreference
+import androidx.preference.ListPreference
+import androidx.preference.Preference
+import androidx.preference.PreferenceCategory
import com.ichi2.anki.analytics.UsageAnalytics
import com.ichi2.annotations.NeedsTest
-import com.ichi2.libanki.Collection
import com.ichi2.preferences.StepsPreference.Companion.convertFromJSON
import com.ichi2.preferences.StepsPreference.Companion.convertToJSON
import com.ichi2.themes.Themes
@@ -216,7 +219,7 @@
} else {
pref = DeckPreferenceHack()
pref.registerOnSharedPreferenceChangeListener(this)
- addPreferences(col)
+ // addPreferences(col)
buildLists()
updateSummaries()
}
@@ -238,32 +241,32 @@
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
- @Suppress("deprecation") // Tracked as #5019 on github: addPreferencesFromResource
- private fun addPreferences(col: Collection) {
- addPreferencesFromResource(R.xml.cram_deck_options)
- if (col.schedVer() != 1) {
- Timber.d("sched v2: removing filtered deck custom study steps")
- // getPreferenceScreen.removePreference didn't return true, so remove from the category
- setupSecondFilterListener()
- setupPreviewDelaysListener()
- val category = findPreference("studyOptions") as PreferenceCategory
- removePreference(category, "stepsOn")
- removePreference(category, "steps")
- }
- }
+// @Suppress("deprecation") // Tracked as #5019 on github: addPreferencesFromResource
+// private fun addPreferences(col: Collection) {
+// addPreferencesFromResource(R.xml.cram_deck_options)
+// if (col.schedVer() != 1) {
+// Timber.d("sched v2: removing filtered deck custom study steps")
+// // getPreferenceScreen.removePreference didn't return true, so remove from the category
+// setupSecondFilterListener()
+// setupPreviewDelaysListener()
+// val category = findPreference("studyOptions") as PreferenceCategory
+// removePreference(category, "stepsOn")
+// removePreference(category, "steps")
+// }
+// }
- @Suppress("deprecation") // Tracked as #5019 on github: findPreference
- private fun removePreference(category: PreferenceCategory?, key: String) {
- val preference = findPreference(key)
- if (category == null || preference == null) {
- Timber.w("Failed to remove preference '%s'", key)
- return
- }
- val result = category.removePreference(preference)
- if (!result) {
- Timber.w("Failed to remove preference '%s'", key)
- }
- }
+// @Suppress("deprecation") // Tracked as #5019 on github: findPreference
+// private fun removePreference(category: PreferenceCategory?, key: String) {
+// val preference = findPreference(key)
+// if (category == null || preference == null) {
+// Timber.w("Failed to remove preference '%s'", key)
+// return
+// }
+// val result = category.removePreference(preference)
+// if (!result) {
+// Timber.w("Failed to remove preference '%s'", key)
+// }
+// }
override fun closeWithResult() {
if (prefChanged) { @david-allison I've commented the mentioned files, and here's the link to my fork if you need to take a look: https://github.com/andriusezerskis/Anki-Android/tree/remove-import-wildcard. The patch shown here is obviously just one of the files but the issue remains the same. |
Index: AnkiDroid/src/main/java/com/ichi2/anki/FilteredDeckOptions.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/FilteredDeckOptions.kt b/AnkiDroid/src/main/java/com/ichi2/anki/FilteredDeckOptions.kt
--- a/AnkiDroid/src/main/java/com/ichi2/anki/FilteredDeckOptions.kt (revision 2c959dcfdf444ffc62e0b8bc0bf4803889c2ec2c)
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/FilteredDeckOptions.kt (date 1721047190132)
@@ -1,4 +1,4 @@
-package com.ichi2.anki
+@file:Suppress("DEPRECATION") // #3625 android.preference deprecation
/****************************************************************************************
* Copyright (c) 2009 Casey Link <[email protected]> *
@@ -17,9 +17,15 @@
* this program. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************************/
+package com.ichi2.anki
+
import android.content.SharedPreferences
import android.os.Bundle
-import android.preference.*
+import android.preference.CheckBoxPreference
+import android.preference.EditTextPreference
+import android.preference.ListPreference
+import android.preference.Preference
+import android.preference.PreferenceCategory
import com.ichi2.anki.analytics.UsageAnalytics
import com.ichi2.annotations.NeedsTest
import com.ichi2.libanki.Collection You can apply this by copying the above code block double-tapping shift inside Android Studio and selecting 'apply patch from clipboard'. This patch is based off It's not a great option, but it's the best we have for now |
I agree. Although this one was added automatically by the IDE.
Default for Kotlin is 3 imports to substitute to
*
(https://stackoverflow.com/questions/49870306/disable-wild-cart-import-in-intellij-android-studio-in-kotlin)It can be a good first issue to change it on the project codestyle file (https://github.com/ankidroid/Anki-Android/blob/main/.idea/codeStyles/Project.xml)
Originally posted by @BrayanDSO in #11803 (comment)
The text was updated successfully, but these errors were encountered: