Search in sources :

Example 6 with OCFile

use of com.owncloud.android.datamodel.OCFile in project android by owncloud.

the class UploadPathActivity method onAccountSet.

/**
     * Called when the ownCloud {@link Account} associated to the Activity was
     * just updated.
     */
@Override
protected void onAccountSet(boolean stateWasRecovered) {
    super.onAccountSet(stateWasRecovered);
    if (getAccount() != null) {
        updateFileFromDB();
        OCFile folder = getFile();
        if (folder == null || !folder.isFolder()) {
            // fall back to root folder
            setFile(getStorageManager().getFileByPath(OCFile.ROOT_PATH));
            folder = getFile();
        }
        onBrowsedDownTo(folder);
        if (!stateWasRecovered) {
            OCFileListFragment listOfFolders = getListOfFilesFragment();
            // TODO Enable when "On Device" is recovered ?
            listOfFolders.listDirectory(folder);
            startSyncFolderOperation(folder, false);
        }
        updateNavigationElementsInActionBar();
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment)

Example 7 with OCFile

use of com.owncloud.android.datamodel.OCFile in project android by owncloud.

the class UploadPathActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String instantUploadPath = getIntent().getStringExtra(KEY_INSTANT_UPLOAD_PATH);
    // The caller activity (Preferences) is not a FileActivity, so it has no OCFile, only a path.
    OCFile folder = new OCFile(instantUploadPath);
    setFile(folder);
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile)

Example 8 with OCFile

use of com.owncloud.android.datamodel.OCFile in project android by owncloud.

the class FileOperationsHelper method copyFiles.

/**
     * Start operations to copy one or several files
     *
     * @param files            Files to copy
     * @param targetFolder     Folder where the files while be copied into
     */
public void copyFiles(Collection<OCFile> files, OCFile targetFolder) {
    for (OCFile file : files) {
        Intent service = new Intent(mFileActivity, OperationsService.class);
        service.setAction(OperationsService.ACTION_COPY_FILE);
        service.putExtra(OperationsService.EXTRA_NEW_PARENT_PATH, targetFolder.getRemotePath());
        service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
        service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
        mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
    }
    mFileActivity.showLoadingDialog(R.string.wait_a_moment);
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) Intent(android.content.Intent)

Example 9 with OCFile

use of com.owncloud.android.datamodel.OCFile in project android by owncloud.

the class FileOperationsHelper method moveFiles.

/**
     * Start operations to move one or several files
     *
     * @param files            Files to move
     * @param targetFolder     Folder where the files while be moved into
     */
public void moveFiles(Collection<OCFile> files, OCFile targetFolder) {
    for (OCFile file : files) {
        Intent service = new Intent(mFileActivity, OperationsService.class);
        service.setAction(OperationsService.ACTION_MOVE_FILE);
        service.putExtra(OperationsService.EXTRA_NEW_PARENT_PATH, targetFolder.getRemotePath());
        service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
        service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
        mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
    }
    mFileActivity.showLoadingDialog(R.string.wait_a_moment);
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) Intent(android.content.Intent)

Example 10 with OCFile

use of com.owncloud.android.datamodel.OCFile in project android by owncloud.

the class OCFileListFragment method onBrowseUp.

/**
     * Call this, when the user presses the up button.
     *
     * Tries to move up the current folder one level. If the parent folder was removed from the
     * database, it continues browsing up until finding an existing folders.
     * <p/>
     * return       Count of folder levels browsed up.
     */
public int onBrowseUp() {
    OCFile parentDir;
    int moveCount = 0;
    if (mFile != null) {
        FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
        String parentPath = null;
        if (mFile.getParentId() != FileDataStorageManager.ROOT_PARENT_ID) {
            parentPath = new File(mFile.getRemotePath()).getParent();
            parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath : parentPath + OCFile.PATH_SEPARATOR;
            parentDir = storageManager.getFileByPath(parentPath);
            moveCount++;
        } else {
            parentDir = storageManager.getFileByPath(OCFile.ROOT_PATH);
        }
        while (parentDir == null) {
            parentPath = new File(parentPath).getParent();
            parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath : parentPath + OCFile.PATH_SEPARATOR;
            parentDir = storageManager.getFileByPath(parentPath);
            moveCount++;
        }
        // exit is granted because storageManager.getFileByPath("/") never returns null
        mFile = parentDir;
        // TODO Enable when "On Device" is recovered ?
        listDirectory(mFile);
        onRefresh(false);
        // restore index and top position
        restoreIndexAndTopPosition();
    }
    return moveCount;
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) OCFile(com.owncloud.android.datamodel.OCFile) File(java.io.File)

Aggregations

OCFile (com.owncloud.android.datamodel.OCFile)84 File (java.io.File)14 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)9 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)8 Intent (android.content.Intent)7 Account (android.accounts.Account)6 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)6 FileFragment (com.owncloud.android.ui.fragment.FileFragment)5 Vector (java.util.Vector)5 Bundle (android.os.Bundle)4 OwnCloudAccount (com.owncloud.android.lib.common.OwnCloudAccount)4 RemoteFile (com.owncloud.android.lib.resources.files.RemoteFile)4 SuppressLint (android.annotation.SuppressLint)3 Bitmap (android.graphics.Bitmap)3 View (android.view.View)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 ThumbnailsCacheManager (com.owncloud.android.datamodel.ThumbnailsCacheManager)3 TransferProgressController (com.owncloud.android.ui.controller.TransferProgressController)3 SharedPreferences (android.content.SharedPreferences)2