Skip to content

Commit

Permalink
Merge pull request #20095 from wordpress-mobile/issue/integrate-flipper
Browse files Browse the repository at this point in the history
Integrate Flipper
  • Loading branch information
Antonis Lilis authored Feb 1, 2024
2 parents 503f4bf + ce3cda9 commit ec4b610
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
14 changes: 10 additions & 4 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,6 @@ dependencies {
}
implementation "org.wordpress:persistentedittext:$wordPressPersistentEditTextVersion"

// To enable Stetho, a debug bridge that enables the Chrome Developer Tools for debug purposes.
debugImplementation "com.facebook.stetho:stetho:$stethoVersion"
debugImplementation "com.facebook.stetho:stetho-okhttp3:$stethoVersion"

implementation "androidx.arch.core:core-common:$androidxArchCoreVersion"
implementation "androidx.arch.core:core-runtime:$androidxArchCoreVersion"
implementation "com.google.code.gson:gson:$googleGsonVersion"
Expand Down Expand Up @@ -558,6 +554,16 @@ dependencies {
// - Jetpack Compose - UI Tests
androidTestImplementation "androidx.compose.ui:ui-test-junit4"
implementation "androidx.compose.material3:material3:$androidxComposeMaterial3Version"

// - Flipper
debugImplementation ("com.facebook.flipper:flipper:$flipperVersion") {
exclude group:'org.jetbrains.kotlinx', module:'kotlinx-serialization-json-jvm'
}
debugImplementation "com.facebook.soloader:soloader:$soLoaderVersion"
debugImplementation ("com.facebook.flipper:flipper-network-plugin:$flipperVersion"){
exclude group:'org.jetbrains.kotlinx', module:'kotlinx-serialization-json-jvm'
}
releaseImplementation "com.facebook.flipper:flipper-noop:$flipperVersion"
}

configurations.all {
Expand Down
2 changes: 2 additions & 0 deletions WordPress/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@
android:name=".ui.debug.preferences.DebugSharedPreferenceFlagsActivity"
android:label="@string/debug_settings_debug_flags_screen"
android:theme="@style/WordPress.NoActionBar" />
<activity android:name="com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity"
android:exported="true"/>
</application>
</manifest>
22 changes: 19 additions & 3 deletions WordPress/src/debug/java/org/wordpress/android/WordPressDebug.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

import android.os.StrictMode;

import com.facebook.stetho.Stetho;
import com.facebook.flipper.android.AndroidFlipperClient;
import com.facebook.flipper.android.utils.FlipperUtils;
import com.facebook.flipper.core.FlipperClient;
import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
import com.facebook.soloader.SoLoader;

import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;
Expand All @@ -11,14 +18,23 @@

@HiltAndroidApp
public class WordPressDebug extends WordPressApp {
public static final NetworkFlipperPlugin NETWORK_FLIPPER_PLUGIN = new NetworkFlipperPlugin();
@Override
public void onCreate() {
super.onCreate();

// enableStrictMode()

// Init Stetho
Stetho.initializeWithDefaults(this);
// init Flipper
SoLoader.init(this, false);

if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(this)) {
final FlipperClient client = AndroidFlipperClient.getInstance(this);
client.addPlugin(new InspectorFlipperPlugin(this, DescriptorMapping.withDefaults()));
client.addPlugin(NETWORK_FLIPPER_PLUGIN);
client.addPlugin(new DatabasesFlipperPlugin(this));
client.start();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.wordpress.android.modules;

import com.facebook.stetho.okhttp3.StethoInterceptor;
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;

import org.wordpress.android.WordPressDebug;

import javax.inject.Named;

Expand All @@ -11,11 +13,12 @@
import dagger.multibindings.IntoSet;
import okhttp3.Interceptor;


@InstallIn(SingletonComponent.class)
@Module
public class InterceptorModule {
@Provides @IntoSet @Named("network-interceptors")
public Interceptor provideStethoInterceptor() {
return new StethoInterceptor();
public Interceptor provideFlipperInterceptor() {
return new FlipperOkhttpInterceptor(WordPressDebug.NETWORK_FLIPPER_PLUGIN);
}
}
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ ext {
indexosMediaForMobileVersion = '43a9026f0973a2f0a74fa813132f6a16f7499c3a'

// debug
stethoVersion = '1.6.0'
flipperVersion = '0.245.0'
soLoaderVersion = '0.10.5'

// main
androidInstallReferrerVersion = '2.2'
Expand Down

0 comments on commit ec4b610

Please sign in to comment.