Skip to content

Commit

Permalink
notebook now special too
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 committed Dec 16, 2024
1 parent d958cf5 commit 9681f3d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class GsFileBrowserListAdapter extends RecyclerView.Adapter<GsFileBrowser
public static final File VIRTUAL_STORAGE_POPULAR = new File(VIRTUAL_STORAGE_ROOT, "Popular");
public static final File VIRTUAL_STORAGE_APP_DATA_PRIVATE = new File(VIRTUAL_STORAGE_ROOT, "AppData (data partition)");
public static final File VIRTUAL_STORAGE_DOWNLOAD = new File(VIRTUAL_STORAGE_ROOT, "Download");
public static final File VIRTUAL_STORAGE_HOME = new File(VIRTUAL_STORAGE_ROOT, "Notebook");
public static final File VIRTUAL_STORAGE_NOTEBOOK = new File(VIRTUAL_STORAGE_ROOT, "Notebook");
private static final File GO_BACK_SIGNIFIER = new File("__GO_BACK__");
private static final StrikethroughSpan STRIKE_THROUGH_SPAN = new StrikethroughSpan();
public static final String EXTRA_CURRENT_FOLDER = "EXTRA_CURRENT_FOLDER";
Expand Down Expand Up @@ -167,8 +167,8 @@ public void updateVirtualFolders() {
}
}

if (_dopt.virtualMaps != null) {
_virtualMapping.putAll(_dopt.virtualMaps);
if (_dopt.virtualDirs != null) {
_virtualMapping.putAll(_dopt.virtualDirs);
}

final File download = getDownloadFolder();
Expand All @@ -180,8 +180,8 @@ public void updateVirtualFolders() {
_virtualMapping.put(VIRTUAL_STORAGE_POPULAR, VIRTUAL_STORAGE_POPULAR);
_virtualMapping.put(VIRTUAL_STORAGE_FAVOURITE, VIRTUAL_STORAGE_FAVOURITE);

if (_dopt.homeFolder != null) {
_virtualMapping.put(VIRTUAL_STORAGE_HOME, _dopt.homeFolder);
if (_dopt.notebookFolder != null) {
_virtualMapping.put(VIRTUAL_STORAGE_NOTEBOOK, _dopt.notebookFolder);
}
}

Expand Down Expand Up @@ -231,13 +231,12 @@ public void onBindViewHolder(@NonNull FilesystemViewerViewHolder holder, int pos

if (isGoUp) {
holder.title.setText("..", TextView.BufferType.SPANNABLE);
} else if (VIRTUAL_STORAGE_HOME.equals(displayFile) && _dopt.homeDirTitle != 0) {
holder.title.setText(_context.getString(R.string.home), TextView.BufferType.SPANNABLE);
} else if (VIRTUAL_STORAGE_NOTEBOOK.equals(displayFile) && _dopt.notebookDirTitle != 0) {
holder.title.setText(_context.getString(_dopt.notebookDirTitle), TextView.BufferType.SPANNABLE);
} else {
holder.title.setText(titleText, TextView.BufferType.SPANNABLE);
}

holder.title.setText(isGoUp ? ".." : titleText, );
holder.title.setTextColor(ContextCompat.getColor(_context, _dopt.primaryTextColor));

if (!isFileWriteable(displayFile, isGoUp) && !isVirtualFolder(displayFile) && holder.title.length() > 0) {
Expand All @@ -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) {
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@

import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;

import net.gsantner.opoc.util.GsFileUtils;
import net.gsantner.opoc.wrapper.GsCallback;

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"})
Expand All @@ -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<File> 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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -134,8 +139,10 @@ public static class Options {
@ColorRes
public int folderColor = 0;

public final List<VirtualDir> virtualDirs = new ArrayList<>();
public final Map<File, File> virtualDirs = new LinkedHashMap<>();
public Collection<File> favouriteFiles, recentFiles, popularFiles = null;
public GsCallback.a1<CharSequence> setTitle = null, setSubtitle = null;

public GsCallback.a0 refresh = null;
}

Expand Down

0 comments on commit 9681f3d

Please sign in to comment.