DanielRendox / GroceryGenius

A feature-rich shopping list Android app with offline-first mode and Material You design
GNU General Public License v3.0
83 stars 5 forks source link

Introduce Category and Icon Selection, along with Product Deletion Capabilities #5

Closed DanielRendox closed 5 months ago

DanielRendox commented 5 months ago

This PR introduces the functionality of removing, deleting, and customizing groceries. Users can now customize their own products with ready-made icons and categories. (note that it's not available for predefined groceries).

https://github.com/DanielRendox/GroceryGenius/assets/107246216/c7363e17-98a8-4380-a86b-b67bf7b0f834

DanielRendox commented 5 months ago

@CodiumAI-Agent /update_changelog

CodiumAI-Agent commented 5 months ago

Changelog updates:

2024-04-04

Added

to commit the new content to the CHANGELOG.md file, please type: '/update_changelog --pr_update_changelog.push_changelog_changes=true'

DanielRendox commented 5 months ago

@CodiumAI-Agent /ask "summarize the changes made in this PR and suggest a better title"

CodiumAI-Agent commented 5 months ago

Question: summarize the changes made in this PR and suggest a better title

Answer: This PR introduces several changes to the GroceryList feature in the Kotlin-based application. The primary changes include:

  1. The addition of new repositories: CategoryRepository and IconRepository have been added to the GroceryListScreenViewModel. This allows the ViewModel to fetch categories and icons for groceries.

  2. The introduction of groceryIconsFlow and groceryCategories flows: These flows are used to fetch and handle the state of grocery icons and categories respectively.

  3. The addition of new intents: New intents such as OnCategorySelected, OnCustomCategorySelected, OnIconSelected, OnRemoveGroceryFromList, and OnDeleteProduct have been added to handle user interactions related to category selection, icon selection, grocery removal, and product deletion.

  4. The addition of new functions: Functions like onCategorySelected, onIconSelected, onRemoveGroceryFromList, and onDeleteProduct have been added to handle the new intents.

  5. The update of UI components: The GroceryListScreen and EditGroceryBottomSheetContent components have been updated to accommodate the new features. This includes the addition of category and icon pickers, and delete product confirmation dialog.

  6. The addition of new dialog components: CategoryPickerDialog and IconPickerDialog have been added to allow users to pick a category or an icon for a grocery item.

A more descriptive title for this PR could be: "Enhancement of GroceryList Feature with Category and Icon Selection, and Product Deletion Capabilities".


โœจ Ask tool usage guide:
**Overview:** The `ask` tool answers questions about the PR, based on the PR code changes. It can be invoked manually by commenting on any PR: ``` /ask "..." ``` Note that the tool does not have "memory" of previous questions, and answers each question independently.
More PR-Agent commands
> To invoke the PR-Agent, add a comment using one of the following commands: > - **/review**: Request a review of your Pull Request. > - **/describe**: Update the PR title and description based on the contents of the PR. > - **/improve [--extended]**: Suggest code improvements. Extended mode provides a higher quality feedback. > - **/ask \**: Ask a question about the PR. > - **/update_changelog**: Update the changelog based on the PR's contents. > - **/add_docs** ๐Ÿ’Ž: Generate docstring for new components introduced in the PR. > - **/generate_labels** ๐Ÿ’Ž: Generate labels for the PR based on the PR's contents. > - **/analyze** ๐Ÿ’Ž: Automatically analyzes the PR, and presents changes walkthrough for each component. >See the [tools guide](https://pr-agent-docs.codium.ai/tools/) for more details. >To list the possible configuration parameters, add a **/config** comment.
See the [ask usage](https://pr-agent-docs.codium.ai/tools/ask/) page for a comprehensive guide on using this tool.
DanielRendox commented 5 months ago

@CodiumAI-Agent /review

CodiumAI-Agent commented 5 months ago

PR Review

โฑ๏ธ Estimated effort to review [1-5] 4, due to the extensive changes across multiple files, including database schema, UI components, and business logic. The PR introduces new features, modifies existing functionalities, and involves UI changes, which require careful review to ensure consistency, performance, and adherence to best practices.
๐Ÿงช Relevant tests No
๐Ÿ” Possible issues Possible Bug: The `GroceryListViewModel` uses `UUID.randomUUID().toString()` for generating `productId` when adding a custom product. This approach might not guarantee uniqueness across different devices or app installations, potentially leading to conflicts.
Performance Concern: Loading all grocery icons into memory (`groceryIconsFlow`) might lead to increased memory usage, especially if the icons are large or numerous. Consider lazy loading or caching strategies.
๐Ÿ”’ Security concerns No
Code feedback:
relevant fileapp/src/main/java/com/rendox/grocerygenius/screens/grocery_list/GroceryListViewModel.kt
suggestion       Consider implementing a more robust ID generation mechanism that ensures uniqueness across devices and app installations for `productId`. One approach could be combining a device identifier with a timestamp or a sequence number. [important]
relevant lineproductId = productId,

relevant fileapp/src/main/java/com/rendox/grocerygenius/data/icons/IconRepositoryImpl.kt
suggestion       Implement a caching mechanism for icons to reduce memory usage and improve performance. Icons could be cached in memory with a fixed size LRU cache, or on disk using an appropriate caching library. [important]
relevant lineoverride fun getAllGroceryIcons() = iconDao.getAllGroceryIcons()

relevant fileapp/src/main/java/com/rendox/grocerygenius/ui/components/grocery_list/GroceryGridItem.kt
suggestion       Optimize image loading by checking the size of the `ImageBitmap` and scaling it down if necessary before displaying it in the UI. This can help reduce memory usage for large images. [medium]
relevant linebitmap.prepareToDraw()

relevant fileapp/src/main/java/com/rendox/grocerygenius/screens/grocery_list/GroceryListViewModel.kt
suggestion       To improve the maintainability of the `GroceryListViewModel`, consider refactoring large functions and splitting them into smaller, more focused methods. This can make the code easier to understand and test. [medium]
relevant lineprivate fun addCustomProduct(customProduct: CustomProduct) {


โœจ Review tool usage guide:
**Overview:** The `review` tool scans the PR code changes, and generates a PR review which includes several types of feedbacks, such as possible PR issues, security threats and relevant test in the PR. More feedbacks can be [added](https://pr-agent-docs.codium.ai/tools/review/#general-configurations) by configuring the tool. The tool can be triggered [automatically](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-app-automatic-tools-when-a-new-pr-is-opened) every time a new PR is opened, or can be invoked manually by commenting on any PR. - When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L23) related to the review tool (`pr_reviewer` section), use the following template: ``` /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=... ``` - With a [configuration file](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/), use the following template: ``` [pr_reviewer] some_config1=... some_config2=... ``` See the review [usage page](https://pr-agent-docs.codium.ai/tools/review/) for a comprehensive guide on using this tool.
DanielRendox commented 5 months ago

Loading all grocery icons into memory (groceryIconsFlow) might lead to increased memory usage, especially if the icons are large or numerous. Consider lazy loading or caching strategies.

Yep, we'll take care of the performance later. Probably by introducing Coil for loading images from files instead of decoding bitmaps manually.