czlucius / code-scanner

An Android app to scan and generate codes(barcodes/QR codes)
GNU Affero General Public License v3.0
39 stars 24 forks source link

[Feature]: Add share button to bottom sheet #22

Open czlucius opened 2 years ago

czlucius commented 2 years ago

Is your feature request related to a problem? Please describe.

Users cannot share the scanned text and have to copy and paste in their desired app

Describe the solution you'd like

Add a share chip to the action bar on the bottom sheet dialog.

Describe alternatives you've considered

Copy and paste the text scanned.

Additional context

prvn2004 commented 1 year ago

can we add a share button in the bottom dialog and pass the text fields to that and share them using intent.

czlucius commented 1 year ago

We can add a chip to the current Actions pane. Currently, the architecture of this app is built such that the buttons shown on the bottom dialog are created for each Action supplied. An Action (https://github.com/czlucius/code-scanner/blob/main/app/src/main/java/com/czlucius/scan/objects/actions/Action.java) is supplied to a predefined Type (https://github.com/czlucius/code-scanner/blob/main/app/src/main/java/com/czlucius/scan/objects/Type.java), which will be used by the bottom dialog to show the buttons

Currently, I have a Share Action ready, but the implementation is not quite polished: https://github.com/czlucius/code-scanner/blob/c00e75a83dbfb39ba0af41f232cf6ce880e6957f/app/src/main/java/com/czlucius/scan/objects/Type.java#L64

It calls data.constructShareIntent for the data type. https://github.com/czlucius/code-scanner/blob/main/app/src/main/java/com/czlucius/scan/objects/actions/ShareAction.java#L42

So for the data types in https://github.com/czlucius/code-scanner/tree/main/app/src/main/java/com/czlucius/scan/objects/data, you have to override the constructShareIntent here (if a custom intent is needed, else it will just share text) Especially for the contact, Wi-Fi, geolocation intents, they are not just simple plain text intents

prvn2004 commented 1 year ago

so we have to create intents for special cases and override the custom intent.

czlucius commented 1 year ago

Yes

czlucius commented 1 year ago

In here https://github.com/czlucius/code-scanner/tree/main/app/src/main/java/com/czlucius/scan/objects/data

czlucius commented 1 year ago

For contacts you have to create a VCF file and share via the content provider

czlucius commented 1 year ago

https://github.com/czlucius/code-scanner/blob/c00e75a83dbfb39ba0af41f232cf6ce880e6957f/app/src/main/java/com/czlucius/scan/objects/data/Data.java#L36-L45 An example

tripathisharad commented 1 year ago

Hello @czlucius can you assign this project to me so that I will try to add share button at bottom sheet.

czlucius commented 1 year ago

You can come out with the code changes first, and make a PR. Afterwards, I will assign the issue.

prvn2004 commented 1 year ago

barcode library from android is deprecated. and it is giving some error in my studio.

czlucius commented 1 year ago

Can I have a screenshot? ML Kit is not deprecated, its still supported by Google.

prvn2004 commented 1 year ago

I am still figuring it out. Will contact you if doesn't find anything.

prvn2004 commented 1 year ago

IMG_20221007_231254378 It is giving this error on Barcode. And the android studio is not recognizing this import.