Silcoish
Silcoish

Reputation: 29

Android modify imported library via gradle

I am imported the zxing android library for use via gradle, however I want to modify the way things are drawn. From my understanding, that can only be changed by changing the draw function in one of the classes in the library. The problem is I cannot modify the classes in the library due to them being imported with gradle.

Is there any way I can edit that file or even supply another file to override that one? Thanks for your time.

Edit: Here is a link to the zxing github and the class that I am trying to change the functions in. I want to be able to change what the onDraw function does.

https://github.com/zxing/zxing/blob/master/android/src/com/google/zxing/client/android/ViewfinderView.java

Upvotes: 0

Views: 652

Answers (2)

Silcoish
Silcoish

Reputation: 29

I wasn't able to find a way to override the file, but I did find a workaround. I ended up extending the zXingScannerView file and did an override for the function setAutoFocus(boolean state). I chose that one because it was always called after the overlay was set and allowed me to easily remove it straight away.

Inside that funtion I did:

int chidrenCount = getChildCount();
for(int i = 0; i < childrenCount; i++) {
    if(getChildAt(i) instanceof ViewFinderView) {
        getChildAt(i).setVisibility(View.INVISIBLE);
    }
}

Upvotes: 0

FlyingPumba
FlyingPumba

Reputation: 1053

if you refer to the Zxing Android library for working with Barcodes, it's Open Source ! That means you can download the source code of this library, import it to your project and make the changes you need.

For reading more on importing libraries to Android projects, read this SO question.

Also, if you feel that other users of ZXing would benefit from this change, you can always contribute to the library on GitHub.

Upvotes: 0

Related Questions