top of page

Project 2 Milestone 4

  • Alexandra Charland
  • Dec 3, 2020
  • 4 min read

The app that I made is called MeanTime. It's purpose was to calculate and keep track of the average time it took to complete a task. As part of the MVP, these were the components that I have implemented: text input to add a task, spinner to select a task to time, stopwatch with start, pause, and end buttons, and a table to store the average time for each task.


SQLite Database

In order for the app to keep track of the average time for all the tasks, I needed to implement some form of data persistence. Since the app would have to store an unknown number of tasks and average times, I decided to use a SQLite Database to store the following data fields for every task the user adds: task id, task name, average hours, average minutes, average seconds, and iterations. This way I could retrieve the necessary parameters for average times and iterations in order to calculate the new average time for individual tasks using this formula:

average_new = average_old +((new_time - average_old)/iterations)

Spinner

The spinner contains choices with all the tasks that the user has added to the table and the choice to add a new task. When the user selects "Add a new task", a dialog box with a text input will come, prompting the user to add a new task. I used this approach in order to avoid cluttering the main screen when the user does not wish to add a task. The dialog box is temporary and will only come up when the user requests it. The contents in the spinner are updated when a new task is added, and the spinner choice is automatically set to the recently added task so the user does not have to find this task again in the spinner.


Text Input with Dialog

The text input that appears in the dialog box was a way to make adding a new task easier in the familiar format of submitting a form. The dialog would only appear when the user chooses "Add new task" from the spinner, and can be dismissed by hitting "Cancel" or typing in a unique task name and hitting "Done".


Stopwatch with buttons

The timer is displayed with three digit fields in the format 00:00:00 for hours, minutes, and seconds, and counts up to resemble a stopwatch. This allows for the user to see how much time they can spend performing their task, which can extend up to 24 hours. The "Start" button lights up when a task is chosen from the spinner to indicate that the timer is ready to go. After starting the timer, the "Start" button will turn into a "Pause" button and the "End" button will light up, letting the user know that they are in control of the timer.


ListView

All the tasks with their average times are displayed all in one ListView where the user can keep track of each task. This table is updated when a new task is added and when a new time is factored into the old average for a task. There is a delete functionality that would allow the user to delete a task by tapping and holding the table row, however as this delete functionality was not part of the MVP, it is incomplete and could cause the problems if the timer is already running.

Overall this project took me three days of consistent effort. Configuring the SQLite database was the most challenging component of this project and took up 3/4 of the total time for this project. I was able to figure it out thanks to a helpful tutorial that showed me how to implement the insert, delete, and update methods, and since all the tutorials and resources I found used java, I made my project all in java so I could save time and follow along more easily. I learned the SQL language in some other computer science classes, so I was already familiar with how to write queries and could figure out how to retrieve and manipulate the data I needed for the app, but sometimes the app would crash because the SQLite helper class wouldn't accept the query format. I had to modify my approach for updating the average time for the correct task due to this, which worked out because the spinner was populated with the tasks in the same order that they appear in the table. Instead of retrieving a task by its unique id, I set up a condition that the user could not add a task with the same name in order to match up the unique task name in the spinner with the task in the database and update it.


I initially had some trouble saving the instance state of the stopwatch, which was partially due to implementing my project in java and using the wrong onSaveInstanceState method. It was easier to figure out once I was actually able to retrieve the saved instance states of the variables I needed. The saved instance states were probably the most annoying part about working with Android studio, but once I got it working it was easier to figure out what I needed to do. I still couldn't figure out everything however, such as how to preserve the appearance of the timer while rotating it when paused (the time displayed is wrong but when hitting "Start" again, it returns to the correct time).


In the future, I will make sure to start a day earlier so I can spend an entire day trying to figure out how to properly migrate the saved instance states.

Recent Posts

See All
Project Close

Final project can be found on GitHub. As I mentioned before in the adapt phase, there's a lot that goes into building an app to make sure...

 
 
 
Project Adapt (Iteration 3)

For this iteration I tried to implement my app with features mostly complete. I realized that although they were there, some features...

 
 
 
Project Explore (Iteration 3)

For this iteration I wanted to have all of my features working. I was able to get most of the features implemented except the exact data...

 
 
 

Comments


© 2019 by Alexandra Charland. Proudly created with Wix.com

bottom of page