Skip to content

Migration of Java Code to Kotlin for Enhanced Code Consistency and Maintainability #5928

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

Open
Saifuddin53 opened this issue Nov 15, 2024 · 19 comments
Assignees

Comments

@Saifuddin53
Copy link
Contributor

What is the user problem or growth opportunity you want to see solved?

The current codebase consists of a mix of Java and Kotlin, which introduces inconsistencies and can make the code harder to maintain and extend. Migrating fully to Kotlin would streamline the code, reduce verbosity, and provide a more cohesive developer experience. This transition would also open up future opportunities to leverage Kotlin Multiplatform (KMP), facilitating easier expansion to iOS if desired.

How do you know that this problem exists today? Why is this important?

Android development is increasingly Kotlin-centric, as it’s the recommended language with strong support for modern Android features, readability, and efficiency improvements. Having a consistent codebase fully in Kotlin will improve maintainability and simplify onboarding.

Who will benefit from it?

  • Developers: A fully Kotlin-based codebase will improve readability, maintainability, and efficiency, enhancing the developer experience.
  • Project Maintainability: This alignment with modern Android standards will simplify contributions and align with future technology trends.
  • End Users: Indirectly, users will benefit from a well-maintained app that can more easily adopt new features and improvements.

Anything else you would like to add?

Once the migration to Kotlin is complete, further modernization could include adopting Jetpack Compose for the UI layer, reducing XML dependency, and simplifying the UI structure. This approach would prepare the project for KMP, creating a strong foundation for potential iOS app development in the future.

@misaochan
Copy link
Member

I agree wholeheartedly with your points, and we started the process several years ago. It will take a long time and quite a lot of work, however, as it involves rewriting large portions of the app. Would you be interested in working on this, @Saifuddin53 ?

@Saifuddin53
Copy link
Contributor Author

Yes @misaochan @nicolas-raoul, I'm interested in contributing to this migration process.

I plan to start with the utility/helper classes, as they are more isolated and easier to migrate. After completing that, I’ll adopt a module-wise approach, focusing on one module at a time to ensure smooth transitions and minimal disruptions.

Alternatively, if needed, I can prioritize specific areas, such as the data layer or UI components. Since this involves a large amount of work, anyone interested in joining the migration process is more than welcome to collaborate. It would be great to share the workload and move faster while ensuring high-quality results.

@misaochan
Copy link
Member

That sounds great, thank you very much. :) I'll assign you to this @Saifuddin53 , but if anyone else is interested, please feel free to chime in. Unlike other issues, I think it should be fine for multiple people to work on this one, as it is a huge task. We can probably add a checklist later to track the PRs as they come in.

@Saifuddin53
Copy link
Contributor Author

Thank you so much for assigning me to this, @misaochan

Also, for anyone who’d like to join this migration effort:

  1. Check if someone is already working on the file/module you’re interested in. This can be done by looking at the existing issues or PRs related to the migration.

  2. Create a ticket/issue for the files or modules you’re taking on, if no one is already working on them. In the ticket:

    • Mention the parent migration ticket.
    • Specify the files/modules you plan to work on.

This approach will help us stay coordinated and avoid overlaps.

@neeldoshii
Copy link
Contributor

Working on Bookmark module & Achievement Module

@neeldoshii
Copy link
Contributor

I guess its better to migrate a class by class to java to kotlin rather than a module by module. isn't it? Focusing more on refactoring our previous java code too as things in kotlin gives us lot of advantage to null pointer and fixing our lint issues since its a whole rewrite. What's your take?

@Saifuddin53
Copy link
Contributor Author

Alternatively, if needed, I can prioritize specific areas, such as the data layer or UI components.

Of course, that's a valid point, @neeldoshii. You can also take that approach too, as mentioned earlier. A hybrid approach might work well here. However, there are also benefits to the module-by-module approach, it allows us to complete logical chunks of the application which can be tested and reviewed in isolation.

@psh
Copy link
Collaborator

psh commented Jan 2, 2025

If the project has agreed that moving to Kotlin is a sensible idea (it seems to be), then what do we need to do to make this happen?

Chris, read back up this issue, and see all of the merges and people posting to claim packages? It already is happening; the grass-roots / self-organizing movement is doing great. Make a cup of tea, sit back and maybe have some fun - visualize the updates to the project with a tool like Gource 😄

@chrisdebian
Copy link

Thanks, Paul; i've already moved on. The 500 bugs will sort themselves, even the ones that are 10 years old. I'll continue as a Commons user, and leave organising to those best able to do it.

Chris

@psh
Copy link
Collaborator

psh commented Jan 7, 2025

Quick check on status - searching for a count of Java files remaining in packages -

Package java files
bookmarks 3 #6017 in progress - @Saifuddin53
bookmarks/items 4 #6017 in progress - @Saifuddin53
bookmarks/locations 4 #6017 in progress - @Saifuddin53
bookmarks/pictures 4 #6017 in progress - @Saifuddin53
concurrency 4
contributions 16
explore 5
explore/depictions 1
explore/map 5
explore/recentsearches 3
media 7
media/zoomControllers/gestures 2
media/zoomControllers/zoomable 9
nearby 15
nearby/contract 1
nearby/fragments 1
profile 1

Great work all! Let's keep it going!

@Saifuddin53
Copy link
Contributor Author

@psh bookmarks items, locations, pictures would also be covered in #6017 :)

@Sujal-Gupta-SG
Copy link
Contributor

@nicolas-raoul Can i also work on this issue so that work get completed fastly

@Saifuddin53
Copy link
Contributor Author

Yes @Sujal-Gupta-SG, feel free to go ahead and start working on it. Choose a package or file you'd like to work on, create an issue for it, and begin your work. Once you're done, submit a pull request. 🙂

@Sujal-Gupta-SG
Copy link
Contributor

@psh I have done profile package, can you assign the issue #6118 and check whether it satisfy the condition i have raised the pull request also #6119, if not then i can again work on it

Sujal-Gupta-SG added a commit to Sujal-Gupta-SG/apps-android-commons that referenced this issue Jan 11, 2025
Sujal-Gupta-SG added a commit to Sujal-Gupta-SG/apps-android-commons that referenced this issue Jan 11, 2025
nicolas-raoul pushed a commit that referenced this issue Jan 16, 2025
* Rename .java to .kt

* Migrate Profile Package to Kotlin #6118 #5928

* Migrate Profile Package to Kotlin #6118 #5928

* Migrate Profile Package to Kotlin #6118 #5928
@Sujal-Gupta-SG
Copy link
Contributor

I am migrating contribution folder if anyone is doing already let me know

@psh
Copy link
Collaborator

psh commented Apr 17, 2025

Based on what is currently on the main branch, I am seeing the remaining Java files needing conversion, based on running the Unix command

find . -name \*.java >> remaining.txt 

Nearby

nearby/NearbyController.java
nearby/PlacesLocalDataSource.java
nearby/contract/NearbyParentFragmentContract.java
nearby/Sitelinks.java
nearby/Label.java
nearby/Place.java
nearby/NearbyfilterSearchListView.java
nearby/PlaceDao.java
nearby/PageEditHelper.java
nearby/CheckBoxTriStates.java
nearby/NearbyNotificationCardView.java
nearby/PlacesRepository.java
nearby/NearbyPlaces.java
nearby/MarkerPlaceGroup.java
nearby/NearbyFilterSearchRecyclerViewAdapter.java
nearby/NearbyFilterState.java

Explore

explore/ExploreListRootFragment.java
explore/ExploreFragment.java
explore/depictions/WikidataItemDetailsActivity.java
explore/ParentViewPager.java
explore/map/ExploreMapContract.java
explore/map/ExploreMapFragment.java
explore/map/ExploreMapPresenter.java
explore/map/ExploreMapCalls.java
explore/map/ExploreMapController.java
explore/ExploreMapRootFragment.java
explore/recentsearches/RecentSearchesDao.java
explore/recentsearches/RecentSearchesContentProvider.java
explore/recentsearches/RecentSearchesFragment.java
explore/SearchActivity.java

Bookmarks

bookmarks/pictures/BookmarkPicturesContentProvider.java
bookmarks/pictures/BookmarkPicturesDao.java
bookmarks/pictures/BookmarkPicturesController.java
bookmarks/pictures/BookmarkPicturesFragment.java
bookmarks/BookmarkFragment.java
bookmarks/BookmarkListRootFragment.java
bookmarks/items/BookmarkItemsController.java
bookmarks/items/BookmarkItemsContentProvider.java
bookmarks/items/BookmarkItemsDao.java
bookmarks/items/BookmarkItemsFragment.java
bookmarks/BookmarksPagerAdapter.java

Media

media/CaptionListViewAdapter.java
media/MwParseResult.java
media/CustomOkHttpNetworkFetcher.java
media/Caption.java
media/MwParseResponse.java
media/CommonsWikibaseItem.java
media/MediaDetailPagerFragment.java

Top Level

WelcomeActivity.java
MapController.java
License.java
ViewHolder.java
Utils.java
MvpView.java
BasePresenter.java
WelcomePagerAdapter.java
OkHttpConnectionFactory.java
ViewPagerAdapter.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants