ruboto 0.10.2 → 0.11.0.rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/Gemfile +2 -4
  2. data/Gemfile.lock +12 -6
  3. data/README.md +2 -2
  4. data/assets/rakelib/ruboto.rake +165 -7
  5. data/assets/samples/sample_activity.rb +1 -1
  6. data/assets/samples/sample_activity_test.rb +2 -2
  7. data/assets/samples/sample_broadcast_receiver.rb +3 -3
  8. data/assets/samples/sample_broadcast_receiver_test.rb +1 -1
  9. data/assets/samples/sample_service.rb +2 -2
  10. data/assets/src/RubotoBroadcastReceiver.java +9 -0
  11. data/assets/src/org/ruboto/EntryPointActivity.java +3 -0
  12. data/assets/src/org/ruboto/JRubyAdapter.java +57 -23
  13. data/assets/src/org/ruboto/ScriptLoader.java +5 -2
  14. data/assets/src/ruboto/activity.rb +12 -13
  15. data/assets/src/ruboto/base.rb +2 -2
  16. data/assets/src/ruboto/broadcast_receiver.rb +1 -1
  17. data/assets/src/ruboto/package.rb +2 -2
  18. data/assets/src/ruboto/preference.rb +4 -4
  19. data/assets/src/ruboto/service.rb +9 -10
  20. data/assets/src/ruboto/util/stack.rb +10 -2
  21. data/assets/src/ruboto/widget.rb +5 -3
  22. data/lib/ruboto/sdk_versions.rb +1 -1
  23. data/lib/ruboto/util/update.rb +97 -52
  24. data/lib/ruboto/version.rb +1 -1
  25. data/lib/ruboto.rb +1 -1
  26. data/test/activity/image_button_activity.rb +1 -1
  27. data/test/activity/image_button_and_button_activity.rb +1 -1
  28. data/test/activity/json_activity.rb +1 -1
  29. data/test/activity/margins_activity.rb +1 -1
  30. data/test/activity/navigation_activity.rb +4 -4
  31. data/test/activity/navigation_target_activity.rb +1 -1
  32. data/test/activity/option_menu_activity.rb +2 -2
  33. data/test/activity/psych_activity.rb +1 -1
  34. data/test/activity/ruby_file_activity.rb +1 -1
  35. data/test/activity/stack_activity.rb +1 -1
  36. data/test/activity/startup_exception_activity.rb +31 -0
  37. data/test/activity/startup_exception_activity_test.rb +15 -0
  38. data/test/activity/subclass_activity.rb +2 -2
  39. data/test/activity/view_constants_activity.rb +1 -1
  40. data/test/app_test_methods.rb +1 -5
  41. data/test/broadcast_receiver_test.rb +4 -4
  42. data/test/minimal_app_test.rb +36 -8
  43. data/test/ruboto_gen_test.rb +5 -9
  44. data/test/service_test.rb +5 -5
  45. data/test/sqldroid_test.rb +1 -1
  46. data/test/test_helper.rb +13 -4
  47. metadata +67 -50
@@ -24,9 +24,17 @@ class Thread
24
24
  def self.with_large_stack(opts = {}, &block)
25
25
  opts = {:size => opts} if opts.is_a? Integer
26
26
  stack_size_kb = opts.delete(:size) || 64
27
- name = opts.delete(:name) || "Thread with large stack"
27
+ name = opts.delete(:name) || 'Thread with large stack'
28
28
  raise "Unknown option(s): #{opts.inspect}" unless opts.empty?
29
- t = java.lang.Thread.new(nil, block, name, stack_size_kb * 1024)
29
+ block_with_logging = proc do
30
+ begin
31
+ block.call
32
+ rescue Exception
33
+ STDERR.puts "Exception in #{name}: #{$!}\n#{$!.backtrace.join("\n")}"
34
+ raise
35
+ end
36
+ end
37
+ t = java.lang.Thread.new(nil, block_with_logging, name, stack_size_kb * 1024)
30
38
  t.start
31
39
  t
32
40
  end
@@ -75,7 +75,7 @@ end
75
75
  # Load ViewGroup constants
76
76
  #
77
77
 
78
- java_import "android.view.ViewGroup"
78
+ java_import 'android.view.ViewGroup'
79
79
  ViewGroup::LayoutParams.constants.each do |i|
80
80
  View.add_constant_conversion i.downcase.to_sym, ViewGroup::LayoutParams.const_get(i)
81
81
  end
@@ -84,7 +84,7 @@ end
84
84
  # Load Gravity constants
85
85
  #
86
86
 
