Closed dannypadilla closed 4 years ago
So there's Camera2 then CameraX. CameraX still uses Camera2 stuff, but with what sounds like an easier API (preview/analysis/capture). Read up a bit. https://developer.android.com/training/camerax/architecture?#structure
We would just need to convert this to handle fragments, then create the individual fragments. I can do it maybe later tonight.
So the Q is: Do we want to use Camera X over Camera2? This starter code practically has everything we would need to start with (already uses fragments too)... https://github.com/android/camera-samples/tree/master/CameraXBasic
I converted it to handle fragments. Is should look like our HW now. We can just create fragments for any additional functionality. This could be our baseline?
There is a tiny bug..... FIXED BELOW
When you initially run the app and are prompted to give permission to access the Camera, after you agree; the camera view doesn't display anything.....
But after you reload the app, it functions as intended.. and never has that issue again.
There may've been something I was suppose to update when converting this to a Fragment. I moved everything from MainActivity
to CameraDisplay
.
I suggest separating the Permission logic from CameraDisplay
to it's own fragment. I saw in the cameraX code that it does this too:
Maybe we should just use this instead... It also has a image gallery view which we would need. Which would transition to the labeling part.
Fixed the bug.. should've made a separate pr...but this hasn't been merged yet... so RIP
https://stackoverflow.com/a/46046597/6052770
Noticed that after permission had to be requested, it wasn't reloading the fragment, so it had to be with the way we were passing the fragment to the request (was Activity)... hence why it would work after reloading the app.. the if hasPermission conditional uses the fragment correctly.... die
I'm going to merge and close since it seems like a good baseline and there hasn't been any objections... I'll create issues for separating the permissions and camera in to separate fragments..
I pushed the code labs tutorial I went through. https://codelabs.developers.google.com/codelabs/camerax-getting-started/index.html
This is using the new jetpack CameraX lib; https://developer.android.com/training/camera