Wednesday April 12, 11pm. STRICT.
The KitchenTimer app at the repository https://bitbucket.org/luca_de_alfaro/kitchen_timer
Note: I defined one second to last 100 milliseconds so you don't have to wait quite as long while developing and debugging the app. The pasta will be rather al dente though.
NOTE: I updated the code at 6:14pm Thursday April 6. If you checked it out before then, re-check it out. You might want to check the repository for changes; if I find mistakes, I will fix them.
Below the START and STOP buttons, place three buttons in a row (similarly to how the +, 0, - buttons are placed). The buttons should be labeled with the three most recent times the user has set.
You can do this in a simple-minded way, by just remembering the three most recent distinct times at which the user pressed the START button. This works, but it is not perfect. A user can set 12 minutes, then start the timer, then stop it (say at 9:24), then restart it. If you remember the most recent three distinct times at which the user has pressed START, you will remember also 9:24, which doesn't make much sense if you think of it.
If you want to be fancy, and get extra credit, you have to remember the most recent three distinct times when a user pressed the START button immediately after pressing the "+" or "-" buttons. By detecting a press of START immediately after a press of "+" or "-", you are detecting the times the user has set for countdown, while disregarding intermediate stops such as the 9:24 above.
Initially, the three buttons should be blank. Then, they should be labeled with times, as the user sets the times.
When a button containing a pre-defined time is pressed, you should:
My suggestion for the last part is just to call onClickStart(null), or if you find this too horrible (I do), you can write a separate private void startTimer, and you can call that method both from onClickStart and from the above method.
Who would have ever thought that a timer for cooking pasta is such a complicated thing to build?
For each of the buttons you add, you will need to store the following information:
Our beautiful button labels will be forgotten every time the app is stopped for good (stopped, and Android reclaims its memory). Clearly this is undesirable. How can we store the information permanently, so that the buttons are correctly initialized every time we launch the app? We will learn this next week.