Code Monkey home page Code Monkey logo

zxingfragmentlib's People

Contributors

ebuildy avatar ened avatar joniks avatar lovince avatar mitoyarzun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zxingfragmentlib's Issues

Application goes blank for couple of seconds then resumes to normal when the camera is initiated

I have successfully added the library to my project and it works as expected. One thing that I'm facing is that when I initiate the barcode scanner, the whole application goes blank for couple of seconds and then the camera shows up. The following times, when the camera is initiated the application doesn't go blank. Have anyone faced a similar issue? If yes what was your solution? Thanks!

Autofocus stops working when flashlight turns on

Autofocus runs fine while the flashlight is left off. once flashlight is turned on, autofocus stops. this persists even when flashlight is turned off.

tested with sample code and also implemented the code below in my app:

torchState = !torchState;
mScannerFragment.setTorch(torchState);

device : Samsung Galaxy S4 Active (LTE)
OS : Lollipop
Root : no

zxingfragmentlib Camera in Portrait mode on Android

Hi friends,

I found a bug in the zxing scanner. I use zxingfragmentlib to implement my fragment scanner. I have set android:screenOrientation to "portrait" in AndroidManifest, so I can only use it in portrait orientation.

I have tested the scanner in many android devices. I´ve found out that when I use the devise where the camera width is bigger than height then it rotates the camera view to 90 dregge.

Right now I have to rotate my device to 90 dregge in order to scan the barcode. It is not a good idea to do it that way.

I google the probleme for finding a solution. I found this page:
http://stackoverflow.com/questions/16252791/zxing-camera-in-portrait-mode-on-android

When I do what the Roylee says, the camera returns to the correct position but the scanner can't scan.

What should I do?

Please help me to figure out my problem
I thank you in advance.

Exception switching to landscape orientation

When I rotate my phone to landscape orientation I get the following exception:

06-18 10:18:21.798 3193-3344/com.welcu.android.zxingfragmentlibsample E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-10361
Process: com.welcu.android.zxingfragmentlibsample, PID: 3193
java.lang.IllegalArgumentException: Crop rectangle does not fit within image data.
at com.google.zxing.PlanarYUVLuminanceSource.(PlanarYUVLuminanceSource.java:50)
at com.welcu.android.zxingfragmentlib.camera.CameraManager.buildLuminanceSource(CameraManager.java:360)
at com.welcu.android.zxingfragmentlib.DecodeHandler.decode(DecodeHandler.java:77)
at com.welcu.android.zxingfragmentlib.DecodeHandler.handleMessage(DecodeHandler.java:56)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at com.welcu.android.zxingfragmentlib.DecodeThread.run(DecodeThread.java:101)

I need to load sample_activity.xml via Fragment

Hi friends,

My problem is when i call the onCreateView from my fragment (Scan) the program crashes because i can't use it with a normal Fragment. I have to use FragmentActivity to use sample_activity.xml but thats the problem.

 android.view.InflateException: Binary XML file line #9: Error inflating class fragment

Is there any alternative i can use without using FragmentActivity?

this lib work well but there is some problem

sometimes, Scan the qr code seems like must be in a distance . if too closer, it doesn't work.
when scan the one dimension code, it donesn't work as qr code effectively.
but when i use the barcode scanner app, it always work well whether one code or qr code.
what can i do for this problem? Thank you for

QR & Barcode scanner + Flashlight

Hi Friends,
The reason why I write you is my wish to have the zxing fragment library expanded with a flashlight function.Below you may see my code that generates a flashlight.

My problem is now that I need a camera opener function.
Unfortunately the code doesn´t work due to the fact that the camera is already open. And so there is a conflict meaning that the camera can´t open twice, because the first camera-open-function was used for opening the bar code scanner, and so I get an error message when I try to open the camera the second time.

Now, how do I handle this situation?
Is it possible through the library to get access to switch on and put off function for the flashlight. Will you be kind enough to help me?

