From 45d626c277fa79b13838e642eb3afb6fc86b9d91 Mon Sep 17 00:00:00 2001 From: Elias Lecomte Date: Sat, 23 May 2020 14:51:45 +0200 Subject: [PATCH] fix: Fix Android 10 no-internet support (#82) Co-authored-by: Elias Lecomte Co-authored-by: Thibault Maekelbergh --- CONTRIBUTORS.md | 15 +++++++++++---- android/build.gradle | 6 +++--- .../com/reactlibrary/rnwifi/RNWifiModule.java | 14 ++++++++------ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 93bc35e..e83e591 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -8,16 +8,23 @@ Nodeunit contributors (sorted alphabetically) * **[eliaslecomte](https://github.com/eliaslecomte)** * Update gradle configuration - * Update all Library in Android - + * Update Android library + * Use [WifiUtils](https://github.com/ThanosFisherman/WifiUtils/) + * Use promises over callbacks + * Return meaningful exceptions + * **[kristfal](https://github.com/kristfal)** - * [android] rename the default name of package + * [android] Rename the default name of package * **[Rapsssito](https://github.com/Rapsssito)** - * [android] added network compatibility + * [android] Added network compatibility * **[gabrielrra](https://github.com/gabrielrra)** * [docs] Update docs + +* **[thibmaek](https://github.com/thibmaek)** + + * [docs] Added type declarations diff --git a/android/build.gradle b/android/build.gradle index 59c88c8..c3c1d10 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.6.1' + classpath 'com.android.tools.build:gradle:3.6.3' } } @@ -14,7 +14,7 @@ apply plugin: 'com.android.library' android { compileSdkVersion 29 - buildToolsVersion '29.0.2' + buildToolsVersion '29.0.3' defaultConfig { minSdkVersion 21 @@ -36,6 +36,6 @@ dependencies { //noinspection GradleDynamicVersion implementation 'com.facebook.react:react-native:+' - implementation 'com.thanosfisherman.wifiutils:wifiutils:1.5.1' + implementation 'com.thanosfisherman.wifiutils:wifiutils:1.6.1' } \ No newline at end of file diff --git a/android/src/main/java/com/reactlibrary/rnwifi/RNWifiModule.java b/android/src/main/java/com/reactlibrary/rnwifi/RNWifiModule.java index 685ca9a..aeca6e2 100644 --- a/android/src/main/java/com/reactlibrary/rnwifi/RNWifiModule.java +++ b/android/src/main/java/com/reactlibrary/rnwifi/RNWifiModule.java @@ -22,6 +22,7 @@ import com.reactlibrary.utils.LocationUtils; import com.reactlibrary.utils.PermissionUtils; import com.thanosfisherman.wifiutils.WifiUtils; +import com.thanosfisherman.wifiutils.wifiConnect.ConnectionErrorCode; import com.thanosfisherman.wifiutils.wifiConnect.ConnectionSuccessListener; import org.json.JSONArray; @@ -182,12 +183,13 @@ public void connectToProtectedSSID(@NonNull final String SSID, @NonNull final St WifiUtils.withContext(context).connectWith(SSID, password).onConnectionResult(new ConnectionSuccessListener() { @Override - public void isSuccessful(boolean isSuccess) { - if (isSuccess) { - promise.resolve("connected"); - } else { - promise.reject("failed", "Could not connect to network"); - } + public void success() { + promise.resolve("connected"); + } + + @Override + public void failed(@NonNull ConnectionErrorCode errorCode) { + promise.reject("failed", "Could not connect to network"); } }).start(); }