mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-11-14 05:44:55 +00:00
renamed to "restricted mode"
This commit is contained in:
parent
5a193d50f6
commit
63087a4311
@ -43,7 +43,7 @@ public class DebugApp extends App {
|
|||||||
DownloaderImpl downloader = DownloaderImpl.init(new OkHttpClient.Builder()
|
DownloaderImpl downloader = DownloaderImpl.init(new OkHttpClient.Builder()
|
||||||
.addNetworkInterceptor(new StethoInterceptor()));
|
.addNetworkInterceptor(new StethoInterceptor()));
|
||||||
setCookiesToDownloader(downloader);
|
setCookiesToDownloader(downloader);
|
||||||
downloader.updateAgeRestrictedContentCookies(getApplicationContext());
|
downloader.updateRestrictedModeCookies(getApplicationContext());
|
||||||
return downloader;
|
return downloader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ public class App extends Application {
|
|||||||
getApplicationContext());
|
getApplicationContext());
|
||||||
final String key = getApplicationContext().getString(R.string.recaptcha_cookies_key);
|
final String key = getApplicationContext().getString(R.string.recaptcha_cookies_key);
|
||||||
downloader.setCookie(ReCaptchaActivity.RECAPTCHA_COOKIES_KEY, prefs.getString(key, ""));
|
downloader.setCookie(ReCaptchaActivity.RECAPTCHA_COOKIES_KEY, prefs.getString(key, ""));
|
||||||
downloader.updateAgeRestrictedContentCookies(getApplicationContext());
|
downloader.updateRestrictedModeCookies(getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureRxJavaErrorHandler() {
|
private void configureRxJavaErrorHandler() {
|
||||||
|
@ -44,10 +44,9 @@ import static org.schabi.newpipe.MainActivity.DEBUG;
|
|||||||
public final class DownloaderImpl extends Downloader {
|
public final class DownloaderImpl extends Downloader {
|
||||||
public static final String USER_AGENT
|
public static final String USER_AGENT
|
||||||
= "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Firefox/68.0";
|
= "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Firefox/68.0";
|
||||||
|
public static final String YOUTUBE_RESTRICTED_MODE_COOKIE_KEY
|
||||||
public static final String YOUTUBE_AGE_RESTRICTED_CONTENT_COOKIE_KEY =
|
= "youtube_restricted_mode_key";
|
||||||
"youtube_age_restricted_content_cookie_key";
|
public static final String YOUTUBE_RESTRICTED_MODE_COOKIE = "PREF=f2=8000000";
|
||||||
public static final String YOUTUBE_AGE_RESTRICTED_CONTENT_COOKIE = "PREF=f2=8000000";
|
|
||||||
public static final String YOUTUBE_DOMAIN = "youtube.com";
|
public static final String YOUTUBE_DOMAIN = "youtube.com";
|
||||||
|
|
||||||
private static DownloaderImpl instance;
|
private static DownloaderImpl instance;
|
||||||
@ -134,7 +133,7 @@ public final class DownloaderImpl extends Downloader {
|
|||||||
public String getCookies(final String url) {
|
public String getCookies(final String url) {
|
||||||
List<String> resultCookies = new ArrayList<>();
|
List<String> resultCookies = new ArrayList<>();
|
||||||
if (url.contains(YOUTUBE_DOMAIN)) {
|
if (url.contains(YOUTUBE_DOMAIN)) {
|
||||||
String youtubeCookie = getCookie(YOUTUBE_AGE_RESTRICTED_CONTENT_COOKIE_KEY);
|
String youtubeCookie = getCookie(YOUTUBE_RESTRICTED_MODE_COOKIE_KEY);
|
||||||
if (youtubeCookie != null) {
|
if (youtubeCookie != null) {
|
||||||
resultCookies.add(youtubeCookie);
|
resultCookies.add(youtubeCookie);
|
||||||
}
|
}
|
||||||
@ -159,20 +158,20 @@ public final class DownloaderImpl extends Downloader {
|
|||||||
mCookies.remove(key);
|
mCookies.remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateAgeRestrictedContentCookies(final Context context) {
|
public void updateRestrictedModeCookies(final Context context) {
|
||||||
String showAgeRestrictedContentKey =
|
String restrictedModeEnabledKey =
|
||||||
context.getString(R.string.show_age_restricted_content);
|
context.getString(R.string.restricted_mode_enabled);
|
||||||
boolean showAgeRestrictedContent = PreferenceManager.getDefaultSharedPreferences(context)
|
boolean restrictedModeEnabled = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
.getBoolean(showAgeRestrictedContentKey, false);
|
.getBoolean(restrictedModeEnabledKey, false);
|
||||||
updateAgeRestrictedContentCookies(showAgeRestrictedContent);
|
updateRestrictedModeCookies(restrictedModeEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateAgeRestrictedContentCookies(final boolean showAgeRestrictedContent) {
|
public void updateRestrictedModeCookies(final boolean restrictedModeEnabled) {
|
||||||
if (!showAgeRestrictedContent) {
|
if (restrictedModeEnabled) {
|
||||||
setCookie(YOUTUBE_AGE_RESTRICTED_CONTENT_COOKIE_KEY,
|
setCookie(YOUTUBE_RESTRICTED_MODE_COOKIE_KEY,
|
||||||
YOUTUBE_AGE_RESTRICTED_CONTENT_COOKIE);
|
YOUTUBE_RESTRICTED_MODE_COOKIE);
|
||||||
} else {
|
} else {
|
||||||
removeCookie(YOUTUBE_AGE_RESTRICTED_CONTENT_COOKIE_KEY);
|
removeCookie(YOUTUBE_RESTRICTED_MODE_COOKIE_KEY);
|
||||||
}
|
}
|
||||||
InfoCache.getInstance().clearCache();
|
InfoCache.getInstance().clearCache();
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,8 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
|||||||
|
|
||||||
private boolean hasTabsChanged = false;
|
private boolean hasTabsChanged = false;
|
||||||
|
|
||||||
private boolean previousShowAgeRestrictedContent;
|
private boolean previousRestrictedModeEnabled;
|
||||||
private String showAgeRestrictedContentKey;
|
private String restrictedModeEnabledKey;
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Fragment's LifeCycle
|
// Fragment's LifeCycle
|
||||||
@ -70,10 +70,10 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
showAgeRestrictedContentKey = getString(R.string.show_age_restricted_content);
|
restrictedModeEnabledKey = getString(R.string.restricted_mode_enabled);
|
||||||
previousShowAgeRestrictedContent =
|
previousRestrictedModeEnabled =
|
||||||
PreferenceManager.getDefaultSharedPreferences(getContext())
|
PreferenceManager.getDefaultSharedPreferences(getContext())
|
||||||
.getBoolean(showAgeRestrictedContentKey, false);
|
.getBoolean(restrictedModeEnabledKey, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,11 +100,11 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
boolean showAgeRestrictedContent =
|
boolean restrictedModeEnabled =
|
||||||
PreferenceManager.getDefaultSharedPreferences(getContext())
|
PreferenceManager.getDefaultSharedPreferences(getContext())
|
||||||
.getBoolean(showAgeRestrictedContentKey, false);
|
.getBoolean(restrictedModeEnabledKey, false);
|
||||||
if (previousShowAgeRestrictedContent != showAgeRestrictedContent) {
|
if (previousRestrictedModeEnabled != restrictedModeEnabled) {
|
||||||
previousShowAgeRestrictedContent = showAgeRestrictedContent;
|
previousRestrictedModeEnabled = restrictedModeEnabled;
|
||||||
setupTabs();
|
setupTabs();
|
||||||
} else if (hasTabsChanged) {
|
} else if (hasTabsChanged) {
|
||||||
setupTabs();
|
setupTabs();
|
||||||
|
@ -58,7 +58,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||||||
private File newpipeSettings;
|
private File newpipeSettings;
|
||||||
|
|
||||||
private String thumbnailLoadToggleKey;
|
private String thumbnailLoadToggleKey;
|
||||||
private String showAgeRestrictedContentKey;
|
private String restrictedModeEnabledKey;
|
||||||
|
|
||||||
private Localization initialSelectedLocalization;
|
private Localization initialSelectedLocalization;
|
||||||
private ContentCountry initialSelectedContentCountry;
|
private ContentCountry initialSelectedContentCountry;
|
||||||
@ -68,7 +68,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
thumbnailLoadToggleKey = getString(R.string.download_thumbnail_key);
|
thumbnailLoadToggleKey = getString(R.string.download_thumbnail_key);
|
||||||
showAgeRestrictedContentKey = getString(R.string.show_age_restricted_content);
|
restrictedModeEnabledKey = getString(R.string.restricted_mode_enabled);
|
||||||
|
|
||||||
initialSelectedLocalization = org.schabi.newpipe.util.Localization
|
initialSelectedLocalization = org.schabi.newpipe.util.Localization
|
||||||
.getPreferredLocalization(requireContext());
|
.getPreferredLocalization(requireContext());
|
||||||
@ -90,10 +90,10 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preference.getKey().equals(showAgeRestrictedContentKey)) {
|
if (preference.getKey().equals(restrictedModeEnabledKey)) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
DownloaderImpl.getInstance().updateAgeRestrictedContentCookies(context);
|
DownloaderImpl.getInstance().updateRestrictedModeCookies(context);
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "onPreferenceTreeClick: null context");
|
Log.w(TAG, "onPreferenceTreeClick: null context");
|
||||||
}
|
}
|
||||||
|
@ -170,6 +170,7 @@
|
|||||||
<string name="peertube_instance_list_key" translatable="false">peertube_instance_list</string>
|
<string name="peertube_instance_list_key" translatable="false">peertube_instance_list</string>
|
||||||
<string name="content_country_key" translatable="false">content_country</string>
|
<string name="content_country_key" translatable="false">content_country</string>
|
||||||
<string name="show_age_restricted_content" translatable="false">show_age_restricted_content</string>
|
<string name="show_age_restricted_content" translatable="false">show_age_restricted_content</string>
|
||||||
|
<string name="restricted_mode_enabled" translatable="false">restricted_mode_enabled</string>
|
||||||
<string name="use_tor_key" translatable="false">use_tor</string>
|
<string name="use_tor_key" translatable="false">use_tor</string>
|
||||||
<string name="enable_search_history_key" translatable="false">enable_search_history</string>
|
<string name="enable_search_history_key" translatable="false">enable_search_history</string>
|
||||||
<string name="enable_watch_history_key" translatable="false">enable_watch_history</string>
|
<string name="enable_watch_history_key" translatable="false">enable_watch_history</string>
|
||||||
|
@ -137,6 +137,7 @@
|
|||||||
<string name="content">Content</string>
|
<string name="content">Content</string>
|
||||||
<string name="show_age_restricted_content_title">Age restricted content</string>
|
<string name="show_age_restricted_content_title">Age restricted content</string>
|
||||||
<string name="video_is_age_restricted">Show age restricted video. Future changes are possible from the settings.</string>
|
<string name="video_is_age_restricted">Show age restricted video. Future changes are possible from the settings.</string>
|
||||||
|
<string name="restricted_mode_enabled_title">Restricted mode</string>
|
||||||
<string name="restricted_video">This video is age restricted.\n\nIf you want to view it, enable \"Age restricted content\" in the settings.</string>
|
<string name="restricted_video">This video is age restricted.\n\nIf you want to view it, enable \"Age restricted content\" in the settings.</string>
|
||||||
<string name="duration_live">Live</string>
|
<string name="duration_live">Live</string>
|
||||||
<string name="downloads">Downloads</string>
|
<string name="downloads">Downloads</string>
|
||||||
|
@ -51,6 +51,12 @@
|
|||||||
android:key="@string/show_age_restricted_content"
|
android:key="@string/show_age_restricted_content"
|
||||||
android:title="@string/show_age_restricted_content_title"/>
|
android:title="@string/show_age_restricted_content_title"/>
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/restricted_mode_enabled"
|
||||||
|
android:title="@string/restricted_mode_enabled_title"/>
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
|
Loading…
Reference in New Issue
Block a user