diff --git a/app/src/main/java/net/gsantner/markor/frontend/filebrowser/MarkorFileBrowserFactory.java b/app/src/main/java/net/gsantner/markor/frontend/filebrowser/MarkorFileBrowserFactory.java index 032ab1a3b8..72b0b7e557 100644 --- a/app/src/main/java/net/gsantner/markor/frontend/filebrowser/MarkorFileBrowserFactory.java +++ b/app/src/main/java/net/gsantner/markor/frontend/filebrowser/MarkorFileBrowserFactory.java @@ -43,6 +43,7 @@ public static GsFileBrowserOptions.Options prepareFsViewerOpts( if (listener != null) { opts.listener = listener; } + opts.doSelectFolder = doSelectFolder; opts.doSelectFile = !doSelectFolder; @@ -69,11 +70,21 @@ public static GsFileBrowserOptions.Options prepareFsViewerOpts( opts.folderColor = R.color.folder; opts.fileImage = R.drawable.ic_file_white_24dp; opts.folderImage = R.drawable.ic_folder_white_24dp; - opts.descriptionFormat = appSettings.getString(R.string.pref_key__file_description_format, ""); opts.titleText = R.string.select; opts.mountedStorageFolder = cu.getStorageAccessFolder(context); - // These should be refreshed in onFsViewerConfig + updateFsViewerOpts(opts, context, appSettings); + + return opts; + } + + public static void updateFsViewerOpts( + final GsFileBrowserOptions.Options opts, + final Context context, + AppSettings appSettings + ) { + appSettings = appSettings != null ? appSettings : ApplicationObject.settings(); + opts.sortFolderFirst = appSettings.isFileBrowserSortFolderFirst(); opts.sortByType = appSettings.getFileBrowserSortByType(); opts.sortReverse = appSettings.isFileBrowserSortReverse(); @@ -82,16 +93,27 @@ public static GsFileBrowserOptions.Options prepareFsViewerOpts( opts.recentFiles = appSettings.getRecentFiles(); opts.popularFiles = appSettings.getPopularFiles(); - opts.addVirtualFile("Download", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), R.drawable.baseline_download_24); - opts.addVirtualFile(cu.rstr(context, R.string.notebook), appSettings.getNotebookDirectory(), R.drawable.ic_home_black_24dp); + opts.descriptionFormat = appSettings.getString(R.string.pref_key__file_description_format, ""); + + opts.storageMaps.clear(); + opts.iconMaps.clear(); + + final File downloads = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); + opts.addVirtualFile("Download", downloads, R.drawable.baseline_download_24); + + final File notebook = appSettings.getNotebookDirectory(); + opts.addVirtualFile(context.getString(R.string.notebook), notebook, R.drawable.ic_home_black_24dp); opts.iconMaps.put(GsFileBrowserListAdapter.VIRTUAL_STORAGE_FAVOURITE, R.drawable.ic_star_black_24dp); opts.iconMaps.put(GsFileBrowserListAdapter.VIRTUAL_STORAGE_RECENTS, R.drawable.ic_history_black_24dp); opts.iconMaps.put(GsFileBrowserListAdapter.VIRTUAL_STORAGE_POPULAR, R.drawable.ic_favorite_black_24dp); - - return opts; + opts.iconMaps.put(notebook, R.drawable.ic_home_black_24dp); + opts.iconMaps.put(downloads, R.drawable.baseline_download_24); + opts.iconMaps.put(appSettings.getQuickNoteFile(), R.drawable.ic_lightning_black_24dp); + opts.iconMaps.put(appSettings.getTodoFile(), R.drawable.ic_assignment_turned_in_black_24dp); } + public static File[] strlistToArray(List strlist) { File[] files = new File[strlist.size()]; for (int i = 0; i < files.length; i++) { 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 df2482d07b..c9a6f46ebc 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 @@ -207,13 +207,10 @@ public void onFsViewerConfig(GsFileBrowserOptions.Options dopt) { _callback.onFsViewerConfig(dopt); } - dopt.sortFolderFirst = _appSettings.isFileBrowserSortFolderFirst(); - dopt.sortByType = _appSettings.getFileBrowserSortByType(); - dopt.sortReverse = _appSettings.isFileBrowserSortReverse(); - dopt.filterShowDotFiles = _appSettings.isFileBrowserFilterShowDotFiles(); - dopt.favouriteFiles = _appSettings.getFavouriteFiles(); - dopt.recentFiles = _appSettings.getRecentFiles(); - dopt.popularFiles = _appSettings.getPopularFiles(); + final Context context = getContext(); + if (context != null) { + MarkorFileBrowserFactory.updateFsViewerOpts(dopt, context, _appSettings); + } } @Override diff --git a/app/thirdparty/java/other/writeily/widget/WrWidgetConfigure.java b/app/thirdparty/java/other/writeily/widget/WrWidgetConfigure.java index 18d9f76541..46750d59c4 100644 --- a/app/thirdparty/java/other/writeily/widget/WrWidgetConfigure.java +++ b/app/thirdparty/java/other/writeily/widget/WrWidgetConfigure.java @@ -20,6 +20,7 @@ import net.gsantner.markor.R; import net.gsantner.markor.activity.MarkorBaseActivity; import net.gsantner.markor.frontend.filebrowser.MarkorFileBrowserFactory; +import net.gsantner.opoc.frontend.filebrowser.GsFileBrowserListAdapter; import net.gsantner.opoc.frontend.filebrowser.GsFileBrowserOptions; import java.io.File; @@ -65,7 +66,7 @@ public void onFsViewerSelected(String request, File file, final Integer lineNumb @Override public void onFsViewerConfig(GsFileBrowserOptions.Options dopt) { dopt.titleText = R.string.select_folder; - dopt.rootFolder = ApplicationObject.settings().getNotebookDirectory(); + dopt.rootFolder = GsFileBrowserListAdapter.VIRTUAL_STORAGE_ROOT; } @Override