From 8ec0de457f9617b7ccce64130b28dca8ce0c465a Mon Sep 17 00:00:00 2001 From: Dave Johnson Date: Mon, 28 Jun 2010 16:02:10 -0700 Subject: [PATCH 1/5] added target to the droidgap script and updated the readme and getting started wiki page --- README.md | 3 ++- droidgap | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ba2244dd..33fab581 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,10 @@ Getting Started with PhoneGap/Android 1. From the root of this repo run the following command to generate a new PhoneGap/Android app:
    
-    ./droidgap [android_sdk_path] [name] [package_name] [www] [path]
+    ./droidgap [android_sdk_path] [target] [name] [package_name] [www] [path]
 
     android_sdk_path ... The path to your Android SDK install.
+    target ......................The target version of the Android platform (3, 4, 6, 7, 8 correspond to 1.5, 1.6, 2.0.1, 2.1, 2.2).
     name ............... The name of your application.
     package_name ....... The name of your package (For example: com.nitobi.demo)
     www ................ The path to your www folder. (Wherein your HTML, CSS and JS app is.)
diff --git a/droidgap b/droidgap
index 18ea2b6e..af27e1eb 100755
--- a/droidgap
+++ b/droidgap
@@ -3,10 +3,10 @@ require 'fileutils'
 
 # ./droidgap /Users/brianleroux/Code/android-sdk-mac MyApp com.westcoastlogic example /Users/brianleroux/Desktop/MyApp
 class Build
-  attr_reader :android_sdk_path, :name, :pkg, :www, :path
+  attr_reader :android_sdk_path, :name, :pkg, :www, :path, :target_id
   
   def initialize(*a)
-    @android_sdk_path, @name, @pkg, @www, @path = a
+    @android_sdk_path, @target, @name, @pkg, @www, @path = a
     @android_dir = File.expand_path(File.dirname(__FILE__))
     @framework_dir = File.join(@android_dir, "framework")
   end
@@ -44,9 +44,8 @@ class Build
   # TODO fix 'android' shell call so that it works on Windows. Can't prepend android command with path to it.
   def create_android
     android_exec = File.join(@android_sdk_path, "tools", "android");
-    target_id = 5 
     puts "Creating Android project for target level #{ target_id }"
-    `android create project -t #{ target_id } -k #{ @pkg } -a #{ @name } -n #{ @name } -p #{ @path }`
+    `android create project -t #{ @target_id } -k #{ @pkg } -a #{ @name } -n #{ @name } -p #{ @path }`
   end
   
   def include_www

From 5972147e36f83e4675cae0e987f75e9456206e93 Mon Sep 17 00:00:00 2001
From: Dave Johnson 
Date: Mon, 28 Jun 2010 16:19:54 -0700
Subject: [PATCH 2/5] undoing those changes for target on joes' recommendation

---
 README.md | 3 +--
 droidgap  | 7 ++++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 33fab581..ba2244dd 100644
--- a/README.md
+++ b/README.md
@@ -19,10 +19,9 @@ Getting Started with PhoneGap/Android
 1. From the root of this repo run the following command to generate a new PhoneGap/Android app:
 
 
    
-    ./droidgap [android_sdk_path] [target] [name] [package_name] [www] [path]
+    ./droidgap [android_sdk_path] [name] [package_name] [www] [path]
 
     android_sdk_path ... The path to your Android SDK install.
-    target ......................The target version of the Android platform (3, 4, 6, 7, 8 correspond to 1.5, 1.6, 2.0.1, 2.1, 2.2).
     name ............... The name of your application.
     package_name ....... The name of your package (For example: com.nitobi.demo)
     www ................ The path to your www folder. (Wherein your HTML, CSS and JS app is.)
diff --git a/droidgap b/droidgap
index af27e1eb..7c9d9d1e 100755
--- a/droidgap
+++ b/droidgap
@@ -3,10 +3,10 @@ require 'fileutils'
 
 # ./droidgap /Users/brianleroux/Code/android-sdk-mac MyApp com.westcoastlogic example /Users/brianleroux/Desktop/MyApp
 class Build
