Added filtered chooser dialog for activities that can receive a link
[pub/Android/ownCloud.git] / src / com / owncloud / android / datamodel / FileDataStorageManager.java
index 0b35bea..12390c3 100644 (file)
@@ -29,6 +29,7 @@ import com.owncloud.android.MainApp;
 import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
 import com.owncloud.android.lib.operations.common.OCShare;
 import com.owncloud.android.lib.operations.common.ShareType;
+import com.owncloud.android.lib.utils.FileUtils;
 import com.owncloud.android.utils.FileStorageUtils;
 import com.owncloud.android.utils.Log_OC;
 
@@ -1098,4 +1099,36 @@ public class FileDataStorageManager {
         }
         
     } 
+
+
+    public void saveSharesDB(ArrayList<OCShare> shares) {
+
+        if (shares.size() > 0) {
+            // Save share file
+            saveShares(shares);
+
+            ArrayList<OCFile> sharedFiles = new ArrayList<OCFile>();
+
+            for (OCShare share : shares) {
+                // Get the path
+                String path = share.getPath();
+                if (share.isDirectory()) {
+                    path = path + FileUtils.PATH_SEPARATOR;
+                }           
+
+                // Update OCFile with data from share: ShareByLink  ¿and publicLink?
+                OCFile file = getFileByPath(path);
+                if (file != null) {
+                    if (share.getShareType().equals(ShareType.PUBLIC_LINK)) {
+                        file.setShareByLink(true);
+                        sharedFiles.add(file);
+                    }
+                } 
+            }
+            
+            if (sharedFiles.size() > 0) {
+                updateSharedFiles(sharedFiles);
+            }
+        }
+    }
 }