浏览代码

Combined ShareActivity with FileDetailSharingFragment as much as possible

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 4 年之前
父节点
当前提交
7732ff065b
共有 19 个文件被更改,包括 338 次插入2214 次删除
  1. 1 1
      scripts/analysis/lint-results.txt
  2. 1 1
      src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java
  3. 199 4
      src/main/java/com/owncloud/android/ui/activity/FileActivity.java
  4. 0 167
      src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java
  5. 2 1
      src/main/java/com/owncloud/android/ui/activity/PassCodeActivity.java
  6. 3 2
      src/main/java/com/owncloud/android/ui/activity/RichDocumentsEditorWebView.java
  7. 52 271
      src/main/java/com/owncloud/android/ui/activity/ShareActivity.java
  8. 0 136
      src/main/java/com/owncloud/android/ui/adapter/ShareUserListAdapter.java
  9. 5 2
      src/main/java/com/owncloud/android/ui/decoration/SimpleListItemDividerDecoration.java
  10. 22 17
      src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java
  11. 0 237
      src/main/java/com/owncloud/android/ui/fragment/SearchShareesFragment.java
  12. 0 858
      src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java
  13. 0 41
      src/main/java/com/owncloud/android/ui/fragment/ShareFragmentListener.java
  14. 2 1
      src/main/java/com/owncloud/android/ui/preview/FileDownloadFragment.java
  15. 0 42
      src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java
  16. 0 96
      src/main/java/com/owncloud/android/utils/GetShareWithUsersAsyncTask.java
  17. 51 4
      src/main/res/layout/share_activity.xml
  18. 0 326
      src/main/res/layout/share_file_layout.xml
  19. 0 7
      src/main/res/values/strings.xml

+ 1 - 1
scripts/analysis/lint-results.txt

@@ -1,2 +1,2 @@
 DO NOT TOUCH; GENERATED BY DRONE
-      <span class="mdl-layout-title">Lint Report: 92 warnings</span>
+      <span class="mdl-layout-title">Lint Report: 91 warnings</span>

+ 1 - 1
src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java

@@ -814,7 +814,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
      * See {@link super#onSaveInstanceState(Bundle)}
      */
     @Override
-    protected void onSaveInstanceState(Bundle outState) {
+    protected void onSaveInstanceState(@NonNull Bundle outState) {
         //Log_OC.e(TAG, "onSaveInstanceState init" );
         super.onSaveInstanceState(outState);
 

+ 199 - 4
src/main/java/com/owncloud/android/ui/activity/FileActivity.java

@@ -36,6 +36,7 @@ import android.net.Uri;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.IBinder;
+import android.text.TextUtils;
 
 import com.google.android.material.snackbar.Snackbar;
 import com.nextcloud.client.account.UserAccountManager;
@@ -60,13 +61,18 @@ import com.owncloud.android.lib.common.operations.RemoteOperation;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
 import com.owncloud.android.lib.common.utils.Log_OC;
+import com.owncloud.android.lib.resources.shares.OCShare;
+import com.owncloud.android.lib.resources.shares.ShareType;
+import com.owncloud.android.operations.CreateShareViaLinkOperation;
 import com.owncloud.android.operations.CreateShareWithShareeOperation;
 import com.owncloud.android.operations.GetSharesForFileOperation;
 import com.owncloud.android.operations.SynchronizeFileOperation;
 import com.owncloud.android.operations.SynchronizeFolderOperation;
 import com.owncloud.android.operations.UnshareOperation;
+import com.owncloud.android.operations.UpdateNoteForShareOperation;
 import com.owncloud.android.operations.UpdateSharePermissionsOperation;
 import com.owncloud.android.operations.UpdateShareViaLinkOperation;
+import com.owncloud.android.providers.UsersAndGroupsSearchProvider;
 import com.owncloud.android.services.OperationsService;
 import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
 import com.owncloud.android.ui.asynctasks.CheckRemoteWipeTask;
@@ -75,6 +81,8 @@ import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
 import com.owncloud.android.ui.dialog.LoadingDialog;
 import com.owncloud.android.ui.dialog.ShareLinkToDialog;
 import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;
+import com.owncloud.android.ui.fragment.FileDetailFragment;
+import com.owncloud.android.ui.fragment.FileDetailSharingFragment;
 import com.owncloud.android.ui.helpers.FileOperationsHelper;
 import com.owncloud.android.utils.ClipboardUtil;
 import com.owncloud.android.utils.DisplayUtils;
@@ -83,15 +91,21 @@ import com.owncloud.android.utils.FilesSyncHelper;
 import com.owncloud.android.utils.ThemeUtils;
 
 import java.lang.ref.WeakReference;
+import java.util.ArrayList;
 
 import javax.inject.Inject;
 
 import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.StringRes;
 import androidx.fragment.app.DialogFragment;
 import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentManager;
 import androidx.fragment.app.FragmentTransaction;
 
+import static com.owncloud.android.ui.activity.FileDisplayActivity.TAG_PUBLIC_LINK;
+import static com.owncloud.android.ui.activity.FileDisplayActivity.TAG_SECOND_FRAGMENT;
+
 
 /**
  * Activity with common behaviour for activities handling {@link OCFile}s in ownCloud {@link Account}s .
@@ -376,11 +390,26 @@ public abstract class FileActivity extends DrawerActivity
                 updateFileFromDB();
 
             } else {
-                DisplayUtils.showSnackMessage(
-                        this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
-                );
+                DisplayUtils.showSnackMessage(this,
+                                              ErrorMessageAdapter.getErrorCauseMessage(result,
+                                                                                       operation,
+                                                                                       getResources()));
             }
         }
+
+        if (operation instanceof CreateShareViaLinkOperation) {
+            onCreateShareViaLinkOperationFinish((CreateShareViaLinkOperation) operation, result);
+        } else if (operation instanceof CreateShareWithShareeOperation) {
+            onUpdateShareInformation(result, R.string.sharee_add_failed);
+        } else if (operation instanceof UpdateShareViaLinkOperation) {
+            onUpdateShareInformation(result, R.string.updating_share_failed);
+        } else if (operation instanceof UpdateSharePermissionsOperation) {
+            onUpdateShareInformation(result, R.string.updating_share_failed);
+        } else if (operation instanceof UnshareOperation) {
+            onUpdateShareInformation(result, R.string.unsharing_failed);
+        } else if (operation instanceof UpdateNoteForShareOperation) {
+            onUpdateNoteForShareOperationFinish(result);
+        }
     }
 
     /**
@@ -708,7 +737,8 @@ public abstract class FileActivity extends DrawerActivity
 
         if (username != null) {
             intentToShareLink.putExtra(Intent.EXTRA_SUBJECT,
-                                       activity.getString(R.string.subject_user_shared_with_you, username,
+                                       activity.getString(R.string.subject_user_shared_with_you,
+                                                          username,
                                                           file.getFileName()));
         } else {
             intentToShareLink.putExtra(Intent.EXTRA_SUBJECT,
@@ -720,4 +750,169 @@ public abstract class FileActivity extends DrawerActivity
         DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intentToShareLink, packagesToExclude);
         chooserDialog.show(activity.getSupportFragmentManager(), FileDisplayActivity.FTAG_CHOOSER_DIALOG);
     }
+
+    private void onUpdateNoteForShareOperationFinish(RemoteOperationResult result) {
+        FileDetailSharingFragment sharingFragment = getShareFileFragment();
+
+        if (result.isSuccess()) {
+            if (sharingFragment != null) {
+                sharingFragment.refreshPublicShareFromDB();
+                sharingFragment.onUpdateShareInformation(result, getFile());
+            }
+        } else {
+            DisplayUtils.showSnackMessage(this, R.string.note_could_not_sent);
+        }
+    }
+
+    private void onUpdateShareInformation(RemoteOperationResult result, @StringRes int defaultError) {
+        Snackbar snackbar;
+        FileDetailSharingFragment sharingFragment = getShareFileFragment();
+
+        if (result.isSuccess()) {
+            updateFileFromDB();
+            if (sharingFragment != null) {
+                sharingFragment.onUpdateShareInformation(result, getFile());
+            }
+        } else if (sharingFragment != null && sharingFragment.getView() != null) {
+            String errorResponse;
+
+            if (result.getData() != null && result.getData().size() > 0) {
+                errorResponse = result.getData().get(0).toString();
+            } else {
+                errorResponse = "";
+            }
+
+            if (!TextUtils.isEmpty(errorResponse)) {
+                snackbar = Snackbar.make(sharingFragment.getView(), errorResponse, Snackbar.LENGTH_LONG);
+            } else {
+                snackbar = Snackbar.make(sharingFragment.getView(), defaultError, Snackbar.LENGTH_LONG);
+            }
+
+            ThemeUtils.colorSnackbar(this, snackbar);
+            snackbar.show();
+        }
+    }
+
+    private void onCreateShareViaLinkOperationFinish(CreateShareViaLinkOperation operation,
+                                                     RemoteOperationResult result) {
+        FileDetailSharingFragment sharingFragment = getShareFileFragment();
+
+        if (result.isSuccess()) {
+            updateFileFromDB();
+
+            // if share to user and share via link multiple ocshares are returned,
+            // therefore filtering for public_link
+            String link = "";
+            OCFile file = null;
+            for (Object object : result.getData()) {
+                OCShare shareLink = (OCShare) object;
+                if (TAG_PUBLIC_LINK.equalsIgnoreCase(shareLink.getShareType().name())) {
+                    link = shareLink.getShareLink();
+                    file = getStorageManager().getFileByPath(shareLink.getPath());
+                    break;
+                }
+            }
+
+            copyAndShareFileLink(this, file, link);
+
+            if (sharingFragment != null) {
+                sharingFragment.refreshPublicShareFromDB();
+                sharingFragment.onUpdateShareInformation(result, getFile());
+            }
+        } else {
+            // Detect Failure (403) --> maybe needs password
+            String password = operation.getPassword();
+            if (result.getCode() == RemoteOperationResult.ResultCode.SHARE_FORBIDDEN &&
+                TextUtils.isEmpty(password) &&
+                getCapabilities().getFilesSharingPublicEnabled().isUnknown()) {
+                // Was tried without password, but not sure that it's optional.
+
+                // Try with password before giving up; see also ShareFileFragment#OnShareViaLinkListener
+                if (sharingFragment != null && sharingFragment.isAdded()) { // only if added to the view hierarchy
+
+                    sharingFragment.requestPasswordForShareViaLink(true,
+                                                                   getCapabilities().getFilesSharingPublicAskForOptionalPassword()
+                                                                       .isTrue());
+                }
+
+            } else {
+                if (sharingFragment != null) {
+                    sharingFragment.refreshPublicShareFromDB();
+                }
+                Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content),
+                                                  ErrorMessageAdapter.getErrorCauseMessage(result,
+                                                                                           operation,
+                                                                                           getResources()),
+                                                  Snackbar.LENGTH_LONG);
+                ThemeUtils.colorSnackbar(this, snackbar);
+                snackbar.show();
+            }
+        }
+    }
+
+    /**
+     * Shortcut to get access to the {@link FileDetailSharingFragment} instance, if any
+     *
+     * @return A {@link FileDetailSharingFragment} instance, or null
+     */
+    private @Nullable
+    FileDetailSharingFragment getShareFileFragment() {
+        Fragment fragment = getSupportFragmentManager().findFragmentByTag(ShareActivity.TAG_SHARE_FRAGMENT);
+
+        if (fragment == null) {
+            fragment = getSupportFragmentManager().findFragmentByTag(TAG_SECOND_FRAGMENT);
+        }
+
+        if (fragment instanceof FileDetailSharingFragment) {
+            return (FileDetailSharingFragment) fragment;
+        } else if (fragment instanceof FileDetailFragment) {
+            FileDetailFragment fileDetailFragment = (FileDetailFragment) fragment;
+            return fileDetailFragment.getFileDetailSharingFragment();
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    protected void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
+
+        if (UsersAndGroupsSearchProvider.ACTION_SHARE_WITH.equals(intent.getAction())) {
+            Uri data = intent.getData();
+            String dataString = intent.getDataString();
+            String shareWith = dataString.substring(dataString.lastIndexOf('/') + 1);
+
+            ArrayList<String> existingSharees = new ArrayList<>();
+            for (OCShare share : getStorageManager().getSharesWithForAFile(getFile().getRemotePath(),
+                                                                           getAccount().name)) {
+                existingSharees.add(share.getShareType() + "_" + share.getShareWith());
+            }
+
+            String dataAuthority = data.getAuthority();
+            ShareType shareType = UsersAndGroupsSearchProvider.getShareType(dataAuthority);
+
+            if (!existingSharees.contains(shareType + "_" + shareWith)) {
+                doShareWith(shareWith, shareType);
+            }
+        }
+    }
+
+    private void doShareWith(String shareeName, ShareType shareType) {
+        getFileOperationsHelper().shareFileWithSharee(getFile(),
+                                                      shareeName,
+                                                      shareType,
+                                                      getAppropriatePermissions(shareType));
+    }
+
+    private int getAppropriatePermissions(ShareType shareType) {
+        if (getFile().isSharedWithMe()) {
+            return OCShare.READ_PERMISSION_FLAG;    // minimum permissions
+        } else if (ShareType.FEDERATED.equals(shareType)) {
+            return getFile().isFolder() ? OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 :
+                OCShare.FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9;
+        } else {
+            return getFile().isFolder() ? OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER :
+                OCShare.MAXIMUM_PERMISSIONS_FOR_FILE;
+        }
+    }
 }

+ 0 - 167
src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -38,7 +38,6 @@ import android.content.IntentFilter;
 import android.content.ServiceConnection;
 import android.content.pm.PackageManager;
 import android.content.res.Resources.NotFoundException;
-import android.net.Uri;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.os.Parcelable;
@@ -74,24 +73,15 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCo
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.resources.files.RestoreFileVersionRemoteOperation;
 import com.owncloud.android.lib.resources.files.SearchRemoteOperation;
-import com.owncloud.android.lib.resources.shares.OCShare;
-import com.owncloud.android.lib.resources.shares.ShareType;
 import com.owncloud.android.lib.resources.status.OwnCloudVersion;
 import com.owncloud.android.operations.CopyFileOperation;
 import com.owncloud.android.operations.CreateFolderOperation;
-import com.owncloud.android.operations.CreateShareViaLinkOperation;
-import com.owncloud.android.operations.CreateShareWithShareeOperation;
 import com.owncloud.android.operations.MoveFileOperation;
 import com.owncloud.android.operations.RefreshFolderOperation;
 import com.owncloud.android.operations.RemoveFileOperation;
 import com.owncloud.android.operations.RenameFileOperation;
 import com.owncloud.android.operations.SynchronizeFileOperation;
-import com.owncloud.android.operations.UnshareOperation;
-import com.owncloud.android.operations.UpdateNoteForShareOperation;
-import com.owncloud.android.operations.UpdateSharePermissionsOperation;
-import com.owncloud.android.operations.UpdateShareViaLinkOperation;
 import com.owncloud.android.operations.UploadFileOperation;
-import com.owncloud.android.providers.UsersAndGroupsSearchProvider;
 import com.owncloud.android.syncadapter.FileSyncAdapter;
 import com.owncloud.android.ui.asynctasks.CheckAvailableSpaceTask;
 import com.owncloud.android.ui.asynctasks.FetchRemoteFileTask;
@@ -140,7 +130,6 @@ import javax.annotation.Nullable;
 import javax.inject.Inject;
 
 import androidx.annotation.NonNull;
-import androidx.annotation.StringRes;
 import androidx.appcompat.app.AlertDialog;
 import androidx.appcompat.widget.SearchView;
 import androidx.core.view.MenuItemCompat;
@@ -530,24 +519,6 @@ public class FileDisplayActivity extends FileActivity
                         transaction.commit();
                     }
                 }
-            } else if (UsersAndGroupsSearchProvider.ACTION_SHARE_WITH.equals(intent.getAction())) {
-                Uri data = intent.getData();
-                String dataString = intent.getDataString();
-                String shareWith = dataString.substring(dataString.lastIndexOf('/') + 1);
-
-                ArrayList<String> existingSharees = new ArrayList<>();
-                for (OCShare share : getStorageManager().getSharesWithForAFile(getFile().getRemotePath(),
-                                                                               getAccount().name)) {
-                    existingSharees.add(share.getShareType() + "_" + share.getShareWith());
-                }
-
-                String dataAuthority = data.getAuthority();
-                ShareType shareType = UsersAndGroupsSearchProvider.getShareType(dataAuthority);
-
-                if (!existingSharees.contains(shareType + "_" + shareWith)) {
-                    doShareWith(shareWith, shareType);
-                }
-
             } else if (ALL_FILES.equals(intent.getAction())) {
                 Log_OC.d(this, "Switch to oc file fragment");
 
@@ -558,28 +529,6 @@ public class FileDisplayActivity extends FileActivity
             }
     }
 
