X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/a8fade7369bc8d1752dc4ba5fe07935cac84e96f..d7c4d1248587e87ad5320c6f1df66e8d422ea3aa:/src/com/owncloud/android/ui/activity/FileDisplayActivity.java diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 5eba7dc0..1e41889e 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -594,23 +594,22 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa @Override public void onBackPressed() { - if (!mSyncInProgress) { - OCFileListFragment listOfFiles = getListOfFilesFragment(); - if (mDualPane || getSecondFragment() == null) { - if (listOfFiles != null) { // should never be null, indeed - if (mDirectories.getCount() <= 1) { - finish(); - return; - } - popDirname(); - listOfFiles.onBrowseUp(); - } - } + OCFileListFragment listOfFiles = getListOfFilesFragment(); + if (mDualPane || getSecondFragment() == null) { if (listOfFiles != null) { // should never be null, indeed - setFile(listOfFiles.getCurrentFile()); + if (mDirectories.getCount() <= 1) { + finish(); + return; + } + popDirname(); + listOfFiles.onBrowseUp(); } - cleanSecondFragment(); } + if (listOfFiles != null) { // should never be null, indeed + setFile(listOfFiles.getCurrentFile()); + } + cleanSecondFragment(); + } @Override @@ -652,19 +651,6 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa @Override - protected void onStart() { - super.onStart(); - Log_OC.e(TAG, "onStart() start"); - - // Update the sync operation - if (mSyncInProgress){ - } - - Log_OC.e(TAG, "onStart() end"); - } - - - @Override protected void onPause() { super.onPause(); Log_OC.e(TAG, "onPause() start"); @@ -876,42 +862,44 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa public void onReceive(Context context, Intent intent) { boolean inProgress = intent.getBooleanExtra(FileSyncService.IN_PROGRESS, false); String accountName = intent.getStringExtra(FileSyncService.ACCOUNT_NAME); + RemoteOperationResult synchResult = (RemoteOperationResult)intent.getSerializableExtra(FileSyncService.SYNC_RESULT); Log_OC.d(TAG, "sync of account " + accountName + " is in_progress: " + inProgress); - RemoteOperationResult synchResult = (RemoteOperationResult)intent.getSerializableExtra(FileSyncService.SYNC_RESULT); - if (getAccount() != null && accountName.equals(getAccount().name)) { String synchFolderRemotePath = intent.getStringExtra(FileSyncService.SYNC_FOLDER_REMOTE_PATH); - boolean fillBlankRoot = false; - OCFile currentDir = getCurrentDir(); - if (currentDir == null) { - currentDir = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR); - fillBlankRoot = (currentDir != null); - } + OCFile currentFile = mStorageManager.getFileById(getFile().getFileId()); + OCFile currentDir = mStorageManager.getFileById(getCurrentDir().getFileId()); - if ((synchFolderRemotePath != null && currentDir != null && (currentDir.getRemotePath().equals(synchFolderRemotePath))) - || fillBlankRoot ) { - if (!fillBlankRoot) - currentDir = getStorageManager().getFileByPath(synchFolderRemotePath); - OCFileListFragment fileListFragment = getListOfFilesFragment(); - if (fileListFragment != null) { - fileListFragment.listDirectory(currentDir); - + if (currentDir == null) { + // current folder was removed from the server + Toast.makeText(FileDisplayActivity.this, getString(R.string.sync_current_folder_was_removed), Toast.LENGTH_LONG) + .show(); + onBackPressed(); + + } else { + if (currentFile == null && !getFile().isDirectory()) { + // currently selected file was removed in the server, and now we know it + cleanSecondFragment(); + currentFile = currentDir; + } + + if (synchFolderRemotePath != null && currentDir.getRemotePath().equals(synchFolderRemotePath)) { + OCFileListFragment fileListFragment = getListOfFilesFragment(); + if (fileListFragment != null) { + fileListFragment.listDirectory(currentDir); + } } - if (getSecondFragment() == null) - setFile(currentDir); + setFile(currentFile); } setSupportProgressBarIndeterminateVisibility(inProgress); removeStickyBroadcast(intent); - mSyncInProgress = inProgress; } - if (synchResult != null) { if (synchResult.getCode().equals(RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) { @@ -997,7 +985,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa cleanSecondFragment(); // Sync Folder - startSyncFolderOperation(directory.getRemotePath(), directory.getFileId()); + startSyncFolderOperation(directory); } @@ -1073,7 +1061,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa if (chosenFile == null || mDualPane) { // only list of files - set for browsing through folders OCFile currentDir = getCurrentDir(); - actionBar.setDisplayHomeAsUpEnabled(currentDir != null && currentDir.getParentId() != 0 && !mSyncInProgress); + actionBar.setDisplayHomeAsUpEnabled(currentDir != null && currentDir.getParentId() != 0); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(mDirectories, this); // assuming mDirectories is updated @@ -1371,7 +1359,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa // Create directory path += newDirectoryName + OCFile.PATH_SEPARATOR; - RemoteOperation operation = new CreateFolderOperation(path, getCurrentDir().getFileId(), mStorageManager); + RemoteOperation operation = new CreateFolderOperation(path, false, mStorageManager); operation.execute( getAccount(), FileDisplayActivity.this, FileDisplayActivity.this, @@ -1407,21 +1395,20 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa return null; } - public void startSyncFolderOperation(String remotePath, long parentId) { + public void startSyncFolderOperation(OCFile folder) { long currentSyncTime = System.currentTimeMillis(); mSyncInProgress = true; // perform folder synchronization - RemoteOperation synchFolderOp = new SynchronizeFolderOperation( remotePath, - currentSyncTime, - parentId, - false, - false, - getStorageManager(), - getAccount(), - getApplicationContext() - ); + RemoteOperation synchFolderOp = new SynchronizeFolderOperation( folder, + currentSyncTime, + false, + false, + getStorageManager(), + getAccount(), + getApplicationContext() + ); synchFolderOp.execute(getAccount(), this, null, null, this); setSupportProgressBarIndeterminateVisibility(true);