Android has made great advances the last couple of years, and is one of the major actors in the phone and tablet markets. The main programming language on Android is Java. Android offers a comprehensive API to apps running on the Dalvik VM. The API covers a large part of the Java standard library in addition to Android specific APIs. Android includes tooling to convert Java .class files to Dalvik VM compatible class files. Ruboto uses JRuby to allow you to run Ruby scripts on the Dalvik VM. Using Ruby code, you have access to the complete Android API.
This presentation will introduce the different parts of Ruboto.
2. Ruboto
JRuby on Android
Saturday, January 26, 13 1
3. Uwe Kubosch
Work at Datek Wireless in
Norway
Ruboto core developer
JRuby rookie committer
Saturday, January 26, 13 2
4. Ruboto?
Platform for developing
Android apps using Ruby
Builds on JRuby and the
Android SDK
Application and component
generators
Test framework
Compact GUI definition
Saturday, January 26, 13 3
5. _why Ruboto?
Write Ruby instead of
Java/XML
Use Ruby libraries (gems)
Focus on testing
Faster development cycles
Saturday, January 26, 13 4
6. Topics covered
History
Ruboto IRB
Installation & development
tools
Hello world!
Demos
Limitations
Roadmap
Saturday, January 26, 13 5
7. Android basics/terms
Activity: A screen
View: A screen component
Service: Background process
Intent: Definition of action
BroadcastReceiver: Listener for Intents
Saturday, January 26, 13 6
8. History 2009
PoC by Charles Nutter
(headius) February 24,
2009
ruboto-irb by headius
August 1, 2009
Saturday, January 26, 13 7
9. History 2009
PoC by Charles Nutter
(headius) February 24,
2009
ruboto-irb by headius
August 1, 2009
Saturday, January 26, 13 7
10. History 2009
PoC by Charles Nutter
(headius) February 24,
2009
ruboto-irb by headius
August 1, 2009
Saturday, January 26, 13 7
11. History 2009
PoC by Charles Nutter
(headius) February 24,
2009
ruboto-irb by headius
August 1, 2009
Saturday, January 26, 13 7
12. History 2009
PoC by Charles Nutter
(headius) February 24,
2009
ruboto-irb by headius
August 1, 2009
Saturday, January 26, 13 7
16. History 2010
ruboto-core : GSoC 2010 by Daniel Jackoway
Version 0.0.3 released December 19, 2010
Saturday, January 26, 13 10
17. History 2011
Testing framework: Feb 13, Rename to just “ruboto”:
2011 (my first contribution) december 24, 2011
Bundler support: may 21,
2011
New Logo & Icons by
RedNifre: july 20, 2011
RubotoCore platform
package: august 2011
Saturday, January 26, 13 11
18. History 2011
Testing framework: Feb 13, Rename to just “ruboto”:
2011 (my first contribution) december 24, 2011
Bundler support: may 21,
2011
New Logo & Icons by
RedNifre: july 20, 2011
RubotoCore platform
package: august 2011
Saturday, January 26, 13 11
19. History 2012
Class oriented component definition, 2012
On-device generation of subclasses may 10,
2012
Subclassing of Java classes (next release)
Saturday, January 26, 13 12
20. History 2012
$activity.handle_create do |bundle|
setTitle ‘Hello World!’
setup_content do
linear_layout :orientation => LinearLayout::VERTICAL do
@text_view = text_view :text => 'What hath Matz wrought?'
button :text => ‘Click me!’, :width => :wrap_content, :id => 43
Class oriented component definition, 2012
end
end
handle_click do |view|
if view.id == 43
On-device generation of subclasses may 10,
@text_view.setText 'What hath Matz wrought!'
toast 'Flipped a bit via butterfly'
end
2012 end
end
Subclassing of Java classes (next release)
Saturday, January 26, 13 12
21. $activity.handle_create do |bundle|
History 2012
setTitle ‘Hello World!’
setup_content do
linear_layout :orientation => LinearLayout::VERTICAL do
@text_view = text_view :text => 'What hath Matz wrought?'
button :text => ‘Click me!’, :width => :wrap_content, :id => 43
end
end
handle_click do |view|
if view.id == 43 $activity.start_ruboto_activity do
@text_view.setText 'Whaton_create(bundle)
def hath Matz wrought!'
toast 'Flipped a bit via butterfly'
setTitle ‘Hello World!’
end
end click_handler = proc do |view|
end @text_view.setText 'What hath Matz wrought!'
toast 'Flipped a bit via butterfly'
Class oriented component definition, 2012
end
self.content_view =
linear_layout :orientation => LinearLayout::VERTICAL do
@text_view = text_view :text => 'What hath Matz wrought?'
On-device generation of subclasses may 10,
button :text => ‘Click me!, :width => :wrap_content,
end
:on_click_listener => click_handler
2012 end
end
Subclassing of Java classes (next release)
Saturday, January 26, 13 12
22. $activity.handle_create do |bundle|
$activity.start_ruboto_activity do
History 2012
setTitle ‘Hello World!’
def on_create(bundle)
setup_content do setTitle ‘Hello World!’
linear_layout :orientation => LinearLayout::VERTICAL do
click_handler = proc do |view|
@text_view = text_view :text => 'What hath Matz wrought?'
@text_view.setText 'What hath Matz wrought!'
button :text => ‘Click me!’, :width => :wrap_content, :id => 43
end toast 'Flipped a bit via butterfly'
end end
handle_click do |view| self.content_view =
if view.id == 43 class ImageButtonActivity linear_layout :orientation => LinearLayout::VERTICAL do
def on_create(bundle)
@text_view.setText 'What hath Matz wrought!' @text_view = text_view :text => 'What hath Matz wrought?'
super
toast 'Flipped a bit via butterfly' button :text => ‘Click me!, :width => :wrap_content,
end set_title ‘Hello World!’ :on_click_listener => click_handler
end end
end click_handler = proc do |view|
end
@text_view.setTextend
'What hath Matz wrought!'
toast 'Flipped a bit via butterfly'
Class oriented component definition, 2012
end
self.content_view =
linear_layout :orientation => :vertical do
On-device generation of subclasses may 10,
@text_view = text_view :text => 'What hath Matz wrought?'
button :text => ‘Click me!’, :width => :wrap_content, :id => 43,
:on_click_listener => click_handler
2012
end
end
end
Subclassing of Java classes (next release)
Saturday, January 26, 13 12
23. History 2012
Class oriented component definition, 2012
On-device generation of subclasses may 10,
2012
Subclassing of Java classes (next release)
Saturday, January 26, 13 13
24. History 2012
require 'ruboto/generate'
ruboto_generate("android.widget.ArrayAdapter" => $package_name + ".MyArrayAdapter")
adapter = MyArrayAdapter.new(self, android.R.layout.simple_list_item_1 , [...])
Class oriented component definition, 2012
adapter.initialize_ruboto_callbacks do
def get_view(position, convert_view, parent)
@inflater ||= context.getSystemService(Context::LAYOUT_INFLATER_SERVICE)
row = convert_view ? convert_view : @inflater.inflate(mResource, nil)
row.findViewById(mFieldId).text = get_item(position)
On-device generation of subclasses may 10,
row
end
end
2012
Subclassing of Java classes (next release)
Saturday, January 26, 13 13
25. require 'ruboto/generate'
History 2012
ruboto_generate("android.widget.ArrayAdapter" => $package_name + ".MyArrayAdapter")
adapter = MyArrayAdapter.new(self, android.R.layout.simple_list_item_1 , [...])
adapter.initialize_ruboto_callbacks do
def get_view(position, convert_view, parent)
@inflater ||= context.getSystemService(Context::LAYOUT_INFLATER_SERVICE)
row = convert_view ? convert_view : @inflater.inflate(mResource, nil)
row.findViewById(mFieldId).text = get_item(position)
row
end
end
class MyArrayAdapter < android.widget.ArrayAdapter
def get_view(position, convert_view, parent)
@inflater ||= context.getSystemService(Context::LAYOUT_INFLATER_SERVICE)
row = convert_view ? convert_view : @inflater.inflate(mResource, nil)
Class oriented component definition, 2012
row.findViewById(mFieldId).text = get_item(position)
row
end
end
On-device generation of subclasses may 10,
adapter = MyArrayAdapter.new(self, android.R.layout.simple_list_item_1, [...])
2012
Subclassing of Java classes (next release)
Saturday, January 26, 13 13