-    private void doShareWith(String shareeName, ShareType shareType) {
-        getFileOperationsHelper().shareFileWithSharee(getFile(), shareeName, shareType,
-                                                      getAppropriatePermissions(shareType));
-    }
-
-    private int getAppropriatePermissions(ShareType shareType) {
-
-        // check if the Share is FEDERATED
-        boolean isFederated = ShareType.FEDERATED.equals(shareType);
-
-        if (getFile().isSharedWithMe()) {
-            return OCShare.READ_PERMISSION_FLAG;    // minimum permissions
-
-        } else if (isFederated) {
-            return getFile().isFolder() ? OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 :
-                    OCShare.FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9;
-        } else {
-            return getFile().isFolder() ? OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER :
-                    OCShare.MAXIMUM_PERMISSIONS_FOR_FILE;
-        }
-    }
-
     private Fragment chooseInitialSecondFragment(OCFile file) {
         Fragment secondFragment = null;
         if (file != null && !file.isFolder()) {
@@ -1695,20 +1644,8 @@ public class FileDisplayActivity extends FileActivity
             onMoveFileOperationFinish((MoveFileOperation) operation, result);
         } else if (operation instanceof CopyFileOperation) {
             onCopyFileOperationFinish((CopyFileOperation) operation, result);
-        } else if (operation instanceof CreateShareViaLinkOperation) {
-            onCreateShareViaLinkOperationFinish((CreateShareViaLinkOperation) operation, result);
-        } else if (operation instanceof CreateShareWithShareeOperation) {
-            onUpdateShareInformation(result, R.string.sharee_add_failed);
-        } else if (operation instanceof UpdateShareViaLinkOperation) {
-            onUpdateShareInformation(result, R.string.updating_share_failed);
-        } else if (operation instanceof UpdateSharePermissionsOperation) {
-            onUpdateShareInformation(result, R.string.updating_share_failed);
-        } else if (operation instanceof UnshareOperation) {
-            onUpdateShareInformation(result, R.string.unsharing_failed);
         } else if (operation instanceof RestoreFileVersionRemoteOperation) {
             onRestoreFileVersionOperationFinish(result);
-        } else if (operation instanceof UpdateNoteForShareOperation) {
-            onUpdateNoteForShareOperationFinish(result);
         }
     }
 
@@ -1833,110 +1770,6 @@ public class FileDisplayActivity extends FileActivity
         }
     }
 
-    private void onCreateShareViaLinkOperationFinish(CreateShareViaLinkOperation operation,
-                                                     RemoteOperationResult result) {
-        FileDetailFragment fileDetailFragment = getShareFileFragment();
-        if (result.isSuccess()) {
-            updateFileFromDB();
-
-            // if share to user and share via link multiple ocshares are returned,
-            // therefore filtering for public_link
-            String link = "";
-            OCFile file = null;
-            for (Object object : result.getData()) {
-                OCShare shareLink = (OCShare) object;
-                if (TAG_PUBLIC_LINK.equalsIgnoreCase(shareLink.getShareType().name())) {
-                    link = shareLink.getShareLink();
-                    file = getStorageManager().getFileByPath(shareLink.getPath());
-                    break;
-                }
-            }
-
-            copyAndShareFileLink(this, file, link);
-
-            if (fileDetailFragment != null && fileDetailFragment.getFileDetailSharingFragment() != null) {
-                fileDetailFragment.getFileDetailSharingFragment().refreshPublicShareFromDB();
-                fileDetailFragment.getFileDetailSharingFragment().onUpdateShareInformation(result, getFile());
-            }
-            updateListOfFilesFragment(false);
-        } else {
-            // Detect Failure (403) --> maybe needs password
-            String password = operation.getPassword();
-            if (result.getCode() == RemoteOperationResult.ResultCode.SHARE_FORBIDDEN    &&
-                    TextUtils.isEmpty(password)                                         &&
-                    getCapabilities().getFilesSharingPublicEnabled().isUnknown()) {
-                // Was tried without password, but not sure that it's optional.
-
-                // Try with password before giving up; see also ShareFileFragment#OnShareViaLinkListener
-                if (fileDetailFragment != null && fileDetailFragment.isAdded()) { // only if added to the view hierarchy
-
-                    fileDetailFragment
-                        .getFileDetailSharingFragment()
-                        .requestPasswordForShareViaLink(true,
-                                                        getCapabilities().getFilesSharingPublicAskForOptionalPassword()
-                                                            .isTrue());
-                }
-
-            } else {
-                if (fileDetailFragment != null && fileDetailFragment.getFileDetailSharingFragment() != null) {
-                    fileDetailFragment.getFileDetailSharingFragment().refreshPublicShareFromDB();
-                }
-                Snackbar snackbar = Snackbar.make(
-                        binding.getRoot(),
-                        ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
-                        Snackbar.LENGTH_LONG
-                );
-                ThemeUtils.colorSnackbar(this, snackbar);
-                snackbar.show();
-            }
-        }
-    }
-
-    private void onUpdateNoteForShareOperationFinish(RemoteOperationResult result) {
-        FileDetailFragment fileDetailFragment = getShareFileFragment();
-
-        if (result.isSuccess()) {
-            if (fileDetailFragment != null && fileDetailFragment.getFileDetailSharingFragment() != null) {
-                fileDetailFragment.getFileDetailSharingFragment().refreshPublicShareFromDB();
-                fileDetailFragment.getFileDetailSharingFragment().onUpdateShareInformation(result, getFile());
-            }
-        } else {
-            DisplayUtils.showSnackMessage(this, R.string.note_could_not_sent);
-        }
-    }
-
-    private void onUpdateShareInformation(RemoteOperationResult result, @StringRes int defaultError) {
-        Snackbar snackbar;
-        Fragment fileDetailFragment = getSecondFragment();
-
-        if (result.isSuccess()) {
-            updateFileFromDB();
-            updateListOfFilesFragment(false);
-        } else if (fileDetailFragment != null && fileDetailFragment.getView() != null) {
-            String errorResponse;
-
-            if (result.getData() != null && result.getData().size() > 0) {
-                errorResponse = result.getData().get(0).toString();
-            } else {
-                errorResponse = "";
-            }
-
-            if (!TextUtils.isEmpty(errorResponse)) {
-                snackbar = Snackbar.make(fileDetailFragment.getView(), errorResponse, Snackbar.LENGTH_LONG);
-            } else {
-                snackbar = Snackbar.make(fileDetailFragment.getView(), defaultError, Snackbar.LENGTH_LONG);
-            }
-
-            ThemeUtils.colorSnackbar(this, snackbar);
-            snackbar.show();
-        }
-
-        if (fileDetailFragment instanceof FileDetailFragment) {
-            ((FileDetailFragment) fileDetailFragment).getFileDetailSharingFragment()
-                    .onUpdateShareInformation(result, getFile());
-        }
-    }
-
     /**
      * Shortcut to get access to the {@link FileDetailFragment} instance, if any
      *

+ 2 - 1
src/main/java/com/owncloud/android/ui/activity/PassCodeActivity.java

@@ -49,6 +49,7 @@ import java.util.Arrays;
 
 import javax.inject.Inject;
 
+import androidx.annotation.NonNull;
 import androidx.appcompat.app.AppCompatActivity;
 
 public class PassCodeActivity extends AppCompatActivity implements Injectable {
@@ -388,7 +389,7 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
 
 
     @Override
-    public void onSaveInstanceState(Bundle outState) {
+    public void onSaveInstanceState(@NonNull Bundle outState) {
         super.onSaveInstanceState(outState);
         outState.putBoolean(PassCodeActivity.KEY_CONFIRMING_PASSCODE, mConfirmingPassCode);
         outState.putStringArray(PassCodeActivity.KEY_PASSCODE_DIGITS, mPassCodeDigits);

+ 3 - 2
src/main/java/com/owncloud/android/ui/activity/RichDocumentsEditorWebView.java

@@ -61,6 +61,7 @@ import java.lang.ref.WeakReference;
 
 import javax.inject.Inject;
 
+import androidx.annotation.NonNull;
 import androidx.annotation.RequiresApi;
 import butterknife.ButterKnife;
 import butterknife.Unbinder;
@@ -193,13 +194,13 @@ public class RichDocumentsEditorWebView extends EditorWebView {
     }
 
     @Override
-    protected void onSaveInstanceState(Bundle outState) {
+    protected void onSaveInstanceState(@NonNull Bundle outState) {
         outState.putString(EXTRA_URL, url);
         super.onSaveInstanceState(outState);
     }
 
     @Override
-    public void onRestoreInstanceState(Bundle savedInstanceState) {
+    public void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
         url = savedInstanceState.getString(EXTRA_URL);
         super.onRestoreInstanceState(savedInstanceState);
     }

+ 52 - 271
src/main/java/com/owncloud/android/ui/activity/ShareActivity.java

@@ -21,68 +21,82 @@
 
 package com.owncloud.android.ui.activity;
 
-import android.app.SearchManager;
-import android.content.Intent;
-import android.net.Uri;
+import android.graphics.Bitmap;
+import android.graphics.PorterDuff;
 import android.os.Bundle;
-import android.text.TextUtils;
 
-import com.google.android.material.snackbar.Snackbar;
 import com.owncloud.android.R;
+import com.owncloud.android.databinding.ShareActivityBinding;
 import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.lib.common.OwnCloudAccount;
-import com.owncloud.android.lib.common.accounts.AccountUtils;
+import com.owncloud.android.datamodel.ThumbnailsCacheManager;
 import com.owncloud.android.lib.common.operations.RemoteOperation;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.common.utils.Log_OC;
-import com.owncloud.android.lib.resources.shares.OCShare;
-import com.owncloud.android.lib.resources.shares.ShareType;
-import com.owncloud.android.operations.CreateShareViaLinkOperation;
 import com.owncloud.android.operations.GetSharesForFileOperation;
-import com.owncloud.android.operations.UnshareOperation;
-import com.owncloud.android.operations.UpdateSharePermissionsOperation;
-import com.owncloud.android.providers.UsersAndGroupsSearchProvider;
-import com.owncloud.android.ui.dialog.ShareLinkToDialog;
-import com.owncloud.android.ui.fragment.EditShareFragment;
-import com.owncloud.android.ui.fragment.SearchShareesFragment;
-import com.owncloud.android.ui.fragment.ShareFileFragment;
-import com.owncloud.android.ui.fragment.ShareFragmentListener;
-import com.owncloud.android.utils.ErrorMessageAdapter;
-import com.owncloud.android.utils.GetShareWithUsersAsyncTask;
+import com.owncloud.android.ui.fragment.FileDetailSharingFragment;
+import com.owncloud.android.utils.DisplayUtils;
+import com.owncloud.android.utils.MimeTypeUtil;
+import com.owncloud.android.utils.ThemeUtils;
 
-import java.util.ArrayList;
-import java.util.Locale;
-
-import androidx.fragment.app.DialogFragment;
 import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentTransaction;
 
 /**
  * Activity for sharing files.
  */