87
- java_import "android.view.Gravity"
87
+ java_import 'android.view.Gravity'
88
88
  Gravity.constants.each do |i|
89
89
  View.add_constant_conversion i.downcase.to_sym, Gravity.const_get(i)
90
90
  end
@@ -97,7 +97,7 @@ def ruboto_import_widgets(*widgets)
97
97
  widgets.each { |i| ruboto_import_widget i }
98
98
  end
99
99
 
100
- def ruboto_import_widget(class_name, package_name="android.widget")
100
+ def ruboto_import_widget(class_name, package_name='android.widget')
101
101
  if class_name.is_a?(String) or class_name.is_a?(Symbol)
102
102
  klass = java_import("#{package_name}.#{class_name}") || eval("Java::#{package_name}.#{class_name}")
103
103
  else
@@ -165,6 +165,7 @@ def setup_image_button
165
165
  end
166
166
 
167
167
  def setup_list_view
168
+ Java::android.widget.ListView.__persistent__ = true
168
169
  Java::android.widget.ListView.class_eval do
169
170
  def configure(context, params = {})
170
171
  if list = params.delete(:list)
@@ -186,6 +187,7 @@ def setup_list_view
186
187
  end
187
188
 
188
189
  def setup_spinner
190
+ Java::android.widget.Spinner.__persistent__ = true
189
191
  Java::android.widget.Spinner.class_eval do
190
192
  attr_reader :adapter, :adapter_list
191
193
 
@@ -13,7 +13,7 @@ module Ruboto
13
13
  }
14
14
  MINIMUM_SUPPORTED_SDK_LEVEL = 7
15
15
  MINIMUM_SUPPORTED_SDK = "android-#{MINIMUM_SUPPORTED_SDK_LEVEL}"
16
- DEFAULT_TARGET_SDK_LEVEL = 8
16
+ DEFAULT_TARGET_SDK_LEVEL = 10
17
17
  DEFAULT_TARGET_SDK = "android-#{DEFAULT_TARGET_SDK_LEVEL}"
18
18
  if ENV['ANDROID_HOME']
19
19
  ANDROID_HOME = ENV['ANDROID_HOME']
@@ -36,7 +36,7 @@ module Ruboto
36
36
  puts "\nGenerating Android test project #{name} in #{root}..."
37
37
  system %Q{android create test-project -m "#{root.gsub('"', '\"')}" -n "#{name}Test" -p "#{root.gsub('"', '\"')}/test"}
38
38
  FileUtils.rm_rf File.join(root, 'test', 'src', verify_package.split('.'))
39
- puts "Done"
39
+ puts 'Done'
40
40
  end
41
41
 
42
42
  Dir.chdir File.join(root, 'test') do
@@ -67,7 +67,7 @@ module Ruboto
67
67
  # puts 'Added external permission tag'
68
68
  # end
69
69
 
70
- File.open("AndroidManifest.xml", 'w') { |f| REXML::Formatters::OrderedAttributes.new(4).write(test_manifest.document, f) }
70
+ File.open('AndroidManifest.xml', 'w') { |f| REXML::Formatters::OrderedAttributes.new(4).write(test_manifest.document, f) }
71
71
 
72
72
  run_tests_override = <<-EOF
73
73
  <!-- BEGIN added by Ruboto -->
@@ -120,14 +120,14 @@ module Ruboto
120
120
  # EMXIF
121
121
 
122
122
  ant_script.gsub!(/\s*<!-- BEGIN added by Ruboto -->.*?<!-- END added by Ruboto -->\s*/m, '')
123
- raise "Bad ANT script" unless ant_script.gsub!(/\s*(<\/project>)/, "\n\n#{run_tests_override}\n\n\\1")
123
+ raise 'Bad ANT script' unless ant_script.gsub!(/\s*(<\/project>)/, "\n\n#{run_tests_override}\n\n\\1")
124
124
  File.open('build.xml', 'w') { |f| f << ant_script }
125
125
  end
126
126
  end
127
127
 
128
128
  def update_jruby(force=nil, explicit = false)
129
- jruby_core = Dir.glob("libs/jruby-core-*.jar")[0]
130
- jruby_stdlib = Dir.glob("libs/jruby-stdlib-*.jar")[0]
129
+ jruby_core = Dir.glob('libs/jruby-core-*.jar')[0]
130
+ jruby_stdlib = Dir.glob('libs/jruby-stdlib-*.jar')[0]
131
131
 
132
132
  unless force
133
133
  if !jruby_core || !jruby_stdlib
@@ -145,7 +145,7 @@ module Ruboto
145
145
  new_jruby_version = JRubyJars::VERSION
