From a12110e6fac5edc7e0ab405f69ae9c97e14d8544 Mon Sep 17 00:00:00 2001 From: RandyMcMillan Date: Sat, 5 May 2012 16:38:16 -0400 Subject: [PATCH] . --- .../avantic/diagnosticPlugin/Diagnostic.java | 298 +++++++++--------- Android/Diagnostic/www/diagnostic.js | 256 +++++++-------- iOS/Diagnostic/diagnostic.js | 202 ++++++------ iOS/Diagnostic/example/www/init.js | 244 +++++++------- 4 files changed, 500 insertions(+), 500 deletions(-) diff --git a/Android/Diagnostic/src/net/avantic/diagnosticPlugin/Diagnostic.java b/Android/Diagnostic/src/net/avantic/diagnosticPlugin/Diagnostic.java index f30576f4..5d7d5186 100644 --- a/Android/Diagnostic/src/net/avantic/diagnosticPlugin/Diagnostic.java +++ b/Android/Diagnostic/src/net/avantic/diagnosticPlugin/Diagnostic.java @@ -1,150 +1,150 @@ -/** - * Plugin diagnostic - * - * Copyright (c) 2012 AVANTIC ESTUDIO DE INGENIEROS - * -**/ - -package net.avantic.diagnosticPlugin; - -import org.apache.cordova.api.PluginResult.Status; -import org.json.JSONArray; - -import android.bluetooth.BluetoothAdapter; -import android.content.Context; -import android.content.Intent; -import android.location.LocationManager; -import android.net.wifi.WifiManager; -import android.os.Looper; -import android.provider.Settings; -import android.util.Log; - -import com.phonegap.api.Plugin; -import com.phonegap.api.PluginResult; - -public class Diagnostic extends Plugin { - - private static final String LOG_TAG = "Diagnostic"; - - - @Override - public PluginResult execute(String action, JSONArray args, String callbackId) { - Log.d(LOG_TAG, "Executing Diagnostic Plugin"); - if ("isLocationEnabled".equals(action)) - return new PluginResult(Status.OK, isLocationEnabled()); - else if ("switchToLocationSettings".equals(action)) { - switchToLocationSettings(); - return new PluginResult(Status.OK); - } else if ("isGpsEnabled".equals(action)) - return new PluginResult(Status.OK, isGpsEnabled()); - else if ("isWirelessNetworkLocationEnabled".equals(action)) - return new PluginResult(Status.OK, isWirelessNetworkLocationEnabled()); - else if ("isWifiEnabled".equals(action)) - return new PluginResult(Status.OK, isWifiEnabled()); - else if ("switchToWifiSettings".equals(action)) { - switchToWifiSettings(); - return new PluginResult(Status.OK); - } else if ("isBluetoothEnabled".equals(action)) - return new PluginResult(Status.OK, isBluetoothEnabled()); - else if ("switchToBluetoothSettings".equals(action)) { - switchToBluetoothSettings(); - return new PluginResult(Status.OK); - } else { - Log.d(LOG_TAG, "Invalid action"); - return new PluginResult(Status.INVALID_ACTION); - } - } - - - /** - * Check device settings for location. - * - * @returns {boolean} The status of location services in device settings. - */ - public boolean isLocationEnabled() { - boolean result = (isGpsEnabled() || isWirelessNetworkLocationEnabled()); - Log.d(LOG_TAG, "Location enabled: " + result); - return result; - } - - /** - * Requests that the user enable the location in device settings. - */ - public void switchToLocationSettings() { - Log.d(LOG_TAG, "Switch to Location Settings"); - Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); - ctx.startActivity(settingsIntent); - } - - /** - * Check device settings for GPS. - * - * @returns {boolean} The status of GPS in device settings. - */ - public boolean isGpsEnabled() { - boolean result = isLocationProviderEnabled(LocationManager.GPS_PROVIDER); - Log.d(LOG_TAG, "GPS enabled: " + result); - return result; - } - - /** - * Check device settings for wireless network location (Wi-Fi and/or mobile - * networks). - * - * @returns {boolean} The status of wireless network location in device - * settings. - */ - public boolean isWirelessNetworkLocationEnabled() { - boolean result = isLocationProviderEnabled(LocationManager.NETWORK_PROVIDER); - Log.d(LOG_TAG, "Wireless Network Location enabled: " + result); - return result; - } - - private boolean isLocationProviderEnabled(String provider) { - LocationManager locationManager = (LocationManager) ctx.getSystemService(Context.LOCATION_SERVICE); - return locationManager.isProviderEnabled(provider); - } - - /** - * Check device settings for Wi-Fi. - * - * @returns {boolean} The status of Wi-Fi in device settings. - */ - public boolean isWifiEnabled() { - WifiManager wifiManager = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE); - boolean result = wifiManager.isWifiEnabled(); - Log.d(LOG_TAG, "Wifi enabled: " + result); - return result; - } - - /** - * Requests that the user enable the Wi-Fi in device settings. - */ - public void switchToWifiSettings() { - Log.d(LOG_TAG, "Switch to Wifi Settings"); - Intent settingsIntent = new Intent(Settings.ACTION_WIFI_SETTINGS); - ctx.startActivity(settingsIntent); - } - - /** - * Check device settings for Bluetooth. - * - * @returns {boolean} The status of Bluetooth in device settings. - */ - public boolean isBluetoothEnabled() { - Looper.prepare(); - BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); - boolean result = bluetoothAdapter.isEnabled(); - Log.d(LOG_TAG, "Bluetooth enabled: " + result); - return result; - } - - /** - * Requests that the user enable the Bluetooth in device settings. - */ - public void switchToBluetoothSettings() { - Log.d(LOG_TAG, "Switch to Bluetooth Settings"); - Intent settingsIntent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS); - ctx.startActivity(settingsIntent); - } +/** + * Plugin diagnostic + * + * Copyright (c) 2012 AVANTIC ESTUDIO DE INGENIEROS + * +**/ + +package net.avantic.diagnosticPlugin; + +import org.apache.cordova.api.PluginResult.Status; +import org.json.JSONArray; + +import android.bluetooth.BluetoothAdapter; +import android.content.Context; +import android.content.Intent; +import android.location.LocationManager; +import android.net.wifi.WifiManager; +import android.os.Looper; +import android.provider.Settings; +import android.util.Log; + +import com.phonegap.api.Plugin; +import com.phonegap.api.PluginResult; + +public class Diagnostic extends Plugin { + + private static final String LOG_TAG = "Diagnostic"; + + + @Override + public PluginResult execute(String action, JSONArray args, String callbackId) { + Log.d(LOG_TAG, "Executing Diagnostic Plugin"); + if ("isLocationEnabled".equals(action)) + return new PluginResult(Status.OK, isLocationEnabled()); + else if ("switchToLocationSettings".equals(action)) { + switchToLocationSettings(); + return new PluginResult(Status.OK); + } else if ("isGpsEnabled".equals(action)) + return new PluginResult(Status.OK, isGpsEnabled()); + else if ("isWirelessNetworkLocationEnabled".equals(action)) + return new PluginResult(Status.OK, isWirelessNetworkLocationEnabled()); + else if ("isWifiEnabled".equals(action)) + return new PluginResult(Status.OK, isWifiEnabled()); + else if ("switchToWifiSettings".equals(action)) { + switchToWifiSettings(); + return new PluginResult(Status.OK); + } else if ("isBluetoothEnabled".equals(action)) + return new PluginResult(Status.OK, isBluetoothEnabled()); + else if ("switchToBluetoothSettings".equals(action)) { + switchToBluetoothSettings(); + return new PluginResult(Status.OK); + } else { + Log.d(LOG_TAG, "Invalid action"); + return new PluginResult(Status.INVALID_ACTION); + } + } + + + /** + * Check device settings for location. + * + * @returns {boolean} The status of location services in device settings. + */ + public boolean isLocationEnabled() { + boolean result = (isGpsEnabled() || isWirelessNetworkLocationEnabled()); + Log.d(LOG_TAG, "Location enabled: " + result); + return result; + } + + /** + * Requests that the user enable the location in device settings. + */ + public void switchToLocationSettings() { + Log.d(LOG_TAG, "Switch to Location Settings"); + Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); + ctx.startActivity(settingsIntent); + } + + /** + * Check device settings for GPS. + * + * @returns {boolean} The status of GPS in device settings. + */ + public boolean isGpsEnabled() { + boolean result = isLocationProviderEnabled(LocationManager.GPS_PROVIDER); + Log.d(LOG_TAG, "GPS enabled: " + result); + return result; + } + + /** + * Check device settings for wireless network location (Wi-Fi and/or mobile + * networks). + * + * @returns {boolean} The status of wireless network location in device + * settings. + */ + public boolean isWirelessNetworkLocationEnabled() { + boolean result = isLocationProviderEnabled(LocationManager.NETWORK_PROVIDER); + Log.d(LOG_TAG, "Wireless Network Location enabled: " + result); + return result; + } + + private boolean isLocationProviderEnabled(String provider) { + LocationManager locationManager = (LocationManager) ctx.getSystemService(Context.LOCATION_SERVICE); + return locationManager.isProviderEnabled(provider); + } + + /** + * Check device settings for Wi-Fi. + * + * @returns {boolean} The status of Wi-Fi in device settings. + */ + public boolean isWifiEnabled() { + WifiManager wifiManager = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE); + boolean result = wifiManager.isWifiEnabled(); + Log.d(LOG_TAG, "Wifi enabled: " + result); + return result; + } + + /** + * Requests that the user enable the Wi-Fi in device settings. + */ + public void switchToWifiSettings() { + Log.d(LOG_TAG, "Switch to Wifi Settings"); + Intent settingsIntent = new Intent(Settings.ACTION_WIFI_SETTINGS); + ctx.startActivity(settingsIntent); + } + + /** + * Check device settings for Bluetooth. + * + * @returns {boolean} The status of Bluetooth in device settings. + */ + public boolean isBluetoothEnabled() { + Looper.prepare(); + BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); + boolean result = bluetoothAdapter.isEnabled(); + Log.d(LOG_TAG, "Bluetooth enabled: " + result); + return result; + } + + /** + * Requests that the user enable the Bluetooth in device settings. + */ + public void switchToBluetoothSettings() { + Log.d(LOG_TAG, "Switch to Bluetooth Settings"); + Intent settingsIntent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS); + ctx.startActivity(settingsIntent); + } } \ No newline at end of file diff --git a/Android/Diagnostic/www/diagnostic.js b/Android/Diagnostic/www/diagnostic.js index afc1899c..e1ef6c82 100644 --- a/Android/Diagnostic/www/diagnostic.js +++ b/Android/Diagnostic/www/diagnostic.js @@ -1,129 +1,129 @@ -/** - * Plugin diagnostic - * - * Copyright (c) 2012 AVANTIC ESTUDIO DE INGENIEROS - * -**/ - - -var Diagnostic = function() { -}; - - -/** - * Checks device settings for location. - * - * @param successCallback The callback which will be called when diagnostic of location is successful. - * This callback function have a boolean param with the diagnostic result. - * @param errorCallback The callback which will be called when diagnostic of location encounters an error. - * This callback function have a string param with the error. - */ -Diagnostic.prototype.isLocationEnabled = function(successCallback, errorCallback) { - return cordova.exec(successCallback, - errorCallback, - 'Diagnostic', - 'isLocationEnabled', - []); -}; - -/** - * Requests that the user enable the location services in device settings. - */ -Diagnostic.prototype.switchToLocationSettings = function() { - return cordova.exec(null, - null, - 'Diagnostic', - 'switchToLocationSettings', - []); -}; - -/** - * Checks device settings for GPS. - * - * @param successCallback The callback which will be called when diagnostic of GPS is successful. - * This callback function have a boolean param with the diagnostic result. - * @param errorCallback The callback which will be called when diagnostic of GPS encounters an error. - * This callback function have a string param with the error. - */ -Diagnostic.prototype.isGpsEnabled = function(successCallback, errorCallback) { - return cordova.exec(successCallback, - errorCallback, - 'Diagnostic', - 'isGpsEnabled', - []); -}; - -/** - * Checks device settings for wireless network location (Wi-Fi and/or mobile networks). - * - * @param successCallback The callback which will be called when diagnostic of wireless network location is successful. - * This callback function have a boolean param with the diagnostic result. - * @param errorCallback The callback which will be called when diagnostic of wireless network location encounters an error. - * This callback function have a string param with the error. - */ -Diagnostic.prototype.isWirelessNetworkLocationEnabled = function(successCallback, errorCallback) { - return cordova.exec(successCallback, - errorCallback, - 'Diagnostic', - 'isWirelessNetworkLocationEnabled', - []); -}; - -/** - * Checks device settings for Wi-Fi. - * - * @param successCallback The callback which will be called when diagnostic of Wi-Fi is successful. - * This callback function have a boolean param with the diagnostic result. - * @param errorCallback The callback which will be called when diagnostic of Wi-Fi encounters an error. - * This callback function have a string param with the error. - */ -Diagnostic.prototype.isWifiEnabled = function(successCallback, errorCallback) { - return cordova.exec(successCallback, - errorCallback, - 'Diagnostic', - 'isWifiEnabled', - []); -}; - -/** - * Requests that the user enable the Wi-Fi in device settings. - */ -Diagnostic.prototype.switchToWifiSettings = function() { - return cordova.exec(null, - null, - 'Diagnostic', - 'switchToWifiSettings', - []); -}; - -/** - * Checks device settings for bluetooth. - * - * @param successCallback The callback which will be called when diagnostic of bluetooth is successful. - * This callback function have a boolean param with the diagnostic result. - * @param errorCallback The callback which will be called when diagnostic of bluetooth encounters an error. - * This callback function have a string param with the error. - */ -Diagnostic.prototype.isBluetoothEnabled = function(successCallback, errorCallback) { - return cordova.exec(successCallback, - errorCallback, - 'Diagnostic', - 'isBluetoothEnabled', - []); -}; - - -/** - * Requests that the user enable the bluetooth in device settings. - */ -Diagnostic.prototype.switchToBluetoothSettings = function() { - return cordova.exec(null, - null, - 'Diagnostic', - 'switchToBluetoothSettings', - []); -}; - -cordova.addConstructor(function() { - cordova.addPlugin("diagnostic", new Diagnostic()); +/** + * Plugin diagnostic + * + * Copyright (c) 2012 AVANTIC ESTUDIO DE INGENIEROS + * +**/ + + +var Diagnostic = function() { +}; + + +/** + * Checks device settings for location. + * + * @param successCallback The callback which will be called when diagnostic of location is successful. + * This callback function have a boolean param with the diagnostic result. + * @param errorCallback The callback which will be called when diagnostic of location encounters an error. + * This callback function have a string param with the error. + */ +Diagnostic.prototype.isLocationEnabled = function(successCallback, errorCallback) { + return cordova.exec(successCallback, + errorCallback, + 'Diagnostic', + 'isLocationEnabled', + []); +}; + +/** + * Requests that the user enable the location services in device settings. + */ +Diagnostic.prototype.switchToLocationSettings = function() { + return cordova.exec(null, + null, + 'Diagnostic', + 'switchToLocationSettings', + []); +}; + +/** + * Checks device settings for GPS. + * + * @param successCallback The callback which will be called when diagnostic of GPS is successful. + * This callback function have a boolean param with the diagnostic result. + * @param errorCallback The callback which will be called when diagnostic of GPS encounters an error. + * This callback function have a string param with the error. + */ +Diagnostic.prototype.isGpsEnabled = function(successCallback, errorCallback) { + return cordova.exec(successCallback, + errorCallback, + 'Diagnostic', + 'isGpsEnabled', + []); +}; + +/** + * Checks device settings for wireless network location (Wi-Fi and/or mobile networks). + * + * @param successCallback The callback which will be called when diagnostic of wireless network location is successful. + * This callback function have a boolean param with the diagnostic result. + * @param errorCallback The callback which will be called when diagnostic of wireless network location encounters an error. + * This callback function have a string param with the error. + */ +Diagnostic.prototype.isWirelessNetworkLocationEnabled = function(successCallback, errorCallback) { + return cordova.exec(successCallback, + errorCallback, + 'Diagnostic', + 'isWirelessNetworkLocationEnabled', + []); +}; + +/** + * Checks device settings for Wi-Fi. + * + * @param successCallback The callback which will be called when diagnostic of Wi-Fi is successful. + * This callback function have a boolean param with the diagnostic result. + * @param errorCallback The callback which will be called when diagnostic of Wi-Fi encounters an error. + * This callback function have a string param with the error. + */ +Diagnostic.prototype.isWifiEnabled = function(successCallback, errorCallback) { + return cordova.exec(successCallback, + errorCallback, + 'Diagnostic', + 'isWifiEnabled', + []); +}; + +/** + * Requests that the user enable the Wi-Fi in device settings. + */ +Diagnostic.prototype.switchToWifiSettings = function() { + return cordova.exec(null, + null, + 'Diagnostic', + 'switchToWifiSettings', + []); +}; + +/** + * Checks device settings for bluetooth. + * + * @param successCallback The callback which will be called when diagnostic of bluetooth is successful. + * This callback function have a boolean param with the diagnostic result. + * @param errorCallback The callback which will be called when diagnostic of bluetooth encounters an error. + * This callback function have a string param with the error. + */ +Diagnostic.prototype.isBluetoothEnabled = function(successCallback, errorCallback) { + return cordova.exec(successCallback, + errorCallback, + 'Diagnostic', + 'isBluetoothEnabled', + []); +}; + + +/** + * Requests that the user enable the bluetooth in device settings. + */ +Diagnostic.prototype.switchToBluetoothSettings = function() { + return cordova.exec(null, + null, + 'Diagnostic', + 'switchToBluetoothSettings', + []); +}; + +cordova.addConstructor(function() { + cordova.addPlugin("diagnostic", new Diagnostic()); }); \ No newline at end of file diff --git a/iOS/Diagnostic/diagnostic.js b/iOS/Diagnostic/diagnostic.js index 84d333f2..89bac318 100644 --- a/iOS/Diagnostic/diagnostic.js +++ b/iOS/Diagnostic/diagnostic.js @@ -1,102 +1,102 @@ -/** - * Plugin diagnostic - * - * Copyright (c) 2012 AVANTIC ESTUDIO DE INGENIEROS - * -**/ - - -var Diagnostic = function() { -}; - -/** - * Checks if location is enabled (Device setting for location and authorization). - * - * @param successCallback The callback which will be called when diagnostic of location is successful. - * This callback function have a boolean param with the diagnostic result. - * @param errorCallback The callback which will be called when diagnostic of location encounters an error. - * This callback function have a string param with the error. - */ - -Diagnostic.prototype.isLocationEnabled = function(successCallback, errorCallback) { - return cordova.exec(successCallback, - errorCallback, - 'Diagnostic', - 'isLocationEnabled', - []); -}; - -/** - * Checks device settings for location. - * - * @param successCallback The callback which will be called when diagnostic of location is successful. - * This callback function have a boolean param with the diagnostic result. - * @param errorCallback The callback which will be called when diagnostic of location encounters an error. - * This callback function have a string param with the error. - */ - -Diagnostic.prototype.isLocationEnabledSetting = function(successCallback, errorCallback) { - return cordova.exec(successCallback, - errorCallback, - 'Diagnostic', - 'isLocationEnabledSetting', - []); -}; - -/** - * Checks if the application is authorized to use location. - * - * @param successCallback The callback which will be called when diagnostic of location is successful. - * This callback function have a boolean param with the diagnostic result. - * @param errorCallback The callback which will be called when diagnostic of location encounters an error. - * This callback function have a string param with the error. - */ - -Diagnostic.prototype.isLocationAuthorized = function(successCallback, errorCallback) { - return cordova.exec(successCallback, - errorCallback, - 'Diagnostic', - 'isLocationAuthorized', - []); -}; - -/** - * Checks if exists Wi-Fi connection. - * - * @param successCallback The callback which will be called when diagnostic of Wi-Fi is successful. - * This callback function have a boolean param with the diagnostic result. - * @param errorCallback The callback which will be called when diagnostic of Wi-Fi encounters an error. - * This callback function have a string param with the error. - */ - -Diagnostic.prototype.isWifiEnabled = function(successCallback, errorCallback) { - return cordova.exec(successCallback, - errorCallback, - 'Diagnostic', - 'isWifiEnabled', - []); -}; - -/** - * Checks if exists camera. - * - * @param successCallback The callback which will be called when diagnostic of camera is successful. - * This callback function have a boolean param with the diagnostic result. - * @param errorCallback The callback which will be called when diagnostic of camera encounters an error. - * This callback function have a string param with the error. - */ - - -Diagnostic.prototype.isCameraEnabled = function(successCallback, errorCallback) { - return cordova.exec(successCallback, - errorCallback, - 'Diagnostic', - 'isCameraEnabled', - []); -}; - -cordova.addConstructor(function() { - if(!window.plugins) - window.plugins = {}; - window.plugins.diagnostic = new Diagnostic(); +/** + * Plugin diagnostic + * + * Copyright (c) 2012 AVANTIC ESTUDIO DE INGENIEROS + * +**/ + + +var Diagnostic = function() { +}; + +/** + * Checks if location is enabled (Device setting for location and authorization). + * + * @param successCallback The callback which will be called when diagnostic of location is successful. + * This callback function have a boolean param with the diagnostic result. + * @param errorCallback The callback which will be called when diagnostic of location encounters an error. + * This callback function have a string param with the error. + */ + +Diagnostic.prototype.isLocationEnabled = function(successCallback, errorCallback) { + return cordova.exec(successCallback, + errorCallback, + 'Diagnostic', + 'isLocationEnabled', + []); +}; + +/** + * Checks device settings for location. + * + * @param successCallback The callback which will be called when diagnostic of location is successful. + * This callback function have a boolean param with the diagnostic result. + * @param errorCallback The callback which will be called when diagnostic of location encounters an error. + * This callback function have a string param with the error. + */ + +Diagnostic.prototype.isLocationEnabledSetting = function(successCallback, errorCallback) { + return cordova.exec(successCallback, + errorCallback, + 'Diagnostic', + 'isLocationEnabledSetting', + []); +}; + +/** + * Checks if the application is authorized to use location. + * + * @param successCallback The callback which will be called when diagnostic of location is successful. + * This callback function have a boolean param with the diagnostic result. + * @param errorCallback The callback which will be called when diagnostic of location encounters an error. + * This callback function have a string param with the error. + */ + +Diagnostic.prototype.isLocationAuthorized = function(successCallback, errorCallback) { + return cordova.exec(successCallback, + errorCallback, + 'Diagnostic', + 'isLocationAuthorized', + []); +}; + +/** + * Checks if exists Wi-Fi connection. + * + * @param successCallback The callback which will be called when diagnostic of Wi-Fi is successful. + * This callback function have a boolean param with the diagnostic result. + * @param errorCallback The callback which will be called when diagnostic of Wi-Fi encounters an error. + * This callback function have a string param with the error. + */ + +Diagnostic.prototype.isWifiEnabled = function(successCallback, errorCallback) { + return cordova.exec(successCallback, + errorCallback, + 'Diagnostic', + 'isWifiEnabled', + []); +}; + +/** + * Checks if exists camera. + * + * @param successCallback The callback which will be called when diagnostic of camera is successful. + * This callback function have a boolean param with the diagnostic result. + * @param errorCallback The callback which will be called when diagnostic of camera encounters an error. + * This callback function have a string param with the error. + */ + + +Diagnostic.prototype.isCameraEnabled = function(successCallback, errorCallback) { + return cordova.exec(successCallback, + errorCallback, + 'Diagnostic', + 'isCameraEnabled', + []); +}; + +cordova.addConstructor(function() { + if(!window.plugins) + window.plugins = {}; + window.plugins.diagnostic = new Diagnostic(); }); \ No newline at end of file diff --git a/iOS/Diagnostic/example/www/init.js b/iOS/Diagnostic/example/www/init.js index 98d87710..74824b49 100644 --- a/iOS/Diagnostic/example/www/init.js +++ b/iOS/Diagnostic/example/www/init.js @@ -1,123 +1,123 @@ - - - function onLoad() { - document.addEventListener("deviceready", onDeviceReady, false); - } - - function onDeviceReady() { - - - - // To know if the location is turned ON/OFF and if the app is allowed to use it. - window.plugins.diagnostic.isLocationEnabled(locationEnabledSuccessCallback, locationEnabledErrorCallback); - - function locationEnabledSuccessCallback(result) { - if (result) - { - //alert("Location ON"); - document.getElementById('location').innerHTML = 'ON'; - - //alert("Location Setting ON"); - document.getElementById('locationSetting').innerHTML = 'ON'; - - //alert("Auth Location ON"); - document.getElementById('locationAuthorization').innerHTML = 'ON'; - - function locationAuthorizedErrorCallback(error) { - console.log(error); - } - } - else - { - //alert("Location OFF"); - document.getElementById('location').innerHTML = 'OFF'; - // To know if the location is turned ON/OFF. - window.plugins.diagnostic.isLocationEnabledSetting(locationEnabledSettingSuccessCallback, locationEnabledSettingErrorCallback); - - function locationEnabledSettingSuccessCallback(result) { - if (result) - { - //alert("Location Setting ON"); - document.getElementById('locationSetting').innerHTML = 'ON'; - } - else - { - //alert("Location Setting OFF"); - document.getElementById('locationSetting').innerHTML = 'OFF'; - } - } - - function locationEnabledSettingErrorCallback(error) { - console.log(error); - } - - // To know if the app is allowed to use it. - window.plugins.diagnostic.isLocationAuthorized(locationAuthorizedSuccessCallback, locationAuthorizedErrorCallback); - - function locationAuthorizedSuccessCallback(result) { - if (result) - { - //alert("Auth Location ON"); - document.getElementById('locationAuthorization').innerHTML = 'ON'; - } - else - { - //alert("Auth Location OFF"); - document.getElementById('locationAuthorization').innerHTML = 'OFF'; - } - } - - function locationAuthorizedErrorCallback(error) { - console.log(error); - } - } - } - - function locationEnabledErrorCallback(error) { - console.log(error); - } - - - // To know if the WiFi is turned ON/OFF. - window.plugins.diagnostic.isWifiEnabled(wifiEnabledSuccessCallback, wifiEnabledErrorCallback); - - function wifiEnabledSuccessCallback(result) { - if (result) - { - //alert("WiFi ON"); - document.getElementById('wifi').innerHTML = 'ON'; - } - else - { - //alert("WiFi OFF"); - document.getElementById('wifi').innerHTML = 'OFF'; - } - } - - function wifiEnabledErrorCallback(error) { - console.log(error); - } - - // To know if the camera is enabled. - window.plugins.diagnostic.isCameraEnabled(cameraEnabledSuccessCallback, cameraEnabledErrorCallback); - - function cameraEnabledSuccessCallback(result) { - if (result) - { - //alert("Camera ON"); - document.getElementById('camera').innerHTML = 'ON'; - } - else - { - //alert("Camera OFF"); - document.getElementById('camera').innerHTML = 'OFF'; - } - } - - function cameraEnabledErrorCallback(error) { - console.log(error); - } - - - + + + function onLoad() { + document.addEventListener("deviceready", onDeviceReady, false); + } + + function onDeviceReady() { + + + + // To know if the location is turned ON/OFF and if the app is allowed to use it. + window.plugins.diagnostic.isLocationEnabled(locationEnabledSuccessCallback, locationEnabledErrorCallback); + + function locationEnabledSuccessCallback(result) { + if (result) + { + //alert("Location ON"); + document.getElementById('location').innerHTML = 'ON'; + + //alert("Location Setting ON"); + document.getElementById('locationSetting').innerHTML = 'ON'; + + //alert("Auth Location ON"); + document.getElementById('locationAuthorization').innerHTML = 'ON'; + + function locationAuthorizedErrorCallback(error) { + console.log(error); + } + } + else + { + //alert("Location OFF"); + document.getElementById('location').innerHTML = 'OFF'; + // To know if the location is turned ON/OFF. + window.plugins.diagnostic.isLocationEnabledSetting(locationEnabledSettingSuccessCallback, locationEnabledSettingErrorCallback); + + function locationEnabledSettingSuccessCallback(result) { + if (result) + { + //alert("Location Setting ON"); + document.getElementById('locationSetting').innerHTML = 'ON'; + } + else + { + //alert("Location Setting OFF"); + document.getElementById('locationSetting').innerHTML = 'OFF'; + } + } + + function locationEnabledSettingErrorCallback(error) { + console.log(error); + } + + // To know if the app is allowed to use it. + window.plugins.diagnostic.isLocationAuthorized(locationAuthorizedSuccessCallback, locationAuthorizedErrorCallback); + + function locationAuthorizedSuccessCallback(result) { + if (result) + { + //alert("Auth Location ON"); + document.getElementById('locationAuthorization').innerHTML = 'ON'; + } + else + { + //alert("Auth Location OFF"); + document.getElementById('locationAuthorization').innerHTML = 'OFF'; + } + } + + function locationAuthorizedErrorCallback(error) { + console.log(error); + } + } + } + + function locationEnabledErrorCallback(error) { + console.log(error); + } + + + // To know if the WiFi is turned ON/OFF. + window.plugins.diagnostic.isWifiEnabled(wifiEnabledSuccessCallback, wifiEnabledErrorCallback); + + function wifiEnabledSuccessCallback(result) { + if (result) + { + //alert("WiFi ON"); + document.getElementById('wifi').innerHTML = 'ON'; + } + else + { + //alert("WiFi OFF"); + document.getElementById('wifi').innerHTML = 'OFF'; + } + } + + function wifiEnabledErrorCallback(error) { + console.log(error); + } + + // To know if the camera is enabled. + window.plugins.diagnostic.isCameraEnabled(cameraEnabledSuccessCallback, cameraEnabledErrorCallback); + + function cameraEnabledSuccessCallback(result) { + if (result) + { + //alert("Camera ON"); + document.getElementById('camera').innerHTML = 'ON'; + } + else + { + //alert("Camera OFF"); + document.getElementById('camera').innerHTML = 'OFF'; + } + } + + function cameraEnabledErrorCallback(error) { + console.log(error); + } + + + } \ No newline at end of file