Skip to content
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

Allow starting the search fragment via intent #11615

Closed
wants to merge 1 commit into from

Conversation

jiahengguo123
Copy link

@jiahengguo123 jiahengguo123 commented Oct 17, 2024

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

  • Extended custom URL scheme to include service selection: Implemented the ability for third-party apps to initiate a search in NewPipe on a specific service by using the custom URL scheme newpipe://search?service=SERVICE_NAME\&q=YOUR_QUERY.
  • Added intent-filter to RouterActivity: Updated AndroidManifest.xml to include an intent-filter in RouterActivity to handle the custom URL scheme.
  • Enhanced RouterActivity to handle 'service' parameter: Modified RouterActivity to parse the incoming service parameter from the intent, retrieve the corresponding service ID, and start MainActivity with the specified service and search query.
  • Added error handling for invalid service names: Implemented validation for the service parameter to check if the provided service name is valid. If the service name is invalid, the app displays an error message to the user.
  • Tested the implementation: Used ADB commands to send an intent with the custom URI and verified that NewPipe performs the search as expected, such as adb shell am start -a android.intent.action.VIEW -d "newpipe://search?service=Soundcloud\&q=funny%20cats".

Fixes the following issue(s)

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.

Due diligence

@github-actions github-actions bot added the size/medium PRs with less than 250 changed lines label Oct 17, 2024
@ShareASmile ShareASmile added feature request Issue is related to a feature in the app search Anything related to the search function labels Oct 17, 2024
@ShareASmile ShareASmile mentioned this pull request Oct 20, 2024
5 tasks
@opusforlife2
Copy link
Collaborator

How does this interact with service selection? If Soundcloud is selected by the user before this intent is sent, will it still work?

@jiahengguo123
Copy link
Author

How does this interact with service selection? If Soundcloud is selected by the user before this intent is sent, will it still work?

I think it will still work. Through ServiceHelper. GetSelectedServiceId (this) in RouterActivity service for the currently selected user ID is the keypoint. This ID is then passed to the MainActivity and used to initialize the SearchFragment, make sure that the search operation is performed for the currently selected service by the user. Therefore, if the user has selected SoundCloud before sending this intent, the search will be performed on SoundCloud.

@opusforlife2
Copy link
Collaborator

I'm a little confused, then. If an app sends to search for a Youtube video, but the user has selected Soundcloud, will they get an incorrect search? Or maybe an error?

There seems to be a need to specify the service in addition to the query string.

@jiahengguo123
Copy link
Author

I understand the question. I can add a match to the URL with the service parameter in the Intent filter. The new command can be newpipe://search? service=youtube&q=funny cats

@jiahengguo123
Copy link
Author

I have improved the code so that now users can specify a service to search by adding a service name to the URL. And an error notification for the wrong name. I also modified the Pull Request description.

Copy link
Member

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

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

Thank your for the PR.
Please clean your git history, squash commits if reasonable, check for faulty merges / rebases. Your PR has merge conflicts. We'll take another look at this PR once the changeset is clear.

Copy link
Member

@TobiGr TobiGr Nov 2, 2024

Choose a reason for hiding this comment

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

It looks like that a merge / rebase went wrong here. This reverts changes from a recently merged PR. Please check and clean your git history and rebase the PR.

- Implemented the abilImplemented the ability for third-party apps to initiate a search in NewPipe on a specific service by using the custom URL scheme `newpipe://search?service=SERVICE_NAME&q=YOUR_QUERY`.
- Added intent-filter to RouterActivity to handle the custom URL scheme.
- Enhanced RouterActivity to parse the incoming service parameter, retrieve the corresponding service ID, and start MainActivity with the specified service and search query.
- Added error handling for invalid service names: displays an error message to the user if the service name is invalid.
- Tested the implementation using ADB commands to send an intent with the custom URI.
Fixes: Expose search API with url TeamNewPipe#3475

Add new tag to customize urls

add logic of handling custom search intents in onCreate method

add comments to helping review

add a new method to get the service by name

improve the RouterActivity to handle the service name

improve the RouterActivity
@Stypox Stypox changed the title Expose search issue #3475 Allow starting the search fragment via intent Nov 10, 2024
@Stypox
Copy link
Member

Stypox commented Nov 18, 2024

Closing as there has not been recent activity and because NewPipe is currently not accepting new feature PRs, as noted in the README. This feature, however, would be pretty neat. It should probably be implemented in MainActivity though.

@Stypox Stypox closed this Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issue is related to a feature in the app search Anything related to the search function size/medium PRs with less than 250 changed lines
Projects
No open projects
Status: Rejected
Development

Successfully merging this pull request may close these issues.

Expose search API with url
5 participants