-  attr_reader :android_sdk_path, :name, :pkg, :www, :path, :target_id
+  attr_reader :android_sdk_path, :name, :pkg, :www, :path
   
   def initialize(*a)
-    @android_sdk_path, @target, @name, @pkg, @www, @path = a
+    @android_sdk_path, @name, @pkg, @www, @path = a
     @android_dir = File.expand_path(File.dirname(__FILE__))
     @framework_dir = File.join(@android_dir, "framework")
   end
@@ -44,8 +44,9 @@ class Build
   # TODO fix 'android' shell call so that it works on Windows. Can't prepend android command with path to it.
   def create_android
     android_exec = File.join(@android_sdk_path, "tools", "android");
+    target_id = 8
     puts "Creating Android project for target level #{ target_id }"
-    `android create project -t #{ @target_id } -k #{ @pkg } -a #{ @name } -n #{ @name } -p #{ @path }`
+    `android create project -t #{ target_id } -k #{ @pkg } -a #{ @name } -n #{ @name } -p #{ @path }`
   end
   
   def include_www

From d6e79f158f4c75c8084368148f1b1fe01a28f903 Mon Sep 17 00:00:00 2001
From: Dave Johnson 
Date: Wed, 7 Jul 2010 15:54:33 -0700
Subject: [PATCH 3/5] Beep does not crash your app if there is no notification
 sound

---
 framework/src/com/phonegap/Device.java | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/framework/src/com/phonegap/Device.java b/framework/src/com/phonegap/Device.java
index 074f72f5..922fd01f 100644
--- a/framework/src/com/phonegap/Device.java
+++ b/framework/src/com/phonegap/Device.java
@@ -57,9 +57,11 @@ public class Device{
 	{
 		Uri ringtone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
 		Ringtone notification = RingtoneManager.getRingtone(mCtx, ringtone);
-		for (long i = 0; i < pattern; ++i)
-		{
-			notification.play();
+		if (notification != null) { // This will be the case when the phone is set to silent for example
+			for (long i = 0; i < pattern; ++i)
+			{
+				notification.play();
+			}
 		}
 	}
 	

From ac952b25bb02b57600312f869ac16178e06fde62 Mon Sep 17 00:00:00 2001
From: Jan Monschke 
Date: Fri, 9 Jul 2010 00:13:55 +0200
Subject: [PATCH 4/5] this should fix the windows encoding bug described here:
 http://phonegap.lighthouseapp.com/projects/20118-android/tickets/23

---
 framework/src/com/phonegap/GpsListener.java     | 4 ++--
 framework/src/com/phonegap/NetworkListener.java | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/framework/src/com/phonegap/GpsListener.java b/framework/src/com/phonegap/GpsListener.java
index 1b60a7df..a236f563 100644
--- a/framework/src/com/phonegap/GpsListener.java
+++ b/framework/src/com/phonegap/GpsListener.java
@@ -4,7 +4,7 @@ package com.phonegap;
  * website: http://phonegap.com
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
- * “Software”), to deal in the Software without restriction, including
+ * "Software"), to deal in the Software without restriction, including
  * without limitation the rights to use, copy, modify, merge, publish,
  * distribute, sublicense, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject to
@@ -13,7 +13,7 @@ package com.phonegap;
  * The above copyright notice and this permission notice shall be
  * included in all copies or substantial portions of the Software.
  * 
- * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
diff --git a/framework/src/com/phonegap/NetworkListener.java b/framework/src/com/phonegap/NetworkListener.java
index 46d5246a..4b0ecda4 100644
--- a/framework/src/com/phonegap/NetworkListener.java
+++ b/framework/src/com/phonegap/NetworkListener.java
@@ -4,7 +4,7 @@ package com.phonegap;
  * website: http://phonegap.com
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
- * “Software”), to deal in the Software without restriction, including
+ * "Software"), to deal in the Software without restriction, including
  * without limitation the rights to use, copy, modify, merge, publish,
  * distribute, sublicense, and/or sell copies of the Software, and to
  * permit persons to whom the Software is furnished to do so, subject to
