Răsfoiți Sursa

Unified search: several UI and navigation improvements

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
Álvaro Brey Vilas 3 ani în urmă
părinte
comite
3fc6fc8bdf

+ 165 - 170
src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -51,6 +51,7 @@ import android.view.ViewTreeObserver;
 import android.view.WindowManager;
 
 import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
 import com.google.android.material.snackbar.Snackbar;
 import com.nextcloud.client.account.User;
 import com.nextcloud.client.appinfo.AppInfo;
@@ -152,9 +153,9 @@ import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
  * Displays, what files the user has available in his ownCloud. This is the main view.
  */
 public class FileDisplayActivity extends FileActivity
-        implements FileFragment.ContainerActivity,
-        OnEnforceableRefreshListener, SortingOrderDialogFragment.OnSortingOrderListener,
-        SendShareDialog.SendShareDialogDownloader, Injectable {
+    implements FileFragment.ContainerActivity,
+    OnEnforceableRefreshListener, SortingOrderDialogFragment.OnSortingOrderListener,
+    SendShareDialog.SendShareDialogDownloader, Injectable {
 
     public static final String RESTART = "RESTART";
     public static final String ALL_FILES = "ALL_FILES";
@@ -273,7 +274,7 @@ public class FileDisplayActivity extends FileActivity
         // Init Fragment without UI to retain AsyncTask across configuration changes
         FragmentManager fm = getSupportFragmentManager();
         TaskRetainerFragment taskRetainerFragment =
-                (TaskRetainerFragment) fm.findFragmentByTag(TaskRetainerFragment.FTAG_TASK_RETAINER_FRAGMENT);
+            (TaskRetainerFragment) fm.findFragmentByTag(TaskRetainerFragment.FTAG_TASK_RETAINER_FRAGMENT);
         if (taskRetainerFragment == null) {
             taskRetainerFragment = new TaskRetainerFragment();
             fm.beginTransaction()
@@ -357,8 +358,7 @@ public class FileDisplayActivity extends FileActivity
     }
 
     /**
-     * For Android 7+.
-     * Opens a pop up info for the new instant upload and disabled the old instant upload.
+     * For Android 7+. Opens a pop up info for the new instant upload and disabled the old instant upload.
      */
     private void upgradeNotificationForInstantUpload() {
         // check for Android 6+ if legacy instant upload is activated --> disable + show info
@@ -366,23 +366,23 @@ public class FileDisplayActivity extends FileActivity
             preferences.removeLegacyPreferences();
             // show info pop-up
             new AlertDialog.Builder(this, R.style.Theme_ownCloud_Dialog)
-                    .setTitle(R.string.drawer_synced_folders)
-                    .setMessage(R.string.synced_folders_new_info)
-                    .setPositiveButton(R.string.drawer_open, new DialogInterface.OnClickListener() {
-                        public void onClick(DialogInterface dialog, int which) {
-                            // show instant upload
-                            Intent syncedFoldersIntent = new Intent(getApplicationContext(), SyncedFoldersActivity.class);
-                            dialog.dismiss();
-                            startActivity(syncedFoldersIntent);
-                        }
-                    })
-                    .setNegativeButton(R.string.drawer_close, new DialogInterface.OnClickListener() {
-                        public void onClick(DialogInterface dialog, int which) {
-                            dialog.dismiss();
-                        }
-                    })
-                    .setIcon(R.drawable.nav_synced_folders)
-                    .show();
+                .setTitle(R.string.drawer_synced_folders)
+                .setMessage(R.string.synced_folders_new_info)
+                .setPositiveButton(R.string.drawer_open, new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialog, int which) {
+                        // show instant upload
+                        Intent syncedFoldersIntent = new Intent(getApplicationContext(), SyncedFoldersActivity.class);
+                        dialog.dismiss();
+                        startActivity(syncedFoldersIntent);
+                    }
+                })
+                .setNegativeButton(R.string.drawer_close, new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialog, int which) {
+                        dialog.dismiss();
+                    }
+                })
+                .setIcon(R.drawable.nav_synced_folders)
+                .show();
         }
     }
 
