Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 788a29c

Browse files
committed
Merge branch 'master' of github.com:phonegap/phonegap
2 parents b55c8cd + c04000a commit 788a29c

7 files changed

Lines changed: 51 additions & 92 deletions

File tree

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
PhoneGap
33
=============================================================
44
PhoneGap is a development tool that allows web developers to
5-
take advantage of the core features in the iPhone and Android
6-
SDK using JavaScript.
5+
take advantage of the core features in the iPhone, Android,
6+
BlackBerry, and Symbian WRT (Nokia) SDK using JavaScript.
77

88

99
Get Started
1010
-------------------------------------------------------------
1111
Download the source.
1212

13-
git clone git://github.com/sintaxi/phonegap.git
13+
git clone git://github.com/phonegap/phonegap.git
1414

1515
PhoneGap project is separated into a native project for each
1616
device, javascript files and a rakefile.
@@ -21,6 +21,8 @@ device, javascript files and a rakefile.
2121
|- android/
2222
|- blackberry/
2323
|- iphone/
24+
|- symbian.wrt/
25+
|- winmo/
2426
`- javascripts/
2527
2628
Each project has a respective README.md file. view that file
@@ -80,8 +82,9 @@ Community
8082
-------------------------------------------------------------
8183
* Website - [phonegap.com](http://phonegap.com)
8284
* Google Group - [groups.google.com/group/phonegap](http://groups.google.com/group/phonegap)
83-
* Wiki - [phonegap.pbwiki.com/](http://phonegap.pbwiki.com/)
85+
* Wiki - [phonegap.pbworks.com/](http://phonegap.pbworks.com/)
8486
* Twitter - [twitter.com/phonegap](http://twitter.com/phonegap)
87+
* Issue Tracker [phonegap.lighthouseapp.com](http://phonegap.lighthouseapp.com/)
8588

8689

8790
The MIT License

android/src/com/phonegap/AccelListener.java

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
package com.phonegap;
22

3-
import static android.hardware.SensorManager.DATA_X;
4-
import static android.hardware.SensorManager.DATA_Y;
5-
import static android.hardware.SensorManager.DATA_Z;
3+
4+
import java.util.List;
5+
6+
import android.hardware.Sensor;
7+
import android.hardware.SensorEvent;
8+
import android.hardware.SensorEventListener;
69
import android.hardware.SensorManager;
710
import android.content.Context;
8-
import android.hardware.SensorListener;
911
import android.webkit.WebView;
1012

11-
@SuppressWarnings("deprecation")
12-
public class AccelListener implements SensorListener{
13+
public class AccelListener implements SensorEventListener{
1314

1415
WebView mAppView;
1516
Context mCtx;
1617
String mKey;
18+
Sensor mSensor;
1719
int mTime = 10000;
1820
boolean started = false;
1921

@@ -26,16 +28,21 @@ public class AccelListener implements SensorListener{
2628
mCtx = ctx;
2729
mAppView = appView;
2830
sensorManager = (SensorManager) mCtx.getSystemService(Context.SENSOR_SERVICE);
31+
2932
}
3033

3134
public void start(int time)
3235
{
3336
mTime = time;
34-
if (!started)
37+
List<Sensor> list = this.sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
38+
if (list.size() > 0)
3539
{
36-
sensorManager.registerListener(this,
37-
SensorManager.SENSOR_ACCELEROMETER,
38-
SensorManager.SENSOR_DELAY_GAME);
40+
this.mSensor = list.get(0);
41+
this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_NORMAL);
42+
}
43+
else
44+
{
45+
// Call fail
3946
}
4047
}
4148

@@ -45,23 +52,25 @@ public void stop()
4552
sensorManager.unregisterListener(this);
4653
}
4754

48-
public void onAccuracyChanged(int sensor, int accuracy) {
49-
// This should call the FAIL method
50-
}
5155

52-
public void onSensorChanged(int sensor, float[] values) {
53-
if (sensor != SensorManager.SENSOR_ACCELEROMETER || values.length < 3)
54-
return;
56+
57+
public void onAccuracyChanged(Sensor sensor, int accuracy) {
58+
// TODO Auto-generated method stub
59+
60+
}
61+
62+
public void onSensorChanged(SensorEvent event) {
63+
if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER)
64+
return;
5565
long curTime = System.currentTimeMillis();
56-
if (lastUpdate == -1 || (curTime - lastUpdate) > mTime) {
57-
66+
if (lastUpdate == -1 || (curTime - lastUpdate) > mTime) {
5867
lastUpdate = curTime;
59-
60-
float x = values[DATA_X];
61-
float y = values[DATA_Y];
62-
float z = values[DATA_Z];
68+
69+
float x = event.values[0];
70+
float y = event.values[1];
71+
float z = event.values[2];
6372
mAppView.loadUrl("javascript:gotAccel(" + x + ", " + y + "," + z + " )");
64-
}
73+
}
6574
}
6675

6776

android/src/com/phonegap/AccelTuple.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

android/src/com/phonegap/DroidGap.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class DroidGap extends Activity {
5151
private ContactManager mContacts;
5252
private FileUtils fs;
5353
private NetworkManager netMan;
54+
private CompassListener mCompass;
5455

5556
/** Called when the activity is first created. */
5657
@Override
@@ -109,6 +110,7 @@ private void bindBrowser(WebView appView)
109110
mContacts = new ContactManager(this, appView);
110111
fs = new FileUtils(appView);
111112
netMan = new NetworkManager(this, appView);
113+
mCompass = new CompassListener(this, appView);
112114

113115
// This creates the new javascript interfaces for PhoneGap
114116
appView.addJavascriptInterface(gap, "DroidGap");
@@ -118,6 +120,7 @@ private void bindBrowser(WebView appView)
118120
appView.addJavascriptInterface(mContacts, "ContactHook");
119121
appView.addJavascriptInterface(fs, "FileUtil");
120122
appView.addJavascriptInterface(netMan, "NetworkManager");
123+
appView.addJavascriptInterface(mCompass, "CompassHook");
121124
}
122125

123126
/**

android/src/com/phonegap/GeoTuple.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

iphone/Classes/JSON/NSObject+SBJSON.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ @implementation NSObject (NSObject_SBJSON)
3535
- (NSString *)JSONFragment {
3636
SBJsonWriter *jsonWriter = [SBJsonWriter new];
3737
NSString *json = [jsonWriter stringWithFragment:self];
38-
if (json)
38+
if (json == nil)
3939
NSLog(@"-JSONFragment failed. Error trace is: %@", [jsonWriter errorTrace]);
4040
[jsonWriter release];
4141
return json;
@@ -44,7 +44,7 @@ - (NSString *)JSONFragment {
4444
- (NSString *)JSONRepresentation {
4545
SBJsonWriter *jsonWriter = [SBJsonWriter new];
4646
NSString *json = [jsonWriter stringWithObject:self];
47-
if (json)
47+
if (json == nil)
4848
NSLog(@"-JSONRepresentation failed. Error trace is: %@", [jsonWriter errorTrace]);
4949
[jsonWriter release];
5050
return json;

iphone/Classes/Sound.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ - (AudioFile*) audioFileForResource:(NSString*) resourcePath
6363
if (audioFile == nil) {
6464
NSError *error;
6565

66-
audioFile = [[AudioFile alloc] init];
66+
audioFile = [[[AudioFile alloc] init] autorelease];
6767
audioFile.resourcePath = resourcePath;
6868
audioFile.resourceURL = resourceURL;
6969

@@ -102,7 +102,6 @@ - (void) prepare:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)optio
102102
audioFile.player.delegate = self;
103103
[audioFile.player prepareToPlay];
104104
}
105-
[audioFile release];
106105
}
107106

108107
- (void) play:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
@@ -118,7 +117,13 @@ - (void) play:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
118117
if (audioFile.player != nil) {
119118
NSLog(@"Playing audio sample '%@'", audioFile.resourcePath);
120119
audioFile.player.numberOfLoops = numberOfLoops;
120+
121+
if(audioFile.player.isPlaying){
122+
[audioFile.player stop];
123+
audioFile.player.currentTime = 0;
124+
}
121125
[audioFile.player play];
126+
122127
} else {
123128
NSError* error;
124129
// try loading it one more time, in case the file was recorded previously

0 commit comments

Comments
 (0)