From c4fda9a770760a7a3b9d6c1ce9ad7174ab003b74 Mon Sep 17 00:00:00 2001 From: frankknoll Date: Wed, 4 Dec 2024 14:51:10 +0100 Subject: [PATCH] refactoring --- OsmAnd/build-common.gradle | 2 +- ...IncludePreferenceInSearchResultsPredicate.java | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/OsmAnd/build-common.gradle b/OsmAnd/build-common.gradle index 3e44f6939a3..c9e7c91dcc9 100644 --- a/OsmAnd/build-common.gradle +++ b/OsmAnd/build-common.gradle @@ -375,7 +375,7 @@ dependencies { implementation "androidx.car.app:app-projected:1.4.0" implementation 'com.google.android.gms:play-services-location:21.3.0' - implementation 'com.github.KnollFrank:SettingsSearch:21ac7ef232' + implementation 'com.github.KnollFrank:SettingsSearch:d5f48a4a0a' // https://mvnrepository.com/artifact/com.google.guava/guava implementation 'com.google.guava:guava:33.3.1-android' 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 a380a11f1e7..2e256c0c03a 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/search/IncludePreferenceInSearchResultsPredicate.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/search/IncludePreferenceInSearchResultsPredicate.java @@ -15,16 +15,14 @@ class IncludePreferenceInSearchResultsPredicate implements de.KnollFrank.lib.settingssearch.provider.IncludePreferenceInSearchResultsPredicate { @Override - public boolean includePreferenceInSearchResults(final SearchablePreferencePOJO preference, - final Class hostOfPreference) { - return !isPreferenceConnectedToAnyInactivePlugin(preference, hostOfPreference); + public boolean includePreferenceInSearchResults(final SearchablePreferencePOJO preference) { + return !isPreferenceConnectedToAnyInactivePlugin(preference); } - private static boolean isPreferenceConnectedToAnyInactivePlugin(final SearchablePreferencePOJO preference, - final Class hostOfPreference) { + private static boolean isPreferenceConnectedToAnyInactivePlugin(final SearchablePreferencePOJO preference) { return IncludePreferenceInSearchResultsPredicate .getInactivePlugins() - .anyMatch(inactivePlugin -> isPreferenceConnectedToPlugin(preference, hostOfPreference, inactivePlugin)); + .anyMatch(inactivePlugin -> isPreferenceConnectedToPlugin(preference, inactivePlugin)); } private static Stream getInactivePlugins() { @@ -35,15 +33,14 @@ private static Stream getInactivePlugins() { } private static boolean isPreferenceConnectedToPlugin(final SearchablePreferencePOJO preference, - final Class hostOfPreference, final OsmandPlugin plugin) { - return isPreferenceOnSettingsScreen(hostOfPreference, plugin.getSettingsScreenType()) || + return isPreferenceOnSettingsScreen(preference.getHost(), plugin.getSettingsScreenType()) || PreferenceMarker.isPreferenceConnectedToPlugin(preference, plugin.getClass()); } private static boolean isPreferenceOnSettingsScreen( final Class preferenceFragment, final @Nullable SettingsScreenType settingsScreenType) { - return settingsScreenType != null && settingsScreenType.fragmentName.equals(preferenceFragment.getName()); + return settingsScreenType != null && settingsScreenType.fragmentClass.equals(preferenceFragment); } }