BarcodeScanner Plugin - Specify Screen Orientation

10 posts, 1 answers
  1. Bill
    Bill avatar
    75 posts
    Member since:
    Feb 2013

    Posted 27 Mar 2015 Link to this post

    I updated our BarcodeScanner plugin today and discovered that the camera/scanner now auto rotates its orientation. This is a game breaker for situations when you can't rotate a barcode. Think of a car door where the VIN barcode is vertical...

    Does anyone know of a parameter or setting that can be used to lock in the current orientation or specify one?
  2. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 01 Apr 2015 Link to this post

    Hi Bill,

    Thank you for contacting us about the matter. Indeed, since version 1.2.4, the Barcode Scanner plugin supports both landscape and portrait orientations in Android. However, the view rotates automatically and at this stage, there is no way to prevent this out of the box. I have escalated this to the Telerik Verified Plugins Marketplace team. I believe a solution will be developed soon.

    Until then, the only possible solution will be to use an older version of the Barcode Scanner plugin. As said above, the change is introduced for the first time in version 1.2.4. This means that, you should be able to still use any of the prior versions.

    I hope this helps.

    Regards,
    Kaloyan
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  3. Answer
    Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 07 Apr 2015 Link to this post

    Hi again Bill,

    I am happy to say that our engineers are working on a permanent fix that should expose a way to enable/disable the auto rotation programmatically. Still, until the fix is released, here is another possible workaround if you wish to benefit from the latest BarcodeScanner plugin version:
    1. Download the content in the above mentioned git repo as an archive.
    2. Import it in your project, under the Plugins folder.
    3. Open your project's properties and disable the default BarcodeScanner plugin. You should notice that there are two included now (one of them can't be disabled from the project's properties window).
    4. In AppBuilder, navigate to the newly imported BarcodeScanner plugin's plugin.xml file. You should see it under: Plugins/BarcodeScanner-master/plugin.xml.
    5. Add the following line in it:
      <config-file target="AndroidManifest.xml" parent="/manifest/application">
         <activity
            android:name="com.google.zxing.client.android.CaptureActivity"
            android:clearTaskOnLaunch="true"
            android:screenOrientation="landscape"
            android:configChanges="orientation|keyboardHidden"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:windowSoftInputMode="stateAlwaysHidden"
            android:exported="false">
         <intent-filter>
            <action android:name="com.phonegap.plugins.barcodescanner.SCAN"/>
            <category android:name="android.intent.category.DEFAULT"/>
         </intent-filter>
      </activity>
    This will lock the BarcodeScanner's orientation to landscape. I hope it helps.

    Regards,
    Kaloyan
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  4. Bill
    Bill avatar
    75 posts
    Member since:
    Feb 2013

    Posted 05 Jun 2015 in reply to Kaloyan Link to this post

    Kaloyan, thanks for the work around. Setting the screen orientation in the plugin.xml file works.

     Unfortunately, the newer versions of the barcode scanner has the scanning window is so small that CODE_128 barcodes for vehicle VINs no longer work (at least on my test device it doesn't: LG G3).

     Are there any options to increase the scan window? I'm guessing that is the problem...  See screenshot.

  5. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 10 Jun 2015 Link to this post

    Hello Bill,

    I just tested this on Samsung Note 4 and you are absolutely correct that the scanning windows is too small. I ran the sample BarcodeScanner app with the latest (1.2.9) version of the plugin. The issue comes from this commit to the BarcodeScanner 1.2.4 version. The MAX_FRAME_WIDTH and MAX_FRAME_HEIGHT properties are changed there. This means that, with prior to the 1.2.4 version of the BarcodeScanner plugin, the issue should not be present. However, I will escalate the matter to our development team in order for a fix to be applied as soon as possible. Meanwhile, what I can suggest is to change the MAX_FRAME_WIDTH and MAX_FRAME_HEIGHT properties, as described here. Note that, you will have to re-build the zxing library for the changes to take effect.

    I hope this helps.

    Regards,
    Kaloyan
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  6. Amir
    Amir avatar
    2 posts
    Member since:
    Aug 2015

    Posted 04 Aug 2015 in reply to Kaloyan Link to this post

    Hey i am stuck with the same problem in the ios?

     So do u have nay fix for iphone/ipad.

     

    I tried adding changes to the config file

    <preference name="Orientation" value="lanscape"/>

    but this does not work. also in xcode (general tab i changed it to the same). The issue is when i open the barcodescanner it rotate as we changed the orientation.

    Please reply. 

     

     

  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 07 Aug 2015 Link to this post

    Hi Amir,

    I wasn't able to replicate this issue with the sample app available in the Plugin Marketplace. Can you please give it a try on your side and if the issue can be replicated, let me know the steps I should follow.

    I tested the sample app on an iPad running iOS 7.0.4 and an iPad Mini running iOS 7.1.1. If the sample app doesn't replicate the issue on your side, please send over a sample app that does so I can further investigate the reported behavior.

    Regards,
    Tina Stancheva
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  8. Amir
    Amir avatar
    2 posts
    Member since:
    Aug 2015

    Posted 09 Aug 2015 in reply to Tina Stancheva Link to this post

    Thanks Tina for the reply. Well i fixed the orientation issue in the native code.

     

    Regards

    Amir Gill

  9. Sam
    Sam avatar
    1 posts
    Member since:
    Sep 2015

    Posted 30 Sep 2015 in reply to Kaloyan Link to this post

    Hi, I am trying to lock my orientation to portrait during scan. My xamarin.android project has no plugins folder so i added it and added the plugins file from Github. The folder is showing up black in solution explorer so its not included in The project?? any ideas???
  10. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 05 Oct 2015 Link to this post

    Hi Sam,

    The BarcodeScanner plugin discussed in this forum thread is a Cordova plugin and the Plugins folder is part of an AppBuilder project structure. Can you please confirm whether you're using AppBuilder to develop your project? If you are, then the Plugins folder should be available in the project template out-of-the-box for you.

    Regards,
    Tina Stancheva
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
Back to Top