-
-
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
refactor(Prefs): use XML constants everywhere #17869
Conversation
@@ -30,47 +32,55 @@ import kotlin.reflect.KProperty | |||
object Prefs { | |||
private val sharedPrefs get() = AnkiDroidApp.sharedPrefs() | |||
|
|||
@VisibleForTesting | |||
val resources get() = AnkiDroidApp.appResources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to inline this, but I had some trouble mocking Prefs::key()
to avoid trying to get the app instance
AnkiDroid/src/test/java/com/ichi2/anki/analytics/PreferencesAnalyticsTest.kt
Show resolved
Hide resolved
AnkiDroid/src/test/java/com/ichi2/anki/analytics/PreferencesAnalyticsTest.kt
Show resolved
Hide resolved
d534fbe
to
a297fd6
Compare
adding a preference key leads to a lot of boilerplate (mostly caused by me) because it is necessary to 1. add a constant in preferences.xml 2. add the string for analytics 3. add the string to PrefKey To reduce the boiler, `PrefKey` is being replaced with the preferences.xml constants. Since the XMLs keys can be used in both code and XMLs, keeping it as default seems like the best option. Some of PrefKey strings were just inlined to reduce the scope of the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all works for me, definitely less boilerplate this way
This is going to affect ...and I'm about to get that one in as well, I want to get this in first then I can clean up the collision in 17826 the code being moved around (or, deleted really) here is pretty new and if it needs another tuning that's fine in another PR |
Purpose / Description
adding a preference key leads to a lot of boilerplate (mostly caused by me) because it is necessary to
To reduce the boiler,
PrefKey
is being replaced with the preferences.xml constants.I'm sorry for the churn, but I'm trying to clean up my own mess.
Approach
In the commits
How Has This Been Tested?
Unit Tests + checking if the
Frame style
pref works (just as an example)Learning (optional, can help others)
More random stuff around testing, like mockkObject
Checklist
Please, go through these checks before submitting the PR.