Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 >(")
}
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -1546,7 +1546,7 @@ class FileDisplayActivity :
return
}

ocFileListFragment.listDirectory(currentDir, MainApp.isOnlyOnDevice(), false)
ocFileListFragment.listDirectory(currentDir, MainApp.isOnlyOnDevice())
}

private fun handleScrollBehaviour(ocFileListFragment: OCFileListFragment?) {
Expand Down Expand Up @@ -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()
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -2190,7 +2190,7 @@ class FileDisplayActivity :
*/
private fun onCopyFileOperationFinish(operation: CopyFileOperation?, result: RemoteOperationResult<*>) {
if (result.isSuccess) {
updateListOfFilesFragment(false)
updateListOfFilesFragment()
refreshGalleryFragmentIfNeeded()
} else {
try {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -188,7 +189,7 @@ open class FolderPickerActivity :
folder = file
}

listOfFilesFragment?.listDirectory(folder, false, false)
listOfFilesFragment?.listDirectory(folder, false)
startSyncFolderOperation(folder, false)
updateUiElements()
}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -560,7 +566,7 @@ open class FolderPickerActivity :
currentFile = currentDir
}
if (currentDir.remotePath == syncFolderRemotePath) {
listOfFilesFragment?.listDirectory(currentDir, false, false)
listOfFilesFragment?.listDirectory(currentDir, false)
}
file = currentFile
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ open class ExtendedListFragment :
is FileDisplayActivity -> {
if (isBackPressed && query.isEmpty()) {
activity.resetSearchView()
activity.updateListOfFilesFragment(true)
activity.updateListOfFilesFragment()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer: This is the only instance where the parameter was true. It didn't have any effect anymore - but maybe something specific was desired here and got lost over time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alperozturk96 what do you think about this PR? Please review and let me know.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobiasKaminsky Make sense to me, what do you think about new behavior?

} else {
Handler(Looper.getMainLooper()).post {
if (adapter is OCFileListAdapter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -1097,7 +1097,7 @@ public int onBrowseUp() {
}

private void updateFileList() {
listDirectory(mFile, MainApp.isOnlyOnDevice(), false);
listDirectory(mFile, MainApp.isOnlyOnDevice());
onRefresh(false);
restoreIndexAndTopPosition();
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1497,6 +1497,8 @@ private void pickFolderForMoveOrCopy(final Set<OCFile> 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);
}
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down