Skip to content

Commit 7f9b8cb

Browse files
committed
Upgrade flipper to 0.36.0
1 parent 068f168 commit 7f9b8cb

File tree

9 files changed

+236
-65
lines changed

9 files changed

+236
-65
lines changed

.gitignore

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,5 @@
33

44
.packages
55
.pub/
6-
pubspec.lock
76

8-
build/
9-
.idea/
10-
.metadata
11-
.settings/
12-
.classpath
13-
.project
7+
build/

android/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99

1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:3.2.1'
11+
classpath 'com.android.tools.build:gradle:3.5.0'
1212
}
1313
}
1414

@@ -33,8 +33,8 @@ android {
3333
}
3434
dependencies {
3535
releaseImplementation project(':flipper-no-op')
36-
debugImplementation 'com.facebook.flipper:flipper:0.26.0'
37-
debugImplementation 'com.facebook.flipper:flipper-network-plugin:0.26.0'
38-
debugImplementation 'com.facebook.soloader:soloader:0.5.1'
36+
debugImplementation 'com.facebook.flipper:flipper:0.36.0'
37+
debugImplementation 'com.facebook.flipper:flipper-network-plugin:0.36.0'
38+
debugImplementation 'com.facebook.soloader:soloader:0.8.2'
3939
}
4040
}

android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
org.gradle.jvmargs=-Xmx1536M
2-
2+
android.enableR8=true
33
android.useAndroidX=true
44
android.enableJetifier=true

android/src/main/java/org/blankapp/flutterplugins/flutter_flipperkit/FlutterFlipperkitPlugin.java

Lines changed: 66 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.blankapp.flutterplugins.flutter_flipperkit;
22

3-
import android.app.Activity;
43
import android.content.Context;
54

5+
import androidx.annotation.NonNull;
6+
67
import com.facebook.flipper.android.AndroidFlipperClient;
78
import com.facebook.flipper.android.utils.FlipperUtils;
89
import com.facebook.flipper.core.FlipperClient;
@@ -22,6 +23,8 @@
2223
import java.util.Map;
2324
import java.util.Set;
2425

26+
import io.flutter.embedding.engine.plugins.FlutterPlugin;
27+
import io.flutter.plugin.common.BinaryMessenger;
2528
import io.flutter.plugin.common.EventChannel;
2629
import io.flutter.plugin.common.MethodCall;
2730
import io.flutter.plugin.common.MethodChannel;
@@ -32,44 +35,44 @@
3235
/**
3336
* FlutterFlipperkitPlugin
3437
*/
35-
public class FlutterFlipperkitPlugin implements MethodCallHandler, EventChannel.StreamHandler {
36-
private EventChannel.EventSink eventSink;
38+
public class FlutterFlipperkitPlugin implements FlutterPlugin, MethodCallHandler, EventChannel.StreamHandler {
39+
private static final String CHANNEL_NAME = "flutter_flipperkit";
40+
private static final String EVENT_CHANNEL_NAME = "flutter_flipperkit/event_channel";
3741

3842
private Context context;
43+
private MethodChannel channel;
44+
private EventChannel eventChannel;
45+
46+
private EventChannel.EventSink eventSink;
47+
3948
private FlipperClient flipperClient;
4049
private NetworkFlipperPlugin networkFlipperPlugin;
4150
private SharedPreferencesFlipperPlugin sharedPreferencesFlipperPlugin;
4251

4352
private FlipperDatabaseBrowserPlugin flipperDatabaseBrowserPlugin;
4453
private FlipperReduxInspectorPlugin flipperReduxInspectorPlugin;
4554

46-
public FlutterFlipperkitPlugin(Context context) {
47-
this.context = context;
48-
SoLoader.init(context.getApplicationContext(), false);
49-
if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(context)) {
50-
flipperClient = AndroidFlipperClient.getInstance(context);
51-
networkFlipperPlugin = new NetworkFlipperPlugin();
52-
sharedPreferencesFlipperPlugin = new SharedPreferencesFlipperPlugin(context, "FlutterSharedPreferences");
53-
54-
flipperDatabaseBrowserPlugin = new FlipperDatabaseBrowserPlugin();
55-
flipperReduxInspectorPlugin = new FlipperReduxInspectorPlugin();
56-
}
55+
@Override
56+
public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
57+
this.setupChannel(flutterPluginBinding.getBinaryMessenger(), flutterPluginBinding.getApplicationContext());
5758
}
5859

59-
/**
60-
* Plugin registration.
61-
*/
60+
// This static function is optional and equivalent to onAttachedToEngine. It supports the old
61+
// pre-Flutter-1.12 Android projects. You are encouraged to continue supporting
62+
// plugin registration via this function while apps migrate to use the new Android APIs
63+
// post-flutter-1.12 via https://flutter.dev/go/android-project-migration.
64+
//
65+
// It is encouraged to share logic between onAttachedToEngine and registerWith to keep
66+
// them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called
67+
// depending on the user's project. onAttachedToEngine or registerWith must both be defined
68+
// in the same class.
6269
public static void registerWith(Registrar registrar) {
63-
final FlutterFlipperkitPlugin flipperkitPlugin = new FlutterFlipperkitPlugin(registrar.activeContext());
64-
final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_flipperkit");
65-
channel.setMethodCallHandler(flipperkitPlugin);
66-
67-
final EventChannel eventChannel = new EventChannel(registrar.messenger(), "flutter_flipperkit/event_channel");
68-
eventChannel.setStreamHandler(flipperkitPlugin);
70+
final FlutterFlipperkitPlugin plugin = new FlutterFlipperkitPlugin();
71+
plugin.setupChannel(registrar.messenger(), registrar.activeContext());
6972
}
7073

7174
@Override
72-
public void onMethodCall(MethodCall call, Result result) {
75+
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
7376
if (!FlipperUtils.shouldEnableFlipper(context)) {
7477
result.success(true);
7578
return;
@@ -200,15 +203,17 @@ private byte[] convertBody(MethodCall call) {
200203

201204
if (argBody instanceof HashMap) {
202205
bodyString = new JSONObject((HashMap) argBody).toString();
203-
} else if (argBody instanceof ArrayList) {
206+
} else if (argBody instanceof ArrayList) {
204207
bodyString = new JSONArray((ArrayList) argBody).toString();
205208
}
206-
} catch (ClassCastException e) { }
209+
} catch (ClassCastException e) {
210+
}
207211

208212
if (bodyString == null) {
209213
try {
210214
bodyString = call.argument("body");
211-
} catch (NullPointerException e) { }
215+
} catch (NullPointerException e) {
216+
}
212217
}
213218
}
214219