-public class ShareActivity extends FileActivity implements ShareFragmentListener {
+public class ShareActivity extends FileActivity {
 
     private static final String TAG = ShareActivity.class.getSimpleName();
 
-    private static final String TAG_SHARE_FRAGMENT = "SHARE_FRAGMENT";
+    static final String TAG_SHARE_FRAGMENT = "SHARE_FRAGMENT";
     private static final String TAG_SEARCH_FRAGMENT = "SEARCH_USER_AND_GROUPS_FRAGMENT";
     private static final String TAG_EDIT_SHARE_FRAGMENT = "EDIT_SHARE_FRAGMENT";
-    private static final String TAG_PUBLIC_LINK = "PUBLIC_LINK";
-
-    /// Tags for dialog fragments
-    private static final String FTAG_CHOOSER_DIALOG = "CHOOSER_DIALOG";
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        setContentView(R.layout.share_activity);
+        ShareActivityBinding binding = ShareActivityBinding.inflate(getLayoutInflater());
+        setContentView(binding.getRoot());
+
+        OCFile file = getFile();
+
+        // Icon
+        if (file.isFolder()) {
+            binding.shareFileIcon.setImageDrawable(MimeTypeUtil.getFolderTypeIcon(file.isSharedWithMe() ||
+                                                                                      file.isSharedWithSharee(),
+                                                                                  file.isSharedViaLink(),
+                                                                                  file.isEncrypted(),
+                                                                                  file.getMountType(),
+                                                                                  this));
+        } else {
+            binding.shareFileIcon.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
+                                                                                file.getFileName(),
+                                                                                getAccount(),
+                                                                                this));
+            if (MimeTypeUtil.isImage(file)) {
+                String remoteId = String.valueOf(file.getRemoteId());
+                Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(remoteId);
+                if (thumbnail != null) {
+                    binding.shareFileIcon.setImageBitmap(thumbnail);
+                }
+            }
+        }
+
+        // Name
+        binding.shareFileName.setText(getResources().getString(R.string.share_file, file.getFileName()));
+
+        binding.shareHeaderDivider.getBackground().setColorFilter(ThemeUtils.primaryAccentColor(this),
+                                                                  PorterDuff.Mode.SRC_ATOP);
+
+        // Size
+        binding.shareFileSize.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
 
         FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
 
         if (savedInstanceState == null) {
             // Add Share fragment on first creation
-            Fragment fragment = ShareFileFragment.newInstance(getFile(), getAccount());
+            Fragment fragment = FileDetailSharingFragment.newInstance(getFile(), getAccount());
             ft.replace(R.id.share_fragment_container, fragment, TAG_SHARE_FRAGMENT);
             ft.commit();
         }
@@ -95,111 +109,6 @@ public class ShareActivity extends FileActivity implements ShareFragmentListener
         // Load data into the list
         Log_OC.d(TAG, "Refreshing lists on account set");
         refreshSharesFromStorageManager();
-
-        // Request for a refresh of the data through the server (starts an Async Task)
-        refreshUsersOrGroupsListFromServer();
-    }
-
-
-    @Override
-    protected void onNewIntent(Intent intent) {
-        // Verify the action and get the query
-        super.onNewIntent(intent);
-        if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
-            String query = intent.getStringExtra(SearchManager.QUERY);
-            Log_OC.w(TAG, "Ignored Intent requesting to query for " + query);
-
-        } else if (UsersAndGroupsSearchProvider.ACTION_SHARE_WITH.equals(intent.getAction())) {
-            Uri data = intent.getData();
-            String dataString = intent.getDataString();
-            String shareWith = dataString.substring(dataString.lastIndexOf('/') + 1);
-
-            ArrayList<String> shareeNames = new ArrayList<>();
-            for (OCShare share : getStorageManager().getSharesWithForAFile(getFile().getRemotePath(), getAccount().name)) {
-                shareeNames.add(share.getShareWith());
-            }
-
-            if (!shareeNames.contains(shareWith)) {
-
-                doShareWith(
-                    shareWith,
-                    data.getAuthority()
-                );
-            }
-
-        } else {
-            Log_OC.e(TAG, String.format(Locale.US, "Unexpected intent %s", intent));
-        }
-    }
-
-    private void doShareWith(String shareeName, String dataAuthority) {
-
-        ShareType shareType = UsersAndGroupsSearchProvider.getShareType(dataAuthority);
-
-        getFileOperationsHelper().shareFileWithSharee(
-                getFile(),
-                shareeName,
-                shareType,
-                getAppropiatePermissions(shareType)
-        );
-    }
-
-    private int getAppropiatePermissions(ShareType shareType) {
-
-        // check if the Share is FEDERATED
-        boolean isFederated = ShareType.FEDERATED.equals(shareType);
-
-        if (getFile().isSharedWithMe()) {
-            return OCShare.READ_PERMISSION_FLAG;    // minimum permissions
-
-        } else if (isFederated) {
-                return getFile().isFolder() ? OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 :
-                        OCShare.FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9;
-        } else {
-            return getFile().isFolder() ? OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER :
-                    OCShare.MAXIMUM_PERMISSIONS_FOR_FILE;
-        }
-    }
-
-
-    @Override
-    public void showSearchUsersAndGroups() {
-        // replace ShareFragment with SearchFragment on demand
-        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
-        Fragment searchFragment = SearchShareesFragment.newInstance(getFile(), getAccount());
-        ft.replace(R.id.share_fragment_container, searchFragment, TAG_SEARCH_FRAGMENT);
-        ft.addToBackStack(null);    // BACK button will recover the ShareFragment
-        ft.commit();
-    }
-
-    @Override
-    public void showEditShare(OCShare share) {
-        // replace current fragment with EditShareFragment on demand
-        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
-        Fragment editShareFragment = EditShareFragment.newInstance(share, getFile(), accountManager.getUser());
-        ft.replace(R.id.share_fragment_container, editShareFragment, TAG_EDIT_SHARE_FRAGMENT);
-        ft.addToBackStack(null);    // BACK button will recover the previous fragment
-        ft.commit();
-    }
-
-    @Override
-    // Call to Unshare operation
-    public void unshareWith(OCShare share) {
-        OCFile file = getFile();
-        getFileOperationsHelper().unshareFileWithUserOrGroup(file, share.getShareType(), share.getShareWith());
-    }
-
-    /**
-     * Get users and groups from the server to fill in the "share with" list
-     */
-    @Override
-    public void refreshUsersOrGroupsListFromServer() {
-        // Show loading
-        showLoadingDialog(getString(R.string.common_loading));
-        // Get Users and Groups
-        GetShareWithUsersAsyncTask getTask = new GetShareWithUsersAsyncTask(this);
-        Object[] params = {getFile(), getAccount(), getStorageManager()};
-        getTask.execute(params);
     }
 
     /**
@@ -221,20 +130,6 @@ public class ShareActivity extends FileActivity implements ShareFragmentListener
             Log_OC.d(TAG, "Refreshing view on successful operation or finished refresh");
             refreshSharesFromStorageManager();
         }
-
-        if (operation instanceof CreateShareViaLinkOperation) {
-            onCreateShareViaLinkOperationFinish((CreateShareViaLinkOperation) operation, result);
-        }
-
-        if (operation instanceof UnshareOperation && result.isSuccess() && getEditShareFragment() != null) {
-            getSupportFragmentManager().popBackStack();
-        }
-
-        if (operation instanceof UpdateSharePermissionsOperation
-                && getEditShareFragment() != null && getEditShareFragment().isAdded()) {
-            getEditShareFragment().onUpdateSharePermissionsFinished(result);
-        }
-
     }
 
     /**
@@ -242,135 +137,21 @@ public class ShareActivity extends FileActivity implements ShareFragmentListener
      */
     private void refreshSharesFromStorageManager() {
 
-        ShareFileFragment shareFileFragment = getShareFileFragment();
+        FileDetailSharingFragment shareFileFragment = getShareFileFragment();
         if (shareFileFragment != null
                 && shareFileFragment.isAdded()) {   // only if added to the view hierarchy!!
             shareFileFragment.refreshCapabilitiesFromDB();
-            shareFileFragment.refreshUsersOrGroupsListFromDB();
+            //shareFileFragment.refrefreshUsersOrGroupsListFromDB();
             shareFileFragment.refreshPublicShareFromDB();
         }
-
-        SearchShareesFragment searchShareesFragment = getSearchFragment();
-        if (searchShareesFragment != null &&
-                searchShareesFragment.isAdded()) {  // only if added to the view hierarchy!!
-            searchShareesFragment.refreshUsersOrGroupsListFromDB();
-        }
-
-        EditShareFragment editShareFragment = getEditShareFragment();
-        if (editShareFragment != null &&
-                editShareFragment.isAdded()) {
-            editShareFragment.refreshUiFromDB();
-        }
-    }
-
-    /**
-     * Shortcut to get access to the {@link ShareFileFragment} instance, if any
-     *
-     * @return A {@link ShareFileFragment} instance, or null
-     */
-    private ShareFileFragment getShareFileFragment() {
-        return (ShareFileFragment) getSupportFragmentManager().findFragmentByTag(TAG_SHARE_FRAGMENT);
     }
 
     /**
-     * Shortcut to get access to the {@link SearchShareesFragment} instance, if any
+     * Shortcut to get access to the {@link FileDetailSharingFragment} instance, if any
      *
-     * @return A {@link SearchShareesFragment} instance, or null
+     * @return A {@link FileDetailSharingFragment} instance, or null
      */
-    private SearchShareesFragment getSearchFragment() {
-        return (SearchShareesFragment) getSupportFragmentManager().findFragmentByTag(TAG_SEARCH_FRAGMENT);
-    }
-
-    /**
-     * Shortcut to get access to the {@link EditShareFragment} instance, if any
-     *
-     * @return A {@link EditShareFragment} instance, or null
-     */
-    private EditShareFragment getEditShareFragment() {
-        return (EditShareFragment) getSupportFragmentManager().findFragmentByTag(TAG_EDIT_SHARE_FRAGMENT);
-    }
-
-    private void onCreateShareViaLinkOperationFinish(CreateShareViaLinkOperation operation,
-                                                     RemoteOperationResult result) {
-        if (result.isSuccess()) {
-            updateFileFromDB();
-
-            // Create dialog to allow the user choose an app to send the link
-            Intent intentToShareLink = new Intent(Intent.ACTION_SEND);
-
-            // if share to user and share via link multiple ocshares are returned,
-            // therefore filtering for public_link
-            String link = "";
-            for (Object object : result.getData()) {
-                OCShare shareLink = (OCShare) object;
-                if (TAG_PUBLIC_LINK.equalsIgnoreCase(shareLink.getShareType().name())) {
-                    link = shareLink.getShareLink();
-                    break;
-                }
-            }
-
-            intentToShareLink.putExtra(Intent.EXTRA_TEXT, link);
-            intentToShareLink.setType("text/plain");
-
-            String username;
-            try {
-                OwnCloudAccount oca = new OwnCloudAccount(getAccount(), this);
-                if (oca.getDisplayName() != null && !oca.getDisplayName().isEmpty()) {
-                    username = oca.getDisplayName();
-                } else {
-                    username = AccountUtils.getUsernameForAccount(getAccount());
-                }
-            } catch (Exception e) {
-                username = AccountUtils.getUsernameForAccount(getAccount());
-            }
-
-            if (username != null) {
-                intentToShareLink.putExtra(
-                    Intent.EXTRA_SUBJECT,
-                    getString(
-                        R.string.subject_user_shared_with_you,
-                        username,
-                        getFile().getFileName()
-                    )
-                );
-            } else {
-                intentToShareLink.putExtra(
-                    Intent.EXTRA_SUBJECT,
-                    getString(
-                        R.string.subject_shared_with_you,
-                        getFile().getFileName()
-                    )
-                );
-            }
-
-            String[] packagesToExclude = new String[]{getPackageName()};
-            DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intentToShareLink, packagesToExclude);
-            chooserDialog.show(getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
-
-        } else {
-            // Detect Failure (403) --> maybe needs password
-            String password = operation.getPassword();
-            if (result.getCode() == RemoteOperationResult.ResultCode.SHARE_FORBIDDEN    &&
-                    TextUtils.isEmpty(password)                                         &&
-                    getCapabilities().getFilesSharingPublicEnabled().isUnknown()) {
-                    // Was tried without password, but not sure that it's optional.
-
-                // Try with password before giving up; see also ShareFileFragment#OnShareViaLinkListener
-                ShareFileFragment shareFileFragment = getShareFileFragment();
-                if (shareFileFragment != null && shareFileFragment.isAdded()) { // only if added to the view hierarchy!!
-
-                    boolean askForPassword = getCapabilities().getFilesSharingPublicAskForOptionalPassword().isTrue();
-
-                    shareFileFragment.requestPasswordForShareViaLink(true, askForPassword);
-                }
-
-            } else {
-                Snackbar.make(
-                        findViewById(android.R.id.content),
-                        ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
-                        Snackbar.LENGTH_LONG
-                ).show();
-            }
-        }
+    private FileDetailSharingFragment getShareFileFragment() {
+        return (FileDetailSharingFragment) getSupportFragmentManager().findFragmentByTag(TAG_SHARE_FRAGMENT);
     }
 }

+ 0 - 136
src/main/java/com/owncloud/android/ui/adapter/ShareUserListAdapter.java

