mirror of
https://github.com/MaintainTeam/LastPipeBender.git
synced 2025-03-01 13:58:20 +03:00
Revert "searchfilters: integrate 3rd UI SearchFragment/SearchFragmentLegacy"
This reverts commit 2fc0ceeff1
.
This commit is contained in:
parent
d042457172
commit
93b597a418
4 changed files with 3 additions and 112 deletions
|
@ -154,7 +154,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
|
||||
private FragmentSearchBinding searchBinding;
|
||||
|
||||
protected View searchToolbarContainer;
|
||||
private View searchToolbarContainer;
|
||||
private EditText searchEditText;
|
||||
private View searchClear;
|
||||
|
||||
|
@ -171,19 +171,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
ArrayList<Integer> userSelectedSortFilterList = null;
|
||||
|
||||
public static SearchFragment getInstance(final int serviceId, final String searchString) {
|
||||
final SearchFragment searchFragment;
|
||||
final App app = App.getApp();
|
||||
|
||||
|
||||
final String searchUi = PreferenceManager.getDefaultSharedPreferences(app)
|
||||
.getString(app.getString(R.string.search_filter_ui_key),
|
||||
app.getString(R.string.search_filter_ui_value));
|
||||
if (app.getString(R.string.search_filter_ui_option_menu_legacy_key).equals(searchUi)) {
|
||||
searchFragment = new SearchFragmentLegacy();
|
||||
} else {
|
||||
searchFragment = new SearchFragment();
|
||||
}
|
||||
|
||||
final SearchFragment searchFragment = new SearchFragment();
|
||||
searchFragment.setQuery(serviceId, searchString, null, null);
|
||||
|
||||
if (!TextUtils.isEmpty(searchString)) {
|
||||
|
@ -679,7 +667,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
KeyboardUtil.showKeyboard(activity, searchEditText);
|
||||
}
|
||||
|
||||
protected void hideKeyboardSearch() {
|
||||
private void hideKeyboardSearch() {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "hideKeyboardSearch() called");
|
||||
}
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
// Created by evermind-zz 2022, licensed GNU GPL version 3 or later
|
||||
|
||||
package org.schabi.newpipe.fragments.list.search;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.fragments.list.search.filter.SearchFilterUIOptionMenu;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import icepick.State;
|
||||
|
||||
/**
|
||||
* UI that hosts the options menu based filter 'dialog'.
|
||||
* <p>
|
||||
* Called ..Legacy because of this was the way NewPipe had implemented the search filter dialog.
|
||||
* The new UI was implemented using a {@link androidx.fragment.app.DialogFragment}
|
||||
* {@link SearchFragment}
|
||||
*/
|
||||
public class SearchFragmentLegacy extends SearchFragment {
|
||||
|
||||
@State
|
||||
protected int countOnPrepareOptionsMenuCalls = 0;
|
||||
private SearchFilterUIOptionMenu searchFilterUi;
|
||||
|
||||
@Override
|
||||
protected void initializeFilterData() {
|
||||
try {
|
||||
final StreamingService service = NewPipe.getService(serviceId);
|
||||
|
||||
searchFilterUi = new SearchFilterUIOptionMenu(service, this, getContext());
|
||||
searchFilterUi.restorePreviouslySelectedFilters(
|
||||
userSelectedContentFilterList,
|
||||
userSelectedSortFilterList);
|
||||
|
||||
userSelectedContentFilterList = searchFilterUi.getSelectedContentFilters();
|
||||
userSelectedSortFilterList = searchFilterUi.getSelectedSortFilters();
|
||||
selectedContentFilter = searchFilterUi.getSelectedContentFilterItems();
|
||||
selectedSortFilter = searchFilterUi.getSelectedSortFiltersItems();
|
||||
} catch (final ExtractionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull final Bundle bundle) {
|
||||
// get data to save its state via Icepick
|
||||
userSelectedContentFilterList = searchFilterUi.getSelectedContentFilters();
|
||||
userSelectedSortFilterList = searchFilterUi.getSelectedSortFilters();
|
||||
|
||||
super.onSaveInstanceState(bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createMenu(@NonNull final Menu menu,
|
||||
@NonNull final MenuInflater inflater) {
|
||||
searchFilterUi.createSearchUI(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
||||
return searchFilterUi.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews(final View rootView,
|
||||
final Bundle savedInstanceState) {
|
||||
super.initViews(rootView, savedInstanceState);
|
||||
final Toolbar toolbar = (Toolbar) searchToolbarContainer.getParent();
|
||||
toolbar.setOverflowIcon(ContextCompat.getDrawable(requireContext(),
|
||||
R.drawable.ic_sort));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(@NonNull final Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
// workaround: we want to hide the keyboard in case we open the options
|
||||
// menu. As somehow this method gets triggered twice but only the 2nd
|
||||
// time is relevant as the options menu is selected by the user.
|
||||
if (++countOnPrepareOptionsMenuCalls > 1) {
|
||||
hideKeyboardSearch();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1278,18 +1278,15 @@
|
|||
|
||||
<string name="search_filter_ui_dialog_key">dialog</string>
|
||||
<string name="search_filter_ui_option_menu_style_key">style</string>
|
||||
<string name="search_filter_ui_option_menu_legacy_key">legacy</string>
|
||||
|
||||
<string-array name="search_filter_ui_values">
|
||||
<item>@string/search_filter_ui_dialog_key</item>
|
||||
<item>@string/search_filter_ui_option_menu_style_key</item>
|
||||
<item>@string/search_filter_ui_option_menu_legacy_key</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="search_filter_ui_description">
|
||||
<item>@string/search_filter_ui_dialog</item>
|
||||
<item>@string/search_filter_ui_style</item>
|
||||
<item>@string/search_filter_ui_legacy</item>
|
||||
</string-array>
|
||||
|
||||
<string name="tablet_mode_key">tablet_mode</string>
|
||||
|
|
|
@ -552,7 +552,6 @@
|
|||
<string name="search_filter_ui">Select Search Filter UI</string>
|
||||
<string name="search_filter_ui_dialog">Simple Dialog (default)</string>
|
||||
<string name="search_filter_ui_style">Action Menu styled Dialog</string>
|
||||
<string name="search_filter_ui_legacy">Action Menu (legacy)</string>
|
||||
<!-- Seekbar Preview Thumbnail-->
|
||||
<string name="seekbar_preview_thumbnail_title">Seekbar thumbnail preview</string>
|
||||
<string name="high_quality_larger">High quality (larger)</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue