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

Convert all data models and value objects to Kotlin

Open mltbnz opened this issue 3 months ago • 2 comments

Summary

  • Converted all data models and value objects from Java to Kotlin (27 files)
  • Achieved significant code reduction (up to 82% in some cases)
  • Maintained 100% backward compatibility with existing Java code
  • Added Kotlin support to Gradle build configuration

Changes Made

  • Build Configuration: Added Kotlin plugin and dependencies to root and app build.gradle
  • Data Classes: Converted simple data containers to Kotlin data classes (ReceivedChatMessage, etc.)
  • Value Objects: Converted utility classes like PermissionRequest with default parameters and cleaner syntax
  • Business Models: Converted core models (OwnLocationModel, ChatModel, UserModel, etc.) with proper null safety
  • GPX Models: Converted all GPX-related data structures to Kotlin

Technical Details

  • Used @JvmField annotations where needed for Java interoperability
  • Implemented proper null safety with Elvis operators (?:)
  • Maintained original exception behavior for backward compatibility
  • All existing Java code can access Kotlin classes without changes

Testing

  • ✅ All unit tests pass
  • ✅ Lint checks clean
  • ✅ APK builds successfully
  • ✅ No breaking changes to existing functionality

This represents Phase 1 of the Android modernization plan, establishing the foundation for future improvements like coroutines, ViewModels, and modern UI patterns.

🤖 Generated with Claude Code

mltbnz avatar Sep 29 '25 12:09 mltbnz

Hi Malte,

First of all, fyi: I'm currently working on the app again (at least I try to ;) ). One of the main points is upping the minSdk to 26, updating all dependencies, and mainly switching to another mapping library. Migrating to kotlin would have been the next step for me.

I will merge this in a few days as a first step.

Thank you :)

cbalster avatar Sep 29 '25 16:09 cbalster

That's awesome. I started a path to let claude move the codebase over to kotlin since from there on out I think I could also work on adding some features but I am not fully confident about if that would be a good move.

In this PR it probably is not doing any bad.

I want to get into some Android development I think so I could pick up some tasks from the rewrite

mltbnz avatar Sep 29 '25 17:09 mltbnz