146
146
 
147
147
  unless force
148
- current_jruby_version = jruby_core ? jruby_core[16..-5] : "None"
148
+ current_jruby_version = jruby_core ? jruby_core[16..-5] : 'None'
149
149
  if current_jruby_version == new_jruby_version
150
150
  puts "JRuby is up to date at version #{new_jruby_version}. Make sure you 'gem update jruby-jars' if there is a new version."
151
151
  return false
@@ -155,11 +155,11 @@ module Ruboto
155
155
  puts "New jruby version: #{new_jruby_version}"
156
156
  end
157
157
 
158
- copier = AssetCopier.new Ruboto::ASSETS, File.expand_path(".")
159
- log_action("Removing #{jruby_core}") { File.delete *Dir.glob("libs/jruby-core-*.jar") } if jruby_core
160
- log_action("Removing #{jruby_stdlib}") { File.delete *Dir.glob("libs/jruby-stdlib-*.jar") } if jruby_stdlib
161
- log_action("Copying #{JRubyJars::core_jar_path} to libs") { copier.copy_from_absolute_path JRubyJars::core_jar_path, "libs" }
162
- log_action("Copying #{JRubyJars::stdlib_jar_path} to libs") { copier.copy_from_absolute_path JRubyJars::stdlib_jar_path, "libs" }
158
+ copier = AssetCopier.new Ruboto::ASSETS, File.expand_path('.')
159
+ log_action("Removing #{jruby_core}") { File.delete *Dir.glob('libs/jruby-core-*.jar') } if jruby_core
160
+ log_action("Removing #{jruby_stdlib}") { File.delete *Dir.glob('libs/jruby-stdlib-*.jar') } if jruby_stdlib
161
+ log_action("Copying #{JRubyJars::core_jar_path} to libs") { copier.copy_from_absolute_path JRubyJars::core_jar_path, 'libs' }
162
+ log_action("Copying #{JRubyJars::stdlib_jar_path} to libs") { copier.copy_from_absolute_path JRubyJars::stdlib_jar_path, 'libs' }
163
163
 
164
164
  unless File.read('project.properties') =~ /^dex.force.jumbo=/
165
165
  log_action('Setting JUMBO dex file format') do
@@ -182,17 +182,17 @@ module Ruboto
182
182
  FileUtils.rm(Dir['libs/dexmaker*.jar'])
183
183
  # EMXIF
184
184
 
185
- jar_file = Dir.glob("libs/dx.jar")[0]
185
+ jar_file = Dir.glob('libs/dx.jar')[0]
186
186
 
187
187
  # FIXME(uwe): Remove when we stop updating from Ruboto 0.10.0 and older.
188
- jruby_present = !!Dir.glob("libs/jruby-core-*.jar")[0]
188
+ jruby_present = !!Dir.glob('libs/jruby-core-*.jar')[0]
189
189
  log_action("Removing #{jar_file}") { File.delete jar_file } if jar_file && !jruby_present
190
190
  # EMXIF
191
191
 
192
192
  return if !jar_file && !force
193
193
 
194
- copier = AssetCopier.new Ruboto::ASSETS, File.expand_path(".")
195
- log_action("Copying dx.jar to libs") { copier.copy 'libs' }
194
+ copier = AssetCopier.new Ruboto::ASSETS, File.expand_path('.')
195
+ log_action('Copying dx.jar to libs') { copier.copy 'libs' }
196
196
  end
197
197
 
198
198
  def update_assets
@@ -229,9 +229,9 @@ module Ruboto
229
229
 
230
230
  def update_classes(old_version, force = nil)
231
231
  copier = Ruboto::Util::AssetCopier.new Ruboto::ASSETS, '.'
232
- log_action("Ruboto java classes") { copier.copy "src/org/ruboto/*.java" }
233
- log_action("Ruboto java test classes") { copier.copy "src/org/ruboto/test/*.java", "test" }
234
- Dir["src/**/*.java"].each do |f|
232
+ log_action('Ruboto java classes') { copier.copy 'src/org/ruboto/*.java' }
233
+ log_action('Ruboto java test classes') { copier.copy 'src/org/ruboto/test/*.java', 'test' }
234
+ Dir['src/**/*.java'].each do |f|
235
235
  source_code = File.read(f)
236
236
  if source_code =~ /^\s*package\s+org.ruboto\s*;/
237
237
  next
@@ -241,7 +241,7 @@ module Ruboto
241
241
  generate_inheriting_file(class_name, subclass_name, verify_package)
242
242
 