@@ -406,7 +406,7 @@ public class FileDisplayActivity extends FileActivity
             case PermissionUtil.PERMISSIONS_WRITE_EXTERNAL_STORAGE: {
                 // If request is cancelled, result arrays are empty.
                 if (grantResults.length > 0
-                        && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                     // permission was granted
                     EventBus.getDefault().post(new TokenPushEvent());
                     syncAndUpdateFolder(true);
@@ -440,7 +440,7 @@ public class FileDisplayActivity extends FileActivity
             Bundle args = new Bundle();
 
             args.putParcelable(OCFileListFragment.SEARCH_EVENT,
-                    getIntent().getParcelableExtra(OCFileListFragment.SEARCH_EVENT));
+                               getIntent().getParcelableExtra(OCFileListFragment.SEARCH_EVENT));
             args.putBoolean(OCFileListFragment.ARG_ALLOW_CONTEXTUAL_ACTIONS, true);
 
             listOfFiles.setArguments(args);
@@ -578,6 +578,12 @@ public class FileDisplayActivity extends FileActivity
         transaction.addToBackStack(null);
         transaction.replace(R.id.left_fragment_container, fragment, TAG_LIST_OF_FILES);
         transaction.commit();
+
+        if (fragment instanceof UnifiedSearchFragment) {
+            showSortListGroup(false);
+        } else {
+            showSortListGroup(true);
+        }
     }
 
 
@@ -840,7 +846,8 @@ public class FileDisplayActivity extends FileActivity
                     isSearchOpen()) {
                 onBackPressed();
             } else if (getLeftFragment() instanceof FileDetailFragment ||
-                    getLeftFragment() instanceof PreviewMediaFragment) {
+                getLeftFragment() instanceof PreviewMediaFragment ||
+                getLeftFragment() instanceof UnifiedSearchFragment) {
                 onBackPressed();
             } else {
                 openDrawer();
@@ -854,7 +861,7 @@ public class FileDisplayActivity extends FileActivity
         } else {
             retval = super.onOptionsItemSelected(item);
         }
-        
+
         return retval;
     }
 
@@ -865,21 +872,21 @@ public class FileDisplayActivity extends FileActivity
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
 
         if (requestCode == REQUEST_CODE__SELECT_CONTENT_FROM_APPS &&
-                (resultCode == RESULT_OK ||
-                        resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
+            (resultCode == RESULT_OK ||
+                resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
 
             requestUploadOfContentFromApps(data, resultCode);
 
         } else if (requestCode == REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM &&
-                (resultCode == RESULT_OK ||
-                        resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE ||
-                        resultCode == UploadFilesActivity.RESULT_OK_AND_DO_NOTHING ||
-                        resultCode == UploadFilesActivity.RESULT_OK_AND_DELETE)) {
+            (resultCode == RESULT_OK ||
+                resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE ||
+                resultCode == UploadFilesActivity.RESULT_OK_AND_DO_NOTHING ||
+                resultCode == UploadFilesActivity.RESULT_OK_AND_DELETE)) {
 
             requestUploadOfFilesFromFileSystem(data, resultCode);
 
         } else if (requestCode == REQUEST_CODE__UPLOAD_FROM_CAMERA &&
-                (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_DELETE)) {
+            (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_DELETE)) {
 
             new CheckAvailableSpaceTask(new CheckAvailableSpaceTask.CheckAvailableSpaceListener() {
                 @Override
@@ -910,27 +917,27 @@ public class FileDisplayActivity extends FileActivity
             exitSelectionMode();
             final Intent fData = data;
             getHandler().postDelayed(
-                    new Runnable() {
-                        @Override
-                        public void run() {
-                            requestMoveOperation(fData);
-                        }
-                    },
-                    DELAY_TO_REQUEST_OPERATIONS_LATER
-            );
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        requestMoveOperation(fData);
+                    }
+                },
+                DELAY_TO_REQUEST_OPERATIONS_LATER
+                                    );
 
         } else if (requestCode == REQUEST_CODE__COPY_FILES && resultCode == RESULT_OK) {
             exitSelectionMode();
             final Intent fData = data;
             getHandler().postDelayed(
-                    new Runnable() {
-                        @Override
-                        public void run() {
-                            requestCopyOperation(fData);
-                        }
-                    },
-                    DELAY_TO_REQUEST_OPERATIONS_LATER
-            );
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        requestCopyOperation(fData);
+                    }
+                },
+                DELAY_TO_REQUEST_OPERATIONS_LATER
+                                    );
         } else {
             super.onActivityResult(requestCode, resultCode, data);
         }