Exceptions:
E/Camera Error. Failed to Open. Error:(28639): Fail to connect to camera service
java.lang.RuntimeException: Fail to connect to camera service
at android.hardware.Camera.native_setup(Native Method)
at android.hardware.Camera.(Camera.java:413)
at android.hardware.Camera.open(Camera.java:384)
at dk.logoslogit.repository.ZxingScanFragment.getCamera(ZxingScanFragment.java:225)
at dk.logoslogit.repository.ZxingScanFragment.access$1(ZxingScanFragment.java:222)
at dk.logoslogit.repository.ZxingScanFragment$2.onClick(ZxingScanFragment.java:79)
at android.view.View.performClick(View.java:4475)
at android.view.View$PerformClick.run(View.java:18786)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5419)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
at dalvik.system.NativeStart.main(Native Method)

public class ZxingScanFragment extends Fragment {

private final String TAG = "ZxingScanFragment";
private FragmentTransaction fTransaction;
private Camera camera;
private Fragment fDisplay;
private ImageButton torch;
private boolean isFlashOn;
private boolean hasFlash;
private Parameters parameter;
private MediaPlayer player;
private View mView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) {
    super.onCreateView(inflater, container, savedInstance);
    mView = inflater.inflate(R.layout.scan_zxing, container, false);
    setListTitle();     
    torch = (ImageButton) mView.findViewById(R.id.torch);

    // First check if device is supporting flashlight or not       
    hasFlash = getActivity().getApplicationContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);

    if (!hasFlash) {
        // Device doesn't support flash
        // Show alert message and close the application
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
        alertDialog.setTitle("Error");
        alertDialog.setMessage("Sorry, your device doesn't support flash light!");            
        alertDialog.setNegativeButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // Closing the application
                dialog.cancel();
            }
        });            
        alertDialog.show();
    }

    // Displaying button image
    toggleButtonImage();

    // Switch button click event to toggle flash on/off
    torch.setOnClickListener(new View.OnClickListener() { 
        @Override
        public void onClick(View v) {
            if (isFlashOn) {
                // On starting the app get the camera params
                getCamera();
                // Turn off flash
                turnOffFlash();
            } else {
                // On starting the app get the camera params
                getCamera();
                // Turn on flash
                turnOnFlash();
            }
        }
    });

    if (savedInstance == null) {            
        fDisplay = new ScanFragment();
        fTransaction = getChildFragmentManager().beginTransaction();
        fTransaction.remove(fDisplay);
        fTransaction.replace(R.id.scan_layout, fDisplay);
        fTransaction.commit();          
    }
    return mView;
}

private void setListTitle() {
    try {
        TextView onlineStatus = (TextView) mView.findViewById(R.id.list_title);   
        onlineStatus.setText("Scan stregkode");
    } catch (Exception ex) {
        Log.v(TAG, "Exception: setListTitle");
        ex.printStackTrace();
    }
}

// Turning On flash
private void turnOnFlash() {
    if (!isFlashOn) {
        if (camera == null || parameter == null) {
            return;
        }
        // Play sound
        playSound();             
        parameter = camera.getParameters();
        parameter.setFlashMode(Parameters.FLASH_MODE_TORCH);
        camera.setParameters(parameter);
        camera.startPreview();
        isFlashOn = true;             
        // Changing button/switch image
        toggleButtonImage();
    }

}


// Turning Off flash
private void turnOffFlash() {
    if (isFlashOn) {
        if (camera == null || parameter == null) {
            return;
        }
        // Play sound
        playSound();

        parameter = camera.getParameters();
        parameter.setFlashMode(Parameters.FLASH_MODE_OFF);
        camera.setParameters(parameter);
        camera.stopPreview();
        isFlashOn = false;             
        // Changing button/switch image
        toggleButtonImage();
    }
}


