mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 07:16:04 -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) {
|
if (constraint != null) {
|
||||||
try {
|
try {
|
||||||
|
final String query = constraint.toString();
|
||||||
/* Get search request */
|
|
||||||
final String query = constraint.toString();
|
ZimContentProvider.searchSuggestions(query, 200);
|
||||||
|
String suggestion;
|
||||||
/* Fulltex search */
|
String suggestionUrl;
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
List<String> alreadyAdded = new ArrayList<>();
|
||||||
if (sharedPreferences.getBoolean(KiwixMobileActivity.PREF_FULL_TEXT_SEARCH, false)) {
|
while ((suggestion = ZimContentProvider.getNextSuggestion()) != null) {
|
||||||
String[] results = jniKiwix.indexedQuery(query, 200).split("\n");
|
suggestionUrl = ZimContentProvider.getPageUrlFromTitle(suggestion);
|
||||||
for (String result : results) {
|
if (!alreadyAdded.contains(suggestionUrl)) {
|
||||||
if (!result.trim().isEmpty())
|
alreadyAdded.add(suggestionUrl);
|
||||||
data.add(result);
|
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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return results */
|
/* Return results */
|
||||||
filterResults.values = data;
|
filterResults.values = data;
|
||||||
filterResults.count = data.size();
|
filterResults.count = data.size();
|
||||||
}
|
}
|
||||||
return filterResults;
|
return filterResults;
|
||||||
}
|
}
|
||||||
|
@ -46,12 +46,6 @@
|
|||||||
android:title="@string/pref_newtab_background_title"
|
android:title="@string/pref_newtab_background_title"
|
||||||
android:summary="@string/pref_newtab_background_summary"/>
|
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
|
<org.kiwix.kiwixmobile.settings.CustomSwitchPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="pref_wifi_only"
|
android:key="pref_wifi_only"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user