@@ -993,7 +1000,7 @@ public class FileDisplayActivity extends FileActivity
                 false,
                 false,
                 NameCollisionPolicy.ASK_USER
-            );
+                                      );
 
         } else {
             Log_OC.d(TAG, "User clicked on 'Update' with no selection");
@@ -1016,19 +1023,19 @@ public class FileDisplayActivity extends FileActivity
         }
 
         int behaviour = (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE) ? FileUploader.LOCAL_BEHAVIOUR_MOVE :
-                FileUploader.LOCAL_BEHAVIOUR_COPY;
+            FileUploader.LOCAL_BEHAVIOUR_COPY;
 
         OCFile currentDir = getCurrentDir();
         String remotePath = (currentDir != null) ? currentDir.getRemotePath() : OCFile.ROOT_PATH;
 
         UriUploader uploader = new UriUploader(
-                this,
-                streamsToUpload,
-                remotePath,
-                getUser().orElseThrow(RuntimeException::new),
-                behaviour,
-                false, // Not show waiting dialog while file is being copied from private storage
-                null  // Not needed copy temp task listener
+            this,
+            streamsToUpload,
+            remotePath,
+            getUser().orElseThrow(RuntimeException::new),
+            behaviour,
+            false, // Not show waiting dialog while file is being copied from private storage
+            null  // Not needed copy temp task listener
         );
 
         uploader.uploadUris();
@@ -1076,10 +1083,10 @@ public class FileDisplayActivity extends FileActivity
     @SuppressFBWarnings("ITC_INHERITANCE_TYPE_CHECKING")
     @Override
     public void onBackPressed() {
-        boolean isDrawerOpen = isDrawerOpen();
-        boolean isSearchOpen = isSearchOpen();
+        final boolean isDrawerOpen = isDrawerOpen();
+        final boolean isSearchOpen = isSearchOpen();
 
-        Fragment leftFragment = getLeftFragment();
+        final Fragment leftFragment = getLeftFragment();
 
         if (leftFragment instanceof OCFileListFragment) {
             OCFileListFragment listOfFiles = (OCFileListFragment) leftFragment;
@@ -1119,6 +1126,7 @@ public class FileDisplayActivity extends FileActivity
         } else {
             // pop back
             hideSearchView(getCurrentDir());
+            showSortListGroup(true);
             super.onBackPressed();
         }
     }
@@ -1271,11 +1279,11 @@ public class FileDisplayActivity extends FileActivity
                 String accountName = intent.getStringExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME);
 
                 String synchFolderRemotePath =
-                        intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH);
+                    intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH);
                 RemoteOperationResult synchResult = (RemoteOperationResult)
-                        DataHolderUtil.getInstance().retrieve(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));
+                    DataHolderUtil.getInstance().retrieve(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));
                 boolean sameAccount = getAccount() != null &&
-                        accountName.equals(getAccount().name) && getStorageManager() != null;
+                    accountName.equals(getAccount().name) && getStorageManager() != null;
 
                 if (sameAccount) {
 
@@ -1291,10 +1299,10 @@ public class FileDisplayActivity extends FileActivity
                         if (currentDir == null) {
                             // current folder was removed from the server
                             DisplayUtils.showSnackMessage(
-                                    getActivity(),
-                                    R.string.sync_current_folder_was_removed,
-                                    synchFolderRemotePath
-                            );
+                                getActivity(),
+                                R.string.sync_current_folder_was_removed,
+                                synchFolderRemotePath
+                                                         );
 
                             browseToRoot();
 
@@ -1316,10 +1324,10 @@ public class FileDisplayActivity extends FileActivity
                         }
 
                         mSyncInProgress = !FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) &&
-                                !RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event);
+                            !RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event);
 
                         if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.equals(event) &&
