8000 Feat: Enable opening chats in new app instance by chikoski · Pull Request #136 · android/socialite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feat: Enable opening chats in new app instance #136

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 1 commit into from
Apr 16, 2025

Conversation

chikoski
Copy link

This PR enables opening a chat in another instance:

  1. Show the chat list on the app
  2. Long press a chat in the list
  3. Select "Open in new window" in the popup menu. When app is in compact window, a bottom sheet shows up instead of popup menu.

This PR also includes dependencies update and some code cleanup.

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 introduces a new feature that allows users to open chats in a new application instance. This is achieved by adding a new option to the chat list, which when selected, launches a new instance of the app with the selected chat. The PR also includes dependency updates and some code cleanup. The main changes are in MainActivity.kt, Main.kt, ChatsListDetail.kt, ChatList.kt, and ChatListItem.kt. Additionally, some changes were made to PreloadManagerWrapper.kt and strings.xml, and the dependencies in gradle/libs.versions.toml were updated.

Highlights

  • New Feature: Open Chat in New Instance: Implements the ability to open a chat in a separate app instance via a long press context menu option in the chat list.
  • App Architecture: Introduces AppArgs sealed interface to handle different app launch scenarios (shortcut vs. direct launch with chatId).
  • UI Changes: Updates the chat list to include a bottom sheet or tooltip (depending on screen size) with an option to open the chat in a new window.
  • Dependency Updates: Updates various dependencies in gradle/libs.versions.toml including Compose BOM, Hilt, Media3, Navigation, Room, and others.
  • Code Cleanup: Removes unused imports and simplifies some logic in Main.kt.

Changelog

Click here to see the changelog
  • app/src/main/java/com/google/android/samples/socialite/MainActivity.kt
    • Introduces AppArgs sealed interface to handle different app launch scenarios.
    • Replaces extractShortcutParams with extractAppArgs to handle both shortcut and direct launch parameters.
    • Adds LaunchParams data class to handle launching the app with a specific chat ID.
  • app/src/main/java/com/google/android/samples/socialite/ui/Main.kt
    • Removes unused imports and ShortcutParams data class.
    • Modifies MainNavigation to use LocalActivity instead of LocalContext.current as Activity.
    • Adds LaunchedEffect to navigate to the correct route based on appArgs.
    • Introduces NavigationTree composable to encapsulate the NavHost.
  • app/src/main/java/com/google/android/samples/socialite/ui/home/ChatsListDetail.kt
    • Updates ChatsListDetail to use ChatOpenRequest to handle chat opening requests.
    • Adds handleOChatOpenRequest function to handle different types of chat opening requests (same window vs. new window).
    • Introduces launchAnotherInstance extension function to launch a new instance of the app with a specific chat ID.
    • Changes navigator content type to Long.
  • app/src/main/java/com/google/android/samples/socialite/ui/home/chatlist/ChatList.kt
    • Updates ChatList to use onOpenChatRequest instead of onChatClicked.
    • Adds logic to display a bottom sheet or tooltip (depending on screen size) with an option to open the chat in a new window.
    • Introduces ChatListBottomSheet composable to display the bottom sheet.
    • Uses WindowSizeClass to determine if bottom sheet should be used.
  • app/src/main/java/com/google/android/samples/socialite/ui/home/chatlist/ChatListItem.kt
    • Renames ChatRow to ChatListItem.
    • Updates ChatListItem to use combinedClickable to handle both click and long click events.
    • Adds ChatListToolTip composable to display the tooltip with the option to open the chat in a new window.
  • app/src/main/java/com/google/android/samples/socialite/ui/home/chatlist/ChatOpenRequest.kt
    • Introduces ChatOpenRequest sealed interface to represent different types of chat opening requests (same window vs. new window).
  • app/src/main/java/com/google/android/samples/socialite/ui/player/preloadmanager/PreloadManagerWrapper.kt
    • Replaces STAGE_LOADED_TO_POSITION_MS with STAGE_LOADED_FOR_DURATION_MS in PreloadStatusControl.
  • app/src/main/res/values/strings.xml
    • Adds string resource for "Open in new window".
  • gradle/libs.versions.toml
    • Updates various dependencies including Compose BOM, Hilt, Media3, Navigation, Room, and others.
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 window opens wide,
A new chat starts inside,
Socialite's grace.

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 PR introduces a feature to open chats in a new app instance, enhancing user experience by allowing multitasking. The implementation involves updating dependencies, cleaning up code, and implementing new logic for handling app arguments and navigation. Overall, the changes seem well-structured and address the intended functionality.

Summary of Findings

  • AppArgs Sealed Interface: The introduction of the AppArgs sealed interface and its implementations (ShortcutParams, LaunchParams) is a good approach for handling different types of app launch scenarios. However, consider adding documentation to explain the purpose and usage of each class.
  • Intent Flags for New Instance: The use of Intent.FLAG_ACTIVITY_NEW_TASK, Intent.FLAG_ACTIVITY_NEW_DOCUMENT, and Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT is appropriate for launching a new app instance. Ensure that these flags are compatible with different Android versions and devices.
  • Code Duplication: There is some code duplication in the tryFrom methods of ShortcutParams and LaunchParams. Consider refactoring this into a common utility function.

Merge Readiness

The pull request is well-structured and addresses the intended functionality. However, I recommend addressing the code duplication issue and adding documentation for the AppArgs sealed interface before merging. I am unable to approve this pull request, and recommend that others review and approve this code before merging.

@chikoski chikoski merged commit 7f77ba6 into android:p-and-d Apr 16, 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