Skip to content

Commit c0f0976

Browse files
committed
- Android plugin API updated to support v2 Embedding while remaining compatible with apps that don’t use the v2 Android embedding.
1 parent cc4f59e commit c0f0976

File tree

20 files changed

+258
-73
lines changed

20 files changed

+258
-73
lines changed

.pubignore

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
flutter_export_environment.sh
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
**/doc/api/
26+
.dart_tool/
27+
.flutter-plugins
28+
.packages
29+
.pub-cache/
30+
.pub/
31+
/build/
32+
*.chopper.dart
33+
*.g.dart
34+
ios.old.zip
35+
ios.old/
36+
.flutter-plugins-dependencies
37+
38+
# Android related
39+
**/android/**/gradle-wrapper.jar
40+
**/android/.gradle
41+
**/android/captures/
42+
**/android/gradlew
43+
**/android/gradlew.bat
44+
**/android/local.properties
45+
**/android/**/GeneratedPluginRegistrant.java
46+
47+
# iOS/XCode related
48+
**/ios/**/*.mode1v3
49+
**/ios/**/*.mode2v3
50+
**/ios/**/*.moved-aside
51+
**/ios/**/*.pbxuser
52+
**/ios/**/*.perspectivev3
53+
**/ios/**/*sync/
54+
**/ios/**/.sconsign.dblite
55+
**/ios/**/.tags*
56+
**/ios/**/.vagrant/
57+
**/ios/**/DerivedData/
58+
**/ios/**/Icon?
59+
**/ios/**/Pods/
60+
**/ios/**/.symlinks/
61+
**/ios/**/profile
62+
**/ios/**/xcuserdata
63+
**/ios/.generated/
64+
**/ios/Flutter/App.framework
65+
**/ios/Flutter/Flutter.framework
66+
**/ios/Flutter/Generated.xcconfig
67+
**/ios/Flutter/app.flx
68+
**/ios/Flutter/app.zip
69+
**/ios/Flutter/flutter_assets/
70+
**/ios/Flutter/flutter_export_environment.sh
71+
**/ios/ServiceDefinitions.json
72+
**/ios/Runner/GeneratedPluginRegistrant.*
73+
flutter_export_environment.sh
74+
Flutter.podspec
75+
76+
# Exceptions to above rules.
77+
!**/ios/**/default.mode1v3
78+
!**/ios/**/default.mode2v3
79+
!**/ios/**/default.pbxuser
80+
!**/ios/**/default.perspectivev3
81+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
## 2.0.0+11 (2021-05-08)
1+
## 2.0.1+12 (2021-09-14)
2+
### Changed
3+
- Android plugin API updated to support v2 Embedding while remaining compatible with apps that don’t use the v2 Android embedding.
4+
5+
## 2.0.0+11 (2021-05-08)
26
### Added
37
- Support for null safety.
48

59
### Changed
610
- Example updated with new features
711

8-
## 1.0.6+10 (2020-10-12)
12+
## 1.0.6+10 (2020-10-12)
913
### Added
1014
- Support for latest flutter frameworks
1115

analysis_options.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at
17+
# https://dart-lang.github.io/linter/lints/index.html.
18+
#
19+
# Instead of disabling a lint rule for the entire project in the
20+
# section below, it can also be suppressed for a single line of code
21+
# or a specific dart file by using the `// ignore: name_of_lint` and
22+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
23+
# producing the lint.
24+
rules:
25+
avoid_print: false # Uncomment to disable the `avoid_print` rule
26+
constant_identifier_names: false
27+
library_prefixes: false
28+
29+
# Additional information about this file can be found at
30+
# https://dart.dev/guides/language/analysis-options

android/.pubignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures

android/src/main/java/com/plugin/flutter/zsdk/ZsdkPlugin.java

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,43 @@
11
package com.plugin.flutter.zsdk;
22

3+
import android.annotation.SuppressLint;
34
import android.content.Context;
45

6+
import androidx.annotation.NonNull;
7+
import io.flutter.embedding.engine.plugins.FlutterPlugin;
8+
import io.flutter.plugin.common.BinaryMessenger;
59
import io.flutter.plugin.common.MethodCall;
610
import io.flutter.plugin.common.MethodChannel;
711
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
812
import io.flutter.plugin.common.MethodChannel.Result;
913
import io.flutter.plugin.common.PluginRegistry.Registrar;
1014

1115
/** ZsdkPlugin */
12-
public class ZsdkPlugin implements MethodCallHandler {
16+
public class ZsdkPlugin implements FlutterPlugin, MethodCallHandler {
1317

14-
/** Plugin registration. */
15-
public static void registerWith(Registrar registrar) { new ZsdkPlugin(registrar);}
18+
@Override
19+
public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
20+
init(
21+
flutterPluginBinding.getApplicationContext(),
22+
flutterPluginBinding.getBinaryMessenger()
23+
);
24+
}
25+
26+
@Override
27+
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
28+
if(channel != null) channel.setMethodCallHandler(null);
29+
}
30+
31+
// This static method is only to remain compatible with apps that don’t use the v2 Android embedding.
32+
@Deprecated()
33+
@SuppressLint("Registrar")
34+
public static void registerWith(Registrar registrar)
35+
{
36+
new ZsdkPlugin().init(
37+
registrar.context(),
38+
registrar.messenger()
39+
);
40+
}
1641

