ageRestrictedContent first draft

Cookie updated whenever ageRestrictedContent setting is changed or
service is changed. Right now there is only a cookie for youtube, but
cookies for other services could be added in the future.

Problems with this approach: Even when the service is set to youtube,
the downloader doesn't only request youtube urls e.g. it also sends
reqeusts to i.ytimg.com, suggestqueries.google.com, and yt3.ggpht.com.
The ageRestrictedContent cookie is not normally sent when sending
requests to these other urls, so doing so might have unknown effects.
This commit is contained in:
Vincent Nagel 2020-03-15 16:53:29 -05:00
parent fc1fc6842b
commit de4d6037d3
7 changed files with 92 additions and 11 deletions

View file

@ -2,6 +2,7 @@ package org.schabi.newpipe.settings;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
@ -17,6 +18,7 @@ import androidx.preference.Preference;
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.extractor.NewPipe;
@ -56,6 +58,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
private File newpipeSettings;
private String thumbnailLoadToggleKey;
private String showAgeRestrictedContentKey;
private Localization initialSelectedLocalization;
private ContentCountry initialSelectedContentCountry;
@ -65,6 +68,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
public void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
thumbnailLoadToggleKey = getString(R.string.download_thumbnail_key);
showAgeRestrictedContentKey = getString(R.string.show_age_restricted_content);
initialSelectedLocalization = org.schabi.newpipe.util.Localization
.getPreferredLocalization(requireContext());
@ -86,6 +90,13 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
Toast.LENGTH_SHORT).show();
}
if (preference.getKey().equals(showAgeRestrictedContentKey)) {
Context context = getContext();
if(context != null){
DownloaderImpl.getInstance().updateAgeRestrictedContentCookies(context);
}
}
return super.onPreferenceTreeClick(preference);
}