Integrating ProofMode in Simple Camera Android
--
ProofMode has arguably been one of the most exciting projects I have worked on as an Android developer.
ProofMode’s purpose has been to enable any individual to generate proof of images and videos they take using their phones. This proof can be shared with an entity such as a lawyer in court when need be. Though there has been much advancement in the Android and iOS apps, one of our main goals has been to enable other third-party camera app developers to have this power of proof generation in their own apps without necessarily having to get all of ProofMode’s code.
The birth of libProofMode Android
After successfully pulling proof generation into a library tagged libProofMode Android, the next step was to integrate it into a third-party app thus Simple Camera was chosen and we succeeded in the integration. There were of course a few bugs that had to be resolved such as the app failing to do a recording when the shutter sound setting is turned on.
On the technical side of things, we choose to use Android’s WorkManager APIs so that the proof generation is done in the background without affecting the user experience. Thus when a photo or video is captured and saved, the proof generation worker is triggered to generate proof at once. This proof can be shared later as a Zip file with others.
Integrating libProofMode into Your Own App
There is a sample that can be found at the following link. The sample explains how to add the dependencies to your own app and how to generate the proof.
How Does libProofMode Android Generate Proof?
Proof generation is done using a media URI. Given a media URI, a unique media hash is generated and thus used to create the directory to store the proof for this media item. In Simple Camera, we used Android’s WorkManager.
class GenerateProofWorker(
private val ctx: Context,
workParams: WorkerParameters
) : Worker(ctx.applicationContext, workParams) {
override fun doWork(): Result {
val imageOrVideoUriString = inputData.getString(ProofModeUtils.MEDIA_KEY)
val hash = ProofMode.generateProof(ctx…