Skip to content

CRC Cards

arahmad-ualberta edited this page Mar 31, 2025 · 15 revisions

Object-Oriented Analysis (CRC Cards)

Event

Responsibilities Collaborators
Encapsulates all of the data for a single mood event: Comment: (Comments.java) keeps the events comments.
- all of the info such as title, date (as a string and timestamp), the overlay color, the image URL (if it exists for said mood event), emoji. Mapper (Mapper.java) on every interaction between the Event objects and the Firestore document maps.
- it has all of the mood details such as the mood, mood explanation/description and the social situation. Database (Database.java) used for saving, updating, loading, and deleting events
- contains all of the user information for a mood post like the mood event's creator’s username. HomeManager (HomeManager.java) used for filtering, sorting, upserting, and removing events in the UI
- contains the info on the geolocation (latitude and longitude) (if specified by user when making the mood) and whether the post status is public/private status.
- 'Event' also keeps a list of the comments that were made under any single mood event.
- 'Event' also provides getters and setters needed to access and modify any of these properties.

Comment

Responsibilities Collaborators
**Encapsulate a single comment’s details: ** Event (Event.java) Comments are attached to events
- Username of the commenter, comment text, and timestamp
Implement the Comparable interface to enable sorting (using the time string)

User

Responsibilities Collaborators
stores and provides global access to the currently logged-in user’s data (name and username) LoginPageActivity, uses the User class for current user information
Basically a central user data holder across the app lifecycle CreateAccountActivity, uses the User class for current user information
ProfileActivity, uses the User class for current user information
OtherUserProfileActivity, uses the User class for current user information
HomeActivity, uses the User class for current user information

UserHelper

Responsibilities Collaborators
represents a user as stored in firestore Userbase, uses UserHelper objects for firestore operations and following management
maintains user attributes: full name, username, password (hashed), list of followers, and following SearchUserManager:used for filtering and searching for other users
serves as the data search for user-related operations (such as in searches and follow management)

Database

Responsibilities Collaborators
handles all of the firestore operations and data that relates to events: Event: as the primary data model for mood events
- save new events, updates existing ones, loads events (and split them into categories such as for "MYPOSTS", "FOLLOWED", and "EXPLORE"), and deleting events Mapper: uses Database for mapping between event objects and their respective Firestore document maps
save all the comments by updating their corresponding Firestore document FirebaseFirestore: the backend data store
provides callback interfaces for saving, updating, loading, and deleting EventDetailsActivity: receives callbacks for event operations

Mapper

Responsibilities Collaborators
converts Event objects into Map data for saving to Firestore. Database, the Mapper class is used by Database when saving or loading events from firestore
converts a Firestore DocumentSnapshot into an Event object Event, when database is called events is needed as well as the primary data model for mood events
Ensure the proper format for date, timestamp, and other fields

Userbase

Responsibilities Collaborators
manages the user's account data which is stored in the firebase database UserHelper uses Userbase as the firestore model for users
checks to see if a user exists and the retrieve user details including the password hash if the user exists FollowManager works with Userbase often when needing to update the UI based on follow status
creates the new user accounts FirebaseFirestore works with userbase for general data operations
retrieves the detailed user information needed for profile display
handles follow and follow related operations such as:
- checking for the follow statuses between users
- used to send, accept, and remove follow requests
- retrieves the lists of incoming and pending follow requests for specific users
- updates the users “following” and the users “followers” lists

FollowManager

Responsibilities Collaborators
provides static use of the methods used for checking the following statuses between the current user and another user(s) Userbase works with FollowingManager to get follow/follow request data
updates the follow button UI based on the current state (follow, unfollow, pending request) ProfileActivity works with FollowManager to help whereever following actions are initiated
helps to determine whether or not a follow request has already been sent SearchUsersActivity works with this class indirectly to be used to help with follow management when a user selects a profile
OtherUserProfileActivity used for general follow actions

HomeManager

Responsibilities Collaborators
provides the logic needed for the home screen such as for: Event: Works with the list of Event objects
- filtering through events by their text description (mood explanation), mood, and/or recent time (recent week or three most recent mood events) HomeActivity works with homemanager to provide events and apply the filter(s)
- sorts the events in reverse chronological order (making the most recent even appear at the top and the oldest event at the bottom) Database works with this class as the the source of event data that this class manipulates
- adds or updates events in the lists
- removes events by their ID (e.g., after deletion)

EventAdapter

Responsibilities Collaborators
binds a list of the Event class objects to a RecyclerView for displaying them in the home screen Event: provides data for each list item
displays each of the event’s info such as the title, date, overlay color, mood (with emoji), image (loaded using the Photobase class), and
the mood event's public/private status Photobase: Loads the image for a mood event from the firebase database
handles each click events for launching the event details HomeActivity: passes the event clicks events to the activity
resets the view states to avoid problems with the recycling PostStatusFragment: Invoked for status editing when needed

CommentsAdapter

Responsibilities Collaborators
makes a list of the object of the Comment class to be used in the RecyclerView in the EventDetails screen Comment: use to provides the comments data
displays each of the comment’s username, date, and text EventDetailsActivity: used for the RecyclerView to display the comments
makes sure that the proper layout and styling for comment items is displayed

PostStatusFragment

Responsibilities Collaborators
presents the dialog used for changing the status of a mood event being public/private Event collaborates with the event that status is being changed
allows for the user to confirm a status change by asking either “POST” or “CONFIRM” depending on context Database, used for updating the event’s status being public or private
provides the user’s choice back to the activity by calling back the interface HostActivities: (EventDetailsActivity, MoodCreateAndEditActivity) both used for the implementation of the PostStatusDialogListener interface