-                                synchResult != null) {
+                            synchResult != null) {
 
                             if (synchResult.isSuccess()) {
                                 hideInfoBox();
@@ -1364,7 +1372,7 @@ public class FileDisplayActivity extends FileActivity
                 }
 
                 if (synchResult != null && synchResult.getCode().equals(
-                        RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) {
+                    RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) {
                     mLastSslUntrustedServerResult = synchResult;
                 }
             } catch (RuntimeException e) {
@@ -1383,13 +1391,12 @@ public class FileDisplayActivity extends FileActivity
 
     private boolean checkForRemoteOperationError(RemoteOperationResult syncResult) {
         return ResultCode.UNAUTHORIZED.equals(syncResult.getCode()) ||
-                (syncResult.isException() && syncResult.getException()
-                        instanceof AuthenticatorException);
+            (syncResult.isException() && syncResult.getException()
+                instanceof AuthenticatorException);
     }
 
     /**
-     * Show a text message on screen view for notifying user if content is
-     * loading or folder is empty
+     * Show a text message on screen view for notifying user if content is loading or folder is empty
      */
     private void setBackgroundText() {
         final OCFileListFragment ocFileListFragment = getListOfFilesFragment();
@@ -1418,7 +1425,7 @@ public class FileDisplayActivity extends FileActivity
     private class UploadFinishReceiver extends BroadcastReceiver {
         /**
          * Once the file upload has finished -> update view
-         *
+         * <p>
          * {@link BroadcastReceiver} to enable upload feedback in UI
          */
         @Override
@@ -1461,7 +1468,7 @@ public class FileDisplayActivity extends FileActivity
                         getActivity(),
                         R.string.filedetails_renamed_in_upload_msg,
                         newName
-                    );
+                                                 );
                 }
                 if (uploadWasFine || getFile().fileExists()) {
                     ((FileDetailFragment) details).updateFileDetails(false, true);
@@ -1496,9 +1503,8 @@ public class FileDisplayActivity extends FileActivity
 
     /**
      * Class waiting for broadcast events from the {@link FileDownloader} service.
-     *
-     * Updates the UI when a download is started or finished, provided that it is relevant for the
-     * current folder.
+     * <p>
+     * Updates the UI when a download is started or finished, provided that it is relevant for the current folder.
      */
     private class DownloadFinishReceiver extends BroadcastReceiver {
 
@@ -1509,16 +1515,16 @@ public class FileDisplayActivity extends FileActivity
             String downloadBehaviour = intent.getStringExtra(OCFileListFragment.DOWNLOAD_BEHAVIOUR);
             boolean isDescendant = isDescendant(downloadedRemotePath);
 
-                if (sameAccount && isDescendant) {
-                    String linkedToRemotePath = intent.getStringExtra(FileDownloader.EXTRA_LINKED_TO_PATH);
-                    if (linkedToRemotePath == null || isAscendant(linkedToRemotePath)) {
-                        updateListOfFilesFragment(false);
-                    }
-                    refreshSecondFragment(
-                            intent.getAction(),
-                            downloadedRemotePath,
-                            intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false));
+            if (sameAccount && isDescendant) {
+                String linkedToRemotePath = intent.getStringExtra(FileDownloader.EXTRA_LINKED_TO_PATH);
+                if (linkedToRemotePath == null || isAscendant(linkedToRemotePath)) {
+                    updateListOfFilesFragment(false);
                 }
+                refreshSecondFragment(
+                    intent.getAction(),
+                    downloadedRemotePath,
+                    intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false));
+            }
 
             if (mWaitingToSend != null) {
                 // update file after downloading
@@ -1542,7 +1548,7 @@ public class FileDisplayActivity extends FileActivity
         private boolean isDescendant(String downloadedRemotePath) {
             OCFile currentDir = getCurrentDir();
             return currentDir != null &&
-                    downloadedRemotePath != null &&
+                downloadedRemotePath != null &&
                 downloadedRemotePath.startsWith(currentDir.getRemotePath());
         }
 
@@ -1572,8 +1578,7 @@ public class FileDisplayActivity extends FileActivity
 
 
     /**
-     * {@inheritDoc}
-     * Updates action bar and second fragment, if in dual pane mode.
+     * {@inheritDoc} Updates action bar and second fragment, if in dual pane mode.
      */
     @Override
     public void onBrowsedDownTo(OCFile directory) {
@@ -1584,8 +1589,7 @@ public class FileDisplayActivity extends FileActivity
     }
 
     /**
-     * Shows the information of the {@link OCFile} received as a
-     * parameter in the second fragment.
+     * Shows the information of the {@link OCFile} received as a parameter in the second fragment.
      *
      * @param file {@link OCFile} whose details will be shown
      */
@@ -1595,10 +1599,9 @@ public class FileDisplayActivity extends FileActivity
     }
 
     /**
-     * Shows the information of the {@link OCFile} received as a
-     * parameter in the second fragment.
+     * Shows the information of the {@link OCFile} received as a parameter in the second fragment.
      *
-     * @param file {@link OCFile} whose details will be shown
+     * @param file      {@link OCFile} whose details will be shown
      * @param activeTab the active tab in the details view
      */
     public void showDetails(OCFile file, int activeTab) {
@@ -1661,7 +1664,7 @@ public class FileDisplayActivity extends FileActivity
                     }
                 }
             } else if (component.equals(new ComponentName(FileDisplayActivity.this,
-                    FileUploader.class))) {
+                                                          FileUploader.class))) {
                 Log_OC.d(TAG, "Upload service connected");
                 mUploaderBinder = (FileUploaderBinder) service;
             } else {
@@ -1671,7 +1674,7 @@ public class FileDisplayActivity extends FileActivity
             // getFileDownloadBinder() - THIS IS A MESS
             OCFileListFragment listOfFiles = getListOfFilesFragment();
             if (listOfFiles != null && (getIntent() == null ||
-                    (getIntent() != null && getIntent().getParcelableExtra(EXTRA_FILE) == null))) {
+                (getIntent() != null && getIntent().getParcelableExtra(EXTRA_FILE) == null))) {
                 listOfFiles.listDirectory(MainApp.isOnlyOnDevice(), false);
             }
             FileFragment secondFragment = getSecondFragment();
