react-native-camera-android icon indicating copy to clipboard operation
react-native-camera-android copied to clipboard

Merge with react-native-camera?

Open lwansbrough opened this issue 9 years ago • 14 comments

Hey Eddie. By the looks of it you've done some good working getting the camera working on Android. Are you interested in unifying the code base under react-native-camera so we have a single cross-platform module? I'd love to have you as a co-author on the module.

lwansbrough avatar Jan 11 '16 17:01 lwansbrough

+1

ippa avatar Jan 11 '16 18:01 ippa

1+

jtremback avatar Jan 11 '16 21:01 jtremback

@lwansbrough sure!

Do we have to unify the api calls?

and how can we get started?

northfoxz avatar Jan 12 '16 01:01 northfoxz

Awesome! I think it would be appropriate to unify the API calls, yes. I've just given you write access to lwansbrough/react-native-camera - feel free to push your code up whenever you like. We can indicate the progress being made to merge the modules in the read me. Attribute yourself as you see fit.

lwansbrough avatar Jan 12 '16 02:01 lwansbrough

@lwansbrough ok thanks!

I will be modifying my code for the next few days

it might take a while

northfoxz avatar Jan 12 '16 02:01 northfoxz

@NorthFoxz I've revoked access temporarily until we get the merge sorted out. There are a few forks for Android. Yours is one of the most complete and functional ones I've seen. I think everyone can contribute to it the merge, but we should align on what we want to do before anyone commits code. Apologies! Please join the conversation, we're gonna need as much input as possible: https://github.com/lwansbrough/react-native-camera/issues/87

lwansbrough avatar Jan 12 '16 22:01 lwansbrough

@lwansbrough @NorthFoxz hey guys...just wanted to let you know that I had problems with the barcode scanner never reaching the onBarCodeScan event. I found the problem inside the method getFramingRectInPreview always returning a null object because getWidth and getHeight methods for viewport size would return 0. I defaulted them to screen size, and although it is a nasty hack, at least it works. viewFinderDisplay prop is set to true, but there is still no view finder whatsoever, so I guess the problem originates somewhere in passing that prop. Hope I helped at least a little :)

tarikmlaco avatar Feb 03 '16 16:02 tarikmlaco

@tarikmlaco +1 Did you find any solution to it yet? I can't scan barcodes at all.

rohitgoyal avatar Feb 17 '16 10:02 rohitgoyal

Yes, I did. I managed to hack the code inside react-native-camera-android Java code...you need to manually set the viewfinder Rect to screen size and then it will scan barcodes. It seems there is a problem with the viewfinder prop, as it never gets rendered even when it's set to true.

2016-02-17 11:04 GMT+01:00 rohitgoyal [email protected]:

@tarikmlaco https://github.com/tarikmlaco +1 Did you find any solution to it yet? I can't scan barcodes at all.

— Reply to this email directly or view it on GitHub https://github.com/NorthFoxz/react-native-camera-android/issues/1#issuecomment-185132070 .

tarikmlaco avatar Feb 17 '16 13:02 tarikmlaco

@tarikmlaco Where should I do that? Can you share that code?

rohitgoyal avatar Feb 17 '16 13:02 rohitgoyal

public synchronized Rect getFramingRectInPreview(int previewWidth, int
previewHeight) {
        if(this.mFramingRectInPreview == null) {

            Rect framingRect = this.mViewFinderView.getFramingRect();
            int viewFinderViewWidth = this.mViewFinderView.getWidth();
            int viewFinderViewHeight = this.mViewFinderView.getHeight();

            if(framingRect != null) {
                Rect rect = new Rect(framingRect);
                rect.top = 0;
                rect.left = 0;
                rect.right = previewWidth;
                rect.bottom = previewHeight;
                return rect;
            }

            if(framingRect == null || viewFinderViewWidth == 0 ||
viewFinderViewHeight == 0) {
                return null;
            }

            Rect rect = new Rect(framingRect);
            rect.left = rect.left * previewWidth / viewFinderViewWidth;
            rect.right = rect.right * previewWidth / viewFinderViewWidth;
            rect.top = rect.top * previewHeight / viewFinderViewHeight;
            rect.bottom = rect.bottom * previewHeight /
viewFinderViewHeight;
            this.mFramingRectInPreview = rect;
        }
        return this.mFramingRectInPreview;
    }

@rohitgoyal Find this function in the module, it is in RNCameraInstanceView.java and hack it the way I did.

tarikmlaco avatar Feb 18 '16 15:02 tarikmlaco

@tarikmlaco Thanks! Just tried it and it works. :) @lwansbrough Any plans on correcting the issue?

rohitgoyal avatar Feb 19 '16 11:02 rohitgoyal

@rohitgoyal No problem. But bear in mind that this is only a hack and subsequent version should fix the issue with the viewfinder prop. @lwansbrough @NorthFoxz any news on the merge?

tarikmlaco avatar Feb 19 '16 11:02 tarikmlaco

https://github.com/lwansbrough/react-native-camera/issues/87#issuecomment-174223015

lwansbrough avatar Feb 22 '16 08:02 lwansbrough