-
Notifications
You must be signed in to change notification settings - Fork 4
latest reading, recent history and authentication features #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
latest reading, recent history and authentication features #4
Conversation
… feature and bug fixes and merged to the master by rasing a pull request . Here I am commiting all at once. latest screen: to display the latest timestamp data recent screen: to display all the recent timestamp data Login visibility Firebase authentication Error handling Added progress bar on Sign up or sign in Included navigation map functionality as we have more than one screen redefine folder structure for maintainability and scalability Bug fixing for auth logic partial cleanup Syntax rules Code comments or documentation Few proper naming conventions or corrections TODO: test cases Logic implementation for sorting with name and category use EncryptedSharedPreferences to store token or secure credential
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manifest file to launch the Main Activity which is EnergyMeterActivity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this Kotlin file, we have the base repository class. The safeApiCall
function allows for safe execution of API calls with error handling. It utilizes Kotlin Flow to emit loading state, success, or failure based on the API call result or encountered exceptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Kotlin data class defines the structure for representing meter data, including category, unit, value, and variable name. The structure is used to model the data received from the meter.
TODO: Consider adding a GUID property to uniquely identify each meter data entry if needed for tracking or identification purposes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Kotlin data class defines the structure for an individual entry in the recent meter data list, including a GUID and a timestamp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Kotlin interface represents the API service contract for fetching meter data and recent data from the server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Kotlin sealed class represents the result of a network operation, which can be either loading, successful with data, or a failure with an error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Dagger Hilt module provides network-related dependencies such as OkHttpClient, Retrofit, and ApiService. It configures the HTTP client, logging, and base URL for API requests.
|
||
@Singleton | ||
@Provides | ||
fun provideLoggingInterceptor(): HttpLoggingInterceptor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provides an instance of the HTTP logging interceptor used for logging network requests and responses. The logging level is set to 'BODY' for detailed logging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Kotlin class represents the authentication fragment responsible for user login and signup. It uses ViewModel and data binding for handling user interactions and authentication.
TODO: Due to time constraint the comments in the code are missing for now. It's a good practice to provide the method and class comments for important stuff.
import com.tuf2000m.energymeter.data.model.recent.RecentData | ||
import com.tuf2000m.energymeter.databinding.ItemRecyclerRecentsBinding | ||
|
||
interface OnItemClickListener { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This interface defines a click listener for items in the RecyclerView. Implement it to handle item clicks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Kotlin class represents a RecyclerView adapter for displaying recent items. It takes a list of recent items and an item click listener as parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This XML layout represents the UI for the authentication screen. It includes EditTexts for email and password, a login button, a progress bar, and various constraints for proper positioning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This XML file defines the navigation graph for the app, specifying the start destination as AuthFragment.
These elements define fragments within the navigation graph, including AuthFragment and HomeFragment. Each fragment is associated with a unique ID and class, and HomeFragment is linked to AuthFragment through a navigation action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: customizing based on light and dark theme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request includes changes to several essential components of the app. Here's a brief overview:
-
BaseRepository
: Modified the base repository to handle safe API calls using Kotlin Flow, providing more robust error handling and better network result management. -
Data
andRecentData
classes: Added these data models to represent specific information related to the app's functionality, facilitating cleaner data management and usage. -
AuthFragment
,RecentAdapter
, and Navigation XML: Implemented key UI features like authentication flow, a RecyclerView adapter for recent data, and defined navigation flow between authentication and home fragments in the app.
The changes have been thoroughly tested and are ready for review. Your feedback and suggestions are highly appreciated. Thank you!
NOTE: Initially i have create a private repo and committed feature by feature and bug fixes and merged to the master by raising a pull request . Here I am committing all at once.
TODO:
New thoughts are drafted in the at the end of readme file.