diff --git a/.gitignore b/.gitignore index dc13e0c8..e96dabcc 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,9 @@ linked_*.ds unlinked.ds unlinked_spec.ds **/pubspec.lock +.fvm/ +.fvmrc +.cxx/ # Coverage coverage/ diff --git a/packages/wifi_iot/android/src/main/java/com/alternadom/wifiiot/WifiIotPlugin.java b/packages/wifi_iot/android/src/main/java/com/alternadom/wifiiot/WifiIotPlugin.java index 31daddd1..9f82228e 100644 --- a/packages/wifi_iot/android/src/main/java/com/alternadom/wifiiot/WifiIotPlugin.java +++ b/packages/wifi_iot/android/src/main/java/com/alternadom/wifiiot/WifiIotPlugin.java @@ -40,10 +40,7 @@ import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel.MethodCallHandler; import io.flutter.plugin.common.MethodChannel.Result; -import io.flutter.plugin.common.PluginRegistry.Registrar; -import io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener; -import io.flutter.plugin.common.PluginRegistry.ViewDestroyListener; -import io.flutter.view.FlutterNativeView; +import io.flutter.plugin.common.PluginRegistry; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; @@ -56,7 +53,7 @@ public class WifiIotPlugin ActivityAware, MethodCallHandler, EventChannel.StreamHandler, - RequestPermissionsResultListener { + PluginRegistry.RequestPermissionsResultListener { /// This local reference serves to register the plugin with the Flutter Engine and unregister it /// when the Flutter Engine is detached from the Activity private MethodChannel channel; @@ -121,28 +118,6 @@ private void cleanup() { moWiFiAPManager = null; } - /** Plugin registration. This is used for registering with v1 Android embedding. */ - public static void registerWith(Registrar registrar) { - final MethodChannel channel = new MethodChannel(registrar.messenger(), "wifi_iot"); - final EventChannel eventChannel = - new EventChannel(registrar.messenger(), "plugins.wififlutter.io/wifi_scan"); - final WifiIotPlugin wifiIotPlugin = new WifiIotPlugin(); - wifiIotPlugin.initWithActivity(registrar.activity()); - wifiIotPlugin.initWithContext(registrar.activeContext()); - eventChannel.setStreamHandler(wifiIotPlugin); - channel.setMethodCallHandler(wifiIotPlugin); - - registrar.addViewDestroyListener( - new ViewDestroyListener() { - @Override - public boolean onViewDestroy(FlutterNativeView view) { - wifiIotPlugin.cleanup(); - return false; - } - }); - registrar.addRequestPermissionsResultListener(wifiIotPlugin); - } - @Override public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { // initialize method and event channel and set handlers diff --git a/packages/wifi_iot/example/android/app/build.gradle b/packages/wifi_iot/example/android/app/build.gradle index 6937e8b3..00249e52 100644 --- a/packages/wifi_iot/example/android/app/build.gradle +++ b/packages/wifi_iot/example/android/app/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -6,26 +12,32 @@ if (localPropertiesFile.exists()) { } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' } -apply plugin: 'com.android.application' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} android { namespace 'com.alternadom.wifiiotexample' - - compileSdkVersion flutter.compileSdkVersion + compileSdk flutter.compileSdkVersion + ndkVersion flutter.ndkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - lintOptions { - disable 'InvalidPackage' + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' } defaultConfig { @@ -33,9 +45,9 @@ android { applicationId "com.alternadom.wifiiotexample" minSdkVersion flutter.minSdkVersion targetSdkVersion flutter.targetSdkVersion - versionCode 1 - versionName "1.0" - testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName } buildTypes { @@ -51,8 +63,12 @@ flutter { source '../..' } + + dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' } + + diff --git a/packages/wifi_iot/example/android/build.gradle b/packages/wifi_iot/example/android/build.gradle index 0c816a0d..42dc81d9 100644 --- a/packages/wifi_iot/example/android/build.gradle +++ b/packages/wifi_iot/example/android/build.gradle @@ -1,17 +1,7 @@ -buildscript { - repositories { - google() - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:8.2.0' - } -} - allprojects { repositories { google() + mavenCentral() jcenter() } } @@ -26,4 +16,4 @@ subprojects { tasks.register("clean", Delete) { delete rootProject.buildDir -} +} \ No newline at end of file diff --git a/packages/wifi_iot/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/wifi_iot/example/android/gradle/wrapper/gradle-wrapper.properties index b5fc5a7b..3acc4a6f 100644 --- a/packages/wifi_iot/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/packages/wifi_iot/example/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip \ No newline at end of file diff --git a/packages/wifi_iot/example/android/settings.gradle b/packages/wifi_iot/example/android/settings.gradle index 5a2f14fb..f2c26252 100644 --- a/packages/wifi_iot/example/android/settings.gradle +++ b/packages/wifi_iot/example/android/settings.gradle @@ -1,15 +1,25 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() -def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -def plugins = new Properties() -def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') -if (pluginsFile.exists()) { - pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } } -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.2.0" apply false + id "org.jetbrains.kotlin.android" version "1.8.10" apply false } + +include ":app" \ No newline at end of file diff --git a/packages/wifi_scan/example/android/app/build.gradle b/packages/wifi_scan/example/android/app/build.gradle index d2ba306c..042d84f1 100644 --- a/packages/wifi_scan/example/android/app/build.gradle +++ b/packages/wifi_scan/example/android/app/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) { } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' @@ -21,10 +22,6 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { namespace 'dev.flutternetwork.wifi.wifi_scan_example' @@ -66,5 +63,4 @@ flutter { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } diff --git a/packages/wifi_scan/example/android/build.gradle b/packages/wifi_scan/example/android/build.gradle index ddf09fbc..b42eb3a7 100644 --- a/packages/wifi_scan/example/android/build.gradle +++ b/packages/wifi_scan/example/android/build.gradle @@ -1,16 +1,3 @@ -buildscript { - ext.kotlin_version = '1.8.21' - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:8.2.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - allprojects { repositories { google() diff --git a/packages/wifi_scan/example/android/settings.gradle b/packages/wifi_scan/example/android/settings.gradle index 44e62bcf..5b99b39c 100644 --- a/packages/wifi_scan/example/android/settings.gradle +++ b/packages/wifi_scan/example/android/settings.gradle @@ -1,11 +1,25 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.2.0" apply false + id "org.jetbrains.kotlin.android" version "1.8.21" apply false +} + +include ":app" \ No newline at end of file