hypery2k / cordova-barcodescanner-plugin

barcode scanner plugin for PhoneGap
51 stars 39 forks source link

Scan as "portrait" instead of "landscape" #9

Open webmaster-imaginet opened 8 years ago

webmaster-imaginet commented 8 years ago

Hi,

The scan screen is in landscape mode.

cordova-barcodescanner-plugin

Is it possible to add the option to toggle / set it to portrait mode?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/31116010-scan-as-portrait-instead-of-landscape?utm_campaign=plugin&utm_content=tracker%2F12908089&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F12908089&utm_medium=issues&utm_source=github).
hypery2k commented 8 years ago

seems to be android specific

webmaster-imaginet commented 8 years ago

I test it on 3 different android versions: 4.4.4, 5.1.1, 6.0.1 all of them rotate the screen to landscape mode.

hypery2k commented 8 years ago

I know that the error exists in all android version but didn't have time for working on this feature

indianscout commented 7 years ago

Would be great if this plugin supports the same configuration props like https://github.com/phonegap/phonegap-plugin-barcodescanner - eg.:

   cordova.plugins.barcodeScanner.scan(
      function (result) {
          alert("We got a barcode\n" +
                "Result: " + result.text + "\n" +
                "Format: " + result.format + "\n" +
                "Cancelled: " + result.cancelled);
      }, 
      function (error) {
          alert("Scanning failed: " + error);
      },
      {
          "preferFrontCamera" : true,
          "showFlipCameraButton" : true,
          "prompt" : "Place a barcode inside the scan area",
          "formats" : "QR_CODE,PDF_417",
          "orientation" : "landscape"
      }
   );
chuckzee commented 6 years ago

This isn't an enhancement request, this is a bug.

a9y commented 6 years ago

@Krandelbord Have you tried phonegap-plugin-barcodescanner now that this project is discontinued.

Krandelbord commented 6 years ago

Yeah I tried but then the application doesn't start. I assume it phonegap plugins are not compatible with cordova? Is that right ?

a9y commented 6 years ago

I tried it earlier with a fresh project and it worked on my android device. Steps:

$ npm install -g cordova 
$ cordova create MyApp 
$ cd MyApp
$ cordova platform add android
$ cordova plugin add phonegap-plugin-barcodescanner

At this point paste the example code in index.js:

cordova.plugins.barcodeScanner.scan(
      function (result) {
          alert("We got a barcode\n" +
                "Result: " + result.text + "\n" +
                "Format: " + result.format + "\n" +
                "Cancelled: " + result.cancelled);
      },
      function (error) {
          alert("Scanning failed: " + error);
      },
      {
          preferFrontCamera : true, // iOS and Android
          showFlipCameraButton : true, // iOS and Android
          showTorchButton : true, // iOS and Android
          torchOn: true, // Android, launch with the torch switched on (if available)
          saveHistory: true, // Android, save scan history (default false)
          prompt : "Place a barcode inside the scan area", // Android
          resultDisplayDuration: 500, // Android, display scanned text for X ms. 0 suppresses it entirely, default 1500
          formats : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED
          orientation : "landscape", // Android only (portrait|landscape), default unset so it rotates with the device
          disableAnimations : true, // iOS
          disableSuccessBeep: false // iOS and Android
      }
   );

Finally, test:

$ cordova run android

Could it be a version mismatch? Are you inserting it into an older project that uses a previous version of cordova?

graemefaulkner commented 6 years ago

phonegap-plugin-barcodescanner doesn't seem to work for me either, it does say in the documentation that it "requires phonegap 7.1.0+ "

a9y commented 6 years ago

The latest version of cordova (8.0.0) appears to work fine. What version are you using for your project?

Krandelbord commented 6 years ago

It is getting more offtopic. I'm using cordova 8.0.0 and when I install phonegap-barcode-scanner android-run ends-up with: `* What went wrong: Execution failed for task ':processDebugResources'.

com.android.ide.common.process.ProcessException: Failed to execute aapt

a9y commented 6 years ago

I suspect it may be a problem with your build environment.

I just put together a little script that attempts to build a cordova project using the barcodescanner plugin within a clean environment. All files are placed in ~/cordova-demo and are self-contained. The only user interaction required is when accepting the Android license by pressing y and enter when prompted.

It downloads the Java 8 JDK, Android SDK tools/build-tools/platform, and Cordova, so make sure you have the bandwidth to accommodate before running the script.

Running the script a second time will just perform the build stage and won't attempt to download anything. Passing along run as an argument will execute cordova run instead of cordova build.

cordova-demo.sh