@@ -1695,8 +1698,8 @@ public class FileDisplayActivity extends FileActivity
     }
 
     /**
-     * Updates the view associated to the activity after the finish of some operation over files
-     * in the current account.
+     * Updates the view associated to the activity after the finish of some operation over files in the current
+     * account.
      *
      * @param operation Removal operation performed.
      * @param result    Result of the removal.
@@ -1743,8 +1746,7 @@ public class FileDisplayActivity extends FileActivity
     }
 
     /**
-     * Updates the view associated to the activity after the finish of an operation trying to
-     * remove a file.
+     * Updates the view associated to the activity after the finish of an operation trying to remove a file.
      *
      * @param operation Removal operation performed.
      * @param result    Result of the removal.
@@ -1754,7 +1756,7 @@ public class FileDisplayActivity extends FileActivity
 
         if (!operation.isInBackground()) {
             DisplayUtils.showSnackMessage(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation,
-                    getResources()));
+                                                                                         getResources()));
         }
 
         if (result.isSuccess()) {
@@ -1821,8 +1823,7 @@ public class FileDisplayActivity extends FileActivity
     }
 
     /**
-     * Updates the view associated to the activity after the finish of an operation trying to move a
-     * file.
+     * Updates the view associated to the activity after the finish of an operation trying to move a file.
      *
      * @param operation Move operation performed.
      * @param result    Result of the move operation.
@@ -1834,8 +1835,8 @@ public class FileDisplayActivity extends FileActivity
         } else {
             try {
                 DisplayUtils.showSnackMessage(
-                        this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
-                );
+                    this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
+                                             );
 
             } catch (NotFoundException e) {
                 Log_OC.e(TAG, "Error while trying to show fail message ", e);
@@ -1844,8 +1845,7 @@ public class FileDisplayActivity extends FileActivity
     }
 
     /**
-     * Updates the view associated to the activity after the finish of an operation trying to copy a
-     * file.
+     * Updates the view associated to the activity after the finish of an operation trying to copy a file.
      *
      * @param operation Copy operation performed.
      * @param result    Result of the copy operation.
@@ -1856,8 +1856,8 @@ public class FileDisplayActivity extends FileActivity
         } else {
             try {
                 DisplayUtils.showSnackMessage(
-                        this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
-                );
+                    this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
+                                             );
 
             } catch (NotFoundException e) {
                 Log_OC.e(TAG, "Error while trying to show fail message ", e);
@@ -1866,8 +1866,7 @@ public class FileDisplayActivity extends FileActivity
     }
 
     /**
-     * Updates the view associated to the activity after the finish of an operation trying to rename
-     * a file.
+     * Updates the view associated to the activity after the finish of an operation trying to rename a file.
      *
      * @param operation Renaming operation performed.
      * @param result    Result of the renaming.
@@ -1881,12 +1880,12 @@ public class FileDisplayActivity extends FileActivity
             FileFragment details = getSecondFragment();
             if (details != null) {
                 if (details instanceof FileDetailFragment &&
-                        renamedFile.equals(details.getFile())) {
+                    renamedFile.equals(details.getFile())) {
                     ((FileDetailFragment) details).updateFileDetails(renamedFile, currentUser);
                     showDetails(renamedFile);
 
                 } else if (details instanceof PreviewMediaFragment &&
-                        renamedFile.equals(details.getFile())) {
+                    renamedFile.equals(details.getFile())) {
                     ((PreviewMediaFragment) details).updateFile(renamedFile);
                     if (PreviewMediaFragment.canBePreviewed(renamedFile)) {
                         long position = ((PreviewMediaFragment) details).getPosition();
@@ -1912,8 +1911,8 @@ public class FileDisplayActivity extends FileActivity
 
         } else {
             DisplayUtils.showSnackMessage(
-                    this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
-            );
+                this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
+                                         );
 
             if (result.isSslRecoverableException()) {
                 mLastSslUntrustedServerResult = result;
@@ -1934,8 +1933,7 @@ public class FileDisplayActivity extends FileActivity
     }
 
     /**
-     * Updates the view associated to the activity after the finish of an operation trying create a
-     * new folder
+     * Updates the view associated to the activity after the finish of an operation trying create a new folder
      *
      * @param operation Creation operation performed.
      * @param result    Result of the creation.
@@ -1953,7 +1951,7 @@ public class FileDisplayActivity extends FileActivity
                     DisplayUtils.showSnackMessage(this, R.string.folder_already_exists);
                 } else {
                     DisplayUtils.showSnackMessage(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation,
-                            getResources()));
+                                                                                                 getResources()));
                 }
             } catch (NotFoundException e) {
                 Log_OC.e(TAG, "Error while trying to show fail message ", e);
@@ -2004,16 +2002,15 @@ public class FileDisplayActivity extends FileActivity
 
     /**
      * Starts an operation to refresh the requested folder.
-     *
+     * <p>
      * The operation is run in a new background thread created on the fly.
-     *
-     * The refresh updates is a "light sync": properties of regular files in folder are updated (including
-     * associated shares), but not their contents. Only the contents of files marked to be kept-in-sync are
-     * synchronized too.
+     * <p>
+     * The refresh updates is a "light sync": properties of regular files in folder are updated (including associated
+     * shares), but not their contents. Only the contents of files marked to be kept-in-sync are synchronized too.
      *
      * @param folder     Folder to refresh.
-     * @param ignoreETag If 'true', the data from the server will be fetched and sync'ed even if the eTag
-     *                   didn't change.
+     * @param ignoreETag If 'true', the data from the server will be fetched and sync'ed even if the eTag didn't
+     *                   change.
      */
     public void startSyncFolderOperation(OCFile folder, boolean ignoreETag) {
         startSyncFolderOperation(folder, ignoreETag, false);
@@ -2021,16 +2018,15 @@ public class FileDisplayActivity extends FileActivity
 
     /**
      * Starts an operation to refresh the requested folder.
-     *
+     * <p>
      * The operation is run in a new background thread created on the fly.
-     *
-     * The refresh updates is a "light sync": properties of regular files in folder are updated (including
-     * associated shares), but not their contents. Only the contents of files marked to be kept-in-sync are
-     * synchronized too.
+     * <p>
+     * The refresh updates is a "light sync": properties of regular files in folder are updated (including associated
+     * shares), but not their contents. Only the contents of files marked to be kept-in-sync are synchronized too.
      *
      * @param folder      Folder to refresh.
-     * @param ignoreETag  If 'true', the data from the server will be fetched and sync'ed even if the eTag
-     *                    didn't change.
+     * @param ignoreETag  If 'true', the data from the server will be fetched and sync'ed even if the eTag didn't
+     *                    change.
      * @param ignoreFocus reloads file list even without focus, e.g. on tablet mode, focus can still be in detail view
      */
     public void startSyncFolderOperation(final OCFile folder, final boolean ignoreETag, boolean ignoreFocus) {
@@ -2039,12 +2035,12 @@ public class FileDisplayActivity extends FileActivity
         // or if the method is called from a dialog that is being dismissed
         if (TextUtils.isEmpty(searchQuery)) {
             getHandler().postDelayed(
-                    new Runnable() {
-                        @Override
-                        public void run() {
-                            if (ignoreFocus || hasWindowFocus()) {
-                                long currentSyncTime = System.currentTimeMillis();
-                                mSyncInProgress = true;
+                new Runnable() {
+                    @Override
+                    public void run() {
+                        if (ignoreFocus || hasWindowFocus()) {
+                            long currentSyncTime = System.currentTimeMillis();
+                            mSyncInProgress = true;
 
                                 // perform folder synchronization
                                 RemoteOperation synchFolderOp = new RefreshFolderOperation(folder,
@@ -2063,20 +2059,20 @@ public class FileDisplayActivity extends FileActivity
                                         null
                                 );
 
-                                OCFileListFragment fragment = getListOfFilesFragment();
+                            OCFileListFragment fragment = getListOfFilesFragment();
 
-                                if (fragment != null) {
-                                    fragment.setLoading(true);
-                                }
+                            if (fragment != null) {
+                                fragment.setLoading(true);
+                            }
 
-                                setBackgroundText();
+                            setBackgroundText();
 
-                            }   // else: NOTHING ; lets' not refresh when the user rotates the device but there is
-                            // another window floating over
-                        }
-                    },
-                    DELAY_TO_REQUEST_REFRESH_OPERATION_LATER
-            );
+                        }   // else: NOTHING ; lets' not refresh when the user rotates the device but there is
+                        // another window floating over
+                    }
+                },
+                DELAY_TO_REQUEST_REFRESH_OPERATION_LATER
+                                    );
         }
     }
 
