Anki-Android
Anki-Android copied to clipboard
deprecation: compileSdk 33 issues
Hi there! Thanks for picking up a deprecation task - we think these are good first issues because:
1- typically you can just search the codebase for a relevant string and find where the work is quickly 2- typically there is documentation upstream in the Google Android Developer docs that explain how the old API worked, why it is deprecated, and then there is documentation for the new API 3- the functionality is already working, switching to a new implementation has a clear standard to meet, it should be obvious the change was good (because the feature was working, and should just still be working
These are the collection of interfaces deprecated as we switched compileSdkVersion from 32 to 33:
- [ ] Activity.onBackPressed
- [x] Intent.getParcelableExtra
- [ ] Bundle.getSerializable
- [x] Intent.getSerializable
- [ ] Parcel.readSparseArray
- [ ] Parcel.readSerializable
- [ ] Parcel.readList
- [ ] Bundle.getParcelableArrayList
- [ ] Bundle.get (array access: `b["key"]``)
- [ ] Bundle.getParcelable
- [ ] PackageManager.resolveActivity
- [ ] PackageManager.getPackageInfo
- [ ] PackageManager.queryIntentActivities
- [ ] PackageManager.resolveService
The task is to:
- pick one no one else has commented on here, write a comment here that you are working on that one
- search for the second part of the string (for example "onBackPressed")
- verify that it has a
@Suppress("deprecation")
near it signaling that you found the spot! - Add a Timber.d in the area to make sure you can exercise the feature on the emulator before changing it (you should see your log message)
- read the docs on the deprecated API and the new API, and convert the code to the new API
- make sure
./gradlew jacocoTestReport ktlintCheck
passes on your work locally, and that the feature still works - open a PR with your changes
Ask if you have any questions!
Originally posted by @david-allison in https://github.com/ankidroid/Anki-Android/pull/12359#issuecomment-1241571435
@david-allison I would like to work on Activity.onBackPressed deprecation. Edit - If anyone wants to work on this you can. I am not working on it currently
@priyanshuborole great - unless someone has said they are working on something - no need to ask permission, just state (with authority! go for it!) that you are working on such and such. Good luck, and thanks
@david-allison I was working on Intent.getParcelableExtra but when I am trying to update the method it gives an error and not recognizing the API level 33 intent removing the @supress also throws an error while building up the application.
read the docs on the deprecated API and the new API, and convert the code to the new API
Look up the method: getParcelableExtra
: https://developer.android.com/reference/android/content/Intent#getParcelableExtra(java.lang.String)
https://developer.android.com/reference/android/content/Intent#getParcelableExtra(java.lang.String,%20java.lang.Class%3CT%3E) is recommended instead.
- Look into our
Compat
mechanism and see if we can use this here: https://github.com/ankidroid/Anki-Android/blob/57958d263252e9914b2c25ef68bffedc1abc292e/AnkiDroid/src/main/java/com/ichi2/compat/
read the docs on the deprecated API and the new API, and convert the code to the new API
Look up the method:
getParcelableExtra
: https://developer.android.com/reference/android/content/Intent#getParcelableExtra(java.lang.String)https://developer.android.com/reference/android/content/Intent#getParcelableExtra(java.lang.String,%20java.lang.Class%3CT%3E) is recommended instead.
- Look into our
Compat
mechanism and see if we can use this here: https://github.com/ankidroid/Anki-Android/blob/57958d263252e9914b2c25ef68bffedc1abc292e/AnkiDroid/src/main/java/com/ichi2/compat/
I found https://stackoverflow.com/questions/73019160/android-getparcelableextra-deprecated/73311814#73311814 which explains the usability of getPracelableExtra in API >=33
@david-allison Working on Parcel.readSparseArray
Hey, I was working on Bundle.getParcelable.
The method in API level 33 is
public T getParcelable (String key, Class<T> clazz)
I'm not sure which class should be mentioned here
mPreviousImageUri = savedInstanceState.getParcelable("mPreviousImageUri")
Is it Uri::class.java ?
Also if I add a class, it says Call requires API level 33, should I surround it with if (Build.VERSION.SDK_INT >= 33)
?
It's a Uri:
https://github.com/ankidroid/Anki-Android/blob/3f464f6f4cdc35a8b62e9ad9f93a2bb6efbe3306/AnkiDroid/src/main/java/com/ichi2/anki/multimediacard/fields/BasicImageFieldController.kt#L85
See our compat infrastructure for how to handle this. There's already a thread on Discord where I've walked someone through this
#12410 adds this infra, and should be a good starting point
@david-allison I would like to work on Activity.onBackPressed deprecation.
Hey! are you still working on it?
@david-allison I would like to work on Activity.onBackPressed deprecation.
Hey! are you still working on it?
Yes I am working on it, give me 1-2 days if not possible I will update you
Hey, I was working on Bundle.getParcelable. The method in API level 33 is
public T getParcelable (String key, Class<T> clazz)
I'm not sure which class should be mentioned here
mPreviousImageUri = savedInstanceState.getParcelable("mPreviousImageUri")
Is it Uri::class.java ?Also if I add a class, it says Call requires API level 33, should I surround it with
if (Build.VERSION.SDK_INT >= 33)
?
Hey! Are you working on it? coz if not then I would like to overtake it.
I'm working on Parcel.readSparseArray and there is only one place it occurs, which is com/ichi2/anki/FieldEditLine.kt:249 But it looks like it's never used in the project and I can't find a way to test it. What am I supposed to do?
Is anyone working on PackageManager depreciated interfaces? If not I would love to work on it.
Is anyone working on PackageManager depreciated interfaces? If not I would love to work on it.
I don't think anyone is
Hey! Are you working on it? coz if not then I would like to overtake it.
I'm not able to figure out a few things. So sure go ahead. I'll just watch and learn 😂
Hey! Are you working on it? coz if not then I would like to overtake it.
I'm not able to figure out a few things. So sure go ahead. I'll just watch and learn 😂
Sure, Thanks!
Hey, I was working on Bundle.getParcelable. The method in API level 33 is
public T getParcelable (String key, Class<T> clazz)
I'm not sure which class should be mentioned heremPreviousImageUri = savedInstanceState.getParcelable("mPreviousImageUri")
Is it Uri::class.java ? Also if I add a class, it says Call requires API level 33, should I surround it withif (Build.VERSION.SDK_INT >= 33)
?Hey! Are you working on it? coz if not then I would like to overtake it.
yes, you can start working on it.
Could you please review the last PR so that I can move on to the other one? Like whenever you are good to go. Thanks!
@criticalAY if you examine the volume of work in flight at any time (https://github.com/ankidroid/Anki-Android/pulse) you'll see you have to have some patience, especially since we are essentially all volunteers. Sometimes things are very very fast, sometimes they sit, it is not predictable. However, if you feel you have that PR under control, you can take on another one - that's fine. I would only caution against having too many PRs in flight at once, but that would be like 5-6 - at that point it is usually a sign that things are not really being answered satisfactorily for some reason or they would be getting merged. In this case I think we're close, go ahead on something new if you like, while reviewers catch up. Cheers!
Yes, I do understand but if I make another PR that would make a conflict I guess. One thing that I am learning from open source contributions is how to be patient and I would love to wait as I am enjoying working with you all <3
I believe the various SDK33 deprecations will not conflict with each other, each of them should be in different chunks of text which git should ideally be able to handle just fine on merge. Even if not, handling conflicts via git rebase / fixing conflicts / force push to your branch is one of the most powerful things you can learn as a modern software developer (where "modern" is defined as "we are all using git now"). Once you've got git rebase-merge/de-conflict/force-push down, there is almost nothing out of reach with regards to managing a source code repository and that's a powerful professional skill. So don't fear conflicts, in my opinion
API 33 serializable bundle deprecation update #12463 for Bundle.getSerializable
We are still working on it, right?
@criticalAY - if you are looking for status updates, as mentioned before directly to you, with explanation, basically don't unless it really has been a while and then do so on the PR directly. But please note 2 days is not a while, and that's the timestamp on your last comment.
There will be periods of time, sometimes long periods, when no one is working on anything. It is a volunteer project and you cannot expect volunteers time, that is just a reality.
If this is a legitimate question about this issue specifically, unless it is closed it is still being worked on. It is not closed. We close issues not being worked on. I see 13 unchecked boxes above, so it is certainly an area of ongoing work.
will be periods of time, sometimes long periods,
Yes, I am aware of that fact as I already asked that on DC here just the issue of whether it's still up or dumped.
If any decisions are made, they will be communicated, so no communication means no decision + no progress --> have patience please.
I'm currently working on PackageManager.resolveActivity
deprecation.
There is one instance of it in AdaptionUtil
which is used for checking if the device is running MIUI.
Can anyone please help me out in testing it? (Testing it using Timber)
I'm unable to get that part of the code to execute.
Can we please review the last two PRs?
I will work on PackageManager.getPackageInfo
.