Added filtered chooser dialog for activities that can receive a link
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / activity / FileDisplayActivity.java
index e26843b..237113d 100644 (file)
@@ -73,7 +73,6 @@ import com.owncloud.android.operations.CreateFolderOperation;
 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.operations.common.ShareType;
 import com.owncloud.android.lib.operations.common.RemoteOperationResult.ResultCode;
 import com.owncloud.android.operations.CreateShareOperation;
 import com.owncloud.android.operations.RemoveFileOperation;
@@ -1345,11 +1344,25 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
 
         } else if (operation instanceof CreateFolderOperation) {
             onCreateFolderOperationFinish((CreateFolderOperation)operation, result);
+        
+        } else if (operation instanceof CreateShareOperation) {
+            onCreateShareOperation((CreateShareOperation) operation, result);
         }
         
     }
 
 
+    private void onCreateShareOperation(CreateShareOperation operation, RemoteOperationResult result) {
+        if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
+            // Show a Message
+            Toast t = Toast.makeText(this, getString(R.string.share_link_file_no_exist), Toast.LENGTH_LONG);
+            t.show();
+        }
+        
+        refeshListOfFilesFragment();
+        
+    }
+
     /**
      * Updates the view associated to the activity after the finish of an operation trying to remove a 
      * file. 
@@ -1570,23 +1583,4 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
         
     }
 
-
-    public void shareFileWithLink(OCFile file) {
-        
-        if (isSharedSupported()) {
-            // Create the Share
-            CreateShareOperation createShare = new CreateShareOperation(file.getRemotePath(), ShareType.PUBLIC_LINK, "", false, "", 1);
-            createShare.execute(getStorageManager(), this, this, mHandler, this);
-            
-            // TODO
-            // Get the link --> when the operation is finished
-            
-        } else {
-            // Show a Message
-            Toast t = Toast.makeText(this, getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG);
-            t.show();
-            
-        }
-    }
-    
 }