This question is a bit on the broader side of things so I will not provide any specific code because it will be irrelevant.
I have an app that allows the user to take photos, and hopefully videos in the future. Currently it happens as follows:
- The user opens a dialog inside one activity.
- The user can choose to take an image, which sends him to a CameraActivity (using CameraX).
- The user takes an image, the image is saved locally in the app files and the result code and path to the image are sent to the calling activity.
- The dialog overrides onActivityResult and loads the image from the internal storage and displays it.
- The user can choose to delete the image or cancel the entire dialog, on both cases the image needs to be removed from the storage. (The process can happen with multiple images inside the same dialog)
I wanted to ask you if it seems like a reasonable implementation or there are other architectures\android components you would recommend using. More specifically I'm worrying about the time it takes to save the image locally if I will want to increase the quality or do the same process with videos which are much heavier (I've already seen a considerable extra time if I want to save it as png instead of jpeg).
The two improvements to the system that I can think of:
- Using something akin to ViewModel for saving the bitmap and having the data available when moving back to the dialog from the camera activity.
- Saving the data to the cache instead on the local storage (and only save it to the local storage if the user approves in the dialog).
But I'd like to hear suggestions, are there any particular APIs that I should know about? or a recommended change to the architecture? The current system will simply be too slow for higher quality images or a video, and I'm not sure how best to improve things and also not make the app too consuming on the resources side.