A custom Android camera app that uses both Camera1 and Camera2 APIs to support Android phones running pre-V21, V21 or Post-V21 OS. It includes both the custom camera code and a sample use case.
The Picture Picker is a fragment file that manages image capturing (using an in-app custom camera) and picture selection (via selecting picture from the Gallery)
The picture picker is designed to be inflated (like the regular fragment) into another Android Component, e.g. Activity or Fragment.
Assuming that the picture picker will be hosted by fragment PicturePickerTestFragment, do the following:
- Create an instance of class PicturePickerOption [see below for more explanation] to customize the view and behavior of the picture picker. For example:
val picturePickerOption = PicturePickerOption(
promptText = "Snap the customer and position the head between the box",
showCaptureFrame = true)-
Make PicturePickerTestFragment class implement interface PicturePickerCallback [see below for more explanation]
-
Create a new instance of PicturePickerFragment (inside
PicturePickerTestFragment#onCreateView) by passing the created instances in 1. and 2. above to the newInstance() function of the PicturePickerFragment class. For example:
val picturePicker = PicturePickerFragment.newInstance(this, picturePickerOption)NB: 'picturePicker' object can be promoted to a class variable for some use cases of the picture picker.
- Inflate the picturePicker fragment instance into the fragment container (usually, a FrameLayout or FragmentContainer) prepared by fragment_picture_picker_test.xml inside
PicturePickerTestFragment#onCreateView(seeappendix Ifor the complete content in the XML file). For example:
childFragmentManager.beginTransaction()
.replace(R.id.container, picturePicker)
.commit()See more in appendix II.
RECOMMENDATION: DO NOT add this fragment transaction to the transaction backstack.
At this point, you should be able to interact with the Picture Picker UI.
(See Wiki - https://github.com/SirGoingFar/SnapNow/wiki/SnapNow - for more)