|
7 | 7 | import android.content.Intent; |
8 | 8 | import android.content.SharedPreferences; |
9 | 9 | import android.os.Bundle; |
10 | | -import androidx.preference.PreferenceManager; |
11 | 10 | import android.util.Log; |
12 | 11 | import android.widget.Toast; |
13 | 12 |
|
14 | 13 | import androidx.annotation.NonNull; |
15 | 14 | import androidx.annotation.Nullable; |
16 | 15 | import androidx.preference.Preference; |
| 16 | +import androidx.preference.PreferenceManager; |
17 | 17 |
|
18 | 18 | import com.nononsenseapps.filepicker.Utils; |
19 | 19 | import com.nostra13.universalimageloader.core.ImageLoader; |
20 | 20 |
|
21 | 21 | import org.schabi.newpipe.DownloaderImpl; |
22 | 22 | import org.schabi.newpipe.NewPipeDatabase; |
23 | 23 | import org.schabi.newpipe.R; |
| 24 | +import org.schabi.newpipe.ReCaptchaActivity; |
24 | 25 | import org.schabi.newpipe.extractor.NewPipe; |
25 | 26 | import org.schabi.newpipe.extractor.localization.ContentCountry; |
26 | 27 | import org.schabi.newpipe.extractor.localization.Localization; |
@@ -75,6 +76,22 @@ public void onCreate(@Nullable final Bundle savedInstanceState) { |
75 | 76 | .getPreferredContentCountry(requireContext()); |
76 | 77 | initialLanguage = PreferenceManager |
77 | 78 | .getDefaultSharedPreferences(requireContext()).getString("app_language_key", "en"); |
| 79 | + |
| 80 | + final Preference clearCookiePref = findPreference(getString(R.string.clear_cookie_key)); |
| 81 | + |
| 82 | + clearCookiePref.setOnPreferenceClickListener(preference -> { |
| 83 | + defaultPreferences.edit() |
| 84 | + .putString(getString(R.string.recaptcha_cookies_key), "").apply(); |
| 85 | + DownloaderImpl.getInstance().setCookie(ReCaptchaActivity.RECAPTCHA_COOKIES_KEY, ""); |
| 86 | + Toast.makeText(getActivity(), R.string.recaptcha_cookies_cleared, |
| 87 | + Toast.LENGTH_SHORT).show(); |
| 88 | + clearCookiePref.setVisible(false); |
| 89 | + return true; |
| 90 | + }); |
| 91 | + |
| 92 | + if (defaultPreferences.getString(getString(R.string.recaptcha_cookies_key), "").isEmpty()) { |
| 93 | + clearCookiePref.setVisible(false); |
| 94 | + } |
78 | 95 | } |
79 | 96 |
|
80 | 97 | @Override |
|
0 commit comments