diff --git a/OsmAnd/build-common.gradle b/OsmAnd/build-common.gradle
index a36a170661f..73436d93686 100644
--- a/OsmAnd/build-common.gradle
+++ b/OsmAnd/build-common.gradle
@@ -386,7 +386,7 @@ dependencies {
implementation "androidx.car.app:app-projected:1.2.0"
implementation 'com.google.android.gms:play-services-location:21.0.1'
- implementation 'com.github.KnollFrank:SearchPreference:0bb034822d'
+ implementation 'com.github.KnollFrank:SearchPreference:ac4c4f9fa5'
implementation 'com.google.guava:guava:33.2.0-android'
//implementation "androidx.tracing:tracing:1.1.0"
diff --git a/OsmAnd/res/xml/settings_main_screen.xml b/OsmAnd/res/xml/settings_main_screen.xml
index 985eafb2910..7075f83c16b 100644
--- a/OsmAnd/res/xml/settings_main_screen.xml
+++ b/OsmAnd/res/xml/settings_main_screen.xml
@@ -4,9 +4,6 @@
xmlns:tools="http://schemas.android.com/tools"
android:title="@string/shared_string_settings">
-
-
contentViewAndDummyFragmentContainerViewId =
+ UIUtils.createContentViewAndDummyFragmentContainerViewId(
+ resource,
+ this);
+ dummyFragmentContainerViewId = contentViewAndDummyFragmentContainerViewId.second;
+ setContentView(contentViewAndDummyFragmentContainerViewId.first);
+ }
+
+ public SearchConfiguration createSearchConfiguration(final PreferenceFragmentCompat root) {
+ final SearchConfiguration searchConfiguration = new SearchConfiguration();
+ searchConfiguration.setActivity(this);
+ searchConfiguration.setFragmentContainerViewId(FRAGMENT_CONTAINER_VIEW);
+ searchConfiguration.setDummyFragmentContainerViewId(dummyFragmentContainerViewId);
+ searchConfiguration.setPreferenceFragments(
+ PreferenceFragments.getPreferenceFragments(
+ root,
+ this,
+ dummyFragmentContainerViewId));
+ searchConfiguration.setBreadcrumbsEnabled(true);
+ searchConfiguration.setFuzzySearchEnabled(false);
+ searchConfiguration.setHistoryEnabled(true);
+ return searchConfiguration;
+ }
}
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java
index efe3698762f..0b97141f367 100644
--- a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java
@@ -2,7 +2,6 @@
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.SETTINGS_ID;
-import static net.osmand.plus.activities.MapActivity.FRAGMENT_CONTAINER_VIEW;
import android.annotation.SuppressLint;
import android.app.Activity;
@@ -47,9 +46,6 @@
import androidx.recyclerview.widget.RecyclerView;
import com.bytehamster.lib.preferencesearch.BaseSearchPreferenceFragment;
-import com.bytehamster.lib.preferencesearch.PreferenceFragments;
-import com.bytehamster.lib.preferencesearch.SearchConfiguration;
-import com.bytehamster.lib.preferencesearch.SearchPreference;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.snackbar.Snackbar;
@@ -147,7 +143,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
PreferenceManager prefManager = getPreferenceManager();
PreferenceScreen preferenceScreen = prefManager.inflateFromResource(prefManager.getContext(), currentScreenType.preferencesResId, null);
if (prefManager.setPreferences(preferenceScreen)) {
- setupSearchablePreferences();
+ setupPreferences();
registerPreferences(preferenceScreen);
}
} else {
@@ -388,18 +384,6 @@ public void recreate() {
protected abstract void setupPreferences();
- private void setupSearchablePreferences() {
- setupPreferences();
- final SearchPreference searchPreference = findPreference("searchPreference");
- if (searchPreference != null) {
- final SearchConfiguration config = searchPreference.getSearchConfiguration();
- config.setActivity(getMapActivity());
- config.setFragmentContainerViewId(FRAGMENT_CONTAINER_VIEW);
- config.setPreferenceFragmentsSupplier(() -> PreferenceFragments.getPreferenceFragments(new MainSettingsFragment(), getActivity(), FRAGMENT_CONTAINER_VIEW));
- config.setFuzzySearchEnabled(false);
- }
- }
-
protected void onBindPreferenceViewHolder(@NonNull Preference preference, @NonNull PreferenceViewHolder holder) {
if (preference.isSelectable()) {
View selectableView = holder.itemView.findViewById(R.id.selectable_list_item);
@@ -559,7 +543,7 @@ private void updatePreferencesScreen() {
if (resId != -1) {
addPreferencesFromResource(resId);
}
- setupSearchablePreferences();
+ setupPreferences();
registerPreferences(getPreferenceScreen());
}
}
diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/MainSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/MainSettingsFragment.java
index 27d4ee6c2c6..6ec4de5b4f2 100644
--- a/OsmAnd/src/net/osmand/plus/settings/fragments/MainSettingsFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/fragments/MainSettingsFragment.java
@@ -8,7 +8,9 @@
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.view.LayoutInflater;
import android.view.View;
+import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.ColorRes;
@@ -17,8 +19,12 @@
import androidx.fragment.app.FragmentManager;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceViewHolder;
+import com.bytehamster.lib.preferencesearch.SearchConfiguration;
+import com.bytehamster.lib.preferencesearch.SearchPreferenceFragments;
+
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@@ -263,4 +269,27 @@ public void onProfileSelected(Bundle args) {
profileKey, imported);
}
}
+
+ @Override
+ protected void createToolbar(@NonNull final LayoutInflater inflater, @NonNull final View view) {
+ super.createToolbar(inflater, view);
+ configureSearchPreferenceButton(view.findViewById(R.id.action_button));
+ }
+
+ @Override
+ protected void updateToolbar() {
+ super.updateToolbar();
+ }
+
+ private void configureSearchPreferenceButton(final ImageView searchPreferenceButton) {
+ searchPreferenceButton.setOnClickListener(v -> showSearchPreferenceFragment(new MainSettingsFragment()));
+ searchPreferenceButton.setImageDrawable(getIcon(R.drawable.searchpreference_ic_search));
+ searchPreferenceButton.setVisibility(View.VISIBLE);
+ }
+
+ private void showSearchPreferenceFragment(final PreferenceFragmentCompat root) {
+ final SearchConfiguration searchConfiguration = getMapActivity().createSearchConfiguration(root);
+ final SearchPreferenceFragments searchPreferenceFragments = new SearchPreferenceFragments(searchConfiguration);
+ searchPreferenceFragments.showSearchPreferenceFragment();
+ }
}
\ No newline at end of file