From de29fd38ce3bdd53ec5f3d798ed16bd8e078ae09 Mon Sep 17 00:00:00 2001 From: masensio Date: Wed, 5 Feb 2014 17:32:29 +0100 Subject: [PATCH] OC-2833: Access to unshare link from PreviewImageFragment --- owncloud-android-library | 2 +- .../ui/preview/PreviewImageFragment.java | 29 ++++++++++++++----- .../ui/preview/PreviewMediaFragment.java | 24 ++++++++++----- 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/owncloud-android-library b/owncloud-android-library index 984cbbc124..f166bcdd8b 160000 --- a/owncloud-android-library +++ b/owncloud-android-library @@ -1 +1 @@ -Subproject commit 984cbbc124441f6dd9d5c53f5e7989be1593176f +Subproject commit f166bcdd8b52a64c3ad0c8725ed64ba768c1eeb5 diff --git a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java index 69fc1f8567..d8622f24de 100644 --- a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -246,6 +246,22 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper } + /** + * {@inheritDoc} + */ + @Override + public void onPrepareOptionsMenu(Menu menu) { + super.onPrepareOptionsMenu(menu); + + // Options shareLink + if (!getFile().isShareByLink()) { + MenuItem item = menu.findItem(R.id.action_unshare_file); + item.setVisible(false); + item.setEnabled(false); + } + } + + /** * {@inheritDoc} @@ -258,6 +274,11 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper act.getFileOperationsHelper().shareFileWithLink(getFile(), act); return true; } + case R.id.action_unshare_file: { + FileActivity act = (FileActivity)getSherlockActivity(); + act.getFileOperationsHelper().unshareFileWithLink(getFile(), act); + return true; + } case R.id.action_open_file_with: { openFile(); return true; @@ -277,14 +298,6 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper } - /** - * {@inheritDoc} - */ - @Override - public void onPrepareOptionsMenu(Menu menu) { - super.onPrepareOptionsMenu(menu); - } - private void seeDetails() { ((FileFragment.ContainerActivity)getActivity()).showDetails(getFile()); diff --git a/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java b/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java index 60ce314cb2..f83e1ab090 100644 --- a/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java @@ -305,6 +305,22 @@ public class PreviewMediaFragment extends FileFragment implements } + + /** + * {@inheritDoc} + */ + @Override + public void onPrepareOptionsMenu(Menu menu) { + super.onPrepareOptionsMenu(menu); + + // Options shareLink + if (!getFile().isShareByLink()) { + MenuItem item = menu.findItem(R.id.action_unshare_file); + item.setVisible(false); + item.setEnabled(false); + } + } + /** * {@inheritDoc} @@ -340,14 +356,6 @@ public class PreviewMediaFragment extends FileFragment implements - /** - * {@inheritDoc} - */ - @Override - public void onPrepareOptionsMenu(Menu menu) { - super.onPrepareOptionsMenu(menu); - } - private void unshareFileWithLink() { stopPreview(false); FileActivity activity = (FileActivity)((FileFragment.ContainerActivity)getActivity());