+
+
+ @Override
+ public void onDismiss(EditNameDialog dialog) {
+ if (dialog.getResult()) {
+ String newFilename = dialog.getNewFilename();
+ Log.d(TAG, "name edit dialog dismissed with new name " + newFilename);
+ RemoteOperation operation = new RenameFileOperation(mTargetFile,
+ newFilename,
+ mContainerActivity.getStorageManager());
+ WebdavClient wc = OwnCloudClientUtils.createOwnCloudClient(AccountUtils.getCurrentOwnCloudAccount(getSherlockActivity()), getSherlockActivity().getApplicationContext());
+ operation.execute(wc, this, mHandler);
+ getActivity().showDialog(FileDisplayActivity.DIALOG_SHORT_WAIT);
+ }
+ }
+
+
+ @Override
+ public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
+ if (operation instanceof RemoveFileOperation) {
+ onRemoveFileOperationFinish((RemoveFileOperation)operation, result);
+
+ } else if (operation instanceof RenameFileOperation) {
+ onRenameFileOperationFinish((RenameFileOperation)operation, result);
+ }
+ }
+
+
+ private void onRemoveFileOperationFinish(RemoveFileOperation operation, RemoteOperationResult result) {
+ getActivity().dismissDialog(FileDisplayActivity.DIALOG_SHORT_WAIT);
+ if (result.isSuccess()) {
+ Toast msg = Toast.makeText(getActivity().getApplicationContext(), R.string.remove_success_msg, Toast.LENGTH_LONG);
+ msg.show();
+ if (mIsLargeLayout) {
+ // TODO - this should be done only when the current FileDetailFragment shows the deleted file
+ // -> THIS METHOD WOULD BE BETTER PLACED AT THE ACTIVITY LEVEL
+ FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
+ transaction.replace(R.id.file_details_container, new FileDetailFragment(null, null)); // empty FileDetailFragment
+ transaction.commit();
+ }
+ listDirectory();
+
+ } else {
+ Toast msg = Toast.makeText(getActivity(), R.string.remove_fail_msg, Toast.LENGTH_LONG);
+ msg.show();
+ if (result.isSslRecoverableException()) {
+ // TODO show the SSL warning dialog
+ }
+ }
+ }
+
+
+ private void onRenameFileOperationFinish(RenameFileOperation operation, RemoteOperationResult result) {
+ getActivity().dismissDialog(FileDisplayActivity.DIALOG_SHORT_WAIT);
+ if (result.isSuccess()) {
+ listDirectory();
+ // TODO is file
+
+ } else {
+ if (result.getCode().equals(ResultCode.INVALID_LOCAL_FILE_NAME)) {
+ Toast msg = Toast.makeText(getActivity(), R.string.rename_local_fail_msg, Toast.LENGTH_LONG);
+ msg.show();
+ // TODO throw again the new rename dialog
+ } else {
+ Toast msg = Toast.makeText(getActivity(), R.string.rename_server_fail_msg, Toast.LENGTH_LONG);
+ msg.show();
+ if (result.isSslRecoverableException()) {
+ // TODO show the SSL warning dialog
+ }
+ }
+ }
+ }
+
+
+ @Override
+ public void onConfirmation(String callerTag) {
+ if (callerTag.equals(FileDetailFragment.FTAG_CONFIRMATION)) {
+ if (mContainerActivity.getStorageManager().getFileById(mTargetFile.getFileId()) != null) {
+ RemoteOperation operation = new RemoveFileOperation( mTargetFile,
+ true,
+ mContainerActivity.getStorageManager());
+ WebdavClient wc = OwnCloudClientUtils.createOwnCloudClient(AccountUtils.getCurrentOwnCloudAccount(getSherlockActivity()), getSherlockActivity().getApplicationContext());
+ operation.execute(wc, this, mHandler);
+
+ getActivity().showDialog(FileDisplayActivity.DIALOG_SHORT_WAIT);
+ }
+ }
+ }
+
+ @Override
+ public void onNeutral(String callerTag) {
+ File f = null;
+ if (mTargetFile.isDown() && (f = new File(mTargetFile.getStoragePath())).exists()) {
+ f.delete();
+ mTargetFile.setStoragePath(null);
+ mContainerActivity.getStorageManager().saveFile(mFile);
+ }
+ listDirectory();
+ }
+
+ @Override
+ public void onCancel(String callerTag) {
+ Log.d(TAG, "REMOVAL CANCELED");
+ }
+
+