mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 13:15:35 +03:00
Merge pull request #6396 from nextcloud/editLabel
Edit label for public share
This commit is contained in:
commit
2192bdcf39
18 changed files with 355 additions and 241 deletions
|
@ -1 +1 @@
|
|||
335
|
||||
334
|
||||
|
|
|
@ -1047,25 +1047,7 @@ public class FileDataStorageManager {
|
|||
public boolean saveShare(OCShare share) {
|
||||
boolean overridden = false;
|
||||
|
||||
Uri contentUriShare = ProviderTableMeta.CONTENT_URI_SHARE;
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_FILE_SOURCE, share.getFileSource());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_ITEM_SOURCE, share.getItemSource());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_TYPE, share.getShareType().getValue());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_WITH, share.getShareWith());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_PATH, share.getPath());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_PERMISSIONS, share.getPermissions());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARED_DATE, share.getSharedDate());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_EXPIRATION_DATE, share.getExpirationDate());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_TOKEN, share.getToken());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME, share.getSharedWithDisplayName());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, account.name);
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());
|
||||
ContentValues contentValues = createContentValueForShare(share);
|
||||
|
||||
if (shareExistsForRemoteId(share.getRemoteId())) {// for renamed files; no more delete and create
|
||||
overridden = true;
|
||||
|
@ -1260,6 +1242,31 @@ public class FileDataStorageManager {
|
|||
return shares;
|
||||
}
|
||||
|
||||
private ContentValues createContentValueForShare(OCShare share) {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_FILE_SOURCE, share.getFileSource());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_ITEM_SOURCE, share.getItemSource());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_TYPE, share.getShareType().getValue());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_WITH, share.getShareWith());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_PATH, share.getPath());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_PERMISSIONS, share.getPermissions());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARED_DATE, share.getSharedDate());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_EXPIRATION_DATE, share.getExpirationDate());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_TOKEN, share.getToken());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME, share.getSharedWithDisplayName());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, account.name);
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_LINK, share.getShareLink());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_LABEL, share.getLabel());
|
||||
|
||||
return contentValues;
|
||||
}
|
||||
|
||||
// test with null cursor?
|
||||
private OCShare createShareInstance(Cursor cursor) {
|
||||
OCShare share = new OCShare(getString(cursor, ProviderTableMeta.OCSHARES_PATH));
|
||||
|
@ -1279,6 +1286,7 @@ public class FileDataStorageManager {
|
|||
share.setNote(getString(cursor, ProviderTableMeta.OCSHARES_NOTE));
|
||||
share.setHideFileDownload(getInt(cursor, ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD) == 1);
|
||||
share.setShareLink(getString(cursor, ProviderTableMeta.OCSHARES_SHARE_LINK));
|
||||
share.setLabel(getString(cursor, ProviderTableMeta.OCSHARES_SHARE_LABEL));
|
||||
|
||||
return share;
|
||||
}
|
||||
|
@ -1366,24 +1374,7 @@ public class FileDataStorageManager {
|
|||
|
||||
// prepare operations to insert or update files to save in the given folder
|
||||
for (OCShare share : shares) {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_FILE_SOURCE, share.getFileSource());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_ITEM_SOURCE, share.getItemSource());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_TYPE, share.getShareType().getValue());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_WITH, share.getShareWith());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_PATH, share.getPath());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_PERMISSIONS, share.getPermissions());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARED_DATE, share.getSharedDate());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_EXPIRATION_DATE, share.getExpirationDate());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_TOKEN, share.getToken());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME, share.getSharedWithDisplayName());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, account.name);
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());
|
||||
ContentValues contentValues = createContentValueForShare(share);
|
||||
|
||||
if (shareExistsForRemoteId(share.getRemoteId())) {
|
||||
// updating an existing file
|
||||
|
@ -1613,25 +1604,7 @@ public class FileDataStorageManager {
|
|||
ContentValues contentValues;
|
||||
// prepare operations to insert or update files to save in the given folder
|
||||
for (OCShare share : shares) {
|
||||
contentValues = new ContentValues();
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_FILE_SOURCE, share.getFileSource());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_ITEM_SOURCE, share.getItemSource());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_TYPE, share.getShareType().getValue());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_WITH, share.getShareWith());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_PATH, share.getPath());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_PERMISSIONS, share.getPermissions());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARED_DATE, share.getSharedDate());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_EXPIRATION_DATE, share.getExpirationDate());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_TOKEN, share.getToken());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME, share.getSharedWithDisplayName());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, account.name);
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());
|
||||
contentValues.put(ProviderTableMeta.OCSHARES_SHARE_LINK, share.getShareLink());
|
||||
contentValues = createContentValueForShare(share);
|
||||
|
||||
// adding a new share resource
|
||||
operations.add(ContentProviderOperation
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.owncloud.android.MainApp;
|
|||
*/
|
||||
public class ProviderMeta {
|
||||
public static final String DB_NAME = "filelist";
|
||||
public static final int DB_VERSION = 58;
|
||||
public static final int DB_VERSION = 59;
|
||||
|
||||
private ProviderMeta() {
|
||||
// No instance
|
||||
|
@ -146,6 +146,7 @@ public class ProviderMeta {
|
|||
public static final String OCSHARES_NOTE = "note";
|
||||
public static final String OCSHARES_HIDE_DOWNLOAD = "hide_download";
|
||||
public static final String OCSHARES_SHARE_LINK = "share_link";
|
||||
public static final String OCSHARES_SHARE_LABEL = "share_label";
|
||||
|
||||
public static final String OCSHARES_DEFAULT_SORT_ORDER = OCSHARES_FILE_SOURCE
|
||||
+ " collate nocase asc";
|
||||
|
|
|
@ -20,11 +20,9 @@
|
|||
|
||||
package com.owncloud.android.operations;
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.files.FileUtils;
|
||||
import com.owncloud.android.lib.resources.shares.GetShareRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation;
|
||||
|
@ -35,23 +33,17 @@ import com.owncloud.android.operations.common.SyncOperation;
|
|||
* Updates an existing public share for a given file
|
||||
*/
|
||||
public class UpdateShareViaLinkOperation extends SyncOperation {
|
||||
|
||||
private String path;
|
||||
private String password;
|
||||
/** Enable upload permissions to update in Share resource. */
|
||||
private Boolean publicUploadOnFolder;
|
||||
private Boolean publicUploadOnFile;
|
||||
/**
|
||||
* Enable upload permissions to update in Share resource.
|
||||
*/
|
||||
private boolean publicUpload;
|
||||
private Boolean hideFileDownload;
|
||||
private long expirationDateInMillis;
|
||||
private long shareId;
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param path Full path of the file/folder being shared. Mandatory argument
|
||||
*/
|
||||
public UpdateShareViaLinkOperation(String path, long shareId) {
|
||||
this.path = path;
|
||||
public UpdateShareViaLinkOperation(long shareId) {
|
||||
expirationDateInMillis = 0;
|
||||
this.shareId = shareId;
|
||||
}
|
||||
|
@ -63,9 +55,15 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
|||
UpdateShareRemoteOperation updateOp = new UpdateShareRemoteOperation(publicShare.getRemoteId());
|
||||
updateOp.setPassword(password);
|
||||
updateOp.setExpirationDate(expirationDateInMillis);
|
||||
updateOp.setPublicUploadOnFolder(publicUploadOnFolder);
|
||||
updateOp.setPublicUploadOnFile(publicUploadOnFile);
|
||||
updateOp.setHideFileDownload(hideFileDownload);
|
||||
updateOp.setLabel(label);
|
||||
|
||||
if (publicShare.isFolder()) {
|
||||
updateOp.setPublicUploadOnFolder(publicUpload);
|
||||
} else {
|
||||
updateOp.setPublicUploadOnFile(publicUpload);
|
||||
}
|
||||
|
||||
RemoteOperationResult result = updateOp.execute(client);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
|
@ -74,38 +72,13 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
|||
result = getShareOp.execute(client);
|
||||
if (result.isSuccess()) {
|
||||
OCShare share = (OCShare) result.getData().get(0);
|
||||
updateData(share);
|
||||
getStorageManager().saveShare(share);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void updateData(OCShare share) {
|
||||
// Update DB with the response
|
||||
share.setPath(path);
|
||||
if (path.endsWith(FileUtils.PATH_SEPARATOR)) {
|
||||
share.setFolder(true);
|
||||
} else {
|
||||
share.setFolder(false);
|
||||
}
|
||||
|
||||
getStorageManager().saveShare(share); // TODO info about having a password? ask to Gonzalo
|
||||
|
||||
// Update OCFile with data from share: ShareByLink and publicLink
|
||||
// TODO check & remove if not needed
|
||||
OCFile file = getStorageManager().getFileByPath(path);
|
||||
if (file != null) {
|
||||
file.setPublicLink(share.getShareLink());
|
||||
file.setSharedViaLink(true);
|
||||
getStorageManager().saveFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
@ -114,12 +87,8 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
|||
this.password = password;
|
||||
}
|
||||
|
||||
public void setPublicUploadOnFolder(Boolean publicUploadOnFolder) {
|
||||
this.publicUploadOnFolder = publicUploadOnFolder;
|
||||
}
|
||||
|
||||
public void setPublicUploadOnFile(Boolean publicUploadOnFile) {
|
||||
this.publicUploadOnFile = publicUploadOnFile;
|
||||
public void setPublicUpload(boolean publicUpload) {
|
||||
this.publicUpload = publicUpload;
|
||||
}
|
||||
|
||||
public void setHideFileDownload(Boolean hideFileDownload) {
|
||||
|
@ -129,4 +98,8 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
|||
public void setExpirationDateInMillis(long expirationDateInMillis) {
|
||||
this.expirationDateInMillis = expirationDateInMillis;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -748,7 +748,8 @@ public class FileContentProvider extends ContentProvider {
|
|||
+ ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED + INTEGER
|
||||
+ ProviderTableMeta.OCSHARES_NOTE + TEXT
|
||||
+ ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD + INTEGER
|
||||
+ ProviderTableMeta.OCSHARES_SHARE_LINK + " TEXT );");
|
||||
+ ProviderTableMeta.OCSHARES_SHARE_LINK + TEXT
|
||||
+ ProviderTableMeta.OCSHARES_SHARE_LABEL + " TEXT );");
|
||||
}
|
||||
|
||||
private void createCapabilitiesTable(SQLiteDatabase db) {
|
||||
|
@ -2253,6 +2254,24 @@ public class FileContentProvider extends ContentProvider {
|
|||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
|
||||
if (oldVersion < 59 && newVersion >= 59) {
|
||||
Log_OC.i(SQL, "Entering in the #59 add public label to share table");
|
||||
db.beginTransaction();
|
||||
try {
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.OCSHARES_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.OCSHARES_SHARE_LABEL + " TEXT ");
|
||||
|
||||
upgraded = true;
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,6 +103,7 @@ public class OperationsService extends Service {
|
|||
public static final String EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS = "SHARE_EXPIRATION_YEAR";
|
||||
public static final String EXTRA_SHARE_PERMISSIONS = "SHARE_PERMISSIONS";
|
||||
public static final String EXTRA_SHARE_PUBLIC_UPLOAD = "SHARE_PUBLIC_UPLOAD";
|
||||
public static final String EXTRA_SHARE_PUBLIC_LABEL = "SHARE_PUBLIC_LABEL";
|
||||
public static final String EXTRA_SHARE_HIDE_FILE_DOWNLOAD = "HIDE_FILE_DOWNLOAD";
|
||||
public static final String EXTRA_SHARE_ID = "SHARE_ID";
|
||||
public static final String EXTRA_SHARE_NOTE = "SHARE_NOTE";
|
||||
|
@ -111,7 +112,8 @@ public class OperationsService extends Service {
|
|||
public static final String ACTION_CREATE_SHARE_VIA_LINK = "CREATE_SHARE_VIA_LINK";
|
||||
public static final String ACTION_CREATE_SHARE_WITH_SHAREE = "CREATE_SHARE_WITH_SHAREE";
|
||||
public static final String ACTION_UNSHARE = "UNSHARE";
|
||||
public static final String ACTION_UPDATE_SHARE = "UPDATE_SHARE";
|
||||
public static final String ACTION_UPDATE_PUBLIC_SHARE = "UPDATE_PUBLIC_SHARE";
|
||||
public static final String ACTION_UPDATE_USER_SHARE = "UPDATE_USER_SHARE";
|
||||
public static final String ACTION_UPDATE_SHARE_NOTE = "UPDATE_SHARE_NOTE";
|
||||
public static final String ACTION_GET_SERVER_INFO = "GET_SERVER_INFO";
|
||||
public static final String ACTION_GET_USER_NAME = "GET_USER_NAME";
|
||||
|
@ -533,13 +535,11 @@ public class OperationsService extends Service {
|
|||
}
|
||||
break;
|
||||
|
||||
case ACTION_UPDATE_SHARE:
|
||||
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
case ACTION_UPDATE_PUBLIC_SHARE:
|
||||
shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1);
|
||||
|
||||
if (!TextUtils.isEmpty(remotePath)) {
|
||||
UpdateShareViaLinkOperation updateLinkOperation =
|
||||
new UpdateShareViaLinkOperation(remotePath, shareId);
|
||||
if (shareId > 0) {
|
||||
UpdateShareViaLinkOperation updateLinkOperation = new UpdateShareViaLinkOperation(shareId);
|
||||
|
||||
password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD);
|
||||
updateLinkOperation.setPassword(password);
|
||||
|
@ -552,23 +552,28 @@ public class OperationsService extends Service {
|
|||
updateLinkOperation.setHideFileDownload(hideFileDownload);
|
||||
|
||||
if (operationIntent.hasExtra(EXTRA_SHARE_PUBLIC_UPLOAD)) {
|
||||
if (remotePath.endsWith("/")) {
|
||||
updateLinkOperation.setPublicUploadOnFolder(
|
||||
operationIntent.getBooleanExtra(EXTRA_SHARE_PUBLIC_UPLOAD, false));
|
||||
} else {
|
||||
updateLinkOperation.setPublicUploadOnFile(
|
||||
operationIntent.getBooleanExtra(EXTRA_SHARE_PUBLIC_UPLOAD, false));
|
||||
}
|
||||
updateLinkOperation.setPublicUpload(true);
|
||||
}
|
||||
|
||||
if (operationIntent.hasExtra(EXTRA_SHARE_PUBLIC_LABEL)) {
|
||||
updateLinkOperation.setLabel(operationIntent.getStringExtra(EXTRA_SHARE_PUBLIC_LABEL));
|
||||
}
|
||||
|
||||
operation = updateLinkOperation;
|
||||
} else if (shareId > 0) {
|
||||
}
|
||||
break;
|
||||
|
||||
case ACTION_UPDATE_USER_SHARE:
|
||||
shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1);
|
||||
|
||||
if (shareId > 0) {
|
||||
UpdateSharePermissionsOperation updateShare = new UpdateSharePermissionsOperation(shareId);
|
||||
|
||||
int permissions = operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, -1);
|
||||
updateShare.setPermissions(permissions);
|
||||
|
||||
long expirationDateInMillis = operationIntent
|
||||
.getLongExtra(EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, 0L);
|
||||
.getLongExtra(EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, 0L);
|
||||
updateShare.setExpirationDateInMillis(expirationDateInMillis);
|
||||
|
||||
password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD);
|
||||
|
|
|
@ -24,6 +24,7 @@ package com.owncloud.android.ui.adapter;
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
|
@ -48,6 +49,9 @@ class PublicShareViewHolder extends RecyclerView.ViewHolder {
|
|||
}
|
||||
|
||||
public void bind(OCShare publicShare, PublicShareInterface listener) {
|
||||
if (!TextUtils.isEmpty(publicShare.getLabel())) {
|
||||
binding.publicShareLabel.setText(publicShare.getLabel());
|
||||
}
|
||||
binding.copyInternalLinkIcon
|
||||
.getBackground()
|
||||
.setColorFilter(context.getResources().getColor(R.color.primary_button_background_color),
|
||||
|
|
|
@ -44,7 +44,6 @@ import com.owncloud.android.lib.resources.shares.OCShare;
|
|||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.services.OperationsService;
|
||||
import com.owncloud.android.ui.TextDrawable;
|
||||
import com.owncloud.android.ui.dialog.ExpirationDatePickerDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.NoteDialogFragment;
|
||||
|
@ -334,16 +333,6 @@ public class ShareeListAdapter extends RecyclerView.Adapter<ShareeListAdapter.Us
|
|||
notifyDataSetChanged();
|
||||
return true;
|
||||
}
|
||||
case R.id.action_hide_file_listing: {
|
||||
item.setChecked(!item.isChecked());
|
||||
if (capabilities.getFilesFileDrop().isTrue()) {
|
||||
listener.setHideFileListingPermissionsToShare(share, item.isChecked());
|
||||
} else {
|
||||
// not supported in ownCloud
|
||||
listener.showNotSupportedByOcMessage();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case R.id.action_password: {
|
||||
listener.requestPasswordForShare(share);
|
||||
return true;
|
||||
|
@ -434,8 +423,6 @@ public class ShareeListAdapter extends RecyclerView.Adapter<ShareeListAdapter.Us
|
|||
boolean canEditChange,
|
||||
boolean canEditDelete);
|
||||
|
||||
void updateNoteToShare(OCShare share, String note);
|
||||
|
||||
/**
|
||||
* show a snackbar that this feature is not supported by ownCloud.
|
||||
*/
|
||||
|
@ -447,16 +434,5 @@ public class ShareeListAdapter extends RecyclerView.Adapter<ShareeListAdapter.Us
|
|||
* @param share the share for which a password shall be configured/removed
|
||||
*/
|
||||
void requestPasswordForShare(OCShare share);
|
||||
|
||||
/**
|
||||
* Updates a public share on a folder to set its hide file listing permission.
|
||||
* Starts a request to do it in {@link OperationsService}
|
||||
*
|
||||
* @param share {@link OCShare} instance which permissions will be updated.
|
||||
* @param hideFileListing New state of the permission for editing the folder shared via link.
|
||||
*/
|
||||
void setHideFileListingPermissionsToShare(OCShare share, boolean hideFileListing);
|
||||
|
||||
void setHideFileDownloadPermissionToShare(OCFile file, boolean hideFileDownload);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import com.owncloud.android.R;
|
|||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.ui.activity.FileActivity;
|
||||
import com.owncloud.android.ui.helpers.FileOperationsHelper;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
@ -134,8 +135,8 @@ public class ExpirationDatePickerDialogFragment
|
|||
getText(R.string.share_via_link_unset_password),
|
||||
(dialog1, which) -> {
|
||||
if (file != null) {
|
||||
((FileActivity) getActivity()).getFileOperationsHelper()
|
||||
.setExpirationDateToShareViaLink(file, -1);
|
||||
((FileActivity) getActivity()).getFileOperationsHelper().setExpirationDateToPublicShare(share,
|
||||
-1);
|
||||
} else if (share != null) {
|
||||
((FileActivity) getActivity()).getFileOperationsHelper().setExpirationDateToShare(share,-1);
|
||||
}
|
||||
|
@ -175,11 +176,11 @@ public class ExpirationDatePickerDialogFragment
|
|||
chosenDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
|
||||
long chosenDateInMillis = chosenDate.getTimeInMillis();
|
||||
|
||||
FileOperationsHelper operationsHelper = ((FileActivity) requireActivity()).getFileOperationsHelper();
|
||||
if (file != null) {
|
||||
((FileActivity) getActivity()).getFileOperationsHelper()
|
||||
.setExpirationDateToShareViaLink(file, chosenDateInMillis);
|
||||
operationsHelper.setExpirationDateToPublicShare(share, chosenDateInMillis);
|
||||
} else if (share != null) {
|
||||
((FileActivity) getActivity()).getFileOperationsHelper().setExpirationDateToShare(share,chosenDateInMillis);
|
||||
operationsHelper.setExpirationDateToShare(share, chosenDateInMillis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
|
@ -20,7 +20,7 @@
|
|||
|
||||
package com.owncloud.android.ui.dialog;
|
||||
|
||||
/**
|
||||
/*
|
||||
* Dialog to input a new name for an {@link OCFile} being renamed.
|
||||
*
|
||||
* Triggers the rename operation.
|
||||
|
@ -36,9 +36,9 @@ import android.view.View;
|
|||
import android.view.Window;
|
||||
import android.view.WindowManager.LayoutParams;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.databinding.EditBoxDialogBinding;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.resources.files.FileUtils;
|
||||
import com.owncloud.android.ui.activity.ComponentsGetter;
|
||||
|
@ -60,6 +60,7 @@ public class RenameFileDialogFragment
|
|||
|
||||
private static final String ARG_TARGET_FILE = "TARGET_FILE";
|
||||
|
||||
private EditBoxDialogBinding binding;
|
||||
private OCFile mTargetFile;
|
||||
|
||||
/**
|
||||
|
@ -85,44 +86,43 @@ public class RenameFileDialogFragment
|
|||
|
||||
AlertDialog alertDialog = (AlertDialog) getDialog();
|
||||
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(color);
|
||||
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(color);
|
||||
if (alertDialog != null) {
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(color);
|
||||
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
int accentColor = ThemeUtils.primaryAccentColor(getContext());
|
||||
mTargetFile = getArguments().getParcelable(ARG_TARGET_FILE);
|
||||
mTargetFile = requireArguments().getParcelable(ARG_TARGET_FILE);
|
||||
|
||||
// Inflate the layout for the dialog
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
View v = inflater.inflate(R.layout.edit_box_dialog, null);
|
||||
LayoutInflater inflater = requireActivity().getLayoutInflater();
|
||||
binding = EditBoxDialogBinding.inflate(inflater, null, false);
|
||||
View view = binding.getRoot();
|
||||
|
||||
// Setup layout
|
||||
String currentName = mTargetFile.getFileName();
|
||||
EditText inputText = v.findViewById(R.id.user_input);
|
||||
EditText inputText = binding.userInput;
|
||||
inputText.setHighlightColor(ThemeUtils.primaryColor(getActivity()));
|
||||
inputText.setText(currentName);
|
||||
ThemeUtils.themeEditText(getContext(), inputText, false);
|
||||
int selectionStart = 0;
|
||||
int extensionStart = mTargetFile.isFolder() ? -1 : currentName.lastIndexOf('.');
|
||||
int selectionEnd = extensionStart >= 0 ? extensionStart : currentName.length();
|
||||
if (selectionStart >= 0 && selectionEnd >= 0) {
|
||||
inputText.setSelection(
|
||||
Math.min(selectionStart, selectionEnd),
|
||||
Math.max(selectionStart, selectionEnd));
|
||||
}
|
||||
inputText.setSelection(Math.min(selectionStart, selectionEnd), Math.max(selectionStart, selectionEnd));
|
||||
inputText.requestFocus();
|
||||
inputText.getBackground().setColorFilter(accentColor, PorterDuff.Mode.SRC_ATOP);
|
||||
|
||||
// Build the dialog
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setView(v)
|
||||
.setPositiveButton(R.string.file_rename, this)
|
||||
.setNegativeButton(R.string.common_cancel, this)
|
||||
.setTitle(ThemeUtils.getColoredTitle(getResources().getString(R.string.rename_dialog_title),
|
||||
accentColor));
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity());
|
||||
builder.setView(view)
|
||||
.setPositiveButton(R.string.file_rename, this)
|
||||
.setNegativeButton(R.string.common_cancel, this)
|
||||
.setTitle(ThemeUtils.getColoredTitle(getResources().getString(R.string.rename_dialog_title),
|
||||
accentColor));
|
||||
Dialog d = builder.create();
|
||||
|
||||
Window window = d.getWindow();
|
||||
|
@ -137,22 +137,30 @@ public class RenameFileDialogFragment
|
|||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == AlertDialog.BUTTON_POSITIVE) {
|
||||
String newFileName =
|
||||
((TextView)(getDialog().findViewById(R.id.user_input)))
|
||||
.getText().toString().trim();
|
||||
String newFileName = "";
|
||||
|
||||
if (binding.userInput.getText() != null) {
|
||||
newFileName = binding.userInput.getText().toString().trim();
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(newFileName)) {
|
||||
DisplayUtils.showSnackMessage(getActivity(), R.string.filename_empty);
|
||||
DisplayUtils.showSnackMessage(requireActivity(), R.string.filename_empty);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FileUtils.isValidName(newFileName)) {
|
||||
DisplayUtils.showSnackMessage(getActivity(), R.string.filename_forbidden_charaters_from_server);
|
||||
DisplayUtils.showSnackMessage(requireActivity(), R.string.filename_forbidden_charaters_from_server);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
((ComponentsGetter) getActivity()).getFileOperationsHelper().renameFile(mTargetFile, newFileName);
|
||||
((ComponentsGetter) requireActivity()).getFileOperationsHelper().renameFile(mTargetFile, newFileName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager.LayoutParams;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.databinding.EditBoxDialogBinding;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.ui.activity.ComponentsGetter;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
/**
|
||||
* Dialog to rename a public share
|
||||
*/
|
||||
public class RenamePublicShareDialogFragment
|
||||
extends DialogFragment implements DialogInterface.OnClickListener {
|
||||
|
||||
private static final String ARG_PUBLIC_SHARE = "PUBLIC_SHARE";
|
||||
|
||||
public static final String RENAME_PUBLIC_SHARE_FRAGMENT = "RENAME_PUBLIC_SHARE_FRAGMENT";
|
||||
|
||||
private EditBoxDialogBinding binding;
|
||||
private OCShare publicShare;
|
||||
|
||||
public static RenamePublicShareDialogFragment newInstance(OCShare share) {
|
||||
RenamePublicShareDialogFragment frag = new RenamePublicShareDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable(ARG_PUBLIC_SHARE, share);
|
||||
frag.setArguments(args);
|
||||
return frag;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
int color = ThemeUtils.primaryAccentColor(getContext());
|
||||
|
||||
AlertDialog alertDialog = (AlertDialog) getDialog();
|
||||
|
||||
if (alertDialog != null) {
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(color);
|
||||
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
int accentColor = ThemeUtils.primaryAccentColor(getContext());
|
||||
publicShare = requireArguments().getParcelable(ARG_PUBLIC_SHARE);
|
||||
|
||||
// Inflate the layout for the dialog
|
||||
LayoutInflater inflater = requireActivity().getLayoutInflater();
|
||||
binding = EditBoxDialogBinding.inflate(inflater, null, false);
|
||||
View view = binding.getRoot();
|
||||
|
||||
// Setup layout
|
||||
EditText inputText = binding.userInput;
|
||||
inputText.setText(publicShare.getLabel());
|
||||
inputText.requestFocus();
|
||||
inputText.getBackground().setColorFilter(accentColor, PorterDuff.Mode.SRC_ATOP);
|
||||
inputText.setHighlightColor(ThemeUtils.primaryColor(getActivity()));
|
||||
|
||||
// Build the dialog
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity());
|
||||
builder.setView(view)
|
||||
.setPositiveButton(R.string.file_rename, this)
|
||||
.setNegativeButton(R.string.common_cancel, this)
|
||||
.setTitle(ThemeUtils.getColoredTitle(getResources().getString(R.string.public_share_name),
|
||||
accentColor));
|
||||
Dialog dialog = builder.create();
|
||||
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
window.setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
}
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == AlertDialog.BUTTON_POSITIVE) {
|
||||
String newName = "";
|
||||
if (binding.userInput.getText() != null) {
|
||||
newName = binding.userInput.getText().toString().trim();
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(newName)) {
|
||||
DisplayUtils.showSnackMessage(requireActivity(), R.string.label_empty);
|
||||
return;
|
||||
}
|
||||
|
||||
((ComponentsGetter) requireActivity()).getFileOperationsHelper().setLabelToPublicShare(publicShare,
|
||||
newName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
}
|
|
@ -180,7 +180,7 @@ public class SendShareDialog extends BottomSheetDialogFragment {
|
|||
requestPasswordForShareViaLink();
|
||||
} else {
|
||||
// create without password if not enforced by server or we don't know if enforced;
|
||||
((FileActivity) getActivity()).getFileOperationsHelper().shareFileViaLink(file, null);
|
||||
((FileActivity) getActivity()).getFileOperationsHelper().shareFileViaPublicShare(file, null);
|
||||
}
|
||||
|
||||
this.dismiss();
|
||||
|
|
|
@ -193,9 +193,9 @@ public class SharePasswordDialogFragment extends DialogFragment implements Dialo
|
|||
|
||||
private void setPassword(boolean createShare, OCFile file, String password) {
|
||||
if (createShare) {
|
||||
((FileActivity) getActivity()).getFileOperationsHelper().shareFileViaLink(file, password);
|
||||
((FileActivity) getActivity()).getFileOperationsHelper().shareFileViaPublicShare(file, password);
|
||||
} else {
|
||||
((FileActivity) getActivity()).getFileOperationsHelper().setPasswordToShareViaLink(file, password);
|
||||
((FileActivity) getActivity()).getFileOperationsHelper().setPasswordToPublicShare(share, password);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ import com.owncloud.android.ui.adapter.ShareeListAdapter;
|
|||
import com.owncloud.android.ui.decoration.SimpleListItemDividerDecoration;
|
||||
import com.owncloud.android.ui.dialog.ExpirationDatePickerDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.NoteDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.RenamePublicShareDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.SharePasswordDialogFragment;
|
||||
import com.owncloud.android.ui.fragment.util.FileDetailSharingFragmentHelper;
|
||||
import com.owncloud.android.ui.fragment.util.SharingMenuHelper;
|
||||
|
@ -327,7 +328,7 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
|||
|
||||
} else {
|
||||
// create without password if not enforced by server or we don't know if enforced;
|
||||
fileOperationsHelper.shareFileViaLink(file, null);
|
||||
fileOperationsHelper.shareFileViaPublicShare(file, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,14 +397,13 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
|||
case R.id.action_allow_editing:
|
||||
if (file.isSharedViaLink()) {
|
||||
item.setChecked(!item.isChecked());
|
||||
fileOperationsHelper.setUploadPermissionsToShare(file,
|
||||
item.isChecked());
|
||||
fileOperationsHelper.setUploadPermissionsToPublicShare(publicShare, item.isChecked());
|
||||
}
|
||||
return true;
|
||||
case R.id.action_hide_file_listing: {
|
||||
item.setChecked(!item.isChecked());
|
||||
if (capabilities.getFilesFileDrop().isTrue()) {
|
||||
setHideFileListingPermissionsToShare(publicShare, item.isChecked());
|
||||
fileOperationsHelper.setHideFileListingPermissionsToPublicShare(publicShare, item.isChecked());
|
||||
} else {
|
||||
// not supported in ownCloud
|
||||
showNotSupportedByOcMessage();
|
||||
|
@ -412,19 +412,24 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
|||
}
|
||||
case R.id.action_hide_file_download:
|
||||
item.setChecked(!item.isChecked());
|
||||
setHideFileDownloadPermissionToShare(file, item.isChecked());
|
||||
fileOperationsHelper.setHideFileDownloadPermissionsToPublicShare(publicShare, item.isChecked());
|
||||
|
||||
return true;
|
||||
case R.id.action_edit_label:
|
||||
RenamePublicShareDialogFragment renameDialog = RenamePublicShareDialogFragment.newInstance(publicShare);
|
||||
renameDialog.show(fileActivity.getSupportFragmentManager(),
|
||||
RenamePublicShareDialogFragment.RENAME_PUBLIC_SHARE_FRAGMENT);
|
||||
return true;
|
||||
case R.id.action_password: {
|
||||
requestPasswordForShareViaLink(false,
|
||||
capabilities.getFilesSharingPublicAskForOptionalPassword().isTrue());
|
||||
return true;
|
||||
}
|
||||
case R.id.action_share_expiration_date: {
|
||||
ExpirationDatePickerDialogFragment dialog = ExpirationDatePickerDialogFragment
|
||||
ExpirationDatePickerDialogFragment expirationDialog = ExpirationDatePickerDialogFragment
|
||||
.newInstance(file, publicShare.getExpirationDate());
|
||||
dialog.show(fileActivity.getSupportFragmentManager(),
|
||||
ExpirationDatePickerDialogFragment.DATE_PICKER_DIALOG);
|
||||
expirationDialog.show(fileActivity.getSupportFragmentManager(),
|
||||
ExpirationDatePickerDialogFragment.DATE_PICKER_DIALOG);
|
||||
return true;
|
||||
}
|
||||
case R.id.action_share_send_link: {
|
||||
|
@ -436,8 +441,8 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
|||
return true;
|
||||
}
|
||||
case R.id.action_share_send_note:
|
||||
NoteDialogFragment dialog = NoteDialogFragment.newInstance(publicShare);
|
||||
dialog.show(fileActivity.getSupportFragmentManager(), NoteDialogFragment.NOTE_FRAGMENT);
|
||||
NoteDialogFragment noteDialog = NoteDialogFragment.newInstance(publicShare);
|
||||
noteDialog.show(fileActivity.getSupportFragmentManager(), NoteDialogFragment.NOTE_FRAGMENT);
|
||||
return true;
|
||||
case R.id.action_add_another_public_share_link:
|
||||
createShareLink();
|
||||
|
@ -450,16 +455,6 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHideFileListingPermissionsToShare(OCShare share, boolean hideFileListing) {
|
||||
fileOperationsHelper.setHideFileListingPermissionsToShare(share, hideFileListing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHideFileDownloadPermissionToShare(OCFile file, boolean hideFileDownload) {
|
||||
fileOperationsHelper.setHideFileDownloadPermissionsToShare(file, hideFileDownload);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showNotSupportedByOcMessage() {
|
||||
if (getView() != null) {
|
||||
|
@ -523,11 +518,6 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
|||
return permissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNoteToShare(OCShare share, String note) {
|
||||
fileOperationsHelper.updateNoteToShare(share, note);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a dialog that requests a password to the user to protect a share link.
|
||||
*
|
||||
|
|
|
@ -460,7 +460,7 @@ public class FileOperationsHelper {
|
|||
* @param file The file to share.
|
||||
* @param password Optional password to protect the public share.
|
||||
*/
|
||||
public void shareFileViaLink(OCFile file, String password) {
|
||||
public void shareFileViaPublicShare(OCFile file, String password) {
|
||||
if (file != null) {
|
||||
fileActivity.showLoadingDialog(fileActivity.getString(R.string.wait_a_moment));
|
||||
Intent service = new Intent(fileActivity, OperationsService.class);
|
||||
|
@ -580,24 +580,37 @@ public class FileOperationsHelper {
|
|||
|
||||
|
||||
/**
|
||||
* Updates a public share on a file to set its password.
|
||||
* Starts a request to do it in {@link OperationsService}
|
||||
* Updates a public share on a file to set its password. Starts a request to do it in {@link OperationsService}
|
||||
*
|
||||
* @param file File which public share will be protected with a password.
|
||||
* @param password Password to set for the public link; null or empty string to clear
|
||||
* the current password
|
||||
* @param password Password to set for the public link; null or empty string to clear the current password
|
||||
*/
|
||||
public void setPasswordToShareViaLink(OCFile file, String password) {
|
||||
public void setPasswordToPublicShare(OCShare share, String password) {
|
||||
// Set password updating share
|
||||
Intent updateShareIntent = new Intent(fileActivity, OperationsService.class);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_SHARE);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_PUBLIC_SHARE);
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_ID, share.getId());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_PASSWORD, (password == null) ? "" : password);
|
||||
|
||||
queueShareIntent(updateShareIntent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a public share on a file to set its label. Starts a request to do it in {@link OperationsService}
|
||||
*
|
||||
* @param label new label
|
||||
*/
|
||||
public void setLabelToPublicShare(OCShare share, String label) {
|
||||
// Set password updating share
|
||||
Intent updateShareIntent = new Intent(fileActivity, OperationsService.class);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_PUBLIC_SHARE);
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_ID, share.getId());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_PUBLIC_LABEL, (label == null) ? "" : label);
|
||||
|
||||
queueShareIntent(updateShareIntent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a share on a file to set its password.
|
||||
* Starts a request to do it in {@link OperationsService}
|
||||
|
@ -608,30 +621,31 @@ public class FileOperationsHelper {
|
|||
*/
|
||||
public void setPasswordToShare(OCShare share, String password) {
|
||||
Intent updateShareIntent = new Intent(fileActivity, OperationsService.class);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_SHARE);
|
||||
if (TextUtils.isEmpty(share.getShareLink())) {
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_USER_SHARE);
|
||||
} else {
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_PUBLIC_SHARE);
|
||||
}
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_ID, share.getId());
|
||||
updateShareIntent.putExtra(
|
||||
OperationsService.EXTRA_SHARE_PASSWORD,
|
||||
(password == null) ? "" : password
|
||||
);
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_PASSWORD, (password == null) ? "" : password);
|
||||
queueShareIntent(updateShareIntent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates a public share on a file to set its expiration date.
|
||||
* Starts a request to do it in {@link OperationsService}
|
||||
* Updates a public share on a file to set its expiration date. Starts a request to do it in {@link
|
||||
* OperationsService}
|
||||
*
|
||||
* @param file File which public share will be constrained with an expiration date.
|
||||
* @param expirationTimeInMillis Expiration date to set. A negative value clears the current expiration
|
||||
* date, leaving the link unrestricted. Zero makes no change.
|
||||
* @param share {@link OCShare} instance which permissions will be updated.
|
||||
* @param expirationTimeInMillis Expiration date to set. A negative value clears the current expiration date,
|
||||
* leaving the link unrestricted. Zero makes no change.
|
||||
*/
|
||||
public void setExpirationDateToShareViaLink(OCFile file, long expirationTimeInMillis) {
|
||||
public void setExpirationDateToPublicShare(OCShare share, long expirationTimeInMillis) {
|
||||
Intent updateShareIntent = new Intent(fileActivity, OperationsService.class);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_SHARE);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_PUBLIC_SHARE);
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_ID, share.getId());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, expirationTimeInMillis);
|
||||
queueShareIntent(updateShareIntent);
|
||||
}
|
||||
|
@ -646,7 +660,7 @@ public class FileOperationsHelper {
|
|||
*/
|
||||
public void setExpirationDateToShare(OCShare share, long expirationTimeInMillis) {
|
||||
Intent updateShareIntent = new Intent(fileActivity, OperationsService.class);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_SHARE);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_USER_SHARE);
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_ID, share.getId());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, expirationTimeInMillis);
|
||||
|
@ -663,7 +677,7 @@ public class FileOperationsHelper {
|
|||
*/
|
||||
public void setPermissionsToShare(OCShare share, int permissions) {
|
||||
Intent updateShareIntent = new Intent(fileActivity, OperationsService.class);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_SHARE);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_USER_SHARE);
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_ID, share.getId());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_PERMISSIONS, permissions);
|
||||
|
@ -671,17 +685,17 @@ public class FileOperationsHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Updates a public share on a folder to set its editing permission.
|
||||
* Starts a request to do it in {@link OperationsService}
|
||||
* Updates a public share on a folder to set its editing permission. Starts a request to do it in {@link
|
||||
* OperationsService}
|
||||
*
|
||||
* @param folder Folder which editing permission of his public share will be modified.
|
||||
* @param share {@link OCShare} instance which permissions will be updated.
|
||||
* @param uploadPermission New state of the permission for editing the folder shared via link.
|
||||
*/
|
||||
public void setUploadPermissionsToShare(OCFile folder, boolean uploadPermission) {
|
||||
public void setUploadPermissionsToPublicShare(OCShare share, boolean uploadPermission) {
|
||||
Intent updateShareIntent = new Intent(fileActivity, OperationsService.class);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_SHARE);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_PUBLIC_SHARE);
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_REMOTE_PATH, folder.getRemotePath());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_ID, share.getId());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_PUBLIC_UPLOAD, uploadPermission);
|
||||
queueShareIntent(updateShareIntent);
|
||||
}
|
||||
|
@ -693,9 +707,9 @@ public class FileOperationsHelper {
|
|||
* @param share {@link OCShare} instance which permissions will be updated.
|
||||
* @param hideFileListing New state of the permission for editing the folder shared via link.
|
||||
*/
|
||||
public void setHideFileListingPermissionsToShare(OCShare share, boolean hideFileListing) {
|
||||
public void setHideFileListingPermissionsToPublicShare(OCShare share, boolean hideFileListing) {
|
||||
Intent updateShareIntent = new Intent(fileActivity, OperationsService.class);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_SHARE);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_PUBLIC_SHARE);
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_ID, share.getId());
|
||||
|
||||
|
@ -703,17 +717,17 @@ public class FileOperationsHelper {
|
|||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_PERMISSIONS, OCShare.CREATE_PERMISSION_FLAG);
|
||||
} else {
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_PERMISSIONS,
|
||||
OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9);
|
||||
OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9);
|
||||
}
|
||||
|
||||
queueShareIntent(updateShareIntent);
|
||||
}
|
||||
|
||||
public void setHideFileDownloadPermissionsToShare(OCFile file, boolean hideFileDownload) {
|
||||
public void setHideFileDownloadPermissionsToPublicShare(OCShare share, boolean hideFileDownload) {
|
||||
Intent updateShareIntent = new Intent(fileActivity, OperationsService.class);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_SHARE);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_PUBLIC_SHARE);
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_ID, share.getId());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_HIDE_FILE_DOWNLOAD, hideFileDownload);
|
||||
|
||||
queueShareIntent(updateShareIntent);
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
android:src="@drawable/shared_via_link" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/public_share_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
|
|
|
@ -42,6 +42,11 @@
|
|||
android:title="@string/share_via_link_hide_download"
|
||||
android:checkable="true"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_edit_label"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/edit_label"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_password"
|
||||
android:showAsAction="never"
|
||||
|
|
|
@ -278,6 +278,7 @@
|
|||
<string name="filename_forbidden_characters">Forbidden characters: / \\ < > : " | ? *</string>
|
||||
<string name="filename_forbidden_charaters_from_server">Filename contains at least one invalid character</string>
|
||||
<string name="filename_empty">Filename cannot be empty</string>
|
||||
<string name="label_empty">Label cannot be empty</string>
|
||||
<string name="wait_a_moment">Wait a moment…</string>
|
||||
<string name="wait_checking_credentials">Checking stored credentials</string>
|
||||
<string name="filedisplay_no_file_selected">No file selected</string>
|
||||
|
@ -927,4 +928,6 @@
|
|||
<string name="unshare">Unshare</string>
|
||||
<string name="allow_editing">Allow editing</string>
|
||||
<string name="add_new_public_share">Add new public share link</string>
|
||||
<string name="edit_label">Change name</string>
|
||||
<string name="public_share_name">New name</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue