kiwix-android icon indicating copy to clipboard operation
kiwix-android copied to clipboard

Convert Project to Kotlin

Open macgills opened this issue 4 years ago • 52 comments

Is your feature request related to a problem? Please describe. Kotlin is our primary language but 40% of the codebase is still in java, this ticket aims to get that number to 0%. If you want to contribute to the project but are finding it diffcult to find a suitable ticket of a manageable size then this is for you!

Describe the solution you'd like Comment here that you want to convert a class (I recommend starting with small ones) with the class name to claim it. Then make a ticket and start working on it. Use ctrl+alt+shift+k to automatically convert the file and then improve it to be more idiomatic kotlin.

Additional context If you have never worked in kotlin before the koans (and the kotlin docs in general) are a good way to get used to the features. There is also support from kiwix members if you want to open a PR in draft

macgills avatar Feb 27 '20 09:02 macgills

@macgills @kelson42 can I work on this issue. I will start converting file from intro folder and let you know as i progress further

AjayThakur12 avatar Feb 27 '20 17:02 AjayThakur12

@AjayThakur12 Yes, but do piece by piece. Module by module.

kelson42 avatar Feb 27 '20 18:02 kelson42

@macgills @kelson42 can i convert the local_file_transfer folder to kotlin ?

rohanprasadofficial avatar Feb 27 '20 19:02 rohanprasadofficial

@AjayThakur12 a module is a bit larger than my original intention but intros classes are quite small

@rohanprasadofficial I would say LocalFileTransfer is too large to tackle all as one ticket. Try WifiDirectManager, that is over 400 lines, probaby more than the entire intro module.

Both of you please make specific tickets Convert X to kotlin

macgills avatar Feb 28 '20 08:02 macgills

@macgills okay great , thanks i will do WifiDirectManager then

rohanprasadofficial avatar Feb 28 '20 08:02 rohanprasadofficial

@macgills can i work on this?

thelosergeek avatar Mar 11 '20 21:03 thelosergeek

@thelosergeek Yes, Please open a ticket with the part you want to move to Kotlin.

kelson42 avatar Mar 12 '20 07:03 kelson42

@macgills @kelson42, I also want to contribute to the project, is there any class which is not assigned to anyone, I can convert to kotlin.

Dalakoti07 avatar Mar 12 '20 13:03 Dalakoti07

Comment here that you want to convert a class (I recommend starting with small ones) with the class name to claim it. Then make a ticket and start working on it.

Everyone should follow the directions of this ticket.

@Dalakoti07 go looking for a class (over 40% of the project is still in java), find one you like, comment its name here and make sure nobody else has already commented then make a ticket and get to work.

This ticket is meant to be a haven of autonomy mostly because my time is a bit limited right now and also I love seeing classes converted to kotlin.

macgills avatar Mar 12 '20 16:03 macgills

I want to convert HelpActivity.

yash1ts avatar Mar 13 '20 15:03 yash1ts

@yash1ts make a ticket

macgills avatar Mar 13 '20 15:03 macgills

You mean I need to make a new issue and mention this issue there right?

yash1ts avatar Mar 13 '20 17:03 yash1ts

You mean I need to make a new issue and mention this issue there right?

Yes, and you make the corresponding PR with the "fix"

kelson42 avatar Mar 13 '20 17:03 kelson42

can i work on this?

jonggeunpark avatar Apr 27 '20 03:04 jonggeunpark

@jonggeunpark yes, open a ticket and then a PR with the piece of code you want to convert.

kelson42 avatar Apr 27 '20 06:04 kelson42

I would like to convert KiwixWifiP2pBroadcastReceiver.java class to Kotlin

s-ayush2903 avatar Jun 21 '20 14:06 s-ayush2903

I would like to convert SharedPreferenceUtil.java class to Kotlin

s-ayush2903 avatar Jul 10 '20 17:07 s-ayush2903

@kelson42 @macgills I would Like to convert LocaleFileTransferActivity.java file into kotlin #2249

ritvikmahajan17 avatar Aug 04 '20 05:08 ritvikmahajan17

I want to convert ErrorActivity.java into Kotlin file

