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

Kotlin Cleanup

Open Arthur-Milchior opened this issue 3 years ago • 69 comments

Currently, there are 84 @KotlinCleanup in AnkiDroid code source. Most of those changes are supposed to be simple to do and would be a good pull request by themselves. Also, if you are a java developer and new to Kotlin, it will be a great way to learn Kotlin advantages, since it's usually tasks that were introduced when translating java to Kotlin, and which can actually be improved in Kotlin compared to original java code.

Ideally, each PR should contains a single cleanup. This ensure the PR is very very quick to review and merge. The main exception would be if a clean-up is dependent on another clean-up and this would cause merge conflict.

Arthur-Milchior avatar Mar 11 '22 19:03 Arthur-Milchior

i would like to work on this

kilitr avatar Mar 11 '22 22:03 kilitr

Sounds good! IMO it's not worth assigning to this one as there's so much to do and it'd be great to get other people on this at the same time

Ideally one PR per class - just let us know which one you're working on so someone else doesn't work on it at the same time

david-allison avatar Mar 11 '22 22:03 david-allison

Working on CustomStudyDialog.kt

I would like some help concerning the second part of this KotlinCleanup https://github.com/ankidroid/Anki-Android/blob/a9ca2cfa854d999e5e4cbe905239b9109f1aee9c/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/customstudy/CustomStudyDialog.kt#L343-L417

What exactly is meant by "mapping dialogID to an enum"?

  1. IMO, the only thing that would make sense is replacing the CONTEXT_MENU_* and all other fields of the companion object (see below) with two seperate enums (One for the context menu configuration and one for the context menu options). However this would be a huge change across this file.
  2. Introducing an additional enum which dialogID will get mapped to before entering the when statement would be the alternative. This feels dirty to me due to code duplication

https://github.com/ankidroid/Anki-Android/blob/a9ca2cfa854d999e5e4cbe905239b9109f1aee9c/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/customstudy/CustomStudyDialog.kt#L500-L520

kilitr avatar Mar 12 '22 16:03 kilitr

I would also like to work on it. So basically, I have to go through each class marked with @KotlinCleanup and convert ko Kotlin making sure that changes don't break and pass all the tests.

thedroiddiv avatar Mar 12 '22 19:03 thedroiddiv

I would also like to work on it. So basically, I have to go through each class marked with @KotlinCleanup and convert ko Kotlin making sure that changes don't break and pass all the tests.

Well, you just need to find one @KotlinCleanup that is not the one @kilitr is working on, and correct it. Please don't try to solve all clean up in a single PR, that would be very hard to review

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

@kilitr Please do the thing that makes sens to you. This guidance is true all of the time actually. It's easy to be not clear, to miss a nuance, while writtings todo/issues, that is only really catched while implementing the code. It's quite rare that we require something to be done exactly the way we required it, and it never occurs that we are not willing to discuss our demands. So, if you do the work and that you find an idea that is great, feel free to do it. We can always discuss it in details during the code review. The only case where I would really want you to ask for permission before doing the work is if the work will take you hours; and it's only because that will avoid you to write code during hours and then lose all of this works when the PR gets closed without being merged

Arthur-Milchior avatar Mar 12 '22 22:03 Arthur-Milchior

Currently I'm working on DeckPickerFloatingActionMenu.kt Other working on this issue, please mention which class/file they are working on.

thedroiddiv avatar Mar 14 '22 13:03 thedroiddiv

Currently, I'm working on CardTemplatePreviewer.kt. Others also please mention which files they are working on to avoid merge conflicts.

DeepanshuPratik avatar Mar 15 '22 17:03 DeepanshuPratik

Currently, I'm working on CardTemplatePreviewer.kt. Others also please mention which files they are working on to avoid merge conflicts.

Just FYI: conflicts with https://github.com/ankidroid/Anki-Android/pull/10526

david-allison avatar Mar 15 '22 17:03 david-allison

Currently, I'm working on CardTemplatePreviewer.kt. Others also please mention which files they are working on to avoid merge conflicts.

