Lecture 6 & HW 6: Networking, Data, and Persistent Storage
Y'all are awesome! Thank you for all of your hard work so far; we have a small enough class for me to know that each of you (yes, ALL) are very talented and bright Android Developers. I wish you all success and happiness ☺.
Lecture 6 Demo - 10/31/22
Discussion 6 Demo - 11/2/22
Your goal for this week's assignment is to build a notes app using fragments, data-sharing techniques, and networking. We'll provide some guidelines below, but different implementations can often lend themselves to different UI's so you will have the freedom to design the UI however you'll like!
The API spec for the backend you'll be working with is here: https://github.com/cuappdev/ios-course-messageboard.
Note: The backend regularly clears its saved posts. If your call to the endpoint is returning an empty array of posts, it could just be that no one has made a post recently.
- 1.Create a CloudNotesActivity with a
RecyclerViewthat displays notes. The notes should be obtained from a
GETrequest to the server in
- 2.Your app should have a data class to represent a single note based on the backend model. There should also be a singleton class (ie. Repository) that keeps track of the list of notes that have been changed locally.
- 3.Each cell in the
RecyclerViewshould display the title, a truncated note body (up to 150 characters), a timestamp, and the username of the poster.
- 4.Clicking on any cell in the
RecyclerViewshould open the EditNoteActivity, which in this case will display the note's title and body.
- 5.In EditNoteActivity, there should be a way for the user to edit the note title and body. If the user navigated to EditNoteActivity by clicking on a
RecyclerViewcell, clicking on the save button should save the note to the list in Repository, and the user should be redirected back to CloudNotesActivity. You do not need to save edits to existing notes to the server -- it is sufficient to save them locally (as you'll have to display said local notes as detailed in 7).
- 6.CloudNotesActivity should have a "New Note" or "+" button to create a new note. Clicking on it will launch the EditNoteActivity, but in this case, the EditNoteActivity will not be pre-populated, and clicking on the save button should send a
POSTrequest to the server to create the note on the server. You can use your net ID for the
posterfield of the note. The user should be redirected back to CloudNotesActivity after posting.
- 7.CloudNotesActivity should also have a button to view local notes. Clicking this button should take you to the LocalNotesActivity, which will use a
RecyclerViewto display a list of all the notes that you have made edits to locally (list of notes in Repository). There should also be some way of navigating from LocalNotesActivity back to CloudNotesActivity.
These are optional challenge problems, and completing each successfully will earn you 1 extra point per problem. If you do attempt a challenge problem, make sure to include a
README.txtthat states which problem(s) you've attempted!
POSTrequests to save edits to note bodies on the backend (you do not have to edit note titles)
- Refresh your list in CloudNotesActivity when you swipe.
- Use a
CardViewfor the custom layout of the
RecyclerViewcell for that ✨ clean ✨ and modern look.
- Add a feature to ListFragment that allows the user to delete a note from the list. You can decide how to design and implement this! Some ideas include swipe to delete, long-press and delete, select to delete.
- Add a third fragment to MainActivity. This activity should feature a search bar (ie.
SearchView) that allows the user to search for notes by title.
- Notes that match the search query should be displayed in a list of some sort. This can be either a
- Clicking on a cell in the list should direct the user back to EditNoteFragment where the user can modify the note.
- Add a feature to EditNoteFragment that allows the user to change the background color of the note. This color should visible in EditNoteFragment and ListFragment.
SharedPreferences, to support persistent storage for the list of notes. If the user were to close and reopen the app, the list of notes should persist. This challenge problem is a bit tricky because you'll need to think about how to store and retrieve objects from a SharedPreferences file.
For this assignment, you may need to figure out a few things on your own. Some classes that may be helpful for this assignment include:
For basic functionality:
- Intent and Manifest
For challenge problems: