Skip to content

Add a history search UI for history page#13511

Open
TransZAllen wants to merge 7 commits into
TeamNewPipe:refactorfrom
TransZAllen:history_search-3
Open

Add a history search UI for history page#13511
TransZAllen wants to merge 7 commits into
TeamNewPipe:refactorfrom
TransZAllen:history_search-3

Conversation

@TransZAllen

Copy link
Copy Markdown
Contributor

What is it?

  • Bugfix (user facing)
  • [✔] Feature (user facing) ⚠️ Your PR must target the refactor branch
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

Adds a history search UI for history page, and users can search some history entries by clicking the search button and entering keywords in stream titles or uploader names.
Detailed description is provided in the comments below.

Before/After Screenshots/Screen Record

  • Before: There is no search UI for history page.
  • After: The history search UI is added. Here is a screen recording that showing the actions of this history search UI:
history_search_UI_actions-reduce_size.mp4

Fixes the following issue(s)

Due diligence

…arge).

- The sort button is in the History page.
- The TextView inside sortButton was using 'match_parent' width,
  which caused the parent layout to expand to full width,
  making the entire row clickable.
- Changed to 'wrap_content' to limit the clickable area to actual content.
… page

- Added a 'search button' next to the 'sort button' in the same row on the History page
- Ensured that the blank space between 'sort button' and 'search button', as well as the 'search button' itself, is not part of the sort button's clickable area (wrapped buttons in a parent RelativeLayout; sort button width set to wrap_content)
- Added new string "search_history" for search button contentDescription (blind-friendly hint)
  1) Avoid reusing "enable_search_history_title" (intended for settings toggle)
  2) Did not reuse "search" since it is too generic and lacks context.
- Kept playlist control (three buttons in one line) in its original position below the two buttons
- Added a search button to the History page (already implemented in previous commits), next to the sort button
- This search button mimics the search button on home page (main page): clicking it shows a search input overlay
  - Overlay covers the leftmost sort button
  - Overlay includes:
    * 1dp View as underline to mimic the search bar on home page (main page)
    * Text input for search
    * Search input has watermark text "Search history" above the underline
    * Clear (X) button on the right end above the underline to exit search

- Uses FrameLayout to overlay the search bar without pushing playlist control down,
  otherwise the underline and (X) button would wrap to a new line, pushing playlist control down
- Soft keyboard automatically shows when search is activated

UI behavior:
- Tap search icon → overlay appears, covering the sort button
- Tap clear (X) → overlay disappears, input cleared, original UI restored
- No layout shift occurs

Prevent crash on Enter key in search input
- Added OnEditorActionListener to history search input to intercept
  IME search button and Enter key presses
- Hides soft keyboard when these keys are pressed, preventing crashes
- Does not trigger any search yet; just handles keyboard and avoids crash

Make cursor color follow textColor
- Set textCursorDrawable to null so cursor follows textColor
- Keeps behavior consistent with themed colors (no hardcoded values)
- cursor color on home page (main page) is white color, too.
- Added TextWatcher to search input to filter history in real time
- Introduced 'allHistoryEntries' to keep unfiltered dataset
- Implemented filterHistory() to match query against stream 'title' and
  'uploader' names.
  1) 'uploader' also means channel, for example: BBC Earth.
  2) Extract a helper method matchesHistoryEntry() from filterHistory()
- Filtering is case-insensitive and updates UI instantly as user types
…etter spacing

- Add 12dp start padding to align with existing UI spacing
- Improves visual alignment of search input and avoids text touching screen edge
- Limit search underline and input area to the left side of the clear (X) button
- Add a small start margin to the underline for better visual balance
- Improves spacing consistency and avoids the underline visually touching screen edges
…playback

- Reapply current search query when history entries are reloaded
- Keep search results consistent after returning from video playback
@github-actions github-actions Bot added the size/medium PRs with less than 250 changed lines label May 19, 2026
@TransZAllen

TransZAllen commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

Detailed description for current PR

Overview

Add a local history search UI to the history page.

Features:

  • Realtime filtering while typing
  • Case-insensitive matching
  • Search by both title and uploader
  • Preserves filtered state after returning from video playback
  • Multi-keyword search is currently not implemented.

UI Notes

The history search UI follows the existing search button behavior on main page (home page):

  • reuse the existing search icon (@drawable/ic_search)
  • expandable search input
  • close button to exit search mode

The search input temporarily covers the sort button while active.

String resources

Added:

<string name="search_history">Search history</string>

Only the default app/src/main/res/values/strings.xml was updated. Other translations will be handled through Weblate.

Filtering behavior

  • Realtime filtering while typing
  • Case-insensitive matching
  • Supports:
    • Latin characters
    • CJK characters
    • mixed-language input
    • special characters
  • Searches both:
    • stream 'title'
    • 'uploader' name

Currently unsupported:

  • multi-keyword search

About commit: Restore filtered results after returning from video playback

Reproduction steps:

  1. Enter a search query in the history page (for example: dav)
  2. Open a video from the filtered history results
  3. Quit the video playback by clicking the top-left close button (X)
  4. Return to the history page

Previously, the search query was still visible in the input field,
but the displayed history list was restored to the full unfiltered list.

Reason:
handleResult() is called whenever the history page reloads its entries,
including after returning from video playback.
Previously, handleResult() always restored the full history list directly,
without reapplying the current search query stored in the input field.

Fix:
handleResult() now restores history entries through filterHistory().
filterHistory() already handles both:

  • empty query → show full history list
  • non-empty query → show filtered history list

Since filterHistory() already handles the full-list case, the original addItems call is replaced.

Tested

Tested with:

  • 1000+ history entries with rapid typing/deleting → no visible lag
    • For performance/UI testing, a local script (fake_newpipe_history_generator.py) was used to generate ~1000 fake history entries. The script is not included in this PR.
  • special characters (space, multi-language, and mixed-language)
  • empty search results
  • switching sort modes (MOST_PLAYED / LAST_PLAYED) during filtering: filtered results still follow current sort mode correctly.
  • fragment re-entry:
    • background/foreground switching
    • returning from video playback
  • Android back button behavior during active search works normally:
    • first back press hides keyboard
    • second back press performs normal navigation

@TransZAllen

Copy link
Copy Markdown
Contributor Author

Cursor thickness

Note: The cursor is thinner than the one in the main search bar.
I could not find any explicit configuration controlling cursor thickness in the existing XML.
It seems to be the default system behavior in this layout.

If a thicker cursor is preferred, a custom cursor drawable can be introduced, and this PR can directly add a commit to do it.

Here is two screenshots showing the difference between the two cursors.
Image 1: cursor in the main search bar (original)

Image 2: cursor in the history search bar (new)

@ShareASmile ShareASmile added feature request Issue is related to a feature in the app GUI Issue is related to the graphical user interface database Issue and PRs related to database operations history Anything to do with previously watched stuff search Anything related to the search function labels May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

database Issue and PRs related to database operations feature request Issue is related to a feature in the app GUI Issue is related to the graphical user interface history Anything to do with previously watched stuff search Anything related to the search function size/medium PRs with less than 250 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants