add toggle

This commit is contained in:
Bnyro 2022-07-01 18:11:12 +02:00
parent 458af7d7d4
commit e7e4cf7c07
4 changed files with 29 additions and 2 deletions

View File

@ -455,6 +455,9 @@ class PlayerFragment : Fragment() {
if (!relatedStreamsEnabled) toggleComments() if (!relatedStreamsEnabled) toggleComments()
// prepare for autoplay // prepare for autoplay
initAutoPlay() initAutoPlay()
val watchHistoryEnabled =
PreferenceHelper.getBoolean(requireContext(), "Watch_history_toggle", true)
if (watchHistoryEnabled)
PreferenceHelper.addToWatchHistory(requireContext(), videoId!!, response) PreferenceHelper.addToWatchHistory(requireContext(), videoId!!, response)
} }
} }

View File

@ -18,12 +18,20 @@ class AdvancedSettings : PreferenceFragmentCompat() {
val settingsActivity = activity as SettingsActivity val settingsActivity = activity as SettingsActivity
settingsActivity.binding.topBarTextView.text = getString(R.string.advanced) settingsActivity.binding.topBarTextView.text = getString(R.string.advanced)
// clear search history
val clearHistory = findPreference<Preference>("clear_history") val clearHistory = findPreference<Preference>("clear_history")
clearHistory?.setOnPreferenceClickListener { clearHistory?.setOnPreferenceClickListener {
PreferenceHelper.removePreference(requireContext(), "search_history") PreferenceHelper.removePreference(requireContext(), "search_history")
true true
} }
// clear watch history
val clearWatchHistory = findPreference<Preference>("clear_watch_history")
clearWatchHistory?.setOnPreferenceClickListener {
PreferenceHelper.removePreference(requireContext(), "watch_history")
true
}
val resetSettings = findPreference<Preference>("reset_settings") val resetSettings = findPreference<Preference>("reset_settings")
resetSettings?.setOnPreferenceClickListener { resetSettings?.setOnPreferenceClickListener {
showResetDialog() showResetDialog()

View File

@ -79,7 +79,7 @@
<string name="okay">OK</string> <string name="okay">OK</string>
<string name="history">History</string> <string name="history">History</string>
<string name="search_history">Search History</string> <string name="search_history">Search History</string>
<string name="clear_history">Clear History</string> <string name="clear_history">Clear search history</string>
<string name="music_songs">YT Music Songs</string> <string name="music_songs">YT Music Songs</string>
<string name="music_videos">YT Music Videos</string> <string name="music_videos">YT Music Videos</string>
<string name="music_albums">YT Music Albums</string> <string name="music_albums">YT Music Albums</string>
@ -207,4 +207,5 @@
<string name="deleteAccount_summary">Delete your Piped account</string> <string name="deleteAccount_summary">Delete your Piped account</string>
<string name="account">Account</string> <string name="account">Account</string>
<string name="restore">Restore</string> <string name="restore">Restore</string>
<string name="watch_history">Watch history</string>
</resources> </resources>

View File

@ -46,6 +46,21 @@
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory app:title="@string/watch_history">
<SwitchPreference
android:defaultValue="true"
android:icon="@drawable/ic_history_filled"
app:key="watch_history_toggle"
app:title="@string/watch_history" />
<Preference
android:icon="@drawable/ic_trash"
app:key="clear_watch_history"
app:title="@string/clear_history" />
</PreferenceCategory>
<PreferenceCategory> <PreferenceCategory>
<Preference <Preference