X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/9e0f02131f17a2494d84886570617fd0dddb3530..c9626772a19c0f5631ae5b58c09dda39d0baa878:/src/com/owncloud/android/ui/preview/PreviewImageFragment.java diff --git a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java index b323e5f1..70ffa792 100644 --- a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -58,7 +58,7 @@ 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; @@ -79,7 +79,6 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper private View mView; private Account mAccount; - private FileDataStorageManager mStorageManager; private ImageView mImageView; private TextView mMessageView; private ProgressBar mProgressWheel; @@ -106,7 +105,6 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper 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; } @@ -121,7 +119,6 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper public PreviewImageFragment() { super(); mAccount = null; - mStorageManager = null; mIgnoreFirstSavedState = false; } @@ -173,7 +170,6 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper @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); @@ -181,8 +177,8 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper // Update the file if (mAccount!= null) { - mStorageManager = new FileDataStorageManager(mAccount, getActivity().getApplicationContext().getContentResolver()); - OCFile updatedFile = mStorageManager.getFileByPath(file.getRemotePath()); + OCFile updatedFile = ((FileActivity)getSherlockActivity()). + getStorageManager().getFileByPath(file.getRemotePath()); if (updatedFile != null) { setFile(updatedFile); } else { @@ -250,6 +246,12 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper 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) { @@ -310,12 +312,16 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper 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() { @@ -423,13 +429,15 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper */ @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(); } } @@ -440,7 +448,7 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper @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(); } @@ -647,7 +655,7 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper } 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);