From 01ad22d0da1f2022be3aa4ab16340979bbac48ea Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Tue, 24 Nov 2009 17:34:35 -0800 Subject: [PATCH] Finishing up the Jar --- framework/AndroidManifest.xml | 2 +- framework/gen/com/phonegap/R.java | 17 ++--- framework/src/com/phonegap/PhoneGapView.java | 74 -------------------- framework/src/com/phonegap/StandAlone.java | 31 ++++++++ 4 files changed, 38 insertions(+), 86 deletions(-) delete mode 100644 framework/src/com/phonegap/PhoneGapView.java create mode 100644 framework/src/com/phonegap/StandAlone.java diff --git a/framework/AndroidManifest.xml b/framework/AndroidManifest.xml index 399a6e40..e30be848 100644 --- a/framework/AndroidManifest.xml +++ b/framework/AndroidManifest.xml @@ -25,7 +25,7 @@ - diff --git a/framework/gen/com/phonegap/R.java b/framework/gen/com/phonegap/R.java index db7185cc..938334cb 100644 --- a/framework/gen/com/phonegap/R.java +++ b/framework/gen/com/phonegap/R.java @@ -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; } } diff --git a/framework/src/com/phonegap/PhoneGapView.java b/framework/src/com/phonegap/PhoneGapView.java deleted file mode 100644 index 9fd6e785..00000000 --- a/framework/src/com/phonegap/PhoneGapView.java +++ /dev/null @@ -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!"); - } - } - -} diff --git a/framework/src/com/phonegap/StandAlone.java b/framework/src/com/phonegap/StandAlone.java new file mode 100644 index 00000000..463c3bee --- /dev/null +++ b/framework/src/com/phonegap/StandAlone.java @@ -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 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); + } + +}