+ /**
+ * Show an instance of {@link ShareType} for sharing or unsharing the {@OCFile} received as parameter.
+ *
+ * @param file File to share or unshare.
+ */
+ public void showShareFile(OCFile file){
+ Intent intent = new Intent(mFileActivity, ShareActivity.class);
+ intent.putExtra(mFileActivity.EXTRA_FILE, file);
+ intent.putExtra(mFileActivity.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ mFileActivity.startActivity(intent);
+
+ }
+
+
+ /**
+ * Starts a dialog that requests a password to the user to protect a share link.
+ *
+ * @param file File which public share will be protected by the requested password
+ */
+ public void requestPasswordForShareViaLink(OCFile file) {
+ SharePasswordDialogFragment dialog =
+ SharePasswordDialogFragment.newInstance(
+ file,
+ null
+ );
+ dialog.show(
+ mFileActivity.getSupportFragmentManager(),
+ SharePasswordDialogFragment.PASSWORD_FRAGMENT
+ );
+ }
+
+ /**
+ * 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
+ */
+ public void setPasswordToShareViaLink(OCFile file, String password) {
+ // Set password updating share
+ Intent updateShareIntent = new Intent(mFileActivity, OperationsService.class);
+ updateShareIntent.setAction(OperationsService.ACTION_UPDATE_SHARE);
+ updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ updateShareIntent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
+ 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}
+ *
+ * @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.
+ */
+ public void setExpirationDateToShareViaLink(OCFile file, long expirationTimeInMillis) {
+ Intent updateShareIntent = new Intent(mFileActivity, OperationsService.class);
+ updateShareIntent.setAction(OperationsService.ACTION_UPDATE_SHARE);
+ updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ updateShareIntent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
+ updateShareIntent.putExtra(
+ OperationsService.EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS,
+ expirationTimeInMillis
+ );
+ queueShareIntent(updateShareIntent);
+ }
+
+
+ /**
+ * @return 'True' if the server supports the Search Users API
+ */
+ public boolean isSearchUsersSupportedSupported() {
+ if (mFileActivity.getAccount() != null) {
+ OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mFileActivity.getAccount());
+ return (serverVersion != null && serverVersion.isSearchUsersSupported());
+ }
+ return false;
+ }
+