OC-3079: (fix bug) Two send options appear after send and mail with a ownCloud file
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / fragment / FileDetailFragment.java
index af29cff..a567c43 100644 (file)
@@ -252,6 +252,17 @@ public class FileDetailFragment extends FileFragment implements
             item.setVisible(false);
             item.setEnabled(false);
         }
             item.setVisible(false);
             item.setEnabled(false);
         }
+        
+        // Send file
+        item = menu.findItem(R.id.action_send_file);
+        boolean sendEnabled = getString(R.string.send_files_to_other_apps).equalsIgnoreCase("on");
+        if (item != null  && sendEnabled) {
+            item.setVisible(true);
+            item.setEnabled(true);
+        } else {
+            item.setVisible(false);
+            item.setEnabled(false);
+        }
     }
 
     
     }
 
     
@@ -376,6 +387,18 @@ public class FileDetailFragment extends FileFragment implements
                 synchronizeFile();
                 return true;
             }
                 synchronizeFile();
                 return true;
             }
+            case R.id.action_send_file: {
+                FileDisplayActivity activity = (FileDisplayActivity) getSherlockActivity();
+                // Obtain the file
+                if (!getFile().isDown()) {  // Download the file                    
+                    Log_OC.d(TAG, getFile().getRemotePath() + " : File must be downloaded");
+                    activity.startDownloadForSending(getFile());
+                    
+                } else {
+                    activity.getFileOperationsHelper().sendDownloadedFile(getFile(), activity);
+                }
+                return true;
+            }
             default:
                 return false;
         }
             default:
                 return false;
         }