StreetComplete icon indicating copy to clipboard operation
StreetComplete copied to clipboard

Allow the user to pick alternative (non-system) camera app

Open mnalis opened this issue 8 months ago • 4 comments

Use case I would like to use OpenCamera with StreetComplete to take pictures for notes.

Currently StreetComplete forces use of default camera; and unfortunately on Android 11+ phones user can no longer change default camera from the one bundled with system (which they might want to do for variety of reasons: from bad UI, lacking features like https://github.com/streetcomplete/StreetComplete/issues/2880#issuecomment-1586164079, included OEM spyware or having other bugs etc).

Issue has been reported several times before (e.g. https://github.com/streetcomplete/StreetComplete/issues/5207, https://github.com/streetcomplete/StreetComplete/issues/4557, https://github.com/streetcomplete/StreetComplete/issues/4281, https://github.com/streetcomplete/StreetComplete/issues/2911#issuecomment-849855895, ...) but only recently was the root cause discovered in https://github.com/streetcomplete/StreetComplete/discussions/6190#discussioncomment-12847500

Proposed Solution Allow user to specify alternate camera to be used in StreetComplete preferences.

As noted in https://github.com/streetcomplete/StreetComplete/issues/5207#issuecomment-2808625626 by @westnordost :

I didn't know that. I'd accept a PR that allows to use Open Camera when it is installed. Maybe there is a library for that already. It should be multiplatform-capable or at least not get in the way towards making the app multiplatform.

mnalis avatar Apr 24 '25 23:04 mnalis

Vespucci open source implementation can be found around here, however it is Android-only.

It seems just few lines of code when using ACTION_IMAGE_CAPTURE intent like Vespucci does, so that seems simple enough.

However StreetComplete seems to be using some other (more complex) method in AttachPhotoFragment.kt which I am not really able to fully understand (it seems to call ActivityResultContracts.TakePicture in the end to do the actual intent call?)

I do not know what are the advantages of doing things that way, and could/should it be changed to (seemingly) more simple (yet more versatile?) Vespucci way? 🤷 So I don't know if it would satisfy "at least not get in the way towards making the app multiplatform" condition.

I could probably give "the Vespucci way" a try, if that would be acceptable solution? Or try to modify current way if someone would give me a hint how the intent options could be overriden with current ActivityResultContracts.TakePicture?

Maybe there is a library for that already. It should be multiplatform-capable

I tried looking, but wasn't successful[^1]. Closest I've been able to found something called io.github.kashif-mehmood-km:camerak which is "Compose Multiplatform (KMP?)"[^2] but as far as I can say it is more of do-it-yourself solution for integrating camera into your app than something simple like current calling of external camera app, so likely an overkill.

[^1]: not that it says much, I probably just suck at searching this stuff: as I don't even know correct places where such libraries would be strored/distrubuted, so I've just tried generic DuckDuckGo [^2]: if that is what we want? there is also something called "Kotlin Multiplatform Mobile (KMM)" like here, and it seems to be something else?

mnalis avatar Apr 25 '25 00:04 mnalis

Great news! As per your request https://github.com/streetcomplete/StreetComplete/issues/5207#issuecomment-2829069203, I've checked apps I have installed. It seems that Fossify Gallery is able to use Open Camera without problems.

Image

On the other hand, Oruxmaps has a specific menu to prompt the app to use OC:

Image

Hope this helps.

AAnderl avatar Apr 25 '25 07:04 AAnderl

ActivityResultContracts is the "new" way to do it. ActivityResultContracts can be done with any app, e.g. I do this to ask StreetMeasure for a measure result.

westnordost avatar Apr 25 '25 12:04 westnordost

Quick sanity check that these changes wouldn't conflict with the design choice to not allow pictures from the user's gallery (outlined in the FAQ and #1567).

stephenpcook avatar Jun 19 '25 09:06 stephenpcook