mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Unlimited search history preference
This commit is contained in:
parent
7c08838d1c
commit
e8b2d8d02c
@ -97,6 +97,7 @@ object PreferenceKeys {
|
|||||||
const val AUTO_FULLSCREEN_SHORTS = "auto_fullscreen_shorts"
|
const val AUTO_FULLSCREEN_SHORTS = "auto_fullscreen_shorts"
|
||||||
const val PLAY_AUTOMATICALLY = "play_automatically"
|
const val PLAY_AUTOMATICALLY = "play_automatically"
|
||||||
const val FULLSCREEN_GESTURES = "fullscreen_gestures"
|
const val FULLSCREEN_GESTURES = "fullscreen_gestures"
|
||||||
|
const val UNLIMITED_SEARCH_HISTORY = "unlimited_search_history"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Background mode
|
* Background mode
|
||||||
|
@ -40,10 +40,14 @@ object DatabaseHelper {
|
|||||||
suspend fun addToSearchHistory(searchHistoryItem: SearchHistoryItem) {
|
suspend fun addToSearchHistory(searchHistoryItem: SearchHistoryItem) {
|
||||||
Database.searchHistoryDao().insert(searchHistoryItem)
|
Database.searchHistoryDao().insert(searchHistoryItem)
|
||||||
|
|
||||||
|
if (PreferenceHelper.getBoolean(PreferenceKeys.UNLIMITED_SEARCH_HISTORY, false)) return
|
||||||
|
|
||||||
// delete the first watch history entry if the limit is reached
|
// delete the first watch history entry if the limit is reached
|
||||||
val searchHistory = Database.searchHistoryDao().getAll()
|
val searchHistory = Database.searchHistoryDao().getAll().toMutableList()
|
||||||
if (searchHistory.size > MAX_SEARCH_HISTORY_SIZE) {
|
|
||||||
|
while (searchHistory.size > MAX_SEARCH_HISTORY_SIZE) {
|
||||||
Database.searchHistoryDao().delete(searchHistory.first())
|
Database.searchHistoryDao().delete(searchHistory.first())
|
||||||
|
searchHistory.removeFirst()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,6 +416,7 @@
|
|||||||
<string name="background_channel_description">Shows a notification with buttons to control the audio player.</string>
|
<string name="background_channel_description">Shows a notification with buttons to control the audio player.</string>
|
||||||
<string name="push_channel_name">Notification Worker</string>
|
<string name="push_channel_name">Notification Worker</string>
|
||||||
<string name="push_channel_description">Shows a notification when new streams are available.</string>
|
<string name="push_channel_description">Shows a notification when new streams are available.</string>
|
||||||
|
<string name="unlimited_search_history">Unlimited search history</string>
|
||||||
<!-- Relative time formatting strings (remove when setting the minSdk to 24) -->
|
<!-- Relative time formatting strings (remove when setting the minSdk to 24) -->
|
||||||
<plurals name="years_ago">
|
<plurals name="years_ago">
|
||||||
<item quantity="one">%d year ago</item>
|
<item quantity="one">%d year ago</item>
|
||||||
|
@ -11,6 +11,13 @@
|
|||||||
app:key="search_history_toggle"
|
app:key="search_history_toggle"
|
||||||
app:title="@string/search_history" />
|
app:title="@string/search_history" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:dependency="search_history_toggle"
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:icon="@drawable/ic_search"
|
||||||
|
app:key="unlimited_search_history"
|
||||||
|
app:title="@string/unlimited_search_history" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:icon="@drawable/ic_trash"
|
android:icon="@drawable/ic_trash"
|
||||||
app:key="clear_search_history"
|
app:key="clear_search_history"
|
||||||
|
Loading…
Reference in New Issue
Block a user