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

Add search type link #9181

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/src/main/java/org/schabi/newpipe/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,10 @@ private void handleIntent(final Intent intent) {
NavigationHelper.openPlaylistFragment(getSupportFragmentManager(),
serviceId, url, title);
break;
case SEARCH:
NavigationHelper.openSearchFragment(getSupportFragmentManager(), serviceId,
intent.getStringExtra(Constants.KEY_SEARCH_STRING));
break;
}
} else if (intent.hasExtra(Constants.KEY_OPEN_SEARCH)) {
String searchString = intent.getStringExtra(Constants.KEY_SEARCH_STRING);
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,20 @@ private static Intent getOpenIntent(final Context context, final String url,
return mIntent;
}

private static Intent getOpenSearchIntent(final Context context, final String url,
final int serviceId,
final StreamingService.LinkType type,
final String searchString) {
final Intent mIntent = new Intent(context, MainActivity.class);
mIntent.putExtra(Constants.KEY_SERVICE_ID, serviceId);
mIntent.putExtra(Constants.KEY_URL, url);
mIntent.putExtra(Constants.KEY_LINK_TYPE, type);
mIntent.putExtra(Constants.KEY_SEARCH_STRING, searchString);
return mIntent;
}



public static Intent getIntentByLink(final Context context, final String url)
throws ExtractionException {
return getIntentByLink(context, NewPipe.getServiceByUrl(url), url);
Expand All @@ -672,6 +686,11 @@ public static Intent getIntentByLink(final Context context,
+ " url=" + url);
}

if (linkType == StreamingService.LinkType.SEARCH) {
return getOpenSearchIntent(context, url, service.getServiceId(),
linkType, service.getIdByUrl(url));
Comment on lines +690 to +691
Copy link
Member

Choose a reason for hiding this comment

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

Intead of obtaining the ID this way, as said in TeamNewPipe/NewPipeExtractor#950 (comment), I think you should use service.getSearchLHFactory().getId(url).

}

return getOpenIntent(context, url, service.getServiceId(), linkType);
}

Expand Down