Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

[Deprecation] forward port Fragment startActivityForResult/onActvityResult to new Activity APIs

Open mikehardy opened this issue 5 years ago • 7 comments

The androidx.fragment library (and associated androidx.activity library) have taken over a lot of the basic android.Activity object's work with regard to starting activities outside the current Actvitiy or Fragment, and receiving results from them.

In general the Android team is recommending doing this inter-fragment/inter-activity communication now using their AndroidX libraries, and they have specifically deprecated the fragment APIs that we were using in CardTemplateEditor and StudyOptionsFragment (and really, any place we are doing startActivityForResult and onActivityResult throughout the code)

At minimum we need to forward port CardTemplateEditor and StudyOptionsFragment to the new style following these guides:

https://developer.android.com/training/basics/intents/result https://developer.android.com/guide/fragments/communicate#fragment-result

In the meantime I have suppressed the error in the code with a reference to this issue.

mikehardy avatar Mar 20 '21 18:03 mikehardy

Marking this as help wanted, but I will note it is not necessarily a good first issue.

You must have a very strong knowledge of the Android Activity Lifecycle, and everything in the two linked documents should make perfect sense before attempting to restructure the start/result behavior of these fragments

mikehardy avatar Mar 20 '21 19:03 mikehardy

Some functions in AnkiActivity https://github.com/ankidroid/Anki-Android/blame/aec2d6489422a51d3d8a9665ae164541583e5980/src/com/ichi2/anki/AnkiActivity.java have been marked as deprecated since 2012 when they were introduced. Do you think it's related? Otherwise, I believe an extra issue should deal with this and figure out what to do with those function we have been calling for a decade and have always been deprecated without anything indicating why

Arthur-Milchior avatar Mar 21 '21 03:03 Arthur-Milchior

Some functions in AnkiActivity https://github.com/ankidroid/Anki-Android/blame/aec2d6489422a51d3d8a9665ae164541583e5980/src/com/ichi2/anki/AnkiActivity.java have been marked as deprecated since 2012 when they were introduced. Do you think it's related? Otherwise, I believe an extra issue should deal with this and figure out what to do with those function we have been calling for a decade and have always been deprecated without anything indicating why

I believe those are deprecated because we're not specifying an animation when we launch the activity.

david-allison avatar Mar 21 '21 04:03 david-allison

Would love to work on this if available

kartikeysaran avatar Mar 22 '21 08:03 kartikeysaran

Can I work on this?

pravesh00 avatar Mar 22 '21 15:03 pravesh00

@kartikeysaran asked first so I think we should let them have a go at it

Please keep the first PR very small and focused as this will be a new way of starting activities and getting results for us. These are fundamental concepts in Android programming so it's important that we all get a chance to look at it from a design perspective before a lot of implementation takes place, but one single implementation to demonstrate the new design is how to check the design.

So please post a change that just moves CardTemplateEditor to the new APIs and post that, then we can all look?

mikehardy avatar Mar 23 '21 16:03 mikehardy

@kartikeysaran asked first so I think we should let them have a go at it

Please keep the first PR very small and focused as this will be a new way of starting activities and getting results for us. These are fundamental concepts in Android programming so it's important that we all get a chance to look at it from a design perspective before a lot of implementation takes place, but one single implementation to demonstrate the new design is how to check the design.

So please post a change that just moves CardTemplateEditor to the new APIs and post that, then we can all look?

Okay !

kartikeysaran avatar Mar 24 '21 11:03 kartikeysaran