-
Notifications
You must be signed in to change notification settings - Fork 108
Migration of drag & drop indication to IndicationNodeFactory #157
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
Conversation
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.
Hello @chikoski, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request focuses on improving the structure and readability of the drag and drop functionality within the ChatScreen
. The primary change involves migrating the visual effects associated with drag interactions into an IndicationNodeFactory
. Additionally, some functions have been moved from ChatScreen.kt
into separate files to promote better organization and separation of concerns. The pull request also includes updates to library versions in gradle/libs.versions.toml
.
Highlights
- Drag & Drop Indication Migration: The visual effects for drag and drop interactions are now handled by
IndicationNodeFactory
, leading to cleaner code inChatScreen.kt
. - Code Reorganization: Functions related to drag and drop have been extracted from
ChatScreen.kt
and placed into new or existing component files. - Library Updates: The pull request updates several libraries in
gradle/libs.versions.toml
, including Compose, Lifecycle, Navigation, and Material3 libraries.
Changelog
Click here to see the changelog
- app/src/main/java/com/google/android/samples/socialite/ui/chat/ChatScreen.kt
- Removes unused imports such as
android.app.Activity
,android.os.Build
,android.util.Log
, and drag and drop related imports. - Updates
ArrowBack
icon toIcons.AutoMirrored.Filled.ArrowBack
for better RTL support. - Removes drag and drop logic and associated
isDraggedOver
state fromChatContent
. - Replaces the inline drag and drop target implementation with the
mediaItemDropTarget
modifier. - Removes the
dragAndDropBorderModifier
.
- Removes unused imports such as
- app/src/main/java/com/google/android/samples/socialite/ui/chat/component/DropTarget.kt
- Introduces a new file
DropTarget.kt
that contains themediaItemDropTarget
modifier and related classes for handling drag and drop functionality. - Defines
MediaItemDropTargetIndication
as anIndicationNodeFactory
to manage the visual indication during drag and drop. - Implements the
DragAndDropTarget
interface to handle drag events and attach media items. - Includes logic for requesting drag and drop permissions and handling MIME type matching.
- Introduces a new file
- app/src/main/java/com/google/android/samples/socialite/ui/chat/component/InputBar.kt
- Removes
rememberReceiveContentListener
call, as the content receiving logic is moved elsewhere. - Removes
tryCreateMediaItem
andMediaType.Video
related code.
- Removes
- app/src/main/java/com/google/android/samples/socialite/ui/chat/component/TransferableContent.kt
- Creates a new file
TransferableContent.kt
. - Adds
tryCreateMediaItem
to handle media item attachment from transferable content. - Defines
MediaType.Video
andsupportedMediaTypes
for video and image media types.
- Creates a new file
- gradle/libs.versions.toml
- Updates
camera
library from1.5.0-alpha06
to1.5.0-beta01
. - Updates
compose
library from1.9.0-alpha01
to1.9.0-alpha02
. - Updates
compose_bom
from2025.04.01
to2025.05.00
. - Updates
lifecycle
library from2.8.7
to2.9.0
. - Updates
material3
library from1.4.0-alpha13
to1.4.0-alpha14
. - Updates
navigation
library from2.8.9
to2.9.0
. - Updates
material3-adaptive-navigation-suite
library from1.4.0-alpha13
to1.4.0-alpha14
.
- Updates
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A node factory's grace,
Indications in their place,
Drag and drop made neat.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request focuses on improving the drag and drop functionality within the chat screen by migrating the visual effects to IndicationNodeFactory
. This should improve the readability and maintainability of the code. The changes look good overall, with a few suggestions for minor improvements.
Summary of Findings
- Error Handling: Consider adding a log or some other form of error reporting within the
onFailure
block of the focus request to help diagnose potential focus request issues in the future. - Readability: The multiple conditions in the
if
statement for checking drop permissions could be extracted into a separate function with a descriptive name to improve readability. - Resource Management: Consider wrapping the permission request and release in a
try-finally
block to ensure the permission is always released, even if an exception occurs. - hashCode Stability: The comment mentions that
PathEffect
doesn't have a stablehashCode
. This could lead to unexpected behavior ifPathEffect
instances are different but visually the same. Consider using a more stable identifier forPathEffect
if possible, or document this limitation more clearly.
Merge Readiness
The pull request is well-structured and improves the drag and drop functionality. Addressing the suggestions above, especially the error handling and resource management aspects, would further enhance the quality of the code. I am unable to approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the high severity comments should be addressed before merging.
This pull request migrates the visual effects applied to the drag interactions into IndicationNodeFactory to improve readability. This pull request also move some functions from ChatScreen.kt to several files.