8000 Migration of drag & drop indication to IndicationNodeFactory by chikoski · Pull Request #157 · android/socialite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 2 commits into from
May 13, 2025

Conversation

chikoski
Copy link

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.

Copy link
@gemini-code-assist gemini-code-assist bot left a 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 in ChatScreen.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 to Icons.AutoMirrored.Filled.ArrowBack for better RTL support.
    • Removes drag and drop logic and associated isDraggedOver state from ChatContent.
    • Replaces the inline drag and drop target implementation with the mediaItemDropTarget modifier.
    • Removes the dragAndDropBorderModifier.
  • app/src/main/java/com/google/android/samples/socialite/ui/chat/component/DropTarget.kt
    • Introduces a new file DropTarget.kt that contains the mediaItemDropTarget modifier and related classes for handling drag and drop functionality.
    • Defines MediaItemDropTargetIndication as an IndicationNodeFactory 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.
  • 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 and MediaType.Video related code.
  • 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 and supportedMediaTypes for video and image media types.
  • gradle/libs.versions.toml
    • Updates camera library from 1.5.0-alpha06 to 1.5.0-beta01.
    • Updates compose library from 1.9.0-alpha01 to 1.9.0-alpha02.
    • Updates compose_bom from 2025.04.01 to 2025.05.00.
    • Updates lifecycle library from 2.8.7 to 2.9.0.
    • Updates material3 library from 1.4.0-alpha13 to 1.4.0-alpha14.
    • Updates navigation library from 2.8.9 to 2.9.0.
    • Updates material3-adaptive-navigation-suite library from 1.4.0-alpha13 to 1.4.0-alpha14.
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

  1. 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.

Copy link
@gemini-code-assist gemini-code-assist bot left a 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 stable hashCode. This could lead to unexpected behavior if PathEffect instances are different but visually the same. Consider using a more stable identifier for PathEffect 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.

@chikoski chikoski merged commit c02280d into android:p-and-d May 13, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0