/* ownCloud Android client application
- * Copyright (C) 2012-2013 ownCloud Inc.
+ * Copyright (C) 2012-2014 ownCloud Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.lib.network.webdav.WebdavUtils;
-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.common.network.WebdavUtils;
+import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
+import com.owncloud.android.lib.common.operations.RemoteOperation;
+import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.operations.RemoveFileOperation;
import com.owncloud.android.ui.activity.FileActivity;
-import com.owncloud.android.ui.fragment.ConfirmationDialogFragment;
+import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
import com.owncloud.android.ui.fragment.FileFragment;
import com.owncloud.android.utils.Log_OC;
private View mView;
private Account mAccount;
- private FileDataStorageManager mStorageManager;
private ImageView mImageView;
private TextView mMessageView;
private ProgressBar mProgressWheel;
public PreviewImageFragment(OCFile fileToDetail, Account ocAccount, boolean ignoreFirstSavedState) {
super(fileToDetail);
mAccount = ocAccount;
- mStorageManager = null; // we need a context to init this; the container activity is not available yet at this moment
mIgnoreFirstSavedState = ignoreFirstSavedState;
}
public PreviewImageFragment() {
super();
mAccount = null;
- mStorageManager = null;
mIgnoreFirstSavedState = false;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- mStorageManager = new FileDataStorageManager(mAccount, getActivity().getApplicationContext().getContentResolver());
if (savedInstanceState != null) {
if (!mIgnoreFirstSavedState) {
OCFile file = (OCFile)savedInstanceState.getParcelable(PreviewImageFragment.EXTRA_FILE);
+ setFile(file);
mAccount = savedInstanceState.getParcelable(PreviewImageFragment.EXTRA_ACCOUNT);
-
- // Update the file
- if (mAccount!= null) {
- mStorageManager = new FileDataStorageManager(mAccount, getActivity().getApplicationContext().getContentResolver());
- OCFile updatedFile = mStorageManager.getFileByPath(file.getRemotePath());
- if (updatedFile != null) {
- setFile(updatedFile);
- } else {
- setFile(file);
- }
- } else {
- setFile(file);
- }
+// TODO remove this code: update file no needed
+// // Update the file
+//// if (mAccount!= null) {
+// OCFile updatedFile = ((FileActivity)getSherlockActivity()).
+// getStorageManager().getFileByPath(file.getRemotePath());
+// if (updatedFile != null) {
+// setFile(updatedFile);
+// } else {
+// setFile(file);
+// }
+// } else {
+// setFile(file);
+// }
} else {
mIgnoreFirstSavedState = false;
toHide.add(R.id.action_unshare_file);
}
+ // Send file
+ boolean sendEnabled = getString(R.string.send_files_to_other_apps).equalsIgnoreCase("on");
+ if (!sendEnabled) {
+ toHide.add(R.id.action_send_file);
+ }
+
for (int i : toHide) {
item = menu.findItem(i);
if (item != null) {
MenuItem item = menu.findItem(R.id.action_unshare_file);
// Options shareLink
- if (!getFile().isShareByLink()) {
+ OCFile file = ((FileActivity) getSherlockActivity()).getFile();
+ if (!file.isShareByLink()) {
item.setVisible(false);
item.setEnabled(false);
} else {
seeDetails();
return true;
}
+ case R.id.action_send_file: {
+ FileActivity act = (FileActivity)getSherlockActivity();
+ act.getFileOperationsHelper().sendDownloadedFile(getFile(), act);
+ return true;
+ }
default:
return false;
}
}
-
private void seeDetails() {
*/
@Override
public void onConfirmation(String callerTag) {
- if (mStorageManager.getFileById(getFile().getFileId()) != null) { // check that the file is still there;
+ FileDataStorageManager storageManager =
+ ((FileActivity)getSherlockActivity()).getStorageManager();
+ if (storageManager.getFileById(getFile().getFileId()) != null) { // check that the file is still there;
mLastRemoteOperation = new RemoveFileOperation( getFile(), // TODO we need to review the interface with RemoteOperations, and use OCFile IDs instead of OCFile objects as parameters
true,
- mStorageManager);
+ storageManager);
mLastRemoteOperation.execute(mAccount, getSherlockActivity(), this, mHandler, getSherlockActivity());
- ((PreviewImageActivity) getActivity()).showLoadingDialog();
+ ((FileActivity) getActivity()).showLoadingDialog();
}
}
@Override
public void onNeutral(String callerTag) {
OCFile file = getFile();
- mStorageManager.removeFile(file, false, true); // TODO perform in background task / new thread
+ ((FileActivity)getSherlockActivity()).getStorageManager().removeFile(file, false, true); // TODO perform in background task / new thread
finish();
}
}
private void onRemoveFileOperationFinish(RemoveFileOperation operation, RemoteOperationResult result) {
- ((PreviewImageActivity) getActivity()).dismissLoadingDialog();
+ ((FileActivity) getActivity()).dismissLoadingDialog();
if (result.isSuccess()) {
Toast msg = Toast.makeText(getActivity().getApplicationContext(), R.string.remove_success_msg, Toast.LENGTH_LONG);