+ All Categories
Home > Technology > Rhodes And Phone Gap

Rhodes And Phone Gap

Date post: 09-May-2015
Category:
Upload: makoto-inoue
View: 12,692 times
Download: 0 times
Share this document with a friend
Description:
Introductory talk about Rhodes and Phone Gap at London Android User Group
35
new bamboo Rhodes and PhoneGap Makoto Inoue London Android User Group - July
Transcript
Page 1: Rhodes And Phone Gap

new bamboo

Rhodes and PhoneGap

Makoto Inoue London Android User Group - July

Page 3: Rhodes And Phone Gap

new bamboo

Me• Ruby On Rails > 3 years

• New Bamboo > 1 year

• Java == 0 month

• Rhodes experience > 7 months

• PhoneGap experience < 1 month

• This slide > 3 months

Page 4: Rhodes And Phone Gap

new bamboo

Topics

• Basic concept

• Rhodes

• PhoneGap

• More Info

Page 5: Rhodes And Phone Gap

new bamboo

Basic Concept

Page 6: Rhodes And Phone Gap

new bamboo

Why cross platform development ?

Page 8: Rhodes And Phone Gap

new bamboo

Write once, Run anywhere

Page 9: Rhodes And Phone Gap

new bamboo

Sounds familiar .......???

Page 10: Rhodes And Phone Gap

new bamboo

It’s framework that matters

Page 11: Rhodes And Phone Gap

new bamboo

Rhodes & Phone Gap

•HTML/CSS/Javascript for UI

•With Local device capabilities

Page 12: Rhodes And Phone Gap

new bamboo

Rhodes

Page 13: Rhodes And Phone Gap

new bamboo

How does Rhodes work?•MVC => Model on Web(RhoSync as Rails

app) and VC on Device (Rhodes)

•Ruby(XRuby for Android) for business logic and data access

•Generates HTML via Erb (Embedded Ruby)

•ORM => Key&value pair(Rhom)

Page 14: Rhodes And Phone Gap

new bamboo

Architecture

http://rhomobile.com/products

Page 15: Rhodes And Phone Gap

new bamboo

Sample Code

http://github.com/makoto/rhodes-twitter/tree/masterhttp://github.com/makoto/rhosync-twitter-adapter/tree/master

Page 16: Rhodes And Phone Gap

new bamboo

Model(Rhosync)

Page 17: Rhodes And Phone Gap

new bamboo

Model(Rhosync)

class PublicTimeline < SourceAdapter include RestAPIHelpers def initialize(source, credential = nil) super end

def query log "#{self.class} query" log @source.url.inspect

uri = URI.parse(@source.url) res = Net::HTTP.start(uri.host, uri.port) {|http| http.get("/statuses/public_timeline.xml") } xml_data = XmlSimple.xml_in(res.body); @result = xml_data["status"] end

Page 18: Rhodes And Phone Gap

new bamboo

View<ul id="PublicTimeLines" title="PublicTimeLines"><%@PublicTimeLines.each do |x|%>

<li class ="row"> <div class ="photo"> <img src=<%= escape x.user_profile_image_url %> alt=<%= escape x.user_screen_name %> /> </div> <div class ="status"> <div class ="text"> <%= escape x.text %> </div> <div class ="user"> <%= escape x.user_name %> <%= parse_time x.created_at %> via <%= escape x.source %> </div> </div></li><%end%></ul>

Page 19: Rhodes And Phone Gap

new bamboo

Controller&ORM(Rhodes)

Page 20: Rhodes And Phone Gap

new bamboo

PhoneGap

Page 21: Rhodes And Phone Gap

new bamboo

How does PhoneGap work(for Android)?

• Very thin layer on top of skeleton project

• appView.setJavaScriptEnabled

• appView. addJavascriptInterface(gap, "Device");

• appView.loadUrl(this.uri)

Page 22: Rhodes And Phone Gap

new bamboo

Source - DroidGap.java

public class DroidGap extends Activity { private static final String LOG_TAG = "DroidGap"; private WebView appView; private String uri; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); appView = (WebView) findViewById(R.id.appView); appView.setWebChromeClient(new GapClient(this)); appView.getSettings().setJavaScriptEnabled(true); appView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); bindBrowser(appView);

Page 23: Rhodes And Phone Gap

new bamboo

private void bindBrowser(WebView appView) { // The PhoneGap class handles the Notification and Android Specific crap PhoneGap gap = new PhoneGap(this, appView); GeoBroker geo = new GeoBroker(appView, this); AccelListener accel = new AccelListener(this, appView); // This creates the new javascript interfaces for PhoneGap appView.addJavascriptInterface(gap, "Device"); appView.addJavascriptInterface(geo, "Geo"); appView.addJavascriptInterface(accel, "Accel"); }

Source - DroidGap.java

Page 24: Rhodes And Phone Gap

new bamboo

public class PhoneGap{ private static final String LOG_TAG = "PhoneGap"; /* * UUID, version and availability */

.... public void beep(long pattern) { RingtoneManager beeper = new RingtoneManager(mCtx); Uri ringtone = beeper.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Ringtone notification = beeper.getRingtone(mCtx, ringtone); notification.play(); }

Source - PhoneGap.java

Page 25: Rhodes And Phone Gap

new bamboo

Notification.prototype.beep = function(count, volume){ Device.beep(count);}

Source - phonegap.js

Page 26: Rhodes And Phone Gap

new bamboo

Sample - index.html

Page 27: Rhodes And Phone Gap

new bamboo

More about Java & JS bridge at “Hello, Android” Chapter 7.3

Page 28: Rhodes And Phone Gap

new bamboo

More Info

Page 29: Rhodes And Phone Gap

new bamboo

Before you jump in...

Page 30: Rhodes And Phone Gap

new bamboo

Be aware of....• GPL (Some Javascript libraries)

• Dual License (Rhodes)

• Some app getting rejected (PhoneGap)

• Browser & Device compatibility issues

Page 31: Rhodes And Phone Gap

new bamboo

Jump in

Page 32: Rhodes And Phone Gap

new bamboo

More Info(Rhodes)

• Screencast http://www.youtube.com/rhomobile

• Rhomobile web site http://rhomobile.com

• Google group http://groups.google.com/group/rhomobile

• My blog http://rubyonmobile.wordpress.org

• Apps on Market http://rhomobile.com/customers

Page 33: Rhodes And Phone Gap

new bamboo

More Info(PhoneGap)

• web site http://phonegap.com/

• Google group http://groups.google.com/group/phonegap

• Screencast http://tinyurl.com/nl3bvx

• Apps on market http://phonegap.com/projects

Page 35: Rhodes And Phone Gap

new bamboo

Questions?


Recommended