Skip to content

Commit 4e94b26

Browse files
authored
Merge pull request TeamNewPipe#12258 from Profpatsch/show-service-name-in-search
2 parents 4ddc064 + 16e32df commit 4e94b26

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,15 @@ public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGrou
219219
public void onViewCreated(@NonNull final View rootView, final Bundle savedInstanceState) {
220220
searchBinding = FragmentSearchBinding.bind(rootView);
221221
super.onViewCreated(rootView, savedInstanceState);
222+
223+
updateService();
224+
// Add the service name to search string hint
225+
// to make it more obvious which platform is being searched.
226+
if (service != null) {
227+
searchEditText.setHint(
228+
getString(R.string.search_with_service_name,
229+
service.getServiceInfo().getName()));
230+
}
222231
showSearchOnStart();
223232
initSearchListeners();
224233
}
@@ -936,6 +945,20 @@ private void changeContentFilter(final MenuItem item, final List<String> theCont
936945
filterItemCheckedId = item.getItemId();
937946
item.setChecked(true);
938947

948+
if (service != null) {
949+
final boolean isNotFiltered = theContentFilter.isEmpty()
950+
|| "all".equals(theContentFilter.get(0));
951+
if (isNotFiltered) {
952+
searchEditText.setHint(
953+
getString(R.string.search_with_service_name,
954+
service.getServiceInfo().getName()));
955+
} else {
956+
searchEditText.setHint(getString(R.string.search_with_service_name_and_filter,
957+
service.getServiceInfo().getName(),
958+
item.getTitle()));
959+
}
960+
}
961+
939962
contentFilter = theContentFilter.toArray(new String[0]);
940963

941964
if (!TextUtils.isEmpty(searchString)) {

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
<string name="download">Download</string>
1818
<string name="controls_download_desc">Download stream file</string>
1919
<string name="search">Search</string>
20+
<string name="search_with_service_name">Search %1$s</string>
21+
<string name="search_with_service_name_and_filter">Search %1$s (%2$s)</string>
2022
<string name="settings">Settings</string>
2123
<string name="did_you_mean">Did you mean \"%1$s\"?</string>
2224
<string name="search_showing_result_for">Showing results for: %s</string>

0 commit comments

Comments
 (0)