apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

[GSOC] Modularization + Jetpack Compose in Android Commons App

Open neeldoshii opened this issue 9 months ago • 12 comments

Regarding Scope of

  • #6618

This issue is created in order to have discussion related on what module, what strategies we should plan on migrating and what modules priority wise we should pick for migrating to compose.

We should have a plan on how we should get this migration done [each module wise eventual migration], benefits and priority on which module we should migrate first.

2nd. While migration what's our plan? should we move with same legacy ui, or we should go with revamp at some places.

Open for everyone's view and suggestion and points.

Based on the discussion https://github.com/commons-app/apps-android-commons/issues/6618#issuecomment-3940885133

neeldoshii avatar Feb 28 '26 19:02 neeldoshii

I think the module which we are migrating we should start using Flow rather than using RxJava & Dagger 2.

  • Ticket Link : https://github.com/commons-app/apps-android-commons/issues/4665

  • Draft Reference PR which converts RxJava to Flow : https://github.com/commons-app/apps-android-commons/pull/6082#issue-2759868027

  • See https://github.com/commons-app/apps-android-commons/issues/6627#issuecomment-3795601466

We should have

Module I think we should migrate and improve I think

  1. Onboarding
  2. Login
  • https://github.com/commons-app/apps-android-commons/issues/6678
  • https://github.com/commons-app/apps-android-commons/issues/6676
  • https://github.com/commons-app/apps-android-commons/issues/6675
  1. Contribution
  2. Upload

It seems we have a lot of bugs at login and upload module and a lot of ANR I have seen at the module of upload reliablity. Will link the releated known bugs in the specific module so since we would be rewriting the module we can fix or take care of the scenarios.

neeldoshii avatar Feb 28 '26 20:02 neeldoshii

Instead of dealing with RxJava migration first, we perform the modularization by copying and pasting the features into separate Android modules at the root of the project. Since we'll not just copy-paste the code, we'll be rewriting and organizing files following the MVVM architecture. So, code migrations like RxJava to Kotlin coroutines can be performed along the way.

This way, we can keep our main app module intact, and it won't affect any other code unless we combine the extracted module into the app module. Also, I believe many of the bugs can be easily fixed if we follow best practices and architecture when modularizing the project.

rohit9625 avatar Mar 02 '26 06:03 rohit9625

I'm not very familiar with modularization tasks, but the process could be like:

1. Convention Plugin (build-logic) Module

  • Since we want to modularize the whole project, it's better to manage all the dependencies in one place and a root-level module (eg. build-logic). Reference: NowInAndroid repository.
  • This way, we can easily add dependencies to any module that we'll create using Convention Plugins by maintaining consistency in versions.

Note: We can take inspiration from the NowInAndroid app, as it uses libraries we already have (e.g., Dagger, Retrofit). But we don't need to follow that entirely, as it has some root-level modules and then sub-modules, which may increase complexity in managing build logic across multiple build files.

2. The core Module

  • I'm not sure about it, but we can have a core module(although all this can exist in the app module itself, acting as a core module + combining all modules.
  • This module can have these sub-folders like data, domain, di, navigation, and ui:
  • The data folder can have:
    • A database for the Room database-related code shared across the app
    • A network for base configuration of Retrofit/any other network library we are using
    • A preferences folder for Preferences Datastore configurations
  • The domain folder can have:
    • A model folder for shared and generic data classes, such as ApiResponse, ApiError, etc., used across all different features/modules
  • A di folder for all Dependency Injection setup for all modules.
    • It may contain files like: DatabaseModule, NetworkModule, AppModule, etc.
    • Commonly extracted from the current di folder inside the app module
  • A navigation folder for managing navigation logic across the app using Jetpack's Navigation 3 library
    • This is where we combine our existing XML screens with Composable Screens incrementally
    • I'm not sure if it's possible to have both types of navigation combined, but we'll give it a try
  • The ui folder can have:
    • A theme folder for color, theme, typography, and shapes configuration
    • A designsystem/components folder for Composable function components, like CustomTextField, ErrorText, PrimaryButton, CustomSwitch, etc., used across the app
    • Some UI utility functions/helper classes

