Permalink
Browse files

* Issues #281 #282 #290 and #291 Remove legacy callback callbacks

  • Loading branch information...
1 parent e58402c commit 6ba6111043cd99da783008a505f6f3ec5b78b74c @donv donv committed Nov 18, 2012
Showing with 80 additions and 1,303 deletions.
  1. +0 −19 assets/src/InheritingBroadcastReceiver.java
  2. +1 −8 assets/src/InheritingClass.java
  3. +1 −9 assets/src/RubotoActivity.java
  4. +18 −30 assets/src/RubotoBroadcastReceiver.java
  5. +1 −9 assets/src/RubotoService.java
  6. +0 −3 assets/src/org/ruboto/RubotoComponent.java
  7. +0 −15 assets/src/org/ruboto/ScriptInfo.java
  8. +0 −15 assets/src/org/ruboto/ScriptLoader.java
  9. +0 −25 assets/src/ruboto.rb
  10. +15 −40 assets/src/ruboto/activity.rb
  11. +0 −70 assets/src/ruboto/base.rb
  12. +2 −22 assets/src/ruboto/broadcast_receiver.rb
  13. +0 −220 assets/src/ruboto/legacy.rb
  14. +0 −88 assets/src/ruboto/menu.rb
  15. +1 −1 assets/src/ruboto/preference.rb
  16. +14 −51 assets/src/ruboto/service.rb
  17. +2 −2 assets/src/ruboto/widget.rb
  18. BIN examples/RubotoTestApp_0.6.0_tools_r19.tgz
  19. +0 −10 lib/java_class_gen/InheritingClass.java.erb
  20. +0 −5 lib/ruboto/util/build.rb
  21. +0 −27 lib/ruboto/util/update.rb
  22. +6 −16 lib/ruboto/util/xml_element.rb
  23. +2 −2 lib/ruboto/version.rb
  24. +12 −11 matrix_tests.sh
  25. +1 −1 run_tests.sh
  26. +0 −12 test/app_test_methods.rb
  27. +0 −23 test/block_def_activity/image_button_activity.rb
  28. +0 −21 test/block_def_activity/image_button_activity_test.rb
  29. +0 −20 test/block_def_activity/image_button_and_button_activity.rb
  30. +0 −27 test/block_def_activity/image_button_and_button_activity_test.rb
  31. +0 −18 test/block_def_activity/margins_activity.rb
  32. +0 −25 test/block_def_activity/margins_activity_test.rb
  33. +0 −26 test/block_def_activity/option_menu_activity.rb
  34. +0 −17 test/block_def_activity/option_menu_activity_test.rb
  35. +0 −35 test/block_def_activity/psych_activity.rb
  36. +0 −16 test/block_def_activity/psych_activity_test.rb
  37. +0 −25 test/block_def_activity/stack_activity.rb
  38. +0 −39 test/block_def_activity/stack_activity_test.rb
  39. +0 −21 test/handle_activity/image_button_activity.rb
  40. +0 −21 test/handle_activity/image_button_activity_test.rb
  41. +0 −24 test/handle_activity/image_button_and_button_activity.rb
  42. +0 −27 test/handle_activity/image_button_and_button_activity_test.rb
  43. +0 −15 test/handle_activity/margins_activity.rb
  44. +0 −25 test/handle_activity/margins_activity_test.rb
  45. +0 −25 test/handle_activity/option_menu_activity.rb
  46. +0 −20 test/handle_activity/option_menu_activity_test.rb
  47. +0 −31 test/handle_activity/psych_activity.rb
  48. +0 −16 test/handle_activity/psych_activity_test.rb
  49. +0 −24 test/handle_activity/stack_activity.rb
  50. +0 −47 test/handle_activity/stack_activity_test.rb
  51. +4 −4 test/ruboto_gen_test.rb
