|
@@ -95,6 +95,7 @@ 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.RestoreFileVersionOperation;
|
|
|
import com.owncloud.android.operations.SynchronizeFileOperation;
|
|
|
import com.owncloud.android.operations.UnshareOperation;
|
|
|
import com.owncloud.android.operations.UpdateSharePermissionsOperation;
|
|
@@ -137,6 +138,7 @@ import org.parceler.Parcels;
|
|
|
import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import static com.owncloud.android.db.PreferenceManager.getSortOrder;
|
|
|
|
|
@@ -1726,6 +1728,8 @@ public class FileDisplayActivity extends HookActivity
|
|
|
onUpdateShareInformation(result, R.string.updating_share_failed);
|
|
|
} else if (operation instanceof UnshareOperation) {
|
|
|
onUpdateShareInformation(result, R.string.unsharing_failed);
|
|
|
+ } else if (operation instanceof RestoreFileVersionOperation) {
|
|
|
+ onRestoreFileVersionOperationFinish((RestoreFileVersionOperation) operation, result);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1766,7 +1770,11 @@ public class FileDisplayActivity extends HookActivity
|
|
|
OCFile removedFile = operation.getFile();
|
|
|
tryStopPlaying(removedFile);
|
|
|
FileFragment second = getSecondFragment();
|
|
|
- if (second != null && removedFile.equals(second.getFile())) {
|
|
|
+
|
|
|
+ // check if file is still available, if so do nothing
|
|
|
+ boolean fileAvailable = getStorageManager().fileExists(removedFile.getFileId());
|
|
|
+
|
|
|
+ if (second != null && !fileAvailable && removedFile.equals(second.getFile())) {
|
|
|
if (second instanceof PreviewMediaFragment) {
|
|
|
((PreviewMediaFragment) second).stopPreview(true);
|
|
|
}
|
|
@@ -1785,6 +1793,29 @@ public class FileDisplayActivity extends HookActivity
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void onRestoreFileVersionOperationFinish(RestoreFileVersionOperation operation,
|
|
|
+ RemoteOperationResult result) {
|
|
|
+
|
|
|
+ if (result.isSuccess()) {
|
|
|
+ OCFile file = getFile();
|
|
|
+
|
|
|
+ if (file.isDown()) {
|
|
|
+ List<OCFile> list = new ArrayList<>();
|
|
|
+ list.add(file);
|
|
|
+ getFileOperationsHelper().removeFiles(list, true, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ OCFile parent = getStorageManager().getFileById(file.getParentId());
|
|
|
+ startSyncFolderOperation(parent, true, true);
|
|
|
+
|
|
|
+ if (getSecondFragment() instanceof FileDetailFragment) {
|
|
|
+ FileDetailFragment fileDetailFragment = (FileDetailFragment) getSecondFragment();
|
|
|
+ fileDetailFragment.getFileDetailActivitiesFragment().reload();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public void setMediaServiceConnection() {
|
|
|
mMediaServiceConnection = newMediaConnection();// mediaServiceConnection;
|
|
|
bindService(new Intent(this, MediaService.class), mMediaServiceConnection, Context.BIND_AUTO_CREATE);
|
|
@@ -2093,7 +2124,25 @@ public class FileDisplayActivity extends HookActivity
|
|
|
* @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) {
|
|
|
+ public void startSyncFolderOperation(OCFile folder, boolean ignoreETag) {
|
|
|
+ startSyncFolderOperation(folder, ignoreETag, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Starts an operation to refresh the requested folder.
|
|
|
+ * <p/>
|
|
|
+ * The operation is run in a new background thread created on the fly.
|
|
|
+ * <p/>
|
|
|
+ * 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.
|
|
|
+ * @param ignoreFocus reloads file list even without focus, e.g. on tablet mode, focus can still be in detail view
|
|
|
+ */
|
|
|
+ public void startSyncFolderOperation(final OCFile folder, final boolean ignoreETag, boolean ignoreFocus) {
|
|
|
|
|
|
// 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
|
|
@@ -2102,7 +2151,7 @@ public class FileDisplayActivity extends HookActivity
|
|
|
new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- if (hasWindowFocus()) {
|
|
|
+ if (ignoreFocus || hasWindowFocus()) {
|
|
|
long currentSyncTime = System.currentTimeMillis();
|
|
|
mSyncInProgress = true;
|
|
|
|