Skip to content

Commit

Permalink
Start at root folder for widget dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 committed Dec 19, 2024
1 parent d44f498 commit fb512ad
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static GsFileBrowserOptions.Options prepareFsViewerOpts(
if (listener != null) {
opts.listener = listener;
}

opts.doSelectFolder = doSelectFolder;
opts.doSelectFile = !doSelectFolder;

Expand All @@ -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();
Expand All @@ -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<String> strlist) {
File[] files = new File[strlist.size()];
for (int i = 0; i < files.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fb512ad

Please sign in to comment.