From 1980dae0cbbc6878c50e747a541c0927b3878aba Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Fri, 27 Dec 2024 00:00:10 +0530 Subject: [PATCH] Some more small fixes --- .../net/gsantner/markor/activity/MainActivity.java | 6 +----- .../filebrowser/GsFileBrowserFragment.java | 2 +- .../filebrowser/GsFileBrowserListAdapter.java | 14 +++++++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/net/gsantner/markor/activity/MainActivity.java b/app/src/main/java/net/gsantner/markor/activity/MainActivity.java index 915a6bfbc..a45ce1821 100644 --- a/app/src/main/java/net/gsantner/markor/activity/MainActivity.java +++ b/app/src/main/java/net/gsantner/markor/activity/MainActivity.java @@ -297,7 +297,7 @@ public void onClickFab(final View view) { return; } - if (_notebook.getAdapter().isCurrentFolderVirtual()) { + if (!_notebook.getAdapter().isCurrentFolderWriteable()) { _notebook.getAdapter().setCurrentFolder(_appSettings.getNotebookDirectory()); return; } @@ -308,10 +308,6 @@ public void onClickFab(final View view) { return; } - if (!_notebook.getAdapter().isCurrentFolderWriteable()) { - return; - } - NewFileDialog.newInstance(_notebook.getCurrentFolder(), true, this::newItemCallback) .show(getSupportFragmentManager(), NewFileDialog.FRAGMENT_TAG); } diff --git a/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserFragment.java b/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserFragment.java index 69999f3c5..c930f1e9b 100644 --- a/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserFragment.java +++ b/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserFragment.java @@ -571,7 +571,7 @@ public void onFsViewerSelected(String request, File file, Integer lineNumber) { @Override public void onFsViewerConfig(GsFileBrowserOptions.Options dopt) { dopt.titleText = isMove ? R.string.move : R.string.copy; - dopt.rootFolder = _appSettings.getNotebookDirectory(); + dopt.rootFolder = GsFileBrowserListAdapter.VIRTUAL_STORAGE_ROOT; dopt.startFolder = getCurrentFolder(); // Directories cannot be moved into themselves. Don't give users the option final Set selSet = new HashSet<>(); diff --git a/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserListAdapter.java b/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserListAdapter.java index 6e3d7e51a..d94cded56 100644 --- a/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserListAdapter.java +++ b/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserListAdapter.java @@ -280,7 +280,7 @@ public void onAttachedToRecyclerView(@NonNull final RecyclerView view) { super.onAttachedToRecyclerView(view); _recyclerView = view; _layoutManager = (LinearLayoutManager) view.getLayoutManager(); - loadFolder(_dopt.startFolder != null ? _dopt.startFolder : _dopt.rootFolder, null); + reloadCurrentFolder(); } public String formatFileDescription(final File file, String format) { @@ -331,13 +331,17 @@ public void restoreSavedInstanceState(final Bundle savedInstanceState) { } public void reloadCurrentFolder() { - loadFolder(_currentFolder != null ? _currentFolder : _dopt.rootFolder, null); + if (_currentFolder != null) { + loadFolder(_currentFolder, null); + } else if (_dopt.startFolder != null) { + loadFolder(_dopt.startFolder, null); + } else { + loadFolder(_dopt.rootFolder, null); + } } public void setCurrentFolder(final File folder) { - if (folder != null && !folder.equals(_currentFolder)) { - loadFolder(folder, GsFileUtils.isChild(_currentFolder, folder) ? folder : null); - } + loadFolder(folder, GsFileUtils.isChild(_currentFolder, folder) ? folder : null); } public boolean isCurrentFolderVirtual() {