diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsGeneral.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsGeneral.kt index 57074e74..07b4def8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsGeneral.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsGeneral.kt @@ -29,6 +29,8 @@ import com.lagradost.cloudstream3.ui.EasterEggMonke import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setPaddingBottom import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar +import com.lagradost.cloudstream3.utils.* +import com.lagradost.cloudstream3.utils.DataStore.removeKeys import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showMultiDialog @@ -331,6 +333,36 @@ class SettingsGeneral : PreferenceFragmentCompat() { return@setOnPreferenceClickListener true } + getPref(R.string.key_clear_watching)?.setOnPreferenceClickListener { + val builder: AlertDialog.Builder = + AlertDialog.Builder(it.context, R.style.AlertDialogCustom) + builder.setTitle(R.string.clear_watching_pref) + builder.setMessage(R.string.clear_watching_prompt) + builder.setPositiveButton(getString(R.string.yes) + ) { dialog, which -> // Clear Watch History data + var doneClearMessage = R.string.clear_watching_done + try { + it.context.removeKeys("${DataStoreHelper.currentAccount}/$RESULT_RESUME_WATCHING") + it.context.removeKeys("${DataStoreHelper.currentAccount}/$RESULT_RESUME_WATCHING_OLD") + } catch (e: Exception) { + logError(e) + doneClearMessage = R.string.clear_watching_error + } + dialog.dismiss() + + val newBuilder = AlertDialog.Builder(it.context, R.style.AlertDialogCustom) + newBuilder.setTitle(R.string.clear_watching_pref) + newBuilder.setMessage(doneClearMessage) + newBuilder.show() + } + builder.setNegativeButton(getString(R.string.no) + ) { dialog, which -> // Do nothing but close the dialog + dialog.dismiss() + } + builder.show() + return@setOnPreferenceClickListener true + } + try { SettingsFragment.beneneCount = settingsManager.getInt(getString(R.string.benene_count), 0) diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/DataStoreHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/DataStoreHelper.kt index 46c29e3f..44c88e54 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/DataStoreHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/DataStoreHelper.kt @@ -69,7 +69,7 @@ object DataStoreHelper { @JsonProperty("posterHeaders") override var posterHeaders: Map? = null, ) : SearchResponse - private var currentAccount: String = "0" //TODO ACCOUNT IMPLEMENTATION + var currentAccount: String = "0" //TODO ACCOUNT IMPLEMENTATION fun getAllWatchStateIds(): List? { val folder = "$currentAccount/$RESULT_WATCH_STATE" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c3ebd29d..a22f664f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -57,6 +57,7 @@ filter_sub_lang_key pref_filter_search_quality_key enable_nsfw_on_providers_key + key_clear_watching %d %s | %s @@ -413,6 +414,11 @@ Add a clone of an existing site, with a different url Download path + Clear Watch History + Clear \'Continue Watching\' history. + Are you sure you want to clear watch history? + Watch history successfully cleared! + Failed to clear watch history! Nginx server url @@ -501,6 +507,8 @@ Failed to authenticate to %s + Yes + No None Normal All diff --git a/app/src/main/res/xml/settins_general.xml b/app/src/main/res/xml/settins_general.xml index ae87c611..2b08f056 100644 --- a/app/src/main/res/xml/settins_general.xml +++ b/app/src/main/res/xml/settins_general.xml @@ -23,6 +23,12 @@ android:title="@string/download_path_pref" android:icon="@drawable/netflix_download" /> + +