From 694236236670fdb0c05a2a0250501b17ab75b297 Mon Sep 17 00:00:00 2001
From: Jace <54625750+Jacekun@users.noreply.github.com>
Date: Sun, 16 Oct 2022 16:35:15 +0800
Subject: [PATCH] Move button out of settings and into an 'X' button on
Homepage
---
.../cloudstream3/ui/home/HomeFragment.kt | 36 +++++++++++++++++--
.../ui/settings/SettingsGeneral.kt | 32 -----------------
app/src/main/res/layout/fragment_home.xml | 10 ++++++
app/src/main/res/values/strings.xml | 1 -
app/src/main/res/xml/settins_general.xml | 6 ----
5 files changed, 43 insertions(+), 42 deletions(-)
diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt
index 0d571b76..70f70af3 100644
--- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt
+++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt
@@ -49,18 +49,17 @@ import com.lagradost.cloudstream3.ui.search.*
import com.lagradost.cloudstream3.ui.search.SearchHelper.handleSearchClickCallback
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
+import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.isRecyclerScrollable
import com.lagradost.cloudstream3.utils.AppUtils.loadSearchResult
import com.lagradost.cloudstream3.utils.AppUtils.setMaxViewPoolSize
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
import com.lagradost.cloudstream3.utils.DataStore.getKey
import com.lagradost.cloudstream3.utils.DataStore.setKey
-import com.lagradost.cloudstream3.utils.DataStoreHelper
import com.lagradost.cloudstream3.utils.DataStoreHelper.deleteAllBookmarkedData
import com.lagradost.cloudstream3.utils.DataStoreHelper.deleteAllResumeStateIds
import com.lagradost.cloudstream3.utils.DataStoreHelper.removeLastWatched
import com.lagradost.cloudstream3.utils.DataStoreHelper.setResultWatchState
-import com.lagradost.cloudstream3.utils.Event
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showOptionSelectStringRes
import com.lagradost.cloudstream3.utils.SubtitleHelper.getFlagFromIso
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
@@ -70,7 +69,6 @@ import com.lagradost.cloudstream3.utils.UIHelper.getSpanCount
import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIconsAndNoStringRes
import com.lagradost.cloudstream3.utils.UIHelper.setImage
import com.lagradost.cloudstream3.utils.UIHelper.setImageBlur
-import com.lagradost.cloudstream3.utils.USER_SELECTED_HOMEPAGE_API
import com.lagradost.cloudstream3.widget.CenterZoomLayoutManager
import kotlinx.android.synthetic.main.fragment_home.*
import kotlinx.android.synthetic.main.fragment_home.home_api_fab
@@ -522,6 +520,38 @@ class HomeFragment : Fragment() {
activity.loadSearchResult(listHomepageItems.random())
}
}
+ home_clear_watching?.setOnClickListener {
+ 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 {
+ deleteAllResumeStateIds()
+ homeViewModel.loadResumeWatching()
+ } 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.setPositiveButton("OK"
+ ) { newdialog, newwhich -> // Do nothing but close the dialog
+ newdialog.dismiss()
+ }
+ newBuilder.show()
+ }
+ builder.setNegativeButton(getString(R.string.no)
+ ) { dialog, which -> // Do nothing but close the dialog
+ dialog.dismiss()
+ }
+ builder.show()
+ }
//Load value for toggling Random button. Hide at startup
context?.let {
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 07b4def8..57074e74 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,8 +29,6 @@ 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
@@ -333,36 +331,6 @@ 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/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml
index 4abdef0b..d7c49f05 100644
--- a/app/src/main/res/layout/fragment_home.xml
+++ b/app/src/main/res/layout/fragment_home.xml
@@ -395,6 +395,16 @@
style="@style/WatchHeaderText"
android:text="@string/continue_watching" />
+
+
filter_sub_lang_key
pref_filter_search_quality_key
enable_nsfw_on_providers_key
- key_clear_watching
%d %s | %s
diff --git a/app/src/main/res/xml/settins_general.xml b/app/src/main/res/xml/settins_general.xml
index 2b08f056..ae87c611 100644
--- a/app/src/main/res/xml/settins_general.xml
+++ b/app/src/main/res/xml/settins_general.xml
@@ -23,12 +23,6 @@
android:title="@string/download_path_pref"
android:icon="@drawable/netflix_download" />
-
-