Skip to content

Welcome new Android components and architecture #2351

@davigonz

Description

@davigonz

Android is getting more mature and modern and it would be great to start using some of the next technologies to make the ownCloud Android app more robust, testable and future-proof:

Besides, we will modularize the app in different layers

You can find all the sections below more widely describe in:

From MVC to MVVM + Android arch components

3 -New-arch-get-public-shares

Modularization with layers approach

4_-ownCloud-Android-app-modularization

ownCloud modularization (updated)

  • Advantages:

    • Scalability: several developers working independently in different modules.
    • Maintainability: gradle can build modules faster since the classes and resources are separated in different modules. CI builds will be accelerated too.
    • Less tests to run when there's a new change: we need to run the tests in the module affected by that change and anything else that depends on it. We do not need to run all the tests if other modules are not impacted by the changes.
    • Reduce dependencies => less coupled code.
    • SWITCH MODULES: if in the future we want an app with a different UI and a different way to handle the information to show, we would just need to replace the :ownCloudApp module. And the same for the rest of modules, if one day we want to handle data differently to the current implementation, replacing the :ownCloudData module should be enough.
  • Key points:

    • Domain should not depend on data layer directly, use repository interfaces created in domain layer.
  • I/0 '19 talk: https://youtu.be/PZBg5DIzNww

New error and data handling

  • RemoteOperationResult object will not longer appear above data layer, the remote datasources will retrieve data or throw new exceptions to upper layers.
  • These new exceptions will be encapsulated in a UseCaseResult object in domain layer.
  • Datasources should retrieve domain model objects, transforming them from data model objects. Example: Data layer working with ShareEntity and transforming it to Share before pushing it to upper layers.
  • ViewModels will handle UseCaseResult objects and transform the information contained there in new UIResult objects.

New data and error handling

Dependency graph

I've found an open source tool called Apk dependency graph that could help us to follow the decoupling process.

This is how the dependency graph for the ownCloud Android app looks like, based on New arch - capabilities branch (I put it live in https://davigonz.github.io/oCAndroidDependencyGraph/ so everyone can play with it) :

Screenshot 2019-04-24 at 18 31 14

Above we can notice some parts of new architecture (OCShareRepository, OCShareViewModel, OCCapabilityRepository, OCCapabilityViewModel...) along with old code.

And below there's an example of a good architecture with low class coupling:

Screenshot 2019-04-24 at 18 33 25

Taking into account this diagram while working on the new architecture would be great and will allow us to have a higher level vision and complete the whole app transformation process.

So we could use this issue as an epic and create possible changes that come to our mind after having a look at the diagram.

Note: the diagram is currently hosted as a webpage in https://davigonz.github.io/oCAndroidDependencyGraph/ and it uses this repo but we could move it with the rest of ownCloud repositories and even update the diagram via some kind of script included in bitrise (not sure if is possible, need to be checked) and have it updated with new arch changes.

Initial tasks

CC / @jesmrec @michaelstingl

Issues to have a look at

#1447

Code enhancements

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions