1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-25 01:20:34 +00:00

rename setting to "YouTube restricted mode"

This commit is contained in:
Vincent Nagel 2020-04-12 15:13:04 -05:00
parent 63087a4311
commit f60cce54ea
8 changed files with 24 additions and 24 deletions

View File

@ -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.updateRestrictedModeCookies(getApplicationContext()); downloader.updateYoutubeRestrictedModeCookies(getApplicationContext());
return downloader; return downloader;
} }

View File

@ -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.updateRestrictedModeCookies(getApplicationContext()); downloader.updateYoutubeRestrictedModeCookies(getApplicationContext());
} }
private void configureRxJavaErrorHandler() { private void configureRxJavaErrorHandler() {

View File

@ -158,16 +158,16 @@ public final class DownloaderImpl extends Downloader {
mCookies.remove(key); mCookies.remove(key);
} }
public void updateRestrictedModeCookies(final Context context) { public void updateYoutubeRestrictedModeCookies(final Context context) {
String restrictedModeEnabledKey = String restrictedModeEnabledKey =
context.getString(R.string.restricted_mode_enabled); context.getString(R.string.youtube_restricted_mode_enabled);
boolean restrictedModeEnabled = PreferenceManager.getDefaultSharedPreferences(context) boolean restrictedModeEnabled = PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(restrictedModeEnabledKey, false); .getBoolean(restrictedModeEnabledKey, false);
updateRestrictedModeCookies(restrictedModeEnabled); updateYoutubeRestrictedModeCookies(restrictedModeEnabled);
} }
public void updateRestrictedModeCookies(final boolean restrictedModeEnabled) { public void updateYoutubeRestrictedModeCookies(final boolean youtubeRestrictedModeEnabled) {
if (restrictedModeEnabled) { if (youtubeRestrictedModeEnabled) {
setCookie(YOUTUBE_RESTRICTED_MODE_COOKIE_KEY, setCookie(YOUTUBE_RESTRICTED_MODE_COOKIE_KEY,
YOUTUBE_RESTRICTED_MODE_COOKIE); YOUTUBE_RESTRICTED_MODE_COOKIE);
} else { } else {

View File

@ -46,8 +46,8 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
private boolean hasTabsChanged = false; private boolean hasTabsChanged = false;
private boolean previousRestrictedModeEnabled; private boolean previousYoutubeRestrictedModeEnabled;
private String restrictedModeEnabledKey; private String youtubeRestrictedModeEnabledKey;
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
// Fragment's LifeCycle // Fragment's LifeCycle
@ -70,10 +70,10 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
} }
}); });
restrictedModeEnabledKey = getString(R.string.restricted_mode_enabled); youtubeRestrictedModeEnabledKey = getString(R.string.youtube_restricted_mode_enabled);
previousRestrictedModeEnabled = previousYoutubeRestrictedModeEnabled =
PreferenceManager.getDefaultSharedPreferences(getContext()) PreferenceManager.getDefaultSharedPreferences(getContext())
.getBoolean(restrictedModeEnabledKey, false); .getBoolean(youtubeRestrictedModeEnabledKey, 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 restrictedModeEnabled = boolean youtubeRestrictedModeEnabled =
PreferenceManager.getDefaultSharedPreferences(getContext()) PreferenceManager.getDefaultSharedPreferences(getContext())
.getBoolean(restrictedModeEnabledKey, false); .getBoolean(youtubeRestrictedModeEnabledKey, false);
if (previousRestrictedModeEnabled != restrictedModeEnabled) { if (previousYoutubeRestrictedModeEnabled != youtubeRestrictedModeEnabled) {
previousRestrictedModeEnabled = restrictedModeEnabled; previousYoutubeRestrictedModeEnabled = youtubeRestrictedModeEnabled;
setupTabs(); setupTabs();
} else if (hasTabsChanged) { } else if (hasTabsChanged) {
setupTabs(); setupTabs();

View File

@ -58,7 +58,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
private File newpipeSettings; private File newpipeSettings;
private String thumbnailLoadToggleKey; private String thumbnailLoadToggleKey;
private String restrictedModeEnabledKey; private String youtubeRestrictedModeEnabledKey;
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);
restrictedModeEnabledKey = getString(R.string.restricted_mode_enabled); youtubeRestrictedModeEnabledKey = getString(R.string.youtube_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(restrictedModeEnabledKey)) { if (preference.getKey().equals(youtubeRestrictedModeEnabledKey)) {
Context context = getContext(); Context context = getContext();
if (context != null) { if (context != null) {
DownloaderImpl.getInstance().updateRestrictedModeCookies(context); DownloaderImpl.getInstance().updateYoutubeRestrictedModeCookies(context);
} else { } else {
Log.w(TAG, "onPreferenceTreeClick: null context"); Log.w(TAG, "onPreferenceTreeClick: null context");
} }

View File

@ -170,7 +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="youtube_restricted_mode_enabled" translatable="false">youtube_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>

View File

@ -137,7 +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="youtube_restricted_mode_enabled_title">YouTube 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>

View File

@ -54,8 +54,8 @@
<SwitchPreference <SwitchPreference
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
android:defaultValue="false" android:defaultValue="false"
android:key="@string/restricted_mode_enabled" android:key="@string/youtube_restricted_mode_enabled"
android:title="@string/restricted_mode_enabled_title"/> android:title="@string/youtube_restricted_mode_enabled_title"/>
<SwitchPreference <SwitchPreference
app:iconSpaceReserved="false" app:iconSpaceReserved="false"