@@ -2113,11 +2109,10 @@ public class FileDisplayActivity extends FileActivity
     }
 
     /**
-     * Requests the download of the received {@link OCFile} , updates the UI
-     * to monitor the download progress and prepares the activity to send the file
-     * when the download finishes.
+     * Requests the download of the received {@link OCFile} , updates the UI to monitor the download progress and
+     * prepares the activity to send the file when the download finishes.
      *
-     * @param file {@link OCFile} to download and preview.
+     * @param file         {@link OCFile} to download and preview.
      * @param packageName
      * @param activityName
      */
@@ -2258,9 +2253,8 @@ public class FileDisplayActivity extends FileActivity
     }
 
     /**
-     * Requests the download of the received {@link OCFile} , updates the UI
-     * to monitor the download progress and prepares the activity to preview
-     * or open the file when the download finishes.
+     * Requests the download of the received {@link OCFile} , updates the UI to monitor the download progress and
+     * prepares the activity to preview or open the file when the download finishes.
      *
      * @param file {@link OCFile} to download and preview.
      */
@@ -2356,11 +2350,11 @@ public class FileDisplayActivity extends FileActivity
                               (long) bundle.get(PreviewVideoActivity.EXTRA_START_POSITION),
                               (boolean) bundle.get(PreviewVideoActivity.EXTRA_AUTOPLAY), true, true);
         } else if (bundle.containsKey(PreviewImageActivity.EXTRA_VIRTUAL_TYPE)) {
-            startImagePreview((OCFile)bundle.get(EXTRA_FILE),
-                    (VirtualFolderType)bundle.get(PreviewImageActivity.EXTRA_VIRTUAL_TYPE),
-                    true);
+            startImagePreview((OCFile) bundle.get(EXTRA_FILE),
+                              (VirtualFolderType) bundle.get(PreviewImageActivity.EXTRA_VIRTUAL_TYPE),
+                              true);
         } else {
-            startImagePreview((OCFile)bundle.get(EXTRA_FILE),true);
+            startImagePreview((OCFile) bundle.get(EXTRA_FILE), true);
         }
     }
 
