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);
}
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);
}
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);
}
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;
}
use of com.owncloud.android.datamodel.OCFile in project android by owncloud.
the class OCFileListFragment method updateLayout.
private void updateLayout() {
if (!isShowingJustFolders()) {
int filesCount = 0, foldersCount = 0;
int count = mAdapter.getCount();
OCFile file;
for (int i = 0; i < count; i++) {
file = (OCFile) mAdapter.getItem(i);
if (file.isFolder()) {
foldersCount++;
} else {
if (!file.isHidden()) {
filesCount++;
}
}
}
// set footer text
setFooterText(generateFooterText(filesCount, foldersCount));
// decide grid vs list view
OwnCloudVersion version = AccountUtils.getServerVersion(((FileActivity) mContainerActivity).getAccount());
if (version != null && version.supportsRemoteThumbnails() && isGridViewPreferred(mFile)) {
switchToGridView();
} else {
switchToListView();
}
}
invalidateActionMode();
}
Aggregations