-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi user file browsing, closes #2479 #2482
Changes from all commits
7d6ca68
245cff6
9362504
2257a83
63f6c15
4e7b1ba
0123de7
ed98639
d958cf5
9681f3d
d44f498
fb512ad
d11981d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
package net.gsantner.markor.frontend.filebrowser; | ||
|
||
import android.content.Context; | ||
import android.os.Environment; | ||
|
||
import androidx.fragment.app.FragmentManager; | ||
|
||
|
@@ -16,6 +17,7 @@ | |
import net.gsantner.markor.model.AppSettings; | ||
import net.gsantner.markor.util.MarkorContextUtils; | ||
import net.gsantner.opoc.frontend.filebrowser.GsFileBrowserDialog; | ||
import net.gsantner.opoc.frontend.filebrowser.GsFileBrowserListAdapter; | ||
import net.gsantner.opoc.frontend.filebrowser.GsFileBrowserOptions; | ||
import net.gsantner.opoc.util.GsContextUtils; | ||
import net.gsantner.opoc.wrapper.GsCallback; | ||
|
@@ -41,6 +43,7 @@ public static GsFileBrowserOptions.Options prepareFsViewerOpts( | |
if (listener != null) { | ||
opts.listener = listener; | ||
} | ||
|
||
opts.doSelectFolder = doSelectFolder; | ||
opts.doSelectFile = !doSelectFolder; | ||
|
||
|
@@ -67,29 +70,50 @@ 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); | ||
|
||
opts.refresh = () -> { | ||
opts.sortFolderFirst = appSettings.isFileBrowserSortFolderFirst(); | ||
opts.sortByType = appSettings.getFileBrowserSortByType(); | ||
opts.sortReverse = appSettings.isFileBrowserSortReverse(); | ||
opts.filterShowDotFiles = appSettings.isFileBrowserFilterShowDotFiles(); | ||
opts.favouriteFiles = appSettings.getFavouriteFiles(); | ||
opts.recentFiles = appSettings.getRecentFiles(); | ||
opts.popularFiles = appSettings.getPopularFiles(); | ||
opts.storageMaps.clear(); | ||
opts.storageMaps.put(new File("/storage", cu.rstr(context, R.string.notebook)), appSettings.getNotebookDirectory()); | ||
opts.storageMaps.put(new File("/storage/Download"), new File("/storage/emulated/0/Download")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Download folder resolved using API now |
||
}; | ||
opts.refresh.callback(); | ||
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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These don't really need to be refreshed dynamically |
||
opts.sortByType = appSettings.getFileBrowserSortByType(); | ||
opts.sortReverse = appSettings.isFileBrowserSortReverse(); | ||
opts.filterShowDotFiles = appSettings.isFileBrowserFilterShowDotFiles(); | ||
opts.favouriteFiles = appSettings.getFavouriteFiles(); | ||
opts.recentFiles = appSettings.getRecentFiles(); | ||
opts.popularFiles = appSettings.getPopularFiles(); | ||
|
||
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); | ||
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++) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,6 @@ public static GsFileBrowserFragment newInstance() { | |
private Menu _fragmentMenu; | ||
private MarkorContextUtils _cu; | ||
private Toolbar _toolbar; | ||
private File _lastSelectedFile; | ||
|
||
//######################## | ||
//## Methods | ||
|
@@ -207,6 +206,11 @@ public void onFsViewerConfig(GsFileBrowserOptions.Options dopt) { | |
if (_callback != null) { | ||
_callback.onFsViewerConfig(dopt); | ||
} | ||
|
||
final Context context = getContext(); | ||
if (context != null) { | ||
MarkorFileBrowserFactory.updateFsViewerOpts(dopt, context, _appSettings); | ||
} | ||
} | ||
|
||
@Override | ||
|
@@ -235,7 +239,7 @@ private void updateMenuItems() { | |
// Check if is a favourite | ||
boolean selTextFilesOnly = true; | ||
boolean selDirectoriesOnly = true; | ||
boolean selWritable = (!curFilepath.equals("/storage") && !curFilepath.equals("/storage/emulated")); | ||
boolean selWritable = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't hardcode these like this now |
||
boolean allSelectedFav = true; | ||
final Collection<File> favFiles = _dopt.favouriteFiles != null ? _dopt.favouriteFiles : Collections.emptySet(); | ||
for (final File f : selFiles) { | ||
|
@@ -314,10 +318,7 @@ public void onViewStateRestored(final Bundle savedInstanceState) { | |
@Override | ||
public void onResume() { | ||
super.onResume(); | ||
if (_dopt.refresh != null) { | ||
_dopt.refresh.callback(); | ||
} | ||
|
||
_dopt.listener.onFsViewerConfig(_dopt); | ||
final File folder = getCurrentFolder(); | ||
final Activity activity = getActivity(); | ||
if (isVisible() && folder != null && activity != null) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleanups to how these are structured and organized