2021-12-24 21:33:40 +01:00
|
|
|
package org.schabi.newpipe.settings.preferencesearch;
|
|
|
|
|
|
|
|
import androidx.preference.PreferenceCategory;
|
|
|
|
import androidx.preference.PreferenceScreen;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
2022-03-18 18:15:44 +01:00
|
|
|
import java.util.Collections;
|
2021-12-24 21:33:40 +01:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
public class PreferenceSearchConfiguration {
|
2021-12-25 00:06:06 +01:00
|
|
|
private PreferenceSearchFunction searcher = new PreferenceFuzzySearchFunction();
|
2021-12-24 21:33:40 +01:00
|
|
|
|
2022-03-18 18:15:44 +01:00
|
|
|
private final List<String> parserIgnoreElements = Collections.singletonList(
|
2021-12-24 21:33:40 +01:00
|
|
|
PreferenceCategory.class.getSimpleName());
|
|
|
|
private final List<String> parserContainerElements = Arrays.asList(
|
|
|
|
PreferenceCategory.class.getSimpleName(),
|
|
|
|
PreferenceScreen.class.getSimpleName());
|
|
|
|
|
|
|
|
|
|
|
|
public void setSearcher(final PreferenceSearchFunction searcher) {
|
|
|
|
this.searcher = Objects.requireNonNull(searcher);
|
|
|
|
}
|
|
|
|
|
2022-01-09 15:22:05 +01:00
|
|
|
public PreferenceSearchFunction getSearcher() {
|
2021-12-24 21:33:40 +01:00
|
|
|
return searcher;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<String> getParserIgnoreElements() {
|
|
|
|
return parserIgnoreElements;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<String> getParserContainerElements() {
|
|
|
|
return parserContainerElements;
|
|
|
|
}
|
|
|
|
|
|
|
|
@FunctionalInterface
|
|
|
|
public interface PreferenceSearchFunction {
|
|
|
|
Stream<PreferenceSearchItem> search(
|
|
|
|
Stream<PreferenceSearchItem> allAvailable,
|
|
|
|
String keyword);
|
|
|
|
}
|
|
|
|
}
|