mirror of
https://github.com/readrops/Readrops.git
synced 2025-02-02 11:46:52 +01:00
Replace Stetho by Flipper
This commit is contained in:
parent
93d9430718
commit
37325642ce
@ -98,6 +98,4 @@ dependencies {
|
||||
implementation 'com.mikepenz:fastadapter-commons:3.3.0'
|
||||
implementation 'com.mikepenz:materialdrawer:6.1.2'
|
||||
implementation "com.mikepenz:aboutlibraries:6.2.3"
|
||||
|
||||
implementation 'com.facebook.stetho:stetho:1.5.1'
|
||||
}
|
||||
|
9
app/src/debug/AndroidManifest.xml
Normal file
9
app/src/debug/AndroidManifest.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.readrops.app">
|
||||
|
||||
<application
|
||||
android:name=".ReadropsDebugApp"
|
||||
tools:ignore="AllowBackup,GoogleAppIndexingWarning"
|
||||
tools:replace="android:name" />
|
||||
</manifest>
|
49
app/src/debug/java/com/readrops/app/ReadropsDebugApp.java
Normal file
49
app/src/debug/java/com/readrops/app/ReadropsDebugApp.java
Normal file
@ -0,0 +1,49 @@
|
||||
package com.readrops.app;
|
||||
|
||||
import com.facebook.flipper.android.AndroidFlipperClient;
|
||||
import com.facebook.flipper.android.utils.FlipperUtils;
|
||||
import com.facebook.flipper.core.FlipperClient;
|
||||
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
|
||||
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.navigation.NavigationFlipperPlugin;
|
||||
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
|
||||
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
import com.readrops.readropslibrary.utils.HttpManager;
|
||||
|
||||
public class ReadropsDebugApp extends ReadropsApp {
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
SoLoader.init(this, false);
|
||||
|
||||
initFlipper();
|
||||
}
|
||||
|
||||
private void initFlipper() {
|
||||
if (FlipperUtils.shouldEnableFlipper(this)) {
|
||||
FlipperClient client = AndroidFlipperClient.getInstance(this);
|
||||
client.addPlugin(new InspectorFlipperPlugin(this, DescriptorMapping.withDefaults()));
|
||||
|
||||
NetworkFlipperPlugin networkPlugin = new NetworkFlipperPlugin();
|
||||
client.addPlugin(networkPlugin);
|
||||
|
||||
HttpManager.setInstance(
|
||||
HttpManager.getInstance()
|
||||
.getOkHttpClient()
|
||||
.newBuilder()
|
||||
.addInterceptor(new FlipperOkhttpInterceptor(networkPlugin))
|
||||
.build());
|
||||
|
||||
client.addPlugin(new DatabasesFlipperPlugin(this));
|
||||
client.addPlugin(CrashReporterPlugin.getInstance());
|
||||
client.addPlugin(NavigationFlipperPlugin.getInstance());
|
||||
|
||||
client.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import android.os.Build;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.facebook.stetho.Stetho;
|
||||
import com.readrops.app.utils.SharedPreferencesManager;
|
||||
|
||||
import io.reactivex.plugins.RxJavaPlugins;
|
||||
@ -25,11 +24,8 @@ public class ReadropsApp extends Application {
|
||||
RxJavaPlugins.setErrorHandler(e -> {
|
||||
});
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
Stetho.initializeWithDefaults(this);
|
||||
}
|
||||
|
||||
createNotificationChannels();
|
||||
|
||||
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
|
||||
|
||||
if (Boolean.valueOf(SharedPreferencesManager.readString(this, SharedPreferencesManager.SharedPrefKey.DARK_THEME)))
|
||||
|
@ -49,7 +49,8 @@ dependencies {
|
||||
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||
implementation 'org.jsoup:jsoup:1.12.1'
|
||||
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.1'
|
||||
|
||||
|
||||
debugApi 'com.facebook.flipper:flipper:0.30.1'
|
||||
debugApi 'com.facebook.soloader:soloader:0.8.0'
|
||||
debugApi 'com.facebook.flipper:flipper-network-plugin:0.30.1'
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.readrops.readropslibrary.utils;
|
||||
|
||||
import com.readrops.readropslibrary.BuildConfig;
|
||||
import com.readrops.readropslibrary.services.Credentials;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -10,7 +9,6 @@ import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
|
||||
public class HttpManager {
|
||||
|
||||
@ -21,26 +19,12 @@ public class HttpManager {
|
||||
buildOkHttp();
|
||||
}
|
||||
|
||||
public HttpManager(final Credentials credentials) {
|
||||
this.credentials = credentials;
|
||||
|
||||
buildOkHttp();
|
||||
}
|
||||
|
||||
private void buildOkHttp() {
|
||||
OkHttpClient.Builder httpBuilder = new OkHttpClient.Builder()
|
||||
okHttpClient = new OkHttpClient.Builder()
|
||||
.callTimeout(1, TimeUnit.MINUTES)
|
||||
.readTimeout(1, TimeUnit.HOURS);
|
||||
|
||||
httpBuilder.addInterceptor(new AuthInterceptor());
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
|
||||
interceptor.level(HttpLoggingInterceptor.Level.BASIC);
|
||||
httpBuilder.addInterceptor(interceptor);
|
||||
}
|
||||
|
||||
okHttpClient = httpBuilder.build();
|
||||
.readTimeout(1, TimeUnit.HOURS)
|
||||
.addInterceptor(new AuthInterceptor())
|
||||
.build();
|
||||
}
|
||||
|
||||
public OkHttpClient getOkHttpClient() {
|
||||
@ -55,7 +39,6 @@ public class HttpManager {
|
||||
return credentials;
|
||||
}
|
||||
|
||||
|
||||
private static HttpManager instance;
|
||||
|
||||
public static HttpManager getInstance() {
|
||||
@ -66,6 +49,10 @@ public class HttpManager {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void setInstance(OkHttpClient client) {
|
||||
instance.okHttpClient = client;
|
||||
}
|
||||
|
||||
public class AuthInterceptor implements Interceptor {
|
||||
|
||||
public AuthInterceptor() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user