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

Commit c24a9073 authored by Aayush Gupta's avatar Aayush Gupta
Browse files

Merge branch '3-oms-as-boundService' into '1-epic-refactoring-p1'

Transform OperationManagerService into BoundService (SynchronizerService.java)

See merge request !79
parents 61776be7 7e96d82b
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ http://www.gnu.org/licenses/gpl.html
        <service
            android:name=".services.ObserverService"
            android:enabled="true" />
        <service android:name=".services.OperationManagerService" />
        <service android:name=".services.SynchronizationService" />

        <receiver
            android:name=".receivers.PackageEventReceiver"
+12 −7
Original line number Diff line number Diff line
@@ -12,12 +12,14 @@ import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.Application;
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;

@@ -46,17 +48,20 @@ public class EdriveApplication extends Application {
        if (prefs.getString(AccountManager.KEY_ACCOUNT_NAME, null) != null) {
            Log.d(TAG, "Account already registered");
            startRecursiveFileObserver();

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

        } else {
            Account mAccount = CommonUtils.getAccount(getString(R.string.eelo_account_type), AccountManager.get(this));
            if (mAccount != null) {
            if (mAccount == null) {return ;}

            String accountName = mAccount.name;
            String accountType = mAccount.type;

            prefs.edit().putString(AccountManager.KEY_ACCOUNT_NAME, accountName)
                    .putString(AccountManager.KEY_ACCOUNT_TYPE, accountType)
                    .apply();

            }
        }
    }

+26 −0
Original line number Diff line number Diff line
/*
 * Copyright © Vincent Bourgmayer (/e/ foundation).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 */
package foundation.e.drive.models;

import com.owncloud.android.lib.resources.files.model.RemoteFile;

/**
 * @author vincent Bourgmayer
 */
public class DownloadRequest extends SyncRequest {
    private final RemoteFile remoteFile;

    public DownloadRequest (RemoteFile remoteFile, SyncedFileState syncedFileState) {
        super(syncedFileState, Type.DOWNLOAD);
        this.remoteFile = remoteFile;
    }

    public RemoteFile getRemoteFile() {
        return remoteFile;
    }
}
+39 −0
Original line number Diff line number Diff line
/*
 * Copyright © Vincent Bourgmayer (/e/ foundation).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 */
package foundation.e.drive.models;

import androidx.annotation.Nullable;

public class SyncRequest {
    public enum Type { UPLOAD, DOWNLOAD, REMOTE_DELETE};

    private final SyncedFileState syncedFileState;

    private final Type operationType;

    public SyncRequest(SyncedFileState syncedFileState, Type operationType) {
        this.syncedFileState = syncedFileState;
        this.operationType = operationType;
    }

    public Type getOperationType() {
        return operationType;
    }

    public SyncedFileState getSyncedFileState() {
        return syncedFileState;
    }

    @Override
    public boolean equals(@Nullable Object obj) {
        if (obj instanceof SyncRequest) {
            return (syncedFileState.getId() == ((SyncRequest) obj).syncedFileState.getId() );
        }
        return super.equals(obj);
    }
}
+0 −18
Original line number Diff line number Diff line
package foundation.e.drive.operations;

import com.owncloud.android.lib.common.operations.RemoteOperation;

public interface ComparableOperation {

    /**
     * Say if File affected by operation is a media or a settings
     * @return
     */
    public boolean isMediaType();

    /**
     * Cast instance to generic remoteOperation Type
     * @return RemoteOperation this instance
     */
    public RemoteOperation toRemoteOperation();
}
Loading