1742
/** Channel */
1843
static final String _METHOD_CHANNEL = "zsdk";
@@ -42,15 +67,18 @@ public class ZsdkPlugin implements MethodCallHandler {
4267
private MethodChannel channel;
4368
private Context context;
4469

45-
public ZsdkPlugin(Registrar registrar)
70+
public ZsdkPlugin() {
71+
}
72+
73+
private void init(Context context, BinaryMessenger messenger)
4674
{
47-
context = registrar.context();
48-
channel = new MethodChannel(registrar.messenger(), _METHOD_CHANNEL);
75+
this.context = context;
76+
channel = new MethodChannel(messenger, _METHOD_CHANNEL);
4977
channel.setMethodCallHandler(this);
5078
}
5179

5280
@Override
53-
public void onMethodCall(MethodCall call, Result result) {
81+
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
5482
try
5583
{
5684
ZPrinter printer = new ZPrinter(

check-publish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
flutter packages pub publish --dry-run $1
1+
flutter pub publish --dry-run $1

example/analysis_options.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at
17+
# https://dart-lang.github.io/linter/lints/index.html.
18+
#
19+
# Instead of disabling a lint rule for the entire project in the
20+
# section below, it can also be suppressed for a single line of code
21+
# or a specific dart file by using the `// ignore: name_of_lint` and
22+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
23+
# producing the lint.
24+
rules:
25+
avoid_print: false # Uncomment to disable the `avoid_print` rule
26+
constant_identifier_names: false
27+
library_prefixes: false
28+
29+
# Additional information about this file can be found at
30+
# https://dart.dev/guides/language/analysis-options

example/ios/Flutter/flutter_export_environment.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
export "FLUTTER_ROOT=/Users/krrigan/Flutter/SDK"
44
export "FLUTTER_APPLICATION_PATH=/Users/krrigan/Flutter/FlutterProjects/zsdk/example"
55
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
6-
export "FLUTTER_TARGET=/Users/krrigan/Flutter/FlutterProjects/zsdk/example/lib/main.dart"
6+
export "FLUTTER_TARGET=lib/main.dart"
77
export "FLUTTER_BUILD_DIR=build"
8-
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
98
export "FLUTTER_BUILD_NAME=1.0.0"
109
export "FLUTTER_BUILD_NUMBER=1.0.0"
11-
export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ=="
1210
export "DART_OBFUSCATION=false"
13-
export "TRACK_WIDGET_CREATION=true"
11+
export "TRACK_WIDGET_CREATION=false"
1412
export "TREE_SHAKE_ICONS=false"
15-
export "PACKAGE_CONFIG=/Users/krrigan/Flutter/FlutterProjects/zsdk/example/.dart_tool/package_config.json"
13+
export "PACKAGE_CONFIG=.packages"

example/pubspec.lock

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.5.0"
10+
version: "2.8.1"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
@@ -28,7 +28,7 @@ packages:
2828
name: charcode
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "1.2.0"
31+
version: "1.3.1"
3232
clock:
3333
dependency: transitive
3434
description:
@@ -62,6 +62,13 @@ packages:
6262
description: flutter
6363
source: sdk
6464
version: "0.0.0"
65+
flutter_lints:
66+
dependency: "direct dev"
67+
description:
68+
name: flutter_lints
69+
url: "https://pub.dartlang.org"
70+
source: hosted
71+
version: "1.0.4"
6572
flutter_plugin_android_lifecycle:
6673
dependency: transitive
6774
description:
@@ -74,6 +81,13 @@ packages:
7481
description: flutter
7582
source: sdk
7683
version: "0.0.0"
84+
lints:
85+
dependency: transitive
86+
description:
87+
name: lints
88+
url: "https://pub.dartlang.org"
89+
source: hosted
90+
version: "1.0.1"
7791
matcher:
7892
dependency: transitive
7993
description:
@@ -87,7 +101,7 @@ packages:
87101
name: meta
88102
url: "https://pub.dartlang.org"
89103
source: hosted
90-
version: "1.3.0"
104+
version: "1.7.0"
91105
path:
92106
dependency: transitive
93107
description:
@@ -141,7 +155,7 @@ packages:
141155
name: test_api
142156
url: "https://pub.dartlang.org"
143157
source: hosted
144-
version: "0.3.0"
158+
version: "0.4.2"
145159
typed_data:
146160
dependency: transitive
147161
description:
@@ -157,12 +171,12 @@ packages:
157171
source: hosted
158172
version: "2.1.0"
159173
zsdk:
160-
dependency: "direct dev"
174+
dependency: "direct main"
161175
description:
162176
path: ".."
163177
relative: true
164178
source: path
165-
version: "2.0.0+11"
179+
version: "2.0.1+12"
166180
sdks:
167181
dart: ">=2.12.0 <3.0.0"
168182
flutter: ">=1.20.0"

example/pubspec.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ dependencies:
1111
sdk: flutter
1212
file_picker: 1.6.3+2
1313
# filesystem_picker: ^2.0.0-nullsafety.0
14+
zsdk:
15+
path: ../
1416

1517
dev_dependencies:
1618
flutter_test:
1719
sdk: flutter
20+
flutter_lints: ^1.0.4
1821

19-
zsdk:
20-
path: ../
2122

2223
# For information on the generic Dart part of this file, see the
2324
# following page: https://www.dartlang.org/tools/pub/pubspec

0 commit comments

Comments
 (0)