Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
KnollFrank committed Nov 6, 2024
1 parent 3e955b5 commit af9597b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 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:ac1d019831'
implementation 'com.github.KnollFrank:SettingsSearch:290839e5ee'
// 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 @@ -4,6 +4,7 @@

import androidx.preference.PreferenceFragmentCompat;

import net.osmand.plus.plugins.OsmandPlugin;
import net.osmand.plus.plugins.PluginsHelper;
import net.osmand.plus.plugins.development.DevelopmentSettingsFragment;
import net.osmand.plus.plugins.development.OsmandDevelopmentPlugin;
Expand All @@ -13,16 +14,25 @@
class IncludePreferenceInSearchResultsPredicate implements de.KnollFrank.lib.settingssearch.provider.IncludePreferenceInSearchResultsPredicate {

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

private static boolean isPreferenceConnectedToAnInactivePlugin(final SearchablePreferencePOJO preference, final Class<? extends PreferenceFragmentCompat> hostOfPreference) {
// FK-TODO: handle also all the other plugins besides OsmandDevelopmentPlugin
if (isDevelopmentSettingsPreference(preference, host) && !PluginsHelper.isActive(OsmandDevelopmentPlugin.class)) {
return false;
}
return true;
return isPreferenceConnectedToInactivePlugin(
preference,
hostOfPreference,
DevelopmentSettingsFragment.class,
OsmandDevelopmentPlugin.class);
}

private static boolean isDevelopmentSettingsPreference(final SearchablePreferencePOJO preference,
final Class<? extends PreferenceFragmentCompat> host) {
return DevelopmentSettingsFragment.class.equals(host) || isPreferenceConnectedToPlugin(preference, OsmandDevelopmentPlugin.class);
private static boolean isPreferenceConnectedToInactivePlugin(
final SearchablePreferencePOJO preference,
final Class<? extends PreferenceFragmentCompat> hostOfPreference,
final Class<? extends PreferenceFragmentCompat> preferenceFragment,
final Class<? extends OsmandPlugin> plugin) {
return (preferenceFragment.equals(hostOfPreference) || isPreferenceConnectedToPlugin(preference, plugin)) &&
!PluginsHelper.isActive(plugin);
}
}

0 comments on commit af9597b

Please sign in to comment.