Present Single Lens in Camera Kit
Overview
In your Camera Kit integration, sometimes you only want to show a single Lens vs showing all your Lenses in the group. If you are not using your own custom layout then below guide should help you achieve this on Android.
Android Implementation
There are multiple options to present only a single Lens when you present the Camera screen in your application and it depends on which option you have chosen to integrate the Camera Kit.
While using CameraActivity
Your app needs to call CameraActivity.Configuration.WithLens with the parameters which specify which Lens to apply (as lensID) and the Lens group (as lensGroupID) this particular Lens belongs to. Optionally you can pass parameters like displayLensIcon indicating whether an icon should be displayed when this Lens is applied, cameraFacingFront indicating whether the front camera should open by default or the back camera, etc. You can find more of these optional parameters in the CameraActivity.Configuration class. Please refer to camerakit-sample-simple app sample code for examples.
While using CameraLayout
While initializing CameraLayout you can configure the Carousel using configureLensesCarousel method and enable the Lens by its ID for which you are interested in activating by calling configureEachItem. If you don’t want to show Camera Preview without any Lens applied then you can disable the idle state by simply setting disableIdle to true. Similarly you can disable the close button (x icon under Shutter button) by setting closeButtonEnabled to false. Here is the code snippet for the same:
findViewById<CameraLayout>(R.id.camera_layout).apply {
configureLensesCarousel {
disableIdle = true
closeButtonEnabled = false
observedGroupIds = linkedSetOf(*lensGroups)
configureEachItem { item ->
item.enabled = item.lens.id == LENS_ID_TO_BE_APPLIED
}
}
}