diff --git a/android/build.gradle b/android/build.gradle
index 2e5014a..7b081c3 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -8,7 +8,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.2.1'
+ classpath 'com.android.tools.build:gradle:4.2.2'
}
}
@@ -26,7 +26,6 @@ android {
defaultConfig {
minSdkVersion 16
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
diff --git a/android/src/main/java/com/kaivean/system_proxy/SystemProxyPlugin.java b/android/src/main/java/com/kaivean/system_proxy/SystemProxyPlugin.java
index ff6606a..ef68f25 100644
--- a/android/src/main/java/com/kaivean/system_proxy/SystemProxyPlugin.java
+++ b/android/src/main/java/com/kaivean/system_proxy/SystemProxyPlugin.java
@@ -1,49 +1,35 @@
package com.kaivean.system_proxy;
+import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.MethodCall;
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 java.util.HashMap;
import java.util.Map;
import android.net.ProxyInfo;
import android.net.ConnectivityManager;
-import android.net.Network;
-import android.net.NetworkCapabilities;
-import android.net.NetworkInfo;
-import android.net.wifi.WifiInfo;
-import android.net.wifi.WifiManager;
import android.os.Build;
import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
+
+import androidx.annotation.NonNull;
/** SystemProxyPlugin */
-public class SystemProxyPlugin implements MethodCallHandler {
- private final Registrar registrar;
- private final ConnectivityManager manager;
+public class SystemProxyPlugin implements FlutterPlugin, MethodCallHandler {
+ private ConnectivityManager manager;
+ private MethodChannel channel;
- /** Plugin registration. */
- public static void registerWith(Registrar registrar) {
- final MethodChannel channel = new MethodChannel(registrar.messenger(), "system_proxy");
- channel.setMethodCallHandler(new SystemProxyPlugin(registrar));
- }
-
- private SystemProxyPlugin(Registrar registrar) {
- this.registrar = registrar;
- this.manager =
- (ConnectivityManager)
- registrar
- .context()
- .getApplicationContext()
- .getSystemService(Context.CONNECTIVITY_SERVICE);
+ @Override
+ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
+ channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "system_proxy");
+ channel.setMethodCallHandler(this);
+ manager = (ConnectivityManager)flutterPluginBinding.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
}
@Override
- public void onMethodCall(MethodCall call, Result result) {
+ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
if (call.method.equals("getProxySettings")) {
getNetworkType(manager, result);
} else {
@@ -51,6 +37,11 @@ public class SystemProxyPlugin implements MethodCallHandler {
}
}
+ @Override
+ public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
+ channel.setMethodCallHandler(null);
+ }
+
private void getNetworkType(ConnectivityManager manager, Result result) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
ProxyInfo defaultProxy = manager.getDefaultProxy();
diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle
index 33a0bff..515858d 100644
--- a/example/android/app/build.gradle
+++ b/example/android/app/build.gradle
@@ -38,7 +38,6 @@ android {
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -53,9 +52,3 @@ android {
flutter {
source '../..'
}
-
-dependencies {
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'com.android.support.test:runner:1.0.2'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
-}
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index 1033166..253910d 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -1,33 +1,41 @@
-
-
-
+
+ android:name="io.flutter.embedding.android.NormalTheme"
+ android:resource="@style/NormalTheme"
+ />
+
+
+
+
diff --git a/example/android/app/src/main/java/com/kaivean/system_proxy_example/MainActivity.java b/example/android/app/src/main/java/com/kaivean/system_proxy_example/MainActivity.java
index 266e667..c071d64 100644
--- a/example/android/app/src/main/java/com/kaivean/system_proxy_example/MainActivity.java
+++ b/example/android/app/src/main/java/com/kaivean/system_proxy_example/MainActivity.java
@@ -1,13 +1,5 @@
package com.kaivean.system_proxy_example;
-import android.os.Bundle;
-import io.flutter.app.FlutterActivity;
-import io.flutter.plugins.GeneratedPluginRegistrant;
+import io.flutter.embedding.android.FlutterActivity;
-public class MainActivity extends FlutterActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- GeneratedPluginRegistrant.registerWith(this);
- }
-}
+public class MainActivity extends FlutterActivity { }
\ No newline at end of file
diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml
index 00fa441..2fab5b3 100644
--- a/example/android/app/src/main/res/values/styles.xml
+++ b/example/android/app/src/main/res/values/styles.xml
@@ -1,8 +1,18 @@
-
-
+
+
+
\ No newline at end of file
diff --git a/example/android/build.gradle b/example/android/build.gradle
index bb8a303..f5f2ffb 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -5,7 +5,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.2.1'
+ classpath 'com.android.tools.build:gradle:4.2.2'
}
}
@@ -19,8 +19,6 @@ allprojects {
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
-}
-subprojects {
project.evaluationDependsOn(':app')
}
diff --git a/example/android/gradle.properties b/example/android/gradle.properties
index 2bd6f4f..4d3226a 100644
--- a/example/android/gradle.properties
+++ b/example/android/gradle.properties
@@ -1,2 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
-
+android.useAndroidX=true
+android.enableJetifier=true
\ No newline at end of file
diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties
index 2819f02..8b795a6 100644
--- a/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
\ No newline at end of file
diff --git a/example/pubspec.lock b/example/pubspec.lock
index c8455e2..cb6f175 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
- version: "2.5.0"
+ version: "2.6.1"
boolean_selector:
dependency: transitive
description:
@@ -99,7 +99,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
- version: "1.8.0"
+ version: "1.8.1"
stack_trace:
dependency: transitive
description:
@@ -127,7 +127,7 @@ packages:
path: ".."
relative: true
source: path
- version: "0.0.1"
+ version: "0.0.2"
term_glyph:
dependency: transitive
description:
@@ -141,7 +141,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
- version: "0.2.19"
+ version: "0.3.0"
typed_data:
dependency: transitive
description: