diff --git a/build.gradle b/build.gradle
index c4a8f31a29c9..b67097bffd58 100644
--- a/build.gradle
+++ b/build.gradle
@@ -206,9 +206,9 @@ dependencies {
// dependencies for app building
implementation 'com.android.support:multidex:1.0.3'
// implementation project('nextcloud-android-library')
- genericImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
- gplayImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
- versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' // use always latest master
+ genericImplementation "com.github.nextcloud:android-library:shareParameters-SNAPSHOT"
+ gplayImplementation "com.github.nextcloud:android-library:shareParameters-SNAPSHOT"
+ versionDevImplementation 'com.github.nextcloud:android-library:shareParameters-SNAPSHOT' // use always latest master
implementation "com.android.support:support-v4:${supportLibraryVersion}"
implementation "com.android.support:design:${supportLibraryVersion}"
implementation 'com.jakewharton:disklrucache:2.0.2'
diff --git a/drawable_resources/ic_send.svg b/drawable_resources/ic_send.svg
new file mode 100644
index 000000000000..eefce2fb64bb
--- /dev/null
+++ b/drawable_resources/ic_send.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java
index ea7d5e8d4f3a..d34a9b52ec6a 100644
--- a/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java
+++ b/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java
@@ -997,6 +997,8 @@ public boolean saveShare(OCShare share) {
cv.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, mAccount.name);
+ cv.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected());
+
if (shareExistsForRemoteId(share.getRemoteId())) {// for renamed files; no more delete and create
overriden = true;
if (getContentResolver() != null) {
@@ -1200,6 +1202,7 @@ private OCShare createShareInstance(Cursor c) {
share.setIsFolder(c.getInt(c.getColumnIndex(ProviderTableMeta.OCSHARES_IS_DIRECTORY)) == 1);
share.setUserId(c.getLong(c.getColumnIndex(ProviderTableMeta.OCSHARES_USER_ID)));
share.setIdRemoteShared(c.getLong(c.getColumnIndex(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED)));
+ share.setIsPasswordProtected(c.getInt(c.getColumnIndex(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED)) == 1);
}
return share;
}
@@ -1307,6 +1310,8 @@ public void saveShares(Collection shares) {
cv.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, mAccount.name);
+ cv.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
+
if (shareExistsForRemoteId(share.getRemoteId())) {
// updating an existing file
operations.add(
@@ -1588,6 +1593,8 @@ private ArrayList prepareInsertShares(
cv.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, mAccount.name);
+ cv.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
+
// adding a new share resource
operations.add(
ContentProviderOperation.newInsert(ProviderTableMeta.CONTENT_URI_SHARE).
diff --git a/src/main/java/com/owncloud/android/db/ProviderMeta.java b/src/main/java/com/owncloud/android/db/ProviderMeta.java
index 7fe02b943361..d81f0188d1ad 100644
--- a/src/main/java/com/owncloud/android/db/ProviderMeta.java
+++ b/src/main/java/com/owncloud/android/db/ProviderMeta.java
@@ -1,4 +1,4 @@
-/**
+/*
* ownCloud Android client application
*
* @author Bartek Przybylski
@@ -32,7 +32,7 @@
public class ProviderMeta {
public static final String DB_NAME = "filelist";
- public static final int DB_VERSION = 31;
+ public static final int DB_VERSION = 32;
private ProviderMeta() {
}
@@ -128,6 +128,7 @@ static public class ProviderTableMeta implements BaseColumns {
public static final String OCSHARES_USER_ID = "user_id";
public static final String OCSHARES_ID_REMOTE_SHARED = "id_remote_shared";
public static final String OCSHARES_ACCOUNT_OWNER = "owner_share";
+ public static final String OCSHARES_IS_PASSWORD_PROTECTED = "is_password_protected";
public static final String OCSHARES_DEFAULT_SORT_ORDER = OCSHARES_FILE_SOURCE
+ " collate nocase asc";
diff --git a/src/main/java/com/owncloud/android/operations/UpdateSharePermissionsOperation.java b/src/main/java/com/owncloud/android/operations/UpdateSharePermissionsOperation.java
index a1f3b0a52948..6616ce8a3582 100644
--- a/src/main/java/com/owncloud/android/operations/UpdateSharePermissionsOperation.java
+++ b/src/main/java/com/owncloud/android/operations/UpdateSharePermissionsOperation.java
@@ -39,6 +39,7 @@ public class UpdateSharePermissionsOperation extends SyncOperation {
private long mShareId;
private int mPermissions;
private long mExpirationDateInMillis;
+ private String mPassword;
private String mPath;
/**
@@ -50,6 +51,18 @@ public UpdateSharePermissionsOperation(long shareId) {
mShareId = shareId;
mPermissions = -1;
mExpirationDateInMillis = 0L;
+ mPassword = null;
+ }
+
+ /**
+ * Set password to update in private share.
+ *
+ * @param password Password to set to the private share.
+ * Empty string clears the current password.
+ * Null results in no update applied to the password.
+ */
+ public void setPassword(String password) {
+ mPassword = password;
}
/**
@@ -88,6 +101,7 @@ protected RemoteOperationResult run(OwnCloudClient client) {
// Update remote share with password
UpdateRemoteShareOperation updateOp = new UpdateRemoteShareOperation(share.getRemoteId());
+ updateOp.setPassword(mPassword);
updateOp.setPermissions(mPermissions);
updateOp.setExpirationDate(mExpirationDateInMillis);
RemoteOperationResult result = updateOp.execute(client);
@@ -109,6 +123,10 @@ public String getPath() {
return mPath;
}
+ public String getPassword() {
+ return mPassword;
+ }
+
private void updateData(OCShare share) {
// Update DB with the response
share.setPath(mPath); // TODO - check if may be moved to UpdateRemoteShareOperation
@@ -117,6 +135,8 @@ private void updateData(OCShare share) {
} else {
share.setIsFolder(false);
}
+
+ share.setIsPasswordProtected((mPassword != null && mPassword.length() > 0));
getStorageManager().saveShare(share);
}
diff --git a/src/main/java/com/owncloud/android/operations/UpdateShareViaLinkOperation.java b/src/main/java/com/owncloud/android/operations/UpdateShareViaLinkOperation.java
index c11d913cdfe3..46095f735e78 100644
--- a/src/main/java/com/owncloud/android/operations/UpdateShareViaLinkOperation.java
+++ b/src/main/java/com/owncloud/android/operations/UpdateShareViaLinkOperation.java
@@ -35,7 +35,6 @@
/**
* Updates an existing public share for a given file
*/
-
public class UpdateShareViaLinkOperation extends SyncOperation {
private String mPath;
diff --git a/src/main/java/com/owncloud/android/providers/FileContentProvider.java b/src/main/java/com/owncloud/android/providers/FileContentProvider.java
index c25ea1bca788..a09c7ecad616 100644
--- a/src/main/java/com/owncloud/android/providers/FileContentProvider.java
+++ b/src/main/java/com/owncloud/android/providers/FileContentProvider.java
@@ -1687,6 +1687,23 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}
+ if (oldVersion < 32 && newVersion >= 32) {
+ Log_OC.i(SQL, "Entering in the #32 add ocshares.is_password_protected");
+ db.beginTransaction();
+ try {
+ db.execSQL(ALTER_TABLE + ProviderTableMeta.OCSHARES_TABLE_NAME +
+ ADD_COLUMN + ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED + " INTEGER "); // boolean
+
+ upgraded = true;
+ db.setTransactionSuccessful();
+ } finally {
+ db.endTransaction();
+ }
+ }
+
+ if (!upgraded) {
+ Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
+ }
}
@Override
diff --git a/src/main/java/com/owncloud/android/services/OperationsService.java b/src/main/java/com/owncloud/android/services/OperationsService.java
index cbe3414a86ac..8bb8fd404ebb 100644
--- a/src/main/java/com/owncloud/android/services/OperationsService.java
+++ b/src/main/java/com/owncloud/android/services/OperationsService.java
@@ -590,6 +590,8 @@ private void nextOperation() {
((UpdateSharePermissionsOperation)operation).setPermissions(permissions);
long expirationDateInMillis = operationIntent.getLongExtra(EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, 0L);
((UpdateSharePermissionsOperation)operation).setExpirationDate(expirationDateInMillis);
+ String password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD);
+ ((UpdateSharePermissionsOperation)operation).setPassword(password);
}
} else if (action.equals(ACTION_CREATE_SHARE_WITH_SHAREE)) {
diff --git a/src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java
index 5c80c2fc61e5..cce215f11ca5 100644
--- a/src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java
+++ b/src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java
@@ -44,9 +44,10 @@
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.services.OperationsService;
import com.owncloud.android.ui.TextDrawable;
import com.owncloud.android.ui.dialog.ExpirationDatePickerDialogFragment;
-import com.owncloud.android.ui.fragment.util.FileDetailSharingFragmentHelper;
+import com.owncloud.android.ui.fragment.util.SharingMenuHelper;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.ThemeUtils;
@@ -186,27 +187,52 @@ private void onOverflowIconClicked(View view, AppCompatCheckBox allowEditsCheckB
*/
private void prepareOptionsMenu(Menu menu, OCShare share) {
+ MenuItem editCreateItem = menu.findItem(R.id.action_can_edit_create);
+ MenuItem editChangeItem = menu.findItem(R.id.action_can_edit_change);
+ MenuItem editDeleteItem = menu.findItem(R.id.action_can_edit_delete);
+
+ MenuItem hideFileListingItem = menu.findItem(R.id.action_hide_file_listing);
+ MenuItem passwordItem = menu.findItem(R.id.action_password);
+ MenuItem expirationDateItem = menu.findItem(R.id.action_expiration_date);
+
MenuItem reshareItem = menu.findItem(R.id.action_can_reshare);
+
if (isReshareForbidden(share)) {
reshareItem.setVisible(false);
}
reshareItem.setChecked(canReshare(share));
- MenuItem editCreateItem = menu.findItem(R.id.action_can_edit_create);
- MenuItem editChangeItem = menu.findItem(R.id.action_can_edit_change);
- MenuItem editDeleteItem = menu.findItem(R.id.action_can_edit_delete);
- if (file.isFolder() && isEditOptionsAvailable(share)) {
- /// TODO change areEditOptionsAvailable in order to delete !isFederated
- editCreateItem.setChecked(canCreate(share));
- editChangeItem.setChecked(canUpdate(share));
- editDeleteItem.setChecked(canDelete(share));
- } else {
+ if (share.getShareType() == ShareType.EMAIL) {
+ SharingMenuHelper.setupHideFileListingMenuItem(
+ hideFileListingItem,
+ file.isFolder(),
+ canEdit(share),
+ share.getPermissions()
+ );
+ SharingMenuHelper.setupPasswordMenuItem(passwordItem, share.isPasswordProtected());
+
+ reshareItem.setVisible(false);
editCreateItem.setVisible(false);
editChangeItem.setVisible(false);
editDeleteItem.setVisible(false);
+ } else {
+ if (file.isFolder() && isEditOptionsAvailable(share)) {
+ /// TODO change areEditOptionsAvailable in order to delete !isFederated
+ editCreateItem.setChecked(canCreate(share));
+ editChangeItem.setChecked(canUpdate(share));
+ editDeleteItem.setChecked(canDelete(share));
+ } else {
+ editCreateItem.setVisible(false);
+ editChangeItem.setVisible(false);
+ editDeleteItem.setVisible(false);
+ }
+
+ hideFileListingItem.setVisible(false);
+ passwordItem.setVisible(false);
+ expirationDateItem.setVisible(false);
}
- FileDetailSharingFragmentHelper.setupExpirationDateMenuItem(
+ SharingMenuHelper.setupExpirationDateMenuItem(
menu.findItem(R.id.action_expiration_date), share.getExpirationDate(), context.getResources());
}
@@ -280,6 +306,20 @@ private boolean optionsItemSelected(Menu menu, MenuItem item, AppCompatCheckBox
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;
+ }
case R.id.action_expiration_date: {
ExpirationDatePickerDialogFragment dialog = ExpirationDatePickerDialogFragment.newInstance(share, -1);
dialog.show(
@@ -363,5 +403,26 @@ int updatePermissionsToShare(OCShare share,
boolean canEditCreate,
boolean canEditChange,
boolean canEditDelete);
+
+ /**
+ * show a snackbar that this feature is not supported by ownCloud.
+ */
+ void showNotSupportedByOcMessage();
+
+ /**
+ * Starts a dialog that requests a password to the user to protect a share.
+ *
+ * @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);
}
}
diff --git a/src/main/java/com/owncloud/android/ui/dialog/SharePasswordDialogFragment.java b/src/main/java/com/owncloud/android/ui/dialog/SharePasswordDialogFragment.java
index 55aa75fb3a79..251fedcdbb03 100644
--- a/src/main/java/com/owncloud/android/ui/dialog/SharePasswordDialogFragment.java
+++ b/src/main/java/com/owncloud/android/ui/dialog/SharePasswordDialogFragment.java
@@ -38,6 +38,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.utils.ThemeUtils;
@@ -49,10 +50,12 @@
public class SharePasswordDialogFragment extends DialogFragment implements DialogInterface.OnClickListener {
private static final String ARG_FILE = "FILE";
+ private static final String ARG_SHARE = "SHARE";
private static final String ARG_CREATE_SHARE = "CREATE_SHARE";
public static final String PASSWORD_FRAGMENT = "PASSWORD_FRAGMENT";
private OCFile file;
+ private OCShare share;
private boolean createShare;
@Override
@@ -84,6 +87,20 @@ public static SharePasswordDialogFragment newInstance(OCFile file, boolean creat
return frag;
}
+ /**
+ * Public factory method to create new SharePasswordDialogFragment instances.
+ *
+ * @param share OCFile bound to the public share that which password will be set or updated
+ * @return Dialog ready to show.
+ */
+ public static SharePasswordDialogFragment newInstance(OCShare share) {
+ SharePasswordDialogFragment frag = new SharePasswordDialogFragment();
+ Bundle args = new Bundle();
+ args.putParcelable(ARG_SHARE, share);
+ frag.setArguments(args);
+ return frag;
+ }
+
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -94,6 +111,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
file = getArguments().getParcelable(ARG_FILE);
+ share = getArguments().getParcelable(ARG_SHARE);
createShare = getArguments().getBoolean(ARG_CREATE_SHARE, false);
// Inflate the layout for the dialog
@@ -136,9 +154,17 @@ public void onClick(DialogInterface dialog, int which) {
return;
}
- setPassword(createShare, file, password);
+ if (share == null) {
+ setPassword(createShare, file, password);
+ } else {
+ setPassword(share, password);
+ }
} else if (which == AlertDialog.BUTTON_NEUTRAL) {
- setPassword(createShare, file, null);
+ if (share == null) {
+ setPassword(createShare, file, null);
+ } else {
+ setPassword(share, null);
+ }
}
}
@@ -149,4 +175,8 @@ private void setPassword(boolean createShare, OCFile file, String password) {
((FileActivity) getActivity()).getFileOperationsHelper().setPasswordToShareViaLink(file, password);
}
}
+
+ private void setPassword(OCShare share, String password) {
+ ((FileActivity) getActivity()).getFileOperationsHelper().setPasswordToShare(share, password);
+ }
}
diff --git a/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java b/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java
index f20d8a01246d..ff4157d63609 100644
--- a/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java
+++ b/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java
@@ -35,6 +35,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
@@ -64,6 +65,7 @@
import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;
+import butterknife.OnClick;
import butterknife.Unbinder;
public class FileDetailActivitiesFragment extends Fragment implements ActivityListInterface {
@@ -106,6 +108,9 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi
@BindView(android.R.id.list)
public RecyclerView recyclerView;
+ @BindView(R.id.comment_input)
+ public EditText comment;
+
@BindString(R.string.activities_no_results_headline)
public String noResultsHeadline;
@@ -332,6 +337,13 @@ protected void onCreateSwipeToRefresh(SwipeRefreshLayout refreshLayout) {
refreshLayout.setColorSchemeColors(accentColor, primaryColor, darkColor);
}
+ @OnClick(R.id.comment_send)
+ public void sendComment() {
+ if (comment.getText() != null && comment.getText().length() > 0) {
+ // TODO send the comment to the server and refresh the activities list
+ }
+ }
+
@Override
public void onActivityClicked(RichObject richObject) {
// TODO implement activity click
diff --git a/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java b/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java
index 215a35a6f639..5fd55fc5cb20 100644
--- a/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java
+++ b/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java
@@ -58,6 +58,7 @@
import com.owncloud.android.ui.dialog.ExpirationDatePickerDialogFragment;
import com.owncloud.android.ui.dialog.SharePasswordDialogFragment;
import com.owncloud.android.ui.fragment.util.FileDetailSharingFragmentHelper;
+import com.owncloud.android.ui.fragment.util.SharingMenuHelper;
import com.owncloud.android.utils.ThemeUtils;
import java.util.ArrayList;
@@ -273,18 +274,18 @@ public void showLinkOverflowMenu() {
private void prepareOptionsMenu(Menu menu) {
Resources res = getResources();
- FileDetailSharingFragmentHelper.setupHideFileListingMenuItem(
- menu.findItem(R.id.action_share_link_hide_file_listing),
+ SharingMenuHelper.setupHideFileListingMenuItem(
+ menu.findItem(R.id.action_hide_file_listing),
file.isFolder(),
shareByLinkAllowEditing.isChecked(),
publicShare.getPermissions()
);
- FileDetailSharingFragmentHelper.setupPasswordMenuItem(
- menu.findItem(R.id.action_share_link_password),
+ SharingMenuHelper.setupPasswordMenuItem(
+ menu.findItem(R.id.action_password),
publicShare.isPasswordProtected()
);
- FileDetailSharingFragmentHelper.setupExpirationDateMenuItem(
- menu.findItem(R.id.action_share_link_expiration_date),
+ SharingMenuHelper.setupExpirationDateMenuItem(
+ menu.findItem(R.id.action_share_expiration_date),
publicShare.getExpirationDate(),
res
);
@@ -292,28 +293,21 @@ private void prepareOptionsMenu(Menu menu) {
private boolean optionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.action_share_link_hide_file_listing: {
+ case R.id.action_hide_file_listing: {
item.setChecked(!item.isChecked());
if (capabilities.getFilesFileDrop().isTrue()) {
- ((FileActivity) getActivity()).getFileOperationsHelper().
- setHideFileListingPermissionsToShare(publicShare, item.isChecked());
+ setHideFileListingPermissionsToShare(publicShare, item.isChecked());
} else {
// not supported in ownCloud
- Snackbar.make(getView(), R.string.files_drop_not_supported, Snackbar.LENGTH_LONG)
- .setAction(R.string.learn_more, v -> {
- Intent i = new Intent(Intent.ACTION_VIEW);
- i.setData(Uri.parse(getString(R.string.url_server_install)));
- startActivity(i);
- })
- .show();
+ showNotSupportedByOcMessage();
}
return true;
}
- case R.id.action_share_link_password: {
+ case R.id.action_password: {
requestPasswordForShareViaLink(false);
return true;
}
- case R.id.action_share_link_expiration_date: {
+ case R.id.action_expiration_date: {
ExpirationDatePickerDialogFragment dialog = ExpirationDatePickerDialogFragment.newInstance(file, -1);
dialog.show(
getActivity().getSupportFragmentManager(),
@@ -326,6 +320,25 @@ private boolean optionsItemSelected(MenuItem item) {
}
}
+ @Override
+ public void setHideFileListingPermissionsToShare(OCShare share, boolean hideFileListing) {
+ ((FileActivity) getActivity()).getFileOperationsHelper().
+ setHideFileListingPermissionsToShare(share, hideFileListing);
+ }
+
+ @Override
+ public void showNotSupportedByOcMessage() {
+ if (getView() != null) {
+ Snackbar.make(getView(), R.string.files_drop_not_supported, Snackbar.LENGTH_LONG)
+ .setAction(R.string.learn_more, v -> {
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse(getString(R.string.url_server_install)));
+ startActivity(i);
+ })
+ .show();
+ }
+ }
+
/**
* Updates the UI after the result of an update operation on the edited {@link OCFile}.
*
@@ -404,6 +417,12 @@ public void requestPasswordForShareViaLink(boolean createShare) {
dialog.show(getChildFragmentManager(), SharePasswordDialogFragment.PASSWORD_FRAGMENT);
}
+ @Override
+ public void requestPasswordForShare(OCShare share) {
+ SharePasswordDialogFragment dialog = SharePasswordDialogFragment.newInstance(share);
+ dialog.show(getChildFragmentManager(), SharePasswordDialogFragment.PASSWORD_FRAGMENT);
+ }
+
/**
* Get known server capabilities from DB
*
diff --git a/src/main/java/com/owncloud/android/ui/fragment/util/FileDetailSharingFragmentHelper.java b/src/main/java/com/owncloud/android/ui/fragment/util/FileDetailSharingFragmentHelper.java
index d01a1a906274..04a5f94123d2 100644
--- a/src/main/java/com/owncloud/android/ui/fragment/util/FileDetailSharingFragmentHelper.java
+++ b/src/main/java/com/owncloud/android/ui/fragment/util/FileDetailSharingFragmentHelper.java
@@ -38,63 +38,6 @@
* Helper calls for visibility logic of the sharing fragment.
*/
public class FileDetailSharingFragmentHelper {
-
- /**
- * Sets checked/visiblity state on the given {@link MenuItem} based on the given criteria.
- *
- * @param fileListing the {@link MenuItem} to be setup
- * @param isFolder flag if it is a folder
- * @param isEditingAllowed flag if editing is allowed
- * @param publicSharePermissions share permissions of the link
- */
- public static void setupHideFileListingMenuItem(MenuItem fileListing,
- boolean isFolder,
- boolean isEditingAllowed,
- int publicSharePermissions) {
- if (!isFolder) {
- fileListing.setVisible(false);
- } else {
- if (isEditingAllowed) {
- boolean readOnly = (publicSharePermissions & OCShare.READ_PERMISSION_FLAG) != 0;
- fileListing.setChecked(!readOnly);
- } else {
- fileListing.setVisible(false);
- }
- }
- }
-
- /**
- * sets up the password {@link MenuItem}'s title based on the fact if a password is present.
- *
- * @param password the password {@link MenuItem}
- * @param isPasswordProtected flag is a password is present
- */
- public static void setupPasswordMenuItem(MenuItem password, boolean isPasswordProtected) {
- if (isPasswordProtected) {
- password.setTitle(R.string.share_password_title);
- } else {
- password.setTitle(R.string.share_no_password_title);
- }
- }
-
- /**
- * sets up the expiration date {@link MenuItem}'s title based on the fact if an expiration date is present.
- *
- * @param expirationDate the expiration date {@link MenuItem}
- * @param expirationDateValue the expiration date
- * @param res Resources to load the corresponding strings.
- */
- public static void setupExpirationDateMenuItem(MenuItem expirationDate, long expirationDateValue, Resources res) {
- if (expirationDateValue > 0) {
- expirationDate.setTitle(res.getString(
- R.string.share_expiration_date_label,
- SimpleDateFormat.getDateInstance().format(new Date(expirationDateValue))
- ));
- } else {
- expirationDate.setTitle(R.string.share_no_expiration_date_label);
- }
- }
-
/**
* sets up the {@link SearchView}.
*
diff --git a/src/main/java/com/owncloud/android/ui/fragment/util/SharingMenuHelper.java b/src/main/java/com/owncloud/android/ui/fragment/util/SharingMenuHelper.java
new file mode 100644
index 000000000000..454a33d9dfe9
--- /dev/null
+++ b/src/main/java/com/owncloud/android/ui/fragment/util/SharingMenuHelper.java
@@ -0,0 +1,97 @@
+/*
+ * Nextcloud Android client application
+ *
+ * @author Andy Scherzinger
+ * Copyright (C) 2018 Andy Scherzinger
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or 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 AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this program. If not, see .
+ */
+
+package com.owncloud.android.ui.fragment.util;
+
+import android.app.SearchManager;
+import android.content.ComponentName;
+import android.content.res.Resources;
+import android.support.v7.widget.SearchView;
+import android.view.MenuItem;
+import android.view.inputmethod.EditorInfo;
+
+import com.owncloud.android.R;
+import com.owncloud.android.lib.resources.shares.OCShare;
+import com.owncloud.android.lib.resources.status.OCCapability;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Helper calls for visibility logic of the sharing menu.
+ */
+public class SharingMenuHelper {
+
+ /**
+ * Sets checked/visiblity state on the given {@link MenuItem} based on the given criteria.
+ *
+ * @param fileListing the {@link MenuItem} to be setup
+ * @param isFolder flag if it is a folder
+ * @param isEditingAllowed flag if editing is allowed
+ * @param publicSharePermissions share permissions of the link
+ */
+ public static void setupHideFileListingMenuItem(MenuItem fileListing,
+ boolean isFolder,
+ boolean isEditingAllowed,
+ int publicSharePermissions) {
+ if (!isFolder) {
+ fileListing.setVisible(false);
+ } else {
+ if (isEditingAllowed) {
+ boolean readOnly = (publicSharePermissions & OCShare.READ_PERMISSION_FLAG) != 0;
+ fileListing.setChecked(!readOnly);
+ } else {
+ fileListing.setVisible(false);
+ }
+ }
+ }
+
+ /**
+ * sets up the password {@link MenuItem}'s title based on the fact if a password is present.
+ *
+ * @param password the password {@link MenuItem}
+ * @param isPasswordProtected flag is a password is present
+ */
+ public static void setupPasswordMenuItem(MenuItem password, boolean isPasswordProtected) {
+ if (isPasswordProtected) {
+ password.setTitle(R.string.share_password_title);
+ } else {
+ password.setTitle(R.string.share_no_password_title);
+ }
+ }
+
+ /**
+ * sets up the expiration date {@link MenuItem}'s title based on the fact if an expiration date is present.
+ *
+ * @param expirationDate the expiration date {@link MenuItem}
+ * @param expirationDateValue the expiration date
+ * @param res Resources to load the corresponding strings.
+ */
+ public static void setupExpirationDateMenuItem(MenuItem expirationDate, long expirationDateValue, Resources res) {
+ if (expirationDateValue > 0) {
+ expirationDate.setTitle(res.getString(
+ R.string.share_expiration_date_label,
+ SimpleDateFormat.getDateInstance().format(new Date(expirationDateValue))
+ ));
+ } else {
+ expirationDate.setTitle(R.string.share_no_expiration_date_label);
+ }
+ }
+}
diff --git a/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java b/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java
index a28671ba905f..162a1e432414 100755
--- a/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java
+++ b/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java
@@ -518,6 +518,26 @@ public void setPasswordToShareViaLink(OCFile file, String password) {
queueShareIntent(updateShareIntent);
}
+ /**
+ * Updates a share on a file to set its password.
+ * Starts a request to do it in {@link OperationsService}
+ *
+ * @param share File which 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
+ */
+ public void setPasswordToShare(OCShare share, String password) {
+ Intent updateShareIntent = new Intent(mFileActivity, OperationsService.class);
+ updateShareIntent.setAction(OperationsService.ACTION_UPDATE_SHARE);
+ updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ 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 expiration date.
diff --git a/src/main/res/drawable/ic_send.xml b/src/main/res/drawable/ic_send.xml
new file mode 100644
index 000000000000..ac92970db186
--- /dev/null
+++ b/src/main/res/drawable/ic_send.xml
@@ -0,0 +1,23 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/main/res/layout/file_details_activities_fragment.xml b/src/main/res/layout/file_details_activities_fragment.xml
index ca619eecbf38..15cf11a07295 100644
--- a/src/main/res/layout/file_details_activities_fragment.xml
+++ b/src/main/res/layout/file_details_activities_fragment.xml
@@ -29,14 +29,57 @@
android:layout_width="match_parent"
android:visibility="visible">
-
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/res/menu/file_detail_sharing_link_menu.xml b/src/main/res/menu/file_detail_sharing_link_menu.xml
index 5d41d9d4ac10..c4d438322d79 100644
--- a/src/main/res/menu/file_detail_sharing_link_menu.xml
+++ b/src/main/res/menu/file_detail_sharing_link_menu.xml
@@ -23,18 +23,18 @@
tools:ignore="AppCompatResource">
diff --git a/src/main/res/menu/file_detail_sharing_menu.xml b/src/main/res/menu/file_detail_sharing_menu.xml
index 7f05cc42ac7c..2349e50cad00 100644
--- a/src/main/res/menu/file_detail_sharing_menu.xml
+++ b/src/main/res/menu/file_detail_sharing_menu.xml
@@ -46,6 +46,17 @@
android:showAsAction="never"
android:title="@string/share_privilege_can_share"
app:showAsAction="never" />
+
+
- Adding sharee failed
Unsharing failed
Updating share failed
+ New comment…