diff --git a/app/src/main/java/org/schabi/newpipe/settings/HistorySettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/HistorySettingsFragment.java index cf5425a50..8ff86af05 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/HistorySettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/HistorySettingsFragment.java @@ -19,6 +19,7 @@ import io.reactivex.disposables.Disposable; public class HistorySettingsFragment extends BasePreferenceFragment { private String cacheWipeKey; private String viewsHistoryClearKey; + private String playbackStatesClearKey; private String searchHistoryClearKey; private HistoryRecordManager recordManager; private CompositeDisposable disposables; @@ -28,6 +29,7 @@ public class HistorySettingsFragment extends BasePreferenceFragment { super.onCreate(savedInstanceState); cacheWipeKey = getString(R.string.metadata_cache_wipe_key); viewsHistoryClearKey = getString(R.string.clear_views_history_key); + playbackStatesClearKey = getString(R.string.clear_playback_states_key); searchHistoryClearKey = getString(R.string.clear_search_history_key); recordManager = new HistoryRecordManager(getActivity()); disposables = new CompositeDisposable(); @@ -63,7 +65,7 @@ public class HistorySettingsFragment extends BasePreferenceFragment { ErrorActivity.ErrorInfo.make( UserAction.DELETE_FROM_HISTORY, "none", - "Delete view history", + "Delete playback states", R.string.general_error))); final Disposable onDelete = recordManager.deleteWholeStreamHistory() @@ -101,6 +103,33 @@ public class HistorySettingsFragment extends BasePreferenceFragment { .show(); } + if (preference.getKey().equals(playbackStatesClearKey)) { + new AlertDialog.Builder(getActivity()) + .setTitle(R.string.delete_playback_states_alert) + .setNegativeButton(R.string.cancel, ((dialog, which) -> dialog.dismiss())) + .setPositiveButton(R.string.delete, ((dialog, which) -> { + + final Disposable onDeletePlaybackStates = recordManager.deleteCompelteStreamStateHistory() + .observeOn(AndroidSchedulers.mainThread()) + .subscribe( + howManyDeleted -> Toast.makeText(getActivity(), + R.string.watch_history_states_deleted, + Toast.LENGTH_SHORT).show(), + throwable -> ErrorActivity.reportError(getContext(), + throwable, + SettingsActivity.class, null, + ErrorActivity.ErrorInfo.make( + UserAction.DELETE_FROM_HISTORY, + "none", + "Delete playback states", + R.string.general_error))); + + disposables.add(onDeletePlaybackStates); + })) + .create() + .show(); + } + if (preference.getKey().equals(searchHistoryClearKey)) { new AlertDialog.Builder(getActivity()) .setTitle(R.string.delete_search_history_alert) diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 6c51fbb1c..e3a96f3f5 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -160,6 +160,7 @@ cache_wipe_key clear_play_history + clear_playback_states clear_search_history downloads_storage_ask diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fd7a440bb..1025b504b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -171,9 +171,12 @@ Overrides your current history and subscriptions Export history, subscriptions and playlists Clear watch history - Deletes the history of played streams + Deletes the history of played streams and the playback positions Delete entire watch history? Watch history deleted. + Delete playback positions + Deletes all playback positions + Delete all playback positions? Playback positions deleted. Clear search history Deletes history of search keywords diff --git a/app/src/main/res/xml/history_settings.xml b/app/src/main/res/xml/history_settings.xml index cae2d56c0..81dc195f3 100644 --- a/app/src/main/res/xml/history_settings.xml +++ b/app/src/main/res/xml/history_settings.xml @@ -51,6 +51,12 @@ android:title="@string/clear_views_history_title" app:iconSpaceReserved="false" /> + +