From: masensio Date: Tue, 1 Oct 2013 10:58:17 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/develop' into refresh_folder_contents_when_brows... X-Git-Tag: oc-android-1.5.5~155^2~32 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/5ff0989eb47fbc9d5211cc294f17cf692f7eff50?hp=-c Merge remote-tracking branch 'origin/develop' into refresh_folder_contents_when_browsed_into --- 5ff0989eb47fbc9d5211cc294f17cf692f7eff50 diff --combined src/com/owncloud/android/datamodel/FileDataStorageManager.java index eaeaf985,5f6321d8..c60cdacc --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@@ -126,7 -126,7 +126,7 @@@ public class FileDataStorageManager imp cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, file.getFileLength()); cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, file.getMimetype()); cv.put(ProviderTableMeta.FILE_NAME, file.getFileName()); - if (file.getParentId() != 0) + if (file.getParentId() != DataStorageManager.ROOT_PARENT_ID) cv.put(ProviderTableMeta.FILE_PARENT, file.getParentId()); cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath()); if (!file.isDirectory()) @@@ -135,7 -135,6 +135,7 @@@ cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties()); cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData()); cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.keepInSync() ? 1 : 0); + cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag()); boolean sameRemotePath = fileExists(file.getRemotePath()); boolean changesSizeOfAncestors = false; @@@ -223,7 -222,7 +223,7 @@@ cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, file.getFileLength()); cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, file.getMimetype()); cv.put(ProviderTableMeta.FILE_NAME, file.getFileName()); - if (file.getParentId() != 0) + if (file.getParentId() != DataStorageManager.ROOT_PARENT_ID) cv.put(ProviderTableMeta.FILE_PARENT, file.getParentId()); cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath()); if (!file.isDirectory()) @@@ -232,7 -231,6 +232,7 @@@ cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties()); cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData()); cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.keepInSync() ? 1 : 0); + cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag()); if (fileExists(file.getRemotePath())) { OCFile oldFile = getFileByPath(file.getRemotePath()); @@@ -474,8 -472,6 +474,8 @@@ getColumnIndex(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA))); file.setKeepInSync(c.getInt( c.getColumnIndex(ProviderTableMeta.FILE_KEEP_IN_SYNC)) == 1 ? true : false); + file.setEtag(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_ETAG))); + } return file; } @@@ -678,9 -674,8 +678,8 @@@ OCFile file; - while (parentId != 0) { + while (parentId != DataStorageManager.ROOT_PARENT_ID) { - Log_OC.d(TAG, "parent = " + parentId); // Update the size of the parent calculateFolderSize(parentId); diff --combined src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 5eba7dc0,db47d465..d0357460 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@@ -22,8 -22,8 +22,8 @@@ import java.io.File import android.accounts.Account; import android.app.AlertDialog; -import android.app.ProgressDialog; import android.app.Dialog; +import android.app.ProgressDialog; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; @@@ -72,16 -72,15 +72,16 @@@ import com.owncloud.android.operations. import com.owncloud.android.operations.OnRemoteOperationListener; import com.owncloud.android.operations.RemoteOperation; import com.owncloud.android.operations.RemoteOperationResult; +import com.owncloud.android.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.operations.RemoveFileOperation; import com.owncloud.android.operations.RenameFileOperation; import com.owncloud.android.operations.SynchronizeFileOperation; -import com.owncloud.android.operations.RemoteOperationResult.ResultCode; +import com.owncloud.android.operations.SynchronizeFolderOperation; import com.owncloud.android.syncadapter.FileSyncService; import com.owncloud.android.ui.dialog.EditNameDialog; +import com.owncloud.android.ui.dialog.EditNameDialog.EditNameDialogListener; import com.owncloud.android.ui.dialog.LoadingDialog; import com.owncloud.android.ui.dialog.SslValidatorDialog; -import com.owncloud.android.ui.dialog.EditNameDialog.EditNameDialogListener; import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener; import com.owncloud.android.ui.fragment.FileDetailFragment; import com.owncloud.android.ui.fragment.FileFragment; @@@ -118,7 -117,6 +118,7 @@@ OCFileListFragment.ContainerActivity, F private View mRightFragmentContainer; private static final String KEY_WAITING_TO_PREVIEW = "WAITING_TO_PREVIEW"; + private static final String KEY_SYNC_IN_PROGRESS = "SYNC_IN_PROGRESS"; public static final int DIALOG_SHORT_WAIT = 0; private static final int DIALOG_CHOOSE_UPLOAD_SOURCE = 1; @@@ -139,8 -137,6 +139,8 @@@ private OCFile mWaitingToPreview; private Handler mHandler; + + private boolean mSyncInProgress = false; @Override protected void onCreate(Bundle savedInstanceState) { @@@ -170,12 -166,10 +170,12 @@@ /// Load of saved instance state if(savedInstanceState != null) { mWaitingToPreview = (OCFile) savedInstanceState.getParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW); - + mSyncInProgress = savedInstanceState.getBoolean(KEY_SYNC_IN_PROGRESS); + } else { mWaitingToPreview = null; - } + mSyncInProgress = false; + } /// USER INTERFACE @@@ -191,7 -185,7 +191,7 @@@ // Action bar setup mDirectories = new CustomArrayAdapter(this, R.layout.sherlock_spinner_dropdown_item); getSupportActionBar().setHomeButtonEnabled(true); // mandatory since Android ICS, according to the official documentation - setSupportProgressBarIndeterminateVisibility(false); // always AFTER setContentView(...) ; to work around bug in its implementation + setSupportProgressBarIndeterminateVisibility(mSyncInProgress); // always AFTER setContentView(...) ; to work around bug in its implementation Log_OC.d(TAG, "onCreate() end"); } @@@ -464,9 -458,8 +464,9 @@@ FileFragment second = getSecondFragment(); OCFile currentDir = getCurrentDir(); if((currentDir != null && currentDir.getParentId() != 0) || - (second != null && second.getFile() != null)) { + (second != null && second.getFile() != null)) { onBackPressed(); + } break; } @@@ -594,23 -587,21 +594,23 @@@ @Override public void onBackPressed() { - OCFileListFragment listOfFiles = getListOfFilesFragment(); - if (mDualPane || getSecondFragment() == null) { - if (listOfFiles != null) { // should never be null, indeed - if (mDirectories.getCount() <= 1) { - finish(); - return; + 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(); } - popDirname(); - listOfFiles.onBrowseUp(); } + if (listOfFiles != null) { // should never be null, indeed + setFile(listOfFiles.getCurrentFile()); + } + cleanSecondFragment(); } - if (listOfFiles != null) { // should never be null, indeed - setFile(listOfFiles.getCurrentFile()); - } - cleanSecondFragment(); } @Override @@@ -619,8 -610,6 +619,8 @@@ Log_OC.e(TAG, "onSaveInstanceState() start"); super.onSaveInstanceState(outState); outState.putParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW, mWaitingToPreview); + outState.putBoolean(FileDisplayActivity.KEY_SYNC_IN_PROGRESS, mSyncInProgress); + Log_OC.d(TAG, "onSaveInstanceState() end"); } @@@ -652,19 -641,6 +652,19 @@@ @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"); @@@ -878,9 -854,7 +878,9 @@@ String accountName = intent.getStringExtra(FileSyncService.ACCOUNT_NAME); 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); @@@ -899,7 -873,6 +899,7 @@@ OCFileListFragment fileListFragment = getListOfFilesFragment(); if (fileListFragment != null) { fileListFragment.listDirectory(currentDir); + } if (getSecondFragment() == null) setFile(currentDir); @@@ -907,12 -880,10 +907,12 @@@ setSupportProgressBarIndeterminateVisibility(inProgress); removeStickyBroadcast(intent); + + mSyncInProgress = inProgress; } - RemoteOperationResult synchResult = (RemoteOperationResult)intent.getSerializableExtra(FileSyncService.SYNC_RESULT); + if (synchResult != null) { if (synchResult.getCode().equals(RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) { mLastSslUntrustedServerResult = synchResult; @@@ -921,7 -892,7 +921,7 @@@ } } } - + private class UploadFinishReceiver extends BroadcastReceiver { /** @@@ -995,10 -966,6 +995,10 @@@ public void onBrowsedDownTo(OCFile directory) { pushDirname(directory); cleanSecondFragment(); + + // Sync Folder + startSyncFolderOperation(directory.getRemotePath(), directory.getFileId()); + } /** @@@ -1073,7 -1040,7 +1073,7 @@@ if (chosenFile == null || mDualPane) { // only list of files - set for browsing through folders OCFile currentDir = getCurrentDir(); - actionBar.setDisplayHomeAsUpEnabled(currentDir != null && currentDir.getParentId() != 0); + actionBar.setDisplayHomeAsUpEnabled(currentDir != null && currentDir.getParentId() != 0 && !mSyncInProgress); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(mDirectories, this); // assuming mDirectories is updated @@@ -1087,19 -1054,6 +1087,19 @@@ } +// private void updateDisplayHomeAtSync(){ +// ActionBar actionBar = getSupportActionBar(); +// OCFile currentDir = getCurrentDir(); +// if (currentDir.getParentId() != DataStorageManager.ROOT_PARENT_ID) { +// actionBar.setHomeButtonEnabled(!mSyncInProgress); +// actionBar.setDisplayHomeAsUpEnabled(!mSyncInProgress); +// } +// else { +// actionBar.setHomeButtonEnabled(true); +// actionBar.setDisplayHomeAsUpEnabled(false); +// } +// } +// /** * {@inheritDoc} */ @@@ -1220,8 -1174,7 +1220,8 @@@ } else if (operation instanceof CreateFolderOperation) { onCreateFolderOperationFinish((CreateFolderOperation)operation, result); - } + + } } @@@ -1269,6 -1222,7 +1269,6 @@@ refeshListOfFilesFragment(); } else { - //dismissDialog(DIALOG_SHORT_WAIT); dismissLoadingDialog(); try { Toast msg = Toast.makeText(FileDisplayActivity.this, R.string.create_dir_fail_msg, Toast.LENGTH_LONG); @@@ -1329,7 -1283,10 +1329,7 @@@ i.putExtra(ConflictsResolveActivity.EXTRA_ACCOUNT, getAccount()); startActivity(i); - } else { - Toast msg = Toast.makeText(this, R.string.sync_file_fail_msg, Toast.LENGTH_LONG); - msg.show(); - } + } } else { if (operation.transferWasRequested()) { @@@ -1371,7 -1328,7 +1371,7 @@@ // 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, @@@ -1406,37 -1363,5 +1406,37 @@@ } return null; } + + public void startSyncFolderOperation(String remotePath, long parentId) { + long currentSyncTime = System.currentTimeMillis(); + + mSyncInProgress = true; + + // perform folder synchronization + RemoteOperation synchFolderOp = new SynchronizeFolderOperation( remotePath, + currentSyncTime, + parentId, + false, + false, + getStorageManager(), + getAccount(), + getApplicationContext() + ); + synchFolderOp.execute(getAccount(), this, null, null, this); + + setSupportProgressBarIndeterminateVisibility(true); + } + +// public void enableDisableViewGroup(ViewGroup viewGroup, boolean enabled) { +// int childCount = viewGroup.getChildCount(); +// for (int i = 0; i < childCount; i++) { +// View view = viewGroup.getChildAt(i); +// view.setEnabled(enabled); +// view.setClickable(!enabled); +// if (view instanceof ViewGroup) { +// enableDisableViewGroup((ViewGroup) view, enabled); +// } +// } +// } }