mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 14:52:13 -04:00
Default and remove preference for fulltext search
This commit is contained in:
parent
b9c009a2e0
commit
45d9e2a730
@ -76,42 +76,27 @@ public class AutoCompleteAdapter extends ArrayAdapter<String> implements Filtera
|
||||
|
||||
if (constraint != null) {
|
||||
try {
|
||||
|
||||
/* Get search request */
|
||||
final String query = constraint.toString();
|
||||
|
||||
/* Fulltex search */
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
if (sharedPreferences.getBoolean(KiwixMobileActivity.PREF_FULL_TEXT_SEARCH, false)) {
|
||||
String[] results = jniKiwix.indexedQuery(query, 200).split("\n");
|
||||
for (String result : results) {
|
||||
if (!result.trim().isEmpty())
|
||||
data.add(result);
|
||||
final String query = constraint.toString();
|
||||
|
||||
ZimContentProvider.searchSuggestions(query, 200);
|
||||
String suggestion;
|
||||
String suggestionUrl;
|
||||
List<String> alreadyAdded = new ArrayList<>();
|
||||
while ((suggestion = ZimContentProvider.getNextSuggestion()) != null) {
|
||||
suggestionUrl = ZimContentProvider.getPageUrlFromTitle(suggestion);
|
||||
if (!alreadyAdded.contains(suggestionUrl)) {
|
||||
alreadyAdded.add(suggestionUrl);
|
||||
data.add(suggestion);
|
||||
}
|
||||
}
|
||||
|
||||
/* Suggestion search if no fulltext results */
|
||||
if (data.size() == 0) {
|
||||
ZimContentProvider.searchSuggestions(query, 200);
|
||||
String suggestion;
|
||||
String suggestionUrl;
|
||||
List<String> alreadyAdded = new ArrayList<>();
|
||||
while ((suggestion = ZimContentProvider.getNextSuggestion()) != null) {
|
||||
suggestionUrl = ZimContentProvider.getPageUrlFromTitle(suggestion);
|
||||
if (!alreadyAdded.contains(suggestionUrl)) {
|
||||
alreadyAdded.add(suggestionUrl);
|
||||
data.add(suggestion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
/* Return results */
|
||||
filterResults.values = data;
|
||||
filterResults.count = data.size();
|
||||
filterResults.values = data;
|
||||
filterResults.count = data.size();
|
||||
}
|
||||
return filterResults;
|
||||
}
|
||||
|
@ -46,12 +46,6 @@
|
||||
android:title="@string/pref_newtab_background_title"
|
||||
android:summary="@string/pref_newtab_background_summary"/>
|
||||
|
||||
<org.kiwix.kiwixmobile.settings.CustomSwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pref_full_text_search"
|
||||
android:title="@string/pref_full_text_search_title"
|
||||
android:summary="@string/pref_full_text_search_summary"/>
|
||||
|
||||
<org.kiwix.kiwixmobile.settings.CustomSwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="pref_wifi_only"
|
||||
|
Loading…
x
Reference in New Issue
Block a user