// Playing sound
// will play button toggle sound on flash on / off
private void playSound(){
    if(isFlashOn) {
        player = MediaPlayer.create(getActivity(), R.raw.light_switch_off);
    } else {
        player = MediaPlayer.create(getActivity(), R.raw.light_switch_on);
    }
    player.setOnCompletionListener(new OnCompletionListener() {

        @Override
        public void onCompletion(MediaPlayer player) {
            player.release();
        }
    });
    player.start();
}

/*
 * Toggle switch button images
 * changing image states to on / off
 * */
private void toggleButtonImage(){
    if(isFlashOn) {
        torch.setImageResource(R.drawable.scan_icon);
    } else {
        torch.setImageResource(R.drawable.room_icon);
    }
}

@Override
public void onDestroy() {
    super.onDestroy();
    if (camera != null) {
        camera.stopPreview();
        camera.release();
        camera = null;
    }
}

@Override
public void onPause() {
    super.onPause();
    if (camera != null) {
        camera.release();
        camera = null;
    }
    // On pause turn off the flash
    turnOffFlash();
}

@Override
public void onResume() {
    super.onResume();         
    // On resume turn off the flash
    if(hasFlash) {
        turnOffFlash();
    }
}

@Override
public void onStart() {
    super.onStart();                
}

@Override
public void onStop() {
    super.onStop();         
    // On stop release the camera
    if (camera != null) {
        camera.release();
        camera = null;
    }
}

// Get the camera
private void getCamera() {
    if (camera == null) {
        try {
            camera = Camera.open();
            parameter = camera.getParameters();
        } catch (RuntimeException re) {
            Log.e("Camera Error. Failed to Open. Error: ", re.getMessage());
            re.printStackTrace();
        } catch (Exception ex) {
            Log.e(TAG, "Exception: getCamera");
            Log.e(TAG, ex.getMessage());
            ex.printStackTrace();
        }
    } 
}

change frame size

i need a small frame,so i change max frame size.i can't get result if i near the camera .

AmbientLightManager

The torch won't turn on by itself. Are the onKeyDown() and onKeyup() overriding the functions of AmbientLightManager?
Please help.

How to use front camera?

Hi

How can I use the front camera? Or is there any way to switch camera in this library?

Thank you

Crop rectangle does not fit within image data

Hi,
I updated the library yesterday and, i got this issue...

java.lang.IllegalArgumentException: Crop rectangle does not fit within image data.
at com.google.zxing.PlanarYUVLuminanceSource.(PlanarYUVLuminanceSource.java:50)
at com.welcu.android.zxingfragmentlib.camera.CameraManager.buildLuminanceSource(CameraManager.java:360)
at com.welcu.android.zxingfragmentlib.DecodeHandler.decode(DecodeHandler.java:77)
at com.welcu.android.zxingfragmentlib.DecodeHandler.handleMessage(DecodeHandler.java:56)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at com.welcu.android.zxingfragmentlib.DecodeThread.run(DecodeThread.java:101)

It appears when I use the phone in landscape and open the my BarcodeScannerFragment.

I googled this error and, obviously, it means the device's camera driver has a bug.

BUT, i got the issue on multiple devices... and I don't really how to fix it...

Any clue ? Thanks

Laurent

advanced history handling

Hi, a real nice feature would be an advanced history handling.
After a barcode is scanned, it would be great to have a notification, if the new scanned barcode is a new one or it already exist in the history. A display on the screen or a sound would be possible options.

thanks,

BarcodeScannerFragment Skipped 63 Frames! when swiping between 3 fragments

Great work for porting this to use fragments, thanks!

I have a 3 tab viewpager. The barcode is fragment item number 2.

I start my application and the default fragment item 0 is shown. When I swipe to fragment item 1 the barcode scanner stored as item number 2 starts up, maybe the viewpager is caching it I'm not sure. This causes a bit of processing to occur as the camera initializes in the background and the DecodeThread starts up. Now this is all happening as fragment item 1 is showing not the barcode scanner which is fragment item 2.

Due to this there is a moment of about 1 second or ~60 frames frames skipped while switching between fragment item 0 and 1.

Here is an extract of my logcat :

