X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/aa4f47cbe08cfcd2a8e272d103c438b7247fd436..d82263aa2372bb5ec4fc944fc1a17c84182646ea:/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 95e7fad9..f09ed6c7 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -26,7 +26,6 @@ import android.accounts.Account; import android.accounts.AccountManager; import android.accounts.AuthenticatorException; import android.annotation.TargetApi; -import android.support.v7.app.AlertDialog; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; @@ -50,6 +49,7 @@ import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v4.content.ContextCompat; import android.support.v4.view.GravityCompat; +import android.support.v7.app.AlertDialog; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -79,14 +79,11 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCo import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.operations.CopyFileOperation; import com.owncloud.android.operations.CreateFolderOperation; -import com.owncloud.android.operations.CreateShareViaLinkOperation; -import com.owncloud.android.operations.CreateShareWithShareeOperation; import com.owncloud.android.operations.MoveFileOperation; import com.owncloud.android.operations.RefreshFolderOperation; import com.owncloud.android.operations.RemoveFileOperation; import com.owncloud.android.operations.RenameFileOperation; import com.owncloud.android.operations.SynchronizeFileOperation; -import com.owncloud.android.operations.UnshareOperation; import com.owncloud.android.services.observer.FileObserverService; import com.owncloud.android.syncadapter.FileSyncAdapter; import com.owncloud.android.ui.dialog.ConfirmationDialogFragment; @@ -226,6 +223,13 @@ public class FileDisplayActivity extends HookActivity } @Override + protected void onStop() { + Log_OC.v(TAG, "onStop() start"); + super.onStop(); + Log_OC.v(TAG, "onStop() end"); + } + + @Override protected void onDestroy() { Log_OC.v(TAG, "onDestroy() start"); super.onDestroy(); @@ -635,7 +639,7 @@ public class FileDisplayActivity extends HookActivity requestMoveOperation(fData, fResultCode); } }, - DELAY_TO_REQUEST_OPERATION_ON_ACTIVITY_RESULTS + DELAY_TO_REQUEST_OPERATIONS_LATER ); } else if (requestCode == ACTION_COPY_FILES && resultCode == RESULT_OK) { @@ -649,7 +653,7 @@ public class FileDisplayActivity extends HookActivity requestCopyOperation(fData, fResultCode); } }, - DELAY_TO_REQUEST_OPERATION_ON_ACTIVITY_RESULTS + DELAY_TO_REQUEST_OPERATIONS_LATER ); } else { @@ -982,6 +986,7 @@ public class FileDisplayActivity extends HookActivity } } + } removeStickyBroadcast(intent); Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress); @@ -1228,20 +1233,6 @@ public class FileDisplayActivity extends HookActivity setFile(file); } - /** - * Shows the share view for sharing {@link OCFile} received as a - * parameter in the second fragment. - * - * @param file {@link OCFile} File to share with - */ - @Override - public void showShareFile(OCFile file) { - Intent intent = new Intent(this, ShareActivity.class); - intent.putExtra(EXTRA_FILE, file); - intent.putExtra(EXTRA_ACCOUNT, getAccount()); - startActivity(intent); - } - @Override protected void updateActionBarTitleAndHomeButton(OCFile chosenFile) { if (mDualPane) { @@ -1359,15 +1350,6 @@ public class FileDisplayActivity extends HookActivity } else if (operation instanceof CreateFolderOperation) { onCreateFolderOperationFinish((CreateFolderOperation) operation, result); - } else if (operation instanceof CreateShareViaLinkOperation || - operation instanceof CreateShareWithShareeOperation ) { - - refreshShowDetails(); - refreshListOfFilesFragment(); - - } else if (operation instanceof UnshareOperation) { - onUnshareLinkOperationFinish((UnshareOperation) operation, result); - } else if (operation instanceof MoveFileOperation) { onMoveFileOperationFinish((MoveFileOperation) operation, result); @@ -1377,18 +1359,6 @@ public class FileDisplayActivity extends HookActivity } - private void onUnshareLinkOperationFinish(UnshareOperation operation, - RemoteOperationResult result) { - if (result.isSuccess()) { - refreshShowDetails(); - refreshListOfFilesFragment(); - - } else if (result.getCode() == ResultCode.SHARE_NOT_FOUND) { - cleanSecondFragment(); - refreshListOfFilesFragment(); - } - } - private void refreshShowDetails() { FileFragment details = getSecondFragment(); if (details != null) { @@ -1634,26 +1604,60 @@ public class FileDisplayActivity extends HookActivity return null; } - public void startSyncFolderOperation(OCFile folder, boolean ignoreETag) { - long currentSyncTime = System.currentTimeMillis(); - - mSyncInProgress = true; - - // perform folder synchronization - RemoteOperation synchFolderOp = new RefreshFolderOperation( folder, - currentSyncTime, - false, - getFileOperationsHelper().isSharedSupported(), - ignoreETag, - getStorageManager(), - getAccount(), - getApplicationContext() + /** + * Starts an operation to refresh the requested folder. + * + * The operation is run in a new background thread created on the fly. + * + * The refresh updates is a "light sync": properties of regular files in folder are updated (including + * associated shares), but not their contents. Only the contents of files marked to be kept-in-sync are + * synchronized too. + * + * @param folder Folder to refresh. + * @param ignoreETag If 'true', the data from the server will be fetched and sync'ed even if the eTag + * didn't change. + */ + public void startSyncFolderOperation(final OCFile folder, final boolean ignoreETag) { + + // the execution is slightly delayed to allow the activity get the window focus if it's being started + // or if the method is called from a dialog that is being dismissed + getHandler().postDelayed( + new Runnable() { + @Override + public void run() { + if (hasWindowFocus()) { + long currentSyncTime = System.currentTimeMillis(); + mSyncInProgress = true; + + // perform folder synchronization + RemoteOperation synchFolderOp = new RefreshFolderOperation(folder, + currentSyncTime, + false, + getFileOperationsHelper().isSharedSupported(), + ignoreETag, + getStorageManager(), + getAccount(), + getApplicationContext() + ); + synchFolderOp.execute( + getAccount(), + MainApp.getAppContext(), + FileDisplayActivity.this, + null, + null + ); + + mProgressBar.setIndeterminate(true); + + setBackgroundText(); + + } // else: NOTHING ; lets' not refresh when the user rotates the device but there is + // another window floating over + } + }, + DELAY_TO_REQUEST_OPERATIONS_LATER ); - synchFolderOp.execute(getAccount(), MainApp.getAppContext(), this, null, null); - mProgressBar.setIndeterminate(true); - - setBackgroundText(); } /**