From 9681f3d910d5e68ab4fabf1a73b2a40a016f4fa1 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Tue, 17 Dec 2024 00:05:02 +0530 Subject: [PATCH] notebook now special too --- .../filebrowser/MarkorFileBrowserFactory.java | 6 ++-- .../filebrowser/GsFileBrowserListAdapter.java | 21 +++++++------- .../filebrowser/GsFileBrowserOptions.java | 29 ++++++++++++------- 3 files changed, 30 insertions(+), 26 deletions(-) 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 f0936be6b..cc3d5d558 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 @@ -71,13 +71,11 @@ public static GsFileBrowserOptions.Options prepareFsViewerOpts( opts.titleText = R.string.select; opts.mountedStorageFolder = cu.getStorageAccessFolder(context); - opts.virtualDirs.add(new GsFileBrowserOptions.VirtualDir()) - opts.popularImage = R.drawable.ic_favorite_black_24dp; opts.favouriteImage = R.drawable.ic_star_black_24dp; opts.recentImage = R.drawable.ic_history_black_24dp; opts.downloadImage = R.drawable.baseline_download_24; - opts.homeImage = R.drawable.ic_home_black_24dp; + opts.notebookImage = R.drawable.ic_home_black_24dp; opts.refresh = () -> { opts.sortFolderFirst = appSettings.isFileBrowserSortFolderFirst(); @@ -87,7 +85,7 @@ public static GsFileBrowserOptions.Options prepareFsViewerOpts( opts.favouriteFiles = appSettings.getFavouriteFiles(); opts.recentFiles = appSettings.getRecentFiles(); opts.popularFiles = appSettings.getPopularFiles(); - opts.homeFolder = appSettings.getNotebookDirectory(); + opts.notebookFolder = appSettings.getNotebookDirectory(); }; opts.refresh.callback(); 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 afb5c4cf6..6d5d281c4 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 @@ -75,7 +75,7 @@ public class GsFileBrowserListAdapter extends RecyclerView.Adapter 0) { @@ -254,7 +253,7 @@ public void onBindViewHolder(@NonNull FilesystemViewerViewHolder holder, int pos holder.description.setTextColor(ContextCompat.getColor(_context, _dopt.secondaryTextColor)); if (isSelected) { - holder.image.setImageResource(isSelected ? _dopt.selectedItemImage : isFile ? _dopt.fileImage : _dopt.folderImage); + holder.image.setImageResource(isSelected ? _dopt.selectedItemImage : isFile ? _dopt.downloadImage : _dopt.folderImage); } else if (VIRTUAL_STORAGE_FAVOURITE.equals(displayFile) && _dopt.favouriteImage != 0) { holder.image.setImageResource(_dopt.favouriteImage); } else if (VIRTUAL_STORAGE_POPULAR.equals(displayFile) && _dopt.popularImage != 0) { @@ -263,8 +262,8 @@ public void onBindViewHolder(@NonNull FilesystemViewerViewHolder holder, int pos holder.image.setImageResource(_dopt.recentImage); } else if (VIRTUAL_STORAGE_DOWNLOAD.equals(displayFile) && _dopt.downloadImage != 0) { holder.image.setImageResource(_dopt.downloadImage); - } else if (VIRTUAL_STORAGE_HOME.equals(displayFile) && _dopt.homeImage != 0) { - holder.image.setImageResource(_dopt.homeImage); + } else if (VIRTUAL_STORAGE_NOTEBOOK.equals(displayFile) && _dopt.notebookImage != 0) { + holder.image.setImageResource(_dopt.notebookImage); } else { holder.image.setImageResource(isFile ? _dopt.fileImage : _dopt.folderImage); } diff --git a/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserOptions.java b/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserOptions.java index 7c5adc17c..083038aa7 100644 --- a/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserOptions.java +++ b/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserOptions.java @@ -14,7 +14,6 @@ import androidx.annotation.ColorRes; import androidx.annotation.DrawableRes; -import androidx.annotation.Nullable; import androidx.annotation.StringRes; import net.gsantner.opoc.util.GsFileUtils; @@ -22,10 +21,8 @@ import java.io.File; import java.io.Serializable; -import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; @SuppressWarnings({"unused", "WeakerAccess"}) @@ -45,18 +42,12 @@ public interface SelectionListener { void onFsViewerItemLongPressed(final File file, boolean doSelectMultiple); } - public static class VirtualDir { - String title; - @Nullable File location; - @DrawableRes int icon; - @Nullable Collection contents; - } - public static class Options { public SelectionListener listener = new SelectionListenerAdapter(); public File rootFolder = Environment.getExternalStorageDirectory(), mountedStorageFolder = null, + notebookFolder = null, startFolder = null; public String requestId = "show_dialog"; public String sortByType = GsFileUtils.SORT_BY_NAME; @@ -105,6 +96,9 @@ public static class Options { public int contentDescriptionFile = 0; @StringRes public int newDirButtonText = 0; + @StringRes + public int notebookDirTitle = 0; + @DrawableRes public int homeButtonImage = android.R.drawable.star_big_on; @DrawableRes @@ -117,6 +111,17 @@ public static class Options { public int selectedItemImage = android.R.drawable.checkbox_on_background; @DrawableRes public int fileImage = android.R.drawable.ic_menu_edit; + @DrawableRes + public int notebookImage = 0; + @DrawableRes + public int favouriteImage = 0; + @DrawableRes + public int recentImage = 0; + @DrawableRes + public int popularImage = 0; + @DrawableRes + public int downloadImage = 0; + @ColorRes public int backgroundColor = android.R.color.background_light; @ColorRes @@ -134,8 +139,10 @@ public static class Options { @ColorRes public int folderColor = 0; - public final List virtualDirs = new ArrayList<>(); + public final Map virtualDirs = new LinkedHashMap<>(); + public Collection favouriteFiles, recentFiles, popularFiles = null; public GsCallback.a1 setTitle = null, setSubtitle = null; + public GsCallback.a0 refresh = null; }