-
Notifications
You must be signed in to change notification settings - Fork 108
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
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 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
withextractAppArgs
to handle both shortcut and direct launch parameters. - Adds
LaunchParams
data class to handle launching the app with a specific chat ID.
- Introduces
- app/src/main/java/com/google/android/samples/socialite/ui/Main.kt
- Removes unused imports and
ShortcutParams
data class. - Modifies
MainNavigation
to useLocalActivity
instead ofLocalContext.current as Activity
. - Adds
LaunchedEffect
to navigate to the correct route based onappArgs
. - Introduces
NavigationTree
composable to encapsulate theNavHost
.
- Removes unused imports and
- app/src/main/java/com/google/android/samples/socialite/ui/home/ChatsListDetail.kt
- Updates
ChatsListDetail
to useChatOpenRequest
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.
- Updates
- app/src/main/java/com/google/android/samples/socialite/ui/home/chatlist/ChatList.kt
- Updates
ChatList
to useonOpenChatRequest
instead ofonChatClicked
. - 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.
- Updates
- app/src/main/java/com/google/android/samples/socialite/ui/home/chatlist/ChatListItem.kt
- Renames
ChatRow
toChatListItem
. - Updates
ChatListItem
to usecombinedClickable
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.
- Renames
- 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).
- Introduces
- app/src/main/java/com/google/android/samples/socialite/ui/player/preloadmanager/PreloadManagerWrapper.kt
- Replaces
STAGE_LOADED_TO_POSITION_MS
withSTAGE_LOADED_FOR_DURATION_MS
inPreloadStatusControl
.
- Replaces
- 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
-
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 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
, andIntent.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 ofShortcutParams
andLaunchParams
. 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.
This PR enables opening a chat in another instance:
This PR also includes dependencies update and some code cleanup.