Merge remote-tracking branch 'origin/develop' into feature/macgills/1301-night-mode

# Conflicts:
#	core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimFileReader.kt
This commit is contained in:
Sean Mac Gillicuddy 2019-11-29 10:03:00 +00:00
commit 09cd95cb78
5 changed files with 39 additions and 7 deletions

View File

@ -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)

View File

@ -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"

View File

@ -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) }

View File

@ -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<String> implements Filtera
zimReaderContainer.searchSuggestions(query, 200);
String suggestion;
String suggestionUrl;
SearchSuggestion results;
List<String> 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);
}

View File

@ -0,0 +1,21 @@
/*
* Kiwix Android
* Copyright (c) 2019 Kiwix <android.kiwix.org>
* 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 <http://www.gnu.org/licenses/>.
*
*/
package org.kiwix.kiwixmobile.core.search
data class SearchSuggestion(val title: String, val url: String)