Skip to content

Conversation

@riggaroo
Copy link
Collaborator

@riggaroo riggaroo commented Oct 8, 2025

No description provided.

@riggaroo riggaroo requested a review from tiwiz as a code owner October 8, 2025 13:51
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @riggaroo, 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, authored by riggaroo, transitions the application's image saving mechanism from JPEG to PNG format. The changes involve updating the bitmap compression format, file extensions, and MIME types in LocalFileProvider.kt and ImageGenerationRepository.kt to ensure images are consistently saved and handled as PNGs.

Highlights

  • Intent: This pull request changes the image saving format from JPEG to PNG across the application. This likely aims to preserve image quality better, as PNG is a lossless format, or to support transparency, which JPEG does not.
  • Changes Overview: The core change involves updating image compression calls and file handling logic to use the PNG format instead of JPEG. This includes modifying the Bitmap.CompressFormat and updating file extensions and MIME types in relevant file saving operations.
  • Detailed Changes: 1. core/util/src/main/java/com/android/developers/androidify/util/LocalFileProvider.kt: The saveBitmapToFile method was updated to compress bitmaps using Bitmap.CompressFormat.PNG instead of Bitmap.CompressFormat.JPEG. The quality parameter (100) remains the same. 2. data/src/main/java/com/android/developers/androidify/data/ImageGenerationRepository.kt: This file was modified to reflect the change in image format. Specifically: - In saveImage, the cache file name extension was changed from .jpg to .png. - In saveImageToExternalStorage(imageBitmap: Bitmap), the cache file name extension was changed from .jpg to .png, and the MIME type passed to saveToSharedStorage was updated from "image/jpeg" to "image/png". - In saveImageToExternalStorage(imageUri: Uri), the file name extension was changed from .jpg to .png, and the MIME type was updated from "image/jpeg" to "image/png".
  • Reviewer Activity: No reviewer activity has been recorded yet for this pull request.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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

  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
Contributor

@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

In this pull request, you've updated the image saving logic to use PNG instead of JPEG. This is a good change for preserving image quality. I've added a comment with a suggestion to improve maintainability by using constants for file extensions and MIME types. This will make it easier to manage the image format in the future. I also noticed that some test files still reference JPEG files, which you might want to update to keep your tests consistent with these changes.

Comment on lines +110 to 126
val cacheFile = localFileProvider.createCacheFile("shared_image_${UUID.randomUUID()}.png")
localFileProvider.saveBitmapToFile(imageBitmap, cacheFile)
return localFileProvider.sharingUriForFile(cacheFile)
}

override suspend fun saveImageToExternalStorage(imageBitmap: Bitmap): Uri {
val cacheFile = localFileProvider.createCacheFile("androidify_image_result_${UUID.randomUUID()}.jpg")
val cacheFile = localFileProvider.createCacheFile("androidify_image_result_${UUID.randomUUID()}.png")
localFileProvider.saveBitmapToFile(imageBitmap, cacheFile)
return localFileProvider.saveToSharedStorage(cacheFile, cacheFile.name, "image/jpeg")
return localFileProvider.saveToSharedStorage(cacheFile, cacheFile.name, "image/png")
}

override suspend fun saveImageToExternalStorage(imageUri: Uri): Uri {
return localFileProvider.saveUriToSharedStorage(
imageUri,
"androidify_image_original_${UUID.randomUUID()}.jpg",
"image/jpeg",
"androidify_image_original_${UUID.randomUUID()}.png",
"image/png",
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve maintainability and avoid repeating string literals, it would be beneficial to define constants for the file extension, MIME type, and filename prefixes. This will make future changes (e.g., switching to another image format) much easier.

You could add a companion object to the ImageGenerationRepositoryImpl class to hold these constants:

companion object {
    private const val IMAGE_EXTENSION = ".png"
    private const val IMAGE_MIME_TYPE = "image/png"
    private const val SHARED_IMAGE_PREFIX = "shared_image_"
    private const val RESULT_IMAGE_PREFIX = "androidify_image_result_"
    private const val ORIGINAL_IMAGE_PREFIX = "androidify_image_original_"
}

Then you can use these constants to construct the filenames and specify the MIME type across the class, for example:

  • Line 110: localFileProvider.createCacheFile("$SHARED_IMAGE_PREFIX${UUID.randomUUID()}$IMAGE_EXTENSION")
  • Line 116: localFileProvider.createCacheFile("$RESULT_IMAGE_PREFIX${UUID.randomUUID()}$IMAGE_EXTENSION")
  • Line 118: localFileProvider.saveToSharedStorage(cacheFile, cacheFile.name, IMAGE_MIME_TYPE)
  • Line 124: "$ORIGINAL_IMAGE_PREFIX${UUID.randomUUID()}$IMAGE_EXTENSION"
  • Line 125: IMAGE_MIME_TYPE

This change would centralize the image format configuration, making the code cleaner and easier to maintain.

Note: I noticed that test files like FakeImageGenerationRepository.kt and ResultsViewModelTest.kt still use .jpg extensions in hardcoded URIs. You might want to update them as part of this PR to ensure tests are consistent with this change.

@riggaroo riggaroo merged commit 6774068 into main Oct 8, 2025
5 checks passed
@riggaroo riggaroo deleted the feature/png branch October 8, 2025 15:08
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