0
0
mirror of https://github.com/mediathekview/zapp.git synced 2024-09-20 04:12:14 +02:00

Remove search suggestion feature

This commit is contained in:
Christine Coenen 2021-11-07 19:36:00 +01:00
parent 18980c0c83
commit 4b761c10c8
10 changed files with 1 additions and 110 deletions

View File

@ -110,11 +110,6 @@
android:name=".app.player.BackgroundPlayerService"
android:exported="false" />
<provider
android:name=".app.mediathek.repository.MediathekSearchSuggestionsProvider"
android:authorities="de.christinecoenen.code.zapp.MediathekSearchSuggestionsProvider"
android:exported="false" />
<receiver
android:name=".utils.system.PackageUpdateReceiver"
android:enabled="true"

View File

@ -1,29 +0,0 @@
package de.christinecoenen.code.zapp.app.mediathek.repository
import android.content.Context
import android.content.SearchRecentSuggestionsProvider
import android.provider.SearchRecentSuggestions
class MediathekSearchSuggestionsProvider : SearchRecentSuggestionsProvider() {
companion object {
private const val AUTHORITY = "de.christinecoenen.code.zapp.MediathekSearchSuggestionsProvider"
private const val MODE = DATABASE_MODE_QUERIES
fun saveQuery(context: Context, query: String) {
val suggestions = SearchRecentSuggestions(context, AUTHORITY, MODE)
suggestions.saveRecentQuery(query, null)
}
@JvmStatic
fun deleteAllQueries(context: Context) {
val suggestions = SearchRecentSuggestions(context, AUTHORITY, MODE)
suggestions.clearHistory()
}
}
init {
setupSuggestions(AUTHORITY, MODE)
}
}

View File

@ -1,7 +0,0 @@
package de.christinecoenen.code.zapp.app.settings.ui
import android.content.Context
import android.util.AttributeSet
import androidx.preference.DialogPreference
internal class DeleteSearchQueriesPreference(context: Context?, attrs: AttributeSet?) : DialogPreference(context, attrs)

View File

@ -1,26 +0,0 @@
package de.christinecoenen.code.zapp.app.settings.ui
import android.os.Bundle
import androidx.preference.PreferenceDialogFragmentCompat
import de.christinecoenen.code.zapp.app.mediathek.repository.MediathekSearchSuggestionsProvider.Companion.deleteAllQueries
class DeleteSearchQueriesPreferenceDialog : PreferenceDialogFragmentCompat() {
companion object {
fun newInstance(key: String): DeleteSearchQueriesPreferenceDialog {
return DeleteSearchQueriesPreferenceDialog().apply {
arguments = Bundle().apply {
putString(ARG_KEY, key)
}
}
}
}
override fun onDialogClosed(positiveResult: Boolean) {
if (positiveResult) {
deleteAllQueries(requireContext())
}
}
}

View File

@ -9,7 +9,6 @@ import androidx.preference.PreferenceFragmentCompat
import de.christinecoenen.code.zapp.R
import de.christinecoenen.code.zapp.app.settings.helper.ShortcutPreference
import de.christinecoenen.code.zapp.app.settings.repository.SettingsRepository
import java.util.*
/**
* Use the [SettingsFragment.newInstance] factory method to
@ -69,16 +68,4 @@ class SettingsFragment : PreferenceFragmentCompat() {
shortcutPreference.onPreferenceChangeListener = null
uiModePreference.onPreferenceChangeListener = null
}
override fun onDisplayPreferenceDialog(preference: Preference) {
if (preference is DeleteSearchQueriesPreference) {
val dialogFragment = DeleteSearchQueriesPreferenceDialog.newInstance(preference.getKey())
dialogFragment.setTargetFragment(this, 0)
dialogFragment.show(Objects.requireNonNull(parentFragmentManager), null)
return
}
super.onDisplayPreferenceDialog(preference)
}
}

View File

@ -1,8 +1,6 @@
package de.christinecoenen.code.zapp.repositories
import androidx.paging.PagingSource
import de.christinecoenen.code.zapp.app.mediathek.api.IMediathekApiService
import de.christinecoenen.code.zapp.app.mediathek.api.request.QueryRequest
import de.christinecoenen.code.zapp.models.shows.DownloadStatus
import de.christinecoenen.code.zapp.models.shows.MediathekShow
import de.christinecoenen.code.zapp.models.shows.PersistedMediathekShow
@ -14,27 +12,12 @@ import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.withContext
import org.joda.time.DateTime
import retrofit2.http.Body
class MediathekRepository(
private val mediathekApi: IMediathekApiService,
private val database: Database
) {
class MediathekRepository(private val database: Database) {
val downloads: PagingSource<Int, PersistedMediathekShow>
get() = database.mediathekShowDao().getAllDownloads()
suspend fun listShows(@Body queryRequest: QueryRequest): List<MediathekShow> =
withContext(Dispatchers.IO) {
val mediathekAnswer = mediathekApi.listShows(queryRequest)
if (mediathekAnswer.result == null || mediathekAnswer.err != null) {
throw RuntimeException("Empty result")
}
mediathekAnswer.result.results
}
suspend fun persistOrUpdateShow(show: MediathekShow): Flow<PersistedMediathekShow> =
withContext(Dispatchers.IO) {
database

View File

@ -118,9 +118,6 @@
<string name="pref_download_to_sd_card_title">Download to sd card</string>
<string name="pref_download_to_sd_card_summary">Video files will be saved to sd card if present.</string>
<string name="pref_delete_search_queries_title">Delete search queries</string>
<string name="pref_delete_search_queries_dialog_message">Really delete all of your search queries?</string>
<!-- notifications -->
<string name="notification_channel_name_background_playback">Background player</string>
<string name="notification_channel_name_download_progress">Download progress</string>

View File

@ -8,6 +8,5 @@
<string name="pref_key_shortcuts">pref_shortcuts</string>
<string name="pref_key_player_zoomed">pref_key_player_zoomed</string>
<string name="pref_key_download_to_sd_card">pref_key_download_to_sd_card</string>
<string name="pref_key_delete_search_queries">pref_key_delete_search_queries</string>
</resources>

View File

@ -118,9 +118,6 @@
<string name="pref_download_to_sd_card_title">Downloads auf SD-Karte</string>
<string name="pref_download_to_sd_card_summary">Wenn verfügbar, werden Video-Dateien auf die SD-Karte gespeichert.</string>
<string name="pref_delete_search_queries_title">Suchanfragen löschen</string>
<string name="pref_delete_search_queries_dialog_message">Wirklich alle vergangenen Suchanfragen löschen?</string>
<!-- notifications -->
<string name="notification_channel_name_background_playback">Hintergrund-Videoplayer</string>
<string name="notification_channel_name_download_progress">Download Fortschritt</string>

View File

@ -70,11 +70,6 @@
android:summary="@string/pref_download_to_sd_card_summary"
android:title="@string/pref_download_to_sd_card_title" />
<de.christinecoenen.code.zapp.app.settings.ui.DeleteSearchQueriesPreference
android:dialogMessage="@string/pref_delete_search_queries_dialog_message"
android:key="@string/pref_key_delete_search_queries"
android:title="@string/pref_delete_search_queries_title" />
</PreferenceCategory>
</androidx.preference.PreferenceScreen>