Permalink
Browse files

Add barcode app

  • Loading branch information...
Brian Moore Brian Moore
Brian Moore authored and Brian Moore committed Aug 5, 2010
1 parent 7d7b7ab commit ab8ad1a7547683654acbc8af989e443ddaa9045b
Showing with 2,045 additions and 0 deletions.
  1. +28 −0 bars/Rakefile
  2. +23 −0 bars/app/Scanner/index.erb
  3. +7 −0 bars/app/Scanner/scanner.rb
  4. +29 −0 bars/app/Scanner/scanner_controller.rb
  5. +75 −0 bars/app/Settings/controller.rb
  6. +17 −0 bars/app/Settings/home.bb.erb
  7. +23 −0 bars/app/Settings/home.erb
  8. +32 −0 bars/app/Settings/index.bb.erb
  9. +46 −0 bars/app/Settings/index.erb
  10. +35 −0 bars/app/Settings/login.bb.erb
  11. +31 −0 bars/app/Settings/login.erb
  12. +15 −0 bars/app/Settings/reset.bb.erb
  13. +18 −0 bars/app/Settings/reset.erb
  14. +3 −0 bars/app/Settings/wait.bb.erb
  15. +5 −0 bars/app/Settings/wait.erb
  16. +24 −0 bars/app/Signature/edit.bb.erb
  17. +23 −0 bars/app/Signature/edit.erb
  18. +21 −0 bars/app/Signature/index.bb.erb
  19. +31 −0 bars/app/Signature/index.erb
  20. +24 −0 bars/app/Signature/new.bb.erb
  21. +22 −0 bars/app/Signature/new.erb
  22. +21 −0 bars/app/Signature/show.bb.erb
  23. +19 −0 bars/app/Signature/show.erb
  24. +8 −0 bars/app/Signature/signature.rb
  25. +36 −0 bars/app/Signature/signature_controller.rb
  26. +12 −0 bars/app/application.rb
  27. +108 −0 bars/app/helpers/application_helper.rb
  28. +18 −0 bars/app/helpers/browser_helper.rb
  29. +26 −0 bars/app/index.bb.erb
  30. +29 −0 bars/app/index.erb
  31. +25 −0 bars/app/layout.erb
  32. +11 −0 bars/app/loading.html
  33. +7 −0 bars/app/test/scanner_spec.rb
  34. +7 −0 bars/app/test/signature_spec.rb
  35. +18 −0 bars/build.yml
  36. BIN bars/icon/icon.ico
  37. BIN bars/icon/icon.png
  38. +296 −0 bars/public/css/android.css
  39. +115 −0 bars/public/css/blackberry.css
  40. +382 −0 bars/public/css/iphone.css
  41. +41 −0 bars/public/css/webkit.css
  42. +212 −0 bars/public/css/windows_mobile.css
  43. +21 −0 bars/public/images/IUI_LICENSE.txt
  44. BIN bars/public/images/android/btn_check_off.png
  45. BIN bars/public/images/android/btn_check_on.png
  46. BIN bars/public/images/android/btn_radio_off.png
  47. BIN bars/public/images/android/btn_radio_on.png
  48. BIN bars/public/images/android/disclosure.png
  49. BIN bars/public/images/android/ic_menu_more.png
  50. BIN bars/public/images/backButton.png
  51. BIN bars/public/images/blueButton.png
  52. BIN bars/public/images/cancel.png
  53. BIN bars/public/images/grayButton.png
  54. BIN bars/public/images/iphone/disclosure.png
  55. BIN bars/public/images/iphone/disclosure_detail.png
  56. BIN bars/public/images/iphone/radiobutton.png
  57. BIN bars/public/images/iphone/select.png
  58. BIN bars/public/images/iphone/switch.png
  59. BIN bars/public/images/iui-logo-touch-icon.png
  60. BIN bars/public/images/listArrow.png
  61. BIN bars/public/images/listArrowDown.png
  62. BIN bars/public/images/listArrowSel.png
  63. BIN bars/public/images/listGroup.png
  64. BIN bars/public/images/loading.gif
  65. BIN bars/public/images/pinstripes.png
  66. BIN bars/public/images/right_button.png
  67. BIN bars/public/images/selection.png
  68. BIN bars/public/images/thumb.png
  69. BIN bars/public/images/toggle.png
  70. BIN bars/public/images/toggleOn.png
  71. BIN bars/public/images/toolButton.png
  72. BIN bars/public/images/toolButton_new.png
  73. BIN bars/public/images/toolbar.png
  74. BIN bars/public/images/whiteButton.png
  75. +1 −0 bars/public/js/application.js
  76. +4 −0 bars/public/js/rho.js
  77. +59 −0 bars/public/js/rhogeolocation-wm.js
  78. +11 −0 bars/public/js/rhogeolocation.js
  79. +26 −0 bars/rhoconfig.txt
