mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-25 19:32:54 +08:00
stopped the page reloading when the G1 keyboard is flipped out.
This commit is contained in:
parent
49844b4e39
commit
d758397df0
@ -19,7 +19,7 @@
|
|||||||
<application android:icon="@drawable/icon" android:label="@string/app_name"
|
<application android:icon="@drawable/icon" android:label="@string/app_name"
|
||||||
android:debuggable="true">
|
android:debuggable="true">
|
||||||
<activity android:name=".DroidGap"
|
<activity android:name=".DroidGap"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
@ -152,10 +152,10 @@ audio = function(func)
|
|||||||
$('posdur').value = Device.audio.getDuration($('audioFile').value);
|
$('posdur').value = Device.audio.getDuration($('audioFile').value);
|
||||||
}else
|
}else
|
||||||
if (func == 'setEarpiece') {
|
if (func == 'setEarpiece') {
|
||||||
Device.audio.setAudioOutputDevice(func);
|
Device.audio.setAudioOutputDevice(1);
|
||||||
} else
|
} else
|
||||||
if (func == 'setSpeaker') {
|
if (func == 'setSpeaker') {
|
||||||
Device.audio.setAudioOutputDevice(func);
|
Device.audio.setAudioOutputDevice(2);
|
||||||
}else
|
}else
|
||||||
if (func == 'getAudioOutputDevice') {
|
if (func == 'getAudioOutputDevice') {
|
||||||
$('audoutput').value = Device.audio.getAudioOutputDevice();
|
$('audoutput').value = Device.audio.getAudioOutputDevice();
|
||||||
|
@ -26,7 +26,7 @@ public class AudioHandler implements OnCompletionListener, OnPreparedListener, O
|
|||||||
this.mCtx = ctx;
|
this.mCtx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startRecording(String file){
|
protected void startRecording(String file){
|
||||||
if (!isRecording){
|
if (!isRecording){
|
||||||
saveFile=file;
|
saveFile=file;
|
||||||
recorder = new MediaRecorder();
|
recorder = new MediaRecorder();
|
||||||
@ -46,7 +46,7 @@ public class AudioHandler implements OnCompletionListener, OnPreparedListener, O
|
|||||||
f.renameTo(new File("/sdcard" + file));
|
f.renameTo(new File("/sdcard" + file));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopRecording(){
|
protected void stopRecording(){
|
||||||
try{
|
try{
|
||||||
if((recorder != null)&&(isRecording))
|
if((recorder != null)&&(isRecording))
|
||||||
{
|
{
|
||||||
@ -58,7 +58,7 @@ public class AudioHandler implements OnCompletionListener, OnPreparedListener, O
|
|||||||
}catch (Exception e){e.printStackTrace();}
|
}catch (Exception e){e.printStackTrace();}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startPlaying(String file) {
|
protected void startPlaying(String file) {
|
||||||
if (isPlaying==false) {
|
if (isPlaying==false) {
|
||||||
try {
|
try {
|
||||||
mPlayer = new MediaPlayer();
|
mPlayer = new MediaPlayer();
|
||||||
@ -82,7 +82,7 @@ public class AudioHandler implements OnCompletionListener, OnPreparedListener, O
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopPlaying() {
|
protected void stopPlaying() {
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
mPlayer.stop();
|
mPlayer.stop();
|
||||||
mPlayer.release();
|
mPlayer.release();
|
||||||
@ -96,7 +96,7 @@ public class AudioHandler implements OnCompletionListener, OnPreparedListener, O
|
|||||||
isPlaying=false;
|
isPlaying=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCurrentPosition() {
|
protected long getCurrentPosition() {
|
||||||
if (isPlaying)
|
if (isPlaying)
|
||||||
{
|
{
|
||||||
return(mPlayer.getCurrentPosition());
|
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;
|
long duration = -2;
|
||||||
if (!isPlaying & !isStreaming(file)) {
|
if (!isPlaying & !isStreaming(file)) {
|
||||||
try {
|
try {
|
||||||
@ -154,17 +154,17 @@ public class AudioHandler implements OnCompletionListener, OnPreparedListener, O
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setAudioOutputDevice(String output){
|
protected void setAudioOutputDevice(int output){
|
||||||
System.out.println ("Change audio setting to be "+output);
|
// Changes the default audio output device to speaker or earpiece
|
||||||
AudioManager audiMgr = (AudioManager) mCtx.getSystemService(Context.AUDIO_SERVICE);
|
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);
|
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);
|
audiMgr.setRouting(AudioManager.MODE_NORMAL, AudioManager.ROUTE_EARPIECE, AudioManager.ROUTE_ALL);
|
||||||
}else
|
}else
|
||||||
System.out.println("input error");
|
Log.e("AudioHandler setAudioOutputDevice", " unknown output device");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getAudioOutputDevice(){
|
protected int getAudioOutputDevice(){
|
||||||
AudioManager audiMgr = (AudioManager) mCtx.getSystemService(Context.AUDIO_SERVICE);
|
AudioManager audiMgr = (AudioManager) mCtx.getSystemService(Context.AUDIO_SERVICE);
|
||||||
if (audiMgr.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_EARPIECE)
|
if (audiMgr.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_EARPIECE)
|
||||||
|
@ -4,6 +4,7 @@ import java.io.File;
|
|||||||
|
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.StatFs;
|
import android.os.StatFs;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
public class DirectoryManager {
|
public class DirectoryManager {
|
||||||
|
|
||||||
@ -13,7 +14,6 @@ public class DirectoryManager {
|
|||||||
File path = Environment.getExternalStorageDirectory();
|
File path = Environment.getExternalStorageDirectory();
|
||||||
File newPath = constructFilePaths(path.toString(), name);
|
File newPath = constructFilePaths(path.toString(), name);
|
||||||
status = newPath.exists();
|
status = newPath.exists();
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
status = false;
|
status = false;
|
||||||
}
|
}
|
||||||
@ -33,7 +33,6 @@ public class DirectoryManager {
|
|||||||
long blockSize = stat.getBlockSize();
|
long blockSize = stat.getBlockSize();
|
||||||
long availableBlocks = stat.getAvailableBlocks();
|
long availableBlocks = stat.getAvailableBlocks();
|
||||||
freeSpace = availableBlocks*blockSize/1024;
|
freeSpace = availableBlocks*blockSize/1024;
|
||||||
|
|
||||||
} catch (Exception e) {e.printStackTrace(); }
|
} catch (Exception e) {e.printStackTrace(); }
|
||||||
} else { return -1; }
|
} else { return -1; }
|
||||||
return (freeSpace);
|
return (freeSpace);
|
||||||
@ -71,17 +70,15 @@ public class DirectoryManager {
|
|||||||
File newPath = constructFilePaths(path.toString(), fileName);
|
File newPath = constructFilePaths(path.toString(), fileName);
|
||||||
checker.checkDelete(newPath.toString());
|
checker.checkDelete(newPath.toString());
|
||||||
if(newPath.isDirectory()){
|
if(newPath.isDirectory()){
|
||||||
System.out.println("Dir = "+ fileName);
|
|
||||||
String[] listfile = newPath.list();
|
String[] listfile = newPath.list();
|
||||||
|
// delete all files within the specified directory and then delete the directory
|
||||||
try{
|
try{
|
||||||
for (int i=0; i < listfile.length; i++){
|
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());
|
File deletedFile = new File (newPath.toString()+"/"+listfile[i].toString());
|
||||||
deletedFile.delete();
|
deletedFile.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
newPath.delete();
|
newPath.delete();
|
||||||
|
Log.i("DirectoryManager deleteDirectory", fileName);
|
||||||
status = true;
|
status = true;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -93,8 +90,8 @@ public class DirectoryManager {
|
|||||||
}else
|
}else
|
||||||
status = false;
|
status = false;
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean deleteFile(String fileName){
|
protected boolean deleteFile(String fileName){
|
||||||
boolean status;
|
boolean status;
|
||||||
SecurityManager checker = new SecurityManager();
|
SecurityManager checker = new SecurityManager();
|
||||||
@ -106,7 +103,7 @@ public class DirectoryManager {
|
|||||||
checker.checkDelete(newPath.toString());
|
checker.checkDelete(newPath.toString());
|
||||||
if (newPath.isFile()){
|
if (newPath.isFile()){
|
||||||
try {
|
try {
|
||||||
System.out.println("deleting the file");
|
Log.i("DirectoryManager deleteFile", fileName);
|
||||||
newPath.delete();
|
newPath.delete();
|
||||||
status = true;
|
status = true;
|
||||||
}catch (SecurityException se){
|
}catch (SecurityException se){
|
||||||
|
@ -23,6 +23,7 @@ package com.nitobi.phonegap;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -64,8 +65,12 @@ public class DroidGap extends Activity {
|
|||||||
appView.loadUrl("file:///android_asset/index.html");
|
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)
|
private void bindBrowser(WebView appView)
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ import org.apache.http.impl.client.DefaultHttpClient;
|
|||||||
|
|
||||||
public class HttpHandler {
|
public class HttpHandler {
|
||||||
|
|
||||||
public Boolean get(String url, String file)
|
protected Boolean get(String url, String file)
|
||||||
{
|
{
|
||||||
HttpEntity entity = getHttpEntity(url);
|
HttpEntity entity = getHttpEntity(url);
|
||||||
try {
|
try {
|
||||||
|
@ -261,7 +261,6 @@ public class PhoneGap{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long getFreeDiskSpace(){
|
public long getFreeDiskSpace(){
|
||||||
System.out.println("FOOOOOOOO");
|
|
||||||
long freeDiskSpace=fileManager.getFreeDiskSpace();
|
long freeDiskSpace=fileManager.getFreeDiskSpace();
|
||||||
return freeDiskSpace;
|
return freeDiskSpace;
|
||||||
}
|
}
|
||||||
@ -357,9 +356,10 @@ public class PhoneGap{
|
|||||||
return(audio.getDuration(file));
|
return(audio.getDuration(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAudioOutputDevice(String output){
|
public void setAudioOutputDevice(int output){
|
||||||
audio.setAudioOutputDevice(output);
|
audio.setAudioOutputDevice(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAudioOutputDevice(){
|
public int getAudioOutputDevice(){
|
||||||
return audio.getAudioOutputDevice();
|
return audio.getAudioOutputDevice();
|
||||||
}
|
}
|
||||||
|
@ -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
|
* Call back to Java Script
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user