-
Notifications
You must be signed in to change notification settings - Fork 108
Merge the p-and-d branch #163
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
base: main
Are you sure you want to change the base?
Conversation
Adding ChatsListDetail to show both chats list and chat details on one screen when launching on a large screen device.
Add ChatsListDetail
Feat: Enable opening chats in new app instance
Fix the pane transition issue on the ChatListDetails screen
Add keyboard shortcuts
Migrated from navigation 2 to navigation 3. Had to use a snapshot build as it's not public yet. Manually copied Navigation 3 CAMAL support as it is not merged yet.
Migrated to Navigation 3
Fix: keyboard shortcut issues
Fix: self-letterboxing on the timeline screen.
Feat: Enable opening chats by dropping chat list item into desktop
Update navigation3 to latest snapshot
Feat: enable sharing images with other apps
Avoid updating widgets if not supported
Drag and drop files into Socialite
Notifications fix
Migration of drag & drop indication to IndicationNodeFactory
Fix: crash on the timeline pane
Feat: Enable sharing assets
Update Navigation 3 library
Update to latest navigation3 snapshot and add shared elements
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
Hello! gemini-code-assist here, providing a summary of this pull request. This PR merges the p-and-d
branch into main
, bringing in a significant set of changes primarily focused on refactoring the application's navigation architecture and introducing support for drag and drop of media items.
The core of the navigation changes involves migrating from the standard Navigation Compose library to a custom system built upon the new Material 3 Adaptive Navigation components. This refactor utilizes a Pane
-based back stack management system, designed to better support adaptive layouts across different window sizes and enable multi-instance capabilities for the main activity.
Additionally, the PR adds comprehensive drag and drop support for media items within both the chat and timeline screens. This includes handling the necessary URI permissions and implementing logic to save dropped or pasted media files locally using a FileProvider
. Several related components for context menus and draggable/droppable surfaces have been introduced or updated.
Various dependencies have been updated to newer versions, including Compose, CameraX, Media3, and Hilt, and new adaptive navigation libraries have been integrated. Minor changes were also made to the Android Manifest to support multi-instance activities and the new FileProvider setup, along with the addition of keyboard shortcuts for chat scrolling.
Highlights
- Navigation System Refactor: Replaced the existing Navigation Compose setup with a custom navigation system leveraging Material 3 Adaptive Navigation components and a
Pane
-based back stack for improved adaptive layout support and multi-instance handling. - Drag and Drop Media Support: Implemented drag and drop functionality for media items in chat and timeline screens, including handling URI permissions and saving files locally via a new FileProvider.
- Multi-Instance Activity: Enabled multi-instance support for the main activity to allow opening multiple chat windows.
- Dependency Updates: Updated numerous libraries (Compose, CameraX, Media3, Hilt, etc.) and integrated new adaptive navigation dependencies.
- Keyboard Shortcuts: Added keyboard shortcuts for scrolling within chat threads.
Changelog
Click here to see the changelog
- PhotoPickerNavigation.kt
- Deleted file. Navigation logic is now handled by the new system in
Main.kt
.
- Deleted file. Navigation logic is now handled by the new system in
- app/build.gradle.kts
- Added the Kotlin Parcelize plugin.
- Increased
compileSdk
version from 35 to 36. - Added new dependencies for Material 3 Adaptive components (
adaptive
,adaptive-layout
,adaptive-navigation
). - Updated
compose.material3.adaptive
dependency tocompose.material3.adaptive.navigation.suite
. - Removed the standard
navigation.compose
dependency. - Removed the
lifecycle.runtime.compose
dependency. - Added
media3.ui.compose
dependency for Compose UI components for Media3. - Added new dependencies for Navigation 3.0 adaptive components (
adaptive.navigation3
,navigation3.runtime
,navigation3.ui
,lifecycle.viewmodel.navigation3
).
- app/src/main/AndroidManifest.xml
- Added
android:enableOnBackInvokedCallback="true"
attribute to the application tag. - Added
<property android:name="android.window.PROPERTY_SUPPORTS_MULTI_INSTANCE_SYSTEM_UI" android:value="true" />
toMainActivity
to enable multi-instance support. - Changed
AssetFileProvider
toexported="false"
and addedandroid:grantUriPermissions="true"
with specificgrant-uri-permission
paths (/photo/.*
,/video/.*
,/icon/.*
). - Added a new
androidx.core.content.FileProvider
withexported="false"
,grantUriPermissions="true"
, and a meta-data pointing to@xml/shared_paths
.
- Added
- app/src/main/java/com/google/android/samples/socialite/AppArgs.kt
- Added new file defining a sealed interface
AppArgs
withShortcutParams
andLaunchParams
data classes for handling app launch intents.
- Added new file defining a sealed interface
- app/src/main/java/com/google/android/samples/socialite/AssetFileProvider.kt
- Imported
MatrixCursor
andOpenableColumns
. - Updated
getType
to returnString
and determine MIME type based on file extension. - Implemented the
query
method to return display name for media paths.
- Imported
- app/src/main/java/com/google/android/samples/socialite/MainActivity.kt
- Imported classes for keyboard shortcuts and package management.
- Replaced
runBlocking
withlifecycleScope.launch
for widget updates and added a feature check. - Updated the call to the
Main
composable to use the newappArgs
parameter. - Replaced
extractShortcutParams
withextractAppArgs
to handle both shortcut and launch intents using the newAppArgs
. - Added
onProvideKeyboardShortcuts
override to define chat-related keyboard shortcuts.
- app/src/main/java/com/google/android/samples/socialite/repository/ChatRepository.kt
- Added imports for
Intent
,File
,FileOutputStream
,toUri
, andMediaItem
. - Slightly adjusted logic for
isBotEnabled
and updatingenableChatbotKey
. - Added functions
saveAttachedMediaItem
,tryTakePersistableUriPermission
,trySaveAttachedMediaItem
, andremoveAttachedMediaItem
to handle saving and managing attached media files. - Removed unused
lastUserMessage
variable ingenerateBotResponse
. - Updated
saveMessageAndNotify
calls with explicit parameter names for clarity. - Updated
sendMessage
calls to handle attached media URI and MIME type.
- Added imports for
- app/src/main/java/com/google/android/samples/socialite/repository/NotificationHelper.kt
- Imported
AppArgs
. - Added
putExtra(AppArgs.LaunchParams.CHAT_ID_KEY, contact.id)
to the notification content intent to launch directly into the chat.
- Imported
- app/src/main/java/com/google/android/samples/socialite/ui/Main.kt
- Imported numerous classes for adaptive navigation, shared transitions, and state management.
- Removed imports related to standard Navigation Compose.
- Removed screen orientation locking logic.
- Replaced
NavHost
withSharedTransitionLayout
containingSocialiteNavSuite
andNavDisplay
for the new navigation system. - Implemented
Pane
-based back stack management usingrememberSavableMutableStateListOf
. - Defined shared transition scope and entry decorator.
- Mapped
Pane
types to composable screens in theNavDisplay
'sentryProvider
. - Updated screen composable calls to use
Pane
keys and pass necessary arguments. - Added
LaunchedEffect
to handle initialappArgs
from the intent. - Added helper functions for back stack management and multi-instance launching.
- Removed
ShortcutParams
data class andAnimationConstants
object.
- app/src/main/java/com/google/android/samples/socialite/ui/camera/Camera.kt
- Added
chatId: Long
parameter to theCamera
composable. - Passed
chatId
toviewModel.capturePhoto
calls.
- Added
- app/src/main/java/com/google/android/samples/socialite/ui/camera/CameraViewModel.kt
- Removed
SavedStateHandle
injection and the associatedchatId
property. - Changed visibility of several internal properties to private.
- Removed
setChatId
function. - Added
chatId: Long
parameter tocapturePhoto
andsendPhotoMessage
.
- Removed
- app/src/main/java/com/google/android/samples/socialite/ui/chat/ChatMessage.kt
- Added
isVideoContentAttached
andisImageContentAttached
helper properties.
- Added
- app/src/main/java/com/google/android/samples/socialite/ui/chat/ChatScreen.kt
- Removed imports for old UI components and related utilities (moved to component files).
- Imported new component files for chat UI.
- Replaced
input
state withtextFieldState: TextFieldState
. - Added
attachedMedia
state. - Removed
onInputChanged
parameter. - Added
onMediaItemAttached
andonRemoveAttachedMediaItem
parameters. - Applied
scrollWithKeyboards
,focusProperties
,focusGroup
, andmediaItemDropTarget
modifiers. - Updated
MessageList
andInputBar
calls to use new parameters and components. - Changed back button icon to
Icons.AutoMirrored.Filled.ArrowBack
. - Removed old
MessageBubble
,VideoMessagePreview
, andInputBar
composables. - Updated preview function.
- app/src/main/java/com/google/android/samples/socialite/ui/chat/ChatViewModel.kt
- Imported
TextFieldState
and related functions/flows. - Imported
SharingStarted
andstateIn
. - Renamed internal flows (
_chat
tochatDetail
,_messages
tomessagesInChat
). - Refactored message mapping logic for icon visibility.
- Replaced
_input
withtextFieldState
. - Added
attachedMediaItem
state flow andattachedMedia
property. - Refactored
sendEnabled
logic to combine input validity and attached media state. - Updated
updateInput
to usetextFieldState.setTextAndPlaceCursorAtEnd
. - Added
attachMedia
andremoveAttachedMedia
functions. - Updated
send
function to handle attached media and clear state. - Updated
isInputValid
to takeTextFieldState
. - Added
MediaItem
data class.
- Imported
- app/src/main/java/com/google/android/samples/socialite/ui/chat/component/ClipData.kt
- Added new file with
tryIntoClipData
composable to createClipData
from aChatMessage
's media URI.
- Added new file with
- app/src/main/java/com/google/android/samples/socialite/ui/chat/component/ContextMenuArea.kt
- Added new file with
ContextMenuArea
composable for chat messages, providing a 'Copy' option for media.
- Added new file with
- app/src/main/java/com/google/android/samples/socialite/ui/chat/component/Draggable.kt
- Added new file with
draggableMediaItem
modifier to make chat media items draggable.
- Added new file with
- app/src/main/java/com/google/android/samples/socialite/ui/chat/component/DropTarget.kt
- Added new file with
mediaItemDropTarget
modifier to make a composable a drop target for media items, including visual indication.
- Added new file with
- app/src/main/java/com/google/android/samples/socialite/ui/chat/component/InputBar.kt
- Added new file containing the refactored
InputBar
composable and related helpers for text input and attached media.
- Added new file containing the refactored
- app/src/main/java/com/google/android/samples/socialite/ui/chat/component/KeyEvent.kt
- Added new file with helper extension functions for
KeyEvent
to check key presses and modifiers.
- Added new file with helper extension functions for
- app/src/main/java/com/google/android/samples/socialite/ui/chat/component/MessageBubble.kt
- Added new file containing the refactored
MessageBubble
composable, integrating context menu and draggable modifiers.
- Added new file containing the refactored
- app/src/main/java/com/google/android/samples/socialite/ui/chat/component/Scroll.kt
- Added new file with
scrollWithKeyboards
modifier for keyboard-based scrolling in LazyLists.
- Added new file with
- app/src/main/java/com/google/android/samples/socialite/ui/chat/component/TransferableContent.kt
- Added new file with
tryCreateMediaItem
extension forTransferableC 1E0A ontent
to extract media items from dropped/pasted content.
- Added new file with
- app/src/main/java/com/google/android/samples/socialite/ui/components/ClipData.kt
- Added new file with helper functions to create
ClipData
from URIs usingFileProvider
.
- Added new file with helper functions to create
- app/src/main/java/com/google/android/samples/socialite/ui/components/ContextMenuArea.kt
- Added new file with a generic
ContextMenuArea
composable for displaying dropdown menus on right-click.
- Added new file with a generic
- app/src/main/java/com/google/android/samples/socialite/ui/components/ContextMenuItem.kt
- Added new file with
rememberContextMenuToCopyMediaItem
composable to create a 'Copy' context menu item forClipData
.
- Added new file with
- app/src/main/java/com/google/android/samples/socialite/ui/components/FocusRequester.kt
- Added new file with
tryRequestFocus
extension function for safe focus requests.
- Added new file with
- app/src/main/java/com/google/android/samples/socialite/ui/components/Icon.kt
- Added new file with
PlayArrowIcon
andAttachmentRemovalIcon
composables.
- Added new file with
- app/src/main/java/com/google/android/samples/socialite/ui/components/VideoPreview.kt
- Added new file with
VideoPreview
composables for displaying video thumbnails.
- Added new file with
- app/src/main/java/com/google/android/samples/socialite/ui/home/chatlist/ChatList.kt
- Updated
ChatList
composable to useonOpenChatRequest
. - Added logic to determine if a bottom sheet should be used based on window size class.
- Added state for
selectedChatId
andisBottomSheetVisible
. - Updated
ChatListItem
call to use new parameters (onOpenChatRequest
,onLongClick
,shouldUseMenu
). - Added
draggableWithIntentToOpenChat
modifier toChatListItem
for drag-and-drop launching. - Added
ChatListBottomSheet
composable for displaying chat options in a bottom sheet.
- Updated
- app/src/main/java/com/google/android/samples/socialite/ui/home/chatlist/ChatListItem.kt
- Moved file from
ui/ChatRow.kt
and renamed toChatListItem.kt
. - Renamed
ChatRow
composable toChatListItem
. - Updated parameters to use
onOpenChatRequest
,onLongClick
, andshouldUseMenu
. - Added
ChatListItemOptionButton
andChatListOptionMenu
composables for chat options.
- Moved file from
- app/src/main/java/com/google/android/samples/socialite/ui/home/chatlist/ChatOpenRequest.kt
- Added new file defining
ChatOpenRequest
sealed interface for different ways to open a chat.
- Added new file defining
- app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/Timeline.kt
- Imported new component files for Timeline UI.
- Removed imports for old Timeline UI components and logic.
- Updated to use
collectAsStateWithLifecycle
for media items. - Updated to use the new
TimelineScaffold
and delegate rendering toTimelineVerticalPager
orTimelineGrid
based onTimelineFormat
.
- app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/TimelineViewModel.kt
- Removed old media fetching logic from
init
block. - Changed
media
to a reactiveFlow<List<TimelineMediaItem>>
derived from chat messages. - Added
createTimelineMediaItemList
helper function. - Used
combine
andflattenConcat
to process media from multiple chats. - Used
onEach
to initialize the preload manager. - Refactored player thread initialization and quitting to be safer.
- Removed old media fetching logic from
- app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/ClipData.kt
- Added new file with
tryIntoClipData
composable to createClipData
from aTimelineMediaItem
's URI.
- Added new file with
- app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/ContextMenuArea.kt
- Added new file with
ContextMenuArea
composable for timeline media items, providing a 'Copy' option.
- Added new file with
- app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/Draggable.kt
- Added new file with
draggableMediaItem
modifier to make timeline media items draggable.
- Added new file with
- app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/EmptyTimeline.kt
- Added new file containing the refactored
EmptyTimeline
composable.
- Added new file containing the refactored
- app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/MetadataOverlay.kt
- Added new file containing the refactored
MetadataOverlay
composable.
- Added new file containing the refactored
- app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/TimelineCard.kt
- Added new file with
TimelineCard
composable for consistent styling.
- Added new file with
- app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/TimelineFormat.kt
- Added new file defining
TimelineFormat
enum andrememberTimelineFormat
composable.
- Added new file defining
- app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/TimelineGrid.kt
- Added new file implementing the grid layout for the timeline with a carousel overlay for selected items.
- app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/TimelineGridItem.kt
- Added new file representing a single item in the timel F438 ine grid.
- app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/TimelineScaffold.kt
- Added new file providing a common Scaffold structure for Timeline screens.
- app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/TimelineVerticalPager.kt
- Added new file implementing the vertical pager layout for the timeline.
- app/src/main/java/com/google/android/samples/socialite/ui/navigation/SocialiteNavigation.kt
- Renamed
Route
sealed interface toPane
and made itParcelable
. - Updated
TopLevelDestination
to usePane
instead ofRoute
. - Updated navigation logic in
SocialiteNavSuite
to use thePane
-based back stack.
- Renamed
- app/src/main/java/com/google/android/samples/socialite/ui/photopicker/PhotoPickerViewModel.kt
- Removed
SavedStateHandle
injection. - Added
chatId: Long
parameter toonPhotoPicked
.
- Removed
- app/src/main/java/com/google/android/samples/socialite/ui/photopicker/navigation/PhotoPickerRoute.kt
- Added
chatId: Long
parameter to thePhotoPickerRoute
composable. - Passed
chatId
toviewModel.onPhotoPicked
.
- Added
- app/src/main/java/com/google/android/samples/socialite/ui/videoedit/VideoEditScreen.kt
- Removed
NavController
parameter. - Replaced
navController.popBackStack
with a call to the newonFinishEditing
lambda. - Updated preview function signature.
- Removed
- app/src/main/res/values/strings.xml
- Added new strings for chat, window options, attachments, copy, keyboard shortcuts, and timeline carousel.
- app/src/main/res/xml/shared_paths.xml
- Added new file defining a
files-path
for the media directory, used byFileProvider
.
- Added new file defining a
- gradle/libs.versions.toml
- Updated various library versions.
- Added new adaptive navigation and media3-ui-compose libraries.
- Removed the standard navigation library.
- Added the Kotlin Parcelize plugin.
- gradle/wrapper/gradle-wrapper.properties
- Updated Gradle version to 8.11.1.
- settings.gradle.kts
- Added androidx snapshot repositories.
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.
Navigation flows anew,
Panes shift, a different view.
Drag, drop, media flies,
Adaptive, under skies.
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 introduces a significant number of features and refactorings, primarily focused on enhancing UI adaptiveness, navigation, and media handling. Key changes include:
- Navigation Overhaul: Transitioned from Jetpack Navigation Compose to a custom solution using
NavDisplay
andPane
-based navigation, which seems to facilitate adaptive layouts and shared element transitions. - Enhanced Media Handling: Added robust support for attaching media via drag-and-drop and pasting in chats, including persisting URIs and copying media to internal storage.
- UI Component Refactoring: Many UI components, especially for the chat and timeline screens, have been modularized and new ones introduced for better organization and new features like context menus and drag-and-drop interactions.
- Adaptive UI Features: Introduced
ChatListBottomSheet
and differentTimelineFormat
(Pager/Grid) to adapt to various screen sizes. Drag-to-open new chat window feature is also a nice addition for larger screens. - Keyboard Navigation & Shortcuts: Added keyboard shortcuts for chat actions and improved keyboard-based scrolling in lists.
- Dependency Updates: Updated several libraries and Gradle itself, and added new ones to support the new navigation and adaptive UI features.
Overall, these are substantial and positive changes. The move to a more custom navigation system is a big step and seems well-integrated with the new adaptive features. The enhanced media handling is also a great improvement.
However, there are a few critical and medium-severity issues that need addressing before merging, particularly a potential NPE and some maintainability concerns. Please see the detailed comments below.
Summary of Findings
- Potential NullPointerException in media saving: A critical NPE could occur in
ChatRepository.kt
'strySaveAttachedMediaItem
method if an input stream cannot be opened for a media item, ascreatedUri!!
might be called on a null reference. MediaItem
Data Class Placement: TheMediaItem
data class is defined inChatViewModel.kt
but used across UI components and the repository. It should be moved to a shared model package for better organization.- TODO Comment in
ChatList.kt
: ATODO
comment regarding agraphicsLayer
workaround indraggableWithIntentToOpenChat
needs clarification or tracking for future resolution. - Redundant
tools:ignore
in Manifest: Thetools:ignore="ExportedContentProvider"
forAssetFileProvider
inAndroidManifest.xml
may no longer be needed after settingandroid:exported="false"
. - Copyright Year (Not Commented): The new file
AppArgs.kt
has a copyright year of 2025. This is a minor oversight and was not commented on due to review settings. - Stylistic and Minor Code Improvements (Not Commented): Several minor code improvements and stylistic changes (e.g., boolean preference handling, unused variable removal, formatting) were noted but not commented on due to review settings. These changes are generally positive.
Merge Readiness
This pull request brings substantial improvements and new features. However, there is a critical NullPointerException risk in ChatRepository.kt
that must be addressed. Additionally, a few medium-severity maintainability issues (data class placement, TODO
comment, and a potentially redundant tools:ignore
in the manifest) should be considered for resolution.
I recommend addressing at least the critical issue before merging. The medium-severity issues would also improve code quality if tackled. As I am an AI, I am not authorized to approve pull requests; please ensure other reviewers approve these changes before merging.
This pull request merges the commits on the p-and-d branch with main branch.