CreateAccountActivity

Responsibilities Collaborators
provides the UI for creating the new user sign-up Userbase, used to check for existing users and to create a new account
check to see if the input fields of the name, username, and password to ensure that none of them are empty PasswordHasher hashes the password which it gets from CreateAccountActivity
checks for if the username is unique by using the Userbase class User is used to store the current user details
hashes the password entered by using the PasswordHasher class before the account creation
creates the new user in Firestore
populates the User class and navigates to the LoginPageActivity
handles the back navigation

LoginPageActivity

Responsibilities Collaborators
provides the UI for the user login PasswordHasher is used for password hashing
check to see that the user input is valid and ensures the username and password are not empty Userbase checks the user credentials
uses the Userbase class to check to see if the user exists and to compare the hashed password FirebaseAuth handles authentification
handles the firebase authentification SharedPreferences stores and accesses the user's details
saves the user's details in the SharedPreferences class User stores and accesses user's details
populates the required User class data's and navigates to the HomeActivity after login is successful
manages the loading indicators and disable buttons during processing

ProfileActivity

Responsibilities Collaborators
displays the current user’s profile and its respective information including the full name, username, and the profile photo Userbase used in updating and retrieving the user details
allow editing of the profile: FirebaseFirestore used for profile photo storage
- changing the name (updating to Firebase using the Userbase class) SharedPreferences used to cache the user's profile data
- changing the profile photo OtherUserProfileActivity is used to navigate to other users profiles or search
loads the user's profile photo either from SharedPreferences or from Firestore if not already cached SearchUsersActivity is used to navigate to other users profiles or search
provides navigation to search for other users and sign out

NotificationActivity

Responsibilities Collaborators
displays the notifications (especially for the follow requests) in a RecyclerView Userbase used for follow request management (accepting or rejecting/removing)
separating the incoming follow requests from pending ones into seperate tabs FollowManager used indirectly through following
allows the user to accept or to reject any incoming follow requests RecyclerView used to display notifications
navigates back to the HomeActivity, preserving selected tab and filter state

NotificationAdapter

(similar to the NotificationActivity)

Responsibilities Collaborators
binds the notification data of the usernames and the request messages to a list of items Userbase used for follow request management (accepting or rejecting/removing)
displays the appropriate action buttons of accepting and denying incoming follow requests FollowManager used indirectly through following
updates the UI and the data when actions are taken RecyclerView used to display notifications

PhotoActivity

Responsibilities Collaborators
provides options to take a photo with the camera or select an image from the photo gallery of the phone emulator Photobase stores the image and uploads and retrieves the image when needed
handles the permissions for camera and gallery access AndriodEmulator camera (if used)
Process the selected image: AndriodEmulator photos (if used)
- converts the image into a bitmap
- validates the image size making sure that it is below 64kb
- displays the image in the UI
uploads the processed image to the firebase database using the Photobase class and returns the document ID

Photobase

Responsibilities Collaborators
manages the image storage and retrieval using Firestore PhotoActivity used to handle the image upload and load requests
converts the image into Bitmap string FirebaseFirestore to store the photo
uploads the image to Firestore after checking the size
retrieves the image from Firestore and convert them for display

OfflineActivity

Responsibilities Collaborators
enables the Firestore’s offline data persistence FirebaseFirestore is used for setting offline persistence options
configures the firestore settings to allow proper work without wifi

RecentMoodEventRepository

Responsibilities Collaborators
check the Firebase database for recent mood events for the “MyPosts” tab and orders them by their timestamps in descending order (making the most recent appear at the top and the least recent appear at the bottom of the list) FirebaseFirestore used to check event data
maps the database documents to Event objects Event class used as the data model for mood events
HomeManager used if the user uses the filtering/sorting
RecyclerView & Adapter were used to display the mood events

RecentMoodEventFragment

(similar to RecentMoodEventRepository)

Responsibilities Collaborators
displays a list of recent mood events in a RecyclerView FirebaseFirestore used to check event data
uses an EventAdapter to match the data to the UI Event class used as the data model for mood events
HomeManager used if the user uses the filtering/sorting
RecyclerView & Adapter were used to display the mood events

SearchUserManager

(same as SearchUsersActivity and UserAdapter)

Responsibilities Collaborators
provide the methods for searching users by username UserHelper is used as the data model for users
filters the list of the UserHelper objects using the user inputted string in the search FirebaseFirestore used for getting the user's data
Userbase for the additional user management
OtherUserProfileActivity for navigating to the selected profiles

SearchUsersActivity

(same as SearchUserManager and UserAdapter)

Responsibilities Collaborators
allows the user to search for other users using the EditText and buttons UserHelper is used as the data model for users
searches the database for users matching the search criteria FirebaseFirestore used for getting the user's data
displays the search results in a RecyclerView Userbase for the additional user management
OtherUserProfileActivity for navigating to the selected profiles

UserAdapter

(same as SearchUserManager and SearchUsersActivity)

Responsibilities Collaborators
puts the UserHelper's objects to a RecyclerView for display UserHelper is used as the data model for users
handles the items clicks to navigate to the selected user’s profile FirebaseFirestore used for getting the user's data
Userbase for the additional user management
OtherUserProfileActivity for navigating to the selected profiles

Clone this wiki locally