-
Notifications
You must be signed in to change notification settings - Fork 89
Magic Selfie sample redesign #85
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.
Summary of Changes
Hello @lethargicpanda, 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!
This pull request significantly redesigns the user interface of the Magic Selfie sample application. The changes focus on improving the visual appeal and user experience by integrating custom UI components from a shared ui-component
module, standardizing the top app bar, and refining the input and feedback mechanisms. The underlying ML Kit Segmentation dependency was also updated to use a version catalog, ensuring consistent dependency management across the project.
Highlights
- Dependency Updates: The project's dependency management was updated to include
mlkitSegmentation
inlibs.versions.toml
and themagic-selfie
sample'sbuild.gradle.kts
was modified to use this new version catalog entry. Additionally, themagic-selfie
sample now depends on the shared:ui-component
module. - UI Redesign in MagicSelfieScreen: The
MagicSelfieScreen.kt
file underwent a significant UI overhaul. This includes replacing the standardTopAppBar
with a customSampleDetailTopAppBar
, changing the main layout from aColumn
to aBox
with a visually appealing background shader, and replacing standard Material Design components likeButton
andTextField
with customPrimaryButton
,GenerateButton
,SecondaryButton
, andTextInput
components from the newly integratedui-component
module. - Removal of SeeCodeButton: The
SeeCodeButton.kt
file was removed, as its functionality to link to the source code is now integrated directly into theSampleDetailTopAppBar
component, streamlining the UI and reducing redundant code. - String Resource Updates: The
strings.xml
file was updated to reflect the new UI elements and messaging. This involved renaming existing strings, adding new ones for the redesigned components (e.g.,magic_selfie_title
,add_image
,prompt_placeholder
), and removing strings related to the old UI and background processing status messages. - UI Component Enhancement: The
SecondaryButton
composable in theui-component
module was enhanced by adding anenabled
parameter. This allows for better control over the button's interactive state, enabling or disabling it based on application logic.
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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
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.
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 and welcome redesign of the Magic Selfie sample's UI. It successfully componentizes UI elements into a shared :ui-component
module, improving code organization and reusability. The new UI is more modern and visually appealing.
My review focuses on a few areas for improvement:
- Adherence to lifecycle best practices for collecting state flows in Compose.
- Correct handling of side effects to prevent bugs like repeated
Toast
messages. - Restoring user feedback for long-running operations to improve UX.
- Enhancing accessibility by providing content descriptions for images.
Overall, this is a great update, and with a few adjustments, it will be even better.
...amples/magic-selfie/src/main/java/com/android/ai/samples/magicselfie/ui/MagicSelfieScreen.kt
Outdated
Show resolved
Hide resolved
...amples/magic-selfie/src/main/java/com/android/ai/samples/magicselfie/ui/MagicSelfieScreen.kt
Show resolved
Hide resolved
...amples/magic-selfie/src/main/java/com/android/ai/samples/magicselfie/ui/MagicSelfieScreen.kt
Outdated
Show resolved
Hide resolved
fc97089
to
00c617b
Compare
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.
When ran on my emulator, I get an error saying "Failed to init module subject segmenter" which feels like a bit of a vague error. Assuming this is because there's not really a solid image (it's the weird emulator selfie camera), but just wanted to double check this is expected.
) | ||
}, | ||
) { innerPadding -> | ||
Column( | ||
val imageBitmap = remember { |
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.
Since we're reusing this component in 3 places already (Imagen, Multimodal, and Selfie) - it would make sense to extract it into the ui-components module, wdyt?
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.
I thought about it, but they all have a slightly different behavior (w/ and w/o input text, etc...) so it felt quicker to rebuild it adhoc for the sake of time. But eventually I want to revisit it.
@JolandaVerhoef thanks for flagging it. Is it the case with the |
.height(80.dp) | ||
.align(Alignment.BottomCenter), | ||
primaryButton = { | ||
GenerateButton( |
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.
doesn't have to be addressed in this PR, but perhaps we should have GenerateButton and SecondaryButton's text
parameter be optional, similar to how icon
is optional right now
private fun MagicSelfieScreenPreview() { | ||
AISampleCatalogTheme { | ||
MagicSelfieScreen( | ||
uiState = MagicSelfieUiState.Initial, |
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.
Would be nice to add Previews for different Screen states
Implementation of new UI:

This is an early implementation of the screen. It has the following known issues that will be addressed in following PRs: