Reference: BNR book: Chapter 9 (5th Edition) or Chapter 8 (4th Edition).
CriminalIntent records the details of "office crimes" – things like leaving dirty dishes in the break room sink or walking away from an empty shared printer after documents have printed.
With CriminalIntent, you can make a record of a crime including a title, a date, and a photo. You can also identify a suspect from your contacts and lodge a complaint via email, Twitter, Facebook, or another app. After documenting and reporting a crime, you can proceed with your work free of resentment and ready to focus on the business at hand.
CriminalIntent is a complex app that will take 11 chapters to complete. It will have a list-detail interface: The main screen will display a list of recorded crimes, and users will be able to add new crimes or select an existing crime to view and edit its details (Figure 8.1)
Below are the selected screenshots that demonstrate the features of the app.
Git branch: version1
- Chapters 8, 9
- Crime
- CrimeFragment
- MainActivity
- res/layout/activity_fragment.xml
- res/layout/fragment_crime.xml
Jetpack packages: https://developer.android.com/jetpack/androidx/versions
- CrimeListViewModel
- CrimeListFragment
- MainActivity (updated)
- res/layout/fragment_crime_list.xml
- res/layout/list_item_crime.xml
Git branch: version2
- Chapters 10, 11
- res/layout/list_item_crime.xml: Converted to ConstraintLayout
- res/drawable/ic_solved
- CrimeListFragment: updated to use ImageView and to have customised view properties
- Room API for database access
- Note: for SDK 30, can only use Room version <= 2.3.0
- Crime: updated with @Entity
- package
database
with 3 classes: CrimeDao, CrimeDatabase, CrimeTypeConverters - database directory on emulator:
/data/au.edu.swin.sdmd.criminalintent/databases
- CrimeRepository
- CriminalIntentApplication
- CrimeListViewModel, CrimeListFragment: updated to use LiveData
Git branch: version3
- Chapters 12, 13
- CrimeDetailViewModel: load, save changed data from view to database
- CrimeListFragment, CrimeFragment, MainActivity: updated to support fragment navigation
- CrimeRepository: support update, insert
database.CrimeDao
: support update, insert
- DatePickerFragment: added
- CrimeFragment: updated to interact with DatePickerFragment to allow user pick a date
Git branch: version4
- Chapters: 14,15,16
- CriminalListFragment: added options menu in App Bar, that allows user to add a new item
- database from versions 2 & 3: removed from the emulator, to make it easier for users to view new items that they add (a fresh database is also created on the emulator with the new items)
- CrimeFragment: "choose suspect" and "send crime report"
- CrimeFragment: "photo" view and "take photo" button
- Configured to use camera to take photo and converts it into bitmap for display