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

Commit 103278dc authored by Vincent Bourgmayer's avatar Vincent Bourgmayer
Browse files

Merge branch 'main' into 115-epic

parents 55b1a4ee b258e7b1
Loading
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
# eDrive

eDrive is a persitent application provided by default with /e/OS.
eDrive is a [persistent][doc-persistence] application provided by default with /e/OS.
It synchronizes user's data files to /e/Cloud or a self-hosted cloud.

## Install
@@ -22,8 +22,8 @@ and finally `adb reboot`.
| /storage/emulated/0/Ringtones        | /Ringtones                             | Ringtones    |
| /storage/emulated/0/Documents        | /Documents                             | Documents    |
| /storage/emulated/0/Podcasts         | /Podcasts                              | Podcasts     |
| /data/system/users/0/                | /Devices/\<id\>/rom_settings/          | Rom settings |
| /data/data/foundation.e.drive/files/ | /Devices/\<id\>/rom_settings/app_list/ | Rom settings |
| /data/system/users/0/                | /Devices/\<id\>/rom_settings/          | ROM settings |
| /data/data/foundation.e.drive/files/ | /Devices/\<id\>/rom_settings/app_list/ | ROM settings |

All remote directories are created by eDrive if needed.

@@ -31,7 +31,7 @@ All remote directories are created by eDrive if needed.

### How it works

When you register an /e/account the synchronization is enabled by default.
When you register an /e/account, the synchronization is enabled by default.
The synchronization is done on `ACTION_SCREEN_OFF` intent if the last
sync is greater than 15 min. Otherwise a sync is scheduled each 30 min.

@@ -39,14 +39,14 @@ sync is greater than 15 min. Otherwise a sync is scheduled each 30 min.

To enable/disable the synchronisation, go into your account settings:

* Application settings (Rom settings)
* Application settings (ROM settings)
* Pictures and videos (Images, Movies, Music, Ringtones, Documents and Podcasts)

# Interrobility
# Interoperability

eDrive can also receive some broadcast intent for different purprose: 
eDrive can also receive some broadcast intent for different purpose: 

**Force the synchronization.**
**Force the synchronization**