@@ -2516,12 +2510,13 @@ public class FileDisplayActivity extends FileActivity
     }
 
     public void performUnifiedSearch(String query) {
-        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
-        transaction.replace(R.id.left_fragment_container,
-                            UnifiedSearchFragment.Companion.newInstance(query),
-                            TAG_LIST_OF_FILES);
-        transaction.addToBackStack(null);
-        transaction.commit();
+        UnifiedSearchFragment unifiedSearchFragment = UnifiedSearchFragment.Companion.newInstance(query);
+        setLeftFragment(unifiedSearchFragment);
+    }
+
+    public void setMainFabVisible(final Boolean visible) {
+        final int visibility = visible ? View.VISIBLE : View.GONE;
+        binding.fabMain.setVisibility(visibility);
     }
 
     public void showFile(String message) {

+ 4 - 0
src/main/java/com/owncloud/android/ui/fragment/UnifiedSearchFragment.kt

@@ -111,6 +111,10 @@ class UnifiedSearchFragment : Fragment(), Injectable, UnifiedSearchListInterface
     override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
         super.onViewCreated(view, savedInstanceState)
 
+        if (activity is FileDisplayActivity) {
+            (activity as FileDisplayActivity).setMainFabVisible(false)
+        }
+
         val gridLayoutManager = GridLayoutManager(requireContext(), 1)
         adapter = UnifiedSearchListAdapter(
             storageManager,

+ 0 - 1
src/main/java/com/owncloud/android/ui/unifiedsearch/IUnifiedSearchRepository.kt

@@ -24,7 +24,6 @@ package com.owncloud.android.ui.unifiedsearch
 
 import com.owncloud.android.lib.common.SearchResult
 
-
 data class UnifiedSearchResult(val provider: ProviderID, val success: Boolean, val result: SearchResult)
 
 @Suppress("LongParameterList")

+ 3 - 2
src/main/java/com/owncloud/android/ui/unifiedsearch/SearchOnProviderTask.kt

@@ -28,7 +28,8 @@ class SearchOnProviderTask(
     private val query: String,
     private val provider: String,
     private val client: NextcloudClient,
-    private val cursor: Int? = null
+    private val cursor: Int? = null,
+    private val limit: Int = 5
 ) : () -> SearchOnProviderTask.Result {
     companion object {
         private const val TAG = "SearchOnProviderTask"
@@ -38,7 +39,7 @@ class SearchOnProviderTask(
 
     override fun invoke(): Result {
         Log_OC.d(TAG, "Run task")
-        val result = UnifiedSearchRemoteOperation(provider, query, cursor).execute(client)
+        val result = UnifiedSearchRemoteOperation(provider, query, cursor, limit).execute(client)
 
         Log_OC.d(TAG, "Task finished: " + result.isSuccess)
         return if (result.isSuccess && result.resultData != null) {

+ 6 - 6
src/main/java/com/owncloud/android/ui/unifiedsearch/UnifiedSearchViewModel.kt

@@ -68,7 +68,7 @@ class UnifiedSearchViewModel() : ViewModel() {
 
     private lateinit var repository: IUnifiedSearchRepository
     private var loadingStarted: Boolean = false
-    private var metaResults: MutableMap<ProviderID, UnifiedSearchMetadata> = mutableMapOf()
+    private var results: MutableMap<ProviderID, UnifiedSearchMetadata> = mutableMapOf()
 
     val isLoading: MutableLiveData<Boolean> = MutableLiveData<Boolean>(false)
     val searchResults = MutableLiveData<List<UnifiedSearchSection>>(mutableListOf())
@@ -97,7 +97,7 @@ class UnifiedSearchViewModel() : ViewModel() {
     }
 
     open fun refresh() {
-        metaResults = mutableMapOf()
+        results = mutableMapOf()
         searchResults.value = mutableListOf()
         initialQuery()
     }
@@ -126,7 +126,7 @@ class UnifiedSearchViewModel() : ViewModel() {
         val queryTerm = query.value.orEmpty()
 
         if (isLoading.value != true && queryTerm.isNotBlank()) {
-            metaResults[provider]?.nextCursor()?.let { cursor ->
+            results[provider]?.nextCursor()?.let { cursor ->
                 isLoading.value = true
                 repository.queryProvider(
                     queryTerm,
@@ -167,10 +167,10 @@ class UnifiedSearchViewModel() : ViewModel() {
     fun onSearchResult(result: UnifiedSearchResult) {
 
         if (result.success) {
-            val providerMeta = metaResults[result.provider] ?: UnifiedSearchMetadata()
+            val providerMeta = results[result.provider] ?: UnifiedSearchMetadata()
             providerMeta.results.add(result.result)
 
-            metaResults[result.provider] = providerMeta
+            results[result.provider] = providerMeta
             genSearchResultsFromMeta()
         }
 
@@ -181,7 +181,7 @@ class UnifiedSearchViewModel() : ViewModel() {
     }
 
     private fun genSearchResultsFromMeta() {
-        searchResults.value = metaResults
+        searchResults.value = results
             .filter { it.value.results.isNotEmpty() }
             .map { (key, value) ->
                 UnifiedSearchSection(