mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-01 06:30:06 +08:00
Moving to new computer, committing what I have in the branch
This commit is contained in:
parent
08691b73c2
commit
745e550815
@ -89,8 +89,10 @@ public class DroidGap extends Activity {
|
|||||||
|
|
||||||
private void bindBrowser(WebView appView)
|
private void bindBrowser(WebView appView)
|
||||||
{
|
{
|
||||||
|
// The PhoneGap class handles the Notification and Android Specific crap
|
||||||
PhoneGap gap = new PhoneGap(this, mHandler, appView);
|
PhoneGap gap = new PhoneGap(this, mHandler, appView);
|
||||||
appView.addJavascriptInterface(gap, "DroidGap");
|
appView.addJavascriptInterface(gap, "Droid");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
19
src/com/nitobi/phonegap/GeoBroker.java
Normal file
19
src/com/nitobi/phonegap/GeoBroker.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package com.nitobi.phonegap;
|
||||||
|
|
||||||
|
import android.webkit.WebView;
|
||||||
|
|
||||||
|
public class GeoBroker {
|
||||||
|
private WebView mAppView;
|
||||||
|
|
||||||
|
|
||||||
|
public String start(int freq, String success, String failure)
|
||||||
|
{
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop(String key)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
37
src/com/nitobi/phonegap/GeoListener.java
Normal file
37
src/com/nitobi/phonegap/GeoListener.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package com.nitobi.phonegap;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
|
||||||
|
public class GeoListener {
|
||||||
|
String id;
|
||||||
|
String successCallback;
|
||||||
|
String failCallback;
|
||||||
|
GpsListener mGps;
|
||||||
|
NetworkListener mNetwork;
|
||||||
|
Context mCtx;
|
||||||
|
private WebView mAppView;
|
||||||
|
|
||||||
|
int interval;
|
||||||
|
|
||||||
|
GeoListener(String key, Context ctx, int time, String succ, String fail)
|
||||||
|
{
|
||||||
|
id = key;
|
||||||
|
interval = time;
|
||||||
|
mCtx = ctx;
|
||||||
|
mGps = new GpsListener(mCtx, interval, this);
|
||||||
|
mNetwork = new NetworkListener(mCtx, interval, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void success()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* We only need to figure out what we do when we succeed!
|
||||||
|
*/
|
||||||
|
mAppView.loadUrl("javascript:geoLocation.success(" + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
void fail()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -34,12 +34,14 @@ public class GpsListener implements LocationListener {
|
|||||||
private Location cLoc;
|
private Location cLoc;
|
||||||
private LocationManager mLocMan;
|
private LocationManager mLocMan;
|
||||||
private static final String LOG_TAG = "PhoneGap";
|
private static final String LOG_TAG = "PhoneGap";
|
||||||
|
private GeoListener owner;
|
||||||
|
|
||||||
public GpsListener(Context ctx)
|
public GpsListener(Context ctx, int interval, GeoListener m)
|
||||||
{
|
{
|
||||||
|
owner = m;
|
||||||
mCtx = ctx;
|
mCtx = ctx;
|
||||||
mLocMan = (LocationManager) mCtx.getSystemService(Context.LOCATION_SERVICE);
|
mLocMan = (LocationManager) mCtx.getSystemService(Context.LOCATION_SERVICE);
|
||||||
mLocMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 0, this);
|
mLocMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, interval, 0, this);
|
||||||
cLoc = mLocMan.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
cLoc = mLocMan.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,12 +34,14 @@ public class NetworkListener implements LocationListener {
|
|||||||
private Location cLoc;
|
private Location cLoc;
|
||||||
private LocationManager mLocMan;
|
private LocationManager mLocMan;
|
||||||
private static final String LOG_TAG = "PhoneGap";
|
private static final String LOG_TAG = "PhoneGap";
|
||||||
|
GeoListener owner;
|
||||||
|
|
||||||
public NetworkListener(Context ctx)
|
public NetworkListener(Context ctx, int interval, GeoListener m)
|
||||||
{
|
{
|
||||||
|
owner = m;
|
||||||
mCtx = ctx;
|
mCtx = ctx;
|
||||||
mLocMan = (LocationManager) mCtx.getSystemService(Context.LOCATION_SERVICE);
|
mLocMan = (LocationManager) mCtx.getSystemService(Context.LOCATION_SERVICE);
|
||||||
mLocMan.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000, 0, this);
|
mLocMan.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, interval, 0, this);
|
||||||
cLoc = mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
cLoc = mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,8 +57,7 @@ public class PhoneGap{
|
|||||||
this.mCtx = ctx;
|
this.mCtx = ctx;
|
||||||
this.mHandler = handler;
|
this.mHandler = handler;
|
||||||
this.mAppView = appView;
|
this.mAppView = appView;
|
||||||
mGps = new GpsListener(ctx);
|
|
||||||
mNetwork = new NetworkListener(ctx);
|
|
||||||
mSmsListener = new SmsListener(ctx,mAppView);
|
mSmsListener = new SmsListener(ctx,mAppView);
|
||||||
fileManager = new DirectoryManager();
|
fileManager = new DirectoryManager();
|
||||||
audio = new AudioHandler("/sdcard/tmprecording.mp3", ctx);
|
audio = new AudioHandler("/sdcard/tmprecording.mp3", ctx);
|
||||||
@ -90,8 +89,6 @@ public class PhoneGap{
|
|||||||
vibrator.vibrate(pattern);
|
vibrator.vibrate(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void getLocation( ){
|
public void getLocation( ){
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -114,13 +111,6 @@ public class PhoneGap{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String outputText(){
|
|
||||||
String test = "<p>Test</p>";
|
|
||||||
return test;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getUuid()
|
public String getUuid()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user