community-cordova-plugin-wifi 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,10 +4,11 @@
4
4
  <option name="autoReloadType" value="SELECTIVE" />
5
5
  </component>
6
6
  <component name="ChangeListManager">
7
- <list default="true" id="5a269414-5baa-4c38-b2f3-50c21d305b88" name="Changes" comment="fixed progress bar in Ping">
7
+ <list default="true" id="5a269414-5baa-4c38-b2f3-50c21d305b88" name="Changes" comment="isConnectedToTheInternet - Support SDK&gt;29">
8
8
  <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
9
9
  <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
10
10
  <change beforePath="$PROJECT_DIR$/plugin.xml" beforeDir="false" afterPath="$PROJECT_DIR$/plugin.xml" afterDir="false" />
11
+ <change beforePath="$PROJECT_DIR$/src/android/IpInfoUtils.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/android/IpInfoUtils.java" afterDir="false" />
11
12
  <change beforePath="$PROJECT_DIR$/src/android/WifiPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/android/WifiPlugin.java" afterDir="false" />
12
13
  </list>
13
14
  <option name="SHOW_DIALOG" value="false" />
@@ -98,7 +99,7 @@
98
99
  <workItem from="1722058180072" duration="23000" />
99
100
  <workItem from="1722059814051" duration="697000" />
100
101
  <workItem from="1722061550247" duration="21000" />
101
- <workItem from="1723267322946" duration="2826000" />
102
+ <workItem from="1723267322946" duration="4719000" />
102
103
  </task>
103
104
  <task id="LOCAL-00001" summary="update plugin">
104
105
  <option name="closed" value="true" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "community-cordova-plugin-wifi",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "types": "./types/index.d.ts",
5
5
  "readme": "README.md",
6
6
  "repository": "EYALIN/community-cordova-plugin-wifi/tree/master",
package/plugin.xml CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
4
  id="community-cordova-plugin-wifi"
5
- version="1.0.4">
5
+ version="1.0.5">
6
6
  <name>Cordova Plugin Wifi</name>
7
7
  <description></description>
8
8
  <license>MIT</license>
@@ -18,6 +18,7 @@ import org.apache.cordova.PluginResult;
18
18
  import org.json.JSONArray;
19
19
  import org.json.JSONException;
20
20
  import org.json.JSONObject;
21
+ import android.util.Log;
21
22
 
22
23
  import java.io.IOException;
23
24
  import java.util.ArrayList;
@@ -123,28 +124,44 @@ public class IpInfoUtils {
123
124
  }
124
125
  }
125
126
 
126
- private static void fillLocationInfo(JSONObject ipInfoObject, LocationManager locationManager, CordovaInterface cordova) throws IOException, JSONException {
127
- Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
128
- if (location != null) {
129
- ipInfoObject.put("latitude", location.getLatitude());
130
- ipInfoObject.put("longitude", location.getLongitude());
131
- List<Address> addresses = new ArrayList<>();
132
- if (isNetworkAvailable(cordova.getActivity())) {
133
- Geocoder geocoder = new Geocoder(cordova.getActivity(), Locale.getDefault());
134
- addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
135
- }
127
+ private static void fillLocationInfo(JSONObject ipInfoObject, LocationManager locationManager, CordovaInterface cordova) throws JSONException {
128
+ Log.d(TAG, "fillLocationInfo begin");
129
+ Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
130
+ if (location != null) {
131
+ Log.d(TAG, "fillLocationInfo location is exists");
132
+ ipInfoObject.put("latitude", location.getLatitude());
133
+ ipInfoObject.put("longitude", location.getLongitude());
134
+ Log.d(TAG, "fillLocationInfo finish lat and long");
135
+
136
+ List<Address> addresses = new ArrayList<>();
137
+ if (isNetworkAvailable(cordova.getActivity())) {
138
+ try {
139
+ Log.d(TAG, "Geocoder begin");
140
+ Geocoder geocoder = new Geocoder(cordova.getActivity(), Locale.getDefault());
141
+ Log.d(TAG, "Geocoder success");
142
+ addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
143
+ Log.d(TAG, "addresses success");
144
+ } catch (IOException e) {
145
+ Log.e(TAG, "Geocoder failed due to network or I/O issues", e);
146
+ } catch (IllegalArgumentException e) {
147
+ Log.e(TAG, "Geocoder failed due to illegal arguments", e);
148
+ } catch (Exception e) {
149
+ Log.e(TAG, "Geocoder failed due to an unexpected error", e);
150
+ }
151
+ }
152
+
153
+ if (!addresses.isEmpty()) {
154
+ Address address = addresses.get(0);
155
+ ipInfoObject.put("city", address.getLocality());
156
+ ipInfoObject.put("street", address.getThoroughfare());
157
+ ipInfoObject.put("country", address.getCountryName());
158
+ ipInfoObject.put("region", address.getSubAdminArea());
159
+ ipInfoObject.put("zipcode", address.getPostalCode());
160
+ ipInfoObject.put("state", address.getAdminArea());
161
+ }
162
+ }
163
+ }
136
164
 
137
- if (!addresses.isEmpty()) {
138
- Address address = addresses.get(0);
139
- ipInfoObject.put("city", address.getLocality());
140
- ipInfoObject.put("street", address.getThoroughfare());
141
- ipInfoObject.put("country", address.getCountryName());
142
- ipInfoObject.put("region", address.getSubAdminArea());
143
- ipInfoObject.put("zipcode", address.getPostalCode());
144
- ipInfoObject.put("state", address.getAdminArea());
145
- }
146
- }
147
- }
148
165
 
149
166
  public static boolean isNetworkAvailable(Context context) {
150
167
  ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);