Update name references in java docs

Summary: Per title. Tried to only update the things I touched myself.

Reviewed By: jknoxville

Differential Revision: D10028023

fbshipit-source-id: 09b56ea9d19caa277a107e4ea970d3ebb28b2165
This commit is contained in:
Pascal Hartig
2018-09-25 08:46:06 -07:00
committed by Facebook Github Bot
parent a19862d7a2
commit 632628e630
9 changed files with 45 additions and 45 deletions

View File

@@ -4,23 +4,23 @@ title: Mobile Setup
sidebar_label: Mobile Setup sidebar_label: Mobile Setup
--- ---
## Implement SonarPlugin ## Implement FlipperPlugin
Create a class implementing `SonarPlugin`. Create a class implementing `FlipperPlugin`.
### Android ### Android
```java ```java
public class MySonarPlugin implements SonarPlugin { public class MyFlipperPlugin implements FlipperPlugin {
private SonarConnection mConnection; private FlipperConnection mConnection;
@Override @Override
public String getId() { public String getId() {
return "MySonarPlugin"; return "MyFlipperPlugin";
} }
@Override @Override
public void onConnect(SonarConnection connection) throws Exception { public void onConnect(FlipperConnection connection) throws Exception {
mConnection = connection; mConnection = connection;
} }
@@ -57,18 +57,18 @@ public:
}; };
``` ```
## Using SonarConnection ## Using FlipperConnection
Using the `SonarConnection` object you can register a receiver of a desktop method call and respond with data. Using the `FlipperConnection` object you can register a receiver of a desktop method call and respond with data.
### Android ### Android
```java ```java
connection.receive("getData", new SonarReceiver() { connection.receive("getData", new FlipperReceiver() {
@Override @Override
public void onReceive(SonarObject params, FlipperResponder responder) throws Exception { public void onReceive(FlipperObject params, FlipperResponder responder) throws Exception {
responder.success( responder.success(
new SonarObject.Builder() new FlipperObject.Builder()
.put("data", MyData.get()) .put("data", MyData.get())
.build()); .build());
} }
@@ -119,7 +119,7 @@ You don't have to wait for the desktop to request data though, you can also push
```java ```java
connection.send("MyMessage", connection.send("MyMessage",
new SonarObject.Builder() new FlipperObject.Builder()
.put("message", "Hello") .put("message", "Hello")
.build() .build()
``` ```

View File

@@ -33,7 +33,7 @@ Add the following permissions to your AndroidManifest.xml. The SDK needs these t
It's recommended that you add the following activity to the manifest too, which can help diagnose integration issues and other problems: It's recommended that you add the following activity to the manifest too, which can help diagnose integration issues and other problems:
```xml ```xml
<activity android:name="com.facebook.sonar.android.diagnostics.FlipperDiagnosticActivity" <activity android:name="com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity"
android:exported="true"/> android:exported="true"/>
``` ```
@@ -59,9 +59,9 @@ public class MyApplication extends Application {
super.onCreate(); super.onCreate();
SoLoader.init(this, false); SoLoader.init(this, false);
if (BuildConfig.DEBUG && SonarUtils.shouldEnableSonar(this)) { if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(this)) {
final SonarClient client = AndroidFlipperClient.getInstance(this); final FlipperClient client = AndroidFlipperClient.getInstance(this);
client.addPlugin(new InspectorSonarPlugin(this, DescriptorMapping.withDefaults())); client.addPlugin(new InspectorFlipperPlugin(this, DescriptorMapping.withDefaults()));
client.start(); client.start();
} }
} }

View File

@@ -20,11 +20,11 @@ To use the layout inspector plugin, you need to add the plugin to your Flipper c
**Standard Android View Only** **Standard Android View Only**
```java ```java
import com.facebook.sonar.plugins.inspector.DescriptorMapping; import com.facebook.flipper.plugins.inspector.DescriptorMapping;
import com.facebook.sonar.plugins.inspector.InspectorSonarPlugin; import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
final DescriptorMapping descriptorMapping = DescriptorMapping.withDefaults(); final DescriptorMapping descriptorMapping = DescriptorMapping.withDefaults();
client.addPlugin(new InspectorSonarPlugin(mApplicationContext, descriptorMapping)); client.addPlugin(new InspectorFlipperPlugin(mApplicationContext, descriptorMapping));
``` ```
**With Litho Support** **With Litho Support**
@@ -34,9 +34,9 @@ the descriptor with Litho-specific settings and add some addition dependencies.
```java ```java
import com.facebook.litho.config.ComponentsConfiguration; import com.facebook.litho.config.ComponentsConfiguration;
import com.facebook.sonar.plugins.inspector.DescriptorMapping; import com.facebook.flipper.plugins.inspector.DescriptorMapping;
import com.facebook.sonar.plugins.inspector.InspectorSonarPlugin; import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
import com.facebook.sonar.plugins.litho.LithoFlipperDescriptors; import com.facebook.flipper.plugins.litho.LithoFlipperDescriptors;
// Instead of hard-coding this setting, it's a good practice to tie // Instead of hard-coding this setting, it's a good practice to tie
// this to a BuildConfig flag, that you only enable for debug builds // this to a BuildConfig flag, that you only enable for debug builds
@@ -47,7 +47,7 @@ final DescriptorMapping descriptorMapping = DescriptorMapping.withDefaults();
// This adds Litho capabilities to the layout inspector. // This adds Litho capabilities to the layout inspector.
LithoFlipperDescriptors.add(descriptorMapping); LithoFlipperDescriptors.add(descriptorMapping);
client.addPlugin(new InspectorSonarPlugin(mApplicationContext, descriptorMapping)); client.addPlugin(new InspectorFlipperPlugin(mApplicationContext, descriptorMapping));
``` ```
You also need to compile in the `litho-annotations` package, as Flipper reflects You also need to compile in the `litho-annotations` package, as Flipper reflects

View File

@@ -13,14 +13,14 @@ Note: this plugin is only available for Android.
First, add the plugin to your Flipper client instance: First, add the plugin to your Flipper client instance:
```java ```java
import com.facebook.sonar.plugins.leakcanary.LeakCanaryFlipperPlugin; import com.facebook.flipper.plugins.leakcanary.LeakCanaryFlipperPlugin;
client.addPlugin(new LeakCanaryFlipperPlugin()); client.addPlugin(new LeakCanaryFlipperPlugin());
``` ```
Next, build a custom RefWatcher using RecordLeakService: (see [LeakCanary docs](https://github.com/square/leakcanary/wiki/Customizing-LeakCanary#uploading-to-a-server) for more information on RefWatcher) Next, build a custom RefWatcher using RecordLeakService: (see [LeakCanary docs](https://github.com/square/leakcanary/wiki/Customizing-LeakCanary#uploading-to-a-server) for more information on RefWatcher)
```java ```java
import com.facebook.sonar.plugins.leakcanary.RecordLeakService; import com.facebook.flipper.plugins.leakcanary.RecordLeakService;
RefWatcher refWatcher = LeakCanary.refWatcher(this) RefWatcher refWatcher = LeakCanary.refWatcher(this)
.listenerServiceClass(RecordLeakService.class); .listenerServiceClass(RecordLeakService.class);

View File

@@ -14,10 +14,10 @@ To use the network plugin, you need to add the plugin to your Flipper client ins
### Android ### Android
```java ```java
import com.facebook.sonar.plugins.network.NetworkFlipperPlugin; import com.facebook.Flipper.plugins.network.NetworkFlipperPlugin;
NetworkFlipperPlugin networkSonarPlugin = new NetworkFlipperPlugin(); NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
client.addPlugin(networkSonarPlugin); client.addPlugin(networkFlipperPlugin);
``` ```
#### OkHttp Integration #### OkHttp Integration
@@ -25,10 +25,10 @@ client.addPlugin(networkSonarPlugin);
If you are using the popular OkHttp library, you can use the Interceptors system to automatically hook into your existing stack. If you are using the popular OkHttp library, you can use the Interceptors system to automatically hook into your existing stack.
```java ```java
import com.facebook.sonar.plugins.network.FlipperOkhttpInterceptor; import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
new OkHttpClient.Builder() new OkHttpClient.Builder()
.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkSonarPlugin)) .addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin))
.build(); .build();
``` ```

View File

@@ -13,8 +13,8 @@ To use the sandbox plugin, you need to add the plugin to your Flipper client ins
### Android ### Android
```java ```java
import com.facebook.sonar.plugins.SandboxSonarPlugin; import com.facebook.flipper.plugins.SandboxSonarPlugin;
import com.facebook.sonar.plugins.SandboxSonarPluginStrategy; import com.facebook.flipper.plugins.SandboxSonarPluginStrategy;
final SandboxSonarPluginStrategy strategy = getStrategy(); // Your strategy goes here final SandboxSonarPluginStrategy strategy = getStrategy(); // Your strategy goes here
client.addPlugin(new SandboxSonarPlugin(strategy)); client.addPlugin(new SandboxSonarPlugin(strategy));

View File

@@ -14,10 +14,10 @@ Note: this plugin is only available for Android.
### Android ### Android
```java ```java
import com.facebook.sonar.plugins.sharedpreferences.SharedPreferencesSonarPlugin; import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
client.addPlugin( client.addPlugin(
new SharedPreferencesSonarPlugin(context, "my_shared_preference_file")); new SharedPreferencesFlipperPlugin(context, "my_shared_preference_file"));
``` ```
## Usage ## Usage

View File

@@ -8,16 +8,16 @@ Developer tools are only used if they work. We have built APIs to test plugins.
## Android ## Android
Start by creating your first test file in this directory `MySonarPluginTest.java`. In the test method body we create our plugin which we want to test as well as a `SonarConnectionMock`. In this contrived example we simply assert that our plugin's connected status is what we expect. Start by creating your first test file in this directory `MyFlipperPluginTest.java`. In the test method body we create our plugin which we want to test as well as a `FlipperConnectionMock`. In this contrived example we simply assert that our plugin's connected status is what we expect.
```java ```java
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class MySonarPluginTest { public class MyFlipperPluginTest {
@Test @Test
public void myTest() { public void myTest() {
final MySonarPlugin plugin = new MySonarPlugin(); final MyFlipperPlugin plugin = new MyFlipperPlugin();
final SonarConnectionMock connection = new SonarConnectionMock(); final FlipperConnectionMock connection = new FlipperConnectionMock();
plugin.onConnect(connection); plugin.onConnect(connection);
assertThat(plugin.connected(), equalTo(true)); assertThat(plugin.connected(), equalTo(true));
@@ -25,24 +25,24 @@ public class MySonarPluginTest {
} }
``` ```
There are two mock classes that are used to construct tests `SonarConnectionMock` and `SonarResponderMock`. Together these can be used to write very powerful tests to verify the end to end behavior of your plugin. For example we can test if for a given incoming message our plugin responds as we expect. There are two mock classes that are used to construct tests `FlipperConnectionMock` and `FlipperResponderMock`. Together these can be used to write very powerful tests to verify the end to end behavior of your plugin. For example we can test if for a given incoming message our plugin responds as we expect.
```java ```java
@Test @Test
public void myTest() { public void myTest() {
final MySonarPlugin plugin = new MySonarPlugin(); final MyFlipperPlugin plugin = new MyFlipperPlugin();
final SonarConnectionMock connection = new SonarConnectionMock(); final FlipperConnectionMock connection = new FlipperConnectionMock();
final SonarResponderMock responder = new SonarResponderMock(); final FlipperResponderMock responder = new FlipperResponderMock();
plugin.onConnect(connection); plugin.onConnect(connection);
final SonarObject params = new SonarObject.Builder() final FlipperObject params = new FlipperObject.Builder()
.put("phrase", "sonar") .put("phrase", "sonar")
.build(); .build();
connection.receivers.get("myMethod").onReceive(params, responder); connection.receivers.get("myMethod").onReceive(params, responder);
assertThat(responder.successes, hasItem( assertThat(responder.successes, hasItem(
new SonarObject.Builder() new FlipperObject.Builder()
.put("phrase", "ranos") .put("phrase", "ranos")
.build())); .build()));
} }

View File

@@ -37,7 +37,7 @@ The Flipper SDK includes an in-app connection diagnostics screen to help you dia
Replace `<APP_PACKAGE>` below with the package name of your app, e.g. `com.facebook.flipper.sample`. Replace `<APP_PACKAGE>` below with the package name of your app, e.g. `com.facebook.flipper.sample`.
On a terminal, run the following: On a terminal, run the following:
```bash ```bash
adb shell am start -n <APP_PACKAGE>/com.facebook.sonar.android.diagnostics.FlipperDiagnosticActivity adb shell am start -n <APP_PACKAGE>/com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity
``` ```
This will only work if you added `FlipperDiagnosticActivity` to your `AndroidManifest.xml`. See [getting started](getting-started.html) for help. This will only work if you added `FlipperDiagnosticActivity` to your `AndroidManifest.xml`. See [getting started](getting-started.html) for help.