In CrowdGrader, there are three phases to a homework assignment:
Your grade is a combination of your submission grade, and of your reviewing grade. See the CrowdGrader documentation for more details.
This homework consists in building a kitchen timer. The timer needs to display the time in minutes:seconds format (for instance, "3:45"), and count down to 0 with one-second resolution. Once at zero, optionally, you can have it beep.
The kitchen timer needs to have the following buttons:
Here is a skeleton implementation, that we developed in part in class. You can start from this one if you wish. The video of Lecture 2 contains a very detailed description of how to extend this code.
To realize the countdown, you will want to use the Android CountDownTimer class.
An example of use is as follows:
private void startCounter() {
if (timer != null) {
timer.cancel();
}
displayCount(count);
if (count > 0) {
timer = new CountDownTimer(count, 1000) {
public void onTick(long remainingTimeMillis) {
count = remainingTimeMillis;
displayCount(count);
}
public void onFinish() {
displayCount(0);
count = 0;
}
};
timer.start();
}
}
You will want to keep the screen from going off while the count is active. Put this in your onCreate method:
// Prevents the screen from dimming and going to sleep.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
You will also want to prevent the timer from resetting when you change the orientation of the phone. Configure your manifest entry for the activity like this (the crucial bit is the android:configChanges one):
<activity
android:name="com.example.kitchentimer.MainActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/app_name" >
If you want to avoid overcooking your pasta, and want the timer to beep when it reaches 0 (optional), you can look at the MediaPlayer class and at this code example:
MediaPlayer mediaPlayer = MediaPlayer.create(context, R.raw.sound_file_1);
mediaPlayer.start(); // no need to call prepare(); create() does that for you
I very highly recommend that you version your code using git. Otherwise, the risk that one hour before the homework deadline, you make a small change and break everything, is nonzero. To do so, first put the .gitignore file attached in the root directory of your application (you need to rename it to .gitignore, since Google Sites does not accept uploads that start with a dot.
To initialize your repository and do your first commit, do:
git init
git add .
git commit -a
To commit your code, do:
git commit -a
To add a file, then commit your code, do:
git add <your file>
git commit -a
This will get you started.