Skip to content

Commit e1b2440

Browse files
committed
Android version 1.0.2 update
1 parent 35468d7 commit e1b2440

File tree

7 files changed

+64
-54
lines changed

7 files changed

+64
-54
lines changed

google_api_availability_android/android/build.gradle

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
group 'com.baseflow.googleapiavailability'
22
version '1.0-SNAPSHOT'
33

4-
buildscript {
5-
repositories {
6-
google()
7-
mavenCentral()
8-
}
9-
10-
dependencies {
11-
classpath 'com.android.tools.build:gradle:4.1.0'
12-
}
13-
}
14-
154
rootProject.allprojects {
165
repositories {
176
google()
@@ -27,7 +16,7 @@ android {
2716
namespace 'com.baseflow.googleapiavailability'
2817
}
2918

30-
compileSdkVersion 31
19+
compileSdkVersion 35
3120

3221
compileOptions {
3322
sourceCompatibility JavaVersion.VERSION_1_8
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1-
rootProject.name = 'google_api_availability'
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}()
9+
10+
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
11+
12+
repositories {
13+
google()
14+
mavenCentral()
15+
gradlePluginPortal()
16+
}
17+
}
18+
19+
plugins {
20+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21+
id "com.android.application" version "8.1.0" apply false
22+
}
23+
24+
include ":app"

google_api_availability_android/android/src/main/java/com/baseflow/googleapiavailability/GoogleApiAvailabilityPlugin.java

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
99
import io.flutter.plugin.common.BinaryMessenger;
1010
import io.flutter.plugin.common.MethodChannel;
11-
import io.flutter.plugin.common.PluginRegistry.Registrar;
12-
import io.flutter.plugin.common.PluginRegistry.ViewDestroyListener;
13-
import io.flutter.view.FlutterNativeView;
1411

1512
/**
1613
* GoogleApiAvailabilityPlugin
@@ -26,57 +23,53 @@ public GoogleApiAvailabilityPlugin() {
2623
}
2724

2825
@Override
29-
public void onAttachedToActivity(ActivityPluginBinding binding) {
30-
methodCallHandler.setActivity(binding.getActivity());
31-
}
26+
public void onAttachedToActivity(ActivityPluginBinding binding) {
27+
if (methodCallHandler != null) {
28+
methodCallHandler.setActivity(binding.getActivity());
29+
}
30+
}
3231

33-
@Override
34-
public void onDetachedFromActivity() {
35-
methodCallHandler.setActivity(null);
36-
}
32+
@Override
33+
public void onDetachedFromActivity() {
34+
if (methodCallHandler != null) {
35+
methodCallHandler.setActivity(null);
36+
}
37+
}
3738

38-
@Override
39-
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
40-
methodCallHandler.setActivity(binding.getActivity());
41-
}
39+
@Override
40+
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
41+
if (methodCallHandler != null) {
42+
methodCallHandler.setActivity(binding.getActivity());
43+
}
44+
}
4245

43-
@Override
44-
public void onDetachedFromActivityForConfigChanges() {
45-
methodCallHandler.setActivity(null);
46-
}
46+
@Override
47+
public void onDetachedFromActivityForConfigChanges() {
48+
if (methodCallHandler != null) {
49+
methodCallHandler.setActivity(null);
50+
}
51+
}
4752

48-
@Override
49-
public void onAttachedToEngine(FlutterPluginBinding binding) {
50-
registerPlugin(binding.getApplicationContext(), binding.getBinaryMessenger());
51-
}
53+
@Override
54+
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
55+
registerPlugin(binding.getApplicationContext(), binding.getBinaryMessenger());
56+
}
5257

5358
@Override
5459
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
5560
unregisterPlugin();
5661
}
5762

58-
public static void registerWith(Registrar registrar) {
59-
final GoogleApiAvailabilityPlugin plugin = new GoogleApiAvailabilityPlugin();
60-
plugin.registerPlugin(registrar.context(), registrar.messenger());
61-
plugin.methodCallHandler.setActivity(registrar.activity());
62-
63-
registrar.addViewDestroyListener(new ViewDestroyListener() {
64-
@Override
65-
public boolean onViewDestroy(FlutterNativeView view) {
66-
plugin.unregisterPlugin();
67-
return false;
68-
}
69-
});
70-
}
71-
7263
private void registerPlugin(Context context, BinaryMessenger messenger) {
7364
methodCallHandler = new MethodCallHandlerImpl(context, googleApiAvailabilityManager);
7465
channel = new MethodChannel(messenger, "flutter.baseflow.com/google_api_availability_android/methods");
7566
channel.setMethodCallHandler(methodCallHandler);
7667
}
7768

7869
private void unregisterPlugin() {
79-
channel.setMethodCallHandler(null);
80-
channel = null;
70+
if (channel != null) {
71+
channel.setMethodCallHandler(null);
72+
channel = null;
73+
}
8174
}
8275
}

google_api_availability_android/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: An Android implementation for the google_api_availability plugin.
33
repository: https://github.com/baseflow/flutter-google-api-availability/tree/main/google_api_availability_android
44
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
55
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
6-
version: 1.0.1
6+
version: 1.0.2
77

88
flutter:
99
plugin:

google_api_availability_android/test/method_channel_mock.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class MethodChannelMock {
1313
this.result,
1414
this.delay = Duration.zero,
1515
}) : methodChannel = MethodChannel(channelName) {
16-
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
16+
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
1717
.setMockMethodCallHandler(methodChannel, _handler);
1818
}
1919

google_api_availability_platform_interface/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.0.2
2+
3+
* Fixes compile errors for Flutter 3.29.0 (and above)
4+
* Updates compileSDKversion to 35
5+
16
## 1.0.1
27

38
* Adds `removeInstance` to `GoogleApiAvailabilityPlatform` for testing purposes.

0 commit comments

Comments
 (0)