View
@@ -0,0 +1,28 @@
+require 'yaml'
+
+unless File.exists? "build.yml"
+ puts "Cannot find build.yml"
+ exit 1
+end
+
+
+$app_config = YAML::load_file("build.yml")
+$app_path = File.expand_path(File.dirname(__FILE__))
+
+if ENV["RHO_HOME"].nil?
+ rakefilepath = "#{$app_config["sdk"]}/Rakefile"
+else
+ rakefilepath = "#{ENV["RHO_HOME"]}/Rakefile"
+end
+
+unless File.exists? rakefilepath
+ puts "\nCannot find your Rhodes gem or source path."
+ puts "\nIf you have the sdk on your path or have installed the gem this"
+ puts "can be resolved by running 'set-rhodes-sdk'"
+ puts "\nYou can also set this manually by modifying your build.yml or"
+ puts "setting the environment variable RHO_HOME"
+ exit 1
+end
+
+load rakefilepath
+
View
@@ -0,0 +1,23 @@
+<div id="pageTitle">
+ <h1>Scanners</h1>
+</div>
+
+<div id="toolbar">
+ <div id="leftItem" class="regularButton"><%= link_to "Home", Rho::RhoConfig.start_path %></div>
+ <div id="rightItem" class="regularButton"><%= link_to "New", :controller => :Scanner, :action => :new %></div>
+</div>
+
+<div id="content">
+ <ul>
+ <% if System::get_property('has_camera') %>
+
+ <li>
+ <a href="<%= url_for :action => :new %>">
+ <span class="title">Scan Barcode</span>
+ <span class="disclosure_indicator"></span>
+ </a>
+ </li>
+
+ <% end %>
+ </ul>
+</div>
@@ -0,0 +1,7 @@
+# The model has already been created by the framework, and extends Rhom::RhomObject
+# You can add more methods here
+class Scanner
+ include Rhom::PropertyBag
+
+ #add model specifc code here
+end
@@ -0,0 +1,29 @@
+require 'rho/rhocontroller'
+require 'helpers/browser_helper'
+
+class ScannerController < Rho::RhoController
+ include BrowserHelper
+
+ #GET /Scanner
+ def index
+ end
+
+ # GET /Scanner/new
+ def new
+ Camera::take_picture(url_for :action => :camera_callback)
+ redirect :action => :index
+ end
+
+ def show_barcode_info(recognized_code)
+ Alert.show_popup('Barcode['+recognized_code+']')
+ end
+
+ def camera_callback
+ WebView.navigate(url_for :action => :index)
+ barcode = Barcode::barcode_recognize(Rho::RhoApplication::get_blob_path(@params['image_uri']))
+ show_barcode_info(barcode)
+ ""
+ end
+
+
+end
@@ -0,0 +1,75 @@
+require 'rho'
+require 'rho/rhocontroller'
+require 'rho/rhoerror'
+require 'helpers/browser_helper'
+
+class SettingsController < Rho::RhoController
+ include BrowserHelper
+
+ def index
+ @msg = @params['msg']
+ render
+ end
+
+ def login
+ @msg = @params['msg']
+ render :action => :login, :back => '/app'
+ end
+
+ def login_callback
+ errCode = @params['error_code'].to_i
+ if errCode == 0
+ # run sync if we were successful
+ WebView.navigate Rho::RhoConfig.options_path
+ SyncEngine.dosync
+ else
+ if errCode == Rho::RhoError::ERR_CUSTOMSYNCSERVER
+ @msg = @params['error_message']
+ end
+
+ if !@msg || @msg.length == 0
+ @msg = Rho::RhoError.new(errCode).message
+ end
+
+ WebView.navigate ( url_for :action => :login, :query => {:msg => @msg} )
+ end
+ end
+
+ def do_login
+ if @params['login'] and @params['password']
+ begin
+ SyncEngine.login(@params['login'], @params['password'], (url_for :action => :login_callback) )
+ render :action => :wait
+ rescue Rho::RhoError => e
+ @msg = e.message
+ render :action => :login
+ end
+ else
+ @msg = Rho::RhoError.err_message(Rho::RhoError::ERR_UNATHORIZED) unless @msg && @msg.length > 0
+ render :action => :login
+ end
+ end
+
+ def logout
+ SyncEngine.logout
+ @msg = "You have been logged out."
+ render :action => :login
+ end
+
+ def reset
+ render :action => :reset
+ end
+
+ def do_reset
+ Rhom::Rhom.database_full_reset
+ SyncEngine.dosync
+ @msg = "Database has been reset."
+ redirect :action => :index, :query => {:msg => @msg}
+ end
+
+ def do_sync
+ SyncEngine.dosync
+ @msg = "Sync has been triggered."
+ redirect :action => :index, :query => {:msg => @msg}
+ end
+end
@@ -0,0 +1,17 @@
+<div id="pageTitle">
+ <h1>Home</h1>
+</div>
+
+<div id="toolbar">
+ <% if SyncEngine::logged_in > 0 %>
+ <%= link_to "Logout", :action => :logout %>
+ <% else %>
+ <%= link_to "Login", :action => :login %>
+ <% end %>
+</div>
+
+<div id="content">
+ <ul>
+ <li>Add links here...</li>
+ </ul>
+</div>
View
@@ -0,0 +1,23 @@
+<div id="pageTitle">>
+ <h1>Home</h1>
+</div>
+
+<div id="toolbar">
+ <div id="leftItem" class="blueButton"><%%= link_to "Sync", :action => :do_sync %></div>
+ <%% if SyncEngine::logged_in > 0 %>
+ <div id="rightItem" class="regularButton"><%%= link_to "Logout", :action => :logout %></div>
+ <%% else %>
+ <div id="rightItem" class="regularButton"><%%= link_to "Login", :action => :login %></div>
+ <%% end %>
+</div>
+
+<div id="content">
+ <ul>
+ <li>
+ <a href="#">
+ <span class="title">Add Links Here...</span>
+ <span class="disclosure_indicator"></span>
+ </a>
+ </li>
+ </ul>
+</div>
@@ -0,0 +1,32 @@
+<div id="pageTitle">
+ <h1>Settings</h1>
+</div>
+
+<div id="content">
+ <% if @msg %>
+ <div class="alert" align="center"><%= @msg %></div>
+ <% end %>
+
+ <ul>
+ <li>
+ <p>Client ID: <span class="cid"><%= Rhom::Rhom::client_id %></span></p>
+ </li>
+ <li>
+ <%= link_to "Reset Database", :action => :reset %>
+ </li>
+ <li>
+ <%= link_to "Sync", :action => :do_sync %>
+ </li>
+
+ <% if SyncEngine::logged_in > 0 %>
+ <li>
+ <%= link_to "Logout", :action => :logout %>
+ </li>
+ <% else %>
+ <li>
+ <%= link_to "Login", :action => :login %>
+ </li>
+ <% end %>
+ </ul>
+
+</div>
@@ -0,0 +1,46 @@
+<div id="pageTitle">
+ <h1>Settings</h1>
+</div>
+
+<div id="toolbar"></div>
+
+<div id="content">
+ <ul id="settings">
+ <% if @msg %>
+ <li class="alertMessage">
+ <span class="message"><%= @msg %></span>
+ </li>
+ <% end %>
+ <li>
+ <div class="itemLabel">
+ <span class="title">Client ID:</span>
+ </div>
+ <div class="itemValue">
+ <span class="clientID"><%= Rhom::Rhom::client_id %></span>
+ </div>
+ </li>
+ <li>
+ <a href="<%= url_for :action => :reset %>">
+ <span class="title">Reset Database</span>
+ </a>
+ </li>
+ <li>
+ <a href="<%= url_for :action => :do_sync %>">
+ <span class="title">Perform Sync</span>
+ </a>
+ </li>
+ <% if SyncEngine::logged_in > 0 %>
+ <li>
+ <a href="<%= url_for :action => :logout %>">
+ <span class="title">Logout</span>
+ </a>
+ </li>
+ <% else %>
+ <li>
+ <a href="<%= url_for :action => :login %>">
+ <span class="title">Login</span>
+ </a>
+ </li>
+ <% end %>
+ </ul>
+</div>
@@ -0,0 +1,35 @@
+<div id="pageTitle">
+ <h1>Login</h1>
+</div>
+
+<div id="toolbar">
+ <%= link_to "Back", :action => :index %>
+</div>
+
+<div id="content">
+ <form method="POST" action="<%= url_for :action => :do_login %>">
+
+ <% if @msg %>
+ <div class="alert" align="center"><%= @msg %></div>
+ <% end %>
+
+ <table>
+
+ <tr>
+ <td width="125" class="fieldLabel">Login</td>
+ <td><input type="text" maxlength="100" name="login"/></td>
+ </tr>
+
+ <tr>
+ <td width="125" class="fieldLabel">Password</td>
+ <td><input type="password" maxlength="100" name="password"/></td>
+ </tr>
+ </table>
+
+ <input type="submit" class="standardButton" value="Login" />
+ </form>
+</div>
+
+
+
+
@@ -0,0 +1,31 @@
+<div id="pageTitle">
+ <h1>Login</h1>
+</div>
+
+
+<div id="toolbar">
+ <div id="leftItem" class="regularButton"><%= link_to "Cancel", :action => :index %></div>
+</div>
+
+
+
+<div id="content">
+ <form method="POST" action="<%= url_for :action => :do_login %>">
+
+ <% if @msg %>
+ <p style="color:#ff0000"><%= @msg %></p>
+ <% end %>
+ <ul>
+ <li>
+ <label for="login" class="fieldLabel">Login</label>
+ <input type="text" name="login" <%= placeholder( "Login" ) %> />
+ </li>
+
+ <li>
+ <label for="password" class="fieldLabel">Password</label>
+ <input type="password" name="password" <%= placeholder( "Password" ) %> />
+ </li>
+ </ul>
+ <input type="submit" class="standardButton" value="Login" />
+ </form>
+</div>
@@ -0,0 +1,15 @@
+<div id="pageTitle">
+ <h1>Reset Database</h1>
+</div>
+
+<div id="toolbar">
+ <%= link_to "Confirm", :action => :do_reset %>
+ <%= link_to "Cancel", Rho::RhoConfig.options_path %>
+</div>
+
+<div id="content">
+ <div class="warning">
+ <h2>Are you sure?</h2>
+ <p> Resetting removes all objects from your device.</p>
+ </div>
+</div>
@@ -0,0 +1,18 @@
+<div id="pageTitle">
+ <h1>Reset Database</h1>
+</div>
+
+
+
+<div id="toolbar">
+ <div id="leftItem" class="regularButton"><%= link_to "Cancel", :action => :index %></div>
+ <div id="rightItem" class="blueButton"><%= link_to "Confirm", :action => :do_reset %></div>
+</div>
+
+
+<div id="content">
+ <div id="reset">
+ <h4>Are you sure?<br/>
+ Resetting removes all objects from your device.</h4>
+ </div>
+</div>
Oops, something went wrong.

0 comments on commit ab8ad1a

Please sign in to comment.