Skip to content

Commit 22db417

Browse files
committed
Moved reset-reCAPTCHA-cookie to cache tab and made it read-only
so that the search works as expected
1 parent 8fc935b commit 22db417

4 files changed

Lines changed: 24 additions & 23 deletions

File tree

app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.schabi.newpipe.NewPipeDatabase;
2525
import org.schabi.newpipe.R;
2626
import org.schabi.newpipe.error.ErrorUtil;
27-
import org.schabi.newpipe.error.ReCaptchaActivity;
2827
import org.schabi.newpipe.extractor.NewPipe;
2928
import org.schabi.newpipe.extractor.localization.ContentCountry;
3029
import org.schabi.newpipe.extractor.localization.Localization;
@@ -105,21 +104,6 @@ ZIP_MIME_TYPE, getImportExportDataUri()),
105104
.getPreferredContentCountry(requireContext());
106105
initialLanguage = defaultPreferences.getString(getString(R.string.app_language_key), "en");
107106

108-
final Preference clearCookiePref = requirePreference(R.string.clear_cookie_key);
109-
clearCookiePref.setOnPreferenceClickListener(preference -> {
110-
defaultPreferences.edit()
111-
.putString(getString(R.string.recaptcha_cookies_key), "").apply();
112-
DownloaderImpl.getInstance().setCookie(ReCaptchaActivity.RECAPTCHA_COOKIES_KEY, "");
113-
Toast.makeText(getActivity(), R.string.recaptcha_cookies_cleared,
114-
Toast.LENGTH_SHORT).show();
115-
clearCookiePref.setVisible(false);
116-
return true;
117-
});
118-
119-
if (defaultPreferences.getString(getString(R.string.recaptcha_cookies_key), "").isEmpty()) {
120-
clearCookiePref.setVisible(false);
121-
}
122-
123107
findPreference(getString(R.string.download_thumbnail_key)).setOnPreferenceChangeListener(
124108
(preference, newValue) -> {
125109
PicassoHelper.setShouldLoadImages((Boolean) newValue);

app/src/main/java/org/schabi/newpipe/settings/HistorySettingsFragment.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
import androidx.appcompat.app.AlertDialog;
99
import androidx.preference.Preference;
1010

11+
import org.schabi.newpipe.DownloaderImpl;
1112
import org.schabi.newpipe.R;
1213
import org.schabi.newpipe.error.ErrorInfo;
1314
import org.schabi.newpipe.error.ErrorUtil;
15+
import org.schabi.newpipe.error.ReCaptchaActivity;
1416
import org.schabi.newpipe.error.UserAction;
1517
import org.schabi.newpipe.local.history.HistoryRecordManager;
1618
import org.schabi.newpipe.util.InfoCache;
@@ -37,6 +39,21 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro
3739
searchHistoryClearKey = getString(R.string.clear_search_history_key);
3840
recordManager = new HistoryRecordManager(getActivity());
3941
disposables = new CompositeDisposable();
42+
43+
final Preference clearCookiePref = requirePreference(R.string.clear_cookie_key);
44+
clearCookiePref.setOnPreferenceClickListener(preference -> {
45+
defaultPreferences.edit()
46+
.putString(getString(R.string.recaptcha_cookies_key), "").apply();
47+
DownloaderImpl.getInstance().setCookie(ReCaptchaActivity.RECAPTCHA_COOKIES_KEY, "");
48+
Toast.makeText(getActivity(), R.string.recaptcha_cookies_cleared,
49+
Toast.LENGTH_SHORT).show();
50+
clearCookiePref.setEnabled(false);
51+
return true;
52+
});
53+
54+
if (defaultPreferences.getString(getString(R.string.recaptcha_cookies_key), "").isEmpty()) {
55+
clearCookiePref.setEnabled(false);
56+
}
4057
}
4158

4259
@Override

app/src/main/res/xml/content_settings.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,6 @@
128128
app:singleLineTitle="false"
129129
app:iconSpaceReserved="false" />
130130

131-
<Preference
132-
android:key="@string/clear_cookie_key"
133-
android:summary="@string/clear_cookie_summary"
134-
android:title="@string/clear_cookie_title"
135-
app:singleLineTitle="false"
136-
app:iconSpaceReserved="false" />
137-
138131
<PreferenceCategory
139132
android:layout="@layout/settings_category_header_layout"
140133
android:title="@string/settings_category_feed_title"

app/src/main/res/xml/history_settings.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@
7171
app:singleLineTitle="false"
7272
app:iconSpaceReserved="false" />
7373

74+
<Preference
75+
android:key="@string/clear_cookie_key"
76+
android:summary="@string/clear_cookie_summary"
77+
android:title="@string/clear_cookie_title"
78+
app:singleLineTitle="false"
79+
app:iconSpaceReserved="false" />
80+
7481
</PreferenceCategory>
7582

7683
</PreferenceScreen>

0 commit comments

Comments
 (0)