ruboto 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -1
- data/README.md +44 -43
- data/RELEASE_CANDICATE_DOC +10 -12
- data/RELEASE_DOC +69 -37
- data/Rakefile +47 -27
- data/assets/rakelib/ruboto.rake +69 -26
- data/assets/src/RubotoActivity.java +17 -4
- data/assets/src/RubotoService.java +18 -0
- data/assets/src/org/ruboto/EntryPointActivity.java +1 -1
- data/assets/src/org/ruboto/JRubyAdapter.java +3 -1
- data/assets/src/org/ruboto/ScriptLoader.java +27 -4
- data/assets/src/ruboto/activity.rb +4 -3
- data/assets/src/ruboto/activity/reload.rb +17 -12
- data/assets/src/ruboto/widget.rb +18 -18
- data/bin/elevate.exe +0 -0
- data/bin/elevate_32.exe +0 -0
- data/lib/java_class_gen/android_api.xml +1 -1
- data/lib/ruboto/commands/base.rb +3 -5
- data/lib/ruboto/util/build.rb +1 -1
- data/lib/ruboto/util/emulator.rb +31 -5
- data/lib/ruboto/util/setup.rb +183 -68
- data/lib/ruboto/util/update.rb +35 -42
- data/lib/ruboto/util/xml_element.rb +45 -33
- data/lib/ruboto/version.rb +1 -1
- data/test/activity/call_super_activity.rb +1 -1
- data/test/activity/dialog_fragment_activity.rb +37 -0
- data/test/activity/dialog_fragment_activity_test.rb +19 -0
- data/test/activity/image_button_activity.rb +2 -1
- data/test/activity/navigation_activity_test.rb +2 -1
- data/test/activity/no_on_create_activity.rb +17 -0
- data/test/activity/no_on_create_activity_test.rb +15 -0
- data/test/activity/spinner_activity.rb +51 -0
- data/test/activity/spinner_activity_test.rb +65 -0
- data/test/activity/stack_activity_test.rb +14 -7
- data/test/activity/startup_exception_activity.rb +7 -5
- data/test/activity/startup_exception_activity_test.rb +2 -2
- data/test/app_test_methods.rb +4 -0
- data/test/git_based_gem_test.rb +64 -0
- data/test/minimal_app_test.rb +12 -13
- data/test/rake_test.rb +1 -0
- data/test/ruboto_gen_test.rb +21 -15
- data/test/ruboto_update_test.rb +23 -6
- data/test/sqldroid_test.rb +0 -1
- data/test/test_helper.rb +37 -19
- metadata +25 -2
data/lib/ruboto/util/update.rb
CHANGED
@@ -353,6 +353,10 @@ module Ruboto
|
|
353
353
|
|
354
354
|
def update_core_classes(force = nil)
|
355
355
|
generate_core_classes(:class => 'all', :method_base => 'on', :method_include => '', :method_exclude => '', :force => force, :implements => '')
|
356
|
+
if File.exists?('ruboto.yml')
|
357
|
+
FileUtils.touch 'ruboto.yml'
|
358
|
+
system 'rake jruby_adapter'
|
359
|
+
end
|
356
360
|
end
|
357
361
|
|
358
362
|
def read_ruboto_version
|
@@ -407,7 +411,7 @@ module Ruboto
|
|
407
411
|
`jar -xf #{jruby_core}`
|
408
412
|
raise "Unpacking jruby-core jar failed: #$?" unless $? == 0
|
409
413
|
File.delete jruby_core
|
410
|
-
if Gem::Version.new(jruby_core_version) >= Gem::Version.new('
|
414
|
+
if Gem::Version.new(jruby_core_version) >= Gem::Version.new('9000.dev')
|
411
415
|
#noinspection RubyLiteralArrayInspection
|
412
416
|
excluded_core_packages = [
|
413
417
|
'**/*Darwin*',
|
@@ -439,7 +443,6 @@ module Ruboto
|
|
439
443
|
'jnr/posix/OpenBSD*',
|
440
444
|
'jnr/x86asm',
|
441
445
|
'org/jruby/ant',
|
442
|
-
'org/jruby/cext',
|
443
446
|
# 'org/jruby/compiler', # Needed for initialization, but should not be necessary
|
444
447
|
# 'org/jruby/compiler/impl', # Needed for initialization, but should not be necessary
|
445
448
|
'org/jruby/compiler/impl/BaseBodyCompiler*',
|
@@ -448,11 +451,7 @@ module Ruboto
|
|
448
451
|
'org/jruby/embed/bsf',
|
449
452
|
'org/jruby/embed/jsr223',
|
450
453
|
'org/jruby/embed/osgi',
|
451
|
-
# 'org/jruby/ext/
|
452
|
-
'org/jruby/ext/ffi/AbstractMemory*',
|
453
|
-
'org/jruby/ext/ffi/io',
|
454
|
-
'org/jruby/ext/ffi/jffi',
|
455
|
-
'org/jruby/ext/tracepoint',
|
454
|
+
# 'org/jruby/ext/tracepoint',
|
456
455
|
'org/jruby/javasupport/bsf',
|
457
456
|
# 'org/jruby/management', # should be excluded
|
458
457
|
# 'org/jruby/runtime/invokedynamic', # Should be excluded
|
@@ -460,6 +459,8 @@ module Ruboto
|
|
460
459
|
# 'org/jruby/runtime/opto/OptoFactory*', # What is this?
|
461
460
|
'org/yecht',
|
462
461
|
]
|
462
|
+
elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.5')
|
463
|
+
excluded_core_packages = %w(**/*Darwin* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius com/kenai/constantine com/kenai/jffi com/kenai/jnr/x86asm com/martiansoftware jni jnr/constants/platform/darwin jnr/constants/platform/fake jnr/constants/platform/freebsd jnr/constants/platform/openbsd jnr/constants/platform/sunos jnr/ffi/annotations jnr/ffi/byref jnr/ffi/mapper jnr/ffi/provider jnr/ffi/util jnr/ffi/Struct$* jnr/ffi/types jnr/posix/Aix* jnr/posix/FreeBSD* jnr/posix/MacOS* jnr/posix/OpenBSD* jnr/x86asm org/jruby/ant org/jruby/cext org/jruby/compiler/impl/BaseBodyCompiler* org/jruby/compiler/util org/jruby/demo org/jruby/embed/bsf org/jruby/embed/jsr223 org/jruby/embed/osgi org/jruby/ext/ffi/AbstractMemory* org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/ext/tracepoint org/jruby/javasupport/bsf org/yecht)
|
463
464
|
elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.4')
|
464
465
|
excluded_core_packages = %w(**/*Darwin* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius com/kenai/constantine com/kenai/jffi com/kenai/jnr/x86asm com/martiansoftware jline jni jnr/constants/platform/darwin jnr/constants/platform/fake jnr/constants/platform/freebsd jnr/constants/platform/openbsd jnr/constants/platform/sunos jnr/ffi/annotations jnr/ffi/byref jnr/ffi/mapper jnr/ffi/provider jnr/ffi/util jnr/ffi/Struct$* jnr/ffi/types jnr/posix/Aix* jnr/posix/FreeBSD* jnr/posix/MacOS* jnr/posix/OpenBSD* jnr/x86asm org/apache org/fusesource org/jruby/ant org/jruby/cext org/jruby/compiler/impl/BaseBodyCompiler* org/jruby/compiler/util org/jruby/demo org/jruby/embed/bsf org/jruby/embed/jsr223 org/jruby/embed/osgi org/jruby/ext/ffi/AbstractMemory* org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/ext/ripper org/jruby/ext/tracepoint org/jruby/javasupport/bsf org/yecht)
|
465
466
|
elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.3')
|
@@ -535,8 +536,8 @@ module Ruboto
|
|
535
536
|
# - Moves ruby stdlib to the root of the jruby-stdlib jar
|
536
537
|
def reconfigure_jruby_stdlib
|
537
538
|
min_sdk_version = verify_manifest.elements['uses-sdk'].attributes['android:minSdkVersion'].to_i
|
538
|
-
included_stdlibs = verify_ruboto_config[
|
539
|
-
excluded_stdlibs = [*verify_ruboto_config[
|
539
|
+
included_stdlibs = verify_ruboto_config['included_stdlibs']
|
540
|
+
excluded_stdlibs = [*verify_ruboto_config['excluded_stdlibs']].compact
|
540
541
|
Dir.chdir 'libs' do
|
541
542
|
jruby_stdlib = Dir['jruby-stdlib-*.jar'][-1]
|
542
543
|
log_action("Reformatting #{jruby_stdlib}") do
|
@@ -551,45 +552,37 @@ module Ruboto
|
|
551
552
|
FileUtils.move 'old/META-INF/jruby.home/lib', 'new/jruby.home/lib'
|
552
553
|
FileUtils.rm_rf 'new/jruby.home/lib/ruby/gems'
|
553
554
|
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
file = "#{d}.rb"
|
571
|
-
FileUtils.rm_rf file if File.exists? file
|
572
|
-
jarfile = "#{d}.jar"
|
573
|
-
FileUtils.rm_rf jarfile if File.exists? jarfile
|
574
|
-
print "#{d}..."
|
555
|
+
Dir.chdir 'new/jruby.home/lib/ruby' do
|
556
|
+
ruby_stdlib_versions = Dir['*'] - %w(gems)
|
557
|
+
if included_stdlibs
|
558
|
+
print 'excluded...'
|
559
|
+
ruby_stdlib_versions.each do |ld|
|
560
|
+
Dir.chdir ld do
|
561
|
+
libs = Dir['*'].map { |d| d.sub /\.(rb|jar)$/, '' }.uniq
|
562
|
+
libs.each do |d|
|
563
|
+
next if included_stdlibs.include? d
|
564
|
+
FileUtils.rm_rf d if File.exists? d
|
565
|
+
file = "#{d}.rb"
|
566
|
+
FileUtils.rm_rf file if File.exists? file
|
567
|
+
jarfile = "#{d}.jar"
|
568
|
+
FileUtils.rm_rf jarfile if File.exists? jarfile
|
569
|
+
print "#{d}..."
|
570
|
+
end
|
575
571
|
end
|
576
572
|
end
|
577
573
|
end
|
578
|
-
end
|
579
574
|
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
file = "#{dir}.rb"
|
589
|
-
FileUtils.rm_rf file if File.exists? file
|
575
|
+
if excluded_stdlibs.any?
|
576
|
+
ruby_stdlib_versions.each do |ld|
|
577
|
+
excluded_stdlibs.each do |d|
|
578
|
+
dir = "#{ld}/#{d}"
|
579
|
+
FileUtils.rm_rf dir if File.exists? dir
|
580
|
+
file = "#{dir}.rb"
|
581
|
+
FileUtils.rm_rf file if File.exists? file
|
582
|
+
end
|
590
583
|
end
|
584
|
+
print "excluded #{excluded_stdlibs.join(' ')}..."
|
591
585
|
end
|
592
|
-
print "excluded #{excluded_stdlibs.join(' ')}..."
|
593
586
|
end
|
594
587
|
|
595
588
|
Dir.chdir 'new' do
|
@@ -44,12 +44,12 @@ module Ruboto
|
|
44
44
|
def find_class_or_interface(klass, a_type)
|
45
45
|
abort "ERROR: Can't parse package from #{klass}" unless klass.match(/([a-z.]+)\.([A-Z][A-Za-z.]+)/)
|
46
46
|
|
47
|
-
package = self['package'].find{|i| i.attribute('name') == $1}
|
47
|
+
package = self['package'].find { |i| i.attribute('name') == $1 }
|
48
48
|
abort "ERROR: Can't find package #{$1}" unless package
|
49
49
|
if a_type == 'either'
|
50
|
-
package['class'].find{|i| i.attribute('name') == $2} or package['interface'].find{|i| i.attribute('name') == $2}
|
50
|
+
package['class'].find { |i| i.attribute('name') == $2 } or package['interface'].find { |i| i.attribute('name') == $2 }
|
51
51
|
else
|
52
|
-
package[a_type].find{|i| i.attribute('name') == $2}
|
52
|
+
package[a_type].find { |i| i.attribute('name') == $2 }
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -63,37 +63,37 @@ module Ruboto
|
|
63
63
|
|
64
64
|
def all_methods(method_base='all', method_include='', method_exclude='', implements='')
|
65
65
|
# get all the methogs
|
66
|
-
all_methods = get_elements('method').select{|m| m.attribute('static') != 'true'}
|
66
|
+
all_methods = get_elements('method').select { |m| m.attribute('static') != 'true' }
|
67
67
|
|
68
68
|
# establish the base set of methods
|
69
69
|
working_methods = case method_base.to_s
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
70
|
+
when 'all' then
|
71
|
+
all_methods
|
72
|
+
when 'none' then
|
73
|
+
[]
|
74
|
+
when 'abstract' then
|
75
|
+
all_methods.select { |i| i.attribute('abstract') == 'true' }
|
76
|
+
when 'on' then
|
77
|
+
all_methods.select { |i| i.attribute('name').match(/^on[A-Z]/) }
|
78
|
+
end
|
79
79
|
|
80
80
|
# make sure to include requested methods
|
81
81
|
include_methods = method_include.split(',') if method_include.is_a?(String)
|
82
|
-
all_methods.each{|i| working_methods << i if include_methods.include?(i.attribute('name'))}
|
82
|
+
all_methods.each { |i| working_methods << i if include_methods.include?(i.attribute('name')) }
|
83
83
|
|
84
84
|
# make sure to exclude rejected methods
|
85
85
|
exclude_methods = method_exclude.split(',') if method_exclude.is_a?(String)
|
86
|
-
working_methods = working_methods.select{|i| not exclude_methods.include?(i.attribute('name'))}
|
86
|
+
working_methods = working_methods.select { |i| not exclude_methods.include?(i.attribute('name')) }
|
87
87
|
|
88
88
|
# remove methods marked final
|
89
|
-
working_methods = working_methods.select{|i| (not i.attribute('final')) or i.attribute('final') == 'false'}
|
89
|
+
working_methods = working_methods.select { |i| (not i.attribute('final')) or i.attribute('final') == 'false' }
|
90
90
|
|
91
91
|
# get additional methods from parent
|
92
92
|
if name =='class' and attribute('extends')
|
93
93
|
parent = root.find_class(attribute('extends'))
|
94
94
|
parent_methods = parent.all_methods(method_base, method_include, method_exclude)
|
95
95
|
working_signatures = working_methods.map(&:method_signature)
|
96
|
-
working_methods += parent_methods.select{|i| not working_signatures.include?(i.method_signature)}
|
96
|
+
working_methods += parent_methods.select { |i| not working_signatures.include?(i.method_signature) }
|
97
97
|
end
|
98
98
|
|
99
99
|
# get additional methods from interfaces
|
@@ -102,7 +102,7 @@ module Ruboto
|
|
102
102
|
interface = root.find_interface(i)
|
103
103
|
abort("Unkown interface: #{i}") unless interface
|
104
104
|
working_signatures = working_methods.map(&:method_signature)
|
105
|
-
working_methods += interface.all_methods.select{|j| not working_signatures.include?(j.method_signature)}
|
105
|
+
working_methods += interface.all_methods.select { |j| not working_signatures.include?(j.method_signature) }
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
@@ -110,37 +110,40 @@ module Ruboto
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def parameters
|
113
|
-
get_elements('parameter').map {|p| [p.attribute('name'), p.attribute('type').gsub('<', '<').gsub('>', '>')]}
|
113
|
+
get_elements('parameter').map { |p| [p.attribute('name'), p.attribute('type').gsub('<', '<').gsub('>', '>')] }
|
114
114
|
end
|
115
115
|
|
116
116
|
def method_signature
|
117
|
-
"#{attribute('name')}(#{parameters.map{|i| i[1]}.join(',')})"
|
117
|
+
"#{attribute('name')}(#{parameters.map { |i| i[1] }.join(',')})"
|
118
118
|
end
|
119
119
|
|
120
120
|
def constant_string
|
121
|
-
'CB_' + attribute('name').gsub(/[A-Z]/) {|i| "_#{i}"}.upcase.gsub(/^ON_/, '')
|
121
|
+
'CB_' + attribute('name').gsub(/[A-Z]/) { |i| "_#{i}" }.upcase.gsub(/^ON_/, '')
|
122
122
|
end
|
123
123
|
|
124
124
|
def super_string
|
125
125
|
if attribute('api_added') and
|
126
|
-
|
127
|
-
|
126
|
+
attribute('api_added').to_i > verify_min_sdk.to_i and
|
127
|
+
attribute('api_added').to_i <= verify_target_sdk.to_i
|
128
128
|
nil
|
129
129
|
elsif attribute('abstract') == 'true'
|
130
130
|
nil
|
131
131
|
elsif name == 'method'
|
132
|
-
"super.#{attribute('name')}(#{parameters.map{|i| i[0]}.join(', ')});"
|
132
|
+
"super.#{attribute('name')}(#{parameters.map { |i| i[0] }.join(', ')});"
|
133
133
|
elsif name == 'constructor'
|
134
|
-
"super(#{parameters.map{|i| i[0]}.join(', ')});"
|
134
|
+
"super(#{parameters.map { |i| i[0] }.join(', ')});"
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
138
|
def default_return
|
139
139
|
return nil unless attribute('return')
|
140
140
|
case attribute('return')
|
141
|
-
when 'boolean' then
|
142
|
-
|
143
|
-
when '
|
141
|
+
when 'boolean' then
|
142
|
+
'return false;'
|
143
|
+
when 'int' then
|
144
|
+
'return 0;'
|
145
|
+
when 'void' then
|
146
|
+
nil
|
144
147
|
else
|
145
148
|
'return null;'
|
146
149
|
end
|
@@ -152,7 +155,7 @@ module Ruboto
|
|
152
155
|
rv ? "return #{rv}" : default_return
|
153
156
|
end
|
154
157
|
|
155
|
-
def ruby_call(
|
158
|
+
def ruby_call(snake_case = false)
|
156
159
|
params = parameters
|
157
160
|
args = ''
|
158
161
|
if params.size > 1
|
@@ -175,7 +178,7 @@ module Ruboto
|
|
175
178
|
convert_return = "#{return_class.sub(/<.*>$/, '')}.class, "
|
176
179
|
end
|
177
180
|
|
178
|
-
method_name =
|
181
|
+
method_name = snake_case ? snake_case_attribute : attribute('name')
|
179
182
|
["#{return_cast}JRubyAdapter.runRubyMethod(#{convert_return}scriptInfo.getRubyInstance(), \"#{method_name}\"#{args});"]
|
180
183
|
end
|
181
184
|
|
@@ -195,12 +198,21 @@ module Ruboto
|
|
195
198
|
'String rubyClassName = scriptInfo.getRubyClassName();',
|
196
199
|
"if (rubyClassName == null) #{super_return}",
|
197
200
|
if_else(
|
198
|
-
"(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(false).any?{|m| m.to_sym == :#{
|
201
|
+
"(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(false).any?{|m| m.to_sym == :#{attribute('name')}}\")",
|
199
202
|
ruby_call,
|
200
203
|
if_else(
|
201
|
-
"(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(false).any?{|m| m.to_sym == :#{
|
204
|
+
"(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(false).any?{|m| m.to_sym == :#{snake_case_attribute}}\")",
|
202
205
|
ruby_call(true),
|
203
|
-
|
206
|
+
if_else(
|
207
|
+
"(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(true).any?{|m| m.to_sym == :#{snake_case_attribute}}\")",
|
208
|
+
ruby_call(true),
|
209
|
+
# FIXME(uwe): Can the method be unimplemented? Is the Ruby instance always an instance of this class?
|
210
|
+
#if_else(
|
211
|
+
# "(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(true).any?{|m| m.to_sym == :#{attribute('name')}}\")",
|
212
|
+
ruby_call,
|
213
|
+
# [super_return]
|
214
|
+
#)
|
215
|
+
)
|
204
216
|
)
|
205
217
|
)
|
206
218
|
]
|
data/lib/ruboto/version.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'ruboto/widget'
|
2
|
+
|
3
|
+
ruboto_import_widgets :LinearLayout, :TextView
|
4
|
+
|
5
|
+
class DialogFragmentActivity
|
6
|
+
def onCreate(bundle)
|
7
|
+
super
|
8
|
+
set_title 'Dialog Fragment Test'
|
9
|
+
|
10
|
+
self.content_view =
|
11
|
+
linear_layout :orientation => :vertical, :gravity => :center do
|
12
|
+
text_view :id => 42, :text => title, :text_size => 48.0,
|
13
|
+
:gravity => :center
|
14
|
+
end
|
15
|
+
ft = getFragmentManager.beginTransaction
|
16
|
+
ft.addToBackStack(nil)
|
17
|
+
ExampleDialogFragment.new.show(ft, 'example_dialog')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class ExampleDialogFragment < android.app.DialogFragment
|
22
|
+
def onCreate(bundle)
|
23
|
+
super
|
24
|
+
@some_var = 'Ruboto does fragments!'
|
25
|
+
end
|
26
|
+
|
27
|
+
def onCreateView(inflater, container, bundle)
|
28
|
+
dialog.title = @some_var
|
29
|
+
|
30
|
+
linear_layout :orientation => :vertical do
|
31
|
+
linear_layout :gravity => :center, :layout => {:width= => :fill_parent} do
|
32
|
+
text_view :text => @some_var, :id => 43, :text_size => 40.0,
|
33
|
+
:gravity => :center
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
activity org.ruboto.test_app.DialogFragmentActivity
|
2
|
+
|
3
|
+
setup do |activity|
|
4
|
+
start = Time.now
|
5
|
+
loop do
|
6
|
+
@text_view = activity.findViewById(42)
|
7
|
+
wait_for_idle_sync
|
8
|
+
fragment = activity.fragment_manager.findFragmentByTag('example_dialog')
|
9
|
+
@fragment_text = fragment.view.findViewById(43) if fragment
|
10
|
+
break if (@text_view && @fragment_text) || (Time.now - start > 60)
|
11
|
+
sleep 1
|
12
|
+
end
|
13
|
+
assert @text_view && @fragment_text
|
14
|
+
end
|
15
|
+
|
16
|
+
test 'start fragment', :ui => false do |activity|
|
17
|
+
assert_equal 'Dialog Fragment Test', @text_view.text.to_s
|
18
|
+
assert_equal 'Ruboto does fragments!', @fragment_text.text.to_s
|
19
|
+
end
|
@@ -6,7 +6,8 @@ ruboto_import_widgets :ImageButton, :LinearLayout, :TextView
|
|
6
6
|
class ImageButtonActivity
|
7
7
|
def onCreate(bundle)
|
8
8
|
super
|
9
|
-
set_title File.basename(__FILE__).chomp('_activity.rb').split('_').
|
9
|
+
set_title File.basename(__FILE__).chomp('_activity.rb').split('_').
|
10
|
+
map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
10
11
|
|
11
12
|
click_handler = proc do |view|
|
12
13
|
@text_view.setText 'What hath Matz wrought!'
|
@@ -87,7 +87,8 @@ def start_activity_by_button(activity, button_id, activity_class_name = 'org.rub
|
|
87
87
|
btn.request_focus
|
88
88
|
btn.perform_click
|
89
89
|
end
|
90
|
-
|
90
|
+
waitForIdleSync
|
91
|
+
current_activity = wait_for_monitor_with_timeout(monitor, 10000)
|
91
92
|
ensure
|
92
93
|
removeMonitor(monitor)
|
93
94
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'ruboto/widget'
|
2
|
+
|
3
|
+
ruboto_import_widgets :LinearLayout, :TextView
|
4
|
+
|
5
|
+
class NoOnCreateActivity
|
6
|
+
def onResume
|
7
|
+
super
|
8
|
+
set_title File.basename(__FILE__).chomp('_activity.rb').split('_').
|
9
|
+
map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
10
|
+
|
11
|
+
self.content_view = linear_layout :orientation => :vertical,
|
12
|
+
:gravity => android.view.Gravity::CENTER do
|
13
|
+
text_view :id => 42, :text => title, :text_size => 48.0,
|
14
|
+
:gravity => android.view.Gravity::CENTER
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
activity org.ruboto.test_app.NoOnCreateActivity
|
2
|
+
|
3
|
+
setup do |activity|
|
4
|
+
start = Time.now
|
5
|
+
loop do
|
6
|
+
@text_view = activity.findViewById(42)
|
7
|
+
break if @text_view || (Time.now - start > 60)
|
8
|
+
sleep 1
|
9
|
+
end
|
10
|
+
assert @text_view
|
11
|
+
end
|
12
|
+
|
13
|
+
test('activity starts without onCreate implemented') do |activity|
|
14
|
+
assert_equal 'No On Create', @text_view.text.to_s
|
15
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'ruboto/widget'
|
2
|
+
|
3
|
+
ruboto_import_widgets :LinearLayout, :Spinner, :TextView
|
4
|
+
|
5
|
+
class SpinnerActivity
|
6
|
+
def onCreate(bundle)
|
7
|
+
super
|
8
|
+
set_title File.basename(__FILE__).chomp('_activity.rb').split('_').
|
9
|
+
map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
10
|
+
|
11
|
+
click_handler = proc do |parent, view, position, id|
|
12
|
+
@text_view.text = parent.adapter.get_item(position)
|
13
|
+
end
|
14
|
+
|
15
|
+
self.content_view =
|
16
|
+
linear_layout :orientation => :vertical, :gravity => :center_horizontal do
|
17
|
+
spinner :width => :match_parent, :id => 42
|
18
|
+
plain_spinner = spinner :width => :match_parent, :id => 43,
|
19
|
+
:on_item_selected_listener => click_handler
|
20
|
+
plain_spinner.adapter = android.widget.ArrayAdapter.new(self, R::layout::simple_spinner_item)
|
21
|
+
|
22
|
+
# FIXME(uwe): Simplify when we stop supporting Android < 4.0.3
|
23
|
+
if android.os.Build::VERSION::SDK_INT < 11
|
24
|
+
['Plain Spinner', 'Plain Item'].each do |i|
|
25
|
+
plain_spinner.adapter.add(i)
|
26
|
+
end
|
27
|
+
else
|
28
|
+
plain_spinner.adapter.add_all(['Plain Spinner', 'Plain Item'])
|
29
|
+
end
|
30
|
+
# EMXIF
|
31
|
+
|
32
|
+
spinner :width => :match_parent, :id => 44,
|
33
|
+
:on_item_selected_listener => click_handler,
|
34
|
+
:adapter => android.widget.ArrayAdapter.new(self, R::layout::simple_spinner_item, ['Adapter Spinner', 'Adapter Item'])
|
35
|
+
spinner :width => :match_parent, :id => 45 ,
|
36
|
+
:on_item_selected_listener => click_handler,
|
37
|
+
:list => ['List Spinner', 'List Item']
|
38
|
+
spinner :width => :match_parent, :id => 46 ,
|
39
|
+
:on_item_selected_listener => click_handler,
|
40
|
+
:list => ['List Spinner', 'List Item'],
|
41
|
+
:item_layout => R::layout::simple_spinner_dropdown_item
|
42
|
+
spinner :width => :match_parent, :id => 47 ,
|
43
|
+
:on_item_selected_listener => click_handler,
|
44
|
+
:list => ['List Spinner', 'List Item'],
|
45
|
+
:item_layout => R::layout::simple_spinner_dropdown_item,
|
46
|
+
:dropdown_layout => R::layout::simple_spinner_item
|
47
|
+
@text_view = text_view :text => 'Spinning?', :id => 69, :width => :match_parent,
|
48
|
+
:gravity => :center, :text_size => 48.0
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|