From 36126bcfb6e4c67f9959bb062f6b290c3075de28 Mon Sep 17 00:00:00 2001 From: frankknoll Date: Tue, 3 Dec 2024 23:45:19 +0100 Subject: [PATCH] refactoring --- .../plus/settings/fragments/BaseSettingsFragment.java | 1 + .../IncludePreferenceInSearchResultsPredicate.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java index 237597cb574..f532f95ee61 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java @@ -112,6 +112,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl private int statusBarColor = -1; private boolean nightMode; private boolean wasDrawerDisabled; + // FK-TODO: remove configureSettingsSearch? private boolean configureSettingsSearch = false; @Override diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/search/IncludePreferenceInSearchResultsPredicate.java b/OsmAnd/src/net/osmand/plus/settings/fragments/search/IncludePreferenceInSearchResultsPredicate.java index 0a066892c46..a380a11f1e7 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/search/IncludePreferenceInSearchResultsPredicate.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/search/IncludePreferenceInSearchResultsPredicate.java @@ -6,6 +6,8 @@ import net.osmand.plus.plugins.PluginsHelper; import net.osmand.plus.settings.fragments.SettingsScreenType; +import java.util.stream.Stream; + import javax.annotation.Nullable; import de.KnollFrank.lib.settingssearch.db.preference.pojo.SearchablePreferencePOJO; @@ -20,11 +22,16 @@ public boolean includePreferenceInSearchResults(final SearchablePreferencePOJO p private static boolean isPreferenceConnectedToAnyInactivePlugin(final SearchablePreferencePOJO preference, final Class hostOfPreference) { + return IncludePreferenceInSearchResultsPredicate + .getInactivePlugins() + .anyMatch(inactivePlugin -> isPreferenceConnectedToPlugin(preference, hostOfPreference, inactivePlugin)); + } + + private static Stream getInactivePlugins() { return PluginsHelper .getAvailablePlugins() .stream() - .filter(plugin -> !plugin.isActive()) - .anyMatch(inactivePlugin -> isPreferenceConnectedToPlugin(preference, hostOfPreference, inactivePlugin)); + .filter(plugin -> !plugin.isActive()); } private static boolean isPreferenceConnectedToPlugin(final SearchablePreferencePOJO preference,