cordova-barcodescanner-plugin icon indicating copy to clipboard operation
cordova-barcodescanner-plugin copied to clipboard

Scan as "portrait" instead of "landscape"

Open webmaster-imaginet opened this issue 9 years ago • 12 comments

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).

webmaster-imaginet avatar Feb 22 '16 10:02 webmaster-imaginet

seems to be android specific

hypery2k avatar Feb 25 '16 04:02 hypery2k

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.

webmaster-imaginet avatar Feb 28 '16 08:02 webmaster-imaginet

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

hypery2k avatar Feb 28 '16 11:02 hypery2k

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"
      }
   );

indianscout avatar Sep 05 '16 19:09 indianscout

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

chuckzee avatar Apr 04 '18 21:04 chuckzee

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

a9y avatar Jun 04 '18 17:06 a9y

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

Krandelbord avatar Jun 04 '18 19:06 Krandelbord

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?

a9y avatar Jun 04 '18 19:06 a9y

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

graemefaulkner avatar Jun 05 '18 14:06 graemefaulkner

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

a9y avatar Jun 05 '18 16:06 a9y

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

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. at ChildProcess.whenDone (/tmp/apc/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23) at emitTwo (events.js:126:13) at ChildProcess.emit (events.js:214:7) at maybeClose (internal/child_process.js:925:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) (node:29841) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:29841) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. `

Krandelbord avatar Jun 05 '18 19:06 Krandelbord

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

a9y avatar Jun 05 '18 22:06 a9y