Skip to content

Commit

Permalink
flipper (android): Prepare to enable Flipper (1/5).
Browse files Browse the repository at this point in the history
Done as part of the RN v0.61 -> v0.62 upgrade.

In this commit:
- Part of the RN v0.60 -> v0.61 [sic] changes to the template
  app [1], corresponding to facebook/react-native@3a66fc7dc
- A partial reversion of that, in the RN v0.61 -> v0.62 changes to
  the template app [2], corresponding to
  facebook/react-native@bb272bacc.

It looks like this was prematurely released in RN v0.61 instead of
RN v0.62 [3], the latter being where most sources claim Flipper
support was added; a list of such sources is on CZO [4].

In that partial reversion, the initialize-Flipper function's only
call site is removed.

We'll re-enable Flipper after the main upgrade commit, not before,
just to be safe [5]. That will correspond to
facebook/react-native@05f5cb534.

[1] https://react-native-community.github.io/upgrade-helper/?from=0.60.6&to=0.61.5
[2] https://react-native-community.github.io/upgrade-helper/?from=0.61.5&to=0.62.2
[3] zulip#3782 (comment)
[4] https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/Flipper/near/900499
[5] zulip#4244 (comment)
  • Loading branch information
chrisbobbe committed Sep 9, 2020
1 parent adf21d1 commit 8383b9c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions android/app/src/main/java/com/zulipmobile/MainApplication.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.zulipmobile;

import android.app.Application;
import android.content.Context;
import android.util.Log;

import com.facebook.react.PackageList;
Expand All @@ -10,6 +11,7 @@
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.List;
import org.unimodules.adapters.react.ModuleRegistryAdapter;
Expand Down Expand Up @@ -77,4 +79,30 @@ public void onCreate() {
SoLoader.init(this, /* native exopackage */ false);
conversations = new ConversationMap();
}

/**
* Loads Flipper in React Native templates.
*
* @param context
*/
private static void initializeFlipper(Context context) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}

0 comments on commit 8383b9c

Please sign in to comment.