@@ -217,7 +222,7 @@ private byte[] convertBody(MethodCall call) {
217222

218223
private List<NetworkReporter.Header> convertHeader(MethodCall call) {
219224
Map<String, Object> argHeaders = call.argument("headers");
220-
List<NetworkReporter.Header> list = new ArrayList<>();;
225+
List<NetworkReporter.Header> list = new ArrayList<>();
221226

222227
if (argHeaders != null) {
223228
Set<String> keys = argHeaders.keySet();
@@ -228,7 +233,7 @@ private List<NetworkReporter.Header> convertHeader(MethodCall call) {
228233
if (value instanceof ArrayList) {
229234
List values = (ArrayList) value;
230235
StringBuilder builder = new StringBuilder();
231-
for(Object obj : values) {
236+
for (Object obj : values) {
232237
builder.append(obj);
233238
}
234239
valueString = builder.toString();
@@ -244,11 +249,42 @@ private List<NetworkReporter.Header> convertHeader(MethodCall call) {
244249
@Override
245250
public void onListen(Object args, EventChannel.EventSink eventSink) {
246251
this.eventSink = eventSink;
247-
flipperDatabaseBrowserPlugin.setEventSink(eventSink);
252+
flipperDatabaseBrowserPlugin.setEventSink(this.eventSink);
248253
}
249254

250255
@Override
251256
public void onCancel(Object args) {
252257
this.eventSink = null;
253258
}
259+
260+
@Override
261+
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
262+
this.teardownChannel();
263+
}
264+
265+
private void setupChannel(BinaryMessenger messenger, Context context) {
266+
this.context = context;
267+
SoLoader.init(context.getApplicationContext(), false);
268+
if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(context)) {
269+
flipperClient = AndroidFlipperClient.getInstance(context);
270+
networkFlipperPlugin = new NetworkFlipperPlugin();
271+
sharedPreferencesFlipperPlugin = new SharedPreferencesFlipperPlugin(context, "FlutterSharedPreferences");
272+
273+
flipperDatabaseBrowserPlugin = new FlipperDatabaseBrowserPlugin();
274+
flipperReduxInspectorPlugin = new FlipperReduxInspectorPlugin();
275+
}
276+
277+
this.channel = new MethodChannel(messenger, CHANNEL_NAME);
278+
this.channel.setMethodCallHandler(this);
279+
280+
this.eventChannel = new EventChannel(messenger, EVENT_CHANNEL_NAME);
281+
this.eventChannel.setStreamHandler(this);
282+
}
283+
284+
private void teardownChannel() {
285+
this.channel.setMethodCallHandler(null);
286+
this.channel = null;
287+
this.eventChannel.setStreamHandler(null);
288+
this.eventChannel = null;
289+
}
254290
}

flutter_flipperkit.iml

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

ios/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ Icon?
3434
.tags*
3535

3636
/Flutter/Generated.xcconfig
37+
/Flutter/flutter_export_environment.sh

ios/flutter_flipperkit.podspec

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
flipperkit_version = '0.26.0'
1+
flipperkit_version = '0.36.0'
22

33
#
44
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
55
#
66
Pod::Spec.new do |s|
77
s.name = 'flutter_flipperkit'
8-
s.version = '0.0.6'
8+
s.version = '0.0.22'
99
s.summary = 'Flipper (Extensible mobile app debugger) for flutter.'
1010
s.description = <<-DESC
1111
Flipper (Extensible mobile app debugger) for flutter.
@@ -25,5 +25,4 @@ Pod::Spec.new do |s|
2525

2626
s.xcconfig = {'OTHER_CFLAGS' => '-DFB_SONARKIT_ENABLED=1'}
2727
s.ios.deployment_target = '9.0'
28-
s.static_framework = true
2928
end

0 commit comments

Comments
 (0)