243
243
  # FIXME(uwe): Remove when we stop supporting upgrading from ruboto 0.7.0 and ruboto 0.8.0
244
- if (old_version == '0.7.0' || old_version == '0.8.0')
244
+ if old_version == '0.7.0' || old_version == '0.8.0'
245
245
  puts "Ruboto version #{old_version.inspect} detected."
246
246
  script_file = File.expand_path("#{SCRIPTS_DIR}/#{underscore(subclass_name)}.rb")
247
247
  puts "Adding explicit super call in #{script_file}"
@@ -272,8 +272,8 @@ module Ruboto
272
272
  def update_manifest(min_sdk, target, force = false)
273
273
  log_action("\nAdding RubotoActivity, RubotoDialog, RubotoService, and SDK versions to the manifest") do
274
274
  if sdk_element = verify_manifest.elements['uses-sdk']
275
- min_sdk ||= sdk_element.attributes["android:minSdkVersion"]
276
- target ||= sdk_element.attributes["android:targetSdkVersion"]
275
+ min_sdk ||= sdk_element.attributes['android:minSdkVersion']
276
+ target ||= sdk_element.attributes['android:targetSdkVersion']
277
277
  else
278
278
  min_sdk ||= MINIMUM_SUPPORTED_SDK_LEVEL
279
279
  target ||= MINIMUM_SUPPORTED_SDK_LEVEL
@@ -295,30 +295,30 @@ module Ruboto
295
295
  app_element.attributes['android:largeHeap'] ||= 'true'
296
296
  end
297
297
 
298
- if !app_element.elements["activity[@android:name='org.ruboto.RubotoActivity']"]
299
- app_element.add_element 'activity', {"android:name" => "org.ruboto.RubotoActivity", 'android:exported' => 'false'}
298
+ unless app_element.elements["activity[@android:name='org.ruboto.RubotoActivity']"]
299
+ app_element.add_element 'activity', {'android:name' => 'org.ruboto.RubotoActivity', 'android:exported' => 'false'}
300
300
  end
301
301
 
302
- if !app_element.elements["activity[@android:name='org.ruboto.RubotoDialog']"]
303
- app_element.add_element 'activity', {"android:name" => "org.ruboto.RubotoDialog", 'android:exported' => 'false', "android:theme" => "@android:style/Theme.Dialog"}
302
+ unless app_element.elements["activity[@android:name='org.ruboto.RubotoDialog']"]
303
+ app_element.add_element 'activity', {'android:name' => 'org.ruboto.RubotoDialog', 'android:exported' => 'false', 'android:theme' => '@android:style/Theme.Dialog'}
304
304
  end
305
305
 
306
- if !app_element.elements["service[@android:name='org.ruboto.RubotoService']"]
307
- app_element.add_element 'service', {"android:name" => "org.ruboto.RubotoService", 'android:exported' => 'false'}
306
+ unless app_element.elements["service[@android:name='org.ruboto.RubotoService']"]
307
+ app_element.add_element 'service', {'android:name' => 'org.ruboto.RubotoService', 'android:exported' => 'false'}
308
308
  end
309
309
 
310
310
  if sdk_element
311
- sdk_element.attributes["android:minSdkVersion"] = min_sdk
312
- sdk_element.attributes["android:targetSdkVersion"] = target
311
+ sdk_element.attributes['android:minSdkVersion'] = min_sdk
312
+ sdk_element.attributes['android:targetSdkVersion'] = target
313
313
  else
314
- verify_manifest.add_element 'uses-sdk', {"android:minSdkVersion" => min_sdk, "android:targetSdkVersion" => target}
314
+ verify_manifest.add_element 'uses-sdk', {'android:minSdkVersion' => min_sdk, 'android:targetSdkVersion' => target}
315
315
  end
316
316
  save_manifest
317
317
  end
318
318
  end
319
319
 
320
320
  def update_core_classes(force = nil)
321
- generate_core_classes(:class => "all", :method_base => "on", :method_include => "", :method_exclude => "", :force => force, :implements => "")
321
+ generate_core_classes(:class => 'all', :method_base => 'on', :method_include => '', :method_exclude => '', :force => force, :implements => '')
322
322
  end
323
323
 
324
324
  def read_ruboto_version
@@ -327,13 +327,13 @@ module Ruboto
327
327
  end
328
328
 
329
329
  def update_ruboto(force=nil)
330
- log_action("Copying ruboto/version.rb") do
331
- from = File.expand_path(Ruboto::GEM_ROOT + "/lib/ruboto/version.rb")
330
+ log_action('Copying ruboto/version.rb') do
331
+ from = File.expand_path(Ruboto::GEM_ROOT + '/lib/ruboto/version.rb')
332
332
  to = File.expand_path("./#{SCRIPTS_DIR}/ruboto/version.rb")
