<string name="failed_upload_retry_do_nothing_text">do nothing you are not online for instant upload</string>
<string name="failed_upload_failure_text">Failure Message: </string>
<string name="failed_upload_quota_exceeded_text">Please check your server configuration,maybe your quota is exceeded.</string>
+
+ <string name="share_link_no_support_share_api">Sorry, sharing is not enabled on your server. Please contact your administrator.</string>
+ <string name="share_link_file_no_exist">Unable to share this file or folder. Please, make sure it exists</string>
</resources>
}
}
+
+ public void removeShare(OCShare share){
+ Uri share_uri = ProviderTableMeta.CONTENT_URI_SHARE;
+ String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?" + " AND " + ProviderTableMeta.FILE_PATH + "=?";
+ String [] whereArgs = new String[]{mAccount.name, share.getPath()};
+ if (getContentProviderClient() != null) {
+ try {
+ getContentProviderClient().delete(share_uri, where, whereArgs);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ } else {
+ getContentResolver().delete(share_uri, where, whereArgs);
+ }
+ }
}
package com.owncloud.android.operations;
-import java.util.ArrayList;
-
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.RemoteOperationResult.ResultCode;
-import com.owncloud.android.lib.operations.remote.GetRemoteSharesOperation;
+import com.owncloud.android.lib.operations.remote.UnshareLinkRemoteOperation;
import com.owncloud.android.operations.common.SyncOperation;
import com.owncloud.android.utils.Log_OC;
OCShare share = getStorageManager().getShareByPath(mFile.getRemotePath());
if (share != null) {
- GetRemoteSharesOperation operation = new GetRemoteSharesOperation();
+ UnshareLinkRemoteOperation operation = new UnshareLinkRemoteOperation((int) share.getIdRemoteShared());
result = operation.execute(client);
if (result.isSuccess()) {
Log_OC.d(TAG, "Share id = " + share.getIdRemoteShared() + " deleted");
- // TODO Update DB
+ mFile.setShareByLink(false);
+ mFile.setPublicLink("");
+ getStorageManager().saveFile(mFile);
+ getStorageManager().removeShare(share);
}
} else {
import com.owncloud.android.operations.RenameFileOperation;
import com.owncloud.android.operations.SynchronizeFileOperation;
import com.owncloud.android.operations.SynchronizeFolderOperation;
+import com.owncloud.android.operations.UnshareLinkOperation;
import com.owncloud.android.services.OperationsService;
import com.owncloud.android.syncadapter.FileSyncAdapter;
import com.owncloud.android.ui.dialog.EditNameDialog;
} else if (operation instanceof CreateFolderOperation) {
onCreateFolderOperationFinish((CreateFolderOperation)operation, result);
+
+ } else if (operation instanceof UnshareLinkOperation) {
+ onUnshareLinkOperationFinish((UnshareLinkOperation)operation, result);
}
}
+ private void onUnshareLinkOperationFinish(UnshareLinkOperation 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.
mRefreshSharesInProgress = true;
}
+
+ public void unshareFileWithLink(OCFile file) {
+
+ if (isSharedSupported()) {
+ // Unshare the file
+ UnshareLinkOperation unshare = new UnshareLinkOperation(file);
+ unshare.execute(getStorageManager(), this, this, mHandler, this);
+
+ } else {
+ // Show a Message
+ Toast t = Toast.makeText(this, getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG);
+ t.show();
+
+ }
+ }
+
}
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
mTargetFile = (OCFile) mAdapter.getItem(info.position);
switch (item.getItemId()) {
+ case R.id.action_unshare_file: {
+ mContainerActivity.unshareFileWithLink(mTargetFile);
+ return true;
+ }
case R.id.action_rename_file: {
String fileName = mTargetFile.getFileName();
int extensionStart = mTargetFile.isFolder() ? -1 : fileName.lastIndexOf(".");
*/
public void onBrowsedDownTo(OCFile folder);
+ public void unshareFileWithLink(OCFile mTargetFile);
+
public void startDownloadForPreview(OCFile file);
public void startMediaPreview(OCFile file, int i, boolean b);