ruboto 0.9.0 → 0.10.0.rc.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.
Files changed (71) hide show
  1. data/README.md +13 -13
  2. data/Rakefile +4 -4
  3. data/assets/rakelib/ruboto.rake +8 -4
  4. data/assets/samples/sample_broadcast_receiver.rb +0 -8
  5. data/assets/src/InheritingBroadcastReceiver.java +0 -19
  6. data/assets/src/InheritingClass.java +1 -8
  7. data/assets/src/RubotoActivity.java +1 -20
  8. data/assets/src/RubotoBroadcastReceiver.java +15 -25
  9. data/assets/src/RubotoService.java +1 -15
  10. data/assets/src/org/ruboto/EntryPointActivity.java +0 -1
  11. data/assets/src/org/ruboto/JRubyAdapter.java +9 -8
  12. data/assets/src/org/ruboto/RubotoComponent.java +0 -3
  13. data/assets/src/org/ruboto/Script.java +9 -9
  14. data/assets/src/org/ruboto/ScriptInfo.java +0 -15
  15. data/assets/src/org/ruboto/ScriptLoader.java +31 -43
  16. data/assets/src/ruboto/activity.rb +16 -41
  17. data/assets/src/ruboto/base.rb +0 -70
  18. data/assets/src/ruboto/broadcast_receiver.rb +2 -22
  19. data/assets/src/ruboto/package.rb +0 -1
  20. data/assets/src/ruboto/preference.rb +7 -3
  21. data/assets/src/ruboto/service.rb +14 -51
  22. data/assets/src/ruboto/widget.rb +2 -2
  23. data/lib/DexClient.java +10 -3
  24. data/lib/ruboto/util/build.rb +0 -5
  25. data/lib/ruboto/util/code_formatting.rb +1 -1
  26. data/lib/ruboto/util/update.rb +69 -50
  27. data/lib/ruboto/util/verify.rb +6 -5
  28. data/lib/ruboto/util/xml_element.rb +16 -29
  29. data/lib/ruboto/version.rb +2 -2
  30. data/test/activity/mytest_activity.rb +56 -0
  31. data/test/activity/mytest_activity_test.rb +52 -0
  32. data/test/activity/mytest_otherfile_activity.rb +12 -0
  33. data/test/activity/navigation_activity.rb +1 -1
  34. data/test/activity/subclass_activity.rb +10 -5
  35. data/test/activity/subclass_activity_test.rb +17 -2
  36. data/test/activity/view_constants_activity.rb +42 -0
  37. data/test/activity/view_constants_activity_test.rb +30 -0
  38. data/test/app_test_methods.rb +31 -26
  39. data/test/broadcast_receiver_test.rb +3 -1
  40. data/test/ruboto_gen_test.rb +4 -4
  41. data/test/test_helper.rb +5 -2
  42. metadata +18 -38
  43. data/assets/src/ruboto.rb +0 -25
  44. data/assets/src/ruboto/legacy.rb +0 -220
  45. data/assets/src/ruboto/menu.rb +0 -88
  46. data/lib/java_class_gen/InheritingClass.java.erb +0 -10
  47. data/test/block_def_activity/image_button_activity.rb +0 -23
  48. data/test/block_def_activity/image_button_activity_test.rb +0 -21
  49. data/test/block_def_activity/image_button_and_button_activity.rb +0 -20
  50. data/test/block_def_activity/image_button_and_button_activity_test.rb +0 -27
  51. data/test/block_def_activity/margins_activity.rb +0 -18
  52. data/test/block_def_activity/margins_activity_test.rb +0 -25
  53. data/test/block_def_activity/option_menu_activity.rb +0 -26
  54. data/test/block_def_activity/option_menu_activity_test.rb +0 -17
  55. data/test/block_def_activity/psych_activity.rb +0 -35
  56. data/test/block_def_activity/psych_activity_test.rb +0 -16
  57. data/test/block_def_activity/stack_activity.rb +0 -25
  58. data/test/block_def_activity/stack_activity_test.rb +0 -39
  59. data/test/handle_activity/image_button_activity.rb +0 -21
  60. data/test/handle_activity/image_button_activity_test.rb +0 -21
  61. data/test/handle_activity/image_button_and_button_activity.rb +0 -24
  62. data/test/handle_activity/image_button_and_button_activity_test.rb +0 -27
  63. data/test/handle_activity/margins_activity.rb +0 -15
  64. data/test/handle_activity/margins_activity_test.rb +0 -25
  65. data/test/handle_activity/option_menu_activity.rb +0 -25
  66. data/test/handle_activity/option_menu_activity_test.rb +0 -20
  67. data/test/handle_activity/psych_activity.rb +0 -31
  68. data/test/handle_activity/psych_activity_test.rb +0 -16
  69. data/test/handle_activity/stack_activity.rb +0 -24
  70. data/test/handle_activity/stack_activity_test.rb +0 -47
  71. data/test/view_constants_test.rb +0 -103
@@ -90,10 +90,10 @@ end
90
90
 
91
91
  def ruboto_import_widget(class_name, package_name="android.widget")
92
92
  if class_name.is_a?(String) or class_name.is_a?(Symbol)
93
- klass = ruboto_import("#{package_name}.#{class_name}") || eval("Java::#{package_name}.#{class_name}")
93
+ klass = java_import("#{package_name}.#{class_name}") || eval("Java::#{package_name}.#{class_name}")
94
94
  else
95
95
  klass = class_name
96
- ruboto_import klass
96
+ java_import klass
97
97
  class_name = klass.java_class.name.split('.')[-1]
98
98
  end
99
99
 
data/lib/DexClient.java CHANGED
@@ -4,6 +4,8 @@ import java.io.ByteArrayOutputStream;
4
4
  import java.io.OutputStreamWriter;
5
5
 
6
6
  import com.android.dx.cf.iface.ParseException;
7
+ // import com.android.dx.dex.DexFormat;
8
+ // import com.android.dx.dex.DexOptions;
7
9
  import com.android.dx.dex.cf.CfOptions;
8
10
  import com.android.dx.dex.cf.CfTranslator;
9
11
  import com.android.dx.dex.code.PositionList;
@@ -13,11 +15,15 @@ import com.android.dx.dex.file.DexFile;
13
15
  public class DexClient {
14
16
  /** {@code non-null;} output file in-progress */
15
17
  private static DexFile outputDex;
16
-
18
+ // private static DexOptions dexOptions = new DexOptions();
19
+ // static {
20
+ // dexOptions.targetApiLevel = DexFormat.API_NO_EXTENDED_OPCODES;
21
+ // }
17
22
  private final CfOptions cfOptions;
18
23
 
19
24
  public DexClient() {
20
25
  outputDex = new DexFile();
26
+ // outputDex = new DexFile(dexOptions);
21
27
  cfOptions = new CfOptions();
22
28
 
23
29
  cfOptions.positionInfo = PositionList.LINES;
@@ -51,8 +57,9 @@ public class DexClient {
51
57
  */
52
58
  private boolean processClass(String name, byte[] bytes) {
53
59
  try {
54
- ClassDefItem clazz =
55
- CfTranslator.translate(name, bytes, cfOptions);
60
+ ClassDefItem clazz;
61
+ clazz = CfTranslator.translate(name, bytes, cfOptions);
62
+ // clazz = CfTranslator.translate(name, bytes, cfOptions, dexOptions);
56
63
  outputDex.add(clazz);
57
64
  return true;
58
65
  } catch (ParseException ex) {
@@ -112,9 +112,6 @@ module Ruboto
112
112
  methods = check_methods(methods, params[:force])
113
113
  puts "Done. Methods created: #{methods.count}"
114
114
 
115
- # Remove any duplicate constants (use *args handle multiple parameter lists)
116
- constants = methods.map(&:constant_string).uniq
117
-
118
115
  params[:implements] = params[:implements].split(",").push('org.ruboto.RubotoComponent').join(",")
119
116
 
120
117
  action = class_desc.name == "class" ? "extends" : "implements"
@@ -125,8 +122,6 @@ module Ruboto
125
122
  "THE_ANDROID_CLASS" => (params[:class] || params[:interface]) +
126
123
  (params[:implements] == "" ? "" : ((action != 'implements' ? " implements " : ', ') + params[:implements].split(",").join(", "))),
127
124
  "THE_RUBOTO_CLASS" => params[:name],
128
- "THE_CONSTANTS" => constants.map { |i| "public static final int #{i} = #{constants.index(i)};" }.indent.join("\n"),
129
- "CONSTANTS_COUNT" => methods.count.to_s,
130
125
  "THE_CONSTRUCTORS" => class_desc.name == "class" ?
131
126
  class_desc.get_elements("constructor").map { |i| i.constructor_definition(params[:name]) }.join("\n\n") : "",
132
127
  "THE_METHODS" => methods.map { |i| i.method_definition(params[:name]) }.join("\n\n")
@@ -10,7 +10,7 @@ module Ruboto
10
10
  body_clause.indent, "}"]
11
11
  end
12
12
 
13
- def if_else(condition, if_clause, else_clause)
13
+ def if_else(condition, if_clause, else_clause = [])
14
14
  ["if (#{condition}) {", if_clause.indent, else_clause.compact.empty? ? nil : "} else {", else_clause.indent, "}"]
15
15
  end
16
16
 
@@ -10,7 +10,6 @@ module Ruboto
10
10
  #
11
11
  # Updating components
12
12
  #
13
-
14
13
  def update_android
15
14
  root = Dir.getwd
16
15
  build_xml_file = "#{root}/build.xml"
@@ -122,15 +121,6 @@ module Ruboto
122
121
  ant_script.gsub!(/\s*<!-- BEGIN added by Ruboto -->.*?<!-- END added by Ruboto -->\s*/m, '')
123
122
  raise "Bad ANT script" unless ant_script.gsub!(/\s*(<\/project>)/, "\n\n#{run_tests_override}\n\n\\1")
124
123
  File.open('build.xml', 'w') { |f| f << ant_script }
125
-
126
- # FIXME(uwe): Remove when we stop supporting update from Ruboto < 0.5.3
127
- if File.directory? 'assets/scripts'
128
- log_action 'Moving test scripts to the "src" directory.' do
129
- FileUtils.mv Dir['assets/scripts/*'], 'src'
130
- FileUtils.rm_rf 'assets/scripts'
131
- end
132
- end
133
- # EMXIF
134
124
  end
135
125
  end
136
126
 
@@ -172,7 +162,10 @@ module Ruboto
172
162
 
173
163
  # FIXME(uwe): Try keeping the class count low to enable installation on Android 2.3 devices
174
164
  # unless new_jruby_version =~ /^1.7.0/ && verify_target_sdk < 15
175
- log_action("Copying dx.jar to libs") { copier.copy 'libs' }
165
+ log_action("Copying dx.jar to libs") do
166
+ copier.copy 'libs'
167
+ # File.open('project.properties', 'a'){|f| f << "dex.force.jumbo=true\n"}
168
+ end
176
169
  # end
177
170
 
178
171
  reconfigure_jruby_libs(new_jruby_version)
@@ -205,13 +198,6 @@ module Ruboto
205
198
 
206
199
  def update_assets
207
200
  puts "\nCopying files:"
208
-
209
- # FIXME(uwe): Remove when we stop supporting updating from Ruboto < 0.6.0
210
- if File.exists?('Rakefile') && !File.exists?('rakelib/ruboto.rake')
211
- FileUtils.rm 'Rakefile'
212
- end
213
- # EMXIF
214
-
215
201
  weak_copier = Ruboto::Util::AssetCopier.new Ruboto::ASSETS, '.', false
216
202
  %w{.gitignore Rakefile}.each { |f| log_action(f) { weak_copier.copy f } }
217
203
 
@@ -333,11 +319,6 @@ module Ruboto
333
319
  end
334
320
 
335
321
  def update_core_classes(force = nil)
336
- # FIXME(uwe): Remove when we stop supporting updating from Ruboto 0.5.5 and older.
337
- FileUtils.rm_rf 'src/org/ruboto/callbacks'
338
- FileUtils.rm_f 'src/org/ruboto/RubotoView.java'
339
- # EMXIF
340
-
341
322
  generate_core_classes(:class => "all", :method_base => "on", :method_include => "", :method_exclude => "", :force => force, :implements => "")
342
323
  end
343
324
 
@@ -347,11 +328,6 @@ module Ruboto
347
328
  end
348
329
 
349
330
  def update_ruboto(force=nil)
350
- log_action("Copying ruboto.rb") do
351
- from = File.expand_path(Ruboto::GEM_ROOT + "/assets/#{SCRIPTS_DIR}/ruboto.rb")
352
- to = File.expand_path("./#{SCRIPTS_DIR}/ruboto.rb")
353
- FileUtils.cp from, to
354
- end
355
331
  log_action("Copying ruboto/version.rb") do
356
332
  from = File.expand_path(Ruboto::GEM_ROOT + "/lib/ruboto/version.rb")
357
333
  to = File.expand_path("./#{SCRIPTS_DIR}/ruboto/version.rb")
@@ -370,6 +346,7 @@ module Ruboto
370
346
  def reconfigure_jruby_libs(jruby_core_version)
371
347
  reconfigure_jruby_core(jruby_core_version)
372
348
  reconfigure_jruby_stdlib
349
+ reconfigure_dx_jar
373
350
  end
374
351
 
375
352
  # - Removes unneeded code from jruby-core
@@ -383,20 +360,33 @@ module Ruboto
383
360
  Dir.chdir 'tmp' do
384
361
  FileUtils.move "../#{jruby_core}", "."
385
362
  `jar -xf #{jruby_core}`
363
+ raise "Unpacking jruby-core jar failed: #$?" unless $? == 0
386
364
  File.delete jruby_core
387
365
  if jruby_core_version >= '1.7.0'
388
366
  excluded_core_packages = [
367
+ '**/*Darwin*',
368
+ '**/*Solaris*',
369
+ '**/*windows*',
370
+ '**/*Windows*',
389
371
  'META-INF', 'cext',
390
372
  'com/headius', # included since we are trying to use DexClient
391
373
  'com/headius/invokebinder',
392
- 'com/kenai/constantine', 'com/kenai/jffi', 'com/martiansoftware', 'ext', 'java',
374
+ 'com/kenai/constantine', 'com/kenai/jffi', 'com/martiansoftware',
375
+ 'ext',
376
+ 'java',
393
377
  'jline', 'jni',
394
378
  'jnr/constants/platform/darwin', 'jnr/constants/platform/fake', 'jnr/constants/platform/freebsd',
395
379
  'jnr/constants/platform/openbsd', 'jnr/constants/platform/sunos', 'jnr/constants/platform/windows',
396
- 'jnr/ffi/annotations', 'jnr/ffi/byref', 'jnr/ffi/provider', 'jnr/ffi/util',
380
+ 'jnr/ffi/annotations', 'jnr/ffi/byref',
381
+ 'jnr/ffi/provider', 'jnr/ffi/util',
397
382
  'jnr/ffi/posix/util',
383
+ 'jnr/ffi/Struct$*',
384
+ 'jnr/ffi/types',
385
+ 'jnr/posix/MacOS*',
386
+ 'jnr/posix/OpenBSD*',
398
387
  'org/apache',
399
388
  'org/bouncycastle', # TODO(uwe): Issue #154 Add back when we add jruby-openssl. The bouncycastle included in Android is cripled.
389
+ 'org/fusesource',
400
390
  'org/jruby/ant',
401
391
  'org/jruby/cext',
402
392
  # 'org/jruby/compiler', # Needed for initialization, but shoud not be necessary
@@ -410,23 +400,13 @@ module Ruboto
410
400
  'org/jruby/ext/ffi/io',
411
401
  'org/jruby/ext/ffi/jffi',
412
402
  'org/jruby/ext/openssl', # TODO(uwe): Issue #154 Add back when we add jruby-openssl.
413
-
414
- # FIXME(uwe): IR is the future. We should try using it.
415
- # 'org/jruby/ir',
416
- 'org/jruby/ir/dataflow',
417
- # 'org/jruby/ir/instructions',
418
- # 'org/jruby/ir/interpreter',
419
- # 'org/jruby/ir/operands',
420
- # 'org/jruby/ir/passes',
421
- 'org/jruby/ir/representations',
422
- 'org/jruby/ir/targets',
423
- 'org/jruby/ir/transformations',
424
- 'org/jruby/ir/util',
425
-
426
403
  'org/jruby/javasupport/bsf',
427
- # 'org/jruby/runtime/invokedynamic', # Should be excluded
428
404
 
429
405
  # 'org/jruby/management', # should be excluded
406
+
407
+ 'org/jruby/org/bouncycastle', # TODO(uwe): Issue #154 Add back when we add jruby-openssl. The bouncycastle included in Android is cripled.
408
+
409
+ # 'org/jruby/runtime/invokedynamic', # Should be excluded
430
410
  ]
431
411
 
432
412
  # TODO(uwe): Remove when we stop supporting jruby-jars < 1.7.0
@@ -452,17 +432,25 @@ module Ruboto
452
432
  end
453
433
 
454
434
  excluded_core_packages.each do |i|
455
- FileUtils.remove_dir(i, true) rescue puts "Failed to remove package: #{i} (#{$!})"
435
+ if File.directory? i
436
+ FileUtils.remove_dir(i, true) rescue puts "Failed to remove package: #{i} (#{$!})"
437
+ elsif Dir[i].each { |f| FileUtils.rm_rf f }.empty?
438
+ puts "Exclude pattern #{i.inspect} found no files."
439
+ end
456
440
  end
457
441
 
458
442
  # FIXME(uwe): Add a Ruboto.yml config for this if it works
459
- # Reduces the installation footprint, but also reduces performance and stack usage
443
+ # Reduces the installation footprint, but also reduces performance and increases stack
460
444
  # FIXME(uwe): Measure the performance change
461
- if false && jruby_core_version =~ /^1.7.0/ && Dir.chdir('../..') { verify_target_sdk < 15 }
462
- invokers = Dir['**/*${INVOKER$*,POPULATOR}.class']
463
- log_action("Removing invokers & populators(#{invokers.size})") do
445
+ if false && jruby_core_version =~ /^1.7./ && Dir.chdir('../..') { verify_min_sdk < 15 }
446
+ invokers = Dir['**/*$INVOKER$*.class']
447
+ log_action("Removing invokers(#{invokers.size})") do
464
448
  FileUtils.rm invokers
465
449
  end
450
+ populators = Dir['**/*$POPULATOR.class']
451
+ log_action("Removing populators(#{populators.size})") do
452
+ FileUtils.rm populators
453
+ end
466
454
  end
467
455
 
468
456
  # Uncomment this section to get a jar for each top level package in the core
@@ -472,10 +460,11 @@ module Ruboto
472
460
  #end
473
461
 
474
462
  # Add our proxy class factory
475
- `javac -source 1.6 -target 1.6 -cp .:#{Ruboto::ASSETS}/libs/dx.jar:#{Dir["#{Ruboto::SdkVersions::ANDROID_HOME}/platforms/android-*/android.jar"][0]} -d . #{Ruboto::GEM_ROOT}/lib/*.java`
463
+ `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`
476
464
  raise "Compile failed" unless $? == 0
477
465
 
478
466
  `jar -cf ../#{jruby_core} .`
467
+ raise "Creating repackaged jruby-core jar failed: #$?" unless $? == 0
479
468
  end
480
469
  FileUtils.remove_dir "tmp", true
481
470
  end
@@ -494,6 +483,7 @@ module Ruboto
494
483
  FileUtils.mkdir_p 'new/jruby.home'
495
484
  Dir.chdir 'old' do
496
485
  `jar -xf ../../#{jruby_stdlib}`
486
+ raise "Unpacking jruby-stdlib jar failed: #$?" unless $? == 0
497
487
  end
498
488
  FileUtils.move 'old/META-INF/jruby.home/lib', 'new/jruby.home/lib'
499
489
  FileUtils.rm_rf 'new/jruby.home/lib/ruby/gems'
@@ -531,6 +521,7 @@ module Ruboto
531
521
  # end
532
522
 
533
523
  `jar -cf ../../#{jruby_stdlib} .`
524
+ raise "Creating repackaged jruby-stdlib jar failed: #$?" unless $? == 0
534
525
  end
535
526
  end
536
527
  end
@@ -539,6 +530,34 @@ module Ruboto
539
530
  end
540
531
  end
541
532
 
533
+ # - Removes unneeded code from dx.jar
534
+ def reconfigure_dx_jar
535
+ dx_jar = 'dx.jar'
536
+ Dir.chdir 'libs' do
537
+ log_action("Removing unneeded classes from #{dx_jar}") do
538
+ FileUtils.rm_rf 'tmp'
539
+ Dir.mkdir 'tmp'
540
+ Dir.chdir 'tmp' do
541
+ FileUtils.move "../#{dx_jar}", "."
542
+ `jar -xf #{dx_jar}`
543
+ raise "Unpacking dx.jar jar failed: #$?" unless $? == 0
544
+ File.delete dx_jar
545
+ excluded_core_packages = [
546
+ 'com/android/dx/command',
547
+ 'com/android/dx/ssa',
548
+ 'junit',
549
+ ]
550
+ excluded_core_packages.each do |i|
551
+ FileUtils.remove_dir(i, true) rescue puts "Failed to remove package: #{i} (#{$!})"
552
+ end
553
+ `jar -cf ../#{dx_jar} .`
554
+ raise "Creating repackaged dx.jar failed: #$?" unless $? == 0
555
+ end
556
+ FileUtils.remove_dir "tmp", true
557
+ end
558
+ end
559
+ end
560
+
542
561
  def update_bundle
543
562
  if File.exist?('Gemfile.apk') && File.exists?('libs/bundle.jar')
544
563
  FileUtils.rm 'libs/bundle.jar'
@@ -48,16 +48,17 @@ module Ruboto
48
48
  end
49
49
 
50
50
  def verify_min_sdk
51
+ return @min_sdk if @min_sdk
51
52
  verify_sdk_versions
52
- @min_sdk ||= @uses_sdk.attribute('android:minSdkVersion').value
53
- abort "you must specify a minimum sdk level in the manifest (e.g., <uses-sdk android:minSdkVersion='3' android:targetSdkVersion='8' />)" unless @min_sdk
54
- @min_sdk
53
+ min_sdk_attr = @uses_sdk.attribute('android:minSdkVersion').value
54
+ abort "you must specify a minimum sdk level in the manifest (e.g., <uses-sdk android:minSdkVersion='3' android:targetSdkVersion='8' />)" unless min_sdk_attr
55
+ @min_sdk = min_sdk_attr.to_i
55
56
  end
56
57
 
57
58
  def verify_target_sdk
58
59
  return @target_sdk if @target_sdk
59
60
  verify_sdk_versions
60
- target_sdk_attr ||= @uses_sdk.attribute('android:targetSdkVersion').value
61
+ target_sdk_attr = @uses_sdk.attribute('android:targetSdkVersion').value
61
62
  abort "you must specify a target sdk level in the manifest (e.g., <uses-sdk android:minSdkVersion='3' android:targetSdkVersion='8' />)" unless target_sdk_attr
62
63
  @target_sdk = target_sdk_attr.to_i
63
64
  end
@@ -86,4 +87,4 @@ module Ruboto
86
87
 
87
88
  end
88
89
  end
89
- end
90
+ end
@@ -151,7 +151,7 @@ module Ruboto
151
151
  rv ? "return #{rv}" : default_return
152
152
  end
153
153
 
154
- def ruby_call(on_ruby_instance = false, camelize = false)
154
+ def ruby_call(camelize = false)
155
155
  params = parameters
156
156
  args = ""
157
157
  if params.size > 1
@@ -175,7 +175,6 @@ module Ruboto
175
175
  convert_return = "#{return_class.sub(/<.*>$/, '')}.class, "
176
176
  end
177
177
 
178
- if on_ruby_instance
179
178
  method_name = camelize ? attribute("name") : snake_case_attribute
180
179
  global_args = params.map{|i| "$arg_#{i[0]}"}.join(", ")
181
180
  ["// FIXME(uwe): Simplify when we stop support for RubotoCore 0.4.7"] +
@@ -192,9 +191,6 @@ module Ruboto
192
191
  ['throw new RuntimeException("Unknown JRuby version: " + JRubyAdapter.get("JRUBY_VERSION"));']
193
192
  )
194
193
  )
195
- else
196
- ["#{return_cast}JRubyAdapter.runRubyMethod(#{convert_return}scriptInfo.getCallbackProcs()[#{constant_string}], \"call\" #{args});"]
197
- end
198
194
  end
199
195
 
200
196
  def snake_case_attribute
@@ -205,31 +201,22 @@ module Ruboto
205
201
  method_call(
206
202
  (attribute("return") ? attribute("return") : "void"),
207
203
  attribute("name"), parameters,
208
- get_elements('exception').map{|m| m.attribute('type')},
204
+ get_elements('exception').map { |m| m.attribute('type') },
209
205
  ["if (ScriptLoader.isCalledFromJRuby()) #{super_return}",
210
- if_else(
211
- "JRubyAdapter.isInitialized()",
212
- if_else(
213
- "scriptInfo.getCallbackProcs() != null && scriptInfo.getCallbackProcs()[#{constant_string}] != null",
214
- [super_string] + ruby_call,
215
- ['String rubyClassName = scriptInfo.getRubyClassName();'] +
216
- if_else(
217
- # TODO(uwe): Remove defined?(rubyClassName) if we remove non-class-based class definitions
218
- "(Boolean)JRubyAdapter.runScriptlet(\"defined?(\" + rubyClassName + \") == 'constant' && \" + rubyClassName + \".instance_methods(false).any?{|m| m.to_sym == :#{snake_case_attribute}}\")",
219
- ruby_call(true),
220
- if_else(
221
- # TODO(uwe): Remove defined?(rubyClassName) if we remove non-class-based class definitions
222
- "(Boolean)JRubyAdapter.runScriptlet(\"defined?(\" + rubyClassName + \") == 'constant' && \" + rubyClassName + \".instance_methods(false).any?{|m| m.to_sym == :#{attribute('name')}}\")",
223
- ruby_call(true, true),
224
- [super_return]
225
- )
226
- )
227
- ),
228
- [
229
- %Q{Log.i("Method called before JRuby runtime was initialized: #{class_name}##{attribute('name')}");},
230
- super_return,
231
- ]
232
- )
206
+ if_else("!JRubyAdapter.isInitialized()",
207
+ [%Q{Log.i("Method called before JRuby runtime was initialized: #{class_name}##{attribute('name')}");},
208
+ super_return]),
209
+ 'String rubyClassName = scriptInfo.getRubyClassName();',
210
+ "if (rubyClassName == null) #{super_return}",
211
+ if_else(
212
+ "(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(false).any?{|m| m.to_sym == :#{snake_case_attribute}}\")",
213
+ ruby_call,
214
+ if_else(
215
+ "(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(false).any?{|m| m.to_sym == :#{attribute('name')}}\")",
216
+ ruby_call(true),
217
+ [super_return]
218
+ )
219
+ )
233
220
  ]
234
221
  ).indent.join("\n")
235
222
  end
@@ -5,6 +5,6 @@ Android using the Ruby language and libraries. It includes support libraries
5
5
  and generators for creating projects, classes, tests, and more. The complete
6
6
  APIs of Android, Java, and Ruby is available to you using the Ruby language.
7
7
  EOF
8
- VERSION = '0.9.0'
9
- UPDATE_VERSION_LIMIT = '0.5.2'
8
+ VERSION = '0.10.0.rc.0'
9
+ UPDATE_VERSION_LIMIT = '0.7.0'
10
10
  end
@@ -0,0 +1,56 @@
1
+ require 'ruboto/activity'
2
+ require 'ruboto/widget'
3
+
4
+ ruboto_import_widgets :Button, :LinearLayout, :TextView
5
+
6
+ class MytestActivity < Java::OrgRuboto::EntryPointActivity
7
+ def on_create(bundle)
8
+ super
9
+ set_title File.basename(__FILE__).chomp('_activity.rb').split('_').
10
+ map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
11
+
12
+ self.content_view =
13
+ linear_layout :orientation => :vertical, :gravity => :center_horizontal do
14
+ text_view :text => 'What hath Matz wrought?', :id => 42, :width => :match_parent,
15
+ :gravity => :center, :text_size => 48.0
16
+ button :text => 'Infile class', :width => :match_parent, :id => 48,
17
+ :on_click_listener => proc { start_infile_activity }
18
+ button :text => 'Otherfile class', :width => :match_parent, :id => 49,
19
+ :on_click_listener => proc { start_otherfile_activity }
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def start_infile_activity
26
+ i = android.content.Intent.new
27
+ i.setClassName($package_name, 'org.ruboto.RubotoActivity')
28
+ configBundle = android.os.Bundle.new
29
+ configBundle.put_string('ClassName', 'MytestInfileActivity')
30
+ i.putExtra('RubotoActivity Config', configBundle)
31
+ startActivity(i)
32
+ end
33
+
34
+ def start_otherfile_activity
35
+ i = android.content.Intent.new
36
+ i.setClassName($package_name, 'org.ruboto.RubotoActivity')
37
+ configBundle = android.os.Bundle.new
38
+ configBundle.put_string('ClassName', 'MytestOtherfileActivity')
39
+ i.putExtra('RubotoActivity Config', configBundle)
40
+ startActivity(i)
41
+ end
42
+
43
+ end
44
+
45
+ class MytestInfileActivity
46
+ def on_create(bundle)
47
+ super
48
+ set_title 'Infile Activity'
49
+
50
+ self.content_view =
51
+ linear_layout :orientation => :vertical, :gravity => :center_horizontal do
52
+ text_view :text => 'This is an infile activity.', :id => 42, :width => :match_parent,
53
+ :gravity => :center, :text_size => 48.0
54
+ end
55
+ end
56
+ end