Finishing up the Jar

This commit is contained in:
Joe Bowser 2009-11-24 17:34:35 -08:00
parent e75a908844
commit 01ad22d0da
4 changed files with 38 additions and 86 deletions

View File

@ -25,7 +25,7 @@
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="false">
<activity android:name=".DroidGap"
<activity android:name=".StandAlone"
android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@ -14,22 +14,17 @@ public final class R {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int appView=0x7f060000;
public static final int go=0x7f060002;
public static final int surface=0x7f060001;
public static final int appView=0x7f050000;
public static final int go=0x7f050002;
public static final int surface=0x7f050001;
}
public static final class layout {
public static final int main=0x7f030000;
public static final int preview=0x7f030001;
}
public static final class raw {
public static final int bird=0x7f040000;
public static final int off=0x7f040001;
public static final int on=0x7f040002;
}
public static final class string {
public static final int app_name=0x7f050000;
public static final int go=0x7f050002;
public static final int url=0x7f050001;
public static final int app_name=0x7f040000;
public static final int go=0x7f040002;
public static final int url=0x7f040001;
}
}

View File

@ -1,74 +0,0 @@
package com.phonegap;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.webkit.WebView;
public class PhoneGapView extends WebView {
private Activity mCtx;
private PhoneGap gap;
private GeoBroker geo;
private AccelListener accel;
private ContactManager mContacts;
private FileUtils fs;
private NetworkManager netMan;
private CameraLauncher launcher;
public PhoneGapView(Activity action){
super((Context) action);
mCtx = action;
}
public void loadUrl(String url)
{
super.loadUrl(url);
bindBrowser();
}
private void bindBrowser()
{
gap = new PhoneGap(mCtx, this);
geo = new GeoBroker(this, mCtx);
accel = new AccelListener(mCtx, this);
mContacts = new ContactManager(mCtx, this);
fs = new FileUtils(this);
netMan = new NetworkManager(mCtx, this);
// This creates the new javascript interfaces for PhoneGap
this.addJavascriptInterface(gap, "DroidGap");
this.addJavascriptInterface(geo, "Geo");
this.addJavascriptInterface(accel, "Accel");
this.addJavascriptInterface(mContacts, "ContactHook");
this.addJavascriptInterface(fs, "FileUtil");
this.addJavascriptInterface(netMan, "NetworkManager");
}
// This is required to start the camera activity! It has to come from the previous activity
public void startCamera(int quality)
{
Intent i = new Intent(mCtx, CameraPreview.class);
i.setAction("android.intent.action.PICK");
i.putExtra("quality", quality);
mCtx.startActivityForResult(i, 0);
}
protected void processResult(int requestCode, int resultCode, Intent intent)
{
String data;
if (resultCode == mCtx.RESULT_OK)
{
data = intent.getStringExtra("picture");
// Send the graphic back to the class that needs it
launcher.processPicture(data);
}
else
{
launcher.failPicture("Did not complete!");
}
}
}

View File

@ -0,0 +1,31 @@
package com.phonegap;
import java.lang.reflect.Field;
import android.os.Bundle;
public class StandAlone extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* Load a URI from the strings.xml file */
Class<R.string> c = R.string.class;
Field f;
String uri;
int i = 0;
try {
f = c.getField("url");
i = f.getInt(f);
uri = this.getResources().getString(i);
} catch (Exception e)
{
uri = "http://www.phonegap.com";
}
super.loadUrl(uri);
}
}