Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: option to disable search history #464

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class KoinModules {
viewModel { parameters -> MediathekListFragmentViewModel(get(), parameters.get()) }
viewModel { MediathekFilterViewModel() }
viewModel { ShowMenuHelperViewModel(get(), get()) }
viewModel { SearchViewModel(get(), get(), get()) }
viewModel { SearchViewModel(get(), get(), get(), get()) }
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import de.christinecoenen.code.zapp.app.mediathek.api.request.MediathekChannel
import de.christinecoenen.code.zapp.app.mediathek.api.request.QueryRequest
import de.christinecoenen.code.zapp.app.mediathek.api.result.QueryInfoResult
import de.christinecoenen.code.zapp.app.mediathek.ui.list.adapter.UiModel
import de.christinecoenen.code.zapp.app.settings.repository.SettingsRepository
import de.christinecoenen.code.zapp.models.search.Comparison
import de.christinecoenen.code.zapp.models.search.DurationQuery
import de.christinecoenen.code.zapp.models.search.DurationQuerySet
Expand All @@ -40,6 +41,7 @@ import timber.log.Timber
class SearchViewModel(
private val searchRepository: SearchRepository,
private val mediathekRepository: MediathekRepository,
private val settingsRepository: SettingsRepository,
private val mediathekApi: IMediathekApiService
) : ViewModel() {

Expand Down Expand Up @@ -218,8 +220,10 @@ class SearchViewModel(
_submittedChannels.tryEmit(_channels.value)
_submittedDurationQueries.tryEmit(_durationQueries.value)

viewModelScope.launch {
searchRepository.saveQuery(_searchQuery.value)
if (settingsRepository.searchHistory) {
viewModelScope.launch {
searchRepository.saveQuery(_searchQuery.value)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class SettingsRepository(context: Context) {

val meteredNetworkStreamQuality: StreamQualityBucket
@SuppressLint("DefaultLocale")
get() = preferences.getString(context.getString(R.string.pref_key_stream_quality_over_metered_network), null).let { quality ->
get() = preferences.getString(
context.getString(R.string.pref_key_stream_quality_over_metered_network),
null
).let { quality ->
if (quality == null) {
StreamQualityBucket.DISABLED
} else {
Expand All @@ -34,7 +37,10 @@ class SettingsRepository(context: Context) {
}

val downloadOverUnmeteredNetworkOnly: Boolean
get() = preferences.getBoolean(context.getString(R.string.pref_key_download_over_unmetered_network_only), true)
get() = preferences.getBoolean(
context.getString(R.string.pref_key_download_over_unmetered_network_only),
true
)

var isPlayerZoomed: Boolean
get() = preferences.getBoolean(context.getString(R.string.pref_key_player_zoomed), false)
Expand All @@ -59,7 +65,10 @@ class SettingsRepository(context: Context) {
}

val downloadToSdCard: Boolean
get() = preferences.getBoolean(context.getString(R.string.pref_key_download_to_sd_card), true)
get() = preferences.getBoolean(
context.getString(R.string.pref_key_download_to_sd_card),
true
)

val dynamicColors: Boolean
get() = preferences.getBoolean(context.getString(R.string.pref_key_dynamic_colors), false)
Expand All @@ -71,21 +80,32 @@ class SettingsRepository(context: Context) {
}

val startFragment: Int
get() = when (preferences.getString(context.getString(R.string.pref_key_start_tab), "live")) {
get() = when (preferences.getString(
context.getString(R.string.pref_key_start_tab),
"live"
)) {
"mediathek" -> R.id.mediathekListFragment
"personal" -> R.id.personalFragment
else -> R.id.channelListFragment
}

val searchHistory: Boolean
get() = preferences.getBoolean(
context.getString(R.string.pref_key_search_history),
true
)

fun prefValueToUiMode(prefSetting: String?): Int {
val defaultMode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM else AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY

return when (prefSetting) {
"light" ->
AppCompatDelegate.MODE_NIGHT_NO

"dark" ->
AppCompatDelegate.MODE_NIGHT_YES

else ->
defaultMode
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/raw-en/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v-next
* Add option to disable search history (thanks to Bnyro)

# 9.0.0-beta1
* Fixed bug where download buttons were shows when no download available
* Prepared Zapp for Android 15
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/raw/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v-next
* Möglichkeit hinzugefügt, den Suchverlauf auszuschalten (danke an Bnyro)

# 9.0.0-beta1
* Fehler behoben, bei dem Download-Buttons bei Sendungen ohne Downloads angezeigt wurden
* Zapp für Android 15 vorbereitet
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@
<string name="pref_dynamic_colors">Dynamic colors</string>
<string name="pref_dynamic_colors_summary">Choose accent colors based on the wallpaper.</string>

<string name="pref_detail_search_history_title">Search history</string>
<string name="pref_detail_search_history_summary">Remember the most recent search queries.</string>

<!-- notifications -->
<string name="notification_channel_name_background_playback">Background player</string>
<string name="notification_channel_name_download_progress">Download progress</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/donottranslate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<string name="pref_key_shortcuts">pref_shortcuts</string>
<string name="pref_key_sleep_timer_delay">pref_key_sleep_timer_delay_millis</string>
<string name="pref_key_player_zoomed">pref_key_player_zoomed</string>
<string name="pref_key_search_history">pref_key_search_history</string>
<string name="pref_key_download_to_sd_card">pref_key_download_to_sd_card</string>
<string name="pref_key_start_tab">pref_key_start_tab</string>

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@
<string name="pref_dynamic_colors">Dynamische Farben</string>
<string name="pref_dynamic_colors_summary">Wähle Akzentfarben basierend auf dem Geräte-Hintergrund.</string>

<string name="pref_detail_search_history_title">Suchverlauf</string>
<string name="pref_detail_search_history_summary">Speichere die letzten Suchanfragen.</string>

<!-- notifications -->
<string name="notification_channel_name_background_playback">Hintergrund-Videoplayer</string>
<string name="notification_channel_name_download_progress">Download Fortschritt</string>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@
android:icon="@drawable/ic_outline_save_24"
android:title="@string/pref_header_data">

<SwitchPreferenceCompat
android:defaultValue="true"
android:key="@string/pref_key_search_history"
android:title="@string/pref_detail_search_history_title"
android:summary="@string/pref_detail_search_history_summary" />

<SwitchPreferenceCompat
android:defaultValue="true"
android:key="@string/pref_key_download_to_sd_card"
Expand Down
Loading