You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2013/05/10 23:03:26 UTC
[01/13] android commit: [CB-3304] Windows create script - Parameters
should be quoted
Updated Branches:
refs/heads/3.0.0 7fb8ab2b6 -> d840446d3
[CB-3304] Windows create script - Parameters should be quoted
Choking on spaces in filenames
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/d226818b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/d226818b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/d226818b
Branch: refs/heads/3.0.0
Commit: d226818be3462d24c8c633eb26d2cd026a011d5a
Parents: 1ee9da7
Author: ucavus <lu...@Maxim.3am>
Authored: Thu Feb 7 15:02:54 2013 +1030
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri May 3 11:12:47 2013 -0400
----------------------------------------------------------------------
bin/create.js | 54 ++++++++++++++++++++++++++--------------------------
1 files changed, 27 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/d226818b/bin/create.js
----------------------------------------------------------------------
diff --git a/bin/create.js b/bin/create.js
index 5176b7d..3979594 100644
--- a/bin/create.js
+++ b/bin/create.js
@@ -185,7 +185,7 @@ else {
}
if(fso.FolderExists(PROJECT_PATH)) {
- Log("Project already exists!", true);
+ Log("Project path already exists!", true);
WScript.Quit(2);
}
@@ -197,41 +197,41 @@ var API_LEVEL=setApiLevel();
var VERSION=read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,'');
// create the project
Log("Creating new android project...");
-exec('android.bat create project --target '+TARGET+' --path '+PROJECT_PATH+' --package '+PACKAGE+' --activity '+ACTIVITY);
+exec('android.bat create project --target "'+TARGET+'" --path "'+PROJECT_PATH+'" --package "'+PACKAGE+'" --activity "'+ACTIVITY+'"');
// build from source. distro should have these files
if (!fso.FileExists(ROOT+'\\cordova-'+VERSION+'.jar') &&
!fso.FileExists(ROOT+'\\cordova-'+VERSION+'.js')) {
Log("Building jar and js files...");
// update the cordova framework project to a target that exists on this machine
- exec('android.bat update project --target '+TARGET+' --path '+ROOT+'\\framework');
+ exec('android.bat update project --target "'+TARGET+'" --path "'+ROOT+'\\framework"');
// pull down commons codec if necessary
downloadCommonsCodec();
- exec('ant.bat -f \"'+ ROOT +'\\framework\\build.xml\" jar');
+ exec('ant.bat -f "'+ ROOT +'\\framework\\build.xml" jar');
}
// copy in the project template
Log("Copying template files...");
-exec('%comspec% /c xcopy "'+ ROOT + '"\\bin\\templates\\project\\res '+PROJECT_PATH+'\\res\\ /E /Y');
-exec('%comspec% /c xcopy "'+ ROOT + '"\\bin\\templates\\project\\assets '+PROJECT_PATH+'\\assets\\ /E /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\project\\AndroidManifest.xml ' + PROJECT_PATH + '\\AndroidManifest.xml /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\project\\Activity.java '+ ACTIVITY_PATH +' /Y');
+exec('%comspec% /c xcopy "'+ ROOT + '\\bin\\templates\\project\\res" "'+PROJECT_PATH+'\\res\\" /E /Y');
+exec('%comspec% /c xcopy "'+ ROOT + '\\bin\\templates\\project\\assets" "'+PROJECT_PATH+'\\assets\\" /E /Y');
+exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\project\\AndroidManifest.xml" "' + PROJECT_PATH + '\\AndroidManifest.xml" /Y');
+exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\project\\Activity.java" "'+ ACTIVITY_PATH +'" /Y');
// check if we have the source or the distro files
Log("Copying js, jar & config.xml files...");
if(fso.FolderExists(ROOT + '\\framework')) {
- exec('%comspec% /c copy "'+ROOT+'"\\framework\\assets\\www\\cordova-'+VERSION+'.js '+PROJECT_PATH+'\\assets\\www\\cordova-'+VERSION+'.js /Y');
- exec('%comspec% /c copy "'+ROOT+'"\\framework\\cordova-'+VERSION+'.jar '+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar /Y');
+ exec('%comspec% /c copy "'+ROOT+'\\framework\\assets\\www\\cordova-'+VERSION+'.js" "'+PROJECT_PATH+'\\assets\\www\\cordova-'+VERSION+'.js" /Y');
+ exec('%comspec% /c copy "'+ROOT+'\\framework\\cordova-'+VERSION+'.jar" "'+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar" /Y');
fso.CreateFolder(PROJECT_PATH + '\\res\\xml');
- exec('%comspec% /c copy "'+ROOT+'"\\framework\\res\\xml\\config.xml ' + PROJECT_PATH + '\\res\\xml\\config.xml /Y');
+ exec('%comspec% /c copy "'+ROOT+'\\framework\\res\\xml\\config.xml" "' + PROJECT_PATH + '\\res\\xml\\config.xml" /Y');
} else {
// copy in cordova.js
- exec('%comspec% /c copy "'+ROOT+'"\\cordova-'+VERSION+'.js '+PROJECT_PATH+'\\assets\\www\\cordova-'+VERSION+'.js /Y');
+ exec('%comspec% /c copy "'+ROOT+'\\cordova-'+VERSION+'.js" "'+PROJECT_PATH+'\\assets\\www\\cordova-'+VERSION+'.js" /Y');
// copy in cordova.jar
- exec('%comspec% /c copy "'+ROOT+'"\\cordova-'+VERSION+'.jar '+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar /Y');
+ exec('%comspec% /c copy "'+ROOT+'\\cordova-'+VERSION+'.jar" "'+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar" /Y');
// copy in xml
fso.CreateFolder(PROJECT_PATH + '\\res\\xml');
- exec('%comspec% /c copy "'+ROOT+'"\\xml\\config.xml ' + PROJECT_PATH + '\\res\\xml\\config.xml /Y');
+ exec('%comspec% /c copy "'+ROOT+'\\xml\\config.xml" "' + PROJECT_PATH + '\\res\\xml\\config.xml" /Y');
}
// copy cordova scripts
@@ -239,19 +239,19 @@ fso.CreateFolder(PROJECT_PATH + '\\cordova');
fso.CreateFolder(PROJECT_PATH + '\\cordova\\lib');
createAppInfoJar();
Log("Copying cordova command tools...");
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\appinfo.jar ' + PROJECT_PATH + '\\cordova\\appinfo.jar /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\lib\\cordova.js ' + PROJECT_PATH + '\\cordova\\lib\\cordova.js /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\lib\\install-device.bat ' + PROJECT_PATH + '\\cordova\\lib\\install-device.bat /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\lib\\install-emulator.bat ' + PROJECT_PATH + '\\cordova\\lib\\install-emulator.bat /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\lib\\list-emulator-images.bat ' + PROJECT_PATH + '\\cordova\\lib\\list-emulator-images.bat /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\lib\\list-devices.bat ' + PROJECT_PATH + '\\cordova\\lib\\list-devices.bat /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\lib\\list-started-emulators.bat ' + PROJECT_PATH + '\\cordova\\lib\\list-started-emulators.bat /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\lib\\start-emulator.bat ' + PROJECT_PATH + '\\cordova\\lib\\start-emulator.bat /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\cordova.bat ' + PROJECT_PATH + '\\cordova\\cordova.bat /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\clean.bat ' + PROJECT_PATH + '\\cordova\\clean.bat /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\build.bat ' + PROJECT_PATH + '\\cordova\\build.bat /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\log.bat ' + PROJECT_PATH + '\\cordova\\log.bat /Y');
-exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\run.bat ' + PROJECT_PATH + '\\cordova\\run.bat /Y');
+exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\appinfo.jar" "' + PROJECT_PATH + '\\cordova\\appinfo.jar" /Y');
+exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\cordova.js" "' + PROJECT_PATH + '\\cordova\\cordova.js" /Y');
+exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\lib\\install-device.bat" "' + PROJECT_PATH + '\\cordova\\lib\\install-device.bat" /Y');
+exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\lib\\install-emulator.bat" "' + PROJECT_PATH + '\\cordova\\lib\\install-emulator.bat" /Y');
+exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\lib\\list-emulator-images.bat" "' + PROJECT_PATH + '\\cordova\\lib\\list-emulator-images.bat" /Y');
+exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\lib\\list-devices.bat" "' + PROJECT_PATH + '\\cordova\\lib\\list-devices.bat" /Y');
+exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\lib\\list-started-emulators.bat" "' + PROJECT_PATH + '\\cordova\\lib\\list-started-emulators.bat" /Y');
+exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\lib\\start-emulator.bat" "' + PROJECT_PATH + '\\cordova\\lib\\start-emulator.bat" /Y');
+exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\cordova.bat" "' + PROJECT_PATH + '\\cordova\\cordova.bat" /Y');
+exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\clean.bat" "' + PROJECT_PATH + '\\cordova\\clean.bat" /Y');
+exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\build.bat" "' + PROJECT_PATH + '\\cordova\\build.bat" /Y');
+exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\log.bat" "' + PROJECT_PATH + '\\cordova\\log.bat" /Y');
+exec('%comspec% /c copy "'+ROOT+'\\bin\\templates\\cordova\\run.bat" "' + PROJECT_PATH + '\\cordova\\run.bat" /Y');
// interpolate the activity name and package
Log("Updating AndroidManifest.xml and Main Activity...");
[08/13] android commit: Fix spacing, convert all tabs to spaces
Posted by bo...@apache.org.
Fix spacing, convert all tabs to spaces
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/21614ea8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/21614ea8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/21614ea8
Branch: refs/heads/3.0.0
Commit: 21614ea891ac350a8f189124b0f532d81ed433cb
Parents: 4b38cce
Author: mbillau <mi...@gmail.com>
Authored: Wed Apr 24 14:52:20 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri May 3 13:21:01 2013 -0400
----------------------------------------------------------------------
framework/src/org/apache/cordova/Notification.java | 142 +++++++--------
1 files changed, 69 insertions(+), 73 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/21614ea8/framework/src/org/apache/cordova/Notification.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Notification.java b/framework/src/org/apache/cordova/Notification.java
index 061aebf..cf2e95f 100755
--- a/framework/src/org/apache/cordova/Notification.java
+++ b/framework/src/org/apache/cordova/Notification.java
@@ -33,7 +33,6 @@ import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Vibrator;
-import android.util.Log;
import android.widget.EditText;
/**
@@ -209,41 +208,40 @@ public class Notification extends CordovaPlugin {
// First button
if (buttonLabels.length() > 0) {
try {
- dlg.setNegativeButton(buttonLabels.getString(0),
- new AlertDialog.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 1));
- }
- });
- } catch (JSONException e) { }
+ dlg.setNegativeButton(buttonLabels.getString(0),
+ new AlertDialog.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 1));
+ }
+ });
+ } catch (JSONException e) { }
}
// Second button
if (buttonLabels.length() > 1) {
try {
- dlg.setNeutralButton(buttonLabels.getString(1),
- new AlertDialog.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 2));
- }
- });
- } catch (JSONException e) { }
+ dlg.setNeutralButton(buttonLabels.getString(1),
+ new AlertDialog.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 2));
+ }
+ });
+ } catch (JSONException e) { }
}
// Third button
if (buttonLabels.length() > 2) {
try {
- dlg.setPositiveButton(buttonLabels.getString(2),
- new AlertDialog.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 3));
- }
- }
- );
- } catch (JSONException e) { }
+ dlg.setPositiveButton(buttonLabels.getString(2),
+ new AlertDialog.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 3));
+ }
+ });
+ } catch (JSONException e) { }
}
dlg.setOnCancelListener(new AlertDialog.OnCancelListener() {
public void onCancel(DialogInterface dialog)
@@ -292,74 +290,72 @@ public class Notification extends CordovaPlugin {
// First button
if (buttonLabels.length() > 0) {
try {
- dlg.setNegativeButton(buttonLabels.getString(0),
- new AlertDialog.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- try {
- result.put("buttonIndex",1);
- result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
- } catch (JSONException e) { e.printStackTrace(); }
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
- }
- });
- } catch (JSONException e) { }
+ dlg.setNegativeButton(buttonLabels.getString(0),
+ new AlertDialog.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ try {
+ result.put("buttonIndex",1);
+ result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
+ } catch (JSONException e) { e.printStackTrace(); }
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
+ }
+ });
+ } catch (JSONException e) { }
}
// Second button
if (buttonLabels.length() > 1) {
try {
- dlg.setNeutralButton(buttonLabels.getString(1),
- new AlertDialog.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- try {
- result.put("buttonIndex",2);
- result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
- } catch (JSONException e) { e.printStackTrace(); }
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
- }
- });
- } catch (JSONException e) { }
+ dlg.setNeutralButton(buttonLabels.getString(1),
+ new AlertDialog.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ try {
+ result.put("buttonIndex",2);
+ result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
+ } catch (JSONException e) { e.printStackTrace(); }
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
+ }
+ });
+ } catch (JSONException e) { }
}
// Third button
if (buttonLabels.length() > 2) {
try {
- dlg.setPositiveButton(buttonLabels.getString(2),
- new AlertDialog.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- try {
- result.put("buttonIndex",3);
- result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
- } catch (JSONException e) { e.printStackTrace(); }
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
- }
- }
- );
- } catch (JSONException e) { }
+ dlg.setPositiveButton(buttonLabels.getString(2),
+ new AlertDialog.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ try {
+ result.put("buttonIndex",3);
+ result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
+ } catch (JSONException e) { e.printStackTrace(); }
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
+ }
+ });
+ } catch (JSONException e) { }
}
dlg.setOnCancelListener(new AlertDialog.OnCancelListener() {
- public void onCancel(DialogInterface dialog)
- {
+ public void onCancel(DialogInterface dialog){
dialog.dismiss();
- try {
- result.put("buttonIndex",0);
- result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
- } catch (JSONException e) { e.printStackTrace(); }
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
+ try {
+ result.put("buttonIndex",0);
+ result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
+ } catch (JSONException e) { e.printStackTrace(); }
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
}
});
dlg.create();
dlg.show();
-
+
};
};
- this.cordova.getActivity().runOnUiThread(runnable);
+ this.cordova.getActivity().runOnUiThread(runnable);
}
-
+
/**
* Show the spinner.
*
[11/13] android commit: Part 1 of 2: CB-2657 Moving DroidGap in git
so we don't lose random commits. This is irritating
Posted by bo...@apache.org.
Part 1 of 2: CB-2657 Moving DroidGap in git so we don't lose random commits. This is irritating
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/35d53a06
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/35d53a06
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/35d53a06
Branch: refs/heads/3.0.0
Commit: 35d53a0684cb244ae6e3df58875f38eeced806ba
Parents: dbeb252
Author: Joe Bowser <bo...@apache.org>
Authored: Tue May 7 09:45:50 2013 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Tue May 7 09:45:50 2013 -0700
----------------------------------------------------------------------
.../src/org/apache/cordova/CordovaActivity.java | 1158 +++++++++++++++
framework/src/org/apache/cordova/DroidGap.java | 1158 ---------------
.../cordova/LinearLayoutSoftKeyboardDetect.java | 4 +-
3 files changed, 1160 insertions(+), 1160 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/35d53a06/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java
new file mode 100755
index 0000000..6e3d99d
--- /dev/null
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -0,0 +1,1158 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+package org.apache.cordova;
+
+import java.util.HashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.apache.cordova.api.CordovaInterface;
+import org.apache.cordova.api.CordovaPlugin;
+import org.apache.cordova.api.LOG;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.graphics.Color;
+import android.media.AudioManager;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.util.Log;
+import android.view.Display;
+import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.ImageView;
+import android.webkit.ValueCallback;
+import android.webkit.WebViewClient;
+import android.widget.LinearLayout;
+
+/**
+ * This class is the main Android activity that represents the Cordova
+ * application. It should be extended by the user to load the specific
+ * html file that contains the application.
+ *
+ * As an example:
+ *
+ * package org.apache.cordova.examples;
+ * import android.app.Activity;
+ * import android.os.Bundle;
+ * import org.apache.cordova.*;
+ *
+ * public class Examples extends DroidGap {
+ * @Override
+ * public void onCreate(Bundle savedInstanceState) {
+ * super.onCreate(savedInstanceState);
+ *
+ * // Set properties for activity
+ * super.setStringProperty("loadingDialog", "Title,Message"); // show loading dialog
+ * super.setStringProperty("errorUrl", "file:///android_asset/www/error.html"); // if error loading file in super.loadUrl().
+ *
+ * // Initialize activity
+ * super.init();
+ *
+ * // Clear cache if you want
+ * super.appView.clearCache(true);
+ *
+ * // Load your application
+ * super.setIntegerProperty("splashscreen", R.drawable.splash); // load splash.jpg image from the resource drawable directory
+ * super.loadUrl("file:///android_asset/www/index.html", 3000); // show splash screen 3 sec before loading app
+ * }
+ * }
+ *
+ * Properties: The application can be configured using the following properties:
+ *
+ * // Display a native loading dialog when loading app. Format for value = "Title,Message".
+ * // (String - default=null)
+ * super.setStringProperty("loadingDialog", "Wait,Loading Demo...");
+ *
+ * // Display a native loading dialog when loading sub-pages. Format for value = "Title,Message".
+ * // (String - default=null)
+ * super.setStringProperty("loadingPageDialog", "Loading page...");
+ *
+ * // Load a splash screen image from the resource drawable directory.
+ * // (Integer - default=0)
+ * super.setIntegerProperty("splashscreen", R.drawable.splash);
+ *
+ * // Set the background color.
+ * // (Integer - default=0 or BLACK)
+ * super.setIntegerProperty("backgroundColor", Color.WHITE);
+ *
+ * // Time in msec to wait before triggering a timeout error when loading
+ * // with super.loadUrl(). (Integer - default=20000)
+ * super.setIntegerProperty("loadUrlTimeoutValue", 60000);
+ *
+ * // URL to load if there's an error loading specified URL with loadUrl().
+ * // Should be a local URL starting with file://. (String - default=null)
+ * super.setStringProperty("errorUrl", "file:///android_asset/www/error.html");
+ *
+ * // Enable app to keep running in background. (Boolean - default=true)
+ * super.setBooleanProperty("keepRunning", false);
+ *
+ * Cordova.xml configuration:
+ * Cordova uses a configuration file at res/xml/cordova.xml to specify the following settings.
+ *
+ * Approved list of URLs that can be loaded into DroidGap
+ * <access origin="http://server regexp" subdomains="true" />
+ * Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
+ * <log level="DEBUG" />
+ *
+ * Cordova plugins:
+ * Cordova uses a file at res/xml/plugins.xml to list all plugins that are installed.
+ * Before using a new plugin, a new element must be added to the file.
+ * name attribute is the service name passed to Cordova.exec() in JavaScript
+ * value attribute is the Java class name to call.
+ *
+ * <plugins>
+ * <plugin name="App" value="org.apache.cordova.App"/>
+ * ...
+ * </plugins>
+ */
+public class CordovaActivity extends Activity implements CordovaInterface {
+ public static String TAG = "DroidGap";
+
+ // The webview for our app
+ protected CordovaWebView appView;
+ protected CordovaWebViewClient webViewClient;
+
+ protected LinearLayout root;
+ protected boolean cancelLoadUrl = false;
+ protected ProgressDialog spinnerDialog = null;
+ private final ExecutorService threadPool = Executors.newCachedThreadPool();
+
+
+ // The initial URL for our app
+ // ie http://server/path/index.html#abc?query
+ //private String url = null;
+
+ private static int ACTIVITY_STARTING = 0;
+ private static int ACTIVITY_RUNNING = 1;
+ private static int ACTIVITY_EXITING = 2;
+ private int activityState = 0; // 0=starting, 1=running (after 1st resume), 2=shutting down
+
+ // Plugin to call when activity result is received
+ protected CordovaPlugin activityResultCallback = null;
+ protected boolean activityResultKeepRunning;
+
+ // Default background color for activity
+ // (this is not the color for the webview, which is set in HTML)
+ private int backgroundColor = Color.BLACK;
+
+ /*
+ * The variables below are used to cache some of the activity properties.
+ */
+
+ // Draw a splash screen using an image located in the drawable resource directory.
+ // This is not the same as calling super.loadSplashscreen(url)
+ protected int splashscreen = 0;
+ protected int splashscreenTime = 3000;
+
+ // LoadUrl timeout value in msec (default of 20 sec)
+ protected int loadUrlTimeoutValue = 20000;
+
+ // Keep app running when pause is received. (default = true)
+ // If true, then the JavaScript and native code continue to run in the background
+ // when another application (activity) is started.
+ protected boolean keepRunning = true;
+
+ private int lastRequestCode;
+
+ private Object responseCode;
+
+ private Intent lastIntent;
+
+ private Object lastResponseCode;
+
+ private String initCallbackClass;
+
+ private Object LOG_TAG;
+
+ /**
+ * Sets the authentication token.
+ *
+ * @param authenticationToken
+ * @param host
+ * @param realm
+ */
+ public void setAuthenticationToken(AuthenticationToken authenticationToken, String host, String realm) {
+ if (this.appView != null && this.appView.viewClient != null) {
+ this.appView.viewClient.setAuthenticationToken(authenticationToken, host, realm);
+ }
+ }
+
+ /**
+ * Removes the authentication token.
+ *
+ * @param host
+ * @param realm
+ *
+ * @return the authentication token or null if did not exist
+ */
+ public AuthenticationToken removeAuthenticationToken(String host, String realm) {
+ if (this.appView != null && this.appView.viewClient != null) {
+ return this.appView.viewClient.removeAuthenticationToken(host, realm);
+ }
+ return null;
+ }
+
+ /**
+ * Gets the authentication token.
+ *
+ * In order it tries:
+ * 1- host + realm
+ * 2- host
+ * 3- realm
+ * 4- no host, no realm
+ *
+ * @param host
+ * @param realm
+ *
+ * @return the authentication token
+ */
+ public AuthenticationToken getAuthenticationToken(String host, String realm) {
+ if (this.appView != null && this.appView.viewClient != null) {
+ return this.appView.viewClient.getAuthenticationToken(host, realm);
+ }
+ return null;
+ }
+
+ /**
+ * Clear all authentication tokens.
+ */
+ public void clearAuthenticationTokens() {
+ if (this.appView != null && this.appView.viewClient != null) {
+ this.appView.viewClient.clearAuthenticationTokens();
+ }
+ }
+
+ /**
+ * Called when the activity is first created.
+ *
+ * @param savedInstanceState
+ */
+ @SuppressWarnings("deprecation")
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ Config.init(this);
+ LOG.d(TAG, "DroidGap.onCreate()");
+ super.onCreate(savedInstanceState);
+
+ if(savedInstanceState != null)
+ {
+ initCallbackClass = savedInstanceState.getString("callbackClass");
+ }
+
+ if(!this.getBooleanProperty("showTitle", false))
+ {
+ getWindow().requestFeature(Window.FEATURE_NO_TITLE);
+ }
+
+ if(this.getBooleanProperty("setFullscreen", false))
+ {
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+ else
+ {
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+ }
+ // This builds the view. We could probably get away with NOT having a LinearLayout, but I like having a bucket!
+ Display display = getWindowManager().getDefaultDisplay();
+ int width = display.getWidth();
+ int height = display.getHeight();
+
+ root = new LinearLayoutSoftKeyboardDetect(this, width, height);
+ root.setOrientation(LinearLayout.VERTICAL);
+ root.setBackgroundColor(this.backgroundColor);
+ root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
+
+ // Setup the hardware volume controls to handle volume control
+ setVolumeControlStream(AudioManager.STREAM_MUSIC);
+ }
+
+ /**
+ * Get the Android activity.
+ *
+ * @return
+ */
+ public Activity getActivity() {
+ return this;
+ }
+
+ /**
+ * Create and initialize web container with default web view objects.
+ */
+ public void init() {
+ CordovaWebView webView = new CordovaWebView(CordovaActivity.this);
+ CordovaWebViewClient webViewClient;
+ if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB)
+ {
+ webViewClient = new CordovaWebViewClient(this, webView);
+ }
+ else
+ {
+ webViewClient = new IceCreamCordovaWebViewClient(this, webView);
+ }
+ this.init(webView, webViewClient, new CordovaChromeClient(this, webView));
+ }
+
+ /**
+ * Initialize web container with web view objects.
+ *
+ * @param webView
+ * @param webViewClient
+ * @param webChromeClient
+ */
+ @SuppressLint("NewApi")
+ public void init(CordovaWebView webView, CordovaWebViewClient webViewClient, CordovaChromeClient webChromeClient) {
+ LOG.d(TAG, "DroidGap.init()");
+
+ // Set up web container
+ this.appView = webView;
+ this.appView.setId(100);
+
+ this.appView.setWebViewClient(webViewClient);
+ this.appView.setWebChromeClient(webChromeClient);
+ webViewClient.setWebView(this.appView);
+ webChromeClient.setWebView(this.appView);
+
+ this.appView.setLayoutParams(new LinearLayout.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ 1.0F));
+
+ if (this.getBooleanProperty("disallowOverscroll", false)) {
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
+ this.appView.setOverScrollMode(CordovaWebView.OVER_SCROLL_NEVER);
+ }
+ }
+
+ // Add web view but make it invisible while loading URL
+ this.appView.setVisibility(View.INVISIBLE);
+ this.root.addView(this.appView);
+ setContentView(this.root);
+
+ // Clear cancel flag
+ this.cancelLoadUrl = false;
+
+ }
+
+ /**
+ * Load the url into the webview.
+ *
+ * @param url
+ */
+ public void loadUrl(String url) {
+
+ // Init web view if not already done
+ if (this.appView == null) {
+ this.init();
+ }
+
+ // Set backgroundColor
+ this.backgroundColor = this.getIntegerProperty("backgroundColor", Color.BLACK);
+ this.root.setBackgroundColor(this.backgroundColor);
+
+ // If keepRunning
+ this.keepRunning = this.getBooleanProperty("keepRunning", true);
+
+ // Then load the spinner
+ this.loadSpinner();
+
+ this.appView.loadUrl(url);
+ }
+
+ /*
+ * Load the spinner
+ */
+ void loadSpinner() {
+
+ // If loadingDialog property, then show the App loading dialog for first page of app
+ String loading = null;
+ if ((this.appView == null) || !this.appView.canGoBack()) {
+ loading = this.getStringProperty("loadingDialog", null);
+ }
+ else {
+ loading = this.getStringProperty("loadingPageDialog", null);
+ }
+ if (loading != null) {
+
+ String title = "";
+ String message = "Loading Application...";
+
+ if (loading.length() > 0) {
+ int comma = loading.indexOf(',');
+ if (comma > 0) {
+ title = loading.substring(0, comma);
+ message = loading.substring(comma + 1);
+ }
+ else {
+ title = "";
+ message = loading;
+ }
+ }
+ this.spinnerStart(title, message);
+ }
+ }
+
+ /**
+ * Load the url into the webview after waiting for period of time.
+ * This is used to display the splashscreen for certain amount of time.
+ *
+ * @param url
+ * @param time The number of ms to wait before loading webview
+ */
+ public void loadUrl(final String url, int time) {
+
+ // Init web view if not already done
+ if (this.appView == null) {
+ this.init();
+ }
+
+ this.splashscreenTime = time;
+ this.splashscreen = this.getIntegerProperty("splashscreen", 0);
+ this.showSplashScreen(this.splashscreenTime);
+ this.appView.loadUrl(url, time);
+ }
+
+ /**
+ * Cancel loadUrl before it has been loaded.
+ */
+ // TODO NO-OP
+ @Deprecated
+ public void cancelLoadUrl() {
+ this.cancelLoadUrl = true;
+ }
+
+ /**
+ * Clear the resource cache.
+ */
+ public void clearCache() {
+ if (this.appView == null) {
+ this.init();
+ }
+ this.appView.clearCache(true);
+ }
+
+ /**
+ * Clear web history in this web view.
+ */
+ public void clearHistory() {
+ this.appView.clearHistory();
+ }
+
+ /**
+ * Go to previous page in history. (We manage our own history)
+ *
+ * @return true if we went back, false if we are already at top
+ */
+ public boolean backHistory() {
+ if (this.appView != null) {
+ return appView.backHistory();
+ }
+ return false;
+ }
+
+ @Override
+ /**
+ * Called by the system when the device configuration changes while your activity is running.
+ *
+ * @param Configuration newConfig
+ */
+ public void onConfigurationChanged(Configuration newConfig) {
+ //don't reload the current page when the orientation is changed
+ super.onConfigurationChanged(newConfig);
+ }
+
+ /**
+ * Get boolean property for activity.
+ *
+ * @param name
+ * @param defaultValue
+ * @return
+ */
+ public boolean getBooleanProperty(String name, boolean defaultValue) {
+ Bundle bundle = this.getIntent().getExtras();
+ if (bundle == null) {
+ return defaultValue;
+ }
+ Boolean p;
+ try {
+ p = (Boolean) bundle.get(name);
+ } catch (ClassCastException e) {
+ String s = bundle.get(name).toString();
+ if ("true".equals(s)) {
+ p = true;
+ }
+ else {
+ p = false;
+ }
+ }
+ if (p == null) {
+ return defaultValue;
+ }
+ return p.booleanValue();
+ }
+
+ /**
+ * Get int property for activity.
+ *
+ * @param name
+ * @param defaultValue
+ * @return
+ */
+ public int getIntegerProperty(String name, int defaultValue) {
+ Bundle bundle = this.getIntent().getExtras();
+ if (bundle == null) {
+ return defaultValue;
+ }
+ Integer p;
+ try {
+ p = (Integer) bundle.get(name);
+ } catch (ClassCastException e) {
+ p = Integer.parseInt(bundle.get(name).toString());
+ }
+ if (p == null) {
+ return defaultValue;
+ }
+ return p.intValue();
+ }
+
+ /**
+ * Get string property for activity.
+ *
+ * @param name
+ * @param defaultValue
+ * @return
+ */
+ public String getStringProperty(String name, String defaultValue) {
+ Bundle bundle = this.getIntent().getExtras();
+ if (bundle == null) {
+ return defaultValue;
+ }
+ String p = bundle.getString(name);
+ if (p == null) {
+ return defaultValue;
+ }
+ return p;
+ }
+
+ /**
+ * Get double property for activity.
+ *
+ * @param name
+ * @param defaultValue
+ * @return
+ */
+ public double getDoubleProperty(String name, double defaultValue) {
+ Bundle bundle = this.getIntent().getExtras();
+ if (bundle == null) {
+ return defaultValue;
+ }
+ Double p;
+ try {
+ p = (Double) bundle.get(name);
+ } catch (ClassCastException e) {
+ p = Double.parseDouble(bundle.get(name).toString());
+ }
+ if (p == null) {
+ return defaultValue;
+ }
+ return p.doubleValue();
+ }
+
+ /**
+ * Set boolean property on activity.
+ *
+ * @param name
+ * @param value
+ */
+ public void setBooleanProperty(String name, boolean value) {
+ Log.d(TAG, "Setting boolean properties in DroidGap will be deprecated in 3.0 on July 2013, please use config.xml");
+ this.getIntent().putExtra(name, value);
+ }
+
+ /**
+ * Set int property on activity.
+ *
+ * @param name
+ * @param value
+ */
+ public void setIntegerProperty(String name, int value) {
+ Log.d(TAG, "Setting integer properties in DroidGap will be deprecated in 3.1 on August 2013, please use config.xml");
+ this.getIntent().putExtra(name, value);
+ }
+
+ /**
+ * Set string property on activity.
+ *
+ * @param name
+ * @param value
+ */
+ public void setStringProperty(String name, String value) {
+ Log.d(TAG, "Setting string properties in DroidGap will be deprecated in 3.0 on July 2013, please use config.xml");
+ this.getIntent().putExtra(name, value);
+ }
+
+ /**
+ * Set double property on activity.
+ *
+ * @param name
+ * @param value
+ */
+ public void setDoubleProperty(String name, double value) {
+ Log.d(TAG, "Setting double properties in DroidGap will be deprecated in 3.0 on July 2013, please use config.xml");
+ this.getIntent().putExtra(name, value);
+ }
+
+ @Override
+ /**
+ * Called when the system is about to start resuming a previous activity.
+ */
+ protected void onPause() {
+ super.onPause();
+
+ LOG.d(TAG, "Paused the application!");
+
+ // Don't process pause if shutting down, since onDestroy() will be called
+ if (this.activityState == ACTIVITY_EXITING) {
+ return;
+ }
+
+ if (this.appView == null) {
+ return;
+ }
+ else
+ {
+ this.appView.handlePause(this.keepRunning);
+ }
+
+ // hide the splash screen to avoid leaking a window
+ this.removeSplashScreen();
+ }
+
+ @Override
+ /**
+ * Called when the activity receives a new intent
+ **/
+ protected void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ //Forward to plugins
+ if (this.appView != null)
+ this.appView.onNewIntent(intent);
+ }
+
+ @Override
+ /**
+ * Called when the activity will start interacting with the user.
+ */
+ protected void onResume() {
+ super.onResume();
+ //Reload the configuration
+ Config.init(this);
+
+ LOG.d(TAG, "Resuming the App");
+
+
+ //Code to test CB-3064
+ String errorUrl = this.getStringProperty("errorUrl", null);
+ LOG.d(TAG, "CB-3064: The errorUrl is " + errorUrl);
+
+ if (this.activityState == ACTIVITY_STARTING) {
+ this.activityState = ACTIVITY_RUNNING;
+ return;
+ }
+
+ if (this.appView == null) {
+ return;
+ }
+
+ this.appView.handleResume(this.keepRunning, this.activityResultKeepRunning);
+
+ // If app doesn't want to run in background
+ if (!this.keepRunning || this.activityResultKeepRunning) {
+
+ // Restore multitasking state
+ if (this.activityResultKeepRunning) {
+ this.keepRunning = this.activityResultKeepRunning;
+ this.activityResultKeepRunning = false;
+ }
+ }
+ }
+
+ @Override
+ /**
+ * The final call you receive before your activity is destroyed.
+ */
+ public void onDestroy() {
+ LOG.d(TAG, "onDestroy()");
+ super.onDestroy();
+
+ // hide the splash screen to avoid leaking a window
+ this.removeSplashScreen();
+
+ if (this.appView != null) {
+ appView.handleDestroy();
+ }
+ else {
+ this.activityState = ACTIVITY_EXITING;
+ }
+ }
+
+ /**
+ * Send a message to all plugins.
+ *
+ * @param id The message id
+ * @param data The message data
+ */
+ public void postMessage(String id, Object data) {
+ if (this.appView != null) {
+ this.appView.postMessage(id, data);
+ }
+ }
+
+ /**
+ * @deprecated
+ * Add services to res/xml/plugins.xml instead.
+ *
+ * Add a class that implements a service.
+ *
+ * @param serviceType
+ * @param className
+ */
+ public void addService(String serviceType, String className) {
+ if (this.appView != null && this.appView.pluginManager != null) {
+ this.appView.pluginManager.addService(serviceType, className);
+ }
+ }
+
+ /**
+ * Send JavaScript statement back to JavaScript.
+ * (This is a convenience method)
+ *
+ * @param message
+ */
+ public void sendJavascript(String statement) {
+ if (this.appView != null) {
+ this.appView.jsMessageQueue.addJavaScript(statement);
+ }
+ }
+
+ /**
+ * Show the spinner. Must be called from the UI thread.
+ *
+ * @param title Title of the dialog
+ * @param message The message of the dialog
+ */
+ public void spinnerStart(final String title, final String message) {
+ if (this.spinnerDialog != null) {
+ this.spinnerDialog.dismiss();
+ this.spinnerDialog = null;
+ }
+ final CordovaActivity me = this;
+ this.spinnerDialog = ProgressDialog.show(CordovaActivity.this, title, message, true, true,
+ new DialogInterface.OnCancelListener() {
+ public void onCancel(DialogInterface dialog) {
+ me.spinnerDialog = null;
+ }
+ });
+ }
+
+ /**
+ * Stop spinner - Must be called from UI thread
+ */
+ public void spinnerStop() {
+ if (this.spinnerDialog != null && this.spinnerDialog.isShowing()) {
+ this.spinnerDialog.dismiss();
+ this.spinnerDialog = null;
+ }
+ }
+
+ /**
+ * End this activity by calling finish for activity
+ */
+ public void endActivity() {
+ this.activityState = ACTIVITY_EXITING;
+ super.finish();
+ }
+
+
+ /**
+ * Launch an activity for which you would like a result when it finished. When this activity exits,
+ * your onActivityResult() method will be called.
+ *
+ * @param command The command object
+ * @param intent The intent to start
+ * @param requestCode The request code that is passed to callback to identify the activity
+ */
+ public void startActivityForResult(CordovaPlugin command, Intent intent, int requestCode) {
+ this.activityResultCallback = command;
+ this.activityResultKeepRunning = this.keepRunning;
+
+ // If multitasking turned on, then disable it for activities that return results
+ if (command != null) {
+ this.keepRunning = false;
+ }
+
+ // Start activity
+ super.startActivityForResult(intent, requestCode);
+ }
+
+ @Override
+ /**
+ * Called when an activity you launched exits, giving you the requestCode you started it with,
+ * the resultCode it returned, and any additional data from it.
+ *
+ * @param requestCode The request code originally supplied to startActivityForResult(),
+ * allowing you to identify who this result came from.
+ * @param resultCode The integer result code returned by the child activity through its setResult().
+ * @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
+ */
+ protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
+ LOG.d(TAG, "Incoming Result");
+ super.onActivityResult(requestCode, resultCode, intent);
+ Log.d(TAG, "Request code = " + requestCode);
+ ValueCallback<Uri> mUploadMessage = this.appView.getWebChromeClient().getValueCallback();
+ if (requestCode == CordovaChromeClient.FILECHOOSER_RESULTCODE) {
+ Log.d(TAG, "did we get here?");
+ if (null == mUploadMessage)
+ return;
+ Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData();
+ Log.d(TAG, "result = " + result);
+// Uri filepath = Uri.parse("file://" + FileUtils.getRealPathFromURI(result, this));
+// Log.d(TAG, "result = " + filepath);
+ mUploadMessage.onReceiveValue(result);
+ mUploadMessage = null;
+ }
+ CordovaPlugin callback = this.activityResultCallback;
+ if(callback == null)
+ {
+ if(initCallbackClass != null)
+ {
+ this.activityResultCallback = appView.pluginManager.getPlugin(initCallbackClass);
+ callback = activityResultCallback;
+ LOG.d(TAG, "We have a callback to send this result to");
+ callback.onActivityResult(requestCode, resultCode, intent);
+ }
+ }
+ else
+ {
+ LOG.d(TAG, "We have a callback to send this result to");
+ callback.onActivityResult(requestCode, resultCode, intent);
+ }
+ }
+
+ public void setActivityResultCallback(CordovaPlugin plugin) {
+ this.activityResultCallback = plugin;
+ }
+
+ /**
+ * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
+ * The errorCode parameter corresponds to one of the ERROR_* constants.
+ *
+ * @param errorCode The error code corresponding to an ERROR_* value.
+ * @param description A String describing the error.
+ * @param failingUrl The url that failed to load.
+ */
+ public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
+ final CordovaActivity me = this;
+
+ // If errorUrl specified, then load it
+ final String errorUrl = me.getStringProperty("errorUrl", null);
+ if ((errorUrl != null) && (errorUrl.startsWith("file://") || Config.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {
+
+ // Load URL on UI thread
+ me.runOnUiThread(new Runnable() {
+ public void run() {
+ // Stop "app loading" spinner if showing
+ me.spinnerStop();
+ me.appView.showWebPage(errorUrl, false, true, null);
+ }
+ });
+ }
+ // If not, then display error dialog
+ else {
+ final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
+ me.runOnUiThread(new Runnable() {
+ public void run() {
+ if (exit) {
+ me.appView.setVisibility(View.GONE);
+ me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ * Display an error dialog and optionally exit application.
+ *
+ * @param title
+ * @param message
+ * @param button
+ * @param exit
+ */
+ public void displayError(final String title, final String message, final String button, final boolean exit) {
+ final CordovaActivity me = this;
+ me.runOnUiThread(new Runnable() {
+ public void run() {
+ try {
+ AlertDialog.Builder dlg = new AlertDialog.Builder(me);
+ dlg.setMessage(message);
+ dlg.setTitle(title);
+ dlg.setCancelable(false);
+ dlg.setPositiveButton(button,
+ new AlertDialog.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ if (exit) {
+ me.endActivity();
+ }
+ }
+ });
+ dlg.create();
+ dlg.show();
+ } catch (Exception e) {
+ finish();
+ }
+ }
+ });
+ }
+
+ /**
+ * Determine if URL is in approved list of URLs to load.
+ *
+ * @param url
+ * @return
+ */
+ public boolean isUrlWhiteListed(String url) {
+ return Config.isUrlWhiteListed(url);
+ }
+
+ /*
+ * Hook in DroidGap for menu plugins
+ *
+ */
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ this.postMessage("onCreateOptionsMenu", menu);
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ this.postMessage("onPrepareOptionsMenu", menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ this.postMessage("onOptionsItemSelected", item);
+ return true;
+ }
+
+ /**
+ * Get Activity context.
+ *
+ * @return
+ */
+ public Context getContext() {
+ LOG.d(TAG, "This will be deprecated December 2012");
+ return this;
+ }
+
+ /**
+ * Load the specified URL in the Cordova webview or a new browser instance.
+ *
+ * NOTE: If openExternal is false, only URLs listed in whitelist can be loaded.
+ *
+ * @param url The url to load.
+ * @param openExternal Load url in browser instead of Cordova webview.
+ * @param clearHistory Clear the history stack, so new page becomes top of history
+ * @param params DroidGap parameters for new app
+ */
+ public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String, Object> params) {
+ if (this.appView != null) {
+ appView.showWebPage(url, openExternal, clearHistory, params);
+ }
+ }
+
+ protected Dialog splashDialog;
+
+ /**
+ * Removes the Dialog that displays the splash screen
+ */
+ public void removeSplashScreen() {
+ if (splashDialog != null && splashDialog.isShowing()) {
+ splashDialog.dismiss();
+ splashDialog = null;
+ }
+ }
+
+ /**
+ * Shows the splash screen over the full Activity
+ */
+ @SuppressWarnings("deprecation")
+ protected void showSplashScreen(final int time) {
+ final CordovaActivity that = this;
+
+ Runnable runnable = new Runnable() {
+ public void run() {
+ // Get reference to display
+ Display display = getWindowManager().getDefaultDisplay();
+
+ // Create the layout for the dialog
+ LinearLayout root = new LinearLayout(that.getActivity());
+ root.setMinimumHeight(display.getHeight());
+ root.setMinimumWidth(display.getWidth());
+ root.setOrientation(LinearLayout.VERTICAL);
+ root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK));
+ root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
+ ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
+ root.setBackgroundResource(that.splashscreen);
+
+ // Create and show the dialog
+ splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
+ // check to see if the splash screen should be full screen
+ if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
+ == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
+ splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+ splashDialog.setContentView(root);
+ splashDialog.setCancelable(false);
+ splashDialog.show();
+
+ // Set Runnable to remove splash screen just in case
+ final Handler handler = new Handler();
+ handler.postDelayed(new Runnable() {
+ public void run() {
+ removeSplashScreen();
+ }
+ }, time);
+ }
+ };
+ this.runOnUiThread(runnable);
+ }
+
+ @Override
+ public boolean onKeyUp(int keyCode, KeyEvent event)
+ {
+ //Get whatever has focus!
+ View childView = appView.getFocusedChild();
+ if ((appView.isCustomViewShowing() || childView != null ) &&
+ (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU)) {
+ return appView.onKeyUp(keyCode, event);
+ } else {
+ return super.onKeyUp(keyCode, event);
+ }
+ }
+
+ /*
+ * Android 2.x needs to be able to check where the cursor is. Android 4.x does not
+ *
+ * (non-Javadoc)
+ * @see android.app.Activity#onKeyDown(int, android.view.KeyEvent)
+ */
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event)
+ {
+ //Get whatever has focus!
+ View childView = appView.getFocusedChild();
+ //Determine if the focus is on the current view or not
+ if (childView != null && (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU)) {
+ return appView.onKeyDown(keyCode, event);
+ }
+ else
+ return super.onKeyDown(keyCode, event);
+ }
+
+
+ /**
+ * Called when a message is sent to plugin.
+ *
+ * @param id The message id
+ * @param data The message data
+ * @return Object or null
+ */
+ public Object onMessage(String id, Object data) {
+ LOG.d(TAG, "onMessage(" + id + "," + data + ")");
+ if ("splashscreen".equals(id)) {
+ if ("hide".equals(data.toString())) {
+ this.removeSplashScreen();
+ }
+ else {
+ // If the splash dialog is showing don't try to show it again
+ if (this.splashDialog == null || !this.splashDialog.isShowing()) {
+ this.splashscreen = this.getIntegerProperty("splashscreen", 0);
+ this.showSplashScreen(this.splashscreenTime);
+ }
+ }
+ }
+ else if ("spinner".equals(id)) {
+ if ("stop".equals(data.toString())) {
+ this.spinnerStop();
+ this.appView.setVisibility(View.VISIBLE);
+ }
+ }
+ else if ("onReceivedError".equals(id)) {
+ JSONObject d = (JSONObject) data;
+ try {
+ this.onReceivedError(d.getInt("errorCode"), d.getString("description"), d.getString("url"));
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+ else if ("exit".equals(id)) {
+ this.endActivity();
+ }
+ return null;
+ }
+
+ public ExecutorService getThreadPool() {
+ return threadPool;
+ }
+
+ protected void onSaveInstanceState(Bundle outState)
+ {
+ super.onSaveInstanceState(outState);
+ if(this.activityResultCallback != null)
+ {
+ String cClass = this.activityResultCallback.getClass().getName();
+ outState.putString("callbackClass", cClass);
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/35d53a06/framework/src/org/apache/cordova/DroidGap.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java
deleted file mode 100755
index a00d43f..0000000
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ /dev/null
@@ -1,1158 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-package org.apache.cordova;
-
-import java.util.HashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.apache.cordova.api.CordovaInterface;
-import org.apache.cordova.api.CordovaPlugin;
-import org.apache.cordova.api.LOG;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.res.Configuration;
-import android.graphics.Color;
-import android.media.AudioManager;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Handler;
-import android.util.Log;
-import android.view.Display;
-import android.view.KeyEvent;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.Window;
-import android.view.WindowManager;
-import android.widget.ImageView;
-import android.webkit.ValueCallback;
-import android.webkit.WebViewClient;
-import android.widget.LinearLayout;
-
-/**
- * This class is the main Android activity that represents the Cordova
- * application. It should be extended by the user to load the specific
- * html file that contains the application.
- *
- * As an example:
- *
- * package org.apache.cordova.examples;
- * import android.app.Activity;
- * import android.os.Bundle;
- * import org.apache.cordova.*;
- *
- * public class Examples extends DroidGap {
- * @Override
- * public void onCreate(Bundle savedInstanceState) {
- * super.onCreate(savedInstanceState);
- *
- * // Set properties for activity
- * super.setStringProperty("loadingDialog", "Title,Message"); // show loading dialog
- * super.setStringProperty("errorUrl", "file:///android_asset/www/error.html"); // if error loading file in super.loadUrl().
- *
- * // Initialize activity
- * super.init();
- *
- * // Clear cache if you want
- * super.appView.clearCache(true);
- *
- * // Load your application
- * super.setIntegerProperty("splashscreen", R.drawable.splash); // load splash.jpg image from the resource drawable directory
- * super.loadUrl("file:///android_asset/www/index.html", 3000); // show splash screen 3 sec before loading app
- * }
- * }
- *
- * Properties: The application can be configured using the following properties:
- *
- * // Display a native loading dialog when loading app. Format for value = "Title,Message".
- * // (String - default=null)
- * super.setStringProperty("loadingDialog", "Wait,Loading Demo...");
- *
- * // Display a native loading dialog when loading sub-pages. Format for value = "Title,Message".
- * // (String - default=null)
- * super.setStringProperty("loadingPageDialog", "Loading page...");
- *
- * // Load a splash screen image from the resource drawable directory.
- * // (Integer - default=0)
- * super.setIntegerProperty("splashscreen", R.drawable.splash);
- *
- * // Set the background color.
- * // (Integer - default=0 or BLACK)
- * super.setIntegerProperty("backgroundColor", Color.WHITE);
- *
- * // Time in msec to wait before triggering a timeout error when loading
- * // with super.loadUrl(). (Integer - default=20000)
- * super.setIntegerProperty("loadUrlTimeoutValue", 60000);
- *
- * // URL to load if there's an error loading specified URL with loadUrl().
- * // Should be a local URL starting with file://. (String - default=null)
- * super.setStringProperty("errorUrl", "file:///android_asset/www/error.html");
- *
- * // Enable app to keep running in background. (Boolean - default=true)
- * super.setBooleanProperty("keepRunning", false);
- *
- * Cordova.xml configuration:
- * Cordova uses a configuration file at res/xml/cordova.xml to specify the following settings.
- *
- * Approved list of URLs that can be loaded into DroidGap
- * <access origin="http://server regexp" subdomains="true" />
- * Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
- * <log level="DEBUG" />
- *
- * Cordova plugins:
- * Cordova uses a file at res/xml/plugins.xml to list all plugins that are installed.
- * Before using a new plugin, a new element must be added to the file.
- * name attribute is the service name passed to Cordova.exec() in JavaScript
- * value attribute is the Java class name to call.
- *
- * <plugins>
- * <plugin name="App" value="org.apache.cordova.App"/>
- * ...
- * </plugins>
- */
-public class DroidGap extends Activity implements CordovaInterface {
- public static String TAG = "DroidGap";
-
- // The webview for our app
- protected CordovaWebView appView;
- protected CordovaWebViewClient webViewClient;
-
- protected LinearLayout root;
- protected boolean cancelLoadUrl = false;
- protected ProgressDialog spinnerDialog = null;
- private final ExecutorService threadPool = Executors.newCachedThreadPool();
-
-
- // The initial URL for our app
- // ie http://server/path/index.html#abc?query
- //private String url = null;
-
- private static int ACTIVITY_STARTING = 0;
- private static int ACTIVITY_RUNNING = 1;
- private static int ACTIVITY_EXITING = 2;
- private int activityState = 0; // 0=starting, 1=running (after 1st resume), 2=shutting down
-
- // Plugin to call when activity result is received
- protected CordovaPlugin activityResultCallback = null;
- protected boolean activityResultKeepRunning;
-
- // Default background color for activity
- // (this is not the color for the webview, which is set in HTML)
- private int backgroundColor = Color.BLACK;
-
- /*
- * The variables below are used to cache some of the activity properties.
- */
-
- // Draw a splash screen using an image located in the drawable resource directory.
- // This is not the same as calling super.loadSplashscreen(url)
- protected int splashscreen = 0;
- protected int splashscreenTime = 3000;
-
- // LoadUrl timeout value in msec (default of 20 sec)
- protected int loadUrlTimeoutValue = 20000;
-
- // Keep app running when pause is received. (default = true)
- // If true, then the JavaScript and native code continue to run in the background
- // when another application (activity) is started.
- protected boolean keepRunning = true;
-
- private int lastRequestCode;
-
- private Object responseCode;
-
- private Intent lastIntent;
-
- private Object lastResponseCode;
-
- private String initCallbackClass;
-
- private Object LOG_TAG;
-
- /**
- * Sets the authentication token.
- *
- * @param authenticationToken
- * @param host
- * @param realm
- */
- public void setAuthenticationToken(AuthenticationToken authenticationToken, String host, String realm) {
- if (this.appView != null && this.appView.viewClient != null) {
- this.appView.viewClient.setAuthenticationToken(authenticationToken, host, realm);
- }
- }
-
- /**
- * Removes the authentication token.
- *
- * @param host
- * @param realm
- *
- * @return the authentication token or null if did not exist
- */
- public AuthenticationToken removeAuthenticationToken(String host, String realm) {
- if (this.appView != null && this.appView.viewClient != null) {
- return this.appView.viewClient.removeAuthenticationToken(host, realm);
- }
- return null;
- }
-
- /**
- * Gets the authentication token.
- *
- * In order it tries:
- * 1- host + realm
- * 2- host
- * 3- realm
- * 4- no host, no realm
- *
- * @param host
- * @param realm
- *
- * @return the authentication token
- */
- public AuthenticationToken getAuthenticationToken(String host, String realm) {
- if (this.appView != null && this.appView.viewClient != null) {
- return this.appView.viewClient.getAuthenticationToken(host, realm);
- }
- return null;
- }
-
- /**
- * Clear all authentication tokens.
- */
- public void clearAuthenticationTokens() {
- if (this.appView != null && this.appView.viewClient != null) {
- this.appView.viewClient.clearAuthenticationTokens();
- }
- }
-
- /**
- * Called when the activity is first created.
- *
- * @param savedInstanceState
- */
- @SuppressWarnings("deprecation")
- @Override
- public void onCreate(Bundle savedInstanceState) {
- Config.init(this);
- LOG.d(TAG, "DroidGap.onCreate()");
- super.onCreate(savedInstanceState);
-
- if(savedInstanceState != null)
- {
- initCallbackClass = savedInstanceState.getString("callbackClass");
- }
-
- if(!this.getBooleanProperty("showTitle", false))
- {
- getWindow().requestFeature(Window.FEATURE_NO_TITLE);
- }
-
- if(this.getBooleanProperty("setFullscreen", false))
- {
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- }
- else
- {
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
- }
- // This builds the view. We could probably get away with NOT having a LinearLayout, but I like having a bucket!
- Display display = getWindowManager().getDefaultDisplay();
- int width = display.getWidth();
- int height = display.getHeight();
-
- root = new LinearLayoutSoftKeyboardDetect(this, width, height);
- root.setOrientation(LinearLayout.VERTICAL);
- root.setBackgroundColor(this.backgroundColor);
- root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
-
- // Setup the hardware volume controls to handle volume control
- setVolumeControlStream(AudioManager.STREAM_MUSIC);
- }
-
- /**
- * Get the Android activity.
- *
- * @return
- */
- public Activity getActivity() {
- return this;
- }
-
- /**
- * Create and initialize web container with default web view objects.
- */
- public void init() {
- CordovaWebView webView = new CordovaWebView(DroidGap.this);
- CordovaWebViewClient webViewClient;
- if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB)
- {
- webViewClient = new CordovaWebViewClient(this, webView);
- }
- else
- {
- webViewClient = new IceCreamCordovaWebViewClient(this, webView);
- }
- this.init(webView, webViewClient, new CordovaChromeClient(this, webView));
- }
-
- /**
- * Initialize web container with web view objects.
- *
- * @param webView
- * @param webViewClient
- * @param webChromeClient
- */
- @SuppressLint("NewApi")
- public void init(CordovaWebView webView, CordovaWebViewClient webViewClient, CordovaChromeClient webChromeClient) {
- LOG.d(TAG, "DroidGap.init()");
-
- // Set up web container
- this.appView = webView;
- this.appView.setId(100);
-
- this.appView.setWebViewClient(webViewClient);
- this.appView.setWebChromeClient(webChromeClient);
- webViewClient.setWebView(this.appView);
- webChromeClient.setWebView(this.appView);
-
- this.appView.setLayoutParams(new LinearLayout.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.MATCH_PARENT,
- 1.0F));
-
- if (this.getBooleanProperty("disallowOverscroll", false)) {
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
- this.appView.setOverScrollMode(CordovaWebView.OVER_SCROLL_NEVER);
- }
- }
-
- // Add web view but make it invisible while loading URL
- this.appView.setVisibility(View.INVISIBLE);
- this.root.addView(this.appView);
- setContentView(this.root);
-
- // Clear cancel flag
- this.cancelLoadUrl = false;
-
- }
-
- /**
- * Load the url into the webview.
- *
- * @param url
- */
- public void loadUrl(String url) {
-
- // Init web view if not already done
- if (this.appView == null) {
- this.init();
- }
-
- // Set backgroundColor
- this.backgroundColor = this.getIntegerProperty("backgroundColor", Color.BLACK);
- this.root.setBackgroundColor(this.backgroundColor);
-
- // If keepRunning
- this.keepRunning = this.getBooleanProperty("keepRunning", true);
-
- // Then load the spinner
- this.loadSpinner();
-
- this.appView.loadUrl(url);
- }
-
- /*
- * Load the spinner
- */
- void loadSpinner() {
-
- // If loadingDialog property, then show the App loading dialog for first page of app
- String loading = null;
- if ((this.appView == null) || !this.appView.canGoBack()) {
- loading = this.getStringProperty("loadingDialog", null);
- }
- else {
- loading = this.getStringProperty("loadingPageDialog", null);
- }
- if (loading != null) {
-
- String title = "";
- String message = "Loading Application...";
-
- if (loading.length() > 0) {
- int comma = loading.indexOf(',');
- if (comma > 0) {
- title = loading.substring(0, comma);
- message = loading.substring(comma + 1);
- }
- else {
- title = "";
- message = loading;
- }
- }
- this.spinnerStart(title, message);
- }
- }
-
- /**
- * Load the url into the webview after waiting for period of time.
- * This is used to display the splashscreen for certain amount of time.
- *
- * @param url
- * @param time The number of ms to wait before loading webview
- */
- public void loadUrl(final String url, int time) {
-
- // Init web view if not already done
- if (this.appView == null) {
- this.init();
- }
-
- this.splashscreenTime = time;
- this.splashscreen = this.getIntegerProperty("splashscreen", 0);
- this.showSplashScreen(this.splashscreenTime);
- this.appView.loadUrl(url, time);
- }
-
- /**
- * Cancel loadUrl before it has been loaded.
- */
- // TODO NO-OP
- @Deprecated
- public void cancelLoadUrl() {
- this.cancelLoadUrl = true;
- }
-
- /**
- * Clear the resource cache.
- */
- public void clearCache() {
- if (this.appView == null) {
- this.init();
- }
- this.appView.clearCache(true);
- }
-
- /**
- * Clear web history in this web view.
- */
- public void clearHistory() {
- this.appView.clearHistory();
- }
-
- /**
- * Go to previous page in history. (We manage our own history)
- *
- * @return true if we went back, false if we are already at top
- */
- public boolean backHistory() {
- if (this.appView != null) {
- return appView.backHistory();
- }
- return false;
- }
-
- @Override
- /**
- * Called by the system when the device configuration changes while your activity is running.
- *
- * @param Configuration newConfig
- */
- public void onConfigurationChanged(Configuration newConfig) {
- //don't reload the current page when the orientation is changed
- super.onConfigurationChanged(newConfig);
- }
-
- /**
- * Get boolean property for activity.
- *
- * @param name
- * @param defaultValue
- * @return
- */
- public boolean getBooleanProperty(String name, boolean defaultValue) {
- Bundle bundle = this.getIntent().getExtras();
- if (bundle == null) {
- return defaultValue;
- }
- Boolean p;
- try {
- p = (Boolean) bundle.get(name);
- } catch (ClassCastException e) {
- String s = bundle.get(name).toString();
- if ("true".equals(s)) {
- p = true;
- }
- else {
- p = false;
- }
- }
- if (p == null) {
- return defaultValue;
- }
- return p.booleanValue();
- }
-
- /**
- * Get int property for activity.
- *
- * @param name
- * @param defaultValue
- * @return
- */
- public int getIntegerProperty(String name, int defaultValue) {
- Bundle bundle = this.getIntent().getExtras();
- if (bundle == null) {
- return defaultValue;
- }
- Integer p;
- try {
- p = (Integer) bundle.get(name);
- } catch (ClassCastException e) {
- p = Integer.parseInt(bundle.get(name).toString());
- }
- if (p == null) {
- return defaultValue;
- }
- return p.intValue();
- }
-
- /**
- * Get string property for activity.
- *
- * @param name
- * @param defaultValue
- * @return
- */
- public String getStringProperty(String name, String defaultValue) {
- Bundle bundle = this.getIntent().getExtras();
- if (bundle == null) {
- return defaultValue;
- }
- String p = bundle.getString(name);
- if (p == null) {
- return defaultValue;
- }
- return p;
- }
-
- /**
- * Get double property for activity.
- *
- * @param name
- * @param defaultValue
- * @return
- */
- public double getDoubleProperty(String name, double defaultValue) {
- Bundle bundle = this.getIntent().getExtras();
- if (bundle == null) {
- return defaultValue;
- }
- Double p;
- try {
- p = (Double) bundle.get(name);
- } catch (ClassCastException e) {
- p = Double.parseDouble(bundle.get(name).toString());
- }
- if (p == null) {
- return defaultValue;
- }
- return p.doubleValue();
- }
-
- /**
- * Set boolean property on activity.
- *
- * @param name
- * @param value
- */
- public void setBooleanProperty(String name, boolean value) {
- Log.d(TAG, "Setting boolean properties in DroidGap will be deprecated in 3.0 on July 2013, please use config.xml");
- this.getIntent().putExtra(name, value);
- }
-
- /**
- * Set int property on activity.
- *
- * @param name
- * @param value
- */
- public void setIntegerProperty(String name, int value) {
- Log.d(TAG, "Setting integer properties in DroidGap will be deprecated in 3.1 on August 2013, please use config.xml");
- this.getIntent().putExtra(name, value);
- }
-
- /**
- * Set string property on activity.
- *
- * @param name
- * @param value
- */
- public void setStringProperty(String name, String value) {
- Log.d(TAG, "Setting string properties in DroidGap will be deprecated in 3.0 on July 2013, please use config.xml");
- this.getIntent().putExtra(name, value);
- }
-
- /**
- * Set double property on activity.
- *
- * @param name
- * @param value
- */
- public void setDoubleProperty(String name, double value) {
- Log.d(TAG, "Setting double properties in DroidGap will be deprecated in 3.0 on July 2013, please use config.xml");
- this.getIntent().putExtra(name, value);
- }
-
- @Override
- /**
- * Called when the system is about to start resuming a previous activity.
- */
- protected void onPause() {
- super.onPause();
-
- LOG.d(TAG, "Paused the application!");
-
- // Don't process pause if shutting down, since onDestroy() will be called
- if (this.activityState == ACTIVITY_EXITING) {
- return;
- }
-
- if (this.appView == null) {
- return;
- }
- else
- {
- this.appView.handlePause(this.keepRunning);
- }
-
- // hide the splash screen to avoid leaking a window
- this.removeSplashScreen();
- }
-
- @Override
- /**
- * Called when the activity receives a new intent
- **/
- protected void onNewIntent(Intent intent) {
- super.onNewIntent(intent);
- //Forward to plugins
- if (this.appView != null)
- this.appView.onNewIntent(intent);
- }
-
- @Override
- /**
- * Called when the activity will start interacting with the user.
- */
- protected void onResume() {
- super.onResume();
- //Reload the configuration
- Config.init(this);
-
- LOG.d(TAG, "Resuming the App");
-
-
- //Code to test CB-3064
- String errorUrl = this.getStringProperty("errorUrl", null);
- LOG.d(TAG, "CB-3064: The errorUrl is " + errorUrl);
-
- if (this.activityState == ACTIVITY_STARTING) {
- this.activityState = ACTIVITY_RUNNING;
- return;
- }
-
- if (this.appView == null) {
- return;
- }
-
- this.appView.handleResume(this.keepRunning, this.activityResultKeepRunning);
-
- // If app doesn't want to run in background
- if (!this.keepRunning || this.activityResultKeepRunning) {
-
- // Restore multitasking state
- if (this.activityResultKeepRunning) {
- this.keepRunning = this.activityResultKeepRunning;
- this.activityResultKeepRunning = false;
- }
- }
- }
-
- @Override
- /**
- * The final call you receive before your activity is destroyed.
- */
- public void onDestroy() {
- LOG.d(TAG, "onDestroy()");
- super.onDestroy();
-
- // hide the splash screen to avoid leaking a window
- this.removeSplashScreen();
-
- if (this.appView != null) {
- appView.handleDestroy();
- }
- else {
- this.activityState = ACTIVITY_EXITING;
- }
- }
-
- /**
- * Send a message to all plugins.
- *
- * @param id The message id
- * @param data The message data
- */
- public void postMessage(String id, Object data) {
- if (this.appView != null) {
- this.appView.postMessage(id, data);
- }
- }
-
- /**
- * @deprecated
- * Add services to res/xml/plugins.xml instead.
- *
- * Add a class that implements a service.
- *
- * @param serviceType
- * @param className
- */
- public void addService(String serviceType, String className) {
- if (this.appView != null && this.appView.pluginManager != null) {
- this.appView.pluginManager.addService(serviceType, className);
- }
- }
-
- /**
- * Send JavaScript statement back to JavaScript.
- * (This is a convenience method)
- *
- * @param message
- */
- public void sendJavascript(String statement) {
- if (this.appView != null) {
- this.appView.jsMessageQueue.addJavaScript(statement);
- }
- }
-
- /**
- * Show the spinner. Must be called from the UI thread.
- *
- * @param title Title of the dialog
- * @param message The message of the dialog
- */
- public void spinnerStart(final String title, final String message) {
- if (this.spinnerDialog != null) {
- this.spinnerDialog.dismiss();
- this.spinnerDialog = null;
- }
- final DroidGap me = this;
- this.spinnerDialog = ProgressDialog.show(DroidGap.this, title, message, true, true,
- new DialogInterface.OnCancelListener() {
- public void onCancel(DialogInterface dialog) {
- me.spinnerDialog = null;
- }
- });
- }
-
- /**
- * Stop spinner - Must be called from UI thread
- */
- public void spinnerStop() {
- if (this.spinnerDialog != null && this.spinnerDialog.isShowing()) {
- this.spinnerDialog.dismiss();
- this.spinnerDialog = null;
- }
- }
-
- /**
- * End this activity by calling finish for activity
- */
- public void endActivity() {
- this.activityState = ACTIVITY_EXITING;
- super.finish();
- }
-
-
- /**
- * Launch an activity for which you would like a result when it finished. When this activity exits,
- * your onActivityResult() method will be called.
- *
- * @param command The command object
- * @param intent The intent to start
- * @param requestCode The request code that is passed to callback to identify the activity
- */
- public void startActivityForResult(CordovaPlugin command, Intent intent, int requestCode) {
- this.activityResultCallback = command;
- this.activityResultKeepRunning = this.keepRunning;
-
- // If multitasking turned on, then disable it for activities that return results
- if (command != null) {
- this.keepRunning = false;
- }
-
- // Start activity
- super.startActivityForResult(intent, requestCode);
- }
-
- @Override
- /**
- * Called when an activity you launched exits, giving you the requestCode you started it with,
- * the resultCode it returned, and any additional data from it.
- *
- * @param requestCode The request code originally supplied to startActivityForResult(),
- * allowing you to identify who this result came from.
- * @param resultCode The integer result code returned by the child activity through its setResult().
- * @param data An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
- */
- protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
- LOG.d(TAG, "Incoming Result");
- super.onActivityResult(requestCode, resultCode, intent);
- Log.d(TAG, "Request code = " + requestCode);
- ValueCallback<Uri> mUploadMessage = this.appView.getWebChromeClient().getValueCallback();
- if (requestCode == CordovaChromeClient.FILECHOOSER_RESULTCODE) {
- Log.d(TAG, "did we get here?");
- if (null == mUploadMessage)
- return;
- Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData();
- Log.d(TAG, "result = " + result);
-// Uri filepath = Uri.parse("file://" + FileUtils.getRealPathFromURI(result, this));
-// Log.d(TAG, "result = " + filepath);
- mUploadMessage.onReceiveValue(result);
- mUploadMessage = null;
- }
- CordovaPlugin callback = this.activityResultCallback;
- if(callback == null)
- {
- if(initCallbackClass != null)
- {
- this.activityResultCallback = appView.pluginManager.getPlugin(initCallbackClass);
- callback = activityResultCallback;
- LOG.d(TAG, "We have a callback to send this result to");
- callback.onActivityResult(requestCode, resultCode, intent);
- }
- }
- else
- {
- LOG.d(TAG, "We have a callback to send this result to");
- callback.onActivityResult(requestCode, resultCode, intent);
- }
- }
-
- public void setActivityResultCallback(CordovaPlugin plugin) {
- this.activityResultCallback = plugin;
- }
-
- /**
- * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
- * The errorCode parameter corresponds to one of the ERROR_* constants.
- *
- * @param errorCode The error code corresponding to an ERROR_* value.
- * @param description A String describing the error.
- * @param failingUrl The url that failed to load.
- */
- public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
- final DroidGap me = this;
-
- // If errorUrl specified, then load it
- final String errorUrl = me.getStringProperty("errorUrl", null);
- if ((errorUrl != null) && (errorUrl.startsWith("file://") || Config.isUrlWhiteListed(errorUrl)) && (!failingUrl.equals(errorUrl))) {
-
- // Load URL on UI thread
- me.runOnUiThread(new Runnable() {
- public void run() {
- // Stop "app loading" spinner if showing
- me.spinnerStop();
- me.appView.showWebPage(errorUrl, false, true, null);
- }
- });
- }
- // If not, then display error dialog
- else {
- final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
- me.runOnUiThread(new Runnable() {
- public void run() {
- if (exit) {
- me.appView.setVisibility(View.GONE);
- me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
- }
- }
- });
- }
- }
-
- /**
- * Display an error dialog and optionally exit application.
- *
- * @param title
- * @param message
- * @param button
- * @param exit
- */
- public void displayError(final String title, final String message, final String button, final boolean exit) {
- final DroidGap me = this;
- me.runOnUiThread(new Runnable() {
- public void run() {
- try {
- AlertDialog.Builder dlg = new AlertDialog.Builder(me);
- dlg.setMessage(message);
- dlg.setTitle(title);
- dlg.setCancelable(false);
- dlg.setPositiveButton(button,
- new AlertDialog.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- if (exit) {
- me.endActivity();
- }
- }
- });
- dlg.create();
- dlg.show();
- } catch (Exception e) {
- finish();
- }
- }
- });
- }
-
- /**
- * Determine if URL is in approved list of URLs to load.
- *
- * @param url
- * @return
- */
- public boolean isUrlWhiteListed(String url) {
- return Config.isUrlWhiteListed(url);
- }
-
- /*
- * Hook in DroidGap for menu plugins
- *
- */
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- this.postMessage("onCreateOptionsMenu", menu);
- return super.onCreateOptionsMenu(menu);
- }
-
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- this.postMessage("onPrepareOptionsMenu", menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- this.postMessage("onOptionsItemSelected", item);
- return true;
- }
-
- /**
- * Get Activity context.
- *
- * @return
- */
- public Context getContext() {
- LOG.d(TAG, "This will be deprecated December 2012");
- return this;
- }
-
- /**
- * Load the specified URL in the Cordova webview or a new browser instance.
- *
- * NOTE: If openExternal is false, only URLs listed in whitelist can be loaded.
- *
- * @param url The url to load.
- * @param openExternal Load url in browser instead of Cordova webview.
- * @param clearHistory Clear the history stack, so new page becomes top of history
- * @param params DroidGap parameters for new app
- */
- public void showWebPage(String url, boolean openExternal, boolean clearHistory, HashMap<String, Object> params) {
- if (this.appView != null) {
- appView.showWebPage(url, openExternal, clearHistory, params);
- }
- }
-
- protected Dialog splashDialog;
-
- /**
- * Removes the Dialog that displays the splash screen
- */
- public void removeSplashScreen() {
- if (splashDialog != null && splashDialog.isShowing()) {
- splashDialog.dismiss();
- splashDialog = null;
- }
- }
-
- /**
- * Shows the splash screen over the full Activity
- */
- @SuppressWarnings("deprecation")
- protected void showSplashScreen(final int time) {
- final DroidGap that = this;
-
- Runnable runnable = new Runnable() {
- public void run() {
- // Get reference to display
- Display display = getWindowManager().getDefaultDisplay();
-
- // Create the layout for the dialog
- LinearLayout root = new LinearLayout(that.getActivity());
- root.setMinimumHeight(display.getHeight());
- root.setMinimumWidth(display.getWidth());
- root.setOrientation(LinearLayout.VERTICAL);
- root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK));
- root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
- ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
- root.setBackgroundResource(that.splashscreen);
-
- // Create and show the dialog
- splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
- // check to see if the splash screen should be full screen
- if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
- == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
- splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- }
- splashDialog.setContentView(root);
- splashDialog.setCancelable(false);
- splashDialog.show();
-
- // Set Runnable to remove splash screen just in case
- final Handler handler = new Handler();
- handler.postDelayed(new Runnable() {
- public void run() {
- removeSplashScreen();
- }
- }, time);
- }
- };
- this.runOnUiThread(runnable);
- }
-
- @Override
- public boolean onKeyUp(int keyCode, KeyEvent event)
- {
- //Get whatever has focus!
- View childView = appView.getFocusedChild();
- if ((appView.isCustomViewShowing() || childView != null ) &&
- (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU)) {
- return appView.onKeyUp(keyCode, event);
- } else {
- return super.onKeyUp(keyCode, event);
- }
- }
-
- /*
- * Android 2.x needs to be able to check where the cursor is. Android 4.x does not
- *
- * (non-Javadoc)
- * @see android.app.Activity#onKeyDown(int, android.view.KeyEvent)
- */
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event)
- {
- //Get whatever has focus!
- View childView = appView.getFocusedChild();
- //Determine if the focus is on the current view or not
- if (childView != null && (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU)) {
- return appView.onKeyDown(keyCode, event);
- }
- else
- return super.onKeyDown(keyCode, event);
- }
-
-
- /**
- * Called when a message is sent to plugin.
- *
- * @param id The message id
- * @param data The message data
- * @return Object or null
- */
- public Object onMessage(String id, Object data) {
- LOG.d(TAG, "onMessage(" + id + "," + data + ")");
- if ("splashscreen".equals(id)) {
- if ("hide".equals(data.toString())) {
- this.removeSplashScreen();
- }
- else {
- // If the splash dialog is showing don't try to show it again
- if (this.splashDialog == null || !this.splashDialog.isShowing()) {
- this.splashscreen = this.getIntegerProperty("splashscreen", 0);
- this.showSplashScreen(this.splashscreenTime);
- }
- }
- }
- else if ("spinner".equals(id)) {
- if ("stop".equals(data.toString())) {
- this.spinnerStop();
- this.appView.setVisibility(View.VISIBLE);
- }
- }
- else if ("onReceivedError".equals(id)) {
- JSONObject d = (JSONObject) data;
- try {
- this.onReceivedError(d.getInt("errorCode"), d.getString("description"), d.getString("url"));
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- else if ("exit".equals(id)) {
- this.endActivity();
- }
- return null;
- }
-
- public ExecutorService getThreadPool() {
- return threadPool;
- }
-
- protected void onSaveInstanceState(Bundle outState)
- {
- super.onSaveInstanceState(outState);
- if(this.activityResultCallback != null)
- {
- String cClass = this.activityResultCallback.getClass().getName();
- outState.putString("callbackClass", cClass);
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/35d53a06/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java b/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java
index 280269b..52712ac 100755
--- a/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java
+++ b/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java
@@ -35,13 +35,13 @@ public class LinearLayoutSoftKeyboardDetect extends LinearLayout {
private int oldWidth = 0; // Need to save old width for orientation change
private int screenWidth = 0;
private int screenHeight = 0;
- private DroidGap app = null;
+ private CordovaActivity app = null;
public LinearLayoutSoftKeyboardDetect(Context context, int width, int height) {
super(context);
screenWidth = width;
screenHeight = height;
- app = (DroidGap) context;
+ app = (CordovaActivity) context;
}
@Override
[07/13] android commit: CB-3022: Add default text to Android Prompt
Posted by bo...@apache.org.
CB-3022: Add default text to Android Prompt
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/4b38ccef
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/4b38ccef
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/4b38ccef
Branch: refs/heads/3.0.0
Commit: 4b38ccef80c8a98f0f99605cb81f21c0f5c3c3aa
Parents: 2d4d18f
Author: mbillau <mi...@gmail.com>
Authored: Wed Apr 24 12:48:48 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri May 3 13:18:30 2013 -0400
----------------------------------------------------------------------
framework/src/org/apache/cordova/Notification.java | 20 ++++++++------
1 files changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4b38ccef/framework/src/org/apache/cordova/Notification.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Notification.java b/framework/src/org/apache/cordova/Notification.java
index 9d96062..061aebf 100755
--- a/framework/src/org/apache/cordova/Notification.java
+++ b/framework/src/org/apache/cordova/Notification.java
@@ -33,6 +33,7 @@ import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Vibrator;
+import android.util.Log;
import android.widget.EditText;
/**
@@ -74,7 +75,7 @@ public class Notification extends CordovaPlugin {
return true;
}
else if (action.equals("prompt")) {
- this.prompt(args.getString(0), args.getString(1), args.getJSONArray(2), callbackContext);
+ this.prompt(args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), callbackContext);
return true;
}
else if (action.equals("activityStart")) {
@@ -271,11 +272,12 @@ public class Notification extends CordovaPlugin {
* @param buttonLabels A comma separated list of button labels (Up to 3 buttons)
* @param callbackContext The callback context.
*/
- public synchronized void prompt(final String message, final String title, final JSONArray buttonLabels, final CallbackContext callbackContext) {
+ public synchronized void prompt(final String message, final String title, final JSONArray buttonLabels, final String defaultText, final CallbackContext callbackContext) {
final CordovaInterface cordova = this.cordova;
final EditText promptInput = new EditText(cordova.getActivity());
-
+ promptInput.setHint(defaultText);
+
Runnable runnable = new Runnable() {
public void run() {
AlertDialog.Builder dlg = new AlertDialog.Builder(cordova.getActivity());
@@ -296,7 +298,7 @@ public class Notification extends CordovaPlugin {
dialog.dismiss();
try {
result.put("buttonIndex",1);
- result.put("input1", promptInput.getText());
+ result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
} catch (JSONException e) { e.printStackTrace(); }
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
}
@@ -313,7 +315,7 @@ public class Notification extends CordovaPlugin {
dialog.dismiss();
try {
result.put("buttonIndex",2);
- result.put("input1", promptInput.getText());
+ result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
} catch (JSONException e) { e.printStackTrace(); }
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
}
@@ -330,7 +332,7 @@ public class Notification extends CordovaPlugin {
dialog.dismiss();
try {
result.put("buttonIndex",3);
- result.put("input1", promptInput.getText());
+ result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
} catch (JSONException e) { e.printStackTrace(); }
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
}
@@ -344,7 +346,7 @@ public class Notification extends CordovaPlugin {
dialog.dismiss();
try {
result.put("buttonIndex",0);
- result.put("input1", promptInput.getText());
+ result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
} catch (JSONException e) { e.printStackTrace(); }
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
}
@@ -355,8 +357,9 @@ public class Notification extends CordovaPlugin {
};
};
- this.cordova.getActivity().runOnUiThread(runnable);
+ this.cordova.getActivity().runOnUiThread(runnable);
}
+
/**
* Show the spinner.
*
@@ -446,5 +449,4 @@ public class Notification extends CordovaPlugin {
this.progressDialog = null;
}
}
-
}
[02/13] android commit: [CB-1108] Convert config.xml from to
Posted by bo...@apache.org.
[CB-1108] Convert config.xml from <plugin> to <feature>
This unifies the config.xml used by iOS and Android. Now <feature> tags can be used
to add plugins. The changes are non-intrusive so the older versions of the config.xml
can still be used after this change. The value of a param named "android-package"
determines the class for the plugin.
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/4b9047b7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/4b9047b7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/4b9047b7
Branch: refs/heads/3.0.0
Commit: 4b9047b7d8ef8b983bd3d107c20620a54474d269
Parents: d226818
Author: Gorkem Ercan <go...@gmail.com>
Authored: Thu Mar 28 10:22:08 2013 +0200
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri May 3 11:35:00 2013 -0400
----------------------------------------------------------------------
framework/res/xml/config.xml | 123 ++++++++------
.../src/org/apache/cordova/api/PluginManager.java | 39 +++--
test/res/xml/config.xml | 135 +++++++++------
3 files changed, 177 insertions(+), 120 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4b9047b7/framework/res/xml/config.xml
----------------------------------------------------------------------
diff --git a/framework/res/xml/config.xml b/framework/res/xml/config.xml
index bc6ca0c..c915f0c 100644
--- a/framework/res/xml/config.xml
+++ b/framework/res/xml/config.xml
@@ -1,60 +1,85 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
+<?xml version="1.0" encoding="UTF-8"?>
+<widget xmlns = "http://www.w3.org/ns/widgets"
+ id = "io.cordova.helloCordova"
+ version = "2.0.0">
+ <name>Hello Cordova</name>
- http://www.apache.org/licenses/LICENSE-2.0
+ <description>
+ A sample Apache Cordova application that responds to the deviceready event.
+ </description>
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<cordova>
- <!--
- access elements control the Android whitelist.
- Domains are assumed blocked unless set otherwise
- -->
+ <author href="http://cordova.io" email="callback-dev@incubator.apache.org">
+ Apache Cordova Team
+ </author>
- <access origin="http://127.0.0.1*"/> <!-- allow local pages -->
-
- <!-- <access origin="https://example.com" /> allow any secure requests to example.com -->
- <!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www -->
- <access origin=".*"/>
+ <access origin="*"/>
+
<!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
<content src="index.html" />
<log level="DEBUG"/>
+
+ <!-- Preferences for Android -->
<preference name="useBrowserHistory" value="true" />
<preference name="exit-on-suspend" value="false" />
-<plugins>
- <plugin name="App" value="org.apache.cordova.App"/>
- <plugin name="Geolocation" value="org.apache.cordova.GeoBroker"/>
- <plugin name="Device" value="org.apache.cordova.Device"/>
- <plugin name="Accelerometer" value="org.apache.cordova.AccelListener"/>
- <plugin name="Compass" value="org.apache.cordova.CompassListener"/>
- <plugin name="Media" value="org.apache.cordova.AudioHandler"/>
- <plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
- <plugin name="Contacts" value="org.apache.cordova.ContactManager"/>
- <plugin name="File" value="org.apache.cordova.FileUtils"/>
- <plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
- <plugin name="Notification" value="org.apache.cordova.Notification"/>
- <plugin name="Storage" value="org.apache.cordova.Storage"/>
- <plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
- <plugin name="Capture" value="org.apache.cordova.Capture"/>
- <plugin name="Battery" value="org.apache.cordova.BatteryListener"/>
- <plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
- <plugin name="Echo" value="org.apache.cordova.Echo" />
- <plugin name="Globalization" value="org.apache.cordova.Globalization"/>
- <plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser"/>
-</plugins>
-</cordova>
+ <feature name="App">
+ <param name="android-package" value="org.apache.cordova.App"/>
+ </feature>
+ <feature name="Geolocation">
+ <param name="android-package" value="org.apache.cordova.GeoBroker"/>
+ </feature>
+ <feature name="Device">
+ <param name="android-package" value="org.apache.cordova.Device"/>
+ </feature>
+ <feature name="Accelerometer">
+ <param name="android-package" value="org.apache.cordova.AccelListener"/>
+ </feature>
+ <feature name="Compass">
+ <param name="android-package" value="org.apache.cordova.CompassListener"/>
+ </feature>
+ <feature name="Media">
+ <param name="android-package" value="org.apache.cordova.AudioHandler"/>
+ </feature>
+ <feature name="Camera">
+ <param name="android-package" value="org.apache.cordova.CameraLauncher"/>
+ </feature>
+ <feature name="Contacts">
+ <param name="android-package" value="org.apache.cordova.ContactManager"/>
+ </feature>
+ <feature name="File">
+ <param name="android-package" value="org.apache.cordova.FileUtils"/>
+ </feature>
+ <feature name="NetworkStatus">
+ <param name="android-package" value="org.apache.cordova.NetworkManager"/>
+ </feature>
+ <feature name="Notification">
+ <param name="android-package" value="org.apache.cordova.Notification"/>
+ </feature>
+ <feature name="Storage">
+ <param name="android-package" value="org.apache.cordova.Storage"/>
+ </feature>
+ <feature name="FileTransfer">
+ <param name="android-package" value="org.apache.cordova.FileTransfer"/>
+ </feature>
+ <feature name="Capture">
+ <param name="android-package" value="org.apache.cordova.Capture"/>
+ </feature>
+ <feature name="Battery">
+ <param name="android-package" value="org.apache.cordova.BatteryListener"/>
+ </feature>
+ <feature name="SplashScreen">
+ <param name="android-package" value="org.apache.cordova.SplashScreen"/>
+ </feature>
+ <feature name="Echo">
+ <param name="android-package" value="org.apache.cordova.Echo"/>
+ </feature>
+ <feature name="Globalization">
+ <param name="android-package" value="org.apache.cordova.Globalization"/>
+ </feature>
+ <feature name="InAppBrowser">
+ <param name="android-package" value="org.apache.cordova.InAppBrowser"/>
+ </feature>
+
+</widget>
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4b9047b7/framework/src/org/apache/cordova/api/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/PluginManager.java b/framework/src/org/apache/cordova/api/PluginManager.java
index 7d823cd..4cf3450 100755
--- a/framework/src/org/apache/cordova/api/PluginManager.java
+++ b/framework/src/org/apache/cordova/api/PluginManager.java
@@ -107,7 +107,7 @@ public class PluginManager {
}
XmlResourceParser xml = this.ctx.getActivity().getResources().getXml(id);
int eventType = -1;
- String service = "", pluginClass = "", paramType = "";
+ String service = "", pluginClass = "", paramType = "", featureName="";
boolean onload = false;
PluginEntry entry = null;
boolean insideFeature = false;
@@ -130,26 +130,28 @@ public class PluginManager {
}
else if (strNode.equals("feature")) {
insideFeature = true;
- //Check for supported feature sets (Accelerometer, Geolocation, etc)
+ //Check for supported feature sets aka. plugins (Accelerometer, Geolocation, etc)
//Set the bit for reading params
- String uri = xml.getAttributeValue(null,"name");
+ featureName = xml.getAttributeValue(null,"name");
}
- else if(strNode.equals("param")) {
- if(insideFeature)
+ else if( insideFeature && strNode.equals("param")) {
+ paramType = xml.getAttributeValue(null, "name");
+ if (paramType.equals("service")) // check if it is using the older service param
+ service = xml.getAttributeValue(null, "value");
+ else if (paramType.equals("package"))
+ pluginClass = xml.getAttributeValue(null, "value");
+ else if (paramType.equals("android-package"))
{
- paramType = xml.getAttributeValue(null, "name");
- if(paramType.equals("service"))
- service = xml.getAttributeValue(null, "value");
- else if(paramType.equals("package"))
- pluginClass = xml.getAttributeValue(null, "value");
- if(service.length() > 0 && pluginClass.length() > 0)
- {
- onload = "true".equals(xml.getAttributeValue(null, "onload"));
- entry = new PluginEntry(service, pluginClass, onload);
- this.addService(entry);
- service = "";
- pluginClass = "";
- }
+ service = featureName;
+ pluginClass = xml.getAttributeValue(null,"value");
+ }
+ if (service.length() > 0 && pluginClass.length() > 0) {
+ onload = "true".equals(xml.getAttributeValue(null,
+ "onload"));
+ entry = new PluginEntry(service, pluginClass, onload);
+ this.addService(entry);
+ service = "";
+ pluginClass = "";
}
}
}
@@ -161,6 +163,7 @@ public class PluginManager {
//Empty the strings to prevent plugin loading bugs
service = "";
pluginClass = "";
+ featureName ="";
insideFeature = false;
}
}
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/4b9047b7/test/res/xml/config.xml
----------------------------------------------------------------------
diff --git a/test/res/xml/config.xml b/test/res/xml/config.xml
index 675aeb5..d3ea4d8 100644
--- a/test/res/xml/config.xml
+++ b/test/res/xml/config.xml
@@ -1,57 +1,86 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<cordova>
- <!--
- access elements control the Android whitelist.
- Domains are assumed blocked unless set otherwise
- -->
-
- <access origin="http://127.0.0.1*"/> <!-- allow local pages -->
-
- <!-- <access origin="https://example.com" /> allow any secure requests to example.com -->
- <!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www -->
- <access origin=".*"/>
+<?xml version="1.0" encoding="UTF-8"?>
+<widget xmlns = "http://www.w3.org/ns/widgets"
+ id = "io.cordova.helloCordova"
+ version = "2.0.0">
+ <name>Hello Cordova</name>
+
+ <description>
+ A sample Apache Cordova application that responds to the deviceready event.
+ </description>
+
+ <author href="http://cordova.io" email="callback-dev@incubator.apache.org">
+ Apache Cordova Team
+ </author>
+
+ <access origin="*"/>
+
+
+ <!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
+ <content src="index.html" />
<log level="DEBUG"/>
+
+ <!-- Preferences for Android -->
<preference name="useBrowserHistory" value="true" />
-<plugins>
- <plugin name="App" value="org.apache.cordova.App"/>
- <plugin name="Activity" value="org.apache.cordova.test.ActivityPlugin"/>
- <plugin name="Geolocation" value="org.apache.cordova.GeoBroker"/>
- <plugin name="Device" value="org.apache.cordova.Device"/>
- <plugin name="Accelerometer" value="org.apache.cordova.AccelListener"/>
- <plugin name="Compass" value="org.apache.cordova.CompassListener"/>
- <plugin name="Media" value="org.apache.cordova.AudioHandler"/>
- <plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
- <plugin name="Contacts" value="org.apache.cordova.ContactManager"/>
- <plugin name="File" value="org.apache.cordova.FileUtils"/>
- <plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
- <plugin name="Notification" value="org.apache.cordova.Notification"/>
- <plugin name="Storage" value="org.apache.cordova.Storage"/>
- <plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
- <plugin name="Capture" value="org.apache.cordova.Capture"/>
- <plugin name="Battery" value="org.apache.cordova.BatteryListener"/>
- <plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
- <plugin name="Echo" value="org.apache.cordova.Echo" />
- <plugin name="Globalization" value="org.apache.cordova.Globalization"/>
- <plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser"/>
-</plugins>
-</cordova>
+ <preference name="exit-on-suspend" value="false" />
+
+ <feature name="App">
+ <param name="android-package" value="org.apache.cordova.App"/>
+ </feature>
+ <feature name="Geolocation">
+ <param name="android-package" value="org.apache.cordova.GeoBroker"/>
+ </feature>
+ <feature name="Device">
+ <param name="android-package" value="org.apache.cordova.Device"/>
+ </feature>
+ <feature name="Accelerometer">
+ <param name="android-package" value="org.apache.cordova.AccelListener"/>
+ </feature>
+ <feature name="Compass">
+ <param name="android-package" value="org.apache.cordova.CompassListener"/>
+ </feature>
+ <feature name="Media">
+ <param name="android-package" value="org.apache.cordova.AudioHandler"/>
+ </feature>
+ <feature name="Camera">
+ <param name="android-package" value="org.apache.cordova.CameraLauncher"/>
+ </feature>
+ <feature name="Contacts">
+ <param name="android-package" value="org.apache.cordova.ContactManager"/>
+ </feature>
+ <feature name="File">
+ <param name="android-package" value="org.apache.cordova.FileUtils"/>
+ </feature>
+ <feature name="NetworkStatus">
+ <param name="android-package" value="org.apache.cordova.NetworkManager"/>
+ </feature>
+ <feature name="Notification">
+ <param name="android-package" value="org.apache.cordova.Notification"/>
+ </feature>
+ <feature name="Storage">
+ <param name="android-package" value="org.apache.cordova.Storage"/>
+ </feature>
+ <feature name="FileTransfer">
+ <param name="android-package" value="org.apache.cordova.FileTransfer"/>
+ </feature>
+ <feature name="Capture">
+ <param name="android-package" value="org.apache.cordova.Capture"/>
+ </feature>
+ <feature name="Battery">
+ <param name="android-package" value="org.apache.cordova.BatteryListener"/>
+ </feature>
+ <feature name="SplashScreen">
+ <param name="android-package" value="org.apache.cordova.SplashScreen"/>
+ </feature>
+ <feature name="Echo">
+ <param name="android-package" value="org.apache.cordova.Echo"/>
+ </feature>
+ <feature name="Globalization">
+ <param name="android-package" value="org.apache.cordova.Globalization"/>
+ </feature>
+ <feature name="InAppBrowser">
+ <param name="android-package" value="org.apache.cordova.InAppBrowser"/>
+ </feature>
+
+</widget>
[10/13] android commit: CB-3337: Not sure why the splashscreen was
changed, fixing 9-patch
Posted by bo...@apache.org.
CB-3337: Not sure why the splashscreen was changed, fixing 9-patch
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/dbeb252f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/dbeb252f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/dbeb252f
Branch: refs/heads/3.0.0
Commit: dbeb252feec836539c84b53030b197b33e2f915d
Parents: 21614ea
Author: Joe Bowser <bo...@apache.org>
Authored: Fri May 3 15:37:48 2013 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Fri May 3 15:37:48 2013 -0700
----------------------------------------------------------------------
framework/src/org/apache/cordova/DroidGap.java | 10 ++--------
1 files changed, 2 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/dbeb252f/framework/src/org/apache/cordova/DroidGap.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java
index 3c6610f..a00d43f 100755
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@ -1040,14 +1040,8 @@ public class DroidGap extends Activity implements CordovaInterface {
root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK));
root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
- // We want the splashscreen to keep its ratio,
- // for this we need to use an ImageView and not simply the background of the LinearLayout
- ImageView splashscreenView = new ImageView(that.getActivity());
- splashscreenView.setImageResource(that.splashscreen);
- splashscreenView.setScaleType(ImageView.ScaleType.CENTER_CROP); // similar to the background-size:cover CSS property
- splashscreenView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
- root.addView(splashscreenView);
-
+ root.setBackgroundResource(that.splashscreen);
+
// Create and show the dialog
splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
// check to see if the splash screen should be full screen
[03/13] android commit: Deprecate in favour of
Posted by bo...@apache.org.
Deprecate <log> in favour of <preference name="loglevel">
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/b7990b7d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/b7990b7d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/b7990b7d
Branch: refs/heads/3.0.0
Commit: b7990b7df83413982a7d8eb115e1f13a6bd51c1a
Parents: 4b9047b
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri May 3 12:11:09 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri May 3 12:11:09 2013 -0400
----------------------------------------------------------------------
framework/src/org/apache/cordova/Config.java | 16 +++++-----------
1 files changed, 5 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/b7990b7d/framework/src/org/apache/cordova/Config.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Config.java b/framework/src/org/apache/cordova/Config.java
index 594c2b2..b9f81f0 100644
--- a/framework/src/org/apache/cordova/Config.java
+++ b/framework/src/org/apache/cordova/Config.java
@@ -97,7 +97,7 @@ public class Config {
}
else if (strNode.equals("log")) {
String level = xml.getAttributeValue(null, "level");
- LOG.i("CordovaLog", "Found log level %s", level);
+ Log.d(TAG, "The <log> tags is deprecated. Use <preference name=\"loglevel\" value=\"" + level + "\"/> instead.");
if (level != null) {
LOG.setLogLevel(level);
}
@@ -113,7 +113,10 @@ public class Config {
Note: We should probably pass in the classname for the variable splash on splashscreen!
*/
- if(name.equals("splashscreen")) {
+ if (name.equals("loglevel")) {
+ String level = xml.getAttributeValue(null, "value");
+ LOG.setLogLevel(level);
+ } else if (name.equals("splashscreen")) {
String value = xml.getAttributeValue(null, "value");
int resource = 0;
if (value != null)
@@ -123,20 +126,14 @@ public class Config {
resource = action.getResources().getIdentifier(value, "drawable", action.getPackageName());
action.getIntent().putExtra(name, resource);
- LOG.i("CordovaLog", "Found preference for %s=%s", name, value);
- Log.d("CordovaLog", "Found preference for " + name + "=" + value);
}
else if(name.equals("backgroundColor")) {
int value = xml.getAttributeIntValue(null, "value", Color.BLACK);
action.getIntent().putExtra(name, value);
- LOG.i("CordovaLog", "Found preference for %s=%d", name, value);
- Log.d("CordovaLog", "Found preference for " + name + "=" + Integer.toString(value));
}
else if(name.equals("loadUrlTimeoutValue")) {
int value = xml.getAttributeIntValue(null, "value", 20000);
action.getIntent().putExtra(name, value);
- LOG.i("CordovaLog", "Found preference for %s=%d", name, value);
- Log.d("CordovaLog", "Found preference for " + name + "=" + Integer.toString(value));
}
else if(name.equals("keepRunning"))
{
@@ -157,12 +154,9 @@ public class Config {
{
String value = xml.getAttributeValue(null, "value");
action.getIntent().putExtra(name, value);
- LOG.i("CordovaLog", "Found preference for %s=%s", name, value);
- Log.d("CordovaLog", "Found preference for " + name + "=" + value);
}
/*
LOG.i("CordovaLog", "Found preference for %s=%s", name, value);
- Log.d("CordovaLog", "Found preference for " + name + "=" + value);
*/
}
else if (strNode.equals("content")) {
[04/13] android commit: [CB-1108] Make onload=true settable as a
Posted by bo...@apache.org.
[CB-1108] Make onload=true settable as a <feature> <param>
Plus some simplification of code.
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/373da39a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/373da39a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/373da39a
Branch: refs/heads/3.0.0
Commit: 373da39ac2c9abfbf7866d76e3ace3ecc360ec96
Parents: b7990b7
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri May 3 12:18:21 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri May 3 12:18:21 2013 -0400
----------------------------------------------------------------------
.../src/org/apache/cordova/api/PluginManager.java | 35 +++++----------
1 files changed, 11 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/373da39a/framework/src/org/apache/cordova/api/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/api/PluginManager.java b/framework/src/org/apache/cordova/api/PluginManager.java
index 4cf3450..36e286e 100755
--- a/framework/src/org/apache/cordova/api/PluginManager.java
+++ b/framework/src/org/apache/cordova/api/PluginManager.java
@@ -107,9 +107,8 @@ public class PluginManager {
}
XmlResourceParser xml = this.ctx.getActivity().getResources().getXml(id);
int eventType = -1;
- String service = "", pluginClass = "", paramType = "", featureName="";
+ String service = "", pluginClass = "", paramType = "";
boolean onload = false;
- PluginEntry entry = null;
boolean insideFeature = false;
while (eventType != XmlResourceParser.END_DOCUMENT) {
if (eventType == XmlResourceParser.START_TAG) {
@@ -118,52 +117,40 @@ public class PluginManager {
if (strNode.equals("plugin")) {
service = xml.getAttributeValue(null, "name");
pluginClass = xml.getAttributeValue(null, "value");
- // System.out.println("Plugin: "+name+" => "+value);
Log.d(TAG, "<plugin> tags are deprecated, please use <features> instead. <plugin> will no longer work as of Cordova 3.0");
onload = "true".equals(xml.getAttributeValue(null, "onload"));
- entry = new PluginEntry(service, pluginClass, onload);
- this.addService(entry);
}
//What is this?
else if (strNode.equals("url-filter")) {
this.urlMap.put(xml.getAttributeValue(null, "value"), service);
}
else if (strNode.equals("feature")) {
- insideFeature = true;
//Check for supported feature sets aka. plugins (Accelerometer, Geolocation, etc)
//Set the bit for reading params
- featureName = xml.getAttributeValue(null,"name");
+ insideFeature = true;
+ service = xml.getAttributeValue(null, "name");
}
- else if( insideFeature && strNode.equals("param")) {
+ else if (insideFeature && strNode.equals("param")) {
paramType = xml.getAttributeValue(null, "name");
if (paramType.equals("service")) // check if it is using the older service param
service = xml.getAttributeValue(null, "value");
- else if (paramType.equals("package"))
- pluginClass = xml.getAttributeValue(null, "value");
- else if (paramType.equals("android-package"))
- {
- service = featureName;
+ else if (paramType.equals("package") || paramType.equals("android-package"))
pluginClass = xml.getAttributeValue(null,"value");
- }
- if (service.length() > 0 && pluginClass.length() > 0) {
- onload = "true".equals(xml.getAttributeValue(null,
- "onload"));
- entry = new PluginEntry(service, pluginClass, onload);
- this.addService(entry);
- service = "";
- pluginClass = "";
- }
+ else if (paramType.equals("onload"))
+ onload = "true".equals(xml.getAttributeValue(null, "onload"));
}
}
else if (eventType == XmlResourceParser.END_TAG)
{
String strNode = xml.getName();
- if(strNode.equals("feature"))
+ if (strNode.equals("feature") || strNode.equals("plugin"))
{
+ PluginEntry entry = new PluginEntry(service, pluginClass, onload);
+ this.addService(entry);
+
//Empty the strings to prevent plugin loading bugs
service = "";
pluginClass = "";
- featureName ="";
insideFeature = false;
}
}
[06/13] android commit: [CB-3040] length is 1-based,
but index is 0-based, can't use == in comparison
Posted by bo...@apache.org.
[CB-3040] length is 1-based, but index is 0-based, can't use == in comparison
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/2d4d18fd
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/2d4d18fd
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/2d4d18fd
Branch: refs/heads/3.0.0
Commit: 2d4d18fd75a56384b4aebadc86ddf27a75b8e0f6
Parents: 27cd9dd
Author: Abel MuiƱo <am...@gmail.com>
Authored: Mon Apr 15 21:27:13 2013 +0200
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri May 3 13:13:48 2013 -0400
----------------------------------------------------------------------
framework/src/org/apache/cordova/FileTransfer.java | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/2d4d18fd/framework/src/org/apache/cordova/FileTransfer.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileTransfer.java b/framework/src/org/apache/cordova/FileTransfer.java
index 3216a45..c87683f 100644
--- a/framework/src/org/apache/cordova/FileTransfer.java
+++ b/framework/src/org/apache/cordova/FileTransfer.java
@@ -685,7 +685,7 @@ public class FileTransfer extends CordovaPlugin {
*/
private static String getArgument(JSONArray args, int position, String defaultString) {
String arg = defaultString;
- if (args.length() >= position) {
+ if (args.length() > position) {
arg = args.optString(position);
if (arg == null || "null".equals(arg)) {
arg = defaultString;
[12/13] android commit: Part 2 of 2: CB-2657 Creating the dummy class
so we have backwards compatibility
Posted by bo...@apache.org.
Part 2 of 2: CB-2657 Creating the dummy class so we have backwards compatibility
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/48b8c69b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/48b8c69b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/48b8c69b
Branch: refs/heads/3.0.0
Commit: 48b8c69ba0ebe1d093ef2c6721d007178f59ef8b
Parents: 35d53a0
Author: Joe Bowser <bo...@apache.org>
Authored: Tue May 7 09:46:26 2013 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Tue May 7 09:46:26 2013 -0700
----------------------------------------------------------------------
framework/src/org/apache/cordova/DroidGap.java | 26 +++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/48b8c69b/framework/src/org/apache/cordova/DroidGap.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java
new file mode 100644
index 0000000..fbaf6c4
--- /dev/null
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@ -0,0 +1,26 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+// We moved everything to CordovaActivity
+
+package org.apache.cordova;
+
+public class DroidGap extends CordovaActivity {
+
+}
[13/13] android commit: Merging latest from master to bring
everything in line
Posted by bo...@apache.org.
Merging latest from master to bring everything in line
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/d840446d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/d840446d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/d840446d
Branch: refs/heads/3.0.0
Commit: d840446d38ab9e58e79c5a838cee045d23da81d3
Parents: 3e01b43 48b8c69
Author: Joe Bowser <bo...@apache.org>
Authored: Tue May 7 10:45:01 2013 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Tue May 7 10:45:01 2013 -0700
----------------------------------------------------------------------
.../src/org/apache/cordova/CordovaActivity.java | 12 +++++++-
framework/src/org/apache/cordova/DroidGap.java | 21 +++++++++++++++
2 files changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/d840446d/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/CordovaActivity.java
index fa610f4,6e3d99d..af2202b
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@@ -684,8 -679,16 +684,17 @@@ public class CordovaActivity extends Ac
*/
protected void onResume() {
super.onResume();
+
+ LOG.d(TAG, "Resuming the App");
+ //Reload the configuration
+ Config.init(this);
+
+ LOG.d(TAG, "Resuming the App");
+
-
+ //Code to test CB-3064
+ String errorUrl = this.getStringProperty("errorUrl", null);
+ LOG.d(TAG, "CB-3064: The errorUrl is " + errorUrl);
+
if (this.activityState == ACTIVITY_STARTING) {
this.activityState = ACTIVITY_RUNNING;
return;
@@@ -1038,7 -1041,7 +1047,6 @@@
root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
root.setBackgroundResource(that.splashscreen);
-
-
// Create and show the dialog
splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
// check to see if the splash screen should be full screen
[09/13] android commit: Merging 3.0 with latest master
Posted by bo...@apache.org.
Merging 3.0 with latest master
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/3e01b436
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/3e01b436
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/3e01b436
Branch: refs/heads/3.0.0
Commit: 3e01b43662d03e09803eeaf00b970775e2576b8c
Parents: 21614ea 7fb8ab2
Author: Joe Bowser <bo...@apache.org>
Authored: Fri May 3 11:27:13 2013 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Fri May 3 11:27:13 2013 -0700
----------------------------------------------------------------------
bin/templates/project/assets/www/index.html | 2 +-
framework/AndroidManifest.xml | 9 +-
framework/assets/js/cordova.android.js | 247 +--
framework/assets/www/index.html | 2 +-
framework/res/xml/config.xml | 58 -
.../src/org/apache/cordova/AccelListener.java | 285 --
framework/src/org/apache/cordova/App.java | 221 --
framework/src/org/apache/cordova/AudioHandler.java | 357 ---
framework/src/org/apache/cordova/AudioPlayer.java | 553 ----
.../src/org/apache/cordova/BatteryListener.java | 163 --
.../src/org/apache/cordova/CameraLauncher.java | 807 ------
framework/src/org/apache/cordova/Capture.java | 445 ---
.../src/org/apache/cordova/CompassListener.java | 295 --
.../src/org/apache/cordova/ContactAccessor.java | 198 --
.../org/apache/cordova/ContactAccessorSdk5.java | 2174 ---------------
.../src/org/apache/cordova/ContactManager.java | 122 -
.../src/org/apache/cordova/CordovaActivity.java | 1155 ++++++++
.../apache/cordova/CordovaLocationListener.java | 251 --
.../src/org/apache/cordova/CordovaWebView.java | 2 +
.../org/apache/cordova/CordovaWebViewClient.java | 1 +
framework/src/org/apache/cordova/Device.java | 199 --
.../src/org/apache/cordova/DirectoryManager.java | 8 +-
framework/src/org/apache/cordova/DroidGap.java | 1161 +--------
framework/src/org/apache/cordova/Echo.java | 48 -
framework/src/org/apache/cordova/ExifHelper.java | 185 --
framework/src/org/apache/cordova/ExposedJsApi.java | 1 +
.../src/org/apache/cordova/FileProgressResult.java | 63 -
framework/src/org/apache/cordova/FileTransfer.java | 964 -------
.../src/org/apache/cordova/FileUploadResult.java | 73 -
framework/src/org/apache/cordova/FileUtils.java | 1059 -------
framework/src/org/apache/cordova/GPSListener.java | 50 -
framework/src/org/apache/cordova/GeoBroker.java | 206 --
.../src/org/apache/cordova/Globalization.java | 577 ----
.../src/org/apache/cordova/GlobalizationError.java | 108 -
framework/src/org/apache/cordova/HttpHandler.java | 86 -
framework/src/org/apache/cordova/InAppBrowser.java | 813 ------
.../cordova/LinearLayoutSoftKeyboardDetect.java | 5 +-
.../org/apache/cordova/NativeToJsMessageQueue.java | 1 +
.../src/org/apache/cordova/NetworkListener.java | 32 -
.../src/org/apache/cordova/NetworkManager.java | 248 --
framework/src/org/apache/cordova/Notification.java | 448 ---
framework/src/org/apache/cordova/SplashScreen.java | 43 -
framework/src/org/apache/cordova/Storage.java | 244 --
framework/src/org/apache/cordova/core/Device.java | 201 ++
44 files changed, 1411 insertions(+), 12759 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/3e01b436/framework/res/xml/config.xml
----------------------------------------------------------------------
diff --cc framework/res/xml/config.xml
index 2fb16c4,41c07e5..e1fb3ac
--- a/framework/res/xml/config.xml
+++ b/framework/res/xml/config.xml
@@@ -32,70 -32,11 +32,12 @@@
<!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
<content src="index.html" />
- <log level="DEBUG"/>
- <preference name="useBrowserHistory" value="true" />
- <preference name="exit-on-suspend" value="false" />
-<plugins>
- <plugin name="Device" value="org.apache.cordova.core.Device"/>
-</plugins>
-</cordova>
-
+ <preference name="loglevel" value="DEBUG" />
+ <!--
+ <preference name="splashscreen" value="resourceName" />
+ <preference name="backgroundColor" value="0xFFF" />
+ <preference name="loadUrlTimeoutValue" value="20000" />
+ <preference name="InAppBrowserStorageEnabled" value="true" />
+ <preference name="disallowOverscroll" value="true" />
+ -->
-
- <feature name="App">
- <param name="android-package" value="org.apache.cordova.App"/>
- </feature>
- <feature name="Geolocation">
- <param name="android-package" value="org.apache.cordova.GeoBroker"/>
- </feature>
- <feature name="Device">
- <param name="android-package" value="org.apache.cordova.Device"/>
- </feature>
- <feature name="Accelerometer">
- <param name="android-package" value="org.apache.cordova.AccelListener"/>
- </feature>
- <feature name="Compass">
- <param name="android-package" value="org.apache.cordova.CompassListener"/>
- </feature>
- <feature name="Media">
- <param name="android-package" value="org.apache.cordova.AudioHandler"/>
- </feature>
- <feature name="Camera">
- <param name="android-package" value="org.apache.cordova.CameraLauncher"/>
- </feature>
- <feature name="Contacts">
- <param name="android-package" value="org.apache.cordova.ContactManager"/>
- </feature>
- <feature name="File">
- <param name="android-package" value="org.apache.cordova.FileUtils"/>
- </feature>
- <feature name="NetworkStatus">
- <param name="android-package" value="org.apache.cordova.NetworkManager"/>
- </feature>
- <feature name="Notification">
- <param name="android-package" value="org.apache.cordova.Notification"/>
- </feature>
- <feature name="Storage">
- <param name="android-package" value="org.apache.cordova.Storage"/>
- </feature>
- <feature name="FileTransfer">
- <param name="android-package" value="org.apache.cordova.FileTransfer"/>
- </feature>
- <feature name="Capture">
- <param name="android-package" value="org.apache.cordova.Capture"/>
- </feature>
- <feature name="Battery">
- <param name="android-package" value="org.apache.cordova.BatteryListener"/>
- </feature>
- <feature name="SplashScreen">
- <param name="android-package" value="org.apache.cordova.SplashScreen"/>
- </feature>
- <feature name="Echo">
- <param name="android-package" value="org.apache.cordova.Echo"/>
- </feature>
- <feature name="Globalization">
- <param name="android-package" value="org.apache.cordova.Globalization"/>
- </feature>
- <feature name="InAppBrowser">
- <param name="android-package" value="org.apache.cordova.InAppBrowser"/>
- </feature>
+</widget>
[05/13] android commit: [CB-1108] Update config.xml template's list
of available s
Posted by bo...@apache.org.
[CB-1108] Update config.xml template's list of available <preference>s
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/27cd9dde
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/27cd9dde
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/27cd9dde
Branch: refs/heads/3.0.0
Commit: 27cd9dde38368e8eab7b84a20a1f21a595313853
Parents: 373da39
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri May 3 12:18:36 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri May 3 12:18:36 2013 -0400
----------------------------------------------------------------------
framework/res/xml/config.xml | 32 ++++++++++++++++++++++++--------
1 files changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/27cd9dde/framework/res/xml/config.xml
----------------------------------------------------------------------
diff --git a/framework/res/xml/config.xml b/framework/res/xml/config.xml
index c915f0c..2fb16c4 100644
--- a/framework/res/xml/config.xml
+++ b/framework/res/xml/config.xml
@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
<widget xmlns = "http://www.w3.org/ns/widgets"
id = "io.cordova.helloCordova"
version = "2.0.0">
@@ -8,21 +23,23 @@
A sample Apache Cordova application that responds to the deviceready event.
</description>
- <author href="http://cordova.io" email="callback-dev@incubator.apache.org">
+ <author href="http://cordova.io" email="dev@cordova.apache.org">
Apache Cordova Team
</author>
<access origin="*"/>
-
<!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
<content src="index.html" />
- <log level="DEBUG"/>
-
- <!-- Preferences for Android -->
- <preference name="useBrowserHistory" value="true" />
- <preference name="exit-on-suspend" value="false" />
+ <preference name="loglevel" value="DEBUG" />
+ <!--
+ <preference name="splashscreen" value="resourceName" />
+ <preference name="backgroundColor" value="0xFFF" />
+ <preference name="loadUrlTimeoutValue" value="20000" />
+ <preference name="InAppBrowserStorageEnabled" value="true" />
+ <preference name="disallowOverscroll" value="true" />
+ -->
<feature name="App">
<param name="android-package" value="org.apache.cordova.App"/>
@@ -81,5 +98,4 @@
<feature name="InAppBrowser">
<param name="android-package" value="org.apache.cordova.InAppBrowser"/>
</feature>
-
</widget>