diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt index 82dc1eaa77f4..1cad11ff87d3 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt @@ -528,7 +528,7 @@ class FileDisplayActivity : /** First fragment */ val listOfFiles = this.listOfFilesFragment if (listOfFiles != null && TextUtils.isEmpty(searchQuery)) { - listOfFiles.listDirectory(getCurrentDir(), file, MainApp.isOnlyOnDevice(), false) + listOfFiles.listDirectory(getCurrentDir(), file, MainApp.isOnlyOnDevice()) } else { Log_OC.e(TAG, "Still have a chance to lose the initialization of list fragment >(") } @@ -806,9 +806,9 @@ class FileDisplayActivity : resetScrolling(true) } - fun updateListOfFilesFragment(fromSearch: Boolean) { + fun updateListOfFilesFragment() { val fileListFragment = this.listOfFilesFragment - fileListFragment?.listDirectory(MainApp.isOnlyOnDevice(), fromSearch) + fileListFragment?.listDirectory(MainApp.isOnlyOnDevice()) } fun resetSearchView() { @@ -1324,10 +1324,10 @@ class FileDisplayActivity : if (searchView != null && !TextUtils.isEmpty(searchQuery)) { searchView?.setQuery(searchQuery, false) } else if (!ocFileListFragment.isSearchFragment && startFile == null) { - updateListOfFilesFragment(false) + updateListOfFilesFragment() ocFileListFragment.registerFabListener() } else { - ocFileListFragment.listDirectory(startFile, false, false) + ocFileListFragment.listDirectory(startFile, false) updateActionBarTitleAndHomeButton(startFile) } @@ -1546,7 +1546,7 @@ class FileDisplayActivity : return } - ocFileListFragment.listDirectory(currentDir, MainApp.isOnlyOnDevice(), false) + ocFileListFragment.listDirectory(currentDir, MainApp.isOnlyOnDevice()) } private fun handleScrollBehaviour(ocFileListFragment: OCFileListFragment?) { @@ -1659,7 +1659,7 @@ class FileDisplayActivity : if (sameAccount && isDescendant) { val linkedToRemotePath = intent.getStringExtra(FileUploadWorker.EXTRA_LINKED_TO_PATH) if (linkedToRemotePath == null || isAscendant(linkedToRemotePath)) { - updateListOfFilesFragment(false) + updateListOfFilesFragment() } } @@ -1732,7 +1732,7 @@ class FileDisplayActivity : if (sameAccount && isDescendant) { val linkedToRemotePath = intent.getStringExtra(FileDownloadWorker.EXTRA_LINKED_TO_PATH) if (linkedToRemotePath == null || isAscendant(linkedToRemotePath)) { - updateListOfFilesFragment(false) + updateListOfFilesFragment() } val intentAction = intent.action @@ -1793,7 +1793,7 @@ class FileDisplayActivity : val listOfFiles = this.listOfFilesFragment if (listOfFiles != null) { // should never be null, indeed val root = storageManager.getFileByPath(OCFile.ROOT_PATH) - listOfFiles.listDirectory(root, MainApp.isOnlyOnDevice(), false) + listOfFiles.listDirectory(root, MainApp.isOnlyOnDevice()) file = listOfFiles.currentFile startSyncFolderOperation(root, false) } @@ -1976,7 +1976,7 @@ class FileDisplayActivity : if (fileListFragment == null) { fileListFragment = listOfFilesFragment } - fileListFragment?.listDirectory(currentDir, MainApp.isOnlyOnDevice(), false) + fileListFragment?.listDirectory(currentDir, MainApp.isOnlyOnDevice()) } private fun handleDownloadWorkerState() { @@ -2100,7 +2100,7 @@ class FileDisplayActivity : } val parentFile = storageManager.getFileById(removedFile.parentId) if (parentFile != null && parentFile == getCurrentDir()) { - updateListOfFilesFragment(false) + updateListOfFilesFragment() } else if (this.leftFragment is GalleryFragment) { val galleryFragment = leftFragment as GalleryFragment galleryFragment.onRefresh() @@ -2190,7 +2190,7 @@ class FileDisplayActivity : */ private fun onCopyFileOperationFinish(operation: CopyFileOperation?, result: RemoteOperationResult<*>) { if (result.isSuccess) { - updateListOfFilesFragment(false) + updateListOfFilesFragment() refreshGalleryFragmentIfNeeded() } else { try { @@ -2240,7 +2240,7 @@ class FileDisplayActivity : val file = storageManager.getFileById(renamedFile.parentId) if (file != null && file == getCurrentDir()) { - updateListOfFilesFragment(false) + updateListOfFilesFragment() } refreshGalleryFragmentIfNeeded() fetchRecommendedFilesIfNeeded(ignoreETag = true, currentDir) @@ -2299,7 +2299,7 @@ class FileDisplayActivity : * {@inheritDoc} */ override fun onTransferStateChanged(file: OCFile, downloading: Boolean, uploading: Boolean) { - updateListOfFilesFragment(false) + updateListOfFilesFragment() val leftFragment = this.leftFragment val optionalUser = user if (leftFragment is FileDetailFragment && file == leftFragment.file && optionalUser.isPresent) { @@ -3003,7 +3003,7 @@ class FileDisplayActivity : if (TextUtils.isEmpty(message)) { val temp = file file = getCurrentDir() - listOfFiles.listDirectory(getCurrentDir(), temp, MainApp.isOnlyOnDevice(), false) + listOfFiles.listDirectory(getCurrentDir(), temp, MainApp.isOnlyOnDevice()) updateActionBarTitleAndHomeButton(null) } else { val view = listOfFiles.view diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt index 7599a5b44c67..7c1f385565e0 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt @@ -25,6 +25,7 @@ import androidx.lifecycle.lifecycleScope import androidx.localbroadcastmanager.content.LocalBroadcastManager import com.nextcloud.client.account.User import com.nextcloud.client.di.Injectable +import com.nextcloud.utils.extensions.getParcelableArgument import com.nextcloud.utils.fileNameValidator.FileNameValidator import com.owncloud.android.R import com.owncloud.android.databinding.FilesFolderPickerBinding @@ -188,7 +189,7 @@ open class FolderPickerActivity : folder = file } - listOfFilesFragment?.listDirectory(folder, false, false) + listOfFilesFragment?.listDirectory(folder, false) startSyncFolderOperation(folder, false) updateUiElements() } @@ -275,8 +276,13 @@ open class FolderPickerActivity : super.onResume() Log_OC.e(TAG, "onResume() start") - refreshListOfFilesFragment(false) - file = listOfFilesFragment?.currentFile + val extraFolder = intent.getParcelableArgument(EXTRA_FOLDER.toString(), OCFile::class.java) + if (extraFolder != null) { + file = extraFolder + } else { + file = listOfFilesFragment?.currentFile + } + refreshListOfFilesFragment(file) updateUiElements() val intentFilter = getSyncIntentFilter() @@ -351,14 +357,14 @@ open class FolderPickerActivity : } } - private fun refreshListOfFilesFragment(fromSearch: Boolean) { - listOfFilesFragment?.listDirectory(false, fromSearch) + private fun refreshListOfFilesFragment(directory: OCFile) { + listOfFilesFragment?.listDirectory(directory, false) } fun browseToRoot() { listOfFilesFragment?.let { val root = storageManager.getFileByEncryptedRemotePath(OCFile.ROOT_PATH) - it.listDirectory(root, false, false) + it.listDirectory(root, false) file = it.currentFile updateUiElements() startSyncFolderOperation(root, false) @@ -560,7 +566,7 @@ open class FolderPickerActivity : currentFile = currentDir } if (currentDir.remotePath == syncFolderRemotePath) { - listOfFilesFragment?.listDirectory(currentDir, false, false) + listOfFilesFragment?.listDirectory(currentDir, false) } file = currentFile } diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.kt b/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.kt index 9c49e9df88a3..6ea7b4daf113 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.kt +++ b/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.kt @@ -253,7 +253,7 @@ open class ExtendedListFragment : is FileDisplayActivity -> { if (isBackPressed && query.isEmpty()) { activity.resetSearchView() - activity.updateListOfFilesFragment(true) + activity.updateListOfFilesFragment() } else { Handler(Looper.getMainLooper()).post { if (adapter is OCFileListAdapter) { diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index 2489b4d555d0..0d22da18810b 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -434,7 +434,7 @@ public void onActivityCreated(Bundle savedInstanceState) { if ((fragmentActivity = getActivity()) != null && fragmentActivity instanceof FileDisplayActivity fileDisplayActivity) { fileDisplayActivity.updateActionBarTitleAndHomeButton(fileDisplayActivity.getCurrentDir()); } - listDirectory(MainApp.isOnlyOnDevice(), false); + listDirectory(MainApp.isOnlyOnDevice()); } protected void setAdapter(Bundle args) { @@ -1097,7 +1097,7 @@ public int onBrowseUp() { } private void updateFileList() { - listDirectory(mFile, MainApp.isOnlyOnDevice(), false); + listDirectory(mFile, MainApp.isOnlyOnDevice()); onRefresh(false); restoreIndexAndTopPosition(); } @@ -1296,7 +1296,7 @@ public void onItemClicked(OCFile file) { private void browseToFolder(OCFile file, int position) { resetSearchIfBrowsingFromFavorites(); - listDirectory(file, MainApp.isOnlyOnDevice(), false); + listDirectory(file, MainApp.isOnlyOnDevice()); // then, notify parent activity to let it update its state and view mContainerActivity.onBrowsedDownTo(file); // save index and top position @@ -1326,7 +1326,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { // update state and view of this fragment searchFragment = false; - listDirectory(file, MainApp.isOnlyOnDevice(), false); + listDirectory(file, MainApp.isOnlyOnDevice()); // then, notify parent activity to let it update its state and view mContainerActivity.onBrowsedDownTo(file); // save index and top position @@ -1497,6 +1497,8 @@ private void pickFolderForMoveOrCopy(final Set checkedFiles) { paths.add(file.getRemotePath()); } action.putStringArrayListExtra(FolderPickerActivity.EXTRA_FILE_PATHS, paths); + action.putExtra(FolderPickerActivity.EXTRA_FOLDER, getCurrentFile()); + action.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); // No animation since we stay in the same folder action.putExtra(FolderPickerActivity.EXTRA_ACTION, extraAction); getActivity().startActivityForResult(action, requestCode); } @@ -1513,21 +1515,21 @@ public OCFile getCurrentFile() { } /** - * Calls {@link OCFileListFragment#listDirectory(OCFile, boolean, boolean)} with a null parameter + * Calls {@link OCFileListFragment#listDirectory(OCFile, boolean)} with a null parameter */ - public void listDirectory(boolean onlyOnDevice, boolean fromSearch) { - listDirectory(null, onlyOnDevice, fromSearch); + public void listDirectory(boolean onlyOnDevice) { + listDirectory(null, onlyOnDevice); } public void refreshDirectory() { searchFragment = false; setFabVisible(mFile.canCreateFileAndFolder()); - listDirectory(getCurrentFile(), MainApp.isOnlyOnDevice(), false); + listDirectory(getCurrentFile(), MainApp.isOnlyOnDevice()); } - public void listDirectory(OCFile directory, boolean onlyOnDevice, boolean fromSearch) { - listDirectory(directory, null, onlyOnDevice, fromSearch); + public void listDirectory(OCFile directory, boolean onlyOnDevice) { + listDirectory(directory, null, onlyOnDevice); } private OCFile getDirectoryForListDirectory(OCFile directory, FileDataStorageManager storageManager) { @@ -1554,7 +1556,7 @@ private OCFile getDirectoryForListDirectory(OCFile directory, FileDataStorageMan * * @param directory File to be listed */ - public void listDirectory(OCFile directory, OCFile file, boolean onlyOnDevice, boolean fromSearch) { + public void listDirectory(OCFile directory, OCFile file, boolean onlyOnDevice) { if (!searchFragment) { FileDataStorageManager storageManager = mContainerActivity.getStorageManager(); if (storageManager == null) {