From d26d51d1849b2ba016590083c34f3e9d469372f6 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Sun, 13 Oct 2024 22:18:15 -0700 Subject: [PATCH 1/9] Horked out unnecessary change too --- .../activity/DocumentEditAndViewFragment.java | 1 + .../markor/activity/MainActivity.java | 3 +- .../frontend/textview/HighlightingEditor.java | 45 ++++++++++++++++ .../gsantner/markor/model/AppSettings.java | 51 ------------------- .../res/values/string-not_translatable.xml | 1 + app/src/main/res/values/strings.xml | 1 + 6 files changed, 49 insertions(+), 53 deletions(-) diff --git a/app/src/main/java/net/gsantner/markor/activity/DocumentEditAndViewFragment.java b/app/src/main/java/net/gsantner/markor/activity/DocumentEditAndViewFragment.java index 39f02c6fb..5207919d7 100644 --- a/app/src/main/java/net/gsantner/markor/activity/DocumentEditAndViewFragment.java +++ b/app/src/main/java/net/gsantner/markor/activity/DocumentEditAndViewFragment.java @@ -20,6 +20,7 @@ import android.text.TextUtils; import android.util.Log; import android.util.TypedValue; +import android.view.ActionMode; import android.view.Gravity; import android.view.KeyEvent; import android.view.Menu; diff --git a/app/src/main/java/net/gsantner/markor/activity/MainActivity.java b/app/src/main/java/net/gsantner/markor/activity/MainActivity.java index beb962f3c..eb689a691 100644 --- a/app/src/main/java/net/gsantner/markor/activity/MainActivity.java +++ b/app/src/main/java/net/gsantner/markor/activity/MainActivity.java @@ -411,8 +411,7 @@ public GsFileBrowserOptions.Options getFilesystemFragmentOptions(GsFileBrowserOp public void onFsViewerConfig(GsFileBrowserOptions.Options dopt) { dopt.descModtimeInsteadOfParent = true; dopt.rootFolder = _appSettings.getNotebookDirectory(); - final File fallback = _appSettings.getFolderToLoadByMenuId(_appSettings.getAppStartupFolderMenuId()); - final File file = MarkorContextUtils.getValidIntentFile(getIntent(), fallback); + final File file = MarkorContextUtils.getValidIntentFile(getIntent(), dopt.rootFolder); if (!GsFileBrowserListAdapter.isVirtualFolder(file) && file.isFile()) { dopt.startFolder = file.getParentFile(); toShow = file; diff --git a/app/src/main/java/net/gsantner/markor/frontend/textview/HighlightingEditor.java b/app/src/main/java/net/gsantner/markor/frontend/textview/HighlightingEditor.java index dc6dc9d15..fc5c62c74 100644 --- a/app/src/main/java/net/gsantner/markor/frontend/textview/HighlightingEditor.java +++ b/app/src/main/java/net/gsantner/markor/frontend/textview/HighlightingEditor.java @@ -18,7 +18,10 @@ import android.text.Layout; import android.text.TextWatcher; import android.util.AttributeSet; +import android.view.ActionMode; import android.view.KeyEvent; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.view.ViewTreeObserver; import android.view.accessibility.AccessibilityEvent; @@ -28,6 +31,7 @@ import androidx.appcompat.widget.AppCompatEditText; import net.gsantner.markor.ApplicationObject; +import net.gsantner.markor.R; import net.gsantner.markor.activity.MainActivity; import net.gsantner.markor.model.AppSettings; import net.gsantner.opoc.format.GsTextUtils; @@ -111,6 +115,9 @@ public void afterTextChanged(final Editable s) { // Fix for Android 12 perf issues - https://github.com/gsantner/markor/discussions/1794 setEmojiCompatEnabled(false); + + // Custom options + setupCustomOptions(); } @Override @@ -503,6 +510,11 @@ public void withAutoFormatDisabled(final GsCallback.a0 callback) { // Utility functions for interaction // --------------------------------------------------------------------------------------------- + public void selectLines() { + final int[] sel = TextViewUtils.getLineSelection(this); + setSelection(sel[0], sel[1]); + } + public void simulateKeyPress(int keyEvent_KEYCODE_SOMETHING) { dispatchKeyEvent(new KeyEvent(0, 0, KeyEvent.ACTION_DOWN, keyEvent_KEYCODE_SOMETHING, 0)); dispatchKeyEvent(new KeyEvent(0, 0, KeyEvent.ACTION_UP, keyEvent_KEYCODE_SOMETHING, 0)); @@ -718,4 +730,37 @@ public void reset() { _maxNumberDigits = 0; } } + + private void setupCustomOptions() { + setCustomSelectionActionModeCallback(new ActionMode.Callback() { + @Override + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + // Add custom items programmatically + menu.add(0, R.string.option_select_lines, 0, R.string.select_lines); + return true; + } + + @Override + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + // Modify menu items here if necessary + return true; + } + + @Override + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + switch (item.getItemId()) { + case R.string.option_select_lines: + HighlightingEditor.this.selectLines(); + return true; + default: + return false; + } + } + + @Override + public void onDestroyActionMode(ActionMode mode) { + // Cleanup if needed + } + }); + } } \ No newline at end of file diff --git a/app/src/main/java/net/gsantner/markor/model/AppSettings.java b/app/src/main/java/net/gsantner/markor/model/AppSettings.java index 7c83c5095..f220291ee 100644 --- a/app/src/main/java/net/gsantner/markor/model/AppSettings.java +++ b/app/src/main/java/net/gsantner/markor/model/AppSettings.java @@ -746,57 +746,6 @@ public String getNavigationBarColor() { return getString(R.string.pref_key__navigationbar_color, "#000000"); } - public String getAppStartupFolderMenuId() { - return getString(R.string.pref_key__app_start_folder, "notebook"); - } - - public File getFolderToLoadByMenuId(String itemId) { - List> appDataPublicDirs = _cu.getAppDataPublicDirs(_context, false, true, false); - switch (itemId) { - case "storage": { - return new File("/storage"); - } - case "notebook": { - return getNotebookDirectory(); - } - case "popular_documents": { - return GsFileBrowserListAdapter.VIRTUAL_STORAGE_POPULAR; - } - case "recently_viewed_documents": { - return GsFileBrowserListAdapter.VIRTUAL_STORAGE_RECENTS; - } - case "favourites": { - return GsFileBrowserListAdapter.VIRTUAL_STORAGE_FAVOURITE; - } - case "appdata_private": { - return _cu.getAppDataPrivateDir(_context); - } - case "internal_storage": { - return Environment.getExternalStorageDirectory(); - } - case "appdata_sdcard_1": { - if (appDataPublicDirs.size() > 0) { - return appDataPublicDirs.get(0).first; - } - return Environment.getExternalStorageDirectory(); - } - case "appdata_sdcard_2": { - if (appDataPublicDirs.size() > 1) { - return appDataPublicDirs.get(1).first; - } - return Environment.getExternalStorageDirectory(); - } - case "appdata_public": { - appDataPublicDirs = _cu.getAppDataPublicDirs(_context, true, false, false); - if (appDataPublicDirs.size() > 0) { - return appDataPublicDirs.get(0).first; - } - return _cu.getAppDataPrivateDir(_context); - } - } - return getNotebookDirectory(); - } - public int getTabWidth() { return getInt(R.string.pref_key__tab_width_v2, 1); } diff --git a/app/src/main/res/values/string-not_translatable.xml b/app/src/main/res/values/string-not_translatable.xml index 5722b3ccb..2128b6a4a 100644 --- a/app/src/main/res/values/string-not_translatable.xml +++ b/app/src/main/res/values/string-not_translatable.xml @@ -426,4 +426,5 @@ work. If not, see . Square Brackets CSV OrgMode + option_select_lines diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7f8f9c820..c3b6d77f5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -64,6 +64,7 @@ work. If not, see . Select this folder Select Select all + Select lines Create Select entries One item selected From b409b66ce1214fb94d7d281d40e027d7a20e224e Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Sun, 13 Oct 2024 22:31:49 -0700 Subject: [PATCH 2/9] cleanups --- .../gsantner/markor/activity/DocumentEditAndViewFragment.java | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/net/gsantner/markor/activity/DocumentEditAndViewFragment.java b/app/src/main/java/net/gsantner/markor/activity/DocumentEditAndViewFragment.java index 5207919d7..39f02c6fb 100644 --- a/app/src/main/java/net/gsantner/markor/activity/DocumentEditAndViewFragment.java +++ b/app/src/main/java/net/gsantner/markor/activity/DocumentEditAndViewFragment.java @@ -20,7 +20,6 @@ import android.text.TextUtils; import android.util.Log; import android.util.TypedValue; -import android.view.ActionMode; import android.view.Gravity; import android.view.KeyEvent; import android.view.Menu; From 900b98788459b35df2a0f02f4cab15a339798775 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Mon, 14 Oct 2024 13:25:00 -0700 Subject: [PATCH 3/9] remember format per template --- .../java/net/gsantner/markor/frontend/NewFileDialog.java | 6 ++++++ app/src/main/res/layout/new_file_dialog.xml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/gsantner/markor/frontend/NewFileDialog.java b/app/src/main/java/net/gsantner/markor/frontend/NewFileDialog.java index 2821db277..f5da1cc7c 100644 --- a/app/src/main/java/net/gsantner/markor/frontend/NewFileDialog.java +++ b/app/src/main/java/net/gsantner/markor/frontend/NewFileDialog.java @@ -162,6 +162,12 @@ private AlertDialog makeDialog(final File basedir, final boolean allowCreateDir, templateAdapter.addAll(GsCollectionUtils.map(templates, p -> p.first)); templateSpinner.setAdapter(templateAdapter); + templateSpinner.setOnItemSelectedListener(new GsAndroidSpinnerOnItemSelectedAdapter(pos -> { + final String template = templateAdapter.getItem(pos); + final String fmt = appSettings.getTemplateTitleFormat(template); + formatEdit.setText(fmt); + })); + // Setup type / format spinner and action // ----------------------------------------------------------------------------------------- final ArrayAdapter typeAdapter = new ArrayAdapter<>(activity, android.R.layout.simple_spinner_dropdown_item); diff --git a/app/src/main/res/layout/new_file_dialog.xml b/app/src/main/res/layout/new_file_dialog.xml index a6cc48837..bb9cbfa1e 100644 --- a/app/src/main/res/layout/new_file_dialog.xml +++ b/app/src/main/res/layout/new_file_dialog.xml @@ -150,7 +150,7 @@ android:text="@string/template" android:textAppearance="@style/TextAppearance.AppCompat.Caption" /> - Date: Sat, 26 Oct 2024 22:54:17 -0700 Subject: [PATCH 4/9] Changed to unicode --- .../gsantner/markor/frontend/textview/HighlightingEditor.java | 2 +- app/src/main/res/values/strings.xml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/net/gsantner/markor/frontend/textview/HighlightingEditor.java b/app/src/main/java/net/gsantner/markor/frontend/textview/HighlightingEditor.java index fc5c62c74..d5ad5ab68 100644 --- a/app/src/main/java/net/gsantner/markor/frontend/textview/HighlightingEditor.java +++ b/app/src/main/java/net/gsantner/markor/frontend/textview/HighlightingEditor.java @@ -736,7 +736,7 @@ private void setupCustomOptions() { @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { // Add custom items programmatically - menu.add(0, R.string.option_select_lines, 0, R.string.select_lines); + menu.add(0, R.string.option_select_lines, 0, "☰"); return true; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c3b6d77f5..7f8f9c820 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -64,7 +64,6 @@ work. If not, see . Select this folder Select Select all - Select lines Create Select entries One item selected From 4b68177ad2ab90fcfdafcdd1af1e86b99df2251d Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Sun, 27 Oct 2024 10:09:22 -0700 Subject: [PATCH 5/9] fallback --- .../java/net/gsantner/markor/format/ActionButtonBase.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/src/main/java/net/gsantner/markor/format/ActionButtonBase.java b/app/src/main/java/net/gsantner/markor/format/ActionButtonBase.java index d6927d9e2..f58de8fd9 100644 --- a/app/src/main/java/net/gsantner/markor/format/ActionButtonBase.java +++ b/app/src/main/java/net/gsantner/markor/format/ActionButtonBase.java @@ -251,11 +251,6 @@ private List loadActionPreference(final String suffix) { public List getActionOrder() { final Set order = new LinkedHashSet<>(loadActionPreference(ORDER_SUFFIX)); - // Handle the case where order was stored without suffix. i.e. before this release. - if (order.isEmpty()) { - order.addAll(loadActionPreference("")); - } - final Set defined = new LinkedHashSet<>(getActiveActionKeys()); final Set disabled = new LinkedHashSet<>(getDisabledActions()); From bc817e8b8d352c5eb9dc7daf7488d3784a56dc92 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Thu, 7 Nov 2024 10:58:09 -0800 Subject: [PATCH 6/9] Synchronized filtering --- .../filebrowser/GsFileBrowserDialog.java | 1 - .../filebrowser/GsFileBrowserFragment.java | 1 - .../filebrowser/GsFileBrowserListAdapter.java | 56 +++++++++---------- 3 files changed, 25 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserDialog.java b/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserDialog.java index b0609cbd7..6ba6c1cd1 100644 --- a/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserDialog.java +++ b/app/src/main/java/net/gsantner/opoc/frontend/filebrowser/GsFileBrowserDialog.java @@ -173,7 +173,6 @@ public void onViewCreated(final View root, final @Nullable Bundle savedInstanceS _filesystemViewerAdapter = new GsFileBrowserListAdapter(_dopt, activity); _recyclerList.setAdapter(_filesystemViewerAdapter); - _filesystemViewerAdapter.getFilter().filter(""); onFsViewerDoUiUpdate(_filesystemViewerAdapter); // Setup callbacks 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 58ef93e0d..f0bb0a4f8 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 @@ -124,7 +124,6 @@ public void onViewCreated(@NonNull View root, @Nullable Bundle savedInstanceStat _filesystemViewerAdapter = new GsFileBrowserListAdapter(_dopt, context); _recyclerList.setAdapter(_filesystemViewerAdapter); - _filesystemViewerAdapter.getFilter().filter(""); onFsViewerDoUiUpdate(_filesystemViewerAdapter); _swipe.setOnRefreshListener(() -> { 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 039b4fddb..6cb0bd176 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 @@ -597,7 +597,7 @@ public void showFile(final File file) { return; } - if (getFilePosition(file) < 0) { + if (_adapterDataFiltered.contains(file)) { final File dir = file.getParentFile(); if (dir != null) { loadFolder(dir, file); @@ -623,7 +623,7 @@ public void onLayoutChange(View v, int l, int t, int r, int b, int ol, int ot, i * @param file File to blink */ public boolean scrollToAndFlash(final File file) { - final int pos = getFilePosition(file); + final int pos = _adapterDataFiltered.indexOf(file); if (pos >= 0 && _layoutManager != null) { _layoutManager.scrollToPosition(pos); _recyclerView.post(() -> @@ -638,19 +638,6 @@ public boolean scrollToAndFlash(final File file) { return false; } - // Get the position of a file in the current view - // -1 if file is not a child of the current directory - public int getFilePosition(final File file) { - if (file != null) { - for (int i = 0; i < _adapterDataFiltered.size(); i++) { - if (_adapterDataFiltered.get(i).equals(file)) { - return i; - } - } - } - return -1; - } - private static final ExecutorService executorService = new ThreadPoolExecutor(0, 3, 60, TimeUnit.SECONDS, new SynchronousQueue<>()); private void loadFolder(final File folder, final File show) { @@ -751,12 +738,16 @@ private synchronized void _loadFolder(final @NonNull File folder, final @Nullabl } if (folderChanged || modSumChanged || !newData.equals(_adapterData)) { + final ArrayList filteredData = new ArrayList<>(); + _filter._filter(newData, filteredData); + _recyclerView.post(() -> { // Modify all these values in the UI thread _adapterData.clear(); _adapterData.addAll(newData); + _adapterDataFiltered.clear(); + _adapterDataFiltered.addAll(filteredData); _currentSelection.retainAll(_adapterData); - _filter.filter(_filter._lastFilter); _currentFolder = folder; _prevModSum = modSum; @@ -775,7 +766,7 @@ private synchronized void _loadFolder(final @NonNull File folder, final @Nullabl _recyclerView.post(() -> scrollToAndFlash(toShow)); }); - } else if (toShow != null && _adapterDataFiltered.contains(toShow)) { + } else { _recyclerView.post(() -> scrollToAndFlash(toShow)); } @@ -783,7 +774,7 @@ private synchronized void _loadFolder(final @NonNull File folder, final @Nullabl _dopt.listener.onFsViewerDoUiUpdate(GsFileBrowserListAdapter.this); } }); - } else if (toShow != null && _adapterDataFiltered.contains(toShow)) { + } else { _recyclerView.post(() -> scrollToAndFlash(toShow)); } } @@ -828,7 +819,7 @@ private static class StringFilter extends Filter { private final GsFileBrowserListAdapter _adapter; private final List _originalList; private final List _filteredList; - public CharSequence _lastFilter = ""; + public String _lastFilter = ""; private StringFilter(GsFileBrowserListAdapter adapter, List adapterData) { super(); @@ -840,25 +831,28 @@ private StringFilter(GsFileBrowserListAdapter adapter, List adapterData) { @Override protected FilterResults performFiltering(CharSequence constraint) { final FilterResults results = new FilterResults(); - constraint = constraint.toString().toLowerCase(Locale.getDefault()).trim(); - _filteredList.clear(); - if (constraint.length() == 0) { - _filteredList.addAll(_originalList); - } else { - for (File file : _originalList) { - if (file.getName().toLowerCase(Locale.getDefault()).contains(constraint)) { - _filteredList.add(file); - } - } - } + _lastFilter = constraint.toString().toLowerCase().trim(); + _filter(_originalList, _filteredList); - _lastFilter = constraint; results.values = _filteredList; results.count = _filteredList.size(); return results; } + public void _filter(final List all, final List filtered) { + filtered.clear(); + if (_lastFilter.isEmpty()) { + filtered.addAll(all); + } else { + for (final File file : all) { + if (file.getName().toLowerCase().contains(_lastFilter)) { + filtered.add(file); + } + } + } + } + @Override @SuppressWarnings("unchecked") protected void publishResults(CharSequence constraint, FilterResults results) { From e9d6b2468a854619d80134a2d2770b75f09c5c9d Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Thu, 7 Nov 2024 11:11:02 -0800 Subject: [PATCH 7/9] Reverted removal of startup folders --- .../markor/activity/MainActivity.java | 3 +- .../gsantner/markor/model/AppSettings.java | 51 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/gsantner/markor/activity/MainActivity.java b/app/src/main/java/net/gsantner/markor/activity/MainActivity.java index eb689a691..beb962f3c 100644 --- a/app/src/main/java/net/gsantner/markor/activity/MainActivity.java +++ b/app/src/main/java/net/gsantner/markor/activity/MainActivity.java @@ -411,7 +411,8 @@ public GsFileBrowserOptions.Options getFilesystemFragmentOptions(GsFileBrowserOp public void onFsViewerConfig(GsFileBrowserOptions.Options dopt) { dopt.descModtimeInsteadOfParent = true; dopt.rootFolder = _appSettings.getNotebookDirectory(); - final File file = MarkorContextUtils.getValidIntentFile(getIntent(), dopt.rootFolder); + final File fallback = _appSettings.getFolderToLoadByMenuId(_appSettings.getAppStartupFolderMenuId()); + final File file = MarkorContextUtils.getValidIntentFile(getIntent(), fallback); if (!GsFileBrowserListAdapter.isVirtualFolder(file) && file.isFile()) { dopt.startFolder = file.getParentFile(); toShow = file; diff --git a/app/src/main/java/net/gsantner/markor/model/AppSettings.java b/app/src/main/java/net/gsantner/markor/model/AppSettings.java index f220291ee..7c83c5095 100644 --- a/app/src/main/java/net/gsantner/markor/model/AppSettings.java +++ b/app/src/main/java/net/gsantner/markor/model/AppSettings.java @@ -746,6 +746,57 @@ public String getNavigationBarColor() { return getString(R.string.pref_key__navigationbar_color, "#000000"); } + public String getAppStartupFolderMenuId() { + return getString(R.string.pref_key__app_start_folder, "notebook"); + } + + public File getFolderToLoadByMenuId(String itemId) { + List> appDataPublicDirs = _cu.getAppDataPublicDirs(_context, false, true, false); + switch (itemId) { + case "storage": { + return new File("/storage"); + } + case "notebook": { + return getNotebookDirectory(); + } + case "popular_documents": { + return GsFileBrowserListAdapter.VIRTUAL_STORAGE_POPULAR; + } + case "recently_viewed_documents": { + return GsFileBrowserListAdapter.VIRTUAL_STORAGE_RECENTS; + } + case "favourites": { + return GsFileBrowserListAdapter.VIRTUAL_STORAGE_FAVOURITE; + } + case "appdata_private": { + return _cu.getAppDataPrivateDir(_context); + } + case "internal_storage": { + return Environment.getExternalStorageDirectory(); + } + case "appdata_sdcard_1": { + if (appDataPublicDirs.size() > 0) { + return appDataPublicDirs.get(0).first; + } + return Environment.getExternalStorageDirectory(); + } + case "appdata_sdcard_2": { + if (appDataPublicDirs.size() > 1) { + return appDataPublicDirs.get(1).first; + } + return Environment.getExternalStorageDirectory(); + } + case "appdata_public": { + appDataPublicDirs = _cu.getAppDataPublicDirs(_context, true, false, false); + if (appDataPublicDirs.size() > 0) { + return appDataPublicDirs.get(0).first; + } + return _cu.getAppDataPrivateDir(_context); + } + } + return getNotebookDirectory(); + } + public int getTabWidth() { return getInt(R.string.pref_key__tab_width_v2, 1); } From e9ed78efb3260d4e83365240070e203acecfb953 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Thu, 7 Nov 2024 19:19:03 -0800 Subject: [PATCH 8/9] Just referring to the adapter --- .../filebrowser/GsFileBrowserListAdapter.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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 6cb0bd176..87af9b4a9 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 @@ -88,7 +88,7 @@ public class GsFileBrowserListAdapter extends RecyclerView.Adapter _virtualMapping; @@ -138,6 +138,7 @@ public GsFileBrowserListAdapter(GsFileBrowserOptions.Options options, Context co _virtualMapping = Collections.unmodifiableMap(getVirtualFolders()); _reverseVirtualMapping = Collections.unmodifiableMap(GsCollectionUtils.reverse(_virtualMapping)); loadFolder(_dopt.startFolder != null ? _dopt.startFolder : _dopt.rootFolder, null); + _filter = new StringFilter(this); } public Map getVirtualFolders() { @@ -364,9 +365,6 @@ public int getItemCount() { @Override public Filter getFilter() { - if (_filter == null) { - _filter = new StringFilter(this, _adapterData); - } return _filter; } @@ -817,14 +815,12 @@ public boolean isCurrentFolderHome() { //######################## private static class StringFilter extends Filter { private final GsFileBrowserListAdapter _adapter; - private final List _originalList; private final List _filteredList; public String _lastFilter = ""; - private StringFilter(GsFileBrowserListAdapter adapter, List adapterData) { + private StringFilter(final GsFileBrowserListAdapter adapter) { super(); _adapter = adapter; - _originalList = adapterData; _filteredList = new ArrayList<>(); } @@ -833,7 +829,7 @@ protected FilterResults performFiltering(CharSequence constraint) { final FilterResults results = new FilterResults(); _lastFilter = constraint.toString().toLowerCase().trim(); - _filter(_originalList, _filteredList); + _filter(_adapter._adapterData, _filteredList); results.values = _filteredList; results.count = _filteredList.size(); From fdcde72a8a39e2b61ad0380f77c7c6f39dfdfb78 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Thu, 7 Nov 2024 21:12:21 -0800 Subject: [PATCH 9/9] Flipped test --- .../opoc/frontend/filebrowser/GsFileBrowserListAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 87af9b4a9..8e6e00409 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 @@ -595,7 +595,7 @@ public void showFile(final File file) { return; } - if (_adapterDataFiltered.contains(file)) { + if (!_adapterDataFiltered.contains(file)) { final File dir = file.getParentFile(); if (dir != null) { loadFolder(dir, file);