*
*/
+import android.content.Intent;
+
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.lib.network.OwnCloudClient;
-import com.owncloud.android.lib.operations.common.OCShare;
-import com.owncloud.android.lib.operations.common.RemoteOperationResult;
-import com.owncloud.android.lib.operations.common.ShareType;
-import com.owncloud.android.lib.operations.remote.CreateShareRemoteOperation;
-import com.owncloud.android.lib.utils.FileUtils;
+import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.resources.shares.OCShare;
+import com.owncloud.android.lib.common.operations.RemoteOperationResult;
+import com.owncloud.android.lib.resources.shares.ShareType;
+import com.owncloud.android.lib.resources.shares.CreateRemoteShareOperation;
+import com.owncloud.android.lib.resources.files.FileUtils;
import com.owncloud.android.operations.common.SyncOperation;
import com.owncloud.android.utils.Log_OC;
private boolean mPublicUpload;
private String mPassword;
private int mPermissions;
+ private Intent mSendIntent;
/**
* Constructor
* For instance, for \93Re-Share\94, \93delete\94, \93read\94, \93update\94, add 16+8+2+1 = 27.
*/
public CreateShareOperation(String path, ShareType shareType, String shareWith, boolean publicUpload,
- String password, int permissions) {
+ String password, int permissions, Intent sendIntent) {
mPath = path;
mShareType = shareType;
mPublicUpload = publicUpload;
mPassword = password;
mPermissions = permissions;
+ mSendIntent = sendIntent;
}
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
- CreateShareRemoteOperation operation = new CreateShareRemoteOperation(mPath, mShareType, mShareWith, mPublicUpload, mPassword, mPermissions);
+ CreateRemoteShareOperation operation = new CreateRemoteShareOperation(mPath, mShareType, mShareWith, mPublicUpload, mPassword, mPermissions);
RemoteOperationResult result = operation.execute(client);
if (result.isSuccess()) {
OCShare share = (OCShare) result.getData().get(0);
// Update DB with the response
+ share.setPath(mPath);
if (mPath.endsWith(FileUtils.PATH_SEPARATOR)) {
- share.setPath(mPath.substring(0, mPath.length()-1));
- share.setIsDirectory(true);
-
+ share.setIsFolder(true);
} else {
- share.setPath(mPath);
- share.setIsDirectory(false);
+ share.setIsFolder(false);
}
share.setPermissions(mPermissions);
// Update OCFile with data from share: ShareByLink and publicLink
OCFile file = getStorageManager().getFileByPath(mPath);
if (file!=null) {
+ mSendIntent.putExtra(Intent.EXTRA_TEXT, share.getShareLink());
file.setPublicLink(share.getShareLink());
+ file.setShareByLink(true);
getStorageManager().saveFile(file);
Log_OC.d(TAG, "Public Link = " + file.getPublicLink());
return result;
}
+
+
+ public Intent getSendIntent() {
+ return mSendIntent;
+ }
}