3. Features into Independent Modules

  • Pick any one feature (I think the simplest one would be the auth feature), then: - Create an auth module at the root using Android Studio
  • Add required dependencies using the convention plugins we created in the build-logic module.
  • Set up architecture for the auth module. One architecture that I use, and I think it's used by many other apps as well, i.e., (MVI + MVVM).
  • In this, we create data, domain, and ui layers(folders in the auth module) as recommended architecture by Google
  • The ui layer will have:
    • Our Composable Screens along with UI Events, UI States, and ViewModels
    • For some features or modules, we might be using only MVVM, i.e., directly managing UI states without any separate classes and directly passing functions from ViewModels.
    • This makes sense because for some screens (like onboarding), separate states and events classes would be overkill
  • The domain layer usually contains:
    • The business logic that is independent of data and ui layers.
    • For the auth module, we should create an AuthRepository interface that acts as a contract between the ui and data layers.
    • We can have a UserInputValidator for validating provided email or password constraints in the same layer
  • The data layer:
    • In this module, we must have an implementation for AuthRepository interface
    • The WikiAccountAuthenticatorService and WikiAccountAuthenticator belong to this layer
    • The AuthRepositoryImpl must take the responsibility to log in and log-out user by making use of the WikiAccount related classes
    • The ui layer must not depend on the implementation of the data layer
  • We can optionally have a util folder for feature-wide utility functions/classes

Here's an overview of the above architecture:

Note: Please feel free to suggest improvements and common pitfalls of this architecture. This architecture is all of my understanding of a multi-module project.

graph TD

%% ================================
%% Root Level Modules
%% ================================

    BuildLogic["build-logic\n(Convention Plugins)"]
    App["app module"]

%% ================================
%% Core Module
%% ================================

    subgraph Core["core module"]

        %% Core - Data
        subgraph CoreData["data"]
            CoreDatabase["database\n(Room)"]
            CoreNetwork["network\n(Retrofit base config)"]
            CorePrefs["preferences\n(DataStore)"]
        end

        %% Core - Domain
        subgraph CoreDomain["domain"]
            CoreModels["model\n(ApiResponse, ApiError, etc.)"]
        end

        %% Core - DI
        subgraph CoreDI["di"]
            DatabaseModule
            NetworkModule
            AppModule
        end

        %% Core - Navigation
        subgraph CoreNavigation["navigation"]
            NavGraph["Navigation 3\n(XML + Compose combined)"]
        end

        %% Core - UI
        subgraph CoreUI["ui"]
            Theme["theme"]
            DesignSystem["designsystem / components"]
            UiUtils["UI utils"]
        end

    end

%% ================================
%% Feature: Auth Module
%% ================================

    subgraph FeatureAuth["feature-auth module"]

        %% Feature - UI
        subgraph AuthUI["ui"]
            AuthScreens["Composable Screens"]
            AuthViewModel["ViewModel"]
            AuthState["UI State / Events (optional)"]
        end

        %% Feature - Domain
        subgraph AuthDomain["domain"]
            AuthRepository["AuthRepository (interface)"]
            UserValidator["UserInputValidator"]
        end

        %% Feature - Data
        subgraph AuthData["data"]
            AuthRepositoryImpl["AuthRepositoryImpl"]
            WikiAuthService["WikiAccountAuthenticatorService"]
            WikiAuthenticator["WikiAccountAuthenticator"]
        end

        %% Clean Architecture Flow
        AuthUI --> AuthDomain
        AuthData --> AuthDomain

    end

%% ================================
%% Cross Module Dependencies
%% ================================

    App --> FeatureAuth
    App --> Core

    FeatureAuth --> Core

    BuildLogic --> App
    BuildLogic --> Core
    BuildLogic --> FeatureAuth

rohit9625 avatar Mar 02 '26 07:03 rohit9625

ANRs on the latest version:

  • [libGLES_mali.so] cmpbe_v2_compile_multiple_shaders Input dispatching timed out
  • [libc.so] __ioctl Input dispatching timed out
  • [libart.so] art::gc::Heap::WaitForGcToCompleteLocked Input dispatching timed out
  • Native method - android.os.MessageQueue.nativePollOnce Input dispatching timed out

