Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

1. What project have you worked about?

goals :
Create Course Scheduler App, Allow students to easily access important course information,
such as instructor information and note.

featurs :
Database Setup: Define a local database table and DAO (data access object) based on the
schema in course.json and use QueryUtils to create a raw query.

Nearest Schedule: Display the nearest schedule in CardHomeView (CustomView).

RecyclerView and CourseAdapter: Initialize RecyclerView with CourseAdapter and delete the
course when the list is swiped.

AddCourseActivity: Create AddCourseActivity in ui/add to set a new course schedule (refer to


"Add Course Screen specifications").

Dark Mode Theme: Update the dark mode theme based on the value in ListPreference.

Daily Reminder: Schedule and cancel daily reminders for every 6:00 AM using AlarmManager.
Show today's schedules in an inbox style notification and open HomeActivity when the
notification is tapped.

2. Which part is hardest?


Writing UI tests: UI testing can be challenging due to the dynamic nature of user interfaces.

Solution : is to use a testing framework like Espresso to automate UI interactions and verify app
behavior.

3. How is the flow to change the theme to a dark theme?


For User :
Open the app, click the top right corner three dots, click settings, see the display dark mode,
click dark mode, then select the theme according to what you like.

Workflow

The ListPreference's OnPreferenceChangeListener is triggered, passing the new dark mode value
to the updateTheme() method.

The updateTheme() method sets the default night mode using


AppCompatDelegate.setDefaultNightMode() with the new value.

To apply the new theme, the current activity is recreated using requireActivity().recreate().
Under the hood:

AppCompatDelegate: AppCompatDelegate is a class that provides compatibility features for


older Android versions. It allows you to set the default night mode for the entire app, which will
be applied to all activities.

recreate(): The recreate() method destroys and recreates the current activity, applying the new
theme in the process..

4. How does notification reminder work?


For User :
Open the app, click the top right corner three dots, click settings, see the display notification,
click notification button.

Workflow :

The SwitchPreference's OnPreferenceChangeListener is triggered, passing the new reminder


state to the DailyReminder class.

If the reminder is enabled, the setDailyReminder() method is called to schedule the daily
reminder using AlarmManager.

If the reminder is disabled, the cancelAlarm() method is called to cancel the daily reminder.

Components:

SharedPreferences: SharedPreferences is a persistent data storage mechanism that is used to


store the reminder state.

AlarmManager: AlarmManager is a system service that is used to schedule alarms.

BroadcastReceiver: A BroadcastReceiver is a class that receives broadcasts from the system.

NotificationManager: NotificationManager is a system service that is used to manage


notifications.

Repository: The Repository is a class that provides access to the data. In this case, the Repository
is used to get the today's schedule.

PendingIntent: A PendingIntent is an object that represents a future intent that can be executed
by the system.

Technical Explanation:
Scheduling the daily reminder: The setDailyReminder() method creates a PendingIntent that
points to the DailyReminder class. It then sets a repeating alarm using AlarmManager. The
repeating alarm will fire every day at 6:00 AM.

Receiving the alarm broadcast: When the alarm broadcast is received, the DailyReminder class
onReceive() method is called. This method gets the today's schedule from the Repository and
shows a notification with the schedule.

Creating the notification: The showNotification() method creates a NotificationCompat.Builder


object and sets the notification's content. It then creates a PendingIntent that points to the
HomeActivity and sets the notification's contentIntent. Finally, it creates and shows the
notification.

5. Why do we need LiveData?


LiveData is a data holder class that is part of the Android Architecture Components. It is
designed to simplify the management of UI-related data that changes over time.

LiveData is used in this app:

To get a course: The getCourse() method returns a LiveData object that emits the specified
course whenever it changes. This is used to display the details of a course in the DetailActivity.

ViewModel is used in the DetailActivity :

ViewModel Initialization: In the onCreate() method of DetailActivity, the ViewModelProvider is


used to create an instance of the DetailViewModel, passing the DetailViewModelFactory as a
factory.

Observing Course LiveData: The DetailActivity observes the course LiveData from the viewModel
using viewModel.course.observe(this) { showCourseDetail(it) }. This ensures that the UI is
updated whenever the course data changes.

Updating UI with Course Data: The showCourseDetail() method receives the Course object and
updates the UI elements accordingly. It sets the course name, time, lecturer, and note using the
corresponding TextView elements.

Deleting Course: When the user selects the "Delete" option from the menu, the
onOptionsItemSelected() method calls viewModel.delete(). The DetailViewModel handles the
deletion logic and updates the repository accordingly.

Features and benefits of LiveData:

Simple to use: LiveData has a simple API that is easy to learn and use.

You might also like