refactor: deduplicate code

This commit is contained in:
oSumAtrIX 2022-06-05 07:33:46 +02:00
parent 94c2c9d6e6
commit 468c72e2a5
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
2 changed files with 29 additions and 28 deletions

View File

@ -1,77 +1,82 @@
package fi.razerman.youtube.litho; package fi.razerman.youtube.litho;
import android.util.Log; import android.util.Log;
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application; import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import fi.razerman.youtube.Helpers.SharedPrefs;
import fi.razerman.youtube.XGlobals;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
/* loaded from: classes6.dex */ import fi.razerman.youtube.Helpers.SharedPrefs;
import fi.razerman.youtube.XGlobals;
public class LithoAdRemoval { public class LithoAdRemoval {
private static final byte[] endRelatedPageAd = {112, 97, 103, 101, 97, 100}; private static final byte[] endRelatedPageAd = {112, 97, 103, 101, 97, 100};
private static final char[] hexArray = "0123456789ABCDEF".toCharArray();
private static boolean getBoolean(String key, boolean _default) {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), key, _default);
}
private static boolean isExperimentalInfoPanelRemoval() { private static boolean isExperimentalInfoPanelRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_info_panel", true); return getBoolean("experimental_info_panel", true);
} }
private static boolean isExperimentalMedicalPanelRemoval() { private static boolean isExperimentalMedicalPanelRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_medical_panel", true); return getBoolean("experimental_medical_panel", true);
} }
private static boolean isExperimentalEmergencyBoxRemoval() { private static boolean isExperimentalEmergencyBoxRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_emergency_box", true); return getBoolean("experimental_emergency_box", true);
} }
public static boolean isExperimentalAdRemoval() { public static boolean isExperimentalAdRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_ad_removal", true); return getBoolean("experimental_ad_removal", true);
} }
public static boolean isExperimentalMerchandiseRemoval() { public static boolean isExperimentalMerchandiseRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_merchandise", true); return getBoolean("experimental_merchandise", true);
} }
public static boolean isExperimentalCommunityPostRemoval() { public static boolean isExperimentalCommunityPostRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_community_posts", false); return getBoolean("experimental_community_posts", false);
} }
public static boolean isExperimentalMovieUpsellRemoval() { public static boolean isExperimentalMovieUpsellRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_movie_upsell", false); return getBoolean("experimental_movie_upsell", false);
} }
public static boolean isExperimentalCompactBannerRemoval() { public static boolean isExperimentalCompactBannerRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_compact_banner", false); return getBoolean("experimental_compact_banner", false);
} }
public static boolean isExperimentalPaidContentRemoval() { public static boolean isExperimentalPaidContentRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_paid_content", true); return getBoolean("experimental_paid_content", true);
} }
public static boolean isExperimentalCommentsRemoval() { public static boolean isExperimentalCommentsRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_comments", false); return getBoolean("experimental_comments", false);
} }
public static boolean isExperimentalCompactMovieRemoval() { public static boolean isExperimentalCompactMovieRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_compact_movie", false); return getBoolean("experimental_compact_movie", false);
} }
public static boolean isExperimentalHorizontalMovieShelfRemoval() { public static boolean isExperimentalHorizontalMovieShelfRemoval() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_horizontal_movie_shelf", false); return getBoolean("experimental_horizontal_movie_shelf", false);
} }
public static boolean isInFeedSurvey() { public static boolean isInFeedSurvey() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_in_feed_survey", false); return getBoolean("experimental_in_feed_survey", false);
} }
public static boolean isShortsShelf() { public static boolean isShortsShelf() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_shorts_shelf", true); return getBoolean("experimental_shorts_shelf", true);
} }
public static boolean isCommunityGuidelines() { public static boolean isCommunityGuidelines() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "experimental_community_guidelines", true); return getBoolean("experimental_community_guidelines", true);
} }
public static boolean containsAd(String value, ByteBuffer buffer) { public static boolean containsAd(String value, ByteBuffer buffer) {
@ -181,12 +186,9 @@ public class LithoAdRemoval {
} }
private static String bytesToHex(byte[] bytes) { private static String bytesToHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2]; StringBuilder builder = new StringBuilder(bytes.length * 2);
for (int j = 0; j < bytes.length; j++) { for (byte b : bytes)
int v = bytes[j] & 255; builder.append(String.format("%02x", b));
hexChars[j * 2] = hexArray[v >>> 4]; return builder.toString();
hexChars[(j * 2) + 1] = hexArray[v & 15];
}
return new String(hexChars);
} }
} }

View File

@ -6,7 +6,6 @@ import java.util.Objects;
import fi.razerman.youtube.Helpers.SharedPrefs; import fi.razerman.youtube.Helpers.SharedPrefs;
/* loaded from: classes6.dex */
public class BooleanPreferences { public class BooleanPreferences {
public static boolean isTapSeekingEnabled() { public static boolean isTapSeekingEnabled() {
return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "xfile_enable_tap_seeking", true); return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "xfile_enable_tap_seeking", true);