Skip to content

Commit a9910f9

Browse files
committed
Version 2.0.0
2 parents f62d836 + fe915b9 commit a9910f9

39 files changed

+846
-447
lines changed

.metadata

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: 035e0765cc575c3b455689c2402cce073d564fce
8+
channel: master
9+
10+
project_type: plugin

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.0.0
2+
* Move from swift to Objective-C and from Kotlin to Java
3+
14
## 1.0.6
25

36
* Fixes a small issue caused by compiling against master build of Flutter.

android/build.gradle

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ group 'com.baseflow.googleapiavailability'
22
version '1.0-SNAPSHOT'
33

44
buildscript {
5-
ext.kotlin_version = '1.3.0'
65
repositories {
76
google()
87
jcenter()
98
}
109

1110
dependencies {
12-
classpath 'com.android.tools.build:gradle:3.2.0'
13-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11+
classpath 'com.android.tools.build:gradle:3.3.1'
1412
}
1513
}
1614

@@ -22,17 +20,13 @@ rootProject.allprojects {
2220
}
2321

2422
apply plugin: 'com.android.library'
25-
apply plugin: 'kotlin-android'
2623

2724
android {
2825
compileSdkVersion 28
2926

30-
sourceSets {
31-
main.java.srcDirs += 'src/main/kotlin'
32-
}
3327
defaultConfig {
3428
minSdkVersion 16
35-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
29+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3630
}
3731
lintOptions {
3832
disable 'InvalidPackage'
@@ -41,6 +35,5 @@ android {
4135

4236
dependencies {
4337
api 'com.google.android.gms:play-services-location:16.0.0'
44-
implementation 'com.google.code.gson:gson:2.8.5'
45-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
46-
}
38+
implementation 'androidx.annotation:annotation:1.0.1'
39+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package com.baseflow.googleapiavailability;
2+
3+
import android.app.Activity;
4+
5+
import com.google.android.gms.common.ConnectionResult;
6+
import com.google.android.gms.common.GoogleApiAvailability;
7+
8+
import java.lang.annotation.Retention;
9+
import java.lang.annotation.RetentionPolicy;
10+
11+
import androidx.annotation.IntDef;
12+
import io.flutter.plugin.common.MethodCall;
13+
import io.flutter.plugin.common.MethodChannel;
14+
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
15+
import io.flutter.plugin.common.MethodChannel.Result;
16+
import io.flutter.plugin.common.PluginRegistry.Registrar;
17+
18+
/**
19+
* GoogleApiAvailabilityPlugin
20+
*/
21+
public class GoogleApiAvailabilityPlugin implements MethodCallHandler {
22+
private static final int REQUEST_GOOGLE_PLAY_SERVICES = 1000;
23+
24+
//GOOGLE_PLAY_SERVICES_AVAILABILITY
25+
private static final int GOOGLE_PLAY_SERVICES_AVAILABILITY_SUCCESS = 0;
26+
private static final int GOOGLE_PLAY_SERVICES_AVAILABILITY_SERVICE_MISSING = 1;
27+
private static final int GOOGLE_PLAY_SERVICES_AVAILABILITY_SERVICE_UPDATING = 2;
28+
private static final int GOOGLE_PLAY_SERVICES_AVAILABILITY_SERVICE_VERSION_UPDATE_REQUIRED = 3;
29+
private static final int GOOGLE_PLAY_SERVICES_AVAILABILITY_SERVICE_DISABLED = 4;
30+
private static final int GOOGLE_PLAY_SERVICES_AVAILABILITY_SERVICE_INVALID = 5;
31+
private static final int GOOGLE_PLAY_SERVICES_AVAILABILITY_NOT_AVAILABLE_ON_PLATFORM = 6;
32+
private static final int GOOGLE_PLAY_SERVICES_AVAILABILITY_UNKNOWN = 7;
33+
34+
@Retention(RetentionPolicy.SOURCE)
35+
@IntDef({
36+
GOOGLE_PLAY_SERVICES_AVAILABILITY_SUCCESS,
37+
GOOGLE_PLAY_SERVICES_AVAILABILITY_SERVICE_MISSING,
38+
GOOGLE_PLAY_SERVICES_AVAILABILITY_SERVICE_UPDATING,
39+
GOOGLE_PLAY_SERVICES_AVAILABILITY_SERVICE_VERSION_UPDATE_REQUIRED,
40+
GOOGLE_PLAY_SERVICES_AVAILABILITY_SERVICE_DISABLED,
41+
GOOGLE_PLAY_SERVICES_AVAILABILITY_SERVICE_INVALID,
42+
GOOGLE_PLAY_SERVICES_AVAILABILITY_NOT_AVAILABLE_ON_PLATFORM,
43+
GOOGLE_PLAY_SERVICES_AVAILABILITY_UNKNOWN,
44+
})
45+
private @interface GooglePlayServicesAvailability {
46+
}
47+
48+
public static void registerWith(Registrar registrar) {
49+
final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter.baseflow.com/google_api_availability/methods");
50+
channel.setMethodCallHandler(new GoogleApiAvailabilityPlugin(registrar.activity()));
51+
}
52+
53+
private final Activity activity;
54+
55+
private GoogleApiAvailabilityPlugin(Activity activity) {
56+
this.activity = activity;
57+
}
58+
59+
@Override
60+
public void onMethodCall(MethodCall call, Result result) {
61+
if (call.method.equals("checkPlayServicesAvailability")) {
62+
final Boolean showDialog = call.argument("showDialog");
63+
GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
64+
final int connectionResult = googleApiAvailability.isGooglePlayServicesAvailable(activity);
65+
66+
if (showDialog != null && showDialog) {
67+
googleApiAvailability.showErrorDialogFragment(activity, connectionResult, REQUEST_GOOGLE_PLAY_SERVICES);
68+
}
69+
70+
final int availability = toPlayServiceAvailability(connectionResult);
71+
result.success(availability);
72+
} else {
73+
result.notImplemented();
74+
}
75+
}
76+
77+
@GooglePlayServicesAvailability
78+
private int toPlayServiceAvailability(int connectionResult) {
79+
switch (connectionResult) {
80+
case ConnectionResult.SUCCESS:
81+
return GOOGLE_PLAY_SERVICES_AVAILABILITY_SUCCESS;
82+
case ConnectionResult.SERVICE_MISSING:
83+
return GOOGLE_PLAY_SERVICES_AVAILABILITY_SERVICE_MISSING;
84+
case ConnectionResult.SERVICE_UPDATING:
85+
return GOOGLE_PLAY_SERVICES_AVAILABILITY_SERVICE_UPDATING;
86+
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
87+
return GOOGLE_PLAY_SERVICES_AVAILABILITY_SERVICE_VERSION_UPDATE_REQUIRED;
88+
case ConnectionResult.SERVICE_DISABLED:
89+
return GOOGLE_PLAY_SERVICES_AVAILABILITY_SERVICE_DISABLED;
90+
case ConnectionResult.SERVICE_INVALID:
91+
return GOOGLE_PLAY_SERVICES_AVAILABILITY_SERVICE_INVALID;
92+
default:
93+
return GOOGLE_PLAY_SERVICES_AVAILABILITY_UNKNOWN;
94+
}
95+
}
96+
}

android/src/main/kotlin/com/baseflow/googleapiavailability/GoogleApiAvailabilityPlugin.kt

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

android/src/main/kotlin/com/baseflow/googleapiavailability/data/PlayServicesAvailability.kt

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

android/src/main/kotlin/com/baseflow/googleapiavailability/utils/Codec.kt

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

example/.gitignore

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,70 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
16
.DS_Store
2-
.dart_tool/
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
317

18+
# Visual Studio Code related
19+
.vscode/
20+
21+
# Flutter/Dart/Pub related
22+
**/doc/api/
23+
.dart_tool/
24+
.flutter-plugins
425
.packages
26+
.pub-cache/
527
.pub/
28+
/build/
629

7-
build/
30+
# Android related
31+
**/android/**/gradle-wrapper.jar
32+
**/android/.gradle
33+
**/android/captures/
34+
**/android/gradlew
35+
**/android/gradlew.bat
36+
**/android/local.properties
37+
**/android/**/GeneratedPluginRegistrant.java
838

9-
.flutter-plugins
39+
# iOS/XCode related
40+
**/ios/**/*.mode1v3
41+
**/ios/**/*.mode2v3
42+
**/ios/**/*.moved-aside
43+
**/ios/**/*.pbxuser
44+
**/ios/**/*.perspectivev3
45+
**/ios/**/*sync/
46+
**/ios/**/.sconsign.dblite
47+
**/ios/**/.tags*
48+
**/ios/**/.vagrant/
49+
**/ios/**/DerivedData/
50+
**/ios/**/Icon?
51+
**/ios/**/Pods/
52+
**/ios/**/.symlinks/
53+
**/ios/**/profile
54+
**/ios/**/xcuserdata
55+
**/ios/.generated/
56+
**/ios/Flutter/App.framework
57+
**/ios/Flutter/Flutter.framework
58+
**/ios/Flutter/Generated.xcconfig
59+
**/ios/Flutter/app.flx
60+
**/ios/Flutter/app.zip
61+
**/ios/Flutter/flutter_assets/
62+
**/ios/ServiceDefinitions.json
63+
**/ios/Runner/GeneratedPluginRegistrant.*
64+
65+
# Exceptions to above rules.
66+
!**/ios/**/default.mode1v3
67+
!**/ios/**/default.mode2v3
68+
!**/ios/**/default.pbxuser
69+
!**/ios/**/default.perspectivev3
70+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

example/.metadata

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: 9299c02cf708497d6f72edda8efae0bb8340660e
8-
channel: beta
7+
revision: 035e0765cc575c3b455689c2402cce073d564fce
8+
channel: master
9+
10+
project_type: app

example/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,13 @@ Demonstrates how to use the google_api_availability plugin.
44

55
## Getting Started
66

7-
For help getting started with Flutter, view our online
8-
[documentation](https://flutter.io/).
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://flutter.io/docs/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook)
13+
14+
For help getting started with Flutter, view our
15+
[online documentation](https://flutter.io/docs), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.

0 commit comments

Comments
 (0)