From 08a6e999b9ca7ee71783f0111f981bda7144f899 Mon Sep 17 00:00:00 2001 From: Vincent Nagel Date: Sat, 11 Apr 2020 16:21:52 -0500 Subject: [PATCH] fix checkstyle errors --- .../org/schabi/newpipe/DownloaderImpl.java | 22 +++++++++++-------- .../newpipe/fragments/MainFragment.java | 8 +++++-- .../org/schabi/newpipe/util/CookieUtils.java | 13 +++-------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java index 9f1722fb3..1abdeb504 100644 --- a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java +++ b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java @@ -45,7 +45,8 @@ public final class DownloaderImpl extends Downloader { public static final String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Firefox/68.0"; - public static final String YOUTUBE_AGE_RESTRICTED_CONTENT_COOKIE_KEY = "youtube_age_restricted_content_cookie_key"; + public static final String YOUTUBE_AGE_RESTRICTED_CONTENT_COOKIE_KEY = + "youtube_age_restricted_content_cookie_key"; public static final String YOUTUBE_AGE_RESTRICTED_CONTENT_COOKIE = "PREF=f2=8000000"; public static final String YOUTUBE_DOMAIN = "youtube.com"; @@ -146,27 +147,30 @@ public final class DownloaderImpl extends Downloader { return CookieUtils.concatCookies(resultCookies); } - public String getCookie(final String key){ + public String getCookie(final String key) { return mCookies.get(key); } - public void setCookie(final String key, final String cookie){ + public void setCookie(final String key, final String cookie) { mCookies.put(key, cookie); } - public void removeCookie(final String key){ + public void removeCookie(final String key) { mCookies.remove(key); } - public void updateAgeRestrictedContentCookies(final Context context){ - String showAgeRestrictedContentKey = context.getString(R.string.show_age_restricted_content); - boolean showAgeRestrictedContent = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(showAgeRestrictedContentKey, false); + public void updateAgeRestrictedContentCookies(final Context context) { + String showAgeRestrictedContentKey = + context.getString(R.string.show_age_restricted_content); + boolean showAgeRestrictedContent = PreferenceManager.getDefaultSharedPreferences(context) + .getBoolean(showAgeRestrictedContentKey, false); updateAgeRestrictedContentCookies(showAgeRestrictedContent); } - public void updateAgeRestrictedContentCookies(boolean showAgeRestrictedContent) { + public void updateAgeRestrictedContentCookies(final boolean showAgeRestrictedContent) { if (!showAgeRestrictedContent) { - setCookie(YOUTUBE_AGE_RESTRICTED_CONTENT_COOKIE_KEY, YOUTUBE_AGE_RESTRICTED_CONTENT_COOKIE); + setCookie(YOUTUBE_AGE_RESTRICTED_CONTENT_COOKIE_KEY, + YOUTUBE_AGE_RESTRICTED_CONTENT_COOKIE); } else { removeCookie(YOUTUBE_AGE_RESTRICTED_CONTENT_COOKIE_KEY); } 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 929d573b0..9cb21f4e7 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java @@ -71,7 +71,9 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte }); showAgeRestrictedContentKey = getString(R.string.show_age_restricted_content); - previousShowAgeRestrictedContent = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean(showAgeRestrictedContentKey, false); + previousShowAgeRestrictedContent = + PreferenceManager.getDefaultSharedPreferences(getContext()) + .getBoolean(showAgeRestrictedContentKey, false); } @Override @@ -98,7 +100,9 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte public void onResume() { super.onResume(); - boolean showAgeRestrictedContent = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean(showAgeRestrictedContentKey, false); + boolean showAgeRestrictedContent = + PreferenceManager.getDefaultSharedPreferences(getContext()) + .getBoolean(showAgeRestrictedContentKey, false); if (previousShowAgeRestrictedContent != showAgeRestrictedContent) { previousShowAgeRestrictedContent = showAgeRestrictedContent; setupTabs(); diff --git a/app/src/main/java/org/schabi/newpipe/util/CookieUtils.java b/app/src/main/java/org/schabi/newpipe/util/CookieUtils.java index e10b83df6..4575e7017 100644 --- a/app/src/main/java/org/schabi/newpipe/util/CookieUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/CookieUtils.java @@ -1,24 +1,17 @@ package org.schabi.newpipe.util; -import android.content.Context; -import android.preference.PreferenceManager; - import org.jsoup.helper.StringUtil; -import org.schabi.newpipe.DownloaderImpl; -import org.schabi.newpipe.R; import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; import java.util.HashSet; -import java.util.Map; import java.util.Set; -public class CookieUtils { +public final class CookieUtils { private CookieUtils() { } - public static String concatCookies(Collection cookieStrings) { + public static String concatCookies(final Collection cookieStrings) { Set cookieSet = new HashSet<>(); for (String cookies : cookieStrings) { cookieSet.addAll(splitCookies(cookies)); @@ -26,7 +19,7 @@ public class CookieUtils { return StringUtil.join(cookieSet, "; ").trim(); } - public static Set splitCookies(String cookies) { + public static Set splitCookies(final String cookies) { return new HashSet<>(Arrays.asList(cookies.split("; *"))); } }