Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26c908cc authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

Add dependency to timber logging lib

- Add dependency into build.gradle
- Call Timber.plant(debugTree) in eDriveApplication and replace every call to Log.?(TAG,...) by Timber logging
parent 28cce24c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ dependencies {
    implementation 'com.github.bumptech.glide:glide:4.13.1'
    implementation "androidx.work:work-runtime:2.7.1"
    implementation 'androidx.test:core:1.4.0'
    implementation 'com.jakewharton.timber:timber:5.0.1'

    androidTestImplementation 'androidx.test:runner:1.4.0'
    androidTestImplementation 'androidx.test:rules:1.4.0'
+15 −11
Original line number Diff line number Diff line
@@ -15,13 +15,14 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Environment;
import android.util.Log;

import foundation.e.drive.FileObservers.FileEventListener;
import foundation.e.drive.FileObservers.RecursiveFileObserver;
import foundation.e.drive.services.SynchronizationService;
import foundation.e.drive.utils.AppConstants;
import foundation.e.drive.utils.CommonUtils;
import timber.log.Timber;
import static timber.log.Timber.DebugTree;

/**
 * Class representing the eDrive application.
@@ -30,15 +31,22 @@ import foundation.e.drive.utils.CommonUtils;
 * @author Vincent Bourgmayer
 */
public class EdriveApplication extends Application {
    private static final String TAG = "EdriveApplication";
    private RecursiveFileObserver mFileObserver = null;
    private FileEventListener fileEventListener;

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

        if (BuildConfig.DEBUG) {
            Timber.plant(new DebugTree());
        } else {
            //Not handled yet
            //Timber.plant(new ReleaseTree());
        }
        Timber.tag("EdriveApplication");

        fileEventListener = new FileEventListener(getApplicationContext());
        Log.i(TAG, "Starting");

        final String pathForObserver = Environment.getExternalStorageDirectory().getAbsolutePath();
        mFileObserver = new RecursiveFileObserver(getApplicationContext(), pathForObserver, fileEventListener);
@@ -47,15 +55,13 @@ public class EdriveApplication extends Application {
        CommonUtils.createNotificationChannel(getApplicationContext());

        if (prefs.getString(AccountManager.KEY_ACCOUNT_NAME, null) != null) {
            Log.d(TAG, "Account already registered");
            startRecursiveFileObserver();

            resetTransferFailureCounter();

            final Intent SynchronizationServiceIntent = new Intent(getApplicationContext(), SynchronizationService.class);
            startService(SynchronizationServiceIntent);

        } else {
        } else { //todo check utility of below code
            final Account mAccount = CommonUtils.getAccount(getString(R.string.eelo_account_type), AccountManager.get(this));
            if (mAccount == null) { return; }

@@ -75,16 +81,14 @@ public class EdriveApplication extends Application {
        if (!mFileObserver.isWatching()) {
            fileEventListener.bindToSynchronizationService();
            mFileObserver.startWatching();
            Log.d(TAG, "Starting RecursiveFileObserver on root folder");
        } else {
            Log.w(TAG, "RecursiveFileObserver (for media's root folder) was already running");
            Timber.d("Started RecursiveFileObserver on root folder");
        }
    }

    public void stopRecursiveFileObserver() {
        mFileObserver.stopWatching();
        fileEventListener.unbindFromSynchronizationService();
        Log.d(TAG, "RecursiveFileObserver on root folder stops watching ");
        Timber.d("Stopped RecursiveFileObserver on root folder");
    }


@@ -101,6 +105,6 @@ public class EdriveApplication extends Application {
    @Override
    public void onLowMemory() {
        super.onLowMemory();
        Log.w(TAG, "System is low on memory. Application might get killed by the system.");
        Timber.w("System is low on memory. Application might get killed by the system.");
    }
}