@@ -1,136 +0,0 @@
-/*
- *   ownCloud Android client application
- *
- *   @author masensio
- *   Copyright (C) 2015 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   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 <http://www.gnu.org/licenses/>.
- *
- */
-
-package com.owncloud.android.ui.adapter;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.owncloud.android.R;
-import com.owncloud.android.lib.resources.shares.OCShare;
-import com.owncloud.android.ui.TextDrawable;
-
-import java.security.NoSuchAlgorithmException;
-import java.util.List;
-
-import androidx.annotation.DrawableRes;
-import androidx.annotation.NonNull;
-
-/**
- * Adapter to show a user/group in Share With List
- */
-public class ShareUserListAdapter extends ArrayAdapter {
-
-    private Context mContext;
-    private List<OCShare> mShares;
-    private ShareUserAdapterListener mListener;
-    private float mAvatarRadiusDimension;
-
-    public ShareUserListAdapter(Context context, int resource, List<OCShare> shares,
-                                ShareUserAdapterListener listener) {
-        super(context, resource);
-        mContext= context;
-        mShares = shares;
-        mListener = listener;
-
-        mAvatarRadiusDimension = context.getResources().getDimension(R.dimen.standard_padding);
-    }
-
-    @Override
-    public int getCount() {
-        return mShares.size();
-    }
-
-    @Override
-    public Object getItem(int position) {
-        return mShares.get(position);
-    }
-
-    @Override
-    public long getItemId(int position) {
-        return 0;
-    }
-
-    @NonNull
-    @Override
-    public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
-        View view = convertView;
-        if (view == null) {
-            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-            view = inflater.inflate(R.layout.share_user_item, parent, false);
-        }
-
-        if (mShares != null && mShares.size() > position) {
-            OCShare share = mShares.get(position);
-
-            TextView userName = view.findViewById(R.id.userOrGroupName);
-            ImageView icon = view.findViewById(R.id.icon);
-            final ImageView editShareButton = view.findViewById(R.id.editShareButton);
-            final ImageView unshareButton = view.findViewById(R.id.unshareButton);
-
-            String name = share.getSharedWithDisplayName();
-
-            switch (share.getShareType()) {
-                case GROUP:
-                    name = getContext().getString(R.string.share_group_clarification, name);
-                    setImage(icon, name, R.drawable.ic_group);
-                    break;
-                case EMAIL:
-                    name = getContext().getString(R.string.share_email_clarification, name);
-                    setImage(icon, name, R.drawable.ic_email);
-                    break;
-                case ROOM:
-                    name = getContext().getString(R.string.share_room_clarification, name);
-                    setImage(icon, name, R.drawable.ic_chat_bubble);
-                    break;
-                default:
-                    setImage(icon, name, R.drawable.ic_user);
-                    break;
-            }
-
-            userName.setText(name);
-
-            /// bind listener to edit privileges
-            editShareButton.setOnClickListener(v -> mListener.editShare(mShares.get(position)));
-
-            /// bind listener to unshare
-            unshareButton.setOnClickListener(v -> mListener.unshareButtonPressed(mShares.get(position)));
-        }
-        return view;
-    }
-
-    private void setImage(ImageView icon, String name, @DrawableRes int fallback) {
-        try {
-            icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
-        } catch (NoSuchAlgorithmException e) {
-            icon.setImageResource(fallback);
-        }
-    }
-
-    public interface ShareUserAdapterListener {
-        void unshareButtonPressed(OCShare share);
-        void editShare(OCShare share);
-    }
-}

+ 5 - 2
src/main/java/com/owncloud/android/ui/decoration/SimpleListItemDividerDecoration.java

@@ -71,8 +71,11 @@ public class SimpleListItemDividerDecoration extends DividerItemDecoration {
             parent.getDecoratedBoundsWithMargins(child, bounds);
             final int bottom = bounds.bottom + Math.round(child.getTranslationY());
             final int top = bottom - 1;
-            divider.setBounds(leftPadding, top, right, bottom);
-            divider.draw(canvas);
+
+            if (divider != null) {
+                divider.setBounds(leftPadding, top, right, bottom);
+                divider.draw(canvas);
+            }
         }
         canvas.restore();
     }

+ 22 - 17
src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java

@@ -100,7 +100,7 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
     private OCShare publicShare;
 
     private FileOperationsHelper fileOperationsHelper;
-    private FileDisplayActivity fileDisplayActivity;
+    private FileActivity fileActivity;
     private FileDataStorageManager fileDataStorageManager;
 
     private Unbinder unbinder;
@@ -182,9 +182,9 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
             throw new IllegalArgumentException("Account may not be null");
         }
 
-        fileDisplayActivity = (FileDisplayActivity) getActivity();
+        fileActivity = (FileActivity) getActivity();
 
-        if (fileDisplayActivity == null) {
+        if (fileActivity == null) {
             throw new IllegalArgumentException("FileActivity may not be null");
         }
     }
@@ -202,8 +202,8 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
         View view = inflater.inflate(R.layout.file_details_sharing_fragment, container, false);
         unbinder = ButterKnife.bind(this, view);
 
-        fileOperationsHelper = fileDisplayActivity.getFileOperationsHelper();
-        fileDataStorageManager = fileDisplayActivity.getStorageManager();
+        fileOperationsHelper = fileActivity.getFileOperationsHelper();
+        fileDataStorageManager = fileActivity.getStorageManager();
 
         setupView();
 
@@ -243,8 +243,8 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
             setShareByLinkInfo(file.isSharedViaLink());
             setShareWithUserInfo();
             FileDetailSharingFragmentHelper.setupSearchView(
-                (SearchManager) fileDisplayActivity.getSystemService(Context.SEARCH_SERVICE), searchView,
-                fileDisplayActivity.getComponentName());
+                (SearchManager) fileActivity.getSystemService(Context.SEARCH_SERVICE), searchView,
+                fileActivity.getComponentName());
             ThemeUtils.themeSearchView(searchView, requireContext());
         } else {
             searchView.setVisibility(View.GONE);
@@ -322,11 +322,16 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
         if (shares.size() > 0) {
             AccountManager accountManager = AccountManager.get(getContext());
             String userId = accountManager.getUserData(account,
-                com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
+                                                       com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
 
             usersList.setVisibility(View.VISIBLE);
-            usersList.setAdapter(new ShareeListAdapter(fileDisplayActivity.getSupportFragmentManager(),
-                                                       fileDisplayActivity, shares, account, file, this, userId));
+            usersList.setAdapter(new ShareeListAdapter(fileActivity.getSupportFragmentManager(),
+                                                       fileActivity,
+                                                       shares,
+                                                       account,
+                                                       file,
+                                                       this,
+                                                       userId));
             usersList.setLayoutManager(new LinearLayoutManager(getContext()));
             usersList.addItemDecoration(new SimpleListItemDividerDecoration(getContext()));
             noList.setVisibility(View.GONE);
@@ -354,7 +359,7 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
             return;
         }
 
-        FileDisplayActivity.showShareLinkDialog(fileDisplayActivity, file, createInternalLink(account, file));
+        FileDisplayActivity.showShareLinkDialog(fileActivity, file, createInternalLink(account, file));
     }
 
     private String createInternalLink(OwnCloudAccount account, OCFile file) {
@@ -379,7 +384,7 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
             if (TextUtils.isEmpty(file.getPublicLink())) {
                 fileOperationsHelper.getFileWithLink(file);
             } else {
-                FileDisplayActivity.showShareLinkDialog(fileDisplayActivity, file, file.getPublicLink());
+                FileDisplayActivity.showShareLinkDialog(fileActivity, file, file.getPublicLink());
             }
         }
     }
@@ -468,14 +473,14 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
                 ExpirationDatePickerDialogFragment dialog = ExpirationDatePickerDialogFragment
                     .newInstance(file, publicShare.getExpirationDate());
                 dialog.show(
-                    fileDisplayActivity.getSupportFragmentManager(),
-                        ExpirationDatePickerDialogFragment.DATE_PICKER_DIALOG
-                );
+                    fileActivity.getSupportFragmentManager(),
+                    ExpirationDatePickerDialogFragment.DATE_PICKER_DIALOG
+                           );
                 return true;
             }
             case R.id.action_share_send_link: {
                 if(shareByLink.isChecked() && file.isSharedViaLink() && !TextUtils.isEmpty(file.getPublicLink())) {
-                    FileDisplayActivity.showShareLinkDialog(fileDisplayActivity, file, file.getPublicLink());
+                    FileDisplayActivity.showShareLinkDialog(fileActivity, file, file.getPublicLink());
                 } else {
                     showSendLinkTo();
                 }
@@ -483,7 +488,7 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
             }
             case R.id.action_share_send_note:
                 NoteDialogFragment dialog = NoteDialogFragment.newInstance(publicShare);
-                dialog.show(fileDisplayActivity.getSupportFragmentManager(), NoteDialogFragment.NOTE_FRAGMENT);
+                dialog.show(fileActivity.getSupportFragmentManager(), NoteDialogFragment.NOTE_FRAGMENT);
                 return true;
             default:
                 return super.onOptionsItemSelected(item);

+ 0 - 237
src/main/java/com/owncloud/android/ui/fragment/SearchShareesFragment.java

@@ -1,237 +0,0 @@
-/**
- *   ownCloud Android client application
- *
- *   @author masensio
- *   @author David A. Velasco
- *   Copyright (C) 2015 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   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 <http://www.gnu.org/licenses/>.
- *
- */
-
-package com.owncloud.android.ui.fragment;
-
-import android.accounts.Account;
-import android.app.Activity;
-import android.app.SearchManager;
-import android.content.Context;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.ListView;
-
-import com.owncloud.android.R;
-import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.lib.common.utils.Log_OC;
-import com.owncloud.android.lib.resources.shares.OCShare;
-import com.owncloud.android.ui.activity.FileActivity;
-import com.owncloud.android.ui.adapter.ShareUserListAdapter;
-
-import java.util.List;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.widget.SearchView;
-import androidx.fragment.app.Fragment;
-
-/**
- * Fragment for Searching sharees (users and groups)
- *
- * A simple {@link Fragment} subclass.
- *
- * Activities that contain this fragment must implement the
- * {@link ShareFragmentListener} interface
- * to handle interaction events.
- *
- * Use the {@link SearchShareesFragment#newInstance} factory method to
- * create an instance of this fragment.
- */
-public class SearchShareesFragment extends Fragment implements ShareUserListAdapter.ShareUserAdapterListener {
-    private static final String TAG = SearchShareesFragment.class.getSimpleName();
-
-    // the fragment initialization parameters
-    private static final String ARG_FILE = "FILE";
-    private static final String ARG_ACCOUNT = "ACCOUNT";
-
-    // Parameters
-    private OCFile mFile;
-    private Account mAccount;
-
-    // other members
-    private List<OCShare> mShares;
-    private ShareFragmentListener mListener;
-
-
-    /**
-     * Public factory method to create new SearchShareesFragment instances.
-     *
-     * @param fileToShare   An {@link OCFile} to be shared
-     * @param account       The ownCloud account containing fileToShare
-     * @return A new instance of fragment SearchShareesFragment.
-     */
-    public static SearchShareesFragment newInstance(OCFile fileToShare, Account account) {
-        SearchShareesFragment fragment = new SearchShareesFragment();
-        Bundle args = new Bundle();
-        args.putParcelable(ARG_FILE, fileToShare);
-        args.putParcelable(ARG_ACCOUNT, account);
-        fragment.setArguments(args);
-        return fragment;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        if (getArguments() != null) {
-            mFile = getArguments().getParcelable(ARG_FILE);
-            mAccount = getArguments().getParcelable(ARG_ACCOUNT);
-        }
-
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-        // Inflate the layout for this fragment
-        View view = inflater.inflate(R.layout.search_users_groups_layout, container, false);
-
-        // Get the SearchView and set the searchable configuration
-        SearchView searchView = view.findViewById(R.id.searchView);
-        SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
-        searchView.setSearchableInfo(searchManager.getSearchableInfo(
-                getActivity().getComponentName())   // assumes parent activity is the searchable activity
-        );
-        searchView.setIconifiedByDefault(false);    // do not iconify the widget; expand it by default
-
-        searchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); // avoid fullscreen with softkeyboard
-
-        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
-            @Override
-            public boolean onQueryTextSubmit(String query) {
-                Log_OC.v(TAG, "onQueryTextSubmit intercepted, query: " + query);
-                return true;    // return true to prevent the query is processed to be queried;
-                // a user / group will be picked only if selected in the list of suggestions
-            }
-
-            @Override
-            public boolean onQueryTextChange(String newText) {
-                return false;   // let it for the parent listener in the hierarchy / default behaviour
-            }
-        });
-
-        return view;
-    }
-
-
-    @Override
-    public void onActivityCreated(Bundle savedInstanceState) {
-        super.onActivityCreated(savedInstanceState);
-
-        getActivity().setTitle(R.string.share_with_title);
-
-        // Load data into the list
-        refreshUsersOrGroupsListFromDB();
-    }
-
-
-    /**
-     * Get users and groups from the DB to fill in the "share with" list
-     *
-     * Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager}
-     * instance ready to use. If not ready, does nothing.
-     */
-    public void refreshUsersOrGroupsListFromDB (){
-        // Get Users and Groups
-        if (((FileActivity) mListener).getStorageManager() != null) {
-            mShares = ((FileActivity) mListener).getStorageManager().getSharesWithForAFile(
-                mFile.getRemotePath(),
-                mAccount.name
-            );
-
-            // Update list of users/groups
-            updateListOfUserGroups();
-        }
-    }
-
-    private void updateListOfUserGroups() {
-        // Update list of users/groups
-        // TODO Refactoring: create a new {@link ShareUserListAdapter} instance with every call should not be needed
-        ShareUserListAdapter userGroupsAdapter = new ShareUserListAdapter(
-                getActivity().getApplicationContext(),
-                R.layout.share_user_item, mShares, this
-        );
-
-        // Show data
-        ListView usersList = getView().findViewById(R.id.searchUsersListView);
-
-        if (mShares.size() > 0) {
-            usersList.setVisibility(View.VISIBLE);
-            usersList.setAdapter(userGroupsAdapter);
-
-        } else {
-            usersList.setVisibility(View.GONE);
-        }
-    }
-
-    @Override
-    public void onAttach(Activity activity) {
-        super.onAttach(activity);
-        try {
-            mListener = (ShareFragmentListener) activity;
-        } catch (ClassCastException e) {
-            throw new IllegalArgumentException(activity.toString()
-                    + " must implement OnFragmentInteractionListener", e);
-        }
-    }
-
-    @Override
-    public void onStart() {
-        super.onStart();
-        // focus the search view and request the software keyboard be shown
-        View searchView = getView().findViewById(R.id.searchView);
-        if (searchView.requestFocus()) {
-            InputMethodManager imm = (InputMethodManager)
-                    getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
-            if (imm != null) {
-                imm.showSoftInput(searchView.findFocus(), InputMethodManager.SHOW_IMPLICIT);
-            }
-        }
-    }
-
-    @Override
-    public void onDetach() {
-        super.onDetach();
-        mListener = null;
-    }
-
-    @Override
-    public void unshareButtonPressed(OCShare share) {
-        // Unshare
-        mListener.unshareWith(share);
-        Log_OC.d(TAG, "Unshare - " + share.getSharedWithDisplayName());
-    }
-
-    @Override
-    public void editShare(OCShare share) {
-        // move to fragment to edit share
-        Log_OC.d(TAG, "Editing " + share.getSharedWithDisplayName());
-        mListener.showEditShare(share);
-    }
-
-}

