Skip to content

Commit f9bca97

Browse files
Stypoxwhistlingwoods
authored andcommitted
Merge pull request TeamNewPipe#12258 from Profpatsch/show-service-name-in-search
1 parent 08a2523 commit f9bca97

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
@@ -220,6 +220,15 @@ public View onCreateView(final LayoutInflater inflater, @Nullable final ViewGrou
220220
public void onViewCreated(@NonNull final View rootView, final Bundle savedInstanceState) {
221221
searchBinding = FragmentSearchBinding.bind(rootView);
222222
super.onViewCreated(rootView, savedInstanceState);
223+
224+
updateService();
225+
// Add the service name to search string hint
226+
// to make it more obvious which platform is being searched.
227+
if (service != null) {
228+
searchEditText.setHint(
229+
getString(R.string.search_with_service_name,
230+
service.getServiceInfo().getName()));
231+
}
223232
showSearchOnStart();
224233
initSearchListeners();
225234
}
@@ -939,6 +948,20 @@ private void changeContentFilter(final MenuItem item, final List<String> theCont
939948
filterItemCheckedId = item.getItemId();
940949
item.setChecked(true);
941950

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

944967
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)