Add Facebook Stetho

pull/413/head
Alex Baker 8 years ago
parent f11c01507f
commit e4eee25611

@ -97,9 +97,8 @@ dependencies {
apt 'com.jakewharton:butterknife-compiler:8.1.0'
compile 'com.jakewharton:butterknife:8.1.0'
debugCompile 'com.facebook.stetho:stetho:1.3.1'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
compile 'com.nononsenseapps:filepicker:2.5.2'
compile 'com.android.support:design:24.0.0'

6
proguard.pro vendored

@ -32,4 +32,8 @@
-dontwarn com.squareup.leakcanary.**
-keep class com.squareup.haha.** { *; }
-keep class com.squareup.leakcanary.** { *; }
-dontwarn android.app.Notification
-dontwarn android.app.Notification
# https://github.com/facebook/stetho/blob/2807d4248c6fa06cdd3626b6afb9bfc42ba50d55/stetho/proguard-consumer.pro
-keep class com.facebook.stetho.** { *; }
-dontwarn com.facebook.stetho.**

@ -0,0 +1,28 @@
package org.tasks;
import android.app.Application;
import android.content.Context;
import com.facebook.stetho.Stetho;
import com.squareup.leakcanary.LeakCanary;
import org.tasks.injection.ForApplication;
import javax.inject.Inject;
import timber.log.Timber;
public class BuildSetup {
private Context context;
@Inject
public BuildSetup(@ForApplication Context context) {
this.context = context;
}
public void setup() {
Timber.plant(new Timber.DebugTree());
Stetho.initializeWithDefaults(context);
LeakCanary.install((Application) context);
}
}

@ -1,9 +1,5 @@
package org.tasks;
import android.content.res.Configuration;
import android.util.Log;
import com.squareup.leakcanary.LeakCanary;
import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.dao.MetadataDao;
import com.todoroo.astrid.dao.StoreObjectDao;
@ -25,8 +21,6 @@ import org.tasks.sync.SyncThrottle;
import javax.inject.Inject;
import timber.log.Timber;
@SuppressWarnings("UnusedDeclaration")
public class Tasks extends InjectingApplication {
@ -47,54 +41,16 @@ public class Tasks extends InjectingApplication {
@Inject Preferences preferences;
@Inject Tracker tracker;
@Inject FlavorSetup flavorSetup;
@Inject BuildSetup buildSetup;
@Override
public void onCreate() {
super.onCreate();
LeakCanary.install(this);
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
} else {
Timber.plant(new ErrorReportingTree());
}
tracker.setTrackingEnabled(preferences.isTrackingEnabled());
buildSetup.setup();
flavorSetup.setup();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (BuildConfig.DEBUG) {
Timber.d("current screen width: %s, smallest screen width: %s", newConfig.screenWidthDp, newConfig.smallestScreenWidthDp);
}
}
private static class ErrorReportingTree extends Timber.Tree {
@Override
protected void log(int priority, String tag, String message, Throwable t) {
if (priority < Log.WARN) {
return;
}
if (priority == Log.ERROR) {
if (t == null) {
Log.e(tag, message);
} else {
Log.e(tag, message, t);
}
} else if(priority == Log.WARN) {
if (t == null) {
Log.w(tag, message);
} else {
Log.w(tag, message, t);
}
}
}
tracker.setTrackingEnabled(preferences.isTrackingEnabled());
}
@Override

@ -0,0 +1,41 @@
package org.tasks;
import android.util.Log;
import javax.inject.Inject;
import timber.log.Timber;
public class BuildSetup {
@Inject
public BuildSetup() {
}
public void setup() {
Timber.plant(new ErrorReportingTree());
}
private static class ErrorReportingTree extends Timber.Tree {
@Override
protected void log(int priority, String tag, String message, Throwable t) {
if (priority < Log.WARN) {
return;
}
if (priority == Log.ERROR) {
if (t == null) {
Log.e(tag, message);
} else {
Log.e(tag, message, t);
}
} else if(priority == Log.WARN) {
if (t == null) {
Log.w(tag, message);
} else {
Log.w(tag, message, t);
}
}
}
}
}
Loading…
Cancel
Save