prayutsu avatar Aug 18 '20 08:08 prayutsu

@prayutsu great, please make that ticket

macgills avatar Aug 18 '20 08:08 macgills

@macgills I want to convert FileReader.java to kotlin.

gouri-panda avatar Aug 20 '20 06:08 gouri-panda

I would like to convert AddNoteDialog.java class to Kotlin

gouri-panda avatar Aug 22 '20 16:08 gouri-panda

I would like to convert HotspotNotificationManager.java to Kotlin

NullByte08 avatar Aug 23 '20 10:08 NullByte08

I would like to convert RateAppCounter.java and HelpAdpater.java to Kotlin

gouri-panda avatar Aug 27 '20 12:08 gouri-panda

I would like to convert KiwixWebView.java class to Kotlin

gouri-panda avatar Sep 04 '20 18:09 gouri-panda

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

stale[bot] avatar Dec 04 '20 20:12 stale[bot]

I want to contribute on it.

yyprince334 avatar Mar 16 '21 18:03 yyprince334

I would like to convert LibraryViewCallback.java to Kotlin

simonnepinto avatar Mar 28 '21 03:03 simonnepinto

@simonnepinto please go ahead! But first creat a ticket for that class.

gouri-panda avatar Mar 28 '21 06:03 gouri-panda

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

stale[bot] avatar Jun 04 '21 15:06 stale[bot]

i think this issue is already solved

if not then please tell me what changes can I do?

Rishavgupta12345 avatar Sep 22 '21 06:09 Rishavgupta12345

Do we have a list of modules which still need to be converted?

kelson42 avatar Sep 22 '21 08:09 kelson42

@kelson42 A couple of handfuls of java files are still here. https://github.com/search?p=5&q=repo%3Akiwix%2Fkiwix-android+language%3AJava&type=Code

gouri-panda avatar Sep 22 '21 18:09 gouri-panda

@kelson42 @gouri-panda WHENEVER I AM DOING A COMMIT ON YOUR CLONED PROJECT I AM GETTING "commit failed with error" and the commit is failing . CAN YOU PLEASE HELP ME OUT ?

DESCRIPTION OF ERROR :

Running lint... Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details > Task :buildSrc:compileKotlin FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':buildSrc:compileKotlin'. > Kotlin could not find the required JDK tools in the Java installation 'C:\Program Files\Java\jre1.8.0_301' used by Gradle. Make sure Gradle is running on a JDK, not JRE. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 10s > Task :buildSrc:compileKotlin FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':buildSrc:compileKotlin'. > Kotlin could not find the required JDK tools in the Java installation 'C:\Program Files\Java\jre1.8.0_301' used by Gradle. Make sure Gradle is running on a JDK, not JRE. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 2s Static analysis found violations and attempted to autofix, please commit these autoformat changes

Rishavgupta12345 avatar Sep 28 '21 05:09 Rishavgupta12345

@Rishavgupta12345 It's complaining that you are using a greater version of JDK 8 when your gradle is only compatible up to a JDK 8version. You need Java 8 or above JDK and not just JRE. Let me know if you still got errors.

gouri-panda avatar Sep 28 '21 18:09 gouri-panda

@gouri-panda yes I did the following changes which you asked but things are not committing yet. but the error has changed from before

description of error:- Starting a Gradle Daemon, 1 incompatible and 4 stopped Daemons could not be reused, use --status for details FAILURE: Build failed with an exception. * What went wrong: Unable to start the daemon process. This problem might be caused by incorrect configuration of the daemon. For example, an unrecognized jvm option is used. Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/6.2/userguide/gradle_daemon.html Process command line: C:\Program Files\Java\jdk1.8.0_301\bin\java.exe -Xmx4096m -Dfile.encoding=windows-1252 -Duser.country=IN -Duser.language=en -Duser.variant -cp C:\Users\risha.gradle\wrapper\dists\gradle-6.2-all\dvufqs6kielxeao781pmk5huj\gradle-6.2\lib\gradle-launcher-6.2.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.2 Please read the following process output to find out more: ----------------------- * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org FAILURE: Build failed with an exception. * What went wrong: java.net.BindException: Address already in use: Cannot bind * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org Static analysis found violations and attempted to autofix, please commit these autoformat changes

