Skip to content

Commit

Permalink
* Issues #31 #39 #64 Make apps use a common Ruboto Core platform APK
Browse files Browse the repository at this point in the history
  • Loading branch information
donv committed Aug 23, 2011
1 parent 1e5d7ba commit b870cae
Show file tree
Hide file tree
Showing 13 changed files with 317 additions and 234 deletions.
4 changes: 4 additions & 0 deletions assets/Rakefile
Expand Up @@ -50,6 +50,10 @@ task :install => APK_FILE do
install_apk
end

task :release do
sh 'ant release'
end

task :tag => :release do
unless `git branch` =~ /^\* master$/
puts "You must be on the master branch to release!"
Expand Down
17 changes: 4 additions & 13 deletions assets/src/InheritingClass.java
@@ -1,28 +1,19 @@
package THE_PACKAGE;

import org.jruby.embed.ScriptingContainer;
import org.jruby.javasupport.util.RuntimeHelpers;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.javasupport.JavaUtil;
import org.jruby.exceptions.RaiseException;
import org.ruboto.Script;

public class THE_RUBOTO_CLASS THE_ACTION THE_ANDROID_CLASS {
private ScriptingContainer __ruby__;

THE_CONSTANTS
private IRubyObject[] callbackProcs = new IRubyObject[CONSTANTS_COUNT];

THE_CONSTRUCTORS
private Object[] callbackProcs = new Object[CONSTANTS_COUNT];

private ScriptingContainer getRuby() {
if (__ruby__ == null) __ruby__ = Script.getRuby();
return __ruby__;
}
THE_CONSTRUCTORS

public void setCallbackProc(int id, IRubyObject obj) {
public void setCallbackProc(int id, Object obj) {
callbackProcs[id] = obj;
}

THE_METHODS

}
55 changes: 20 additions & 35 deletions assets/src/RubotoActivity.java
Expand Up @@ -2,44 +2,23 @@

import java.io.IOException;

import org.jruby.Ruby;
import org.jruby.embed.ScriptingContainer;
import org.jruby.exceptions.RaiseException;
import org.jruby.javasupport.JavaUtil;
import org.jruby.javasupport.util.RuntimeHelpers;
import org.jruby.runtime.builtin.IRubyObject;
import org.ruboto.Script;

import android.app.ProgressDialog;
import android.os.Handler;

public class THE_RUBOTO_CLASS THE_ACTION THE_ANDROID_CLASS {
private ScriptingContainer __ruby__;
private String scriptName;
private String rubyClassName;
private Object rubyInstance;
private int splash = 0;
private String remoteVariable = "";
public Object[] args;
private ProgressDialog loadingDialog;

THE_CONSTANTS
private IRubyObject[] callbackProcs = new IRubyObject[CONSTANTS_COUNT];

private ScriptingContainer getRuby() {
if (__ruby__ == null) {
__ruby__ = Script.getRuby();
private Object[] callbackProcs = new Object[CONSTANTS_COUNT];

if (__ruby__ == null) {
Script.setUpJRuby(this);
__ruby__ = Script.getRuby();
}
}

return __ruby__;
}

public void setCallbackProc(int id, IRubyObject obj) {
public void setCallbackProc(int id, Object obj) {
callbackProcs[id] = obj;
}

Expand Down Expand Up @@ -74,8 +53,8 @@ public void onCreate(android.os.Bundle arg0) {

super.onCreate(arg0);

if (Script.getRuby() != null) {
backgroundCreate();
if (Script.isInitialized()) {
backgroundCreate();
finishCreate();
} else {
if (splash == 0) {
Expand All @@ -90,10 +69,16 @@ public void onCreate(android.os.Bundle arg0) {

private final Handler loadingHandler = new Handler();

private final Thread loadingThread = new Thread() {
public void run(){
backgroundCreate();
loadingHandler.post(loadingComplete);
private final Thread loadingThread = new Thread() {
public void run(){
Script.setUpJRuby(RubotoActivity.this);
if (Script.isInitialized()) {
backgroundCreate();
loadingHandler.post(loadingComplete);
} else {
// FIXME(uwe): Improve handling of missing Ruboto Core platform.
finish();
}
}
};

Expand All @@ -106,10 +91,10 @@ public void run(){
}
};

private void backgroundCreate() {
getRuby().put("$activity", this);
getRuby().put("$bundle", args[0]);
}
private void backgroundCreate() {
Script.put("$activity", this);
Script.put("$bundle", args[0]);
}

private void finishCreate() {
android.os.Bundle configBundle = getIntent().getBundleExtra("RubotoActivity Config");
Expand All @@ -129,9 +114,9 @@ private void finishCreate() {
new Script(scriptName).execute();
/* TODO(uwe): Add a way to add callbacks from a class or just forward all calls to the instance
rubyClassName = this.getClass().getSimpleName();
if (getRuby().get(rubyClassName) != null) {
if (Script.get(rubyClassName) != null) {
rubyInstance = Script.exec(rubyClassName + ".new");
getRuby().callMethod(rubyInstance, "on_create", configBundle);
Script.callMethod(rubyInstance, "on_create", configBundle);
}
*/
} catch(IOException e){
Expand Down
91 changes: 41 additions & 50 deletions assets/src/RubotoBroadcastReceiver.java
Expand Up @@ -2,69 +2,60 @@

import java.io.IOException;

import org.jruby.embed.ScriptingContainer;
import org.jruby.runtime.builtin.IRubyObject;

public abstract class THE_RUBOTO_CLASS THE_ACTION THE_ANDROID_CLASS {
private ScriptingContainer __ruby__;
private String scriptName;
private String remoteVariable = "";
public Object[] args;
private String scriptName;
private String remoteVariable = "";
public Object[] args;

THE_CONSTANTS
private IRubyObject[] callbackProcs = new IRubyObject[CONSTANTS_COUNT];

private ScriptingContainer getRuby() {
if (__ruby__ == null) {
__ruby__ = Script.getRuby();
}

return __ruby__;
}
private Object[] callbackProcs = new Object[CONSTANTS_COUNT];

public void setCallbackProc(int id, IRubyObject obj) {
callbackProcs[id] = obj;
}
public void setCallbackProc(int id, Object obj) {
callbackProcs[id] = obj;
}

public THE_RUBOTO_CLASS setRemoteVariable(String var) {
remoteVariable = ((var == null) ? "" : (var + "."));
return this;
}
public THE_RUBOTO_CLASS setRemoteVariable(String var) {
remoteVariable = ((var == null) ? "" : (var + "."));
return this;
}

public void setScriptName(String name){
scriptName = name;
}
public void setScriptName(String name){
scriptName = name;
}

/****************************************************************************************
*
* Activity Lifecycle: onCreate
*/
/****************************************************************************************
*
* Activity Lifecycle: onCreate
*/

@Override
public void onReceive(android.content.Context arg0, android.content.Intent arg1) {
args = new Object[2];
args[0] = arg0;
args[1] = arg1;

getRuby();

Script.defineGlobalVariable("$broadcast_receiver", this);
Script.defineGlobalVariable("$broadcast_context", arg0);
Script.defineGlobalVariable("$broadcast_intent", arg1);

try {
new Script(scriptName).execute();
} catch(IOException e) {
e.printStackTrace();
@Override
public void onReceive(android.content.Context context, android.content.Intent intent) {
args = new Object[2];
args[0] = context;
args[1] = intent;

if (Script.setUpJRuby(context)) {
Script.defineGlobalVariable("$broadcast_receiver", this);
Script.defineGlobalVariable("$broadcast_context", context);
Script.defineGlobalVariable("$broadcast_intent", intent);
try {
new Script(scriptName).execute();
} catch(IOException e) {
e.printStackTrace();
}
} else {
// FIXME(uwe): What to do if the Ruboto Core platform is missing?
}
}
}

/****************************************************************************************
*
* Generated Methods
*/
/****************************************************************************************
*
* Generated Methods
*/

THE_METHODS

}


41 changes: 13 additions & 28 deletions assets/src/RubotoService.java
@@ -1,36 +1,19 @@
package THE_PACKAGE;

import org.jruby.Ruby;
import org.jruby.javasupport.util.RuntimeHelpers;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.javasupport.JavaUtil;
import org.jruby.embed.ScriptingContainer;
import org.jruby.exceptions.RaiseException;
import org.ruboto.Script;
import java.io.IOException;
import android.app.ProgressDialog;

public abstract class THE_RUBOTO_CLASS THE_ACTION THE_ANDROID_CLASS {
private ScriptingContainer __ruby__;
private String scriptName;
private String remoteVariable = "";
public Object[] args;

THE_CONSTANTS
private IRubyObject[] callbackProcs = new IRubyObject[CONSTANTS_COUNT];

private ScriptingContainer getRuby() {
if (__ruby__ == null) __ruby__ = Script.getRuby();
private Object[] callbackProcs = new Object[CONSTANTS_COUNT];

if (__ruby__ == null) {
Script.setUpJRuby(this);
__ruby__ = Script.getRuby();
}

return __ruby__;
}

public void setCallbackProc(int id, IRubyObject obj) {
public void setCallbackProc(int id, Object obj) {
callbackProcs[id] = obj;
}

Expand All @@ -54,14 +37,15 @@ public void onCreate() {

super.onCreate();

getRuby();

Script.defineGlobalVariable("$service", this);

try {
new Script(scriptName).execute();
} catch(IOException e) {
e.printStackTrace();
if (Script.setUpJRuby(this)) {
Script.defineGlobalVariable("$service", this);
try {
new Script(scriptName).execute();
} catch(IOException e) {
e.printStackTrace();
}
} else {
// FIXME(uwe): What to do if the Ruboto Core plarform cannot be found?
}
}

Expand All @@ -71,6 +55,7 @@ public void onCreate() {
*/

THE_METHODS
}

}


0 comments on commit b870cae

Please sign in to comment.