Skip to content

Commit 6be9743

Browse files
committed
Release version 2.0.3
2 parents 4f093e1 + 3758db3 commit 6be9743

File tree

9 files changed

+66
-36
lines changed

9 files changed

+66
-36
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.3
2+
3+
* Android: Migrate to FlutterPlugin Android API (better support for Add-to-App);
4+
15
## 2.0.2
26

37
* Migrate to AndroidX

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ To use this plugin, add `google_api_availability` as a [dependency in your pubsp
1919

2020
```yaml
2121
dependencies:
22-
google_api_availability: ^2.0.2
22+
google_api_availability: ^2.0.3
2323
```
2424
2525
> **NOTE:** There's a known issue with integrating plugins that use Swift into a Flutter project created with the Objective-C template. See issue [Flutter#16049](https://github.com/flutter/flutter/issues/16049) for help on integration.

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

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
import android.app.Activity;
44
import android.content.Context;
55

6+
import androidx.annotation.IntDef;
7+
68
import com.google.android.gms.common.ConnectionResult;
79
import com.google.android.gms.common.GoogleApiAvailability;
810

911
import java.lang.annotation.Retention;
1012
import java.lang.annotation.RetentionPolicy;
1113

12-
import androidx.annotation.IntDef;
14+
import io.flutter.embedding.engine.plugins.FlutterPlugin;
15+
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
16+
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
17+
import io.flutter.plugin.common.BinaryMessenger;
1318
import io.flutter.plugin.common.MethodCall;
1419
import io.flutter.plugin.common.MethodChannel;
1520
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
@@ -19,7 +24,7 @@
1924
/**
2025
* GoogleApiAvailabilityPlugin
2126
*/
22-
public class GoogleApiAvailabilityPlugin implements MethodCallHandler {
27+
public class GoogleApiAvailabilityPlugin implements MethodCallHandler, FlutterPlugin, ActivityAware {
2328
private static final int REQUEST_GOOGLE_PLAY_SERVICES = 1000;
2429

2530
//GOOGLE_PLAY_SERVICES_AVAILABILITY
@@ -46,15 +51,50 @@ public class GoogleApiAvailabilityPlugin implements MethodCallHandler {
4651
private @interface GooglePlayServicesAvailability {
4752
}
4853

49-
public static void registerWith(Registrar registrar) {
50-
final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter.baseflow.com/google_api_availability/methods");
51-
channel.setMethodCallHandler(new GoogleApiAvailabilityPlugin(registrar.context()));
54+
private Context context;
55+
56+
57+
public void setContext(Context newContext) {
58+
context = newContext;
59+
}
60+
61+
@Override
62+
public void onAttachedToActivity(ActivityPluginBinding binding) {
63+
setContext(binding.getActivity());
64+
}
65+
66+
@Override
67+
public void onDetachedFromActivityForConfigChanges() {
68+
setContext(null);
69+
}
70+
71+
@Override
72+
public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) {
73+
setContext(binding.getActivity());
74+
}
75+
76+
@Override
77+
public void onDetachedFromActivity() {
78+
setContext(null);
79+
}
80+
81+
@Override
82+
public void onAttachedToEngine(FlutterPluginBinding binding) {
83+
this.registerPlugin(null, binding.getBinaryMessenger());
5284
}
5385

54-
private final Context context;
86+
@Override
87+
public void onDetachedFromEngine(FlutterPluginBinding binding) {}
88+
89+
private void registerPlugin(Context context, BinaryMessenger messenger) {
90+
final MethodChannel channel = new MethodChannel(messenger, "flutter.baseflow.com/google_api_availability/methods");
91+
if (context != null) setContext(context);
92+
channel.setMethodCallHandler(this);
93+
}
5594

56-
private GoogleApiAvailabilityPlugin(Context context) {
57-
this.context = context;
95+
public static void registerWith(Registrar registrar) {
96+
final GoogleApiAvailabilityPlugin plugin = new GoogleApiAvailabilityPlugin();
97+
plugin.registerPlugin(registrar.context(), registrar.messenger());
5898
}
5999

60100
@Override
@@ -98,4 +138,4 @@ private int toPlayServiceAvailability(int connectionResult) {
98138
return GOOGLE_PLAY_SERVICES_AVAILABILITY_UNKNOWN;
99139
}
100140
}
101-
}
141+
}

example/android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
android:label="google_api_availability_example"
99
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
1010
<activity
11-
android:name=".MainActivity"
11+
android:name="io.flutter.embedding.android.FlutterActivity"
1212
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
1313
android:hardwareAccelerated="true"
1414
android:launchMode="singleTop"
1515
android:theme="@style/LaunchTheme"
1616
android:windowSoftInputMode="adjustResize">
17+
<meta-data android:name="flutterEmbedding" android:value="2"/>
1718
<!-- This keeps the window background of the activity showing
1819
until Flutter renders its first frame. It can be removed if
1920
there is no splash screen (such as the default splash screen

example/android/app/src/main/java/com/baseflow/googleapiavailabilityexample/MainActivity.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

example/pubspec.lock

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,6 @@ packages:
109109
url: "https://pub.dartlang.org"
110110
source: hosted
111111
version: "1.6.4"
112-
pedantic:
113-
dependency: transitive
114-
description:
115-
name: pedantic
116-
url: "https://pub.dartlang.org"
117-
source: hosted
118-
version: "1.8.0+1"
119112
petitparser:
120113
dependency: transitive
121114
description:
@@ -176,7 +169,7 @@ packages:
176169
name: test_api
177170
url: "https://pub.dartlang.org"
178171
source: hosted
179-
version: "0.2.11"
172+
version: "0.2.15"
180173
typed_data:
181174
dependency: transitive
182175
description:
@@ -200,3 +193,4 @@ packages:
200193
version: "3.5.0"
201194
sdks:
202195
dart: ">=2.4.0 <3.0.0"
196+
flutter: ">=1.12.8 <2.0.0"

ios/google_api_availability.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
Pod::Spec.new do |s|
55
s.name = 'google_api_availability'
6-
s.version = '2.0.2'
6+
s.version = '2.0.3'
77
s.summary = 'A Flutter plugin to check the availability of Google Play Services on an Android device.'
88
s.description = <<-DESC
99
A Flutter plugin to check the availability of Google Play Services on an Android device.

pubspec.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ packages:
162162
name: test_api
163163
url: "https://pub.dartlang.org"
164164
source: hosted
165-
version: "0.2.11"
165+
version: "0.2.15"
166166
typed_data:
167167
dependency: transitive
168168
description:
@@ -186,3 +186,4 @@ packages:
186186
version: "3.5.0"
187187
sdks:
188188
dart: ">=2.4.0 <3.0.0"
189+
flutter: ">=1.12.8 <2.0.0"

pubspec.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ homepage: https://github.com/baseflowit/flutter-google-api-availability
55

66
environment:
77
sdk: ">=2.0.0 <3.0.0"
8+
flutter: ">=1.12.8 <2.0.0"
89

910
dependencies:
1011
flutter:
@@ -18,5 +19,7 @@ dev_dependencies:
1819

1920
flutter:
2021
plugin:
21-
androidPackage: com.baseflow.googleapiavailability
22-
pluginClass: GoogleApiAvailabilityPlugin
22+
platforms:
23+
android:
24+
package: com.baseflow.googleapiavailability
25+
pluginClass: GoogleApiAvailabilityPlugin

0 commit comments

Comments
 (0)