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
@@ -152,15 +152,15 @@ public class Script {
152
152
  }
153
153
  }
154
154
 
155
- // public File getFile() {
156
- // for (String dir : scriptsDir) {
157
- // File f = new File(dir, name);
158
- // if (f.exists()) {
159
- // return f;
160
- // }
161
- // }
162
- // return new File(scriptsDir[0], name);
163
- // }
155
+ public File getFile() {
156
+ for (String dir : scriptsDir) {
157
+ File f = new File(dir, name);
158
+ if (f.exists()) {
159
+ return f;
160
+ }
161
+ }
162
+ return new File(scriptsDir[0], name);
163
+ }
164
164
 
165
165
  public String getName() {
166
166
  return name;
@@ -5,21 +5,6 @@ public class ScriptInfo {
5
5
  private String scriptName;
6
6
  private Object rubyInstance;
7
7
 
8
- // FIXME(uwe): Only used for legacy handle_xxx callbacks. Remove when we stop supporting these.
9
- private final Object[] callbackProcs;
10
-
11
- public ScriptInfo(int callbackSize) {
12
- callbackProcs = new Object[callbackSize];
13
- }
14
-
15
- public Object[] getCallbackProcs() {
16
- return callbackProcs;
17
- }
18
-
19
- public void setCallbackProc(int id, Object obj) {
20
- callbackProcs[id] = obj;
21
- }
22
-
23
8
  public String getRubyClassName() {
24
9
  if (rubyClassName == null && scriptName != null) {
25
10
  return Script.toCamelCase(scriptName);
@@ -31,34 +31,43 @@ public class ScriptLoader {
31
31
  if (rubyScript.exists()) {
32
32
  rubyInstance = component;
33
33
  final String script = rubyScript.getContents();
34
- if (script.matches("(?s).*class " + component.getScriptInfo().getRubyClassName() + ".*")) {
35
- if (!component.getScriptInfo().getRubyClassName().equals(component.getClass().getSimpleName())) {
36
- System.out.println("Script defines methods on meta class");
37
- // FIXME(uwe): Simplify when we stop support for RubotoCore 0.4.7
38
- if (JRubyAdapter.isJRubyPreOneSeven() || JRubyAdapter.isRubyOneEight()) {
39
- JRubyAdapter.put("$java_instance", component);
40
- JRubyAdapter.put(component.getScriptInfo().getRubyClassName(), JRubyAdapter.runScriptlet("class << $java_instance; self; end"));
41
- } else if (JRubyAdapter.isJRubyOneSeven() && JRubyAdapter.isRubyOneNine()) {
42
- JRubyAdapter.runScriptlet("Java::" + component.getClass().getName() + ".__persistent__ = true");
43
- JRubyAdapter.put(component.getScriptInfo().getRubyClassName(), JRubyAdapter.runRubyMethod(component, "singleton_class"));
44
- } else {
45
- throw new RuntimeException("Unknown JRuby/Ruby version: " + JRubyAdapter.get("JRUBY_VERSION") + "/" + JRubyAdapter.get("RUBY_VERSION"));
46
- }
34
+ boolean scriptContainsClass = script.matches("(?s).*class "
35
+ + component.getScriptInfo().getRubyClassName() + ".*");
36
+ boolean hasBackingJavaClass = component.getScriptInfo().getRubyClassName()
37
+ .equals(component.getClass().getSimpleName());
38
+ if (scriptContainsClass && !hasBackingJavaClass) {
39
+ System.out.println("Script defines methods on meta class");
40
+
41
+ // FIXME(uwe): Simplify when we stop support for RubotoCore 0.4.7
42
+ if (JRubyAdapter.isJRubyPreOneSeven() || JRubyAdapter.isRubyOneEight()) {
43
+ JRubyAdapter.put("$java_instance", component);
44
+ rubyClass = JRubyAdapter.runScriptlet("class << $java_instance; self; end");
45
+ } else if (JRubyAdapter.isJRubyOneSeven() && JRubyAdapter.isRubyOneNine()) {
46
+ JRubyAdapter.runScriptlet("Java::" + component.getClass().getName() + ".__persistent__ = true");
47
+ rubyClass = JRubyAdapter.runRubyMethod(component, "singleton_class");
48
+ } else {
49
+ throw new RuntimeException("Unknown JRuby/Ruby version: " + JRubyAdapter.get("JRUBY_VERSION") + "/" + JRubyAdapter.get("RUBY_VERSION"));
47
50
  }
51
+ // EMXIF
52
+
48
53
  }
49
- if (rubyClass == null) {
54
+ if (rubyClass == null || !hasBackingJavaClass) {
50
55
  System.out.println("Loading script: " + component.getScriptInfo().getScriptName());
51
- if (script.matches("(?s).*class " + component.getScriptInfo().getRubyClassName() + ".*")) {
56
+ if (scriptContainsClass) {
52
57
  System.out.println("Script contains class definition");
53
- if (component.getScriptInfo().getRubyClassName().equals(component.getClass().getSimpleName())) {
58
+ if (rubyClass == null && hasBackingJavaClass) {
54
59
  System.out.println("Script has separate Java class");
60
+
55
61
  // FIXME(uwe): Simplify when we stop support for JRuby < 1.7.0
56
62
  if (!JRubyAdapter.isJRubyPreOneSeven()) {
57
63
  JRubyAdapter.runScriptlet("Java::" + component.getClass().getName() + ".__persistent__ = true");
58
64
  }
59
- JRubyAdapter.put(component.getScriptInfo().getRubyClassName(), JRubyAdapter.runScriptlet("Java::" + component.getClass().getName()));
65
+ // EMXIF
66
+
67
+ rubyClass = JRubyAdapter.runScriptlet("Java::" + component.getClass().getName());
60
68
  }
61
- System.out.println("Set class: " + JRubyAdapter.get(component.getScriptInfo().getRubyClassName()));
69
+ System.out.println("Set class: " + rubyClass);
70
+ JRubyAdapter.put(component.getScriptInfo().getRubyClassName(), rubyClass);
62
71
  Thread t = new Thread(new Runnable(){
63
72
  public void run() {
64
73
  JRubyAdapter.setScriptFilename(rubyScript.getAbsolutePath());
@@ -72,17 +81,11 @@ public class ScriptLoader {
72
81
  Thread.currentThread().interrupt();
73
82
  throw new RuntimeException("Interrupted loading script.", ie);
74
83
  }
75
- rubyClass = JRubyAdapter.get(component.getScriptInfo().getRubyClassName());
76
84
  } else {
77
- // FIXME(uwe): Only needed for initial block-based activity definition
78
- System.out.println("Script contains block based activity definition");
79
- if (!JRubyAdapter.isJRubyPreOneSeven()) {
80
- JRubyAdapter.runScriptlet("Java::" + component.getClass().getName() + ".__persistent__ = true");
81
- }
82
- JRubyAdapter.runScriptlet("$activity.instance_variable_set '@ruboto_java_class', '" + component.getScriptInfo().getRubyClassName() + "'");
83
- JRubyAdapter.runScriptlet("puts %Q{$activity: #$activity}");
84
- JRubyAdapter.setScriptFilename(rubyScript.getAbsolutePath());
85
- JRubyAdapter.runScriptlet(script);
85
+ throw new RuntimeException("Expected file "
86
+ + component.getScriptInfo().getScriptName()
87
+ + " to define class "
88
+ + component.getScriptInfo().getRubyClassName());
86
89
  }
87
90
  }
88
91
  } else if (rubyClass != null) {
@@ -98,23 +101,8 @@ public class ScriptLoader {
98
101
  if (component instanceof android.content.Context) {
99
102
  callOnCreate(rubyInstance, args);
100
103
  }
101
- } else {
102
- // FIXME(uwe): Remove when we stop supporting block based main activities.
103
- component.onCreateSuper();
104
104
  }
105
105
  component.getScriptInfo().setRubyInstance(rubyInstance);
106
- } else { // if (configBundle != null) {
107
- // FIXME(uwe): Simplify when we stop support for RubotoCore 0.4.7
108
- if (JRubyAdapter.isJRubyPreOneSeven()) {
109
- JRubyAdapter.runScriptlet("$activity.initialize_ruboto");
110
- } else if (JRubyAdapter.isJRubyOneSeven()) {
111
- JRubyAdapter.runRubyMethod(component, "initialize_ruboto");
112
- } else {
113
- throw new RuntimeException("Unknown JRuby version: " + JRubyAdapter.get("JRUBY_VERSION"));
114
- }
115
- if (component instanceof android.content.Context) {
116
- callOnCreate(component, args);
117
- }
118
106
  }
119
107
  } catch(IOException e){
120
108
  e.printStackTrace();
@@ -5,34 +5,21 @@ require 'ruboto/package'
5
5
  #
6
6
  # ruboto/activity.rb
7
7
  #
8
- # Basic activity set up and callback configuration.
8
+ # Basic activity set up.
9
9
  #
10
10
  #######################################################
11
11
 
12
12
  #
13
13
  # Context
14
14
  #
15
-
16
15
  module Ruboto
17
16
  module Context
18
- def initialize_ruboto()
19
- eval("#{$new_context_global} = self")
20
- $new_context_global = nil
21
-
22
- instance_eval &$context_init_block if $context_init_block
23
- $context_init_block = nil
24
- setup_ruboto_callbacks
25
-
26
- @initialized = true
27
- self
28
- end
29
-
30
17
  def start_ruboto_dialog(remote_variable, theme=Java::android.R.style::Theme_Dialog, &block)
31
- ruboto_import "org.ruboto.RubotoDialog"
18
+ java_import "org.ruboto.RubotoDialog"
32
19
  start_ruboto_activity(remote_variable, RubotoDialog, theme, &block)
33
20
  end
34
-
35
- def start_ruboto_activity(global_variable_name = '$activity', klass=RubotoActivity, theme=nil, options = nil, &block)
21
+
22
+ def start_ruboto_activity(global_variable_name = '$block_based_activity', klass=RubotoActivity, theme=nil, options = nil, &block)
36
23
  # FIXME(uwe): Translate old positional signature to new options-based signature.
37
24
  # FIXME(uwe): Remove when we stop supporting Ruboto 0.8.0 or older.
38
25
  if options.nil?
@@ -44,31 +31,19 @@ module Ruboto
44
31
  global_variable_name = nil
45
32
  end
46
33
 
47
- # FIXME(uwe): Used for block-based definition of main activity.
48
- # FIXME(uwe): Remove when we stop supporting Ruboto 0.8.0 or older.
49
- puts "start_ruboto_activity self: #{self.inspect}"
50
- if @ruboto_java_class and not @ruboto_java_class_initialized
51
- @ruboto_java_class_initialized = true
52
- puts "Block based main activity definition"
53
- instance_eval &block if block
54
- setup_ruboto_callbacks
55
- on_create nil
34
+ class_name = options[:class_name] || "#{klass.name.split('::').last}_#{source_descriptor(block)[0].split("/").last.gsub(/[.-]+/, '_')}_#{source_descriptor(block)[1]}"
35
+ if !Object.const_defined?(class_name)
36
+ Object.const_set(class_name, Class.new(&block))
56
37
  else
57
- puts "Class based main activity definition"
58
- class_name = options[:class_name] || "#{klass.name.split('::').last}_#{source_descriptor(block)[0].split("/").last.gsub(/[.]+/, '_')}_#{source_descriptor(block)[1]}"
59
- if !Object.const_defined?(class_name)
60
- Object.const_set(class_name, Class.new(&block))
61
- else
62
- Object.const_get(class_name).class_eval(&block)
63
- end
64
- b = Java::android.os.Bundle.new
65
- b.putInt("Theme", theme) if theme
66
- b.putString("ClassName", class_name)
67
- i = android.content.Intent.new
68
- i.setClass self, klass.java_class
69
- i.putExtra("RubotoActivity Config", b)
70
- startActivity i
38
+ Object.const_get(class_name).class_eval(&block) if block_given?
71
39
  end
40
+ b = Java::android.os.Bundle.new
41
+ b.putInt("Theme", theme) if theme
42
+ b.putString("ClassName", class_name)
43
+ i = android.content.Intent.new
44
+ i.setClass self, klass.java_class
45
+ i.putExtra("RubotoActivity Config", b)
46
+ startActivity i
72
47
  self
73
48
  end
74
49
 
@@ -110,6 +85,6 @@ def ruboto_configure_activity(klass)
110
85
  end
111
86
 
112
87
  java_import "android.app.Activity"
113
- ruboto_import "org.ruboto.RubotoActivity"
88
+ java_import "org.ruboto.RubotoActivity"
114
89
  ruboto_configure_activity(RubotoActivity)
115
90
 
@@ -6,15 +6,6 @@
6
6
  #
7
7
  #######################################################
8
8
 
9
- # Only used needed for ruboto-core apps
10
- require 'ruboto/version'
11
- $RUBOTO_VERSION = 10
12
-
13
- def confirm_ruboto_version(required_version, exact=true)
14
- raise "requires $RUBOTO_VERSION=#{required_version} or greater, current version #{$RUBOTO_VERSION}" if $RUBOTO_VERSION < required_version and not exact
15
- raise "requires $RUBOTO_VERSION=#{required_version}, current version #{$RUBOTO_VERSION}" if $RUBOTO_VERSION != required_version and exact
16
- end
17
-
18
9
  require 'java'
19
10
 
20
11
  # Create convenience method for top-level android package so we do not need to prefix with 'Java::'.
@@ -32,64 +23,3 @@ end
32
23
 
33
24
  java_import "android.R"
34
25
  AndroidIds = JavaUtilities.get_proxy_class("android.R$id")
35
-
36
- #
37
- # Callbacks
38
- #
39
-
40
- module Ruboto
41
- module CallbackClass
42
- def new_with_callbacks(*args, &block)
43
- new(*args).initialize_ruboto_callbacks(&block)
44
- end
45
- end
46
-
47
- module Callbacks
48
- def initialize_ruboto_callbacks &block
49
- instance_eval &block
50
- setup_ruboto_callbacks
51
- self
52
- end
53
-
54
- def ruboto_callback_methods
55
- # FIXME(uwe): Remove to_sym conversion when we stop supporting Ruby 1.8 mode
56
- (singleton_methods - ["on_create", "on_receive"]).select{|i| self.class.constants.map(&:to_sym).include?(i.to_s.sub(/^on_/, "CB_").upcase.to_sym) || self.class.constants.map(&:to_sym).include?("CB_#{i}".upcase.to_sym)}
57
- end
58
-
59
- def setup_ruboto_callbacks
60
- ruboto_callback_methods.each do |i|
61
- begin
62
- # FIXME(uwe): Remove to_sym conversion when we stop supporting Ruby 1.8 mode
63
- scriptInfo.setCallbackProc((self.class.constants.map(&:to_sym).include?(i.to_s.sub(/^on_/, "CB_").upcase.to_sym) && self.class.const_get(i.to_s.sub(/^on_/, "CB_").upcase)) || (self.class.constants.map(&:to_sym).include?("CB_#{i}".upcase.to_sym) && self.class.const_get("CB_#{i}".upcase)), method(i))
64
- rescue
65
- end
66
- end
67
- end
68
- end
69
- end
70
-
71
- #
72
- # Import a class and set it up for handlers
73
- #
74
-
75
- def ruboto_import(*package_classes)
76
- already_classes = package_classes.select{|i| not i.is_a?(String) and not i.is_a?(Symbol)}
77
- imported_classes = package_classes - already_classes
78
-
79
- unless imported_classes.empty?
80
- # TODO(uwe): The first part of this "if" is only needed for JRuby 1.6.x. Simplify when we stop supporting JRuby 1.6.x
81
- if imported_classes.size == 1
82
- imported_classes = [*(java_import(*imported_classes) || eval("Java::#{imported_classes[0]}"))]
83
- else
84
- imported_classes = java_import(imported_classes)
85
- end
86
- end
87
-
88
- (already_classes + imported_classes).each do |package_class|
89
- package_class.class_eval do
90
- extend Ruboto::CallbackClass
91
- include Ruboto::Callbacks
92
- end
93
- end
94
- end
95
-
@@ -2,33 +2,13 @@
2
2
  #
3
3
  # ruboto/broadcast_receiver.rb
4
4
  #
5
- # Basic broadcast_receiver set up and callback configuration.
5
+ # Basic broadcast_receiver set up.
6
6
  #
7
7
  #######################################################
8
8
 
9
9
  require 'ruboto/base'
10
10
 
11
- ruboto_import "org.ruboto.RubotoBroadcastReceiver"
12
- RubotoBroadcastReceiver.class_eval do
13
- def self.new_with_callbacks &block
14
- (($broadcast_receiver.nil? || $broadcast_receiver.initialized) ? new : $broadcast_receiver).initialize_ruboto_callbacks &block
15
- end
16
-
17
- def initialized
18
- @initialized ||= false
19
- end
20
-
21
- def initialize_ruboto_callbacks &block
22
- instance_eval &block
23
- setup_ruboto_callbacks
24
- @initialized = true
25
- self
26
- end
27
-
28
- def on_receive(context, intent)
29
- end
30
- end
31
-
11
+ java_import "org.ruboto.RubotoBroadcastReceiver"
32
12
  module Ruboto
33
13
  module BroadcastReceiver
34
14
  end
@@ -1,4 +1,3 @@
1
- $package_name = ($activity || $service).package_name
2
1
  $package = eval("Java::#{$package_name}")
3
2
 
4
3
  module Ruboto
@@ -10,14 +10,16 @@ require 'ruboto/activity'
10
10
 
11
11
  java_import "android.preference.PreferenceScreen"
12
12
  java_import "android.preference.Preference"
13
- ruboto_import "org.ruboto.RubotoPreferenceActivity"
13
+ java_import "org.ruboto.RubotoPreferenceActivity"
14
14
  ruboto_configure_activity(RubotoPreferenceActivity)
15
15
 
16
16
  RubotoPreferenceActivity.class_eval do
17
17
  def preference_screen(params={})
18
18
  rv = self.getPreferenceManager.createPreferenceScreen(self)
19
+ parent = params.delete(:parent) || @parent
19
20
  rv.configure self, params
20
- @parent.addPreference(rv) if @parent
21
+ parent.addPreference(rv) if parent
22
+
21
23
  if block_given?
22
24
  old_parent, @parent = @parent, rv
23
25
  yield
@@ -54,8 +56,10 @@ def ruboto_import_preference(class_name, package_name="android.preference")
54
56
  RubotoPreferenceActivity.class_eval "
55
57
  def #{(class_name.to_s.gsub(/([A-Z])/) { '_' + $1.downcase })[1..-1]}(params={})
56
58
  rv = #{class_name}.new self
59
+ parent = params.delete(:parent) || @parent
57
60
  rv.configure self, params
58
- @parent.addPreference(rv) if @parent
61
+ parent.addPreference(rv) if parent
62
+
59
63
  if block_given?
60
64
  old_parent, @parent = @parent, rv
61
65
  yield
@@ -5,71 +5,34 @@ require 'ruboto/package'
5
5
  #
6
6
  # ruboto/service.rb
7
7
  #
8
- # Basic service set up and callback configuration.
8
+ # Basic service set up.
9
9
  #
10
10
  #######################################################
11
11
 
12
- #
13
- # Context
14
- #
12
+ java_import "android.content.Context"
13
+ java_import "org.ruboto.RubotoService"
15
14
 
16
15
  module Ruboto
17
16
  module Context
18
- def initialize_ruboto()
19
- eval("#{$new_context_global} = self")
20
- $new_context_global = nil
21
-
22
- instance_eval &$context_init_block if $context_init_block
23
- $context_init_block = nil
24
- setup_ruboto_callbacks
25
-
26
- @initialized = true
27
- self
28
- end
29
-
30
17
  def start_ruboto_service(global_variable_name = '$service', klass=RubotoService, &block)
31
- $context_init_block = block
32
- $new_context_global = global_variable_name
33
-
34
- if @initialized or (self == $service) or ($service == nil) # FIx mix between activity and service
35
- self.startService Java::android.content.Intent.new(self, klass.java_class)
18
+ class_name = options[:class_name] || "#{klass.name.split('::').last}_#{source_descriptor(block)[0].split("/").last.gsub(/[.-]+/, '_')}_#{source_descriptor(block)[1]}"
19
+ if !Object.const_defined?(class_name)
20
+ Object.const_set(class_name, Class.new(&block))
36
21
  else
37
- initialize_ruboto
38
- on_create
22
+ Object.const_get(class_name).class_eval(&block) if block_given?
39
23
  end
40
-
24
+ b = Java::android.os.Bundle.new
25
+ b.putInt("Theme", theme) if theme
26
+ b.putString("ClassName", class_name)
27
+ i = android.content.Intent.new
28
+ i.setClass self, klass.java_class
29
+ i.putExtra("RubotoActivity Config", b)
30
+ self.startService Java::android.content.Intent.new(self, klass.java_class)
41
31
  self
42
32
  end
43
33
  end
44
34
  end
45
35
 
46
- java_import "android.content.Context"
47
36
  Context.class_eval do
48
37
  include Ruboto::Context
49
38
  end
50
-
51
- #
52
- # Leave for legacy Service Subclass Setup
53
- #
54
-
55
- module Ruboto
56
- module Service
57
- end
58
- end
59
-
60
- #
61
- # Basic Service Setup
62
- #
63
-
64
- def ruboto_configure_service(klass)
65
- klass.class_eval do
66
- include Ruboto::Service
67
-
68
- def on_create
69
- end
70
- end
71
- end
72
-
73
- ruboto_import "org.ruboto.RubotoService"
74
- ruboto_configure_service(RubotoService)
75
-