04-23 23:13:59.076: I/CameraConfiguration(21035): Settable value: off
04-23 23:13:59.076: I/CameraConfiguration(21035): Supported values: [infinity, auto, macro, continuous-video, continuous-picture]
04-23 23:13:59.076: I/CameraConfiguration(21035): Settable value: auto
04-23 23:13:59.076: I/DecodeThread(21035): Hints: {POSSIBLE_FORMATS=[CODABAR, CODE_39, CODE_93, CODE_128, DATA_MATRIX, EAN_8, EAN_13, ITF, QR_CODE, RSS_14, RSS_EXPANDED, UPC_A, UPC_E], NEED_RESULT_POINT_CALLBACK=com.welcu.android.zxingfragmentlib.ViewfinderResultPointCallback@430cc730}
04-23 23:13:59.136: I/PlatformSupportManager(21035): Using implementation class com.welcu.android.zxingfragmentlib.common.executor.HoneycombAsyncTaskExecInterface of interface com.welcu.android.zxingfragmentlib.common.executor.AsyncTaskExecInterface for SDK 11
04-23 23:13:59.136: I/AutoFocusManager(21035): Current focus mode 'auto'; use auto focus? true
04-23 23:14:00.006: E/MediaPlayer(21035): Should have subtitle controller already set
04-23 23:14:00.006: I/Choreographer(21035): Skipped 63 frames! The application may be doing too much work on its main thread.
04-23 23:14:00.536: W/MediaPlayer-JNI(21035): MediaPlayer finalized without being released

Do you know of a way to keep the barcode scanner fragment from continually stopping and starting when swiping though fragments please?

Many Thanks,

Steve

Display Image distorted

I have problem when set my SurfaceView with fix size of 300,300. The displaying image is distorted.

Add license

Hi there.

First of all, thank you for this awesome library.
I use it in my company and it works perfectly.
The only issue we have is that it's missing a license.
Would you be able to add one?
Thanks a lot!

Blurred screen while scanning

Hello,

I have problem with scanning barcode with Samsung Galaxy S8 (dreamlte) with android 7.0. Screen is blurred while scanning.
Exception is:

java.lang.IllegalArgumentException:

at com.google.zxing.PlanarYUVLuminanceSource. (PlanarYUVLuminanceSource.java:50)
at com.google.zxing.client.android.camera.CameraManager.buildLuminanceSource (CameraManager.java:441)
at com.welcu.android.zxingfragmentlib.DecodeHandler.decode (DecodeHandler.java:87)
at com.welcu.android.zxingfragmentlib.DecodeHandler.handleMessage (DecodeHandler.java:53)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:154)
at com.welcu.android.zxingfragmentlib.DecodeThread.run (DecodeThread.java:96)

Scanning with other devices works fine.

Does someone have idea, where could be a problem?

Thanks a lot.

Michaela

Update gradle and Android sdk

It would be great if you could support new gradle version and target to new Android SDK 21.

Are you still developing this?

Thanks!

Scanning only in landscape

Hi,

Using sample code I tested in my Nexus 4 and another datacollector and issue happens. No scan results when in portrait.

Thanks

Lint error in CameraConfigurationManager

Hi,
thanks for this great library!
I am using it as a git submodule in my current project and I have noticed that there is a small Lint error which unfortunately breaks my Jenkins build.
In CameraConfigurationManager, lines 142-147, Lint complains that the method Camera.setDisplayOrientation() is only available on Android 8 and above while the build.gradle states that the library works with 7 as well. In fact, you do the correct thing and the statement will only be executed on versions other than 7. However, Lint does not seem to recognize that "other than 7" is the same as "higher than 7" because of the minSdk specified in build.gradle. A simple "if (Build.VERSION.SDK_INT<=7) {" instead of "if (Build.VERSION.SDK_INT==7) {" fixes the problem.
I would appreciate it if you could incorporate this little fix because I want to stick with using your library and to performing Lint checks on the build server. ;-)
Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.