MartinXPN / SpellNote

Android Java app for spell-checking and note-taking

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SpellNote

SpellNote is an android application designed for creating texts, taking notes, editing and correcting essays, etc. It supports spell-checking in offline mode. The app is designed for multiple languages. Currently English, Russian and Armenian are supported. The number of languages will grow in the near future.

SpellNote is the updated version of my first android project ProCorrector. After publishing several updates of ProCorrector I realised that the code was written so terribly that it was almost impossible to maintain and decided to write everything from scratch. As PlayStore doesn't allow changes in packagename I had to release SpellNote as a separate app because the packagename of Procorrector didn't match with this project.

Structure

First thing that was missing in ProCorrector was a concrete scructure of the project that would allow easy navigation and a more maintainable code. Some android projects use type-based structure having packages like activities, fragments, etc... However I think that this kind of structure gets messy quite easy when the number of fragmetns or activities become large.

SpellNote uses something very similar to Clean Architecture pattern.

app
|
|---> models   ->   EntityClasses
|---> services ---> one service-package for each entity
|---> ui       ---> MVVM
|---> util     -> UtilityClasses
  • Models that are simple POJO classes don't have any dependencies. They just define the entities in the project.

  • Services are simple interfaces that need to define the behaviour of a specific action (an http request to fetch all available languages or save the current document. The latter can be done either with an http request or by writing to a local storage and it's the responsibility of a repository to define its behaviour). Services "know" about models, yet they have no idea about being in an android platform or any other package.

  • Repositories are sub-packages of services and they implement a specific service. Say a service defines how to add a word to dictionary. It may have two separate subpackages one of which defines how to save a word locally and another one sends an http request to a server.

  • UI package includes all the android code. It "knows" about all other packages. It defines both the behaviour of views and the logic of which service to use and when. Yet, putting everything in one activity class would be too stupid and everything would become unmaintainable again. Thats why we're using MVVM design patter to separate models from views and the way each model is glued to its view.

Design Pattern - MVVM

As android is currently supporting data-binding, MVVM paradigm becomes very appealing while developing android apps. MVVM = (Model + View + ViewModel).

  • Model: Entity that contains needed information to be displayed inside a View. It doesn't "know" anything about view or even ViewModel. It needs to be be self contained and depend only on itself (or maybe other models).
  • View: Activities, Fragments, etc are considered to be views. Views don't do anything "smart". They just display information provided by ViewModel.
  • ViewModel: These classes glue together Views and Models. They are responsible for delegating triggers to services which make API calls, interact with databases etc. ViewModels are responsible for presentation logic and all the "clever" part of the code for presenting information inside View. ViewModels "know" about Models, Services but they don't contain android dependent code. That means they don't set onClick listeners or anything like that. However the logic of what needs to be done when click is performed is implemented inside a ViewModel. View is responsible in delegating the click event to ViewModel.

Concurrency - RxJava

For a good and easy support for threading we've used RxJava/RxAndroid. Any part of code that has something to do with concurrency is using RxJava. For making code cleaner and more understandable we've used Java 8 (with its support for lambda expressions, etc).

Libraries & Tools

This project makes use of several libraries and tools that make code much more readable and a lot of things easier to implement. Here are several of them.

About

Android Java app for spell-checking and note-taking

License:Apache License 2.0


Languages

Language:Java 100.0%