@@ -1,28 +1,9 @@
package THE_PACKAGE;
import org.ruboto.JRubyAdapter;
-import org.ruboto.ScriptLoader;
public class InheritingBroadcastReceiver extends org.ruboto.RubotoBroadcastReceiver {
- private boolean scriptLoaded = false;
-
public InheritingBroadcastReceiver() {
super("sample_broadcast_receiver.rb");
- if (JRubyAdapter.isInitialized()) {
- scriptLoaded = true;
- }
- }
-
- public void onReceive(android.content.Context context, android.content.Intent intent) {
- if (!scriptLoaded) {
- if (JRubyAdapter.setUpJRuby(context)) {
- ScriptLoader.loadScript(this);
- scriptLoaded = true;
- } else {
- // FIXME(uwe): What to do if the Ruboto Core platform is missing?
- }
- }
- super.onReceive(context, intent);
}
-
}
@@ -9,9 +9,7 @@
import org.ruboto.ScriptLoader;
public class THE_RUBOTO_CLASS THE_ACTION THE_ANDROID_CLASS {
-THE_CONSTANTS
-
- private final ScriptInfo scriptInfo = new ScriptInfo(CONSTANTS_COUNT);
+ private final ScriptInfo scriptInfo = new ScriptInfo();
{
scriptInfo.setRubyClassName(getClass().getSimpleName());
ScriptLoader.loadScript(this);
@@ -23,11 +21,6 @@ public ScriptInfo getScriptInfo() {
return scriptInfo;
}
- // FIXME(uwe): Only used for block based primary activities. Remove if we remove support for such.
- public void onCreateSuper() {
- // Do nothing
- }
-
THE_METHODS
}
@@ -8,9 +8,7 @@
import android.os.Bundle;
public class THE_RUBOTO_CLASS THE_ACTION THE_ANDROID_CLASS {
-THE_CONSTANTS
-
- private final ScriptInfo scriptInfo = new ScriptInfo(CONSTANTS_COUNT);
+ private final ScriptInfo scriptInfo = new ScriptInfo();
private String remoteVariable = null;
Bundle[] args;
private Bundle configBundle = null;
@@ -32,12 +30,6 @@ public ScriptInfo getScriptInfo() {
*
* Activity Lifecycle: onCreate
*/
-
- // FIXME(uwe): Only used for block based primary activities. Remove if we remove support for such.
- public void onCreateSuper() {
- super.onCreate((Bundle) args[0]);
- }
-
@Override
public void onCreate(Bundle bundle) {
System.out.println("THE_RUBOTO_CLASS onCreate(): " + getClass().getName());
@@ -5,13 +5,9 @@
import org.ruboto.ScriptLoader;
public class THE_RUBOTO_CLASS THE_ACTION THE_ANDROID_CLASS {
- private final ScriptInfo scriptInfo = new ScriptInfo(CONSTANTS_COUNT);
+ private final ScriptInfo scriptInfo = new ScriptInfo();
+ private boolean scriptLoaded = false;
- public void setCallbackProc(int id, Object obj) {
- // Error: no callbacks
- throw new RuntimeException("RubotoBroadcastReceiver does not accept callbacks");
- }
-
public ScriptInfo getScriptInfo() {
return scriptInfo;
}
@@ -25,42 +21,34 @@ public THE_RUBOTO_CLASS(String name) {
if (name != null) {
scriptInfo.setScriptName(name);
-
if (JRubyAdapter.isInitialized()) {
- // TODO(uwe): Only needed for non-class-based definitions
- // Can be removed if we stop supporting non-class-based definitions
- JRubyAdapter.put("$broadcast_receiver", this);
- // TODO end
-
ScriptLoader.loadScript(this);
+ scriptLoaded = true;
}
}
}
- // FIXME(uwe): Only used for block based primary activities. Remove if we remove support for such.
- public void onCreateSuper() {
- // Do nothing
- }
-
public void onReceive(android.content.Context context, android.content.Intent intent) {
try {
Log.d("onReceive: " + this);
-
- // FIXME(uwe): Only needed for older broadcast receiver using callbacks
- // FIXME(uwe): Remove if we stop suppporting callbacks (to avoid global variables).
- JRubyAdapter.put("$context", context);
- JRubyAdapter.put("$intent", intent);
- JRubyAdapter.put("$broadcast_receiver", this);
- // FIXME end
+ if (!scriptLoaded) {
+ if (JRubyAdapter.setUpJRuby(context)) {
+ ScriptLoader.loadScript(this);
+ scriptLoaded = true;
+ } else {
+ // FIXME(uwe): What to do if the Ruboto Core platform is missing?
+ }
+ }
// FIXME(uwe): Simplify when we stop supporting JRuby 1.6.x
- if (JRubyAdapter.isJRubyPreOneSeven()) {
- JRubyAdapter.runScriptlet("$broadcast_receiver.on_receive($context, $intent)");
- } else if (JRubyAdapter.isJRubyOneSeven()) {
+ // if (JRubyAdapter.isJRubyPreOneSeven()) {
+ // JRubyAdapter.put("$broadcast_receiver", this);
+ // JRubyAdapter.runScriptlet("$broadcast_receiver.on_receive($context, $intent)");
+ // } else if (JRubyAdapter.isJRubyOneSeven()) {
JRubyAdapter.runRubyMethod(this, "on_receive", new Object[]{context, intent});
- } else {
- throw new RuntimeException("Unknown JRuby version: " + JRubyAdapter.get("JRUBY_VERSION"));
- }
+ // } else {
+ // throw new RuntimeException("Unknown JRuby version: " + JRubyAdapter.get("JRUBY_VERSION"));
+ // }
} catch(Exception e) {
e.printStackTrace();
}
@@ -5,9 +5,7 @@
import java.io.IOException;
public class THE_RUBOTO_CLASS THE_ACTION THE_ANDROID_CLASS {
-THE_CONSTANTS
-
- private final ScriptInfo scriptInfo = new ScriptInfo(CONSTANTS_COUNT);
+ private final ScriptInfo scriptInfo = new ScriptInfo();
public ScriptInfo getScriptInfo() {
return scriptInfo;
@@ -17,12 +15,6 @@ public ScriptInfo getScriptInfo() {
*
* Service Lifecycle: onCreate
*/
-
- // FIXME(uwe): Only used for block based primary activities. Remove if we remove support for such.
- public void onCreateSuper() {
- super.onCreate();
- }
-
@Override
public void onCreate() {
if (ScriptLoader.isCalledFromJRuby()) {
@@ -2,7 +2,4 @@
public interface RubotoComponent {
ScriptInfo getScriptInfo();
-
- // FIXME(uwe): Only used for block based primary activities. Remove if we remove support for such.
- void onCreateSuper();
}
@@ -5,21 +5,6 @@
private String scriptName;
private Object rubyInstance;
- // FIXME(uwe): Only used for legacy handle_xxx callbacks. Remove when we stop supporting these.
- private final Object[] callbackProcs;
-
- public ScriptInfo(int callbackSize) {
- callbackProcs = new Object[callbackSize];
- }
-
- public Object[] getCallbackProcs() {
- return callbackProcs;
- }
-
- public void setCallbackProc(int id, Object obj) {
- callbackProcs[id] = obj;
- }
-
public String getRubyClassName() {
if (rubyClassName == null && scriptName != null) {
return Script.toCamelCase(scriptName);
@@ -106,23 +106,8 @@ public void run() {
if (component instanceof android.content.Context) {
callOnCreate(rubyInstance, args);
}
- } else {
- // FIXME(uwe): Remove when we stop supporting block based main activities.
- component.onCreateSuper();
}
component.getScriptInfo().setRubyInstance(rubyInstance);
- } else { // if (configBundle != null) {
- // FIXME(uwe): Simplify when we stop support for RubotoCore 0.4.7
- if (JRubyAdapter.isJRubyPreOneSeven()) {
- JRubyAdapter.runScriptlet("$activity.initialize_ruboto");
- } else if (JRubyAdapter.isJRubyOneSeven()) {
- JRubyAdapter.runRubyMethod(component, "initialize_ruboto");
- } else {
- throw new RuntimeException("Unknown JRuby version: " + JRubyAdapter.get("JRUBY_VERSION"));
- }
- if (component instanceof android.content.Context) {
- callOnCreate(component, args);
- }
}
} catch(IOException e){
e.printStackTrace();
View
@@ -1,25 +0,0 @@
-#######################################################
-#
-# ruboto.rb
-#
-# - Wrapper for using RubotoActivity, RubotoService, and
-# RubotoBroadcastReceiver.
-# - Provides interface for generating UI elements.
-# - Imports and configures callback classes.
-#
-# require this script for legacy support or require
-# the individual script files.
-#
-#######################################################
-
-require 'ruboto/base'
-require 'ruboto/package'
-require 'ruboto/activity'
-require 'ruboto/service'
-require 'ruboto/broadcast_receiver'
-
-require 'ruboto/widget'
-require 'ruboto/menu'
-require 'ruboto/util/stack'
-require 'ruboto/util/toast'
-require 'ruboto/legacy'
@@ -5,33 +5,20 @@
#
# ruboto/activity.rb
#
-# Basic activity set up and callback configuration.
+# Basic activity set up.
#
#######################################################
#
# Context
#
-
module Ruboto
module Context
- def initialize_ruboto()
- eval("#{$new_context_global} = self")
- $new_context_global = nil
-
- instance_eval &$context_init_block if $context_init_block
- $context_init_block = nil
- setup_ruboto_callbacks
-
- @initialized = true
- self
- end
-
def start_ruboto_dialog(remote_variable, theme=Java::android.R.style::Theme_Dialog, &block)
- ruboto_import "org.ruboto.RubotoDialog"
+ java_import "org.ruboto.RubotoDialog"
start_ruboto_activity(remote_variable, RubotoDialog, theme, &block)
end
-
+
def start_ruboto_activity(global_variable_name = '$activity', klass=RubotoActivity, theme=nil, options = nil, &block)
# FIXME(uwe): Translate old positional signature to new options-based signature.
# FIXME(uwe): Remove when we stop supporting Ruboto 0.8.0 or older.
@@ -44,31 +31,19 @@ def start_ruboto_activity(global_variable_name = '$activity', klass=RubotoActivi
global_variable_name = nil
end
- # FIXME(uwe): Used for block-based definition of main activity.
- # FIXME(uwe): Remove when we stop supporting Ruboto 0.8.0 or older.
- puts "start_ruboto_activity self: #{self.inspect}"
- if @ruboto_java_class and not @ruboto_java_class_initialized
- @ruboto_java_class_initialized = true
- puts "Block based main activity definition"
- instance_eval &block if block
- setup_ruboto_callbacks
- on_create nil
+ class_name = options[:class_name] || "#{klass.name.split('::').last}_#{source_descriptor(block)[0].split("/").last.gsub(/[.-]+/, '_')}_#{source_descriptor(block)[1]}"
+ if !Object.const_defined?(class_name)
+ Object.const_set(class_name, Class.new(&block))
else
- puts "Class based main activity definition"
- class_name = options[:class_name] || "#{klass.name.split('::').last}_#{source_descriptor(block)[0].split("/").last.gsub(/[.-]+/, '_')}_#{source_descriptor(block)[1]}"
- if !Object.const_defined?(class_name)
- Object.const_set(class_name, Class.new(&block))
- else
- Object.const_get(class_name).class_eval(&block) if block_given?
- end
- b = Java::android.os.Bundle.new
- b.putInt("Theme", theme) if theme
- b.putString("ClassName", class_name)
- i = android.content.Intent.new
- i.setClass self, klass.java_class
- i.putExtra("RubotoActivity Config", b)
- startActivity i
+ Object.const_get(class_name).class_eval(&block) if block_given?
end
+ b = Java::android.os.Bundle.new
+ b.putInt("Theme", theme) if theme
+ b.putString("ClassName", class_name)
+ i = android.content.Intent.new
+ i.setClass self, klass.java_class
+ i.putExtra("RubotoActivity Config", b)
+ startActivity i
self
end
@@ -110,6 +85,6 @@ def ruboto_configure_activity(klass)
end
java_import "android.app.Activity"
-ruboto_import "org.ruboto.RubotoActivity"
+java_import "org.ruboto.RubotoActivity"
ruboto_configure_activity(RubotoActivity)
Oops, something went wrong.

0 comments on commit 6ba6111

Please sign in to comment.