Skip to content

Commit

Permalink
stopped the page reloading when the G1 keyboard is flipped out.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ray Vahey authored and Ray Vahey committed Mar 9, 2009
1 parent b3fa81d commit 1e1e208
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 29 deletions.
2 changes: 1 addition & 1 deletion android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true">
<activity android:name=".DroidGap"
android:label="@string/app_name">
android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
4 changes: 2 additions & 2 deletions android/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@
$('posdur').value = Device.audio.getDuration($('audioFile').value);
}else
if (func == 'setEarpiece') {
Device.audio.setAudioOutputDevice(func);
Device.audio.setAudioOutputDevice(1);
} else
if (func == 'setSpeaker') {
Device.audio.setAudioOutputDevice(func);
Device.audio.setAudioOutputDevice(2);
}else
if (func == 'getAudioOutputDevice') {
$('audoutput').value = Device.audio.getAudioOutputDevice();
Expand Down
24 changes: 12 additions & 12 deletions android/src/com/nitobi/phonegap/AudioHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public AudioHandler(String file, Context ctx) {
this.mCtx = ctx;
}

public void startRecording(String file){
protected void startRecording(String file){
if (!isRecording){
saveFile=file;
recorder = new MediaRecorder();
Expand All @@ -46,7 +46,7 @@ private void moveFile(String file) {
f.renameTo(new File("/sdcard" + file));
}

public void stopRecording(){
protected void stopRecording(){
try{
if((recorder != null)&&(isRecording))
{
Expand All @@ -58,7 +58,7 @@ public void stopRecording(){
}catch (Exception e){e.printStackTrace();}
}

public void startPlaying(String file) {
protected void startPlaying(String file) {
if (isPlaying==false) {
try {
mPlayer = new MediaPlayer();
Expand All @@ -82,7 +82,7 @@ public void startPlaying(String file) {
}
}

public void stopPlaying() {
protected void stopPlaying() {
if (isPlaying) {
mPlayer.stop();
mPlayer.release();
Expand All @@ -96,7 +96,7 @@ public void onCompletion(MediaPlayer mPlayer) {
isPlaying=false;
}

public long getCurrentPosition() {
protected long getCurrentPosition() {
if (isPlaying)
{
return(mPlayer.getCurrentPosition());
Expand All @@ -112,7 +112,7 @@ private boolean isStreaming(String file)
}
}

public long getDuration(String file) {
protected long getDuration(String file) {
long duration = -2;
if (!isPlaying & !isStreaming(file)) {
try {
Expand Down Expand Up @@ -154,17 +154,17 @@ public boolean onError(MediaPlayer mPlayer, int arg1, int arg2) {
return false;
}

protected void setAudioOutputDevice(String output){
System.out.println ("Change audio setting to be "+output);
protected void setAudioOutputDevice(int output){
// Changes the default audio output device to speaker or earpiece
AudioManager audiMgr = (AudioManager) mCtx.getSystemService(Context.AUDIO_SERVICE);
if (output.contains("Speaker"))
if (output == (2))
audiMgr.setRouting(AudioManager.MODE_NORMAL, AudioManager.ROUTE_SPEAKER, AudioManager.ROUTE_ALL);
else if (output.contains("Earpiece")){
else if (output == (1)){
audiMgr.setRouting(AudioManager.MODE_NORMAL, AudioManager.ROUTE_EARPIECE, AudioManager.ROUTE_ALL);
}else
System.out.println("input error");

Log.e("AudioHandler setAudioOutputDevice", " unknown output device");
}

protected int getAudioOutputDevice(){
AudioManager audiMgr = (AudioManager) mCtx.getSystemService(Context.AUDIO_SERVICE);
if (audiMgr.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_EARPIECE)
Expand Down
13 changes: 5 additions & 8 deletions android/src/com/nitobi/phonegap/DirectoryManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import android.os.Environment;
import android.os.StatFs;
import android.util.Log;

public class DirectoryManager {

Expand All @@ -13,7 +14,6 @@ protected boolean testFileExists (String name){
File path = Environment.getExternalStorageDirectory();
File newPath = constructFilePaths(path.toString(), name);
status = newPath.exists();

}else{
status = false;
}
Expand All @@ -33,7 +33,6 @@ protected long getFreeDiskSpace(){
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
freeSpace = availableBlocks*blockSize/1024;

} catch (Exception e) {e.printStackTrace(); }
} else { return -1; }
return (freeSpace);
Expand Down Expand Up @@ -71,17 +70,15 @@ protected boolean deleteDirectory(String fileName){
File newPath = constructFilePaths(path.toString(), fileName);
checker.checkDelete(newPath.toString());
if(newPath.isDirectory()){
System.out.println("Dir = "+ fileName);
String[] listfile = newPath.list();

// delete all files within the specified directory and then delete the directory
try{
for (int i=0; i < listfile.length; i++){
System.out.println(listfile[i].toString()+" length = "+listfile.length);
File deletedFile = new File (newPath.toString()+"/"+listfile[i].toString());
deletedFile.delete();
}

newPath.delete();
Log.i("DirectoryManager deleteDirectory", fileName);
status = true;
}catch (Exception e){
e.printStackTrace();
Expand All @@ -93,8 +90,8 @@ protected boolean deleteDirectory(String fileName){
}else
status = false;
return status;

}

protected boolean deleteFile(String fileName){
boolean status;
SecurityManager checker = new SecurityManager();
Expand All @@ -106,7 +103,7 @@ protected boolean deleteFile(String fileName){
checker.checkDelete(newPath.toString());
if (newPath.isFile()){
try {
System.out.println("deleting the file");
Log.i("DirectoryManager deleteFile", fileName);
newPath.delete();
status = true;
}catch (SecurityException se){
Expand Down
9 changes: 7 additions & 2 deletions android/src/com/nitobi/phonegap/DroidGap.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
Expand Down Expand Up @@ -64,8 +65,12 @@ public void onCreate(Bundle savedInstanceState) {
appView.loadUrl("file:///android_asset/index.html");

}



@Override
public void onConfigurationChanged(Configuration newConfig) {
//don't reload the current page when the orientation is changed
super.onConfigurationChanged(newConfig);
}

private void bindBrowser(WebView appView)
{
Expand Down
2 changes: 1 addition & 1 deletion android/src/com/nitobi/phonegap/HttpHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class HttpHandler {

public Boolean get(String url, String file)
protected Boolean get(String url, String file)
{
HttpEntity entity = getHttpEntity(url);
try {
Expand Down
4 changes: 2 additions & 2 deletions android/src/com/nitobi/phonegap/PhoneGap.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ public int testSaveLocationExists(){
}

public long getFreeDiskSpace(){
System.out.println("FOOOOOOOO");
long freeDiskSpace=fileManager.getFreeDiskSpace();
return freeDiskSpace;
}
Expand Down Expand Up @@ -357,9 +356,10 @@ public long getDurationAudio(String file)
return(audio.getDuration(file));
}

public void setAudioOutputDevice(String output){
public void setAudioOutputDevice(int output){
audio.setAudioOutputDevice(output);
}

public int getAudioOutputDevice(){
return audio.getAudioOutputDevice();
}
Expand Down
2 changes: 1 addition & 1 deletion android/src/com/nitobi/phonegap/SmsListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void onReceive(Context ctx, Intent intent)
}
}

public void onReceiveSMS(String sendersNumber, String smsContent)
protected void onReceiveSMS(String sendersNumber, String smsContent)
/**
* Call back to Java Script
*/
Expand Down

0 comments on commit 1e1e208

Please sign in to comment.