X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/15442976fed24e18f3f21d3edcc0e96a774b0de3..ab3044dc821afd86a99a49ce30b9160e5f25e347:/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 199f8c23..0eb1966c 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -68,10 +68,14 @@ import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder; import com.owncloud.android.files.services.FileUploader.FileUploaderBinder; import com.owncloud.android.operations.CreateFolderOperation; -import com.owncloud.android.oc_framework.operations.OnRemoteOperationListener; -import com.owncloud.android.oc_framework.operations.RemoteOperation; -import com.owncloud.android.oc_framework.operations.RemoteOperationResult; -import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode; + +import com.owncloud.android.operations.GetSharesOperation; + +import com.owncloud.android.lib.operations.common.OnRemoteOperationListener; +import com.owncloud.android.lib.operations.common.RemoteOperation; +import com.owncloud.android.lib.operations.common.RemoteOperationResult; +import com.owncloud.android.lib.operations.common.RemoteOperationResult.ResultCode; + import com.owncloud.android.operations.RemoveFileOperation; import com.owncloud.android.operations.RenameFileOperation; import com.owncloud.android.operations.SynchronizeFileOperation; @@ -88,6 +92,7 @@ import com.owncloud.android.ui.fragment.OCFileListFragment; import com.owncloud.android.ui.preview.PreviewImageActivity; import com.owncloud.android.ui.preview.PreviewMediaFragment; import com.owncloud.android.ui.preview.PreviewVideoActivity; +import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.Log_OC; @@ -120,6 +125,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa private static final String KEY_WAITING_TO_PREVIEW = "WAITING_TO_PREVIEW"; private static final String KEY_SYNC_IN_PROGRESS = "SYNC_IN_PROGRESS"; + private static final String KEY_REFRESH_SHARES_IN_PROGRESS = "SHARES_IN_PROGRESS"; public static final int DIALOG_SHORT_WAIT = 0; private static final int DIALOG_CHOOSE_UPLOAD_SOURCE = 1; @@ -142,6 +148,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa private Handler mHandler; private boolean mSyncInProgress = false; + private boolean mRefreshSharesInProgress = false; @Override protected void onCreate(Bundle savedInstanceState) { @@ -161,6 +168,8 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa // PIN CODE request ; best location is to decide, let's try this first if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_MAIN) && savedInstanceState == null) { requestPinCode(); + } else if (getIntent().getAction() == null && savedInstanceState == null) { + requestPinCode(); } /// file observer @@ -172,10 +181,12 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa if(savedInstanceState != null) { mWaitingToPreview = (OCFile) savedInstanceState.getParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW); mSyncInProgress = savedInstanceState.getBoolean(KEY_SYNC_IN_PROGRESS); + mRefreshSharesInProgress = savedInstanceState.getBoolean(KEY_REFRESH_SHARES_IN_PROGRESS); } else { mWaitingToPreview = null; mSyncInProgress = false; + mRefreshSharesInProgress = false; } /// USER INTERFACE @@ -192,13 +203,16 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa // 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(mSyncInProgress); // 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"); } - + + @Override + protected void onStart() { + super.onStart(); + getSupportActionBar().setIcon(DisplayUtils.getSeasonalIconId()); + } @Override protected void onDestroy() { @@ -217,7 +231,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa protected void onAccountSet(boolean stateWasRecovered) { if (getAccount() != null) { mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver()); - + /// Check whether the 'main' OCFile handled by the Activity is contained in the current Account OCFile file = getFile(); // get parent from path @@ -239,6 +253,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa } setFile(file); setNavigationListWithFolder(file); + if (!stateWasRecovered) { Log_OC.e(TAG, "Initializing Fragments in onAccountChanged.."); initFragmentsWithFile(); @@ -661,6 +676,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa super.onSaveInstanceState(outState); outState.putParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW, mWaitingToPreview); outState.putBoolean(FileDisplayActivity.KEY_SYNC_IN_PROGRESS, mSyncInProgress); + outState.putBoolean(FileDisplayActivity.KEY_REFRESH_SHARES_IN_PROGRESS, mRefreshSharesInProgress); Log_OC.d(TAG, "onSaveInstanceState() end"); } @@ -910,6 +926,11 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa && mStorageManager != null ) { + /// get the shared files + if (isSharedSupported()) { + startGetShares(); + } + String synchFolderRemotePath = intent.getStringExtra(FileSyncService.SYNC_FOLDER_REMOTE_PATH); OCFile currentFile = (getFile() == null) ? null : mStorageManager.getFileByPath(getFile().getRemotePath()); @@ -939,7 +960,12 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa setFile(currentFile); } - setSupportProgressBarIndeterminateVisibility(inProgress); + if (!mRefreshSharesInProgress) { + setSupportProgressBarIndeterminateVisibility(inProgress); + } else { + setSupportProgressBarIndeterminateVisibility(true); + } + removeStickyBroadcast(intent); mSyncInProgress = inProgress; @@ -1151,19 +1177,6 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa } -// 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} */ @@ -1285,10 +1298,28 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa } else if (operation instanceof CreateFolderOperation) { onCreateFolderOperationFinish((CreateFolderOperation)operation, result); - } + } else if (operation instanceof GetSharesOperation) { + onGetSharesOperationFinish((GetSharesOperation) operation, result); + } } + /** Updates the data about shared files + * + * @param operation Get Shared Files + * @param result Result of the operation + */ + private void onGetSharesOperationFinish(GetSharesOperation operation, RemoteOperationResult result) { + // Refresh the filelist with the information + refeshListOfFilesFragment(); + + mRefreshSharesInProgress = false; + + if (!mSyncInProgress) { + setSupportProgressBarIndeterminateVisibility(false); + } + } + /** * Updates the view associated to the activity after the finish of an operation trying to remove a * file. @@ -1335,7 +1366,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa } else { dismissLoadingDialog(); if (result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME) { - Toast.makeText(FileDisplayActivity.this, R.string.create_dir_fail_msg_invalid_characters, Toast.LENGTH_LONG).show(); + Toast.makeText(FileDisplayActivity.this, R.string.filename_forbidden_characters, Toast.LENGTH_LONG).show(); } else { try { Toast msg = Toast.makeText(FileDisplayActivity.this, R.string.create_dir_fail_msg, Toast.LENGTH_LONG); @@ -1375,6 +1406,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa Toast msg = Toast.makeText(this, R.string.rename_local_fail_msg, Toast.LENGTH_LONG); msg.show(); // TODO throw again the new rename dialog + } if (result.getCode().equals(ResultCode.INVALID_CHARACTER_IN_NAME)) { + Toast msg = Toast.makeText(this, R.string.filename_forbidden_characters, Toast.LENGTH_LONG); + msg.show(); } else { Toast msg = Toast.makeText(this, R.string.rename_server_fail_msg, Toast.LENGTH_LONG); msg.show(); @@ -1439,7 +1473,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa // Create directory path += newDirectoryName + OCFile.PATH_SEPARATOR; - RemoteOperation operation = new CreateFolderOperation(newDirectoryName, path, false, mStorageManager); + RemoteOperation operation = new CreateFolderOperation(path, false, mStorageManager); operation.execute( getAccount(), FileDisplayActivity.this, FileDisplayActivity.this, @@ -1495,6 +1529,16 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa } + private void startGetShares() { + // Get shared files/folders + RemoteOperation getShares = new GetSharesOperation(mStorageManager); + getShares.execute(getAccount(), this, this, mHandler, this); + + mRefreshSharesInProgress = true; + setSupportProgressBarIndeterminateVisibility(true); + + } + // public void enableDisableViewGroup(ViewGroup viewGroup, boolean enabled) { // int childCount = viewGroup.getChildCount(); // for (int i = 0; i < childCount; i++) {