stopped the page reloading when the G1 keyboard is flipped out.

This commit is contained in:
Ray Vahey 2009-03-09 17:28:07 +07:00
parent 49844b4e39
commit d758397df0
8 changed files with 31 additions and 29 deletions

View File

@ -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" />

View File

@ -152,10 +152,10 @@ audio = function(func)
$('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();

View File

@ -26,7 +26,7 @@ public class AudioHandler implements OnCompletionListener, OnPreparedListener, O
this.mCtx = ctx;
}
public void startRecording(String file){
protected void startRecording(String file){
if (!isRecording){
saveFile=file;
recorder = new MediaRecorder();
@ -46,7 +46,7 @@ public class AudioHandler implements OnCompletionListener, OnPreparedListener, O
f.renameTo(new File("/sdcard" + file));
}
public void stopRecording(){
protected void stopRecording(){
try{
if((recorder != null)&&(isRecording))
{
@ -58,7 +58,7 @@ public class AudioHandler implements OnCompletionListener, OnPreparedListener, O
}catch (Exception e){e.printStackTrace();}
}
public void startPlaying(String file) {
protected void startPlaying(String file) {
if (isPlaying==false) {
try {
mPlayer = new MediaPlayer();
@ -82,7 +82,7 @@ public class AudioHandler implements OnCompletionListener, OnPreparedListener, O
}
}
public void stopPlaying() {
protected void stopPlaying() {
if (isPlaying) {
mPlayer.stop();
mPlayer.release();
@ -96,7 +96,7 @@ public class AudioHandler implements OnCompletionListener, OnPreparedListener, O
isPlaying=false;
}
public long getCurrentPosition() {
protected long getCurrentPosition() {
if (isPlaying)
{
return(mPlayer.getCurrentPosition());
@ -112,7 +112,7 @@ public class AudioHandler implements OnCompletionListener, OnPreparedListener, O
}
}
public long getDuration(String file) {
protected long getDuration(String file) {
long duration = -2;
if (!isPlaying & !isStreaming(file)) {
try {
@ -154,17 +154,17 @@ public class AudioHandler implements OnCompletionListener, OnPreparedListener, O
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)

View File

@ -4,6 +4,7 @@ import java.io.File;
import android.os.Environment;
import android.os.StatFs;
import android.util.Log;
public class DirectoryManager {
@ -13,7 +14,6 @@ public class DirectoryManager {
File path = Environment.getExternalStorageDirectory();
File newPath = constructFilePaths(path.toString(), name);
status = newPath.exists();
}else{
status = false;
}
@ -33,7 +33,6 @@ public class DirectoryManager {
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
freeSpace = availableBlocks*blockSize/1024;
} catch (Exception e) {e.printStackTrace(); }
} else { return -1; }
return (freeSpace);
@ -71,17 +70,15 @@ public class DirectoryManager {
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();
@ -93,8 +90,8 @@ public class DirectoryManager {
}else
status = false;
return status;
}
protected boolean deleteFile(String fileName){
boolean status;
SecurityManager checker = new SecurityManager();
@ -106,7 +103,7 @@ public class DirectoryManager {
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){

View File

@ -23,6 +23,7 @@ package com.nitobi.phonegap;
*/
import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
@ -65,7 +66,11 @@ public class DroidGap extends Activity {
}
@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)
{

View File

@ -11,7 +11,7 @@ import org.apache.http.impl.client.DefaultHttpClient;
public class HttpHandler {
public Boolean get(String url, String file)
protected Boolean get(String url, String file)
{
HttpEntity entity = getHttpEntity(url);
try {

View File

@ -261,7 +261,6 @@ public class PhoneGap{
}
public long getFreeDiskSpace(){
System.out.println("FOOOOOOOO");
long freeDiskSpace=fileManager.getFreeDiskSpace();
return freeDiskSpace;
}
@ -357,9 +356,10 @@ public class PhoneGap{
return(audio.getDuration(file));
}
public void setAudioOutputDevice(String output){
public void setAudioOutputDevice(int output){
audio.setAudioOutputDevice(output);
}
public int getAudioOutputDevice(){
return audio.getAudioOutputDevice();
}

View File

@ -36,7 +36,7 @@ public class SmsListener extends BroadcastReceiver
}
}
public void onReceiveSMS(String sendersNumber, String smsContent)
protected void onReceiveSMS(String sendersNumber, String smsContent)
/**
* Call back to Java Script
*/