diff --git a/README.md b/README.md index 04ac5f527..72678ff84 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ with additional meta-data. This is the version for Android. Kiwix Android is written in [Kotlin](https://kotlinlang.org/) (with a few old pieces in Java). -[![Build Status](https://travis-ci.org/kiwix/kiwix-android.svg?branch=develop)](https://travis-ci.org/kiwix/kiwix-android) +[![Build Status](https://travis-ci.com/kiwix/kiwix-android.svg?branch=develop)](https://travis-ci.com/kiwix/kiwix-android) [![codecov](https://codecov.io/gh/kiwix/kiwix-android/branch/develop/graph/badge.svg)](https://codecov.io/gh/kiwix/kiwix-android) [![CodeFactor](https://www.codefactor.io/repository/github/kiwix/kiwix-android/badge)](https://www.codefactor.io/repository/github/kiwix/kiwix-android) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index f8b65d6f9..0a7d6de89 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -105,7 +105,7 @@ object Versions { const val core_ktx: String = "1.1.0" - const val kiwixlib: String = "8.1.0" + const val kiwixlib: String = "8.2.1" const val material: String = "1.1.0-beta02" diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt index e7c5e0b7a..858b0fa3d 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt @@ -35,6 +35,7 @@ import org.kiwix.kiwixmobile.core.CoreApp import org.kiwix.kiwixmobile.core.NightModeConfig import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity.Book import org.kiwix.kiwixmobile.core.reader.ZimFileReader.Companion.CONTENT_URI +import org.kiwix.kiwixmobile.core.search.SearchSuggestion import org.kiwix.kiwixmobile.core.utils.files.FileUtils import java.io.File import java.io.FileDescriptor @@ -95,8 +96,14 @@ class ZimFileReader constructor( fun searchSuggestions(prefix: String, count: Int) = jniKiwixReader.searchSuggestions(prefix, count) - fun getNextSuggestion(): String? = - valueOfJniStringAfter(jniKiwixReader::getNextSuggestion) + fun getNextSuggestion(): SearchSuggestion? { + val title = JNIKiwixString() + val url = JNIKiwixString() + + return if (jniKiwixReader.getNextSuggestion(title, url)) + SearchSuggestion(title.value, url.value) + else null + } fun getPageUrlFrom(title: String): String? = valueOfJniStringAfter { jniKiwixReader.getPageUrlFromTitle(title, it) } diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/search/AutoCompleteAdapter.java b/core/src/main/java/org/kiwix/kiwixmobile/core/search/AutoCompleteAdapter.java index c7275ace3..311410c16 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/search/AutoCompleteAdapter.java +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/search/AutoCompleteAdapter.java @@ -26,6 +26,7 @@ import android.widget.Filter; import android.widget.Filterable; import android.widget.TextView; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import javax.inject.Inject; import org.kiwix.kiwixlib.JNIKiwix; @@ -117,10 +118,13 @@ public class AutoCompleteAdapter extends ArrayAdapter implements Filtera zimReaderContainer.searchSuggestions(query, 200); String suggestion; String suggestionUrl; + SearchSuggestion results; List alreadyAdded = new ArrayList<>(); - while ((suggestion = zimReaderContainer.getNextSuggestion()) != null) { - suggestionUrl = zimReaderContainer.getPageUrlFromTitle(suggestion); - if (!alreadyAdded.contains(suggestionUrl)) { + while ((results = zimReaderContainer.getNextSuggestion()) != null) { + suggestion = results.getTitle(); + suggestionUrl = results.getUrl(); + + if (!alreadyAdded.contains(suggestionUrl)) { alreadyAdded.add(suggestionUrl); data.add(suggestion); } diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/search/SearchSuggestion.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/search/SearchSuggestion.kt new file mode 100644 index 000000000..335d4ee32 --- /dev/null +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/search/SearchSuggestion.kt @@ -0,0 +1,21 @@ +/* + * Kiwix Android + * Copyright (c) 2019 Kiwix + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package org.kiwix.kiwixmobile.core.search + +data class SearchSuggestion(val title: String, val url: String)