X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/15309cac8b8fa0bca450ef0cde2e00f922fcb8dd..10f99ceb9ca7a65b2d59f30a7ddfbfa7ffc60a7a:/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 bb4f165e..3a374e08 100644 --- a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -52,10 +52,10 @@ import com.actionbarsherlock.view.MenuItem; 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; @@ -176,8 +176,22 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper mStorageManager = new FileDataStorageManager(mAccount, getActivity().getApplicationContext().getContentResolver()); if (savedInstanceState != null) { if (!mIgnoreFirstSavedState) { - setFile((OCFile)savedInstanceState.getParcelable(PreviewImageFragment.EXTRA_FILE)); + OCFile file = (OCFile)savedInstanceState.getParcelable(PreviewImageFragment.EXTRA_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); + } + } else { mIgnoreFirstSavedState = false; } @@ -236,6 +250,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) { @@ -255,7 +275,8 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper 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 { @@ -295,12 +316,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() {