mirror of
https://gitee.com/shuto/cordova-plugin-network-information.git
synced 2025-01-18 21:52:48 +08:00
Fixed Network plugin: bad ref in plugin.xml. Added connection constants + additional global to attach to. networks JS now registers its own channel and attaches itself to deviceready as a requirement before firing deviceready.
This commit is contained in:
parent
54627b93a9
commit
8f551d6e63
@ -9,6 +9,11 @@ id="org.apache.cordova.core.NetworkManager"
|
||||
|
||||
<js-module src="www/network.js" name="network">
|
||||
<clobbers target="navigator.connection" />
|
||||
<clobbers target="navigator.network.connection" />
|
||||
</js-module>
|
||||
|
||||
<js-module src="www/Connection.js" name="Connection">
|
||||
<clobbers target="Connection" />
|
||||
</js-module>
|
||||
|
||||
<!-- android -->
|
||||
@ -23,7 +28,7 @@ id="org.apache.cordova.core.NetworkManager"
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/android/NetworkManager.java" target-dr="src/org/apache/cordova/core" />
|
||||
<source-file src="src/android/NetworkManager.java" target-dir="src/org/apache/cordova/core" />
|
||||
|
||||
</platform>
|
||||
|
||||
|
@ -22,6 +22,7 @@ import org.apache.cordova.api.CallbackContext;
|
||||
import org.apache.cordova.api.CordovaInterface;
|
||||
import org.apache.cordova.api.CordovaPlugin;
|
||||
import org.apache.cordova.api.PluginResult;
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.json.JSONArray;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
|
34
www/Connection.js
Normal file
34
www/Connection.js
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Network status
|
||||
*/
|
||||
module.exports = {
|
||||
UNKNOWN: "unknown",
|
||||
ETHERNET: "ethernet",
|
||||
WIFI: "wifi",
|
||||
CELL_2G: "2g",
|
||||
CELL_3G: "3g",
|
||||
CELL_4G: "4g",
|
||||
CELL:"cellular",
|
||||
NONE: "none"
|
||||
};
|
@ -1,5 +1,4 @@
|
||||
/*
|
||||
*
|
||||
* 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
|
||||
@ -51,6 +50,9 @@ var me = new NetworkConnection();
|
||||
var timerId = null;
|
||||
var timeout = 500;
|
||||
|
||||
channel.createSticky('onCordovaConnectionReady');
|
||||
channel.waitForInitialization('onCordovaConnectionReady');
|
||||
|
||||
channel.onCordovaReady.subscribe(function() {
|
||||
me.getInfo(function(info) {
|
||||
me.type = info;
|
||||
|
Loading…
Reference in New Issue
Block a user