diff --git a/.fvmrc b/.fvmrc index 64a9dcb..2fa2a80 100644 --- a/.fvmrc +++ b/.fvmrc @@ -1,4 +1,4 @@ { - "flutter": "3.24.0", + "flutter": "3.27.4", "flavors": {} } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 451bd92..e4a5bbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 0.1.3 + +- [Android]: Use intent to get peers when requestPeers() returns empty +- Update README: add Video section +- Use Flutter 3.27.4 +- Upgrade AGP to 8.2.1 in examples + ## 0.1.2 - [Android]: Improve files management and connection diff --git a/README.md b/README.md index 0d9b175..f2f6dad 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,15 @@ The package does not support communication between Android and IOS devices, the Your feedback and suggestions would be greatly appreciated! [You can leave your opinion here](https://forms.gle/FbAtW2dG5RYCxb1DA) +## Video + +Watch a quick demonstration in MP4 format: +- [Android](https://drive.google.com/file/d/1nxdzDjBC6pMmT5GEyf4u88X5Q77khCWy/view?usp=drive_link) +- [iOS](https://drive.google.com/file/d/1MDyDxMJ5jjU9lr-wGeqcAY1uEEHNHTZ_/view?usp=drive_link) + +Or find the GIF demo at the end of the README: +- [Demo](#demo) + ## Table of Contents - [About](#about) diff --git a/android/build.gradle b/android/build.gradle index 574e34d..5ab4423 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,14 +2,14 @@ group 'com.xenikii.nearby_service' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.7.10' + ext.kotlin_version = '2.1.20' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.3.1' + classpath 'com.android.tools.build:gradle:8.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -25,7 +25,8 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdk 33 + compileSdk 35 + namespace 'com.xenikii.nearby_service' compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 234bfaf..4d32611 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/android/src/main/kotlin/com/xenikii/nearby_service/NearbyServiceBroadcastReceiver.kt b/android/src/main/kotlin/com/xenikii/nearby_service/NearbyServiceBroadcastReceiver.kt index 30246d2..ca200c2 100644 --- a/android/src/main/kotlin/com/xenikii/nearby_service/NearbyServiceBroadcastReceiver.kt +++ b/android/src/main/kotlin/com/xenikii/nearby_service/NearbyServiceBroadcastReceiver.kt @@ -14,6 +14,7 @@ import android.os.Build /** * Receiver of [WifiP2pManager] changes. */ +@Suppress("DEPRECATION") class NearbyServiceBroadcastReceiver( private val wifiManager: WifiP2pManager, private val wifiChannel: Channel, @@ -34,7 +35,7 @@ class NearbyServiceBroadcastReceiver( } WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION -> { - writeDevices() + writeDevices { intent.getParcelableExtra(WifiP2pManager.EXTRA_P2P_DEVICE_LIST) } } WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION -> { @@ -76,13 +77,19 @@ class NearbyServiceBroadcastReceiver( } } - private fun writeDevices() { + private fun writeDevices(deviceListSupplier: (() -> WifiP2pDeviceList?)? = null) { try { wifiManager.requestPeers( wifiChannel - ) { newPeers: WifiP2pDeviceList -> + ) { data: WifiP2pDeviceList -> val list: MutableList = mutableListOf() + val newPeers = + if (data.deviceList.isEmpty() && deviceListSupplier != null) { + deviceListSupplier() ?: data + } else { + data + } if (newPeers.deviceList.isEmpty() && connectedDevice != null) { connectedDevice = null } diff --git a/example/.gitignore b/example/.gitignore index f55be74..7c1c46b 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -5,9 +5,11 @@ *.swp .DS_Store .atom/ +.build/ .buildlog/ .history .svn/ +.swiftpm/ migrate_working_dir/ # IntelliJ related diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index c29e0a9..1b51468 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -27,7 +27,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { namespace "com.xenikii.nearby_service_example" - compileSdk 34 + compileSdk 35 ndkVersion flutter.ndkVersion compileOptions { diff --git a/example/android/build.gradle b/example/android/build.gradle index ab1fdb4..c895490 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.9.22' + ext.kotlin_version = '2.1.20' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' + classpath 'com.android.tools.build:gradle:8.2.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 94adc3a..b9a9a24 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,3 +1,6 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 3c472b9..12d9010 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +networkTimeout=10000 +validateDistributionUrl=true diff --git a/example/pubspec.yaml b/example/pubspec.yaml index d0c97ae..1625861 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -9,7 +9,7 @@ environment: dependencies: provider: ^6.1.1 - file_picker: ^6.1.1 + file_picker: ^10.0.0 flutter: sdk: flutter @@ -22,7 +22,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^3.0.1 + flutter_lints: ^5.0.0 flutter: uses-material-design: true diff --git a/example_full/.gitignore b/example_full/.gitignore index 75dfa95..b6323af 100644 --- a/example_full/.gitignore +++ b/example_full/.gitignore @@ -5,9 +5,11 @@ *.swp .DS_Store .atom/ +.build/ .buildlog/ .history .svn/ +.swiftpm/ migrate_working_dir/ # IntelliJ related diff --git a/example_full/android/build.gradle b/example_full/android/build.gradle index e83fb5d..fe2e1d9 100644 --- a/example_full/android/build.gradle +++ b/example_full/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.7.10' + ext.kotlin_version = '2.1.20' repositories { google() mavenCentral() diff --git a/example_full/android/gradle.properties b/example_full/android/gradle.properties index 598d13f..73c3168 100644 --- a/example_full/android/gradle.properties +++ b/example_full/android/gradle.properties @@ -1,3 +1,6 @@ org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false diff --git a/example_full/android/gradle/wrapper/gradle-wrapper.properties b/example_full/android/gradle/wrapper/gradle-wrapper.properties index 3c472b9..9355b41 100644 --- a/example_full/android/gradle/wrapper/gradle-wrapper.properties +++ b/example_full/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/example_full/android/settings.gradle b/example_full/android/settings.gradle index 7cd7128..e720dda 100644 --- a/example_full/android/settings.gradle +++ b/example_full/android/settings.gradle @@ -23,7 +23,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "7.3.0" apply false + id "com.android.application" version '8.2.2' apply false } include ":app" diff --git a/example_full/lib/presentation/components/device_preview.dart b/example_full/lib/presentation/components/device_preview.dart index d2c0a38..99905e5 100644 --- a/example_full/lib/presentation/components/device_preview.dart +++ b/example_full/lib/presentation/components/device_preview.dart @@ -19,7 +19,7 @@ class DevicePreview extends StatelessWidget { final color = device.status.isConnected ? kGreenColor : kGreyColor; final avatar = CircleAvatar( - backgroundColor: kBlueColor.withOpacity(0.7), + backgroundColor: kBlueColor.withValues(alpha: 0.7), foregroundColor: kWhiteColor, maxRadius: largeView ? 100 : 30, child: Padding( diff --git a/example_full/lib/presentation/components/info_panel.dart b/example_full/lib/presentation/components/info_panel.dart index c501739..1a7a5ac 100644 --- a/example_full/lib/presentation/components/info_panel.dart +++ b/example_full/lib/presentation/components/info_panel.dart @@ -120,7 +120,7 @@ class _InfoChip extends StatelessWidget { boxShadow: [ BoxShadow( blurRadius: 2, - color: Theme.of(context).shadowColor.withOpacity(0.4), + color: Theme.of(context).shadowColor.withValues(alpha: 0.4), offset: const Offset(0, 1), ), ], @@ -133,13 +133,16 @@ class _InfoChip extends StatelessWidget { '$label: ', style: TextStyle( fontWeight: FontWeight.bold, + fontSize: 12, color: Theme.of(context).colorScheme.onSurface, ), ), - Text( - value, - style: TextStyle( - color: Theme.of(context).colorScheme.onSurface, + Flexible( + child: Text( + value, + style: TextStyle( + color: Theme.of(context).colorScheme.onSurface, + ), ), ), ], diff --git a/example_full/lib/uikit/action_button.dart b/example_full/lib/uikit/action_button.dart index a2e4563..2a6b3ac 100644 --- a/example_full/lib/uikit/action_button.dart +++ b/example_full/lib/uikit/action_button.dart @@ -33,7 +33,7 @@ class ActionButton extends StatelessWidget { maximumSize: const Size(150, 50), minimumSize: const Size(70, 50), elevation: 2, - surfaceTintColor: type.color.withOpacity(0.05), + surfaceTintColor: type.color.withValues(alpha: 0.05), ), child: Text( title, diff --git a/example_full/pubspec.yaml b/example_full/pubspec.yaml index 719db53..21a2148 100644 --- a/example_full/pubspec.yaml +++ b/example_full/pubspec.yaml @@ -7,7 +7,7 @@ environment: dependencies: provider: ^6.1.1 - file_picker: ^6.1.1 + file_picker: ^10.0.0 flutter: sdk: flutter @@ -20,7 +20,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^3.0.1 + flutter_lints: ^5.0.0 flutter: uses-material-design: true diff --git a/pubspec.yaml b/pubspec.yaml index 0c26cff..9a05687 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: nearby_service description: Nearby Service Flutter Plugin is used to create connections in a P2P network. Supports sending text messages and files. -version: 0.1.2 +version: 0.1.3 homepage: https://github.com/ksenia312/nearby_service repository: https://github.com/ksenia312/nearby_service