Older versions that we'll have to confirm if they're still happening:

  • fr.free.nrw.commons.filepicker.PickedFiles.getMimeType
  • chromium-TrichromeWebViewGoogle6432.aab-stable-749914633
  • fr.free.nrw.commons.media.MediaDetailPagerFragment$setViewPagerCurrentItem$runnable$1.run
  • android.text.StaticLayout.getBaseHyphenationFrequency
  • [base.apk] org.chromium.base.JavaExceptionReporter.uncaughtException SIGABRT
  • fr.free.nrw.commons.upload.FileProcessor.save
  • fr.free.nrw.commons.wikidata.json.RequiredFieldsCheckOnReadTypeAdapterFactory.collectRequiredFields
  • fr.free.nrw.commons.auth.SignupActivity.onCreate
  • fr.free.nrw.commons.wikidata.WikidataEditService.getDepictionsClaimIds
  • Native method - android.os.MessageQueue.nativePollOnce Root cause for this ANR is unknown
  • fr.free.nrw.commons.explore.map.ExploreMapFragment.moveCameraToPosition
  • fr.free.nrw.commons.auth.csrf.CsrfTokenClient.getTokenBlocking
  • [libc.so] abort SIGABRT

These were all the ANRs observed in the last 60 days.

RitikaPahwa4444 avatar Mar 06 '26 20:03 RitikaPahwa4444

Hi, I'm Shoaib, a native Android developer with 3 years of professional experience. My Android journey started with Java + XML, then Kotlin + XML, and for the past 1.5 years I've been delivering production projects exclusively in Kotlin + Jetpack Compose. I have deep experience with Compose from layouts to advanced topics like Canvas, custom drawing APIs, and Material 3 / Material 3 Expressive components — which makes me particularly well-suited for the Modularization + Compose migration work. I've already been exploring the codebase and submitted my first PR #6742 fixing a Snackbar UI bug. I'm very interested in contributing to this GSoC 2026 project. Could you share any specific areas of the codebase you'd like contributors to focus on first for the Compose migration?

Shoaibkhalid65 avatar Mar 16 '26 13:03 Shoaibkhalid65

Hi @RitikaPahwa4444, could you please let me know if we can proceed with the architecture and approach that I suggested in the above comment? I'm creating my proposal for this year's project, and that's why I need a clarification on the architecture to explain it clearly in my proposal.

Feel free to suggest changes in that :)

rohit9625 avatar Mar 24 '26 15:03 rohit9625

Architecture alignment should ideally be done with the mentors after the GSoC selection results are out. This is your proposal @rohit9625, feel free to share what you feel should be the design and scope it based on what you feel you could deliver in a span of 3 months. Design reviews never have a binary answer (yes or no), it always evolves based on the discussions.

Keeping that flexibility in mind, it should, however, be reasonably accurate, and that's what we check for during the application phase. And for that - yes, it's a fairly good plan with enough clarity that can be added to a GSoC proposal :)

@neeldoshii @sivaraam please do add in case you're looking for anything specific in the proposals. Unlike the other project, tasks aren't broken down for this one, so it might not be easier to navigate for the applicants.

RitikaPahwa4444 avatar Mar 24 '26 15:03 RitikaPahwa4444

Thank you @RitikaPahwa4444 for clarification. I'll keep the proposal limited to my capabilities for now and we can discuss after results :)

rohit9625 avatar Mar 24 '26 16:03 rohit9625

As this project didn't had any accepted proposal from Gsoc 26 so what is the roadmap ahead?

THORzero9 avatar May 08 '26 12:05 THORzero9

I'm planning to write a mail to WMF to see if there's any other way to take the project forward. Many orgs offer an internship to retain their top contributors, but I don't remember seeing any similar program run by Wikimedia.

If it doesn't work out in our favour, then since we won't have a dedicated intern this year to work on this project, the only way I could see this project moving is by breaking it down into similar tasks for the volunteers. Given it was ranked among the lowest, the mentors might not be willing to take it up in a future GSoC edition.

RitikaPahwa4444 avatar May 10 '26 12:05 RitikaPahwa4444

Yes, Mifos Initiative also runs MSoC(Mifos Summer of Code). Anyways, even if we don't get any support, I'm always interested in working on this project. However, I'm first looking for full-time roles now 😅

rohit9625 avatar May 10 '26 15:05 rohit9625

The project is quite critical in terms of future maintainability, so let's hope even if there are no options readily found, the community can take it up in smaller chunks.

THORzero9 avatar May 10 '26 15:05 THORzero9