Skip to content

WIP: [ Step 1 ] Remove duplicate code using methods

Juan requested to merge jdvr/disapp:refactor_s_1 into master
  • [ Step 1 ] Remove duplicate code using methods
  • Next [ Step 2 ] Use polymorphism and extract code from MainActivity
  • Next [ Step 3 ] Follow (kind of) Clean Architecture to create well defined responsibilities

The goal of this three steps is to achieve the four rules of simple design

For this project Clean Architecture is a bit overkill, but it guides you to SOLID principles. The idea of this three steps refactors is to make the app easier to maintain. I am not an experienced android developer but I applied almost the same design patters for backend and frontend developments.

Code comments: I want to make and especial mention to comments while using a cvs as git is harder to keep dead code that to just remove it, make a very tinny commit and if you need the code again you can do a revert.

Changes:

I have chosen button setups as examples because IMHO is the easier and most valuable change I could do over the code.

  1. Make code more abstract to create just 4 ways of handle dashboard buttons:
  • launchActivity, from dashboard we launch another activity (eg. State)
  • launchRecommendedAppButton, from dashboard it launches another app (e.g. K9)
  • launchWebviewApp, from dashboard opens webview with url (e.g. Calc)
  • launchWebviewWithNativeBrowser, from dashboard, it requests a uri open to OS (e.g. Upload)

Disclaimer

I know this refactor remove two features:

  1. Let user choose xmpp client
  2. State long press dialog options

This two functionalities will be re-added during step 2 and 3.

PS. Gitlab diff is unclear... it messes up a lot of stuff

Merge request reports