+ 0 - 858
src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java

@@ -1,858 +0,0 @@
-/*
- * ownCloud Android client application
- *
- * @author masensio
- * @author David A. Velasco
- * @author Juan Carlos González Cabrero
- * @author Andy Scherzinger
- * Copyright (C) 2015 ownCloud Inc.
- * Copyright (C) 2018 Andy Scherzinger
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-
-package com.owncloud.android.ui.fragment;
-
-import android.accounts.Account;
-import android.app.Activity;
-import android.graphics.Bitmap;
-import android.graphics.PorterDuff;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.CompoundButton;
-
-import com.google.android.material.button.MaterialButton;
-import com.google.android.material.snackbar.Snackbar;
-import com.owncloud.android.R;
-import com.owncloud.android.databinding.ShareFileLayoutBinding;
-import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.datamodel.ThumbnailsCacheManager;
-import com.owncloud.android.lib.common.utils.Log_OC;
-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.ui.activity.FileActivity;
-import com.owncloud.android.ui.adapter.ShareUserListAdapter;
-import com.owncloud.android.ui.dialog.ExpirationDatePickerDialogFragment;
-import com.owncloud.android.ui.dialog.SharePasswordDialogFragment;
-import com.owncloud.android.utils.DisplayUtils;
-import com.owncloud.android.utils.MimeTypeUtil;
-import com.owncloud.android.utils.ThemeUtils;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.widget.SwitchCompat;
-import androidx.fragment.app.Fragment;
-
-/**
- * Fragment for Sharing a file with sharees (users or groups) or creating a public link.
- * <p>
- * A simple {@link Fragment} subclass.
- * <p>
- * Activities that contain this fragment must implement the {@link ShareFragmentListener} interface to handle
- * interaction events.
- * <p>
- * Use the {@link ShareFileFragment#newInstance} factory method to create an instance of this fragment.
- */
-public class ShareFileFragment extends Fragment implements ShareUserListAdapter.ShareUserAdapterListener {
-
-    private static final String TAG = ShareFileFragment.class.getSimpleName();
-
-    private ShareFileLayoutBinding binding;
-
-    /**
-     * The fragment initialization parameters.
-     */
-    private static final String ARG_FILE = "FILE";
-    private static final String ARG_ACCOUNT = "ACCOUNT";
-
-//    /** Tag for dialog */
-//    private static final String FTAG_CHOOSER_DIALOG = "CHOOSER_DIALOG";
-
-    /**
-     * File to share, received as a parameter in construction time.
-     */
-    private OCFile mFile;
-
-    /**
-     * OC account holding the file to share, received as a parameter in construction time.
-     */
-    private Account mAccount;
-
-    /**
-     * Reference to parent listener.
-     */
-    private ShareFragmentListener mListener;
-
-    /**
-     * List of private shares bound to the file.
-     */
-    private List<OCShare> mPrivateShares;
-
-    /**
-     * Capabilities of the server.
-     */
-    private OCCapability mCapabilities;
-
-    /**
-     * Public share bound to the file.
-     */
-    private OCShare mPublicShare;
-
-    /**
-     * Listener for changes on switch to share / unshare publicly.
-     */
-    private CompoundButton.OnCheckedChangeListener mOnShareViaLinkSwitchCheckedChangeListener;
-
-    /**
-     * Listener for user actions to set, update or clear password on public link.
-     */
-    private OnPasswordInteractionListener mOnPasswordInteractionListener;
-
-    /**
-     * Listener for user actions to set, update or clear expiration date on public link.
-     */
-    private OnExpirationDateInteractionListener mOnExpirationDateInteractionListener;
-
-    /**
-     * Listener for user actions to set or unset edit permission on public link.
-     */
-    private OnEditPermissionInteractionListener mOnEditPermissionInteractionListener;
-
-    /**
-     * Listener for user actions to set or unset hide file listing permission on public link.
-     */
-    private OnHideFileListingPermissionInteractionListener mOnHideFileListingPermissionInteractionListener;
-
-    /**
-     * Public factory method to create new ShareFileFragment instances.
-     *
-     * @param fileToShare An {@link OCFile} to show in the fragment
-     * @param account     An ownCloud account
-     * @return A new instance of fragment ShareFileFragment.
-     */
-    public static ShareFileFragment newInstance(OCFile fileToShare, Account account) {
-        ShareFileFragment fragment = new ShareFileFragment();
-        Bundle args = new Bundle();
-        args.putParcelable(ARG_FILE, fileToShare);
-        args.putParcelable(ARG_ACCOUNT, account);
-        fragment.setArguments(args);
-        return fragment;
-    }
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        Log_OC.d(TAG, "onCreate");
-        if (getArguments() != null) {
-            mFile = getArguments().getParcelable(ARG_FILE);
-            mAccount = getArguments().getParcelable(ARG_ACCOUNT);
-        }
-    }
-
-    @Override
-    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-        Log_OC.d(TAG, "onCreateView");
-
-        // use grey as fallback for elements where custom theming is not available
-        if (ThemeUtils.themingEnabled(getContext())) {
-            requireContext().getTheme().applyStyle(R.style.FallbackThemingTheme, true);
-        }
-
-        int accentColor = ThemeUtils.primaryAccentColor(getContext());
-
-        // Inflate the layout for this fragment
-        binding = ShareFileLayoutBinding.inflate(inflater);
-
-        // Setup layout
-        // Image
-        binding.shareFileIcon.setImageDrawable(
-            MimeTypeUtil.getFileTypeIcon(mFile.getMimeType(), mFile.getFileName(), mAccount, getContext())
-                                              );
-        if (MimeTypeUtil.isImage(mFile)) {
-            String remoteId = String.valueOf(mFile.getRemoteId());
-            Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(remoteId);
-            if (thumbnail != null) {
-                binding.shareFileIcon.setImageBitmap(thumbnail);
-            }
-        }
-
-        // Title
-        binding.shareWithUsersSectionTitle.setTextColor(accentColor);
-
-        // Name
-        binding.shareFileName.setText(getResources().getString(R.string.share_file, mFile.getFileName()));
-
-        binding.shareHeaderDivider.getBackground().setColorFilter(ThemeUtils.primaryAccentColor(getContext()),
-                                                                  PorterDuff.Mode.SRC_ATOP);
-
-        // Size
-        if (mFile.isFolder()) {
-            binding.shareFileSize.setVisibility(View.GONE);
-        } else {
-            binding.shareFileSize.setText(DisplayUtils.bytesToHumanReadable(mFile.getFileLength()));
-        }
-
-        //  Add User Button
-        binding.addUserButton.getBackground().setColorFilter(accentColor, PorterDuff.Mode.SRC_ATOP);
-        // Show Search Fragment
-        binding.addUserButton.setOnClickListener(view -> mListener.showSearchUsersAndGroups());
-
-        // Set listener for user actions on switch for sharing/unsharing via link
-        initShareViaLinkListener();
-
-        // Set listener for user actions on expiration date
-        initExpirationListener();
-
-        // Set listener for user actions on password
-        initPasswordListener();
-
-        // Set listener for user actions on edit permission
-        initEditPermissionListener();
-
-        // Set listener for hide file listing
-        initHideFileListingListener();
-
-        // Hide share features sections that are not enabled
-        hideNotEnabledShareSections();
-
-        return binding.getRoot();
-    }
-
-
-    /**
-     * Binds listener for user actions to create or delete a public share to the views receiving the user events.
-     */
-    private void initShareViaLinkListener() {
-        mOnShareViaLinkSwitchCheckedChangeListener = new OnShareViaLinkListener();
-        ThemeUtils.tintSwitch(binding.shareViaLinkSectionSwitch, ThemeUtils.primaryAccentColor(getContext()), true);
-        binding.shareViaLinkSectionSwitch.setOnCheckedChangeListener(mOnShareViaLinkSwitchCheckedChangeListener);
-    }
-
-    /**
-     * Listener for user actions that create or delete a public share.
-     */
-    private class OnShareViaLinkListener
-        implements CompoundButton.OnCheckedChangeListener {
-
-        /**
-         * Called by R.id.shareViaLinkSectionSwitch to create or delete a public link.
-         *
-         * @param switchView {@link SwitchCompat} toggled by the user, R.id.shareViaLinkSectionSwitch
-         * @param isChecked  New switch state.
-         */
-        @Override
-        public void onCheckedChanged(CompoundButton switchView, boolean isChecked) {
-            if (!isResumed()) {
-                // very important, setCheched(...) is called automatically during
-                // Fragment recreation on device rotations
-                return;
-            }
-            if (isChecked) {
-                if (mCapabilities != null && (mCapabilities.getFilesSharingPublicPasswordEnforced().isTrue() ||
-                    mCapabilities.getFilesSharingPublicAskForOptionalPassword().isTrue())) {
-                    // password enforced by server, request to the user before trying to create
-                    requestPasswordForShareViaLink(true,
-                                                   mCapabilities.getFilesSharingPublicAskForOptionalPassword().isTrue());
-                } else {
-                    // create without password if not enforced by server or we don't know if enforced;
-                    ((FileActivity) requireActivity()).getFileOperationsHelper().shareFileViaLink(mFile, null);
-
-                    // ShareActivity#onCreateShareViaLinkOperationFinish will take care if password
-                    // is enforced by the server but app doesn't know, or if server version is
-                    // older than OwnCloudVersion#MINIMUM_VERSION_CAPABILITIES_API
-                }
-
-            } else {
-                ((FileActivity) requireActivity()).getFileOperationsHelper().unshareFileViaLink(mFile);
-            }
-
-            // undo the toggle to grant the view will be correct if any intermediate dialog is cancelled or
-            // the create/delete operation fails
-            switchView.setOnCheckedChangeListener(null);
-            switchView.toggle();
-            switchView.setOnCheckedChangeListener(mOnShareViaLinkSwitchCheckedChangeListener);
-        }
-    }
-
-    /**
-     * Binds listener for user actions that start any update on a expiration date for the public link to the views
-     * receiving the user events.
-     */
-    private void initExpirationListener() {
-        mOnExpirationDateInteractionListener = new OnExpirationDateInteractionListener();
-
-        binding.shareViaLinkExpirationSwitch.setOnCheckedChangeListener(mOnExpirationDateInteractionListener);
-
-        ThemeUtils.tintSwitch(binding.shareViaLinkExpirationSwitch, ThemeUtils.primaryAccentColor(getContext()));
-
-        binding.shareViaLinkExpirationLabel.setOnClickListener(mOnExpirationDateInteractionListener);
-        binding.shareViaLinkExpirationValue.setOnClickListener(mOnExpirationDateInteractionListener);
-    }
-
-    /**
-     * Listener for user actions that start any update on the expiration date for the public link.
-     */
-    private class OnExpirationDateInteractionListener
-        implements CompoundButton.OnCheckedChangeListener, View.OnClickListener {
-
-        /**
-         * Called by R.id.shareViaLinkExpirationSwitch to set or clear the expiration date.
-         *
-         * @param switchView {@link SwitchCompat} toggled by the user, R.id.shareViaLinkExpirationSwitch
-         * @param isChecked  New switch state.
-         */
-        @Override
-        public void onCheckedChanged(CompoundButton switchView, boolean isChecked) {
-            if (!isResumed()) {
-                // very important, setCheched(...) is called automatically during
-                // Fragment recreation on device rotations
-                return;
-            }
-            if (isChecked) {
-                ExpirationDatePickerDialogFragment dialog = ExpirationDatePickerDialogFragment
-                    .newInstance(mFile, mPublicShare.getExpirationDate());
-                dialog.show(
-                    requireActivity().getSupportFragmentManager(),
-                    ExpirationDatePickerDialogFragment.DATE_PICKER_DIALOG
-                           );
-
-            } else {
-                ((FileActivity) requireActivity()).getFileOperationsHelper().setExpirationDateToShareViaLink(mFile, -1);
-            }
-
-            // undo the toggle to grant the view will be correct if the dialog is cancelled
-            switchView.setOnCheckedChangeListener(null);
-            switchView.toggle();
-            switchView.setOnCheckedChangeListener(mOnExpirationDateInteractionListener);
-        }
-
-        /**
-         * Called by R.id.shareViaLinkExpirationLabel or R.id.shareViaLinkExpirationValue to change the current
-         * expiration date.
-         *
-         * @param expirationView Label or value view touched by the user.
-         */
-        @Override
-        public void onClick(View expirationView) {
-            if (mPublicShare != null && mPublicShare.getExpirationDate() > 0) {
-                long chosenDateInMillis = mPublicShare.getExpirationDate();
-                ExpirationDatePickerDialogFragment dialog =
-                    ExpirationDatePickerDialogFragment
-                        .newInstance(mFile, chosenDateInMillis);
-                dialog.show(
-                    requireActivity().getSupportFragmentManager(),
-                    ExpirationDatePickerDialogFragment.DATE_PICKER_DIALOG
-                           );
-            }
-        }
-    }
-
-    /**
-     * Binds listener for user actions that start any update on a password for the public link to the views receiving
-     * the user events.
-     */
-    private void initPasswordListener() {
-        mOnPasswordInteractionListener = new OnPasswordInteractionListener();
-
-        binding.shareViaLinkPasswordSwitch.setOnCheckedChangeListener(mOnPasswordInteractionListener);
-        ThemeUtils.tintSwitch(binding.shareViaLinkPasswordSwitch, ThemeUtils.primaryAccentColor(getContext()));
-
-        binding.shareViaLinkPasswordLabel.setOnClickListener(mOnPasswordInteractionListener);
-        binding.shareViaLinkPasswordValue.setOnClickListener(mOnPasswordInteractionListener);
-    }
-
-
-    /**
-     * Listener for user actions that start any update on a password for the public link.
-     */
-    private class OnPasswordInteractionListener
-        implements CompoundButton.OnCheckedChangeListener, View.OnClickListener {
-
-        /**
-         * Called by R.id.shareViaLinkPasswordSwitch to set or clear the password.
-         *
-         * @param switchView {@link SwitchCompat} toggled by the user, R.id.shareViaLinkPasswordSwitch
-         * @param isChecked  New switch state.
-         */
-        @Override
-        public void onCheckedChanged(CompoundButton switchView, boolean isChecked) {
-            if (!isResumed()) {
-                // very important, setChecked(...) is called automatically during
-                // Fragment recreation on device rotations
-                return;
-            }
-            if (isChecked) {
-                requestPasswordForShareViaLink(false,
-                                               mCapabilities.getFilesSharingPublicAskForOptionalPassword().isTrue());
-            } else {
-                ((FileActivity) requireActivity()).getFileOperationsHelper().setPasswordToShareViaLink(mFile, ""); //
-                // clears
-            }
-
-            // undo the toggle to grant the view will be correct if the dialog is cancelled
-            switchView.setOnCheckedChangeListener(null);
-            switchView.toggle();
-            switchView.setOnCheckedChangeListener(mOnPasswordInteractionListener);
-        }
-
-        /**
-         * Called by R.id.shareViaLinkPasswordLabel or R.id.shareViaLinkPasswordValue to change the current password.
-         *
-         * @param passwordView Label or value view touched by the user.
-         */
-        @Override
-        public void onClick(View passwordView) {
-            if (mPublicShare != null && mPublicShare.isPasswordProtected()) {
-                requestPasswordForShareViaLink(false,
-                                               mCapabilities.getFilesSharingPublicAskForOptionalPassword().isTrue());
-            }
-        }
-    }
-
-    /**
-     * Binds listener for user actions that start any update the edit permissions for the public link to the views
-     * receiving the user events.
-     */
-    private void initEditPermissionListener() {
-        mOnEditPermissionInteractionListener = new OnEditPermissionInteractionListener();
-
-        binding.shareViaLinkEditPermissionSwitch.setOnCheckedChangeListener(mOnEditPermissionInteractionListener);
-        ThemeUtils.tintSwitch(binding.shareViaLinkEditPermissionSwitch, ThemeUtils.primaryAccentColor(getContext()));
-    }
-
-    /**
-     * Binds listener for user actions that start any update the hide file listing permissions for the public link to
-     * the views receiving the user events.
-     */
-    private void initHideFileListingListener() {
-        mOnHideFileListingPermissionInteractionListener = new OnHideFileListingPermissionInteractionListener();
-
-        binding.shareViaLinkFileListingPermissionSwitch.setOnCheckedChangeListener(mOnHideFileListingPermissionInteractionListener);
-        ThemeUtils.tintSwitch(binding.shareViaLinkFileListingPermissionSwitch, ThemeUtils.primaryAccentColor(getContext()));
-    }
-
-    /**
-     * Listener for user actions that start any update on the edit permissions for the public link.
-     */
-    private class OnEditPermissionInteractionListener implements CompoundButton.OnCheckedChangeListener {
-
-        /**
-         * Called by R.id.shareViaLinkEditPermissionSwitch to set or clear the edit permission.
-         *
-         * @param switchView {@link SwitchCompat} toggled by the user, R.id.shareViaLinkEditPermissionSwitch
-         * @param isChecked  New switch state.
-         */
-        @Override
-        public void onCheckedChanged(CompoundButton switchView, boolean isChecked) {
-            if (!isResumed()) {
-                // very important, setCheched(...) is called automatically during
-                // Fragment recreation on device rotations
-                return;
-            }
-
-            ((FileActivity) requireActivity()).getFileOperationsHelper().setUploadPermissionsToShare(mFile, isChecked);
-
-            // undo the toggle to grant the view will be correct if the dialog is cancelled
-            switchView.setOnCheckedChangeListener(null);
-            switchView.toggle();
-            switchView.setOnCheckedChangeListener(mOnEditPermissionInteractionListener);
-        }
-    }
-
-    /**
-     * Listener for user actions that start any update on the hide file listing permissions for the public link.
-     */
-    private class OnHideFileListingPermissionInteractionListener implements CompoundButton.OnCheckedChangeListener {
-
-        /**
-         * Called by R.id.shareViaLinkHideListPermissionSwitch to set or clear the edit permission.
-         *
-         * @param switchView {@link SwitchCompat} toggled by the user, R.id.shareViaLinkHideListPermissionSwitch
-         * @param isChecked  New switch state.
-         */
-        @Override
-        public void onCheckedChanged(CompoundButton switchView, boolean isChecked) {
-            if (!isResumed()) {
-                // very important, setChecked(...) is called automatically during
-                // Fragment recreation on device rotations
-                return;
-            }
-
-            if (mCapabilities.getFilesFileDrop().isTrue()) {
-                ((FileActivity) requireActivity()).getFileOperationsHelper().
-                    setHideFileListingPermissionsToShare(
-                        mPublicShare,
-                        isChecked
-                                                        );
-            } else {
-                // not supported in ownCloud
-                Snackbar.make(binding.getRoot(), R.string.files_drop_not_supported, Snackbar.LENGTH_LONG)
-                    .setAction(R.string.learn_more, v ->
-                        DisplayUtils.startLinkIntent(requireActivity(), R.string.url_server_install))
-                    .show();
-            }
-
-            // undo the toggle to grant the view will be correct if the dialog is cancelled
-            switchView.setOnCheckedChangeListener(null);
-            switchView.toggle();
-            switchView.setOnCheckedChangeListener(mOnHideFileListingPermissionInteractionListener);
-        }
-    }
-
-
-    @Override
-    public void onActivityCreated(Bundle savedInstanceState) {
-        super.onActivityCreated(savedInstanceState);
-        Log_OC.d(TAG, "onActivityCreated");
-
-        // Load known capabilities of the server from DB
-        refreshCapabilitiesFromDB();
-
-        // Load data into the list of private shares
-        refreshUsersOrGroupsListFromDB();
-
-        // Load data of public share, if exists
-        refreshPublicShareFromDB();
-    }
-
-    @Override
-    public void onAttach(@NonNull Activity activity) {
-        super.onAttach(activity);
-        try {
-            mListener = (ShareFragmentListener) activity;
-        } catch (ClassCastException e) {
-            throw new IllegalArgumentException(
-                activity.toString() + " must implement OnShareFragmentInteractionListener", e);
-        }
-    }
-
-    @Override
-    public void onDetach() {
-        super.onDetach();
-        mListener = null;
-    }
-
-    /**
-     * Get known server capabilities from DB
-     * <p/>
-     * Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager} instance
-     * ready to use. If not ready, does nothing.
-     */
-    public void refreshCapabilitiesFromDB() {
-        if (((FileActivity) mListener).getStorageManager() != null) {
-            mCapabilities = ((FileActivity) mListener).getStorageManager().getCapability(mAccount.name);
-        }
-    }
-
-    /**
-     * Get users and groups from the DB to fill in the "share with" list.
-     * <p/>
-     * Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager} instance
-     * ready to use. If not ready, does nothing.
-     */
-    public void refreshUsersOrGroupsListFromDB() {
-        if (((FileActivity) mListener).getStorageManager() != null) {
-            // Get Users and Groups
-            mPrivateShares = ((FileActivity) mListener).getStorageManager().getSharesWithForAFile(
-                mFile.getRemotePath(),
-                mAccount.name
-                                                                                                 );
-
-            // Update list of users/groups
-            updateListOfUserGroups();
-        }
-    }
-
-    private void updateListOfUserGroups() {
-        // Update list of users/groups
-        // TODO Refactoring: create a new {@link ShareUserListAdapter} instance with every call should not be needed
-        ShareUserListAdapter mUserGroupsAdapter = new ShareUserListAdapter(
-            getActivity(),
-            R.layout.share_user_item,
-            mPrivateShares,
-            this
-        );
-
-        // Show data
-
-        if (mPrivateShares.size() > 0) {
-            binding.shareNoUsers.setVisibility(View.GONE);
-            binding.shareUsersList.setVisibility(View.VISIBLE);
-            binding.shareUsersList.setAdapter(mUserGroupsAdapter);
-        } else {
-            binding.shareNoUsers.setVisibility(View.VISIBLE);
-            binding.shareUsersList.setVisibility(View.GONE);
-        }
-
-        // Set Scroll to initial position
-        binding.shareScroll.scrollTo(0, 0);
-    }
-
-    @Override
-    public void unshareButtonPressed(OCShare share) {
-        // Unshare
-        Log_OC.d(TAG, "Unsharing " + share.getSharedWithDisplayName());
-        mListener.unshareWith(share);
-    }
-
-    @Override
-    public void editShare(OCShare share) {
-        // move to fragment to edit share
-        Log_OC.d(TAG, "Editing " + share.getSharedWithDisplayName());
-        mListener.showEditShare(share);
-    }
-
-    /**
-     * Get public link from the DB to fill in the "Share link" section in the UI.
-     * <p/>
-     * Takes into account server capabilities before reading database.
-     * <p/>
-     * Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager} instance
-     * ready to use. If not ready, does nothing.
-     */
-    public void refreshPublicShareFromDB() {
-        if (isPublicShareDisabled()) {
-            hidePublicShare();
-
-        } else if (((FileActivity) mListener).getStorageManager() != null) {
-            // Get public share
-            mPublicShare = ((FileActivity) mListener).getStorageManager().getFirstShareByPathAndType(
-                mFile.getRemotePath(),
-                ShareType.PUBLIC_LINK,
-                ""
-            );
-
-            // Update public share section
-            updatePublicShareSection();
-        }
-    }
-
-    /**
-     * @return 'True' when public share is disabled in the server
-     */
-    private boolean isPublicShareDisabled() {
-        return mCapabilities != null && mCapabilities.getFilesSharingPublicEnabled().isFalse();
-    }
-
-    /**
-     * Updates in the UI the section about public share with the information in the current public share bound to mFile,
-     * if any.
-     */
-    private void updatePublicShareSection() {
-        if (mPublicShare != null && ShareType.PUBLIC_LINK.equals(mPublicShare.getShareType())) {
-            // public share bound -> expand section
-            updateShareViaLinkSwitch(mOnShareViaLinkSwitchCheckedChangeListener);
-
-            binding.shareViaLinkExpirationSection.setVisibility(View.VISIBLE);
-            binding.shareViaLinkPasswordSection.setVisibility(View.VISIBLE);
-            if (mFile.isFolder() && !mCapabilities.getFilesSharingPublicUpload().isFalse()) {
-                binding.shareViaLinkEditPermissionSection.setVisibility(View.VISIBLE);
-                binding.shareViaLinkHideFileListingPermissionSection.setVisibility(View.VISIBLE);
-            } else {
-                binding.shareViaLinkEditPermissionSection.setVisibility(View.GONE);
-            }
-
-            // init link button
-            initLinkButton();
-
-            /// update state of expiration date switch
-            updateExpirationDateSwitch(mPublicShare.getExpirationDate(), mOnExpirationDateInteractionListener);
-
-            /// update state of password switch
-            updatePasswordSwitch(mPublicShare.isPasswordProtected(), mOnPasswordInteractionListener);
-
-            /// update state of the edit permission switch
-            updatePermissionSwitch(mPublicShare.getPermissions(), mOnEditPermissionInteractionListener);
-
-            /// update state of the hide file listing permission switch
-            updateHideFileListingPermissionSwitch(mPublicShare.getPermissions(),
-                                                  mOnHideFileListingPermissionInteractionListener);
-
-        } else {
-            // no public share -> collapse section
-            collapsePublicShareSection();
-        }
-    }
-
-    private void updateShareViaLinkSwitch(
-        CompoundButton.OnCheckedChangeListener onShareViaLinkSwitchCheckedChangeListener) {
-        SwitchCompat shareViaLinkSwitch = binding.shareViaLinkSectionSwitch;
-        if (!shareViaLinkSwitch.isChecked()) {
-            // set null listener before setChecked() to prevent infinite loop of calls
-            shareViaLinkSwitch.setOnCheckedChangeListener(null);
-            shareViaLinkSwitch.setChecked(true);
-            shareViaLinkSwitch.setOnCheckedChangeListener(onShareViaLinkSwitchCheckedChangeListener);
-        }
-    }
-
-    private void updateHideFileListingPermissionSwitch(
-        int permissions,
-        OnHideFileListingPermissionInteractionListener onHideFileListingPermissionInteractionListener) {
-        SwitchCompat hideFileListingPermissionSwitch = binding.shareViaLinkFileListingPermissionSwitch;
-
-        // set null listener before setChecked() to prevent infinite loop of calls
-        hideFileListingPermissionSwitch.setOnCheckedChangeListener(null);
-
-        boolean readOnly = (permissions & OCShare.READ_PERMISSION_FLAG) != 0;
-        hideFileListingPermissionSwitch.setChecked(!readOnly);
-
-        // recover listener
-        hideFileListingPermissionSwitch.setOnCheckedChangeListener(onHideFileListingPermissionInteractionListener);
-    }
-
-    private void updatePermissionSwitch(
-        int permissions,
-        OnEditPermissionInteractionListener onEditPermissionInteractionListener) {
-        SwitchCompat editPermissionSwitch = binding.shareViaLinkEditPermissionSwitch;
-
-        // set null listener before setChecked() to prevent infinite loop of calls
-        editPermissionSwitch.setOnCheckedChangeListener(null);
-
-        if (permissions > OCShare.READ_PERMISSION_FLAG) {
-            if (!editPermissionSwitch.isChecked()) {
-                editPermissionSwitch.toggle();
-            }
-            binding.shareViaLinkHideFileListingPermissionSection.setVisibility(View.VISIBLE);
-        } else {
-            if (editPermissionSwitch.isChecked()) {
-                editPermissionSwitch.toggle();
-            }
-            binding.shareViaLinkHideFileListingPermissionSection.setVisibility(View.GONE);
-        }
-
-        // recover listener
-        editPermissionSwitch.setOnCheckedChangeListener(onEditPermissionInteractionListener);
-    }
-
-    private void updatePasswordSwitch(
-        boolean isPasswordProtected,
-        OnPasswordInteractionListener onPasswordInteractionListener) {
-        SwitchCompat passwordSwitch = binding.shareViaLinkPasswordSwitch;
-        // set null listener before setChecked() to prevent infinite loop of calls
-        passwordSwitch.setOnCheckedChangeListener(null);
-
-        if (isPasswordProtected) {
-            if (!passwordSwitch.isChecked()) {
-                passwordSwitch.toggle();
-            }
-            binding.shareViaLinkPasswordValue.setVisibility(View.VISIBLE);
-        } else {
-            if (passwordSwitch.isChecked()) {
-                passwordSwitch.toggle();
-            }
-            binding.shareViaLinkPasswordValue.setVisibility(View.INVISIBLE);
-        }
-
-        // recover listener
-        passwordSwitch.setOnCheckedChangeListener(onPasswordInteractionListener);
-    }
-
-    private void updateExpirationDateSwitch(
-        long expirationDate,
-        OnExpirationDateInteractionListener onExpirationDateInteractionListener) {
-        SwitchCompat expirationDateSwitch = binding.shareViaLinkExpirationSwitch;
-        // set null listener before setChecked() to prevent infinite loop of calls
-        expirationDateSwitch.setOnCheckedChangeListener(null);
-
-        if (expirationDate > 0) {
-            if (!expirationDateSwitch.isChecked()) {
-                expirationDateSwitch.toggle();
-            }
-            String formattedDate = SimpleDateFormat.getDateInstance().format(new Date(expirationDate));
-            binding.shareViaLinkExpirationValue.setText(formattedDate);
-        } else {
-            if (expirationDateSwitch.isChecked()) {
-                expirationDateSwitch.toggle();
-            }
-            binding.shareViaLinkExpirationValue.setText(R.string.empty);
-        }
-
-        // recover listener
-        expirationDateSwitch.setOnCheckedChangeListener(onExpirationDateInteractionListener);
-    }
-
-    private void initLinkButton() {
-        MaterialButton getLinkButton = binding.shareViaLinkGetLinkButton;
-        getLinkButton.getBackground().setColorFilter(ThemeUtils.primaryColor(getContext()),
-                                                     PorterDuff.Mode.SRC_ATOP);
-        getLinkButton.setVisibility(View.VISIBLE);
-
-        //GetLink from the server and show ShareLinkToDialog
-        getLinkButton.setOnClickListener(v -> ((FileActivity) requireActivity()).getFileOperationsHelper().
-            getFileWithLink(mFile));
-    }
-
-    private void collapsePublicShareSection() {
-        SwitchCompat shareViaLinkSwitch = binding.shareViaLinkSectionSwitch;
-        if (shareViaLinkSwitch.isChecked()) {
-            shareViaLinkSwitch.setOnCheckedChangeListener(null);
-            binding.shareViaLinkSectionSwitch.setChecked(false);
-            shareViaLinkSwitch.setOnCheckedChangeListener(mOnShareViaLinkSwitchCheckedChangeListener);
-        }
-        binding.shareViaLinkExpirationSection.setVisibility(View.GONE);
-        binding.shareViaLinkPasswordSection.setVisibility(View.GONE);
-        binding.shareViaLinkEditPermissionSection.setVisibility(View.GONE);
-        binding.shareViaLinkHideFileListingPermissionSection.setVisibility(View.GONE);
-        binding.shareViaLinkGetLinkButton.setVisibility(View.GONE);
-    }
-
-    /**
-     * Hides all the UI elements related to public share
-     */
-    private void hidePublicShare() {
-        binding.shareViaLinkSectionSwitch.setVisibility(View.GONE);
-        binding.shareViaLinkExpirationSection.setVisibility(View.GONE);
-        binding.shareViaLinkPasswordSection.setVisibility(View.GONE);
-        binding.shareViaLinkEditPermissionSection.setVisibility(View.GONE);
-        binding.shareViaLinkGetLinkButton.setVisibility(View.GONE);
-        binding.shareViaLinkHideFileListingPermissionSection.setVisibility(View.GONE);
-    }
-
-    /**
-     * Starts a dialog that requests a password to the user to protect a share link.
-     *
-     * @param createShare    When 'true', the request for password will be followed by the creation of a new public
-     *                       link; when 'false', a public share is assumed to exist, and the password is bound to it.
-     * @param askForPassword if true, password is optional
-     */
-    public void requestPasswordForShareViaLink(boolean createShare, boolean askForPassword) {
-        SharePasswordDialogFragment dialog = SharePasswordDialogFragment.newInstance(mFile,
-                                                                                     createShare,
-                                                                                     askForPassword);
-        dialog.show(requireFragmentManager(), SharePasswordDialogFragment.PASSWORD_FRAGMENT);
-    }
-
-    /**
-     * Hide share features sections that are not enabled
-     */
-    private void hideNotEnabledShareSections() {
-        boolean shareViaLinkAllowed = getResources().getBoolean(R.bool.share_via_link_feature);
-        boolean shareWithUsersAllowed = getResources().getBoolean(R.bool.share_with_users_feature);
-
-        // Hide share via link section if it is not enabled
-        if (!shareViaLinkAllowed) {
-            binding.shareViaLinkSection.setVisibility(View.GONE);
-        }
-
-        // Hide share with users section if it is not enabled
-        if (!shareWithUsersAllowed) {
-            binding.shareWithUsersSection.setVisibility(View.GONE);
-        }
-    }
-}

