Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
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;

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;
Expand Down Expand Up @@ -75,6 +76,22 @@ public void onCreate(@Nullable final Bundle savedInstanceState) {
.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
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/settings_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/content_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down