mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 02:12:58 +08:00
changed 'deviceReady' to 'deviceready' in index.html. fixed up the file utils a bit so that they sort of work.
This commit is contained in:
parent
d6e79f158f
commit
d2048a7c5a
@ -113,7 +113,7 @@
|
|||||||
|
|
||||||
function init(){
|
function init(){
|
||||||
document.addEventListener("touchmove", preventBehavior, false);
|
document.addEventListener("touchmove", preventBehavior, false);
|
||||||
document.addEventListener("deviceReady", deviceInfo, true);
|
document.addEventListener("deviceready", deviceInfo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ FileMgr.prototype.createDirectory = function(dirName, successCallback, errorCall
|
|||||||
{
|
{
|
||||||
this.successCallback = successCallback;
|
this.successCallback = successCallback;
|
||||||
this.errorCallback = errorCallback;
|
this.errorCallback = errorCallback;
|
||||||
var test = FileUtils.createDirectory(dirName);
|
var test = FileUtil.createDirectory(dirName);
|
||||||
test ? successCallback() : errorCallback();
|
test ? successCallback() : errorCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ FileMgr.prototype.deleteDirectory = function(dirName, successCallback, errorCall
|
|||||||
{
|
{
|
||||||
this.successCallback = successCallback;
|
this.successCallback = successCallback;
|
||||||
this.errorCallback = errorCallback;
|
this.errorCallback = errorCallback;
|
||||||
var test = FileUtils.deleteDirectory(dirName);
|
var test = FileUtil.deleteDirectory(dirName);
|
||||||
test ? successCallback() : errorCallback();
|
test ? successCallback() : errorCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ FileMgr.prototype.deleteFile = function(fileName, successCallback, errorCallback
|
|||||||
{
|
{
|
||||||
this.successCallback = successCallback;
|
this.successCallback = successCallback;
|
||||||
this.errorCallback = errorCallback;
|
this.errorCallback = errorCallback;
|
||||||
FileUtils.deleteFile(fileName);
|
FileUtil.deleteFile(fileName);
|
||||||
test ? successCallback() : errorCallback();
|
test ? successCallback() : errorCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ FileMgr.prototype.getFreeDiskSpace = function(successCallback, errorCallback)
|
|||||||
{
|
{
|
||||||
this.successCallback = successCallback;
|
this.successCallback = successCallback;
|
||||||
this.errorCallback = errorCallback;
|
this.errorCallback = errorCallback;
|
||||||
this.freeDiskSpace = FileUtils.getFreeDiskSpace();
|
this.freeDiskSpace = FileUtil.getFreeDiskSpace();
|
||||||
(this.freeDiskSpace > 0) ? successCallback() : errorCallback();
|
(this.freeDiskSpace > 0) ? successCallback() : errorCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
public class DirectoryManager {
|
public class DirectoryManager {
|
||||||
|
|
||||||
protected boolean testFileExists (String name){
|
protected static boolean testFileExists (String name){
|
||||||
boolean status;
|
boolean status;
|
||||||
if ((testSaveLocationExists())&&(!name.equals(""))){
|
if ((testSaveLocationExists())&&(!name.equals(""))){
|
||||||
File path = Environment.getExternalStorageDirectory();
|
File path = Environment.getExternalStorageDirectory();
|
||||||
@ -20,7 +20,7 @@ public class DirectoryManager {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected long getFreeDiskSpace(){
|
protected static long getFreeDiskSpace(){
|
||||||
/*
|
/*
|
||||||
* gets the available SD card free space or returns -1 if the SD card is not mounted.
|
* gets the available SD card free space or returns -1 if the SD card is not mounted.
|
||||||
*/
|
*/
|
||||||
@ -38,7 +38,7 @@ public class DirectoryManager {
|
|||||||
return (freeSpace);
|
return (freeSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean createDirectory(String directoryName){
|
protected static boolean createDirectory(String directoryName){
|
||||||
boolean status;
|
boolean status;
|
||||||
if ((testSaveLocationExists())&&(!directoryName.equals(""))){
|
if ((testSaveLocationExists())&&(!directoryName.equals(""))){
|
||||||
File path = Environment.getExternalStorageDirectory();
|
File path = Environment.getExternalStorageDirectory();
|
||||||
@ -50,7 +50,7 @@ public class DirectoryManager {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean testSaveLocationExists(){
|
protected static boolean testSaveLocationExists(){
|
||||||
String sDCardStatus = Environment.getExternalStorageState();
|
String sDCardStatus = Environment.getExternalStorageState();
|
||||||
boolean status;
|
boolean status;
|
||||||
if (sDCardStatus.equals(Environment.MEDIA_MOUNTED)){
|
if (sDCardStatus.equals(Environment.MEDIA_MOUNTED)){
|
||||||
@ -60,7 +60,7 @@ public class DirectoryManager {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean deleteDirectory(String fileName){
|
protected static boolean deleteDirectory(String fileName){
|
||||||
boolean status;
|
boolean status;
|
||||||
SecurityManager checker = new SecurityManager();
|
SecurityManager checker = new SecurityManager();
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ public class DirectoryManager {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean deleteFile(String fileName){
|
protected static boolean deleteFile(String fileName){
|
||||||
boolean status;
|
boolean status;
|
||||||
SecurityManager checker = new SecurityManager();
|
SecurityManager checker = new SecurityManager();
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ public class DirectoryManager {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
private File constructFilePaths (String file1, String file2){
|
private static File constructFilePaths (String file1, String file2){
|
||||||
File newPath;
|
File newPath;
|
||||||
newPath = new File(file1+"/"+file2);
|
newPath = new File(file1+"/"+file2);
|
||||||
return newPath;
|
return newPath;
|
||||||
|
@ -8,7 +8,6 @@ public class FileUtils {
|
|||||||
|
|
||||||
|
|
||||||
WebView mView;
|
WebView mView;
|
||||||
DirectoryManager fileManager;
|
|
||||||
FileReader f_in;
|
FileReader f_in;
|
||||||
FileWriter f_out;
|
FileWriter f_out;
|
||||||
|
|
||||||
@ -18,26 +17,26 @@ public class FileUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int testSaveLocationExists(){
|
public int testSaveLocationExists(){
|
||||||
if (fileManager.testSaveLocationExists())
|
if (DirectoryManager.testSaveLocationExists())
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getFreeDiskSpace(){
|
public long getFreeDiskSpace(){
|
||||||
long freeDiskSpace=fileManager.getFreeDiskSpace();
|
long freeDiskSpace=DirectoryManager.getFreeDiskSpace();
|
||||||
return freeDiskSpace;
|
return freeDiskSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int testFileExists(String file){
|
public int testFileExists(String file){
|
||||||
if (fileManager.testFileExists(file))
|
if (DirectoryManager.testFileExists(file))
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int testDirectoryExists(String file){
|
public int testDirectoryExists(String file){
|
||||||
if (fileManager.testFileExists(file))
|
if (DirectoryManager.testFileExists(file))
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
@ -49,7 +48,7 @@ public class FileUtils {
|
|||||||
* TODO: JavaScript Call backs for success and error handling
|
* TODO: JavaScript Call backs for success and error handling
|
||||||
*/
|
*/
|
||||||
public int deleteDirectory (String dir){
|
public int deleteDirectory (String dir){
|
||||||
if (fileManager.deleteDirectory(dir))
|
if (DirectoryManager.deleteDirectory(dir))
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
@ -61,7 +60,7 @@ public class FileUtils {
|
|||||||
* TODO: JavaScript Call backs for success and error handling
|
* TODO: JavaScript Call backs for success and error handling
|
||||||
*/
|
*/
|
||||||
public int deleteFile (String file){
|
public int deleteFile (String file){
|
||||||
if (fileManager.deleteFile(file))
|
if (DirectoryManager.deleteFile(file))
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
@ -73,7 +72,7 @@ public class FileUtils {
|
|||||||
* TODO: JavaScript Call backs for success and error handling
|
* TODO: JavaScript Call backs for success and error handling
|
||||||
*/
|
*/
|
||||||
public int createDirectory(String dir){
|
public int createDirectory(String dir){
|
||||||
if (fileManager.createDirectory(dir))
|
if (DirectoryManager.createDirectory(dir))
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user