Coder Social home page Coder Social logo

thebookknight / dodotodo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 366 KB

This is a Proof-of-Concept Android app written in Java. It's designed with the following concepts: Publisher-Subscriber Model, Model-View-Viewmodel (MVVM), and Repository Pattern.

Java 100.00%

dodotodo's Introduction

DodoToDo

Dodo To-Do Image

Based off this LinkedInLearning course Building an Android App With Architecture Components

Design Patterns

Concepts:

  • Publisher-Subscriber Model
  • Model-View-Viewmodel (MVVM)
  • Repository Pattern

Step 1: Setup

View Tag v1.0.0-Setup

  1. Add a Vector Asset based on Android's preexisting Add, Edit, Delete, and Check icons 0. To allow custom assets, - go to build.gradle(app) - set this 'vectorDrawables.useSupportLibrary = true' under 'defaultConfig' i. Right Click the app directory and choose 'Create New Vector Asset* ii. Select 'Clip Art' and search for the 'Add button' iii. I made it #FFFFF or white and renamed it as the ic_add.xml iv. it will be in the drawable directory v. Repeat steps 1 to 4 with the remaining buttons

  2. Add LifeCycle and Room dependencies. This will include support for:

    • LiveData
    • ViewModel

Step 2: Notes List UI

Visit Tag v2.0.0-AddUI

See changes here

  1. Add a RecyclerView under DataBinding

    • Optional. Use ButterKnife. In "File > Project Structure > Dependencies > App", click the add button to include latest versions of i. jakewharton:butterknife ii. jakewharton:butterknife-compiler (added as annotationProcessor)
  2. Create a custom note item view. See note_list_item.xml

  3. Create a data transfer object with proper Getters, Setters, and Constructors. See NoteEntity.java as an example

    • To test it, we need to create Sample Data. You can log them in console to see if they work. See 'SampleData.java'
  4. Create a Notes Adapter that determines UI for each note in the recyclerview

  5. Add an Editor Activity, I used a Scrolling Activity to be later used for editing notes

Notes:

Step 3: Data Layer

Visit Tag v3.0.0-DataLayer

See changes here

  1. Add an Entity, DAO, and Database via Room implementation

    • Since SQLite doesn't support Date as type, you need to create a type converter. See DateConverter.java
  2. Add database tests via Android JUnit 4

Step 4: Separating Business and Data

Visit Tag v4.0.0-businessLogic for substeps 1 to 3. See changes here

Visit Tag v5.0.0-addEditFeature for substeps 4 and 5. See changes here

Visit Tag v5.1.0-deleteNoteFeature for substep 6. See changes here

  1. Add a ViewModel

  2. Add a Repository which help will direct where data comes from.

    • MainViewModel will use AppRepository
    • MainActivity uses MainViewModel
    • I heard you can view SQL Lite data with 'DB Browser for SQLite', but I wasn't able to get it working
  3. Via this relationship, Activity -> ViewModel -> Repository

    • it can add sample data
    • delete all notes
  4. Using Bundle and each note item's FAB btn to configure saving each Edit note.

  5. Use above configuration with Bundle and Fab button to add a note.

  6. To delete a note, it's a similar process except you use DAO's deleteNote method

Step 5: Use onSaveInstanceState for Device orientation immunity

Visit Tag v5.2.0-onSavedInstanceState. See changes here

  1. Use a boolean flag based on 'onSaveInstanceState' so it won't override current note edits. See 'EditorActivity.java'

Note: Some refactoring

  • added recyclerview divider lines. Visit Tag v5.2.1-dividerLines. See changes here
  • moved some directories. Visit Tag v5.2.2-moveDirectories. See changes here
  • Added a Splash Screen. See changes here

Step 6: Upgrade Database to include more parameters

Visit Tag v6.0.0-migrateDb. See changes here

  • For upgrading / updating your Database, use Migrations
  • After migrating, update your Add / Edit Note feature to save all the new params in note
    • I updated the constraints so that 'note text' can be empty, because some users don't care about the details

Note: Great Resources for Database migration and Switch UI

Step 7: Implement Incrementing and Decrementing features for Editor

Visit Tag v7.1.0-fixUnitClickDefect. See changes here

  • I used 'Mutable LiveData' to update the UI for incrementing and decrementing those values.
  • There are some rules to keep in mind when implementing these features
    1. The goal is always more than the current number of units
    2. The goal has to be at least one or higher.
    3. The number of units has to be at least zero or higher.

Step 8: Implement 'To Do' and 'Completed' List DISPLAY and DELETE filter

Visit Tag v7.2.0-filter. See changes here

  • Use the SavedInstanceState to remember previous filter for every device configuration change
  • The AppRepository and DAO determines how the filtering is done
  • With filter, delete notes based off completion status and add Alert Dialog
  • Had to create more icons based off filters and error dialog
    • ic_delete_error.xml
    • ic_filter_deleteall.xml
    • ic_filter_todo.xml

Notes: Great Resources for Alert Dialog

Step 9: Implement Notifications

Visit Tag v7.3.0-notifications. See changes here

  • Added preference listeners to trigger notifications
  • Added capability to customize notification message

Notes: Great Resources for Notifications

Step 10: Implement Day by Day notifications

  1. Add the WorkManager dependency
  2. Create a OneTimeWorkRequest to
    • trigger the Periodic Requests an
    • send a Notification at the exact user-set time

dodotodo's People

Contributors

thebookknight avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.