Rishavgupta12345 avatar Sep 29 '21 06:09 Rishavgupta12345

@Rishavgupta12345 You can ask these questions on our slacks Android channel. We can discuss over there. Ask in Android channel and I'll get back to you :)

gouri-panda avatar Sep 29 '21 07:09 gouri-panda

hey, @gouri-panda I would like to convert matcher.java to matcher.kt, and can you explain to me what does it mean by first create a ticket for that class. Thanks :)

cdhiraj40 avatar Oct 20 '21 05:10 cdhiraj40

@cdhiraj40 Github Issues let you track your work on GitHub. If you create an issue then you want to solve this issue, then the issue can assign to you. That's how anyone's work doesn't conflict with each other. If you want to convert a java class file to kotlin then you need to create an issue first if it isn't created yet. In this way, It'll keep track of which files are underway from java to kotlin, and also other contributors will know that if someone is working or not if they are interested in this class to convert java to kotlin.

gouri-panda avatar Oct 20 '21 09:10 gouri-panda

issues let you track your work on GitHub

@cdhiraj40 Github Issues let you track your work on GitHub. If you create an issue then you want to solve this issue, then the issue can assign to you. That's how anyone's work doesn't conflict with each other. If you want to convert a java class file to kotlin then you need to create an issue first if it isn't created yet. In this way, It'll keep track of which files are underway from java to kotlin, and also other contributors will know that if someone is working or not if they are interested in this class to convert java to kotlin.

Okay thanks again for explaining, I will make a new issue if it hasn't been created yet :)

cdhiraj40 avatar Oct 20 '21 10:10 cdhiraj40

I want to contribute on this issue. Are there any classes left on which I can work ?

Im-Kunal-13 avatar Nov 29 '21 03:11 Im-Kunal-13

I want to contribute on this issue. Are there any classes left on which I can work ?

yes there are, here checkout https://github.com/search?p=5&q=repo%3Akiwix%2Fkiwix-android+language%3AJava&type=Code (for some PRs have been created so do check first :)

cdhiraj40 avatar Nov 29 '21 03:11 cdhiraj40

I would like to convert Datasource.java and KiwixIdlingResource.java

cdhiraj40 avatar Dec 10 '21 12:12 cdhiraj40

Can I work on this issue?

aneeshgupta25 avatar Jan 31 '22 16:01 aneeshgupta25

if there are still issues left then I would like to contribute to this one.

the-illuminatus avatar Feb 04 '22 15:02 the-illuminatus

hello @aneeshgupta25 and @the-illuminatus pick any java file from here https://github.com/search?p=5&q=repo%3Akiwix%2Fkiwix-android+language%3AJava&type=Code and convert it to kotlin and make a PR! Don't forget to check if PR for some file has already been created and if not then do create an issue for your file :)

cdhiraj40 avatar Feb 04 '22 17:02 cdhiraj40

@cdhiraj40 Thanks.. Will definitely work on it.. :)

aneeshgupta25 avatar Feb 04 '22 21:02 aneeshgupta25

@cdhiraj40 I am working on the templates.java file but there's this variable "CUSTOM_APP_HAS_EMBEDDED_ZIM " and is initialized to. ~embed_zim~ I am not able to figure out what's ~ symbol in JAVA and about embed_zim. Can you plz guide me about this..?

aneeshgupta25 avatar Feb 05 '22 08:02 aneeshgupta25

@cdhiraj40 @gouri-panda seeking your review and further guidance. This is my first contribution in open source

aneeshgupta25 avatar Feb 07 '22 13:02 aneeshgupta25

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 06:04 stale[bot]

@MohitMaliFtechiz @gouri-panda How much work is left here? I’m not really wanting to keep sucha ticket far more longer open.

kelson42 avatar Aug 26 '22 05:08 kelson42

hi @kelson42 , all files are converted to Kotlin , waiting for PR reviewed.

MohitMaliFtechiz avatar Sep 05 '22 13:09 MohitMaliFtechiz