@@ -13,7 +13,7 @@ package com.phonegap;
  * The above copyright notice and this permission notice shall be
  * included in all copies or substantial portions of the Software.
  * 
- * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE

From d2048a7c5a9540e3a28039457add687486c46416 Mon Sep 17 00:00:00 2001
From: Dave Johnson 
Date: Thu, 8 Jul 2010 15:51:18 -0700
Subject: [PATCH 5/5] changed 'deviceReady' to 'deviceready' in index.html.
 fixed up the file utils a bit so that they sort of work.

---
 example/index.html                               |  2 +-
 framework/assets/js/file.js                      |  8 ++++----
 framework/src/com/phonegap/DirectoryManager.java | 14 +++++++-------
 framework/src/com/phonegap/FileUtils.java        | 15 +++++++--------
 4 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/example/index.html b/example/index.html
index f3b5bb2b..b53776da 100644
--- a/example/index.html
+++ b/example/index.html
@@ -113,7 +113,7 @@
   	
 	function init(){
 		document.addEventListener("touchmove", preventBehavior, false);
-		document.addEventListener("deviceReady", deviceInfo, true);		
+		document.addEventListener("deviceready", deviceInfo, true);		
 	}
 
 	
diff --git a/framework/assets/js/file.js b/framework/assets/js/file.js
index 838c0f10..e32bbfd7 100644
--- a/framework/assets/js/file.js
+++ b/framework/assets/js/file.js
@@ -128,7 +128,7 @@ FileMgr.prototype.createDirectory = function(dirName, successCallback, errorCall
 {
 	this.successCallback = successCallback;
 	this.errorCallback = errorCallback;
-	var test = FileUtils.createDirectory(dirName);
+	var test = FileUtil.createDirectory(dirName);
 	test ? successCallback() : errorCallback();
 }
 
@@ -136,7 +136,7 @@ FileMgr.prototype.deleteDirectory = function(dirName, successCallback, errorCall
 {
 	this.successCallback = successCallback;
 	this.errorCallback = errorCallback;
-	var test = FileUtils.deleteDirectory(dirName);
+	var test = FileUtil.deleteDirectory(dirName);
 	test ? successCallback() : errorCallback();
 }
 
@@ -144,7 +144,7 @@ FileMgr.prototype.deleteFile = function(fileName, successCallback, errorCallback
 {
 	this.successCallback = successCallback;
 	this.errorCallback = errorCallback;
-	FileUtils.deleteFile(fileName);
+	FileUtil.deleteFile(fileName);
 	test ? successCallback() : errorCallback();
 }
 
@@ -158,7 +158,7 @@ FileMgr.prototype.getFreeDiskSpace = function(successCallback, errorCallback)
 	{
 		this.successCallback = successCallback;
 		this.errorCallback = errorCallback;
-		this.freeDiskSpace = FileUtils.getFreeDiskSpace();
+		this.freeDiskSpace = FileUtil.getFreeDiskSpace();
   		(this.freeDiskSpace > 0) ? successCallback() : errorCallback();
 	}
 }
diff --git a/framework/src/com/phonegap/DirectoryManager.java b/framework/src/com/phonegap/DirectoryManager.java
index dab57f9e..2b411a6a 100644
--- a/framework/src/com/phonegap/DirectoryManager.java
+++ b/framework/src/com/phonegap/DirectoryManager.java
@@ -8,7 +8,7 @@ import android.util.Log;
 
 public class DirectoryManager {
 	
-	protected boolean testFileExists (String name){
+	protected static boolean testFileExists (String name){
 		boolean status;
 		if ((testSaveLocationExists())&&(!name.equals(""))){
     		File path = Environment.getExternalStorageDirectory();
@@ -20,7 +20,7 @@ public class DirectoryManager {
 		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.
 		 */
@@ -38,7 +38,7 @@ public class DirectoryManager {
 		return (freeSpace);
 	}	
 	
-	protected boolean createDirectory(String directoryName){
+	protected static boolean createDirectory(String directoryName){
 		boolean status;
 		if ((testSaveLocationExists())&&(!directoryName.equals(""))){
 			File path = Environment.getExternalStorageDirectory();
@@ -50,7 +50,7 @@ public class DirectoryManager {
 		return status;
 	}
 	
-	protected boolean testSaveLocationExists(){
+	protected static boolean testSaveLocationExists(){
 		String sDCardStatus = Environment.getExternalStorageState();
 		boolean status;
 		if (sDCardStatus.equals(Environment.MEDIA_MOUNTED)){
@@ -60,7 +60,7 @@ public class DirectoryManager {
 		return status;
 	}
 	
-	protected boolean deleteDirectory(String fileName){
+	protected static boolean deleteDirectory(String fileName){
 		boolean status;
 		SecurityManager checker = new SecurityManager();
 			
@@ -92,7 +92,7 @@ public class DirectoryManager {
 		return status;
 	}
 	
-	protected boolean deleteFile(String fileName){
+	protected static boolean deleteFile(String fileName){
 		boolean status;
 		SecurityManager checker = new SecurityManager();
 			
@@ -117,7 +117,7 @@ public class DirectoryManager {
 		return status;
 	}
 	
-	private File constructFilePaths (String file1, String file2){
+	private static File constructFilePaths (String file1, String file2){
 		File newPath;
 		newPath = new File(file1+"/"+file2);
 		return newPath;
diff --git a/framework/src/com/phonegap/FileUtils.java b/framework/src/com/phonegap/FileUtils.java
index b1161ffc..ab1a616c 100644
--- a/framework/src/com/phonegap/FileUtils.java
+++ b/framework/src/com/phonegap/FileUtils.java
@@ -8,7 +8,6 @@ public class FileUtils {
 
 
 	WebView mView;
-	DirectoryManager fileManager;
 	FileReader f_in;
 	FileWriter f_out;
 	
@@ -18,26 +17,26 @@ public class FileUtils {
 	}
 	
     public int testSaveLocationExists(){
-        if (fileManager.testSaveLocationExists())
+        if (DirectoryManager.testSaveLocationExists())
             return 0;
         else
             return 1;
     }
     
     public long getFreeDiskSpace(){
-        long freeDiskSpace=fileManager.getFreeDiskSpace();
+        long freeDiskSpace=DirectoryManager.getFreeDiskSpace();
         return freeDiskSpace;
     }
 
     public int testFileExists(String file){
-        if (fileManager.testFileExists(file))
+        if (DirectoryManager.testFileExists(file))
             return 0;
         else
             return 1;
     }
     
     public int testDirectoryExists(String file){
-        if (fileManager.testFileExists(file))
+        if (DirectoryManager.testFileExists(file))
             return 0;
         else
             return 1;
@@ -49,7 +48,7 @@ public class FileUtils {
 	 * TODO: JavaScript Call backs for success and error handling 
 	 */
     public int deleteDirectory (String dir){
-        if (fileManager.deleteDirectory(dir))
+        if (DirectoryManager.deleteDirectory(dir))
             return 0;
         else
             return 1;
@@ -61,7 +60,7 @@ public class FileUtils {
 	 * TODO: JavaScript Call backs for success and error handling 
 	 */
     public int deleteFile (String file){
-        if (fileManager.deleteFile(file))
+        if (DirectoryManager.deleteFile(file))
             return 0;
         else
             return 1;
@@ -73,7 +72,7 @@ public class FileUtils {
 	 * TODO: JavaScript Call backs for success and error handling 
 	 */
     public int createDirectory(String dir){
-    	if (fileManager.createDirectory(dir))
+    	if (DirectoryManager.createDirectory(dir))
             return 0;
         else
             return 1;