Add on-device AI image enhancement feature to enhance images#194
Conversation
…hat screen Major changes: - Integrate the Google Play Services Media Effect Enhancement library to support on-device AI processing. - Implement `ImageEnhancementScreen` and `EnhancementViewModel` to handle image enhancement features, including tonemapping, deblurring, and upscaling. - Add `EnhancementUtils.kt` providing coroutine-based wrappers for enhancement session management, bitmap processing, and module installation. Minor changes: - Add an "AI Enhance" action button to image bubbles within the chat UI. - Update the `ChatMessage` model to include a unique ID and add support for updating media URIs in the `ChatRepository` and `MessageDao`. - Define navigation logic for the new enhancement pane in `Main.kt` and `SocialiteNavigation.kt`. - Update the README to include documentation for the Media Effect Enhancement integration.
There was a problem hiding this comment.
Code Review
This pull request adds on-device AI image enhancement features (tonemapping, deblurring, and upscaling) using Google Play Services, introducing a new enhancement screen, ViewModel, and database updates to persist enhanced image URIs. The review feedback identifies several critical issues: a data loss bug where saving an enhanced image deletes all other enhanced images in the chat history, thread safety issues with concurrent access to enhancementSession, and incorrect coroutine continuation handling during module installation. Additionally, the reviewer recommends removing silent background module downloads to conserve data, avoiding passing short-lived Context objects to the ViewModel to prevent memory leaks, and catching Throwable to safely handle OutOfMemoryError during bitmap decoding.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…hat screen Major changes: - Integrate the Google Play Services Media Effect Enhancement library to support on-device AI processing. - Implement `ImageEnhancementScreen` and `EnhancementViewModel` to handle image enhancement features, including tonemapping, deblurring, and upscaling. - Add `EnhancementUtils.kt` providing coroutine-based wrappers for enhancement session management, bitmap processing, and module installation. Minor changes: - Add an "AI Enhance" action button to image bubbles within the chat UI. - Update the `ChatMessage` model to include a unique ID and add support for updating media URIs in the `ChatRepository` and `MessageDao`. - Define navigation logic for the new enhancement pane in `Main.kt` and `SocialiteNavigation.kt`. - Update the README to include documentation for the Media Effect Enhancement integration.
…ncement # Conflicts: # app/build.gradle.kts # app/src/main/java/com/google/android/samples/socialite/repository/ChatRepository.kt # app/src/main/java/com/google/android/samples/socialite/ui/Main.kt # app/src/main/java/com/google/android/samples/socialite/ui/chat/component/MessageBubble.kt # app/src/main/java/com/google/android/samples/socialite/ui/mediaenhancement/EnhancementUtils.kt # app/src/main/java/com/google/android/samples/socialite/ui/mediaenhancement/EnhancementViewModel.kt # app/src/main/java/com/google/android/samples/socialite/ui/mediaenhancement/ImageEnhancementScreen.kt
…ncement # Conflicts: # app/build.gradle.kts # app/src/main/java/com/google/android/samples/socialite/repository/ChatRepository.kt # app/src/main/java/com/google/android/samples/socialite/ui/Main.kt # app/src/main/java/com/google/android/samples/socialite/ui/chat/component/MessageBubble.kt # app/src/main/java/com/google/android/samples/socialite/ui/mediaenhancement/EnhancementUtils.kt # app/src/main/java/com/google/android/samples/socialite/ui/mediaenhancement/EnhancementViewModel.kt # app/src/main/java/com/google/android/samples/socialite/ui/mediaenhancement/ImageEnhancementScreen.kt
…ncement # Conflicts: # app/src/main/java/com/google/android/samples/socialite/ui/mediaenhancement/EnhancementUtils.kt
…ncement # Conflicts: # app/src/main/java/com/google/android/samples/socialite/ui/mediaenhancement/EnhancementUtils.kt
Major changes: - Integrate Glide Compose to render enhanced images in `ImageEnhancementScreen`. Minor changes: - Add Glide and Glide Compose dependencies to `build.gradle.kts` and `libs.versions.toml`. - Configure `GlideImage` to skip memory and disk caching when loading in-memory bitmaps to avoid unnecessary overhead.
Add on-device AI image enhancement feature to enhance images on the Chat screen.
Major changes:
ImageEnhancementScreenandEnhancementViewModelto handle image enhancement features, including tonemapping, deblurring, and upscaling.EnhancementUtils.ktproviding coroutine-based wrappers for enhancement session management, bitmap processing, and module installation.Minor changes:
ChatMessagemodel to include a unique ID and add support for updating media URIs in theChatRepositoryandMessageDao.Main.ktandSocialiteNavigation.kt.