From 22db4175f37205f650df7a67f3017705404eda2b Mon Sep 17 00:00:00 2001
From: litetex <40789489+litetex@users.noreply.github.com>
Date: Fri, 24 Dec 2021 21:37:04 +0100
Subject: [PATCH] Moved reset-reCAPTCHA-cookie to cache tab and made it
read-only
so that the search works as expected
---
.../settings/ContentSettingsFragment.java | 16 ----------------
.../settings/HistorySettingsFragment.java | 17 +++++++++++++++++
app/src/main/res/xml/content_settings.xml | 7 -------
app/src/main/res/xml/history_settings.xml | 7 +++++++
4 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java
index d79ea0cd5..47458ad3f 100644
--- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java
+++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java
@@ -24,7 +24,6 @@ import org.schabi.newpipe.DownloaderImpl;
import org.schabi.newpipe.NewPipeDatabase;
import org.schabi.newpipe.R;
import org.schabi.newpipe.error.ErrorUtil;
-import org.schabi.newpipe.error.ReCaptchaActivity;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.localization.ContentCountry;
import org.schabi.newpipe.extractor.localization.Localization;
@@ -105,21 +104,6 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
.getPreferredContentCountry(requireContext());
initialLanguage = defaultPreferences.getString(getString(R.string.app_language_key), "en");
- final Preference clearCookiePref = requirePreference(R.string.clear_cookie_key);
- clearCookiePref.setOnPreferenceClickListener(preference -> {
- defaultPreferences.edit()
- .putString(getString(R.string.recaptcha_cookies_key), "").apply();
- DownloaderImpl.getInstance().setCookie(ReCaptchaActivity.RECAPTCHA_COOKIES_KEY, "");
- Toast.makeText(getActivity(), R.string.recaptcha_cookies_cleared,
- Toast.LENGTH_SHORT).show();
- clearCookiePref.setVisible(false);
- return true;
- });
-
- if (defaultPreferences.getString(getString(R.string.recaptcha_cookies_key), "").isEmpty()) {
- clearCookiePref.setVisible(false);
- }
-
findPreference(getString(R.string.download_thumbnail_key)).setOnPreferenceChangeListener(
(preference, newValue) -> {
PicassoHelper.setShouldLoadImages((Boolean) newValue);
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 868618110..86e651e2b 100644
--- a/app/src/main/java/org/schabi/newpipe/settings/HistorySettingsFragment.java
+++ b/app/src/main/java/org/schabi/newpipe/settings/HistorySettingsFragment.java
@@ -8,9 +8,11 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
+import org.schabi.newpipe.DownloaderImpl;
import org.schabi.newpipe.R;
import org.schabi.newpipe.error.ErrorInfo;
import org.schabi.newpipe.error.ErrorUtil;
+import org.schabi.newpipe.error.ReCaptchaActivity;
import org.schabi.newpipe.error.UserAction;
import org.schabi.newpipe.local.history.HistoryRecordManager;
import org.schabi.newpipe.util.InfoCache;
@@ -37,6 +39,21 @@ public class HistorySettingsFragment extends BasePreferenceFragment {
searchHistoryClearKey = getString(R.string.clear_search_history_key);
recordManager = new HistoryRecordManager(getActivity());
disposables = new CompositeDisposable();
+
+ final Preference clearCookiePref = requirePreference(R.string.clear_cookie_key);
+ clearCookiePref.setOnPreferenceClickListener(preference -> {
+ defaultPreferences.edit()
+ .putString(getString(R.string.recaptcha_cookies_key), "").apply();
+ DownloaderImpl.getInstance().setCookie(ReCaptchaActivity.RECAPTCHA_COOKIES_KEY, "");
+ Toast.makeText(getActivity(), R.string.recaptcha_cookies_cleared,
+ Toast.LENGTH_SHORT).show();
+ clearCookiePref.setEnabled(false);
+ return true;
+ });
+
+ if (defaultPreferences.getString(getString(R.string.recaptcha_cookies_key), "").isEmpty()) {
+ clearCookiePref.setEnabled(false);
+ }
}
@Override
diff --git a/app/src/main/res/xml/content_settings.xml b/app/src/main/res/xml/content_settings.xml
index 23b782ffd..e754b3a30 100644
--- a/app/src/main/res/xml/content_settings.xml
+++ b/app/src/main/res/xml/content_settings.xml
@@ -128,13 +128,6 @@
app:singleLineTitle="false"
app:iconSpaceReserved="false" />
-
-
+
+