From f60cce54ea60cd368406a4b0df67d887c0e0c6af Mon Sep 17 00:00:00 2001 From: Vincent Nagel Date: Sun, 12 Apr 2020 15:13:04 -0500 Subject: [PATCH] rename setting to "YouTube restricted mode" --- .../java/org/schabi/newpipe/DebugApp.java | 2 +- app/src/main/java/org/schabi/newpipe/App.java | 2 +- .../org/schabi/newpipe/DownloaderImpl.java | 10 +++++----- .../schabi/newpipe/fragments/MainFragment.java | 18 +++++++++--------- .../settings/ContentSettingsFragment.java | 8 ++++---- app/src/main/res/values/settings_keys.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- app/src/main/res/xml/content_settings.xml | 4 ++-- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/src/debug/java/org/schabi/newpipe/DebugApp.java b/app/src/debug/java/org/schabi/newpipe/DebugApp.java index 1dc6cd03b..8eb1a1f7d 100644 --- a/app/src/debug/java/org/schabi/newpipe/DebugApp.java +++ b/app/src/debug/java/org/schabi/newpipe/DebugApp.java @@ -43,7 +43,7 @@ public class DebugApp extends App { DownloaderImpl downloader = DownloaderImpl.init(new OkHttpClient.Builder() .addNetworkInterceptor(new StethoInterceptor())); setCookiesToDownloader(downloader); - downloader.updateRestrictedModeCookies(getApplicationContext()); + downloader.updateYoutubeRestrictedModeCookies(getApplicationContext()); return downloader; } diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index 77cfcf0f5..8a4ed0607 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -137,7 +137,7 @@ public class App extends Application { getApplicationContext()); final String key = getApplicationContext().getString(R.string.recaptcha_cookies_key); downloader.setCookie(ReCaptchaActivity.RECAPTCHA_COOKIES_KEY, prefs.getString(key, "")); - downloader.updateRestrictedModeCookies(getApplicationContext()); + downloader.updateYoutubeRestrictedModeCookies(getApplicationContext()); } private void configureRxJavaErrorHandler() { diff --git a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java index 66292e38c..95d3c2b7c 100644 --- a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java +++ b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java @@ -158,16 +158,16 @@ public final class DownloaderImpl extends Downloader { mCookies.remove(key); } - public void updateRestrictedModeCookies(final Context context) { + public void updateYoutubeRestrictedModeCookies(final Context context) { String restrictedModeEnabledKey = - context.getString(R.string.restricted_mode_enabled); + context.getString(R.string.youtube_restricted_mode_enabled); boolean restrictedModeEnabled = PreferenceManager.getDefaultSharedPreferences(context) .getBoolean(restrictedModeEnabledKey, false); - updateRestrictedModeCookies(restrictedModeEnabled); + updateYoutubeRestrictedModeCookies(restrictedModeEnabled); } - public void updateRestrictedModeCookies(final boolean restrictedModeEnabled) { - if (restrictedModeEnabled) { + public void updateYoutubeRestrictedModeCookies(final boolean youtubeRestrictedModeEnabled) { + if (youtubeRestrictedModeEnabled) { setCookie(YOUTUBE_RESTRICTED_MODE_COOKIE_KEY, YOUTUBE_RESTRICTED_MODE_COOKIE); } else { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java index 50ed6b024..000318ae2 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java @@ -46,8 +46,8 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte private boolean hasTabsChanged = false; - private boolean previousRestrictedModeEnabled; - private String restrictedModeEnabledKey; + private boolean previousYoutubeRestrictedModeEnabled; + private String youtubeRestrictedModeEnabledKey; /*////////////////////////////////////////////////////////////////////////// // Fragment's LifeCycle @@ -70,10 +70,10 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte } }); - restrictedModeEnabledKey = getString(R.string.restricted_mode_enabled); - previousRestrictedModeEnabled = + youtubeRestrictedModeEnabledKey = getString(R.string.youtube_restricted_mode_enabled); + previousYoutubeRestrictedModeEnabled = PreferenceManager.getDefaultSharedPreferences(getContext()) - .getBoolean(restrictedModeEnabledKey, false); + .getBoolean(youtubeRestrictedModeEnabledKey, false); } @Override @@ -100,11 +100,11 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte public void onResume() { super.onResume(); - boolean restrictedModeEnabled = + boolean youtubeRestrictedModeEnabled = PreferenceManager.getDefaultSharedPreferences(getContext()) - .getBoolean(restrictedModeEnabledKey, false); - if (previousRestrictedModeEnabled != restrictedModeEnabled) { - previousRestrictedModeEnabled = restrictedModeEnabled; + .getBoolean(youtubeRestrictedModeEnabledKey, false); + if (previousYoutubeRestrictedModeEnabled != youtubeRestrictedModeEnabled) { + previousYoutubeRestrictedModeEnabled = youtubeRestrictedModeEnabled; setupTabs(); } else if (hasTabsChanged) { setupTabs(); diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index e577d2ac8..b0bb30aa7 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -58,7 +58,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { private File newpipeSettings; private String thumbnailLoadToggleKey; - private String restrictedModeEnabledKey; + private String youtubeRestrictedModeEnabledKey; private Localization initialSelectedLocalization; private ContentCountry initialSelectedContentCountry; @@ -68,7 +68,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { public void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); 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 .getPreferredLocalization(requireContext()); @@ -90,10 +90,10 @@ public class ContentSettingsFragment extends BasePreferenceFragment { Toast.LENGTH_SHORT).show(); } - if (preference.getKey().equals(restrictedModeEnabledKey)) { + if (preference.getKey().equals(youtubeRestrictedModeEnabledKey)) { Context context = getContext(); if (context != null) { - DownloaderImpl.getInstance().updateRestrictedModeCookies(context); + DownloaderImpl.getInstance().updateYoutubeRestrictedModeCookies(context); } else { Log.w(TAG, "onPreferenceTreeClick: null context"); } diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 0a0d2c70a..5d0073540 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -170,7 +170,7 @@ peertube_instance_list content_country show_age_restricted_content - restricted_mode_enabled + youtube_restricted_mode_enabled use_tor enable_search_history enable_watch_history diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 125d411c2..974acf4f2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -137,7 +137,7 @@ Content Age restricted content Show age restricted video. Future changes are possible from the settings. - Restricted mode + YouTube restricted mode This video is age restricted.\n\nIf you want to view it, enable \"Age restricted content\" in the settings. Live Downloads diff --git a/app/src/main/res/xml/content_settings.xml b/app/src/main/res/xml/content_settings.xml index e90520229..bf9c3d115 100644 --- a/app/src/main/res/xml/content_settings.xml +++ b/app/src/main/res/xml/content_settings.xml @@ -54,8 +54,8 @@ + android:key="@string/youtube_restricted_mode_enabled" + android:title="@string/youtube_restricted_mode_enabled_title"/>