Add button in settings to clear reCAPTCHA cookies
This commit is contained in:
parent
613070d39f
commit
2c23678fb9
|
@ -7,13 +7,13 @@ import android.content.DialogInterface;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.nononsenseapps.filepicker.Utils;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
@ -21,6 +21,7 @@ import com.nostra13.universalimageloader.core.ImageLoader;
|
|||
import org.schabi.newpipe.DownloaderImpl;
|
||||
import org.schabi.newpipe.NewPipeDatabase;
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.ReCaptchaActivity;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.localization.ContentCountry;
|
||||
import org.schabi.newpipe.extractor.localization.Localization;
|
||||
|
@ -75,6 +76,22 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
.getPreferredContentCountry(requireContext());
|
||||
initialLanguage = PreferenceManager
|
||||
.getDefaultSharedPreferences(requireContext()).getString("app_language_key", "en");
|
||||
|
||||
final Preference clearCookiePref = findPreference(getString(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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -246,6 +246,8 @@
|
|||
<string name="import_data" translatable="false">import_data</string>
|
||||
<string name="export_data" translatable="false">export_data</string>
|
||||
|
||||
<string name="clear_cookie_key" translatable="false">clear_cookie</string>
|
||||
|
||||
<string name="download_thumbnail_key" translatable="false">download_thumbnail_key</string>
|
||||
|
||||
<string name="metadata_cache_wipe_key" translatable="false">cache_wipe_key</string>
|
||||
|
|
|
@ -197,8 +197,11 @@
|
|||
<string name="switch_to_main">Switch to Main</string>
|
||||
<string name="import_data_title">Import database</string>
|
||||
<string name="export_data_title">Export database</string>
|
||||
<string name="clear_cookie_title">Clear reCAPTCHA cookies</string>
|
||||
<string name="recaptcha_cookies_cleared">reCAPTCHA cookies have been cleared</string>
|
||||
<string name="import_data_summary">Overrides your current history and subscriptions</string>
|
||||
<string name="export_data_summary">Export history, subscriptions and playlists</string>
|
||||
<string name="clear_cookie_summary">Clear cookies that NewPipe stores when you solve a reCAPTCHA</string>
|
||||
<string name="clear_views_history_title">Clear watch history</string>
|
||||
<string name="clear_views_history_summary">Deletes the history of played streams and the playback positions</string>
|
||||
<string name="delete_view_history_alert">Delete entire watch history?</string>
|
||||
|
|
|
@ -97,6 +97,12 @@
|
|||
android:title="@string/export_data_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<Preference
|
||||
android:key="@string/clear_cookie_key"
|
||||
android:summary="@string/clear_cookie_summary"
|
||||
android:title="@string/clear_cookie_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:layout="@layout/settings_category_header_layout"
|
||||
android:title="@string/settings_category_feed_title">
|
||||
|
|
Loading…
Reference in New Issue