OC-2732: Create 'unshare' option menu for a shared file/folder
authormasensio <masensio@solidgear.es>
Mon, 3 Feb 2014 10:22:39 +0000 (11:22 +0100)
committermasensio <masensio@solidgear.es>
Mon, 3 Feb 2014 10:22:39 +0000 (11:22 +0100)
res/menu/file_actions_menu.xml
res/values/strings.xml
src/com/owncloud/android/ui/fragment/FileDetailFragment.java
src/com/owncloud/android/ui/fragment/OCFileListFragment.java
src/com/owncloud/android/ui/preview/PreviewImageFragment.java
src/com/owncloud/android/ui/preview/PreviewMediaFragment.java

index dcd451c..1e78a36 100644 (file)
@@ -20,7 +20,8 @@
 <menu  xmlns:android="http://schemas.android.com/apk/res/android">
     
        <item   android:id="@+id/action_share_file"                             android:title="@string/action_share_file"                       android:icon="@android:drawable/ic_menu_share"                                  android:orderInCategory="1" />
-    <item      android:id="@+id/action_open_file_with"                 android:title="@string/actionbar_open_with"                     android:icon="@android:drawable/ic_menu_edit"                                   android:orderInCategory="1" />
+       <item   android:id="@+id/action_unshare_file"               android:title="@string/action_unshare_file"                 android:icon="@android:drawable/ic_menu_share"                                  android:orderInCategory="1" />
+    <item      android:id="@+id/action_open_file_with"                 android:title="@string/actionbar_open_with"                     android:icon="@android:drawable/ic_menu_edit"                                   android:orderInCategory="1" /> 
        <item   android:id="@+id/action_download_file"                  android:title="@string/filedetails_download"            android:icon="@drawable/ic_action_download"                                             android:orderInCategory="1" />
     <item      android:id="@+id/action_sync_file"                              android:title="@string/filedetails_sync_file"           android:icon="@drawable/ic_action_refresh"                                              android:orderInCategory="1" />
        <item   android:id="@+id/action_cancel_download"                android:title="@string/common_cancel_download"          android:icon="@android:drawable/ic_menu_close_clear_cancel"             android:orderInCategory="1" />
index 7ae67dc..854a53b 100644 (file)
@@ -60,6 +60,7 @@
     <string name="filedetails_sync_file">Refresh file</string>
     <string name="filedetails_renamed_in_upload_msg">File was renamed to %1$s during upload</string>
     <string name="action_share_file">Share link</string>
+    <string name="action_unshare_file">Unshare link</string>
     <string name="common_yes">Yes</string>
     <string name="common_no">No</string>
     <string name="common_ok">OK</string>
index 4989526..1456272 100644 (file)
@@ -310,6 +310,10 @@ public class FileDetailFragment extends FileFragment implements
             toHide.add(R.id.action_remove_file);
             
         }
+        // Options shareLink
+        if (!file.isShareByLink()) {
+            toHide.add(R.id.action_unshare_file);
+        }
 
         MenuItem item = null;
         for (int i : toHide) {
index 91abe7d..5cd4a15 100644 (file)
@@ -21,6 +21,7 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 
+import com.actionbarsherlock.view.Menu;
 import com.owncloud.android.R;
 import com.owncloud.android.authentication.AccountUtils;
 import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -352,6 +353,25 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName
     
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onPrepareOptionsMenu(Menu menu) {
+        super.onPrepareOptionsMenu(menu);
+        
+        List<Integer> toHide = new ArrayList<Integer>();
+        MenuItem item = null;
+        for (int i : toHide) {
+            item = (MenuItem) menu.findItem(i);
+            if (item != null) {
+                item.setVisible(false);
+                item.setEnabled(false);
+            }
+        }
+    }
+
+
+    /**
      * Use this to query the {@link OCFile} that is currently
      * being displayed by this fragment
      * @return The currently viewed OCFile
index 8555fa7..e7c497e 100644 (file)
@@ -266,6 +266,25 @@ public class PreviewImageFragment extends FileFragment implements   OnRemoteOper
     }
 
     
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onPrepareOptionsMenu(Menu menu) {
+        super.onPrepareOptionsMenu(menu);
+        
+        List<Integer> toHide = new ArrayList<Integer>();
+        MenuItem item = null;
+        for (int i : toHide) {
+            item = (MenuItem) menu.findItem(i);
+            if (item != null) {
+                item.setVisible(false);
+                item.setEnabled(false);
+            }
+        }
+    }
+
+
     private void seeDetails() {
         ((FileFragment.ContainerActivity)getActivity()).showDetails(getFile());        
     }
index 464ea6d..1de8bb1 100644 (file)
@@ -324,6 +324,24 @@ public class PreviewMediaFragment extends FileFragment implements
                 return false;
         }
     }
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onPrepareOptionsMenu(Menu menu) {
+        super.onPrepareOptionsMenu(menu);
+        
+        List<Integer> toHide = new ArrayList<Integer>();
+        MenuItem item = null;
+        for (int i : toHide) {
+            item = (MenuItem) menu.findItem(i);
+            if (item != null) {
+                item.setVisible(false);
+                item.setEnabled(false);
+            }
+        }
+    }
 
     
     private void seeDetails() {