333
333
  FileUtils.mkdir_p File.dirname(to)
334
334
  FileUtils.cp from, to
335
335
  end
336
- log_action("Copying additional ruboto script components") do
336
+ log_action('Copying additional ruboto script components') do
337
337
  Dir.glob(Ruboto::GEM_ROOT + "/assets/#{SCRIPTS_DIR}/ruboto/**/*.rb").each do |from|
338
338
  to = File.expand_path("./#{from.slice /#{SCRIPTS_DIR}\/ruboto\/.*\.rb/}")
339
339
  FileUtils.mkdir_p File.dirname(to)
@@ -357,14 +357,13 @@ module Ruboto
357
357
  FileUtils.rm_rf 'tmp'
358
358
  Dir.mkdir 'tmp'
359
359
  Dir.chdir 'tmp' do
360
- FileUtils.move "../#{jruby_core}", "."
360
+ FileUtils.move "../#{jruby_core}", '.'
361
361
  `jar -xf #{jruby_core}`
362
362
  raise "Unpacking jruby-core jar failed: #$?" unless $? == 0
363
363
  File.delete jruby_core
364
364
  if Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.3.dev')
365
365
  excluded_core_packages = [
366
366
  '**/*Darwin*',
367
- '**/*Ruby20*',
368
367
  '**/*Solaris*',
369
368
  '**/*windows*',
370
369
  '**/*Windows*',
@@ -375,8 +374,11 @@ module Ruboto
375
374
  'com/kenai/jnr/x86asm',
376
375
  'com/martiansoftware',
377
376
  'jline', 'jni',
378
- 'jnr/constants/platform/darwin', 'jnr/constants/platform/fake', 'jnr/constants/platform/freebsd',
379
- 'jnr/constants/platform/openbsd', 'jnr/constants/platform/sunos',
377
+ 'jnr/constants/platform/darwin',
378
+ 'jnr/constants/platform/fake',
379
+ 'jnr/constants/platform/freebsd',
380
+ 'jnr/constants/platform/openbsd',
381
+ 'jnr/constants/platform/sunos',
380
382
  'jnr/ffi/annotations',
381
383
  'jnr/ffi/byref',
382
384
  'jnr/ffi/provider',
@@ -572,20 +574,35 @@ module Ruboto
572
574
  #end
573
575
 
574
576
  # Add our proxy class factory
575
- `javac -source 1.6 -target 1.6 -cp .:#{Ruboto::ASSETS}/libs/dx.jar -bootclasspath #{Dir["#{Ruboto::SdkVersions::ANDROID_HOME}/platforms/android-*/android.jar"][0]} -d . #{Ruboto::GEM_ROOT}/lib/*.java`
576
- raise "Compile failed" unless $? == 0
577
+ android_jar = Dir["#{Ruboto::SdkVersions::ANDROID_HOME}/platforms/*/android.jar"][0]
578
+ unless android_jar
579
+ puts
580
+ puts '*' * 80
581
+ puts " Could not find any Android platforms in #{Ruboto::SdkVersions::ANDROID_HOME}/platforms."
582
+ puts ' At least one Android Platform SDK must be installed to compile the Ruboto classes.'
583
+ puts ' Please install an Android Platform SDK using the "android" package manager.'
584
+ puts '*' * 80
585
+ puts
586
+ exit 1
587
+ end
588
+ android_jar.gsub!(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)
589
+ class_path = ['.', "#{Ruboto::ASSETS}/libs/dx.jar"].join(File::PATH_SEPARATOR).gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)
590
+ sources = "#{Ruboto::GEM_ROOT}/lib/*.java".gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)
591
+ `javac -source 1.6 -target 1.6 -cp #{class_path} -bootclasspath #{android_jar} -d . #{sources}`
592
+ raise 'Compile failed' unless $? == 0
577
593
 
578
- `jar -cf ../#{jruby_core} .`
594
+ `jar -cf ..#{File::ALT_SEPARATOR || File::SEPARATOR}#{jruby_core} .`
579
595
  raise "Creating repackaged jruby-core jar failed: #$?" unless $? == 0
580
596
  end
581
- FileUtils.remove_dir "tmp", true
597
+ FileUtils.remove_dir 'tmp', true
582
598
  end
583
599
  end
584
600
  end
585
601
 
586
602
  # - Moves ruby stdlib to the root of the jruby-stdlib jar
587
603
  def reconfigure_jruby_stdlib
