Search history and suggestion
This commit is contained in:
@@ -41,6 +41,9 @@
|
|||||||
|
|
||||||
<service android:name=".ui.download.DownloadService" />
|
<service android:name=".ui.download.DownloadService" />
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name=".domain.search.MangaSuggestionsProvider"
|
||||||
|
android:authorities="${applicationId}.MangaSuggestionsProvider" />
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="${applicationId}.files"
|
android:authorities="${applicationId}.files"
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package org.koitharu.kotatsu.domain.search
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SearchRecentSuggestionsProvider
|
||||||
|
import android.provider.SearchRecentSuggestions
|
||||||
|
import org.koitharu.kotatsu.BuildConfig
|
||||||
|
|
||||||
|
class MangaSuggestionsProvider : SearchRecentSuggestionsProvider() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
setupSuggestions(AUTHORITY, MODE)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun saveQuery(context: Context, query: String) {
|
||||||
|
SearchRecentSuggestions(context, AUTHORITY, MODE)
|
||||||
|
.saveRecentQuery(query, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearHistory(context: Context) {
|
||||||
|
SearchRecentSuggestions(context, AUTHORITY, MODE)
|
||||||
|
.clearHistory()
|
||||||
|
}
|
||||||
|
|
||||||
|
private const val AUTHORITY = "${BuildConfig.APPLICATION_ID}.MangaSuggestionsProvider"
|
||||||
|
private const val MODE = DATABASE_MODE_QUERIES
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import android.app.SearchManager
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.domain.search.MangaSuggestionsProvider
|
||||||
import org.koitharu.kotatsu.ui.common.BaseActivity
|
import org.koitharu.kotatsu.ui.common.BaseActivity
|
||||||
|
|
||||||
class SearchActivity : BaseActivity() {
|
class SearchActivity : BaseActivity() {
|
||||||
@@ -20,6 +21,7 @@ class SearchActivity : BaseActivity() {
|
|||||||
finish()
|
finish()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
MangaSuggestionsProvider.saveQuery(this, query)
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
title = query
|
title = query
|
||||||
supportActionBar?.setSubtitle(R.string.search_results)
|
supportActionBar?.setSubtitle(R.string.search_results)
|
||||||
|
|||||||
@@ -4,5 +4,7 @@
|
|||||||
android:hint="@string/search_manga"
|
android:hint="@string/search_manga"
|
||||||
android:inputType="textPersonName"
|
android:inputType="textPersonName"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
android:searchSuggestAuthority="org.koitharu.kotatsu.MangaSuggestionsProvider"
|
||||||
|
android:searchSuggestSelection=" ?"
|
||||||
android:voiceLanguageModel="web_search"
|
android:voiceLanguageModel="web_search"
|
||||||
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" />
|
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" />
|
||||||
|
|||||||
Reference in New Issue
Block a user