Skip to content

Migrate to Jetpack Compose and modernize Android stack#1

Open
Badranh wants to merge 3 commits intomasterfrom
claude/refactor-library-70rln
Open

Migrate to Jetpack Compose and modernize Android stack#1
Badranh wants to merge 3 commits intomasterfrom
claude/refactor-library-70rln

Conversation

@Badranh
Copy link
Copy Markdown
Owner

@Badranh Badranh commented Feb 8, 2026

Summary

This PR modernizes the CodingHive project by migrating from the legacy Android Support Library to AndroidX, upgrading to Jetpack Compose for the UI layer, and replacing RxJava with Kotlin Coroutines. The project now targets Android 14 (API 34) with Java 17 compatibility.

Key Changes

Build Configuration

  • Migrated from old Gradle plugin syntax to new plugins DSL
  • Updated compileSdk from 28 to 34 (Android 14)
  • Updated minSdk to 21, targetSdk to 34
  • Added Kotlin support with kotlinOptions configuration
  • Enabled Jetpack Compose with kotlinCompilerExtensionVersion 1.5.1
  • Updated Java/Kotlin target compatibility to version 17

Dependencies

  • Replaced Android Support Library with AndroidX equivalents
  • Added Jetpack Compose BOM and core Compose libraries (ui, material3, tooling)
  • Replaced RxJava/RxAndroid with Kotlin Coroutines
  • Replaced Dagger with Koin for dependency injection
  • Updated test dependencies to latest versions (JUnit 4.13.2, Espresso 3.5.1)
  • Added Navigation Compose for screen navigation
  • Added ViewModel and Lifecycle Compose integration

Architecture & Code

  • Removed legacy MVP pattern (MainActivity, WorkingProjectActivity, Presenters, Contracts)
  • Replaced with modern MVVM using Jetpack Compose and Kotlin Coroutines
  • Converted Java classes to Kotlin (FileSystem, ProjectRepository)
  • Implemented new Compose-based screens (ProjectsScreen, EditorScreen)
  • Added Koin dependency injection module with viewmodels and repositories
  • Created CodingHiveApplication class for Koin initialization
  • Simplified AndroidManifest.xml with namespace declaration and removed unused activities

UI Layer

  • Migrated from XML layouts to Jetpack Compose
  • Implemented EditorScreen with file tabs, code editor, and file management
  • Implemented ProjectsScreen for project selection
  • Added Material3 theming support
  • Implemented navigation using Compose Navigation

Data Layer

  • Refactored FileSystem to use Kotlin coroutines instead of RxJava
  • Created ProjectRepository as single source of truth for project/file operations
  • Improved error handling with proper logging

Notable Implementation Details

  • Uses Koin for lightweight dependency injection instead of Dagger
  • Implements MVI (Model-View-Intent) pattern with state management via StateFlow
  • All file I/O operations use Dispatchers.IO for non-blocking execution
  • Compose-based UI eliminates need for custom views and XML layouts
  • Navigation handled through Compose NavHost with type-safe arguments

https://claude.ai/code/session_011ivzksCxix6VawrbeBoUgK

…up dependencies

Bug fixes:
- Fix NPE in Projects.listDirs() and WorkingProject.listFilesInDir() when
  listFiles() returns null (directory doesn't exist or isn't readable)
- Fix swapped parameters in FileSystem.saveFile() where directory and filename
  were reversed in the File constructor
- Fix RxJava subscribeOn/observeOn being swapped in ChooseProject Presenter
  (subscribeOn should be io, observeOn should be mainThread)
- Add missing onComplete() call in Projects.listDirs() Observable
- Fix deleteFile() calling deleteFileWarning() after deletion already started

Architecture improvements:
- Decouple ViewHolder from Presenter contracts - adapters now bind data
  themselves using data-returning methods instead of passing ViewHolders
  to the presenter
- Rename contract interfaces: UserActions -> PresenterContract for consistency
- Extract dialog creation into dedicated methods in Activities
- Improve MVP separation of concerns

Code quality:
- Use try-with-resources for all IO operations in FileSystem (fixes resource leaks)
- Replace empty catch blocks with proper Log.e() error logging
- Make singleton pattern thread-safe with double-checked locking and volatile
- Add private constructors to singleton classes
- Use File.separator and File constructor for path building instead of string
  concatenation
- Improve variable naming (model1 -> workingProjectModel, subscribe ->
  loadProjectsDisposable, etc.)
- Add proper null-safety checks throughout
- Reset codeChangedSinceLastSave on file open and successful save
- Clear editor when currently-open file is deleted
- Remove unused Dagger 2 dependency (was declared but never used)
- Organize build.gradle dependencies into logical groups
- Fix CachingFactory naming conventions (FontMap -> fontCache)
- Update app name from placeholder to Coding Hive IDE

https://claude.ai/code/session_011ivzksCxix6VawrbeBoUgK
…h Coroutines

Complete rewrite from MVP/Java/XML/RxJava to MVI/Kotlin/Compose/Coroutines:

Architecture (MVI):
- State: Immutable data classes representing entire screen state
- Intent: Sealed interfaces for all user actions
- Effect: One-shot side effects (navigation, toasts) via Channel
- ViewModel: Processes intents, updates StateFlow, emits effects

Build system:
- Upgrade Gradle 4.4 -> 8.2, AGP 3.1.4 -> 8.1.2
- Add Kotlin 1.9.0 with Compose compiler 1.5.1
- Add Compose BOM 2023.10.01 with Material3
- Add Navigation Compose, ViewModel Compose
- Add Kotlinx Coroutines
- Remove RxJava, RxAndroid, RxBinding
- Remove Dagger 2 (was unused)
- Remove SyntaxView XML library (replaced by Compose TextField)
- Remove Android Support libraries (migrated to AndroidX)
- Update compileSdk/targetSdk 28 -> 34

New file structure:
- data/FileSystem.kt - File I/O with suspend functions
- data/ProjectRepository.kt - Repository pattern over file system
- ui/projects/ - Projects screen (State, Intent, ViewModel, Screen)
- ui/editor/ - Editor screen (State, Intent, ViewModel, Screen)
- ui/theme/ - Material3 dark theme matching original design
- MainActivity.kt - Single activity with Compose
- CodingHiveApp.kt - Navigation host

Removed:
- All 13 Java files (MVP presenters, contracts, adapters, models)
- All 5 XML layout files (replaced by Compose)
- CodingTextView/CachingFactory (font handled by Compose FontFamily)
- FiraCode font moved from assets/ to res/font/ for Compose access

https://claude.ai/code/session_011ivzksCxix6VawrbeBoUgK
…ity, add Koin DI

- Move all hardcoded strings to strings.xml with proper resource IDs
- Update effects to use @stringres Int instead of raw strings
- Separate Screen(vm) from ScreenContent(state, onIntent) in both screens
- Add Koin dependency injection: AppModule, CodingHiveApplication, koinViewModel()
- Remove default constructor parameters to let Koin handle wiring

https://claude.ai/code/session_011ivzksCxix6VawrbeBoUgK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants