package de.dotwee.rgb.canteen;

import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.multidex.MultiDexApplication;

import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.core.CrashlyticsCore;

import io.fabric.sdk.android.Fabric;

/**
 * Created by lukas on 10.11.2016.
 */
public class CanteenApplication extends MultiDexApplication {
    private static final String TAG = CanteenApplication.class.getSimpleName();
    private static SharedPreferences sharedPreferences;

    public static SharedPreferences getStaticPreferences() {
        return sharedPreferences;
    }

    @Override
    public void onCreate() {
        super.onCreate();

        initFabric();

        // Init static preferences
        sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    }

    private void initFabric() {

        // Enable Fabric only in production builds
        CrashlyticsCore core = new CrashlyticsCore.Builder()
                .disabled(BuildConfig.DEBUG)
                .build();

        Fabric.with(this, new Crashlytics.Builder().core(core).build());
    }

}

@@ -112,16 +112,60 @@
 anager;%0A
+import android.support.annotation.Nullable;%0A
 import a
@@ -208,16 +208,41 @@
 ication;
+%0Aimport android.util.Log;
 %0A%0Aimport
@@ -369,16 +369,42 @@
 .Fabric;
+%0Aimport timber.log.Timber;
 %0A%0A/**%0A *
@@ -819,26 +819,95 @@
         
-initFabric
+// Init Fabric%0A        initFabric();%0A%0A        // Init Timber%0A        initTimber
 ();%0A%0A   
@@ -1342,10 +1342,1220 @@
 %0A    %7D%0A%0A
+%0A    private void initTimber() %7B%0A        if (BuildConfig.DEBUG) %7B%0A            Timber.plant(new Timber.DebugTree());%0A        %7D else %7B%0A            Timber.plant(new CrashlyticsTree());%0A        %7D%0A    %7D%0A%0A    public static class CrashlyticsTree extends Timber.Tree %7B%0A        private static final String TAG = CrashlyticsTree.class.getSimpleName();%0A%0A        private static final String CRASHLYTICS_KEY_PRIORITY = %22priority%22;%0A        private static final String CRASHLYTICS_KEY_TAG = %22tag%22;%0A        private static final String CRASHLYTICS_KEY_MESSAGE = %22message%22;%0A%0A        @Override%0A        protected void log(int priority, @Nullable String tag, @Nullable String message, @Nullable Throwable t) %7B%0A            if (priority == Log.VERBOSE %7C%7C priority == Log.DEBUG %7C%7C priority == Log.INFO) %7B%0A                return;%0A            %7D%0A%0A            Crashlytics.setInt(CRASHLYTICS_KEY_PRIORITY, priority);%0A            Crashlytics.setString(CRASHLYTICS_KEY_TAG, tag);%0A            Crashlytics.setString(CRASHLYTICS_KEY_MESSAGE, message);%0A%0A            if (t == null) %7B%0A                Crashlytics.logException(new Exception(message));%0A            %7D else %7B%0A                Crashlytics.logException(t);%0A            %7D%0A        %7D%0A    %7D%0A
 %7D%0A

Implement a custom timber tree to handle exceptions handled by timber