2015-09-24 11:27:43 -04:00
|
|
|
package eu.kanade.mangafeed;
|
|
|
|
|
|
|
|
import android.app.Application;
|
|
|
|
import android.content.Context;
|
|
|
|
|
2015-12-08 13:39:57 -05:00
|
|
|
import org.acra.ACRA;
|
2015-10-05 06:47:10 -04:00
|
|
|
import org.acra.annotation.ReportsCrashes;
|
|
|
|
|
2015-10-21 15:04:10 -04:00
|
|
|
import eu.kanade.mangafeed.injection.ComponentReflectionInjector;
|
2015-10-22 19:40:27 -04:00
|
|
|
import eu.kanade.mangafeed.injection.component.AppComponent;
|
2015-10-21 15:04:10 -04:00
|
|
|
import eu.kanade.mangafeed.injection.component.DaggerAppComponent;
|
2015-10-22 19:40:27 -04:00
|
|
|
import eu.kanade.mangafeed.injection.module.AppModule;
|
2015-09-24 11:27:43 -04:00
|
|
|
import timber.log.Timber;
|
|
|
|
|
2015-10-05 06:47:10 -04:00
|
|
|
@ReportsCrashes(
|
2015-12-08 13:39:57 -05:00
|
|
|
formUri = "http://mangafeed.kanade.eu/crash_report",
|
2015-10-05 06:47:10 -04:00
|
|
|
reportType = org.acra.sender.HttpSender.Type.JSON,
|
|
|
|
httpMethod = org.acra.sender.HttpSender.Method.PUT,
|
2015-12-08 13:39:57 -05:00
|
|
|
excludeMatchingSharedPreferencesKeys={".*username.*",".*password.*"}
|
2015-10-05 06:47:10 -04:00
|
|
|
)
|
2015-09-24 11:27:43 -04:00
|
|
|
public class App extends Application {
|
|
|
|
|
2015-12-08 13:39:57 -05:00
|
|
|
AppComponent applicationComponent;
|
|
|
|
ComponentReflectionInjector<AppComponent> componentInjector;
|
2015-09-24 11:27:43 -04:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate() {
|
|
|
|
super.onCreate();
|
|
|
|
if (BuildConfig.DEBUG) Timber.plant(new Timber.DebugTree());
|
|
|
|
|
2015-12-08 13:39:57 -05:00
|
|
|
applicationComponent = DaggerAppComponent.builder()
|
2015-09-24 11:27:43 -04:00
|
|
|
.appModule(new AppModule(this))
|
|
|
|
.build();
|
2015-10-05 06:47:10 -04:00
|
|
|
|
2015-12-08 13:39:57 -05:00
|
|
|
componentInjector =
|
|
|
|
new ComponentReflectionInjector<>(AppComponent.class, applicationComponent);
|
2015-10-16 13:31:18 -04:00
|
|
|
|
2015-12-08 13:39:57 -05:00
|
|
|
ACRA.init(this);
|
2015-09-24 11:27:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public static App get(Context context) {
|
|
|
|
return (App) context.getApplicationContext();
|
|
|
|
}
|
|
|
|
|
|
|
|
public AppComponent getComponent() {
|
2015-12-08 13:39:57 -05:00
|
|
|
return applicationComponent;
|
2015-09-24 11:27:43 -04:00
|
|
|
}
|
|
|
|
|
2015-10-16 13:31:18 -04:00
|
|
|
public ComponentReflectionInjector<AppComponent> getComponentReflection() {
|
2015-12-08 13:39:57 -05:00
|
|
|
return componentInjector;
|
2015-10-16 13:31:18 -04:00
|
|
|
}
|
|
|
|
|
2015-09-24 11:27:43 -04:00
|
|
|
// Needed to replace the component with a test specific one
|
|
|
|
public void setComponent(AppComponent applicationComponent) {
|
2015-12-08 13:39:57 -05:00
|
|
|
this.applicationComponent = applicationComponent;
|
2015-09-24 11:27:43 -04:00
|
|
|
}
|
|
|
|
}
|