588
- min_sdk_version = verify_manifest.elements['uses-sdk'].attributes["android:minSdkVersion"].to_i
604
+ min_sdk_version = verify_manifest.elements['uses-sdk'].attributes['android:minSdkVersion'].to_i
605
+ included_stdlibs = verify_ruboto_config[:included_stdlibs]
589
606
  excluded_stdlibs = [*verify_ruboto_config[:excluded_stdlibs]].compact
590
607
  Dir.chdir 'libs' do
591
608
  jruby_stdlib = JRubyJars::stdlib_jar_path.split('/')[-1]
@@ -604,13 +621,41 @@ module Ruboto
604
621
  raise "Unrecognized JRuby stdlib jar: #{jruby_stdlib}" unless jruby_stdlib =~ /jruby-stdlib-(.*).jar/
605
622
  jruby_stdlib_version = Gem::Version.new($1)
606
623
 
624
+ if included_stdlibs
625
+
626
+ # TODO(uwe): Simplify when we stop supporting JRuby < 1.7.0
627
+ if jruby_stdlib_version < Gem::Version.new('1.7.0.preview1')
628
+ lib_dirs = %w(1.8 1.9 site_ruby/1.8 site_ruby/1.9 site_ruby/shared)
629
+ else
630
+ lib_dirs = %w(1.8 1.9 shared)
631
+ end
632
+ # ODOT
633
+
634
+ print 'excluded...'
635
+
636
+ lib_dirs.each do |ld|
637
+ Dir.chdir "new/jruby.home/lib/ruby/#{ld}" do
638
+ libs = Dir['*'].map{|d|d.sub /\.(rb|jar)$/, ''}.uniq
639
+ libs.each do |d|
640
+ next if included_stdlibs.include? d
641
+ FileUtils.rm_rf d if File.exists? d
642
+ file = "#{d}.rb"
643
+ FileUtils.rm_rf file if File.exists? file
644
+ jarfile = "#{d}.jar"
645
+ FileUtils.rm_rf jarfile if File.exists? jarfile
646
+ print "#{d}..."
647
+ end
648
+ end
649
+ end
650
+ end
651
+
607
652
  if excluded_stdlibs.any?
608
653
 
609
654
  # TODO(uwe): Simplify when we stop supporting JRuby < 1.7.0
610
655
  if jruby_stdlib_version < Gem::Version.new('1.7.0.preview1')
611
- lib_dirs = ['1.8', '1.9', 'site_ruby/1.8', 'site_ruby/1.9', 'site_ruby/shared']
656
+ lib_dirs = %w(1.8 1.9 site_ruby/1.8 site_ruby/1.9 site_ruby/shared)
612
657
  else
613
- lib_dirs = ['1.8', '1.9', 'shared']
658
+ lib_dirs = %w(1.8 1.9 shared)
614
659
  end
615
660
  # ODOT
616
661
 
@@ -708,22 +753,22 @@ module Ruboto
708
753
  FileUtils.rm_rf 'tmp'
709
754
  Dir.mkdir 'tmp'
710
755
  Dir.chdir 'tmp' do
711
- FileUtils.move "../#{dx_jar}", "."
756
+ FileUtils.move "../#{dx_jar}", '.'
712
757
  `jar -xf #{dx_jar}`
713
758
  raise "Unpacking dx.jar jar failed: #$?" unless $? == 0
714
759
  File.delete dx_jar
715
- excluded_core_packages = [
716
- 'com/android/dx/command',
717
- # 'com/android/dx/ssa', # Tests run OK without this package, but we may loose some optimizations.
718
- 'junit',
719
- ]
760
+ excluded_core_packages = [
761
+ 'com/android/dx/command',
762
+ # 'com/android/dx/ssa', # Tests run OK without this package, but we may loose some optimizations.
763
+ 'junit',
764
+ ]
720
765
  excluded_core_packages.each do |i|
721
766
  FileUtils.remove_dir(i, true) rescue puts "Failed to remove package: #{i} (#{$!})"
722
767
  end
723
768
  `jar -cf ../#{dx_jar} .`
724
769
  raise "Creating repackaged dx.jar failed: #$?" unless $? == 0
725
770
  end
726
- FileUtils.remove_dir "tmp", true
771
+ FileUtils.remove_dir 'tmp', true
727
772
  end
728
773
  end
729
774
  end
@@ -1,4 +1,4 @@
1
1
  module Ruboto
2
- VERSION = '0.10.2'
2
+ VERSION = '0.11.0.rc.0'
3
3
  UPDATE_VERSION_LIMIT = '0.7.0'
