Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
KnollFrank committed Dec 4, 2024
1 parent 1c9fe21 commit c4fda9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion OsmAnd/build-common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
class IncludePreferenceInSearchResultsPredicate implements de.KnollFrank.lib.settingssearch.provider.IncludePreferenceInSearchResultsPredicate {

@Override
public boolean includePreferenceInSearchResults(final SearchablePreferencePOJO preference,
final Class<? extends PreferenceFragmentCompat> hostOfPreference) {
return !isPreferenceConnectedToAnyInactivePlugin(preference, hostOfPreference);
public boolean includePreferenceInSearchResults(final SearchablePreferencePOJO preference) {
return !isPreferenceConnectedToAnyInactivePlugin(preference);
}

private static boolean isPreferenceConnectedToAnyInactivePlugin(final SearchablePreferencePOJO preference,
final Class<? extends PreferenceFragmentCompat> 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<OsmandPlugin> getInactivePlugins() {
Expand All @@ -35,15 +33,14 @@ private static Stream<OsmandPlugin> getInactivePlugins() {
}

private static boolean isPreferenceConnectedToPlugin(final SearchablePreferencePOJO preference,
final Class<? extends PreferenceFragmentCompat> 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<? extends PreferenceFragmentCompat> preferenceFragment,
final @Nullable SettingsScreenType settingsScreenType) {
return settingsScreenType != null && settingsScreenType.fragmentName.equals(preferenceFragment.getName());
return settingsScreenType != null && settingsScreenType.fragmentClass.equals(preferenceFragment);
}
}

0 comments on commit c4fda9a

Please sign in to comment.