-
Notifications
You must be signed in to change notification settings - Fork 348
Implement Camera2 - Image Capture Sample #23
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
f14dfb1
to
1160bff
Compare
@@ -24,6 +24,14 @@ android { | |||
} | |||
|
|||
dependencies { | |||
// Add samples specific dependencies | |||
// EXIF Interface | |||
implementation("androidx.exifinterface:exifinterface:1.3.6") |
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.
Use catalog format https://developer.android.com/build/migrate-to-catalogs
implementation("androidx.viewpager2:viewpager2:1.0.0") | ||
|
||
// Glide | ||
implementation("com.github.bumptech.glide:glide:4.15.1") |
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.
The project already uses Coil for image loading. Could you use that instead?
https://github.com/coil-kt/coil
description = "This sample demonstrates how to capture and image and encode it into a JPEG " | ||
+ "container. Includes enable torch (flash) support is available.", | ||
documentation = "https://developer.android.com/training/camera2/capture-sessions-requests", | ||
owners = ["Mozart Louis (mozart@google.com)"], |
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.
Let's avoid this feature. Better not to expose your email in the codebase + owners tend to change quite fast and we rather track this internally
@Sample( | ||
name = "Camera2 - Image Capture", | ||
description = "This sample demonstrates how to capture and image and encode it into a JPEG " | ||
+ "container. Includes enable torch (flash) support is available.", |
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.
"if it's available?"
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.
Some Devices don't have a touch light (Flash Capabilities)
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.
Sure, but I mean the sentence is not correct.
Includes enable torch (flash) support when available.
or
Includes enable torch (flash) support if it's available.
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.
Ah I see what you mean, Correcting in the next commit
@@ -18,6 +18,7 @@ | |||
|
|||
<uses-permission android:name="android.permission.CAMERA" /> | |||
<uses-permission android:name="android.permission.RECORD_AUDIO" /> | |||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> |
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 don't see it being used btw. Is it needed?
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 originally meant for it to be used to send a quick notification so the user can view the photos in an external viewer, but not needed anymore. Will remove
import java.io.File | ||
import kotlin.math.max | ||
|
||
class ImageViewerFragment( |
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.
You should not pass argument like this in a fragment.
https://developer.android.com/guide/fragments/create#add-programmatic
fb1bbdb
to
9c5ff19
Compare
binding.fragmentCamera2ImageCaptureViewfinder.visibility = View.GONE | ||
binding.fragmentCamera2ImageCaptureButton.visibility = View.GONE | ||
|
||
parentFragmentManager.commit { |
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.
The simple image viewer is already part of this fragment. You don't need the commit right?
binding.fragmentCamera2ImageCaptureButton.visibility = View.GONE | ||
|
||
parentFragmentManager.commit { | ||
binding.fragmentCamera2ImageCaptureImageView.setContent { |
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.
How are you handling the back navigation? Once you set the content the image will take most of the screen and user cannot remove it right?
b87f495
to
4a28e64
Compare
private fun returnToImageCapture() { | ||
binding.fragmentCamera2ImageCaptureButton.visibility = View.VISIBLE | ||
binding.fragmentCamera2PostCaptureBackButton.visibility = View.GONE | ||
binding.fragmentCamera2ImageCaptureImageView.setContent { } |
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.
Nit: if you make it gone there is probably no need to set an empty content
4a28e64
to
6bb0fa5
Compare
Description
This CL contains sample code for Camera2 Image Capture. This sample demonstrate how a developer can capture and image using the Camera2 APIs. This sample also demonstrate howt o display the captured image via the
ImageViewerFragment
classHow Has This Been Tested?
This sample app was tested on 3 devices on 3 different version of android:
Test Configuration #1 - Pixel 6 Pro API 33 (Android 13)
**Test Configuration #2 - Samsung Galaxy S22 Ultra (Android 12) **
Test Configuration #3 - Pixel 5a With 5G (Android 11)
Checklist:
Screenshots