Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi user file browsing, closes #2479 #2482

Merged
merged 13 commits into from
Dec 22, 2024

Conversation

harshad1
Copy link
Collaborator

@harshad1 harshad1 commented Dec 12, 2024

Supporting multiple users and adding a number of fixes

This addresses #2479

} else if (VIRTUAL_STORAGE_RECENTS.equals(displayFile)) {
holder.image.setImageResource(R.drawable.ic_history_black_24dp);
} else {
holder.image.setImageResource(isFile ? _dopt.fileImage : _dopt.folderImage);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Use the specific images for these folders

@@ -529,15 +554,13 @@ public boolean canGoBack() {

public boolean goUp() {
if (_currentFolder != null && canGoUp()) {
if (_reverseVirtualMapping.containsKey(_currentFolder)) {
loadFolder(VIRTUAL_STORAGE_ROOT, _reverseVirtualMapping.get(_currentFolder));
final File parent = _currentFolder.getParentFile();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Go up to parent even if listed as a virtual folder in root

@@ -81,9 +81,8 @@ public static GsFileBrowserOptions.Options prepareFsViewerOpts(
opts.favouriteFiles = appSettings.getFavouriteFiles();
opts.recentFiles = appSettings.getRecentFiles();
opts.popularFiles = appSettings.getPopularFiles();
opts.storageMaps.clear();
opts.storageMaps.put(new File("/storage", cu.rstr(context, R.string.notebook)), appSettings.getNotebookDirectory());
opts.storageMaps.put(new File("/storage/Download"), new File("/storage/emulated/0/Download"));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Download folder resolved using API now

@@ -235,7 +235,7 @@ private void updateMenuItems() {
// Check if is a favourite
boolean selTextFilesOnly = true;
boolean selDirectoriesOnly = true;
boolean selWritable = (!curFilepath.equals("/storage") && !curFilepath.equals("/storage/emulated"));
boolean selWritable = true;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't hardcode these like this now

@@ -679,27 +707,28 @@ private void loadFolder(final File folder, final File show) {
final File toShow = show == null ? _fileToShowAfterNextLoad : show;
_fileToShowAfterNextLoad = null;

_currentFolder = folder;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We set this early and in the wrapping sync function. Prevents bugs from preventing this from being set.

if (_hlEditor != null) {
_hlEditor.toggleCase();
}
TextViewUtils.toggleSelectionCase(_hlEditor.getText());
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cleanups to how these are structured and organized

};
opts.refresh.callback();
// These should be refreshed in onFsViewerConfig
opts.sortFolderFirst = appSettings.isFileBrowserSortFolderFirst();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These don't really need to be refreshed dynamically

final String filename = displayFile.getName();
final String currentFolderName = _currentFolder != null ? _currentFolder.getName() : "";
final File currentFolderParent = _currentFolder != null ? _currentFolder.getParentFile() : null;
final File file = GsCollectionUtils.getOrDefault(_virtualMapping, displayFile, displayFile);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All of this is identical but cleaned up

// This function is not called on the main thread, so post to the UI thread
private synchronized void _loadFolder(final @NonNull File folder, final @Nullable File toShow) {
// This function is not called on the main thread
private synchronized void _loadFolder(final boolean folderChanged, final @Nullable File toShow) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We set _currentFolder early and just use that. Prevents some bugs

@harshad1 harshad1 changed the title WIP: Multi user file browsing Multi user file browsing Dec 19, 2024
@harshad1
Copy link
Collaborator Author

I think this is good to go. But I will wait for feedback and more testing.

@gsantner gsantner changed the title Multi user file browsing Multi user file browsing, closes #2479 Dec 22, 2024
@gsantner gsantner merged commit cc9518b into gsantner:master Dec 22, 2024
1 check passed
@gsantner
Copy link
Owner

Thanks, merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiuser support: Filesystem operations malfunction when using the app in secondary users
2 participants