Skip to content

Instantly share code, notes, and snippets.

@obfusk obfusk/README.md
Last active Dec 15, 2015

Embed
What would you like to do?
phonegap barcode lib

Library

android update project --path ./ --library ./phonegap-plugins/Android/BarcodeScanner/2.2.0/LibraryProject

pushd phonegap-plugins/Android/BarcodeScanner/2.2.0/LibraryProject
android update project --path ./ --target android-17
popd

Java

mkdir -p src/com/phonegap/plugins/barcodescanner
ln -s ../../../../../phonegap-plugins/Android/BarcodeScanner/2.0.0/src/com/phonegap/plugins/barcodescanner/BarcodeScanner.java src/com/phonegap/plugins/barcodescanner/

JavaScript

ln -s ../../phonegap-plugins/Android/BarcodeScanner/2.0.0/assets/www/barcodescanner.js assets/www/

res/xml/config.xml

<plugin name="BarcodeScanner" value="com.phonegap.plugins.barcodescanner.BarcodeScanner"/>

AndroidManifest.xml

<!-- ZXing { -->
<activity android:name="com.google.zxing.client.android.CaptureActivity"
          android:screenOrientation="landscape"
          android:clearTaskOnLaunch="true"
          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>
<activity android:name="com.google.zxing.client.android.encode.EncodeActivity" android:label="@string/share_name">
  <intent-filter>
    <action android:name="com.phonegap.plugins.barcodescanner.ENCODE"/>
    <category android:name="android.intent.category.DEFAULT"/>
  </intent-filter>
</activity>
<activity android:name="com.google.zxing.client.android.HelpActivity" android:label="@string/share_name">
  <intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
  </intent-filter>
</activity>
<!-- } ZXing -->

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
$ ->
mobile = navigator.userAgent.match /\b(android|ipad|mobile)\b/i
scan_qr = (succ, canc, err) ->
console.log 'scan_qr'
f = (x) -> if x.cancelled then canc() else succ x.text, x.format
window.plugins.barcodeScanner.scan f, err
scan_canc = -> alert 'Scan Cancelled'
scan_err = (err) -> alert 'Scan Error: ' + err
scan_succ = (text) ->
console.log 'scan_succ: ' + text
# ...
init = ->
console.log 'init; mobile: ' + !!mobile
# ... if mobile
if mobile
document.addEventListener 'deviceready', init, false
else
init()
# vim: set tw=70 sw=2 sts=2 et fdm=marker :
- scripts = %w{ cordova-2.5.0.js barcodescanner.js } +
- %w{ http://code.jquery.com/jquery-1.9.1.min.js } +
- %w{ coffee/index.js }
!!!
%html
%head
%meta{ 'http-equiv' => 'Content-Type', content: 'text/html; charset=UTF-8' }/
%meta{ name: 'format-detection', content: 'telephone=no' }/
%meta{ name: 'viewport', content: 'user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi' }/
- scripts.each do |x|
%script{ type: 'text/javascript', src: x }
%title ...
%body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.