4
4
  end
data/lib/ruboto.rb CHANGED
@@ -10,5 +10,5 @@ require 'ruboto/util/main_fix'
10
10
 
11
11
  module Ruboto
12
12
  GEM_ROOT = File.dirname(File.dirname(__FILE__))
13
- ASSETS = File.join(GEM_ROOT, "assets")
13
+ ASSETS = File.join(GEM_ROOT, 'assets')
14
14
  end
@@ -4,7 +4,7 @@ require 'ruboto/widget'
4
4
  ruboto_import_widgets :ImageButton, :LinearLayout, :TextView
5
5
 
6
6
  class ImageButtonActivity
7
- def on_create(bundle)
7
+ def onCreate(bundle)
8
8
  super
9
9
  set_title File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
10
10
 
@@ -3,7 +3,7 @@ require 'ruboto/widget'
3
3
  ruboto_import_widgets :Button, :ImageButton, :LinearLayout, :TextView
4
4
 
5
5
  class ImageButtonAndButtonActivity
6
- def on_create(bundle)
6
+ def onCreate(bundle)
7
7
  super
8
8
  setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
9
9
 
@@ -1,5 +1,5 @@
1
1
  require 'ruboto/util/stack'
2
- with_large_stack { require 'json' }
2
+ require 'json'
3
3
  require 'ruboto/widget'
4
4
 
5
5
  ruboto_import_widgets :LinearLayout, :TextView
@@ -3,7 +3,7 @@ require 'ruboto/widget'
3
3
  ruboto_import_widgets :LinearLayout, :TextView
4
4
 
5
5
  class MarginsActivity
6
- def on_create(bundle)
6
+ def onCreate(bundle)
7
7
  super
8
8
  setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
9
9
 
@@ -4,7 +4,7 @@ require 'ruboto/widget'
4
4
  ruboto_import_widgets :Button, :LinearLayout, :TextView
5
5
 
6
6
  class NavigationActivity
7
- def on_create(bundle)
7
+ def onCreate(bundle)
8
8
  super
9
9
  set_title File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
10
10
 
@@ -51,7 +51,7 @@ class NavigationActivity
51
51
 
52
52
  def start_inline_activity
53
53
  start_ruboto_activity do
54
- def on_create(bundle)
54
+ def onCreate(bundle)
55
55
  super
56
56
  set_title 'Inline Activity'
57
57
  self.content_view =
@@ -65,7 +65,7 @@ class NavigationActivity
65
65
 
66
66
  def start_inline_activity_with_options
67
67
  start_ruboto_activity(:class_name => 'InlineActivity') do
68
- def on_create(bundle)
68
+ def onCreate(bundle)
69
69
  super
70
70
  set_title 'Inline Activity'
71
71
  self.content_view =
@@ -104,7 +104,7 @@ class NavigationActivity
104
104
  end
105
105
 
106
106
  class InfileActivity
107
- def on_create(bundle)
107
+ def onCreate(bundle)
108
108
  super
109
109
  set_title 'Infile Activity'
110
110
  self.content_view =
@@ -1,5 +1,5 @@
1
1
  class NavigationTargetActivity
2
- def on_create(bundle)
2
+ def onCreate(bundle)
3
3
  super
4
4
  set_title 'Navigation Target Activity'
5
5
 
@@ -4,7 +4,7 @@ require 'ruboto/util/toast'
4
4
  ruboto_import_widgets :LinearLayout, :TextView
5
5
 
6
6
  class OptionMenuActivity
7
- def on_create(bundle)
7
+ def onCreate(bundle)
8
8
  super
9
9
  set_title File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
10
10
 
@@ -15,7 +15,7 @@ class OptionMenuActivity
15
15
  end
16
16
  end
17
17
 
18
- def on_create_options_menu(menu)
18
+ def onCreateOptionsMenu(menu)
19
19
  mi = menu.add('Test')
20
20
  # mi.icon = $package.R::drawable::get_ruboto_core
21
21
  mi.setIcon($package.R::drawable::get_ruboto_core)
@@ -25,7 +25,7 @@ require 'ruboto/widget'
25
25
  ruboto_import_widgets :LinearLayout, :TextView
26
26
 
27
27
  class PsychActivity
28
- def on_create(bundle)
28
+ def onCreate(bundle)
29
29
  super
30
30
  set_title File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
31
31
  self.content_view =
@@ -1,5 +1,5 @@
1
1
  class RubyFileActivity
2
- def on_create(bundle)
2
+ def onCreate(bundle)
3
3
  super
4
4
  set_title 'Ruby file Activity'
5
5
 