+ 0 - 41
src/main/java/com/owncloud/android/ui/fragment/ShareFragmentListener.java

@@ -1,41 +0,0 @@
-/**
- *   ownCloud Android client application
- *
- *   @author masensio
- *   @author David A. Velasco
- *   Copyright (C) 2015 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   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 <http://www.gnu.org/licenses/>.
- *
- */
-
-package com.owncloud.android.ui.fragment;
-
-import com.owncloud.android.lib.resources.shares.OCShare;
-
-/**
- * This interface must be implemented by activities that contain this
- * fragment to allow an interaction in fragments handling {@link OCShare}s
- * to be communicated to the parent activity and potentially other fragments
- * contained in that activity.
- * <p/>
- * See the Android Training lesson <a href=
- * "http://developer.android.com/training/basics/fragments/communicating.html"
- * >Communicating with Other Fragments</a> for more information.
- */
-public interface ShareFragmentListener {
-    void showSearchUsersAndGroups();
-    void showEditShare(OCShare share);
-    void refreshUsersOrGroupsListFromServer();
-    void unshareWith(OCShare share);
-}

+ 2 - 1
src/main/java/com/owncloud/android/ui/preview/FileDownloadFragment.java

@@ -37,6 +37,7 @@ import com.owncloud.android.utils.ThemeUtils;
 
 import java.lang.ref.WeakReference;
 