```bash
adb shell am broadcast -a foundation.e.drive.action.FORCE_SCAN --receiver-include-background
+2 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ plugins {

def versionMajor = 1
def versionMinor = 5
def versionPatch = 0
def versionPatch = 1

def getTestProp(String propName) {
    def result = ""
@@ -93,7 +93,7 @@ android {
}

dependencies {
    implementation 'com.github.nextcloud:android-library:2.13.0'
    implementation 'foundation.e:Nextcloud-Android-Library:1.0.6-release'
    implementation "commons-httpclient:commons-httpclient:3.1@jar"
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    api 'androidx.annotation:annotation:1.7.0'
+18 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ import static foundation.e.drive.utils.AppConstants.ACCOUNT_USER_ID_KEY;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.SharedPreferences;
@@ -55,6 +56,8 @@ public class AccountUserInfoWorker extends Worker {
    private final AccountManager accountManager;
    private final GetUserInfoRemoteOperation GetUserInfoRemoteOperation = new GetUserInfoRemoteOperation();

    private static final int QUOTA_NOTIFICATION_ID = 11;

    private final Context mContext;
    private Account account;

@@ -85,6 +88,7 @@ public class AccountUserInfoWorker extends Worker {
                            .diskCacheStrategy(DiskCacheStrategy.ALL)
                            .preload();
                    ViewUtils.updateWidgetView(mContext);
                    DavClientProvider.getInstance().saveAccounts(mContext);
                    return Result.success();
                } else {
                    return Result.retry();
@@ -157,7 +161,11 @@ public class AccountUserInfoWorker extends Worker {
        } else if (relativeQuota >= 80.0 && needToNotify) {
            addNotification(manager, context.getString(R.string.notif_quota_80plus_title), context.getString(R.string.notif_quota_80Plus_text), false);
        } else {
            manager.cancelAll();
            try {
                manager.cancel(QUOTA_NOTIFICATION_ID);
            } catch (Exception e) {
                Timber.e(e, "Failed to cancel quota notification");
            }
        }
    }

@@ -192,6 +200,11 @@ public class AccountUserInfoWorker extends Worker {
     * - else with different notification. File conflict for example.
     **/
    private void addNotification(NotificationManager manager, String title, String text, boolean isOnGoing) {
        NotificationChannel channel = manager.getNotificationChannel(AppConstants.notificationChannelID);
        if (channel == null) {
            CommonUtils.createNotificationChannel(getApplicationContext());
        }

        final NotificationCompat.Builder builder =
                new NotificationCompat.Builder(getApplicationContext(), AppConstants.notificationChannelID)
                        .setSmallIcon(android.R.drawable.stat_sys_warning)
@@ -200,7 +213,7 @@ public class AccountUserInfoWorker extends Worker {
                        .setOngoing(isOnGoing)
                        .setStyle(new NotificationCompat.BigTextStyle().bigText(text));
        // Add as notification
        manager.notify(0, builder.build());
        manager.notify(QUOTA_NOTIFICATION_ID, builder.build());
    }

    private boolean fetchAliases() {
@@ -223,6 +236,9 @@ public class AccountUserInfoWorker extends Worker {
        }
        accountManager.setUserData(account, ACCOUNT_DATA_ALIAS_KEY, aliases);
        Timber.d("fetchAliases(): success");

        DavClientProvider.getInstance().saveAccounts(mContext);

        return true;
    }
}
+1 −3
Original line number Diff line number Diff line
@@ -12,8 +12,6 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import androidx.work.OneTimeWorkRequest
import androidx.work.WorkManager
import foundation.e.drive.R
import foundation.e.drive.account.AccountUtils
import foundation.e.drive.models.SyncedFolder
@@ -69,7 +67,7 @@ class AccountAddedReceiver() : BroadcastReceiver() {
        prefs: SharedPreferences,
        context: Context
    ): Boolean {
        if (isSetupAlreadyDone(prefs)) {
        if (AccountUtils.isSetupAlreadyDone(prefs)) {
            return false
        }

+6 −14
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ import static foundation.e.drive.utils.AppConstants.SETUP_COMPLETED;

import android.accounts.AccountManager;
import android.annotation.SuppressLint;
import android.app.Application;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -25,12 +26,10 @@ import androidx.work.WorkManager;

import java.io.File;

import foundation.e.drive.EdriveApplication;
import foundation.e.drive.R;
import foundation.e.drive.database.DbHelper;
import foundation.e.drive.database.FailedSyncPrefsManager;
import foundation.e.drive.synchronization.SyncProgressNotifier;
import foundation.e.drive.synchronization.SyncWorker;
import foundation.e.drive.synchronization.SyncProxy;
import foundation.e.drive.utils.AppConstants;
import foundation.e.drive.utils.DavClientProvider;
import foundation.e.drive.utils.ViewUtils;
@@ -52,11 +51,12 @@ public class AccountRemoveCallbackReceiver extends BroadcastReceiver {
        }

        cancelWorkers(applicationContext);
        stopRecursiveFileObserver(applicationContext);
        SyncProxy.INSTANCE.moveToIdle((Application) applicationContext);
        deleteDatabase(applicationContext);
        cleanSharedPreferences(applicationContext, preferences);
        removeCachedFiles(applicationContext);
        deleteNotificationChannels(applicationContext);

        DavClientProvider.getInstance().cleanUp();

        ViewUtils.updateWidgetView(applicationContext);
@@ -73,12 +73,6 @@ public class AccountRemoveCallbackReceiver extends BroadcastReceiver {
        Timber.d("Remove Database: %s", result);
    }

    private void stopRecursiveFileObserver(@NonNull Context applicationContext) {
        if (applicationContext instanceof EdriveApplication) {
            ((EdriveApplication) applicationContext).stopRecursiveFileObserver();
        }
    }

    private boolean shouldProceedWithRemoval(@NonNull Intent intent, @NonNull SharedPreferences preferences, @NonNull Context context) {
        if (isInvalidAction(intent) || intent.getExtras() == null) {
            Timber.w("Invalid account removal request");
@@ -151,12 +145,10 @@ public class AccountRemoveCallbackReceiver extends BroadcastReceiver {
    private void deleteNotificationChannels(Context context) {
        NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

        notificationManager.cancelAll();
        try {
            notificationManager.deleteNotificationChannel(AppConstants.notificationChannelID);
            notificationManager.deleteNotificationChannel(SyncProgressNotifier.NOTIF_CHANNEL_ID);
            notificationManager.cancelAll();
        } catch (Exception exception) {
            Timber.e(exception, "Cannot delete notification Channel");
            Timber.e(exception, "Cannot cancel all notifications");
        }
    }
}
Loading