@@ -8,7 +8,7 @@ ruboto_import_widgets :Button, :LinearLayout, :TextView
8
8
 
9
9
  class StackActivity
10
10
  STACK_DEPTH_CLASS = java.lang.Thread.current_thread.stack_trace.length.to_s
11
- def on_create(bundle)
11
+ def onCreate(bundle)
12
12
  stack_depth_on_create = java.lang.Thread.current_thread.stack_trace.length.to_s
13
13
  super
14
14
  setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
@@ -0,0 +1,31 @@
1
+ require 'ruboto/widget'
2
+
3
+ ruboto_import_widgets :LinearLayout, :TextView
4
+
5
+ class StartupExceptionActivity
6
+ def onCreate(bundle)
7
+ super
8
+ setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
9
+
10
+ self.content_view =
11
+ linear_layout :orientation => :vertical, :gravity => android.view.Gravity::CENTER do
12
+ @text_view = text_view :id => 42, :text => title, :text_size => 48.0, :gravity => android.view.Gravity::CENTER
13
+ end
14
+ intent = android.content.Intent.new
15
+ intent.setClassName($package_name, 'com.example.android.lunarlander.LunarLander')
16
+ startActivity(intent)
17
+ rescue Exception
18
+ puts "************************ Exception creating activity: #{$!}"
19
+ puts $!.backtrace.join("\n")
20
+ end
21
+
22
+ def onResume
23
+ super
24
+ @text_view.text = 'Startup OK'
25
+ end
26
+
27
+ def onPause
28
+ super
29
+ @text_view.text = 'Paused'
30
+ end
31
+ end
@@ -0,0 +1,15 @@
1
+ activity org.ruboto.test_app.StartupExceptionActivity
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('super called correctly') do |activity|
14
+ assert_equal 'Startup OK', activity.find_view_by_id(42).text.to_s
15
+ end
@@ -4,7 +4,7 @@ ruboto_import_widgets :LinearLayout, :ListView, :TextView
4
4
 
5
5
  class SubclassOfArrayAdapter < Java::AndroidWidget::ArrayAdapter
6
6
  def getView(position, convert_view, parent)
7
- puts "IN get_view!!!"
7
+ puts 'IN get_view!!!'
8
8
  @inflater ||= context.getSystemService(Context::LAYOUT_INFLATER_SERVICE)
9
9
  row = convert_view ? convert_view : @inflater.inflate(mResource, nil)
10
10
  row.findViewById(mFieldId).text = "[#{get_item(position)}]"
@@ -21,7 +21,7 @@ class Java::AndroidWidget::ArrayAdapter
21
21
  end
22
22
 
23
23
  class SubclassActivity
24
- def on_create(bundle)
24
+ def onCreate(bundle)
25
25
  super
26
26
  setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
27
27
 
@@ -3,7 +3,7 @@ require 'ruboto/widget'
3
3
  ruboto_import_widgets :Button, :LinearLayout, :TextView
4
4
 
5
5
  class ViewConstantsActivity
6
- def on_create(bundle)
6
+ def onCreate(bundle)
7
7
  super
8
8
  $ruboto_test_app_activity = self
9
9
  setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
@@ -13,7 +13,7 @@ module AppTestMethods
13
13
  assert_code 'Base64Loads', "require 'base64'"
14
14
 
15
15
  # FIXME(uwe): We should try using YAML as well
16
- assert_code 'YamlLoads', "require 'ruboto/util/stack' ; with_large_stack{require 'yaml'}"
16
+ assert_code 'YamlLoads', "require 'yaml'"
17
17
 
18
18
  assert_code 'ReadSourceFile', 'File.read(__FILE__)'
19
19
  assert_code 'DirListsFilesInApk', 'Dir["#{File.dirname(__FILE__)}/*"].each{|f| raise "File #{f.inspect} not found" unless File.exists?(f)}'
@@ -41,10 +41,6 @@ module AppTestMethods
41
41
  next if file =~ /subclass/ && (RUBOTO_PLATFORM == 'CURRENT' || JRUBY_JARS_VERSION < Gem::Version.new('1.7.1.dev'))
42
42
  # EMXIF
43
43
 
44
- # FIXME(uwe): Remove when we stop testing RubotoCore <= 0.5.2 and android-10
45
- next if file =~ /json/ && (RUBOTO_PLATFORM == 'CURRENT' || ANDROID_OS <= 10)
46
- # EMXIF
47
-
48
44
  # FIXME(uwe): Remove when we include jopenssl and bouncycastle
49
45
  next if file =~ /ssl/
50
46
  # EMXIF