8000 Merge the p-and-d branch by chikoski · Pull Request #163 · android/socialite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open

Merge the p-and-d branch #163

wants to merge 59 commits into from

Conversation

chikoski
Copy link

This pull request merges the commits on the p-and-d branch with main branch.

sashalukin and others added 30 commits April 15, 2025 18:27
Adding ChatsListDetail to show both chats list
and chat details on one screen when launching on
a large screen device.
Feat: Enable opening chats in new app instance
Fix the pane transition issue on the ChatListDetails screen
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.
Fix: keyboard shortcut issues
Fix: self-letterboxing on the timeline screen.
Feat: Enable opening chats by dropping chat list item into desktop
alexvanyo and others added 24 commits May 9, 2025 11:29
Update navigation3 to latest snapshot
Feat: enable sharing images with other apps
Avoid updating widgets if not supported
Drag and drop files into Socialite
Migration of drag & drop indication to IndicationNodeFactory
Update to latest navigation3 snapshot and add shared elements
@chikoski chikoski requested a review from madebymozart May 23, 2025 04:37
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

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.
  • 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 to compose.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" /> to MainActivity to enable multi-instance support.
    • Changed AssetFileProvider to exported="false" and added android:grantUriPermissions="true" with specific grant-uri-permission paths (/photo/.*, /video/.*, /icon/.*).
    • Added a new androidx.core.content.FileProvider with exported="false", grantUriPermissions="true", and a meta-data pointing to @xml/shared_paths.
  • app/src/main/java/com/google/android/samples/socialite/AppArgs.kt
    • Added new file defining a sealed interface AppArgs with ShortcutParams and LaunchParams data classes for handling app launch intents.
  • app/src/main/java/com/google/android/samples/socialite/AssetFileProvider.kt
    • Imported MatrixCursor and OpenableColumns.
    • Updated getType to return String and determine MIME type based on file extension.
    • Implemented the query method to return display name for media paths.
  • app/src/main/java/com/google/android/samples/socialite/MainActivity.kt
    • Imported classes for keyboard shortcuts and package management.
    • Replaced runBlocking with lifecycleScope.launch for widget updates and added a feature check.
    • Updated the call to the Main composable to use the new appArgs parameter.
    • Replaced extractShortcutParams with extractAppArgs to handle both shortcut and launch intents using the new AppArgs.
    • 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, and MediaItem.
    • Slightly adjusted logic for isBotEnabled and updating enableChatbotKey.
    • Added functions saveAttachedMediaItem, tryTakePersistableUriPermission, trySaveAttachedMediaItem, and removeAttachedMediaItem to handle saving and managing attached media files.
    • Removed unused lastUserMessage variable in generateBotResponse.
    • Updated saveMessageAndNotify calls with explicit parameter names for clarity.
    • Updated sendMessage calls to handle attached media URI and MIME type.
  • 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.
  • 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 with SharedTransitionLayout containing SocialiteNavSuite and NavDisplay for the new navigation system.
    • Implemented Pane-based back stack management using rememberSavableMutableStateListOf.
    • Defined shared transition scope and entry decorator.
    • Mapped Pane types to composable screens in the NavDisplay's entryProvider.
    • Updated screen composable calls to use Pane keys and pass necessary arguments.
    • Added LaunchedEffect to handle initial appArgs from the intent.
    • Added helper functions for back stack management and multi-instance launching.
    • Removed ShortcutParams data class and AnimationConstants object.
  • app/src/main/java/com/google/android/samples/socialite/ui/camera/Camera.kt
    • Added chatId: Long parameter to the Camera composable.
    • Passed chatId to viewModel.capturePhoto calls.
  • app/src/main/java/com/google/android/samples/socialite/ui/camera/CameraViewModel.kt
    • Removed SavedStateHandle injection and the associated chatId property.
    • Changed visibility of several internal properties to private.
    • Removed setChatId function.
    • Added chatId: Long parameter to capturePhoto and sendPhotoMessage.
  • app/src/main/java/com/google/android/samples/socialite/ui/chat/ChatMessage.kt
    • Added isVideoContentAttached and isImageContentAttached helper properties.
  • 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 with textFieldState: TextFieldState.
    • Added attachedMedia state.
    • Removed onInputChanged parameter.
    • Added onMediaItemAttached and onRemoveAttachedMediaItem parameters.
    • Applied scrollWithKeyboards, focusProperties, focusGroup, and mediaItemDropTarget modifiers.
    • Updated MessageList and InputBar calls to use new parameters and components.
    • Changed back button icon to Icons.AutoMirrored.Filled.ArrowBack.
    • Removed old MessageBubble, VideoMessagePreview, and InputBar 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 and stateIn.
    • Renamed internal flows (_chat to chatDetail, _messages to messagesInChat).
    • Refactored message mapping logic for icon visibility.
    • Replaced _input with textFieldState.
    • Added attachedMediaItem state flow and attachedMedia property.
    • Refactored sendEnabled logic to combine input validity and attached media state.
    • Updated updateInput to use textFieldState.setTextAndPlaceCursorAtEnd.
    • Added attachMedia and removeAttachedMedia functions.
    • Updated send function to handle attached media and clear state.
    • Updated isInputValid to take TextFieldState.
    • Added MediaItem data class.
  • app/src/main/java/com/google/android/samples/socialite/ui/chat/component/ClipData.kt
    • Added new file with tryIntoClipData composable to create ClipData from a ChatMessage's media URI.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • app/src/main/java/com/google/android/samples/socialite/ui/chat/component/TransferableContent.kt
    • Added new file with tryCreateMediaItem extension for TransferableC 1E0A ontent to extract media items from dropped/pasted content.
  • app/src/main/java/com/google/android/samples/socialite/ui/components/ClipData.kt
    • Added new file with helper functions to create ClipData from URIs using FileProvider.
  • 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.
  • 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 for ClipData.
  • app/src/main/java/com/google/android/samples/socialite/ui/components/FocusRequester.kt
    • Added new file with tryRequestFocus extension function for safe focus requests.
  • app/src/main/java/com/google/android/samples/socialite/ui/components/Icon.kt
    • Added new file with PlayArrowIcon and AttachmentRemovalIcon composables.
  • app/src/main/java/com/google/android/samples/socialite/ui/components/VideoPreview.kt
    • Added new file with VideoPreview composables for displaying video thumbnails.
  • app/src/main/java/com/google/android/samples/socialite/ui/home/chatlist/ChatList.kt
    • Updated ChatList composable to use onOpenChatRequest.
    • Added logic to determine if a bottom sheet should be used based on window size class.
    • Added state for selectedChatId and isBottomSheetVisible.
    • Updated ChatListItem call to use new parameters (onOpenChatRequest, onLongClick, shouldUseMenu).
    • Added draggableWithIntentToOpenChat modifier to ChatListItem for drag-and-drop launching.
    • Added ChatListBottomSheet composable for displaying chat options in a bottom sheet.
  • app/src/main/java/com/google/android/samples/socialite/ui/home/chatlist/ChatListItem.kt
    • Moved file from ui/ChatRow.kt and renamed to ChatListItem.kt.
    • Renamed ChatRow composable to ChatListItem.
    • Updated parameters to use onOpenChatRequest, onLongClick, and shouldUseMenu.
    • Added ChatListItemOptionButton and ChatListOptionMenu composables for chat options.
  • 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.
  • 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 to TimelineVerticalPager or TimelineGrid based on TimelineFormat.
  • 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 reactive Flow<List<TimelineMediaItem>> derived from chat messages.
    • Added createTimelineMediaItemList helper function.
    • Used combine and flattenConcat to process media from multiple chats.
    • Used onEach to initialize the preload manager.
    • Refactored player thread initialization and quitting to be safer.
  • app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/ClipData.kt
    • Added new file with tryIntoClipData composable to create ClipData from a TimelineMediaItem's URI.
  • 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.
  • 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.
  • app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/EmptyTimeline.kt
    • Added new file containing the refactored EmptyTimeline composable.
  • app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/MetadataOverlay.kt
    • Added new file containing the refactored MetadataOverlay composable.
  • app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/TimelineCard.kt
    • Added new file with TimelineCard composable for consistent styling.
  • app/src/main/java/com/google/android/samples/socialite/ui/home/timeline/component/TimelineFormat.kt
    • Added new file defining TimelineFormat enum and rememberTimelineFormat composable.
  • 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 to Pane and made it Parcelable.
    • Updated TopLevelDestination to use Pane instead of Route.
    • Updated navigation logic in SocialiteNavSuite to use the Pane-based back stack.
  • app/src/main/java/com/google/android/samples/socialite/ui/photopicker/PhotoPickerViewModel.kt
    • Removed SavedStateHandle injection.
    • Added chatId: Long parameter to onPhotoPicked.
  • app/src/main/java/com/google/android/samples/socialite/ui/photopicker/navigation/PhotoPickerRoute.kt
    • Added chatId: Long parameter to the PhotoPickerRoute composable.
    • Passed chatId to viewModel.onPhotoPicked.
  • app/src/main/java/com/google/android/samples/socialite/ui/videoedit/VideoEditScreen.kt
    • Removed NavController parameter.
    • Replaced navController.popBackStack with a call to the new onFinishEditing lambda.
    • Updated preview function signature.
  • 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 by FileProvider.
  • 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

  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 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 and Pane-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 different TimelineFormat (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's trySaveAttachedMediaItem method if an input stream cannot be opened for a media item, as createdUri!! might be called on a null reference.
  • MediaItem Data Class Placement: The MediaItem data class is defined in ChatViewModel.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: A TODO comment regarding a graphicsLayer workaround in draggableWithIntentToOpenChat needs clarification or tracking for future resolution.
  • Redundant tools:ignore in Manifest: The tools:ignore="ExportedContentProvider" for AssetFileProvider in AndroidManifest.xml may no longer be needed after setting android: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.

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.

3 participants
0