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
---
## Implement SonarPlugin
## Implement FlipperPlugin
Create a class implementing `SonarPlugin`.
Create a class implementing `FlipperPlugin`.
### Android
```java
public class MySonarPlugin implements SonarPlugin {
private SonarConnection mConnection;
public class MyFlipperPlugin implements FlipperPlugin {
private FlipperConnection mConnection;
@Override
public String getId() {
return "MySonarPlugin";
return "MyFlipperPlugin";
}
@Override
public void onConnect(SonarConnection connection) throws Exception {
public void onConnect(FlipperConnection connection) throws Exception {
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
```java
connection.receive("getData", new SonarReceiver() {
connection.receive("getData", new FlipperReceiver() {
@Override
public void onReceive(SonarObject params, FlipperResponder responder) throws Exception {
public void onReceive(FlipperObject params, FlipperResponder responder) throws Exception {
responder.success(
new SonarObject.Builder()
new FlipperObject.Builder()
.put("data", MyData.get())
.build());
}
@@ -119,7 +119,7 @@ You don't have to wait for the desktop to request data though, you can also push
```java
connection.send("MyMessage",
new SonarObject.Builder()
new FlipperObject.Builder()
.put("message", "Hello")
.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:
```xml
<activity android:name="com.facebook.sonar.android.diagnostics.FlipperDiagnosticActivity"
<activity android:name="com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity"
android:exported="true"/>
```
@@ -59,9 +59,9 @@ public class MyApplication extends Application {
super.onCreate();
SoLoader.init(this, false);
if (BuildConfig.DEBUG && SonarUtils.shouldEnableSonar(this)) {
final SonarClient client = AndroidFlipperClient.getInstance(this);
client.addPlugin(new InspectorSonarPlugin(this, DescriptorMapping.withDefaults()));
if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(this)) {
final FlipperClient client = AndroidFlipperClient.getInstance(this);
client.addPlugin(new InspectorFlipperPlugin(this, DescriptorMapping.withDefaults()));
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**
```java
import com.facebook.sonar.plugins.inspector.DescriptorMapping;
import com.facebook.sonar.plugins.inspector.InspectorSonarPlugin;
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
final DescriptorMapping descriptorMapping = DescriptorMapping.withDefaults();
client.addPlugin(new InspectorSonarPlugin(mApplicationContext, descriptorMapping));
client.addPlugin(new InspectorFlipperPlugin(mApplicationContext, descriptorMapping));
```
**With Litho Support**
@@ -34,9 +34,9 @@ the descriptor with Litho-specific settings and add some addition dependencies.
```java
import com.facebook.litho.config.ComponentsConfiguration;
import com.facebook.sonar.plugins.inspector.DescriptorMapping;
import com.facebook.sonar.plugins.inspector.InspectorSonarPlugin;
import com.facebook.sonar.plugins.litho.LithoFlipperDescriptors;
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
import com.facebook.flipper.plugins.litho.LithoFlipperDescriptors;
// 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
@@ -47,7 +47,7 @@ final DescriptorMapping descriptorMapping = DescriptorMapping.withDefaults();
// This adds Litho capabilities to the layout inspector.
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

View File

@@ -13,14 +13,14 @@ Note: this plugin is only available for Android.
First, add the plugin to your Flipper client instance:
```java
import com.facebook.sonar.plugins.leakcanary.LeakCanaryFlipperPlugin;
import com.facebook.flipper.plugins.leakcanary.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)
```java
import com.facebook.sonar.plugins.leakcanary.RecordLeakService;
import com.facebook.flipper.plugins.leakcanary.RecordLeakService;
RefWatcher refWatcher = LeakCanary.refWatcher(this)
.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
```java
import com.facebook.sonar.plugins.network.NetworkFlipperPlugin;
import com.facebook.Flipper.plugins.network.NetworkFlipperPlugin;
NetworkFlipperPlugin networkSonarPlugin = new NetworkFlipperPlugin();
client.addPlugin(networkSonarPlugin);
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
client.addPlugin(networkFlipperPlugin);
```
#### 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.
```java
import com.facebook.sonar.plugins.network.FlipperOkhttpInterceptor;
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
new OkHttpClient.Builder()
.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkSonarPlugin))
.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin))
.build();
```

View File

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

View File

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

View File

@@ -8,16 +8,16 @@ Developer tools are only used if they work. We have built APIs to test plugins.
## 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
@RunWith(RobolectricTestRunner.class)
public class MySonarPluginTest {
public class MyFlipperPluginTest {
@Test
public void myTest() {
final MySonarPlugin plugin = new MySonarPlugin();
final SonarConnectionMock connection = new SonarConnectionMock();
final MyFlipperPlugin plugin = new MyFlipperPlugin();
final FlipperConnectionMock connection = new FlipperConnectionMock();
plugin.onConnect(connection);
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
@Test
public void myTest() {
final MySonarPlugin plugin = new MySonarPlugin();
final SonarConnectionMock connection = new SonarConnectionMock();
final SonarResponderMock responder = new SonarResponderMock();
final MyFlipperPlugin plugin = new MyFlipperPlugin();
final FlipperConnectionMock connection = new FlipperConnectionMock();
final FlipperResponderMock responder = new FlipperResponderMock();
plugin.onConnect(connection);
final SonarObject params = new SonarObject.Builder()
final FlipperObject params = new FlipperObject.Builder()
.put("phrase", "sonar")
.build();
connection.receivers.get("myMethod").onReceive(params, responder);
assertThat(responder.successes, hasItem(
new SonarObject.Builder()
new FlipperObject.Builder()
.put("phrase", "ranos")
.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`.
On a terminal, run the following:
```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.