+import androidx.annotation.NonNull;
 import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentStatePagerAdapter;
 
@@ -163,7 +164,7 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
 
 
     @Override
-    public void onSaveInstanceState(Bundle outState) {
+    public void onSaveInstanceState(@NonNull Bundle outState) {
         super.onSaveInstanceState(outState);
         outState.putParcelable(FileDownloadFragment.EXTRA_FILE, getFile());
         outState.putParcelable(FileDownloadFragment.EXTRA_ACCOUNT, mAccount);

+ 0 - 42
src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java

@@ -32,11 +32,9 @@ import android.content.ServiceConnection;
 import android.graphics.Color;
 import android.os.Bundle;
 import android.os.IBinder;
-import android.text.TextUtils;
 import android.view.MenuItem;
 import android.view.View;
 
-import com.google.android.material.snackbar.Snackbar;
 import com.nextcloud.client.account.User;
 import com.nextcloud.client.di.Injectable;
 import com.nextcloud.client.preferences.AppPreferences;
@@ -53,14 +51,11 @@ import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
 import com.owncloud.android.lib.common.operations.RemoteOperation;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.common.utils.Log_OC;
-import com.owncloud.android.lib.resources.shares.OCShare;
-import com.owncloud.android.operations.CreateShareViaLinkOperation;
 import com.owncloud.android.operations.RemoveFileOperation;
 import com.owncloud.android.operations.SynchronizeFileOperation;
 import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDisplayActivity;
 import com.owncloud.android.ui.fragment.FileFragment;
-import com.owncloud.android.utils.ErrorMessageAdapter;
 import com.owncloud.android.utils.MimeTypeUtil;
 import com.owncloud.android.utils.ThemeUtils;
 
@@ -222,43 +217,6 @@ public class PreviewImageActivity extends FileActivity implements
             finish();
         } else if (operation instanceof SynchronizeFileOperation) {
             onSynchronizeFileOperationFinish(result);
-        } else if (operation instanceof CreateShareViaLinkOperation) {
-            CreateShareViaLinkOperation op = (CreateShareViaLinkOperation) operation;
-
-            if (result.isSuccess()) {
-                updateFileFromDB();
-
-                // if share to user and share via link multiple ocshares are returned,
-                // therefore filtering for public_link
-                String link = "";
-                OCFile file = null;
-                for (Object object : result.getData()) {
-                    OCShare shareLink = (OCShare) object;
-                    if (FileDisplayActivity.TAG_PUBLIC_LINK.equalsIgnoreCase(shareLink.getShareType().name())) {
-                        link = shareLink.getShareLink();
-                        file = getStorageManager().getFileByPath(shareLink.getPath());
-                        break;
-                    }
-                }
-
-                copyAndShareFileLink(this, file, link);
-            } else {
-                // Detect Failure (403) --> maybe needs password
-                String password = op.getPassword();
-                if (result.getCode() == RemoteOperationResult.ResultCode.SHARE_FORBIDDEN &&
-                    TextUtils.isEmpty(password) &&
-                    getCapabilities().getFilesSharingPublicEnabled().isUnknown()) {
-                    // Was tried without password, but not sure that it's optional.
-
-                    Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content),
-                                                      ErrorMessageAdapter.getErrorCauseMessage(result,
-                                                                                               operation,
-                                                                                               getResources()),
-                                                      Snackbar.LENGTH_LONG);
-                    ThemeUtils.colorSnackbar(this, snackbar);
-                    snackbar.show();
-                }
-            }
         }
     }
 

+ 0 - 96
src/main/java/com/owncloud/android/utils/GetShareWithUsersAsyncTask.java

@@ -1,96 +0,0 @@
-/**
- * ownCloud Android client application
- *
- * @author masensio
- * Copyright (C) 2015 ownCloud Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-
-package com.owncloud.android.utils;
-
-import android.accounts.Account;
-import android.os.AsyncTask;
-import android.util.Pair;
-
-import com.owncloud.android.MainApp;
-import com.owncloud.android.datamodel.FileDataStorageManager;
-import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.lib.common.OwnCloudAccount;
-import com.owncloud.android.lib.common.OwnCloudClient;
-import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
-import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
-import com.owncloud.android.lib.common.operations.RemoteOperation;
-import com.owncloud.android.lib.common.operations.RemoteOperationResult;
-import com.owncloud.android.lib.common.utils.Log_OC;
-import com.owncloud.android.operations.GetSharesForFileOperation;
-
-import java.lang.ref.WeakReference;
-
-/**
- * Async Task to get the users and groups which a file is shared with
- */
-public class GetShareWithUsersAsyncTask extends AsyncTask<Object, Void, Pair<RemoteOperation, RemoteOperationResult>> {
-
-    private final String TAG = GetShareWithUsersAsyncTask.class.getSimpleName();
-    private final WeakReference<OnRemoteOperationListener> mListener;
-
-    public GetShareWithUsersAsyncTask(OnRemoteOperationListener listener) {
-        mListener = new WeakReference<OnRemoteOperationListener>(listener);
-    }
-
-    @Override
-    protected Pair<RemoteOperation, RemoteOperationResult> doInBackground(Object... params) {
-
-        GetSharesForFileOperation operation = null;
-        RemoteOperationResult result = null;
-
-        if (params != null && params.length == 3) {
-            OCFile file = (OCFile) params[0];
-            Account account = (Account) params[1];
-            FileDataStorageManager fileDataStorageManager = (FileDataStorageManager) params[2];
-
-            try {
-                // Get shares request
-                operation = new GetSharesForFileOperation(file.getRemotePath(), false, false);
-                OwnCloudAccount ocAccount = new OwnCloudAccount(
-                        account,
-                        MainApp.getAppContext()
-                );
-                OwnCloudClient client = OwnCloudClientManagerFactory.getDefaultSingleton().
-                        getClientFor(ocAccount, MainApp.getAppContext());
-                result = operation.execute(client, fileDataStorageManager);
-
-            } catch (Exception e) {
-                result = new RemoteOperationResult(e);
-                Log_OC.e(TAG, "Exception while getting shares", e);
-            }
-        } else {
-            result = new RemoteOperationResult(RemoteOperationResult.ResultCode.UNKNOWN_ERROR);
-        }
-
-        return new Pair(operation, result);
-    }
-
-    @Override
-    protected void onPostExecute(Pair<RemoteOperation, RemoteOperationResult> result) {
-
-        if (result != null) {
-            OnRemoteOperationListener listener = mListener.get();
-            if (listener != null) {
-                listener.onRemoteOperationFinish(result.first, result.second);
-            }
-        }
-    }
-
-}

