diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1594d12..f7dbcab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,24 @@ + + # Contributing to Apache Cordova Anyone can contribute to Cordova. And we need your contributions. diff --git a/NOTICE b/NOTICE index 8ec56a5..fb19cbd 100644 --- a/NOTICE +++ b/NOTICE @@ -3,3 +3,6 @@ Copyright 2012 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). + +This product includes software developed by Apple Inc. License can be found in the header of the affected files. (src/ios/CDVReachability.h, src/ios/CDVReachability.m) + diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 0a81aa7..dc21f3b 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -53,3 +53,12 @@ * CB-6460: Update license headers * CB-6465: Add license headers to Tizen code * Add NOTICE file + +### 0.2.9 (Jun 05, 2014) +* updated notice file to include missing license +* Cached extra info to better detect changes. +* CB-6809 Add license to CONTRIBUTING.md +* CB-6491 add CONTRIBUTING.md +* CB-6350 - Fix networkStatusForFlags return value type to work with 64-bit iOS (closes #8) +* Initial version of firefox os network information plugin +* there was an error in the object definition diff --git a/plugin.xml b/plugin.xml index 994cc94..c6ae743 100644 --- a/plugin.xml +++ b/plugin.xml @@ -21,7 +21,7 @@ + version="0.2.10-dev"> Network Information Cordova Network Information Plugin diff --git a/src/android/NetworkManager.java b/src/android/NetworkManager.java index e2ac500..aa4e161 100755 --- a/src/android/NetworkManager.java +++ b/src/android/NetworkManager.java @@ -24,6 +24,8 @@ import org.apache.cordova.CordovaPlugin; import org.apache.cordova.PluginResult; import org.apache.cordova.CordovaWebView; import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; import android.content.BroadcastReceiver; import android.content.Context; @@ -75,7 +77,7 @@ public class NetworkManager extends CordovaPlugin { ConnectivityManager sockMan; BroadcastReceiver receiver; - private String lastStatus = ""; + private JSONObject lastInfo = null; /** * Constructor. @@ -104,7 +106,7 @@ public class NetworkManager extends CordovaPlugin { @Override public void onReceive(Context context, Intent intent) { // (The null check is for the ARM Emulator, please use Intel Emulator for better results) - if(NetworkManager.this.webView != null) + if(NetworkManager.this.webView != null) updateConnectionInfo(sockMan.getActiveNetworkInfo()); } }; @@ -126,7 +128,12 @@ public class NetworkManager extends CordovaPlugin { if (action.equals("getConnectionInfo")) { this.connectionCallbackContext = callbackContext; NetworkInfo info = sockMan.getActiveNetworkInfo(); - PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, this.getConnectionInfo(info)); + String connectionType = ""; + try { + connectionType = this.getConnectionInfo(info).get("type").toString(); + } catch (JSONException e) { } + + PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, connectionType); pluginResult.setKeepCallback(true); callbackContext.sendPluginResult(pluginResult); return true; @@ -161,13 +168,17 @@ public class NetworkManager extends CordovaPlugin { private void updateConnectionInfo(NetworkInfo info) { // send update to javascript "navigator.network.connection" // Jellybean sends its own info - String thisStatus = this.getConnectionInfo(info); - if(!thisStatus.equals(lastStatus)) + JSONObject thisInfo = this.getConnectionInfo(info); + if(!thisInfo.equals(lastInfo)) { - sendUpdate(thisStatus); - lastStatus = thisStatus; + String connectionType = ""; + try { + connectionType = thisInfo.get("type").toString(); + } catch (JSONException e) { } + + sendUpdate(connectionType); + lastInfo = thisInfo; } - } /** @@ -176,8 +187,9 @@ public class NetworkManager extends CordovaPlugin { * @param info the current active network info * @return a JSONObject that represents the network info */ - private String getConnectionInfo(NetworkInfo info) { + private JSONObject getConnectionInfo(NetworkInfo info) { String type = TYPE_NONE; + String extraInfo = ""; if (info != null) { // If we are not connected to any network set type to none if (!info.isConnected()) { @@ -186,9 +198,20 @@ public class NetworkManager extends CordovaPlugin { else { type = getType(info); } + extraInfo = info.getExtraInfo(); } + Log.d("CordovaNetworkManager", "Connection Type: " + type); - return type; + Log.d("CordovaNetworkManager", "Connection Extra Info: " + extraInfo); + + JSONObject connectionInfo = new JSONObject(); + + try { + connectionInfo.put("type", type); + connectionInfo.put("extraInfo", extraInfo); + } catch (JSONException e) { } + + return connectionInfo; } /** @@ -247,3 +270,4 @@ public class NetworkManager extends CordovaPlugin { return TYPE_UNKNOWN; } } +