Search in sources :

Example 96 with OCFile

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

the class ReceiveExternalFilesActivity method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    // click on folder in the list
    Timber.d("on item click");
    // get current representation of files:
    // This does not necessarily mean this is the content of the current folder.
    // If the user searches for a folder mAdapter.getFiles() returns only the folders/files
    // that match the currently entered search query.
    Vector<OCFile> tmpfiles = mAdapter.getFiles();
    tmpfiles = sortFileList(tmpfiles);
    if (tmpfiles.size() <= 0) {
        return;
    }
    // filter on dirtype
    Vector<OCFile> files = new Vector<>(tmpfiles);
    if (files.size() < position) {
        throw new IndexOutOfBoundsException("Incorrect item selected");
    }
    if (files.get(position).isFolder()) {
        OCFile folderToEnter = files.get(position);
        startSyncFolderOperation(folderToEnter);
        mParents.push(folderToEnter.getFileName());
        updateDirectoryList();
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) Vector(java.util.Vector)

Example 97 with OCFile

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

the class ReceiveExternalFilesActivity method browseToRoot.

private void browseToRoot() {
    OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
    mFile = root;
    startSyncFolderOperation(root);
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile)

Example 98 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();
            listOfFolders.listDirectory(folder);
            startSyncFolderOperation(folder, false);
        }
        updateNavigationElementsInActionBar();
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment)

Example 99 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 cameraUploadPath = getIntent().getStringExtra(KEY_CAMERA_UPLOAD_PATH);
    // The caller activity (Preferences) is not a FileActivity, so it has no OCFile, only a path.
    OCFile folder = new OCFile(cameraUploadPath);
    setFile(folder);
    // Account may differ from current one. We need to show the picker for this one, not current.
    String accountName = getIntent().getStringExtra(KEY_CAMERA_UPLOAD_ACCOUNT);
    setAccount(AccountUtils.getOwnCloudAccountByName(this, accountName));
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile)

Example 100 with OCFile

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

the class OCFileListFragment method isGridViewPreferred.

/**
 * Determines if user set folder to grid or list view. If folder is not set itself,
 * it finds a parent that is set (at least root is set).
 *
 * @param file Folder to check.
 * @return 'true' is folder should be shown in grid mode, 'false' if list mode is preferred.
 */
private boolean isGridViewPreferred(OCFile file) {
    if (file != null) {
        OCFile fileToTest = file;
        OCFile parentDir;
        String parentPath = null;
        FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
        SharedPreferences setting = requireActivity().getSharedPreferences(GRID_IS_PREFERED_PREFERENCE, Context.MODE_PRIVATE);
        if (setting.contains(String.valueOf(fileToTest.getFileId()))) {
            return setting.getBoolean(String.valueOf(fileToTest.getFileId()), false);
        } else {
            do {
                if (fileToTest.getParentId() != FileDataStorageManager.ROOT_PARENT_ID) {
                    parentPath = new File(fileToTest.getRemotePath()).getParent();
                    parentPath = parentPath.endsWith(File.separator) ? parentPath : parentPath + File.separator;
                    parentDir = storageManager.getFileByPath(parentPath);
                } else {
                    parentDir = storageManager.getFileByPath(OCFile.ROOT_PATH);
                }
                while (parentDir == null) {
                    parentPath = new File(parentPath).getParent();
                    parentPath = parentPath.endsWith(File.separator) ? parentPath : parentPath + File.separator;
                    parentDir = storageManager.getFileByPath(parentPath);
                }
                fileToTest = parentDir;
            } while (endWhile(parentDir, setting));
            return setting.getBoolean(String.valueOf(fileToTest.getFileId()), false);
        }
    } else {
        return false;
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) SharedPreferences(android.content.SharedPreferences) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) OCFile(com.owncloud.android.datamodel.OCFile) File(java.io.File)

Aggregations

OCFile (com.owncloud.android.datamodel.OCFile)307 File (java.io.File)56 Test (org.junit.Test)44 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)43 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)40 ArrayList (java.util.ArrayList)28 Intent (android.content.Intent)27 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)22 OCUpload (com.owncloud.android.db.OCUpload)20 ScreenshotTest (com.owncloud.android.utils.ScreenshotTest)20 FileFragment (com.owncloud.android.ui.fragment.FileFragment)19 User (com.nextcloud.client.account.User)17 RemoteFile (com.owncloud.android.lib.resources.files.model.RemoteFile)16 Bundle (android.os.Bundle)13 Fragment (androidx.fragment.app.Fragment)12 RemoteFile (com.owncloud.android.lib.resources.files.RemoteFile)12 FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)12 Account (android.accounts.Account)11 SuppressLint (android.annotation.SuppressLint)11 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)11