Just FYI: conflicts with #10526

Thanks, I didn't notice it.

DeepanshuPratik avatar Mar 15 '22 17:03 DeepanshuPratik

Currently, I'm working on LanguageUtils.kt.

DeepanshuPratik avatar Mar 15 '22 17:03 DeepanshuPratik

Heya, I'll take on cleaning up ImportUtils.kt

Lizzergas avatar Mar 18 '22 10:03 Lizzergas

@Arthur-Milchior @mikehardy. @david-allison Sir can i work on AsyncDialogFragment,kt

ConnectBhawna avatar Mar 22 '22 08:03 ConnectBhawna

@Arthur-Milchior @mikehardy. @david-allison Sir can i work on AsyncDialogFragment,kt

Sure, and no need for the "sir" 😇

david-allison avatar Mar 22 '22 08:03 david-allison

I also want to work on it . can you please assign it to me

Jatin887 avatar Mar 23 '22 04:03 Jatin887

Sounds good! IMO it's not worth assigning to this one as there's so much to do and it'd be great to get other people on this at the same time

Ideally one PR per class - just let us know which one you're working on so someone else doesn't work on it at the same time

https://github.com/ankidroid/Anki-Android/issues/10489#issuecomment-1065610715

david-allison avatar Mar 23 '22 13:03 david-allison

Can anyone tell me what exactly I have to do in this issue?

Yugal41735 avatar Apr 04 '22 12:04 Yugal41735

Can anyone tell me what exactly I have to do in this issue?

Search the entire codebase for @KotlinCleanup("Description") annotations... read and understand the description and resolve whatever issue was pointed out in the Description.

One basic example that you'll come across very often is removing nullability from a certain Field.

kilitr avatar Apr 04 '22 12:04 kilitr

image

So for example: in the above codebase what exactly I have to do?

Yugal41735 avatar Apr 04 '22 13:04 Yugal41735

anyone could explain what exactly I have to do in the above codebase?

Yugal41735 avatar Apr 04 '22 16:04 Yugal41735

d needs a rename (or a scope function)

david-allison avatar Apr 04 '22 17:04 david-allison

@david-allison Is there anything left in this issue?? I would like to work on it.

Umesh-01 avatar Apr 06 '22 19:04 Umesh-01

Started tackling MyAccount.kt's various cleanup tasks. Might have a PR in later once I verify that the tests pass.

raymondwzeng avatar Apr 06 '22 19:04 raymondwzeng

I am facing this issue while setting up the project can you plese help me out and i wanna convert Taskmangaer.java async task to kotlin coroutines as i am intrested in the project async task to coroutines image

Jatin887 avatar Apr 06 '22 21:04 Jatin887

I am facing this issue while setting up the project can you plese help me out and i wanna convert Taskmangaer.java async task to kotlin coroutines as i am intrested in the project async task to coroutines image

What version of Android Studio are you using?

david-allison avatar Apr 06 '22 21:04 david-allison

@david-allison Is there anything left in this issue?? I would like to work on it.

Lots to do - just state the class you're working on so you don't get conflicts

david-allison avatar Apr 06 '22 21:04 david-allison

Heya👋! I am currently working on Kotlin Cleanup for Counts.kt.

File link : https://github.com/ankidroid/Anki-Android/blob/main/AnkiDroid/src/main/java/com/ichi2/libanki/sched/Counts.kt

arpitmx avatar Apr 07 '22 04:04 arpitmx

I am facing this issue while setting up the project can you plese help me out and i wanna convert Taskmangaer.java async task to kotlin coroutines as i am intrested in the project async task to coroutines image

What version of Android Studio are you using?

image

Jatin887 avatar Apr 07 '22 06:04 Jatin887

it is showing this error but i already set the sdk path in local.properties image

Jatin887 avatar Apr 07 '22 07:04 Jatin887

Currently, I am working on Kotlin Cleanup for HelpDialog.kt

Umesh-01 avatar Apr 07 '22 16:04 Umesh-01