mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
max history size
This commit is contained in:
parent
e78e7daf0a
commit
a859ae101d
@ -142,6 +142,12 @@ object PreferenceHelper {
|
|||||||
|
|
||||||
watchHistory += watchHistoryItem
|
watchHistory += watchHistoryItem
|
||||||
|
|
||||||
|
// remove oldest item when the watch history is longer than the pref
|
||||||
|
val maxWatchHistorySize = getString(PreferenceKeys.WATCH_HISTORY_SIZE, "unlimited")
|
||||||
|
if (maxWatchHistorySize != "unlimited" && watchHistory.size > maxWatchHistorySize.toInt()) {
|
||||||
|
watchHistory.removeAt(0)
|
||||||
|
}
|
||||||
|
|
||||||
val json = mapper.writeValueAsString(watchHistory)
|
val json = mapper.writeValueAsString(watchHistory)
|
||||||
editor.putString("watch_history", json).apply()
|
editor.putString("watch_history", json).apply()
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,11 @@ object PreferenceKeys {
|
|||||||
const val CLEAR_WATCH_POSITIONS = "clear_watch_positions"
|
const val CLEAR_WATCH_POSITIONS = "clear_watch_positions"
|
||||||
const val SHARE_WITH_TIME_CODE = "share_with_time_code"
|
const val SHARE_WITH_TIME_CODE = "share_with_time_code"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* History
|
||||||
|
*/
|
||||||
|
const val WATCH_HISTORY_SIZE = "watch_history_size"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error logs
|
* Error logs
|
||||||
*/
|
*/
|
||||||
|
@ -649,6 +649,7 @@
|
|||||||
<item>1.25x</item>
|
<item>1.25x</item>
|
||||||
<item>1.5x</item>
|
<item>1.5x</item>
|
||||||
<item>2x</item>
|
<item>2x</item>
|
||||||
|
<item>3x</item>
|
||||||
<item>4x</item>
|
<item>4x</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="playbackSpeedValues">
|
<string-array name="playbackSpeedValues">
|
||||||
@ -659,6 +660,7 @@
|
|||||||
<item>1.25</item>
|
<item>1.25</item>
|
||||||
<item>1.5</item>
|
<item>1.5</item>
|
||||||
<item>2</item>
|
<item>2</item>
|
||||||
|
<item>3</item>
|
||||||
<item>4</item>
|
<item>4</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
@ -808,4 +810,22 @@
|
|||||||
<item>metered</item>
|
<item>metered</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="historySize">
|
||||||
|
<item>20</item>
|
||||||
|
<item>50</item>
|
||||||
|
<item>100</item>
|
||||||
|
<item>150</item>
|
||||||
|
<item>200</item>
|
||||||
|
<item>@string/unlimited</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="historySizeValues">
|
||||||
|
<item>20</item>
|
||||||
|
<item>50</item>
|
||||||
|
<item>100</item>
|
||||||
|
<item>150</item>
|
||||||
|
<item>200</item>
|
||||||
|
<item>unlimited</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -294,4 +294,6 @@
|
|||||||
<string name="export_subscriptions">Export Subscriptions</string>
|
<string name="export_subscriptions">Export Subscriptions</string>
|
||||||
<string name="skip_buttons">Skip buttons</string>
|
<string name="skip_buttons">Skip buttons</string>
|
||||||
<string name="skip_buttons_summary">Show buttons to skip to the next or previous video.</string>
|
<string name="skip_buttons_summary">Show buttons to skip to the next or previous video.</string>
|
||||||
|
<string name="history_size">Maximum history size</string>
|
||||||
|
<string name="unlimited">Unlimited</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -27,6 +27,15 @@
|
|||||||
app:key="watch_history_toggle"
|
app:key="watch_history_toggle"
|
||||||
app:title="@string/watch_history" />
|
app:title="@string/watch_history" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="unlimited"
|
||||||
|
android:entries="@array/historySize"
|
||||||
|
android:entryValues="@array/historySizeValues"
|
||||||
|
android:icon="@drawable/ic_list"
|
||||||
|
app:key="watch_history_size"
|
||||||
|
app:title="@string/history_size"
|
||||||
|
app:useSimpleSummaryProvider="true" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:icon="@drawable/ic_trash"
|
android:icon="@drawable/ic_trash"
|
||||||
app:key="clear_watch_history"
|
app:key="clear_watch_history"
|
||||||
|
Loading…
Reference in New Issue
Block a user