+ 51 - 4
src/main/res/layout/share_activity.xml

@@ -16,17 +16,64 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 -->
 
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    android:orientation="vertical"
+    android:paddingBottom="@dimen/standard_padding"
     tools:context="com.owncloud.android.ui.activity.ShareActivity">
 
+    <RelativeLayout
+        android:id="@+id/shareHeaderContainer"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:padding="@dimen/standard_padding">
+
+        <ImageView
+            android:id="@+id/shareFileIcon"
+            android:layout_width="@dimen/file_icon_size"
+            android:layout_height="@dimen/file_icon_size"
+            android:layout_gravity="center_vertical"
+            android:layout_marginEnd="@dimen/standard_half_margin"
+            android:contentDescription="@null"
+            android:src="@drawable/file" />
+
+        <TextView
+            android:id="@+id/shareFileName"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginEnd="@dimen/standard_half_margin"
+            android:layout_marginStart="@dimen/standard_quarter_margin"
+            android:layout_toEndOf="@+id/shareFileIcon"
+            android:ellipsize="middle"
+            android:singleLine="true"
+            android:text="@string/placeholder_filename"
+            android:textColor="@color/text_color"
+            android:textSize="@dimen/two_line_primary_text_size" />
+
+        <TextView
+            android:id="@+id/shareFileSize"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_below="@+id/shareFileName"
+            android:layout_gravity="center_vertical"
+            android:layout_marginStart="@dimen/standard_quarter_margin"
+            android:layout_toEndOf="@+id/shareFileIcon"
+            android:text="@string/placeholder_fileSize"
+            android:textSize="@dimen/share_file_layout_text_size" />
+
+    </RelativeLayout>
+
+    <View
+        android:id="@+id/share_header_divider"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/standard_eighth_margin"
+        android:background="@color/primary" />
+
     <FrameLayout
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:id="@+id/share_fragment_container">
-    </FrameLayout>
+        android:id="@+id/share_fragment_container"></FrameLayout>
 
 </LinearLayout>

+ 0 - 326
src/main/res/layout/share_file_layout.xml

@@ -1,326 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ownCloud Android client application
-  Copyright (C) 2015 ownCloud Inc.
-
-  This program is free software: you can redistribute it and/or modify
-  it under the terms of the GNU General Public License version 2,
-  as published by the Free Software Foundation.
-
-  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 <http://www.gnu.org/licenses/>.
--->
-<ScrollView android:id="@+id/shareScroll"
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    tools:context="com.owncloud.android.ui.fragment.ShareFileFragment">
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:orientation="vertical"
-        >
-
-        <RelativeLayout
-            android:id="@+id/shareHeaderContainer"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:padding="@dimen/standard_padding">
-
-            <ImageView
-                android:id="@+id/shareFileIcon"
-                android:layout_width="@dimen/file_icon_size"
-                android:layout_height="@dimen/file_icon_size"
-                android:layout_gravity="center_vertical"
-                android:layout_marginEnd="@dimen/standard_half_margin"
-                android:contentDescription="@null"
-                android:src="@drawable/file"/>
-
-            <TextView
-                android:id="@+id/shareFileName"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginEnd="@dimen/standard_half_margin"
-                android:layout_marginStart="@dimen/standard_quarter_margin"
-                android:layout_toEndOf="@+id/shareFileIcon"
-                android:ellipsize="middle"
-                android:singleLine="true"
-                android:text="@string/placeholder_filename"
-                android:textColor="@color/text_color"
-                android:textSize="@dimen/two_line_primary_text_size"/>
-
-            <TextView
-                android:id="@+id/shareFileSize"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_below="@+id/shareFileName"
-                android:layout_gravity="center_vertical"
-                android:layout_marginStart="@dimen/standard_quarter_margin"
-                android:layout_toEndOf="@+id/shareFileIcon"
-                android:text="@string/placeholder_fileSize"
-                android:textSize="@dimen/share_file_layout_text_size"/>
-
-        </RelativeLayout>
-
-        <View
-            android:id="@+id/share_header_divider"
-            android:layout_width="match_parent"
-            android:layout_height="@dimen/standard_eighth_margin"
-            android:background="@color/primary"
-            />
-
-        <LinearLayout
-            android:id="@+id/shareWithUsersSection"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="vertical"
-            android:paddingLeft="@dimen/standard_padding"
-            android:paddingRight="@dimen/standard_padding"
-            android:paddingTop="@dimen/standard_padding"
-            >
-
-            <TextView
-                android:id="@+id/shareWithUsersSectionTitle"
-                style="@style/TextAppearance.AppCompat.Body2"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_gravity="start"
-                android:text="@string/share_with_user_section_title"
-                android:textColor="@color/color_accent"/>
-
-            <ListView
-                android:id="@+id/shareUsersList"
-                android:layout_width="match_parent"
-                android:layout_height="0dip"
-                android:layout_weight="1"
-                android:paddingStart="@dimen/standard_half_padding"
-                android:paddingEnd="@dimen/standard_half_padding"
-                android:scrollbars="vertical"
-                android:visibility="gone"/>
-
-            <TextView
-                android:id="@+id/shareNoUsers"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:padding="@dimen/standard_half_padding"
-                android:text="@string/share_no_users"
-                android:textSize="@dimen/share_file_layout_text_size"/>
-
-            <com.google.android.material.button.MaterialButton
-                android:id="@+id/addUserButton"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_gravity="center_horizontal"
-                android:contentDescription="@string/share_add_user_or_group"
-                android:text="@string/share_add_user_or_group"
-                android:theme="@style/Button.Primary"
-                app:cornerRadius="@dimen/button_corner_radius" />
-
-        </LinearLayout>
-
-        <LinearLayout
-            android:id="@+id/shareViaLinkSection"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="vertical"
-            android:paddingBottom="@dimen/standard_padding"
-            android:paddingLeft="@dimen/standard_padding"
-            android:paddingRight="@dimen/standard_padding"
-            >
-
-            <androidx.appcompat.widget.SwitchCompat
-                android:id="@+id/shareViaLinkSectionSwitch"
-                style="@style/TextAppearance.AppCompat.Body2"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_gravity="start"
-                android:layout_marginTop="@dimen/standard_half_margin"
-                android:checked="false"
-                android:paddingEnd="@dimen/standard_half_padding"
-                android:paddingStart="@dimen/zero"
-                android:text="@string/share_via_link_section_title"
-                android:textColor="@color/color_accent"/>
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="vertical"
-                android:layout_marginTop="@dimen/standard_half_margin">
-
-                <RelativeLayout
-                    android:id="@+id/shareViaLinkEditPermissionSection"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:visibility="gone"
-                    android:layout_marginBottom="@dimen/standard_half_margin"
-                    >
-
-                    <androidx.appcompat.widget.SwitchCompat
-                        android:id="@+id/shareViaLinkEditPermissionSwitch"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_alignParentEnd="true"
-                        android:layout_centerInParent="true"
-                        android:padding="@dimen/standard_half_padding"
-                        />
-
-                    <TextView
-                        android:id="@+id/shareViaLinkEditPermissionLabel"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_alignParentStart="true"
-                        android:layout_toStartOf="@id/shareViaLinkEditPermissionSwitch"
-                        android:padding="@dimen/standard_half_padding"
-                        android:text="@string/share_via_link_edit_permission_label"
-                        android:textColor="@color/text_color"
-                        android:textSize="14sp"
-                        />
-
-                </RelativeLayout>
-
-                <RelativeLayout
-                    android:id="@+id/shareViaLinkHideFileListingPermissionSection"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:visibility="gone"
-                    android:layout_marginBottom="@dimen/standard_half_margin"
-                    >
-
-                    <androidx.appcompat.widget.SwitchCompat
-                        android:id="@+id/shareViaLinkFileListingPermissionSwitch"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_alignParentEnd="true"
-                        android:layout_centerInParent="true"
-                        android:padding="@dimen/standard_half_padding"
-                        />
-
-                    <TextView
-                        android:id="@+id/shareViaLinkFileListingPermissionLabel"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_alignParentStart="true"
-                        android:layout_toStartOf="@id/shareViaLinkFileListingPermissionSwitch"
-                        android:padding="@dimen/standard_half_padding"
-                        android:text="@string/share_via_link_hide_file_listing_permission_label"
-                        android:textColor="@color/text_color"
-                        android:textSize="@dimen/two_line_secondary_text_size"
-                        />
-
-                </RelativeLayout>
-
-                <RelativeLayout
-                    android:id="@+id/shareViaLinkPasswordSection"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    >
-
-                    <androidx.appcompat.widget.SwitchCompat
-                        android:id="@+id/shareViaLinkPasswordSwitch"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_alignParentEnd="true"
-                        android:layout_alignParentTop="true"
-                        android:padding="@dimen/standard_half_padding"
-                        />
-
-                    <TextView
-                        android:id="@+id/shareViaLinkPasswordLabel"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_alignParentStart="true"
-                        android:layout_toStartOf="@id/shareViaLinkPasswordSwitch"
-                        android:paddingLeft="@dimen/standard_half_padding"
-                        android:paddingRight="@dimen/standard_half_padding"
-                        android:paddingTop="@dimen/standard_half_padding"
-                        android:text="@string/share_via_link_password_label"
-                        android:textColor="@color/text_color"
-                        android:textSize="@dimen/two_line_secondary_text_size"
-                        />
-
-                    <TextView
-                        android:id="@+id/shareViaLinkPasswordValue"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_alignParentStart="true"
-                        android:layout_below="@id/shareViaLinkPasswordLabel"
-                        android:layout_toStartOf="@id/shareViaLinkPasswordSwitch"
-                        android:paddingBottom="@dimen/standard_half_padding"
-                        android:paddingLeft="@dimen/standard_half_padding"
-                        android:paddingRight="@dimen/standard_half_padding"
-                        android:text="@string/share_via_link_password_title"
-                        android:textSize="@dimen/share_file_layout_text_size"
-                        android:visibility="invisible"
-                        />
-
-                </RelativeLayout>
-
-                <RelativeLayout
-                    android:id="@+id/shareViaLinkExpirationSection"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    >
-
-                    <androidx.appcompat.widget.SwitchCompat
-                        android:id="@+id/shareViaLinkExpirationSwitch"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_alignParentEnd="true"
-                        android:layout_alignParentTop="true"
-                        android:checked="false"
-                        android:padding="@dimen/standard_half_padding"/>
-
-                    <TextView
-                        android:id="@+id/shareViaLinkExpirationLabel"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_alignParentStart="true"
-                        android:layout_toStartOf="@id/shareViaLinkExpirationSwitch"
-                        android:paddingLeft="@dimen/standard_half_padding"
-                        android:paddingRight="@dimen/standard_half_padding"
-                        android:paddingTop="@dimen/standard_half_padding"
-                        android:text="@string/share_via_link_expiration_date_label"
-                        android:textColor="@color/text_color"
-                        android:textSize="@dimen/two_line_secondary_text_size"
-                        />
-
-                    <TextView
-                        android:id="@+id/shareViaLinkExpirationValue"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_alignParentStart="true"
-                        android:layout_below="@id/shareViaLinkExpirationLabel"
-                        android:layout_toStartOf="@id/shareViaLinkExpirationSwitch"
-                        android:paddingBottom="@dimen/standard_half_padding"
-                        android:paddingLeft="@dimen/standard_half_padding"
-                        android:paddingRight="@dimen/standard_half_padding"
-                        android:textSize="@dimen/share_file_layout_text_size"
-                        />
-
-                </RelativeLayout>
-
-                <com.google.android.material.button.MaterialButton
-                    android:id="@+id/shareViaLinkGetLinkButton"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:layout_gravity="center_horizontal"
-                    android:contentDescription="@string/share_get_public_link_button"
-                    android:text="@string/share_get_public_link_button"
-                    android:theme="@style/Button.Primary"
-                    app:cornerRadius="@dimen/button_corner_radius" />
-
-            </LinearLayout>
-
-        </LinearLayout>
-
-    </LinearLayout>
-
-</ScrollView>

+ 0 - 7
src/main/res/values/strings.xml

@@ -473,13 +473,7 @@
 
     <string name="share_dialog_title">Sharing</string>
     <string name="share_file">Share %1$s</string>
-    <string name="share_with_user_section_title">Share with users and groups</string>
     <string name="share_no_users">No data shared with users yet</string>
-    <string name="share_add_user_or_group">Add user or group</string>
-    <string name="share_via_link_edit_permission_label">Allow editing</string>
-    <string name="share_via_link_password_label">Protect with password</string>
-    <string name="share_via_link_password_title">Secured</string>
-    <string name="share_via_link_expiration_date_label">Set expiration date</string>
     <string name="share_via_link_menu_password_label">Password protect (%1$s)</string>
     <string name="share_expiration_date_label">Expires %1$s</string>
     <string name="share_no_expiration_date_label">Set expiration date</string>
@@ -489,7 +483,6 @@
     <string name="share_no_password_title">Set password</string>
     <string name="edit_permission_label">edit</string>
     <string name="share_via_link_hide_file_listing_permission_label">Hide file listing</string>
-    <string name="share_get_public_link_button">Get link</string>
     <string name="share_with_title">Share with…</string>
     <string name="share_with_edit_title">Share with %1$s</string>
     <string name="share_via_link_unset_password">Unset</string>