Skip to content

Feature/search teleport to file - #4713

Open
yasminhosam wants to merge 8 commits into
TeamAmaze:release/4.0from
yasminhosam:feature/search-teleport-to-file
Open

Feature/search teleport to file#4713
yasminhosam wants to merge 8 commits into
TeamAmaze:release/4.0from
yasminhosam:feature/search-teleport-to-file

Conversation

@yasminhosam

Copy link
Copy Markdown

Description

This PR adds a "teleport to file" icon in search results. Tapping the new icon navigates to the file's parent folder and highlights/selects it there, so the user can act on it directly (rename, move, delete, etc.) without opening it first.

Directory results in search are unaffected — tapping a directory result still opens it directly, as before.

This reuses the existing scrollToFileName + getScrollPosition() mechanism already present in MainActivity/MainFragment/MainFragmentViewModel , rather than duplicating scroll/highlight logic.

Issue tracker

Fixes #4695

Automatic tests

  • Added unit tests for specific individual functions
  • Added headless tests for new app functionality
  • Added emulator tests for new UI elements

Manual tests

  • Done

  • Device: Samsung Galaxy A23

  • OS: Android 14

Build tasks success

Successfully running following tasks on local:

  • ./gradlew assembledebug
  • ./gradlew spotlessCheck

Generative code

  • This PR used generative code tools (GenAI, LLMs, etc.)

  • Model: Claude Sonnet 5

  • Version: 5

  • Provider: Anthropic

* Simple holder for a file's parent path and name. Not an android.util.Pair to keep it usable in
* plain JUnit tests (android.* classes are stubbed out in non-Robolectric unit tests).
*/
static class ParentAndFileName {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not using HybridFile here? Does this work with external searches: SMB, FTP, cloud, etc?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not using HybridFile here? Does this work with external searches: SMB, FTP, cloud, etc?

Thanks for pointing that out! You're right — I was doing naive string splitting on the raw path string, which doesn't correctly handle SMB/FTP/cloud paths.
I’ve updated teleportToFile to use HybridFile directly, so it now correctly handles local, SMB, FTP, and cloud paths.

I also added headless tests covering local, SMB, and FTP paths. The FTP test is skipped on Windows due to a Robolectric file-lock/cleanup issue, but the implementation itself works correctly.

@EmmanuelMess EmmanuelMess added the Needs-OPResponse Needs original poster to respond label Aug 18, 2026
…ch result icon

* Update `teleportToFile` in `MainActivity` to accept a `HybridFile` object instead of a string path, leveraging existing methods for parent path and file name retrieval.
* Remove manual path-splitting logic and the `ParentAndFileName` helper class.
* Update `SearchRecyclerViewAdapter` to pass the `HybridFile` object to `teleportToFile`.
* Replace the `ic_location_on_24dp` PNG icon with a new `ic_folder_arrow_right_outline` vector drawable in search results.
Replaces the basic path-splitting unit tests with end-to-end coverage:

- Robolectric tests for local, SMB, and FTP teleport paths, plus the
  no-parent fallback case.
- Espresso instrumented test verifying the target file scrolls into
  view in the real RecyclerView.
- ShadowSmbUtil updated to mock parent paths and prevent an NPE
  during headless SMB file listing.
- Reflection-based workaround refreshing TabHandler's cached database
  reference before each test to avoid a stale SQLite connection left
  over from Robolectric rebuilding the Application between tests.
@yasminhosam

Copy link
Copy Markdown
Author

Hi @EmmanuelMess, just following up on this PR since I addressed your feedback and updated the implementation/tests.

Whenever you have time, I’d appreciate another review. Thanks!

@EmmanuelMess

Copy link
Copy Markdown
Member

Whenever you have time, I’d appreciate another review. Thanks!

Yes, I'm pretty preoccupied with research right now. If you want a faster review, please provide a comment on how you considered and validated the user experience (especially the back button after teleport), and how you tested on networked files (SMB, etc.).

Right now my biggest consideration is how to verify that the PR is thoughtfully implemented.

scrollToFileName was only cleared when teleportToFile had no resolvable
parent, so it stayed set indefinitely otherwise. Any later folder reload
would re-trigger a highlight for that file, even on unrelated navigation.

Now cleared immediately once consumed in MainFragment, making it a
one-shot value. Also moved notifyItemChanged() inside the
scrollPosition != -1 check to avoid calling it with an invalid index.
@yasminhosam

Copy link
Copy Markdown
Author

Thanks for the detailed feedback — here's a full response covering both points.

Back button UX:

I traced the back button handling (MainActivity.onBackPressed()MainFragment.goBack()) and confirmed that when browsing folders, it doesn't use the FragmentManager back stack. Instead, it computes the parent of the current path and navigates there.

Therefore, after a teleport, pressing Back takes the user up one directory level from the location they were teleported to, rather than back to the search results or the previous screen. For example, if you're at Root, search for a file inside FolderA/FolderB, and teleport to it, pressing Back takes you to FolderA. This is consistent with the existing Back behavior when navigating folders normally.

While testing this manually, I also found a bug: scrollToFileName was not cleared after being consumed, so the previously teleported file could be incorrectly re-highlighted during later folder navigations. I fixed this by clearing it immediately after use in MainFragment, and moved notifyItemChanged() inside the scrollPosition != -1 check to avoid calling it with an invalid index. I have just pushed these changes.

Networked file testing (SMB/FTP/cloud):

teleportToFile only uses HybridFile.getParent() and getName(), so it does not perform any network I/O. The relevant behavior here is how the different URI/path formats are parsed.

I added headless Robolectric tests covering local, SMB, and FTP path formats in MainActivityTeleportTest. Each test verifies that the parent path and file name are resolved correctly for the corresponding protocol. FTP is skipped on Windows due to an unrelated Robolectric temporary-directory cleanup issue.

I haven't tested against a live networked server yet, since the change itself is isolated to path handling and HybridFile already handles these path formats. If you think live-server validation would still be useful for this PR, I'm happy to add it.

@EmmanuelMess

Copy link
Copy Markdown
Member

@yasminhosam what have you, the person, done to verify the user interaction?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs-OPResponse Needs original poster to respond

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ALLOW the search to "teleport" to file

2 participants