refactor: prepare for settings patch (#80)

This commit is contained in:
TheJeterLP 2022-07-14 18:42:43 +02:00 committed by GitHub
parent ad1e42eb01
commit ac9e239b16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
67 changed files with 698 additions and 905 deletions

View File

@ -1,147 +0,0 @@
package app.revanced.integrations.adremover;
import android.os.Build;
import androidx.annotation.RequiresApi;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.SharedPrefHelper;
public class LithoAdRemoval {
@RequiresApi(api = Build.VERSION_CODES.N)
public static boolean containsAd(String value, ByteBuffer buffer) {
boolean enabled = false;
for (SettingsEnum setting : SettingsEnum.getAdRemovalSettings()) {
if (setting.getBoolean()) {
enabled = true;
break;
}
}
try {
if (value == null || value.isEmpty() || !enabled) return false;
LogHelper.debug(LithoAdRemoval.class, "Searching for AD: " + value);
List<String> blockList = new ArrayList<>();
List<String> bufferBlockList = new ArrayList<>();
if (SettingsEnum.ADREMOVER_AD_REMOVAL_BOOLEAN.getBoolean()) {
blockList.add("_ad");
blockList.add("ad_badge");
blockList.add("ads_video_with_context");
blockList.add("cell_divider");
blockList.add("reels_player_overlay");
blockList.add("shelf_header");
blockList.add("text_search_ad_with_description_first");
blockList.add("watch_metadata_app_promo");
bufferBlockList.add("ad_cpn");
}
if (SettingsEnum.ADREMOVER_SUGGESTED_FOR_YOU_REMOVAL_BOOLEAN.getBoolean()) {
bufferBlockList.add("watch-vrecH");
}
if (SettingsEnum.ADREMOVER_MOVIE_REMOVAL_BOOLEAN.getBoolean()) {
blockList.add("browsy_bar");
blockList.add("compact_movie");
blockList.add("horizontal_movie_shelf");
blockList.add("movie_and_show_upsell_card");
bufferBlockList.add("YouTube Movies");
}
if (containsAny(value, "home_video_with_context", "related_video_with_context") &&
bufferBlockList.stream().anyMatch(StandardCharsets.UTF_8.decode(buffer).toString()::contains)
) return true;
if (SettingsEnum.ADREMOVER_COMMENTS_REMOVAL_BOOLEAN.getBoolean()) {
blockList.add("comments_");
}
if (SettingsEnum.ADREMOVER_COMMUNITY_GUIDELINES_BOOLEAN.getBoolean()) {
blockList.add("community_guidelines");
}
if (SettingsEnum.ADREMOVER_COMPACT_BANNER_REMOVAL_BOOLEAN.getBoolean()) {
blockList.add("compact_banner");
}
if (SettingsEnum.ADREMOVER_EMERGENCY_BOX_REMOVAL_BOOLEAN.getBoolean()) {
blockList.add("emergency_onebox");
}
if (SettingsEnum.ADREMOVER_FEED_SURVEY_REMOVAL_BOOLEAN.getBoolean()) {
blockList.add("in_feed_survey");
}
if (SettingsEnum.ADREMOVER_MEDICAL_PANEL_REMOVAL_BOOLEAN.getBoolean()) {
blockList.add("medical_panel");
}
if (SettingsEnum.ADREMOVER_PAID_CONTECT_REMOVAL_BOOLEAN.getBoolean()) {
blockList.add("paid_content_overlay");
}
if (SettingsEnum.ADREMOVER_COMMUNITY_POSTS_REMOVAL_BOOLEAN.getBoolean()) {
blockList.add("post_base_wrapper");
}
if (SettingsEnum.ADREMOVER_MERCHANDISE_REMOVAL_BOOLEAN.getBoolean()) {
blockList.add("product_carousel");
}
if (SettingsEnum.ADREMOVER_SHORTS_SHELF_BOOLEAN.getBoolean()) {
blockList.add("shorts_shelf");
}
if (SettingsEnum.ADREMOVER_INFO_PANEL_REMOVAL_BOOLEAN.getBoolean()) {
blockList.add("publisher_transparency_panel");
blockList.add("single_item_information_panel");
}
if (SettingsEnum.ADREMOVER_HIDE_SUGGESTIONS_BOOLEAN.getBoolean()) {
blockList.add("horizontal_video_shelf");
}
if (SettingsEnum.ADREMOVER_HIDE_LATEST_POSTS_BOOLEAN.getBoolean()) {
blockList.add("post_shelf");
}
if (containsAny(value,
"home_video_with_context",
"related_video_with_context",
"search_video_with_context",
"menu",
"root",
"-count",
"-space",
"-button"
)) return false;
if (blockList.stream().anyMatch(value::contains)) {
LogHelper.debug(LithoAdRemoval.class, "Blocking ad: " + value);
return true;
}
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
if (value.contains("related_video_with_context")) {
LogHelper.debug(LithoAdRemoval.class, value + " | " + bytesToHex(buffer.array()));
return false;
}
LogHelper.debug(LithoAdRemoval.class, value + " returns false.");
}
return false;
} catch (Exception ex) {
LogHelper.printException(LithoAdRemoval.class, ex.getMessage(), ex);
return false;
}
}
private static boolean containsAny(String value, String... targets) {
for (String string : targets)
if (value.contains(string)) return true;
return false;
}
private static String bytesToHex(byte[] bytes) {
StringBuilder builder = new StringBuilder(bytes.length * 2);
for (byte b : bytes)
builder.append(String.format("%02x", b));
return builder.toString();
}
}

View File

@ -7,6 +7,6 @@ public class AutoRepeatPatch {
//Used by app.revanced.patches.youtube.layout.autorepeat.patch.AutoRepeatPatch
public static boolean shouldAutoRepeat() {
return SettingsEnum.PREFERRED_AUTO_REPEAT_BOOLEAN.getBoolean();
return SettingsEnum.PREFERRED_AUTO_REPEAT.getBoolean();
}
}

View File

@ -7,6 +7,6 @@ public class BrandingWaterMarkPatch {
//Used by: app.revanced.patches.youtube.layout.watermark.patch.HideWatermarkPatch
public static boolean isBrandingWatermarkShown() {
return SettingsEnum.BRANDING_SHOWN_BOOLEAN.getBoolean();
return SettingsEnum.BRANDING_SHOWN.getBoolean();
}
}

View File

@ -0,0 +1,12 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.settings.SettingsEnum;
public class DisableAutoCaptions {
//ToDo: Write Patch for it
public static boolean autoCaptionsEnabled() {
return SettingsEnum.AUTO_CAPTIONS_ENABLED.getBoolean();
}
}

View File

@ -7,15 +7,15 @@ import app.revanced.integrations.settings.SettingsEnum;
public class ForceCodecPatch {
public static String getManufacturer() {
return SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean() ? "samsung" : Build.MANUFACTURER;
return SettingsEnum.CODEC_OVERRIDE.getBoolean() ? "samsung" : Build.MANUFACTURER;
}
public static String getModel() {
return SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean() ? "SM-G920F" : Build.MODEL;
return SettingsEnum.CODEC_OVERRIDE.getBoolean() ? "SM-G920F" : Build.MODEL;
}
public static boolean shouldForceVP9() {
return SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean();
return SettingsEnum.CODEC_OVERRIDE.getBoolean();
}

View File

@ -5,15 +5,147 @@ import android.os.Build;
import androidx.annotation.RequiresApi;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import app.revanced.integrations.adremover.LithoAdRemoval;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
public class GeneralBytecodeAdsPatch {
//Used by app.revanced.patches.youtube.ad.general.bytecode.patch.GeneralBytecodeAdsPatch
@RequiresApi(api = Build.VERSION_CODES.N)
public static boolean containsAd(String value, ByteBuffer buffer) {
return LithoAdRemoval.containsAd(value, buffer);
return containsLithoAd(value, buffer);
}
@RequiresApi(api = Build.VERSION_CODES.N)
private static boolean containsLithoAd(String value, ByteBuffer buffer) {
boolean enabled = false;
for (SettingsEnum setting : SettingsEnum.getAdRemovalSettings()) {
if (setting.getBoolean()) {
enabled = true;
break;
}
}
try {
if (value == null || value.isEmpty() || !enabled) return false;
LogHelper.debug(GeneralBytecodeAdsPatch.class, "Searching for AD: " + value);
List<String> blockList = new ArrayList<>();
List<String> bufferBlockList = new ArrayList<>();
if (SettingsEnum.ADREMOVER_AD_REMOVAL.getBoolean()) {
blockList.add("_ad");
blockList.add("ad_badge");
blockList.add("ads_video_with_context");
blockList.add("cell_divider");
blockList.add("reels_player_overlay");
blockList.add("shelf_header");
blockList.add("text_search_ad_with_description_first");
blockList.add("watch_metadata_app_promo");
bufferBlockList.add("ad_cpn");
}
if (SettingsEnum.ADREMOVER_SUGGESTED_FOR_YOU_REMOVAL.getBoolean()) {
bufferBlockList.add("watch-vrecH");
}
if (SettingsEnum.ADREMOVER_MOVIE_REMOVAL.getBoolean()) {
blockList.add("browsy_bar");
blockList.add("compact_movie");
blockList.add("horizontal_movie_shelf");
blockList.add("movie_and_show_upsell_card");
bufferBlockList.add("YouTube Movies");
}
if (containsAny(value, "home_video_with_context", "related_video_with_context") &&
bufferBlockList.stream().anyMatch(StandardCharsets.UTF_8.decode(buffer).toString()::contains)
) return true;
if (SettingsEnum.ADREMOVER_COMMENTS_REMOVAL.getBoolean()) {
blockList.add("comments_");
}
if (SettingsEnum.ADREMOVER_COMMUNITY_GUIDELINES.getBoolean()) {
blockList.add("community_guidelines");
}
if (SettingsEnum.ADREMOVER_COMPACT_BANNER_REMOVAL.getBoolean()) {
blockList.add("compact_banner");
}
if (SettingsEnum.ADREMOVER_EMERGENCY_BOX_REMOVAL.getBoolean()) {
blockList.add("emergency_onebox");
}
if (SettingsEnum.ADREMOVER_FEED_SURVEY_REMOVAL.getBoolean()) {
blockList.add("in_feed_survey");
}
if (SettingsEnum.ADREMOVER_MEDICAL_PANEL_REMOVAL.getBoolean()) {
blockList.add("medical_panel");
}
if (SettingsEnum.ADREMOVER_PAID_CONTECT_REMOVAL.getBoolean()) {
blockList.add("paid_content_overlay");
}
if (SettingsEnum.ADREMOVER_COMMUNITY_POSTS_REMOVAL.getBoolean()) {
blockList.add("post_base_wrapper");
}
if (SettingsEnum.ADREMOVER_MERCHANDISE_REMOVAL.getBoolean()) {
blockList.add("product_carousel");
}
if (SettingsEnum.ADREMOVER_SHORTS_SHELF.getBoolean()) {
blockList.add("shorts_shelf");
}
if (SettingsEnum.ADREMOVER_INFO_PANEL_REMOVAL.getBoolean()) {
blockList.add("publisher_transparency_panel");
blockList.add("single_item_information_panel");
}
if (SettingsEnum.ADREMOVER_HIDE_SUGGESTIONS.getBoolean()) {
blockList.add("horizontal_video_shelf");
}
if (SettingsEnum.ADREMOVER_HIDE_LATEST_POSTS.getBoolean()) {
blockList.add("post_shelf");
}
if (containsAny(value,
"home_video_with_context",
"related_video_with_context",
"search_video_with_context",
"menu",
"root",
"-count",
"-space",
"-button"
)) return false;
if (blockList.stream().anyMatch(value::contains)) {
LogHelper.debug(GeneralBytecodeAdsPatch.class, "Blocking ad: " + value);
return true;
}
if (SettingsEnum.DEBUG.getBoolean()) {
if (value.contains("related_video_with_context")) {
LogHelper.debug(GeneralBytecodeAdsPatch.class, value + " | " + bytesToHex(buffer.array()));
return false;
}
LogHelper.debug(GeneralBytecodeAdsPatch.class, value + " returns false.");
}
return false;
} catch (Exception ex) {
LogHelper.printException(GeneralBytecodeAdsPatch.class, ex.getMessage(), ex);
return false;
}
}
private static boolean containsAny(String value, String... targets) {
for (String string : targets)
if (value.contains(string)) return true;
return false;
}
private static String bytesToHex(byte[] bytes) {
StringBuilder builder = new StringBuilder(bytes.length * 2);
for (byte b : bytes)
builder.append(String.format("%02x", b));
return builder.toString();
}
}

View File

@ -21,7 +21,7 @@ public class HDRMaxBrightnessPatch {
*/
public static float getHDRBrightness(float original) {
// do nothing if disabled
if (!SettingsEnum.USE_HDR_AUTO_BRIGHTNESS_BOOLEAN.getBoolean()) {
if (!SettingsEnum.USE_HDR_AUTO_BRIGHTNESS.getBoolean()) {
return original;
}

View File

@ -1,11 +1,13 @@
package app.revanced.integrations.patches;
import android.view.View;
import app.revanced.integrations.settings.SettingsEnum;
public class HideCastButtonPatch {
//Used by app.revanced.patches.youtube.layout.castbutton.patch.HideCastButonPatch
public static int getCastButtonOverrideV2(int original) {
return SettingsEnum.CAST_BUTTON_SHOWN_BOOLEAN.getBoolean() ? original : 8;
return SettingsEnum.CAST_BUTTON_SHOWN.getBoolean() ? original : View.GONE;
}
}

View File

@ -10,12 +10,9 @@ public class HideCreateButtonPatch {
//Used by app.revanced.patches.youtube.layout.createbutton.patch.CreateButtonRemoverPatch
public static void hideCreateButton(View view) {
String message = SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Create button: Shown" : "Create button: Hidden";
boolean show = SettingsEnum.CREATE_BUTTON_SHOWN.getBoolean();
String message = show ? "Create button: Shown" : "Create button: Hidden";
LogHelper.debug(HideCreateButtonPatch.class, message);
if (SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
view.setVisibility(View.VISIBLE);
} else {
view.setVisibility(View.GONE);
}
view.setVisibility(show ? View.VISIBLE : View.GONE);
}
}

View File

@ -3,7 +3,6 @@ package app.revanced.integrations.patches;
import android.view.View;
import app.revanced.integrations.adremover.AdRemoverAPI;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.settings.SettingsEnum;
public class HideHomeAdsPatch {
@ -13,7 +12,7 @@ public class HideHomeAdsPatch {
* @param view
*/
public static void HideHomeAds(View view) {
if (!SettingsEnum.HOME_ADS_SHOWN_BOOLEAN.getBoolean()) {
if (!SettingsEnum.HOME_ADS_SHOWN.getBoolean()) {
AdRemoverAPI.HideViewWithLayout1dp(view);
}
}

View File

@ -1,10 +1,12 @@
package app.revanced.integrations.patches;
import android.view.View;
import app.revanced.integrations.settings.SettingsEnum;
public class HideInfoCardSuggestionsPatch {
public static int hideInfoCardSuggestions() {
return SettingsEnum.INFO_CARDS_SHOWN_BOOLEAN.getBoolean() ? 0 : 8;
return SettingsEnum.INFO_CARDS_SHOWN.getBoolean() ? View.VISIBLE : View.GONE;
}
}

View File

@ -3,7 +3,6 @@ package app.revanced.integrations.patches;
import android.view.View;
import app.revanced.integrations.adremover.AdRemoverAPI;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.settings.SettingsEnum;
public class HideReelsPatch {
@ -14,7 +13,7 @@ public class HideReelsPatch {
* @param view
*/
public static void HideReel(View view) {
if (!SettingsEnum.REEL_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
if (!SettingsEnum.REEL_BUTTON_SHOWN.getBoolean()) {
AdRemoverAPI.HideViewWithLayout1dp(view);
}
}

View File

@ -9,14 +9,14 @@ import app.revanced.integrations.utils.LogHelper;
public class HideShortsButtonPatch {
//Todo: Switch BooleanPreferences to Settings class
//Used by app.revanced.patches.youtube.layout.shorts.button.patch.ShortsButtonRemoverPatch
public static void hideShortsButton(View view) {
if (lastPivotTab != null && lastPivotTab.name() == "TAB_SHORTS") {
String message = SettingsEnum.SHORTS_BUTTON_SHOWN_BOOLEAN.getBoolean() ? "Shorts button: shown" : "Shorts button: hidden";
boolean show = SettingsEnum.SHORTS_BUTTON_SHOWN.getBoolean();
String message = show ? "Shorts button: shown" : "Shorts button: hidden";
LogHelper.debug(HideShortsButtonPatch.class, message);
if (!SettingsEnum.SHORTS_BUTTON_SHOWN_BOOLEAN.getBoolean()) {
view.setVisibility(View.GONE);
if (!show) {
view.setVisibility(show ? View.VISIBLE : View.GONE);
}
}
}

View File

@ -9,6 +9,6 @@ public class MiniplayerOverridePatch {
//And https://drive.google.com/file/d/1-QlgSiKzqQ5lHXQnvRUpijk0GH9T1Sn7/view?usp=sharing
// for where it needs to be used.
public static boolean getTabletMiniplayerOverride() {
return SettingsEnum.USE_TABLET_MINIPLAYER_BOOLEAN.getBoolean();
return SettingsEnum.USE_TABLET_MINIPLAYER.getBoolean();
}
}

View File

@ -4,10 +4,9 @@ import app.revanced.integrations.settings.SettingsEnum;
public class NewActionbarPatch {
//ToDo: Write Patch for it.
//See https://drive.google.com/file/d/1Jg2WK9wwSABCiIcqclzhedy3J3RCf3Hn/view?usp=sharing for where it needs to be used.
//Used by app.revanced.patches.youtube.layout.widesearchbar.patch.WideSearchbarPatch
public static boolean getNewActionBar() {
return SettingsEnum.USE_NEW_ACTIONBAR_BOOLEAN.getBoolean();
return SettingsEnum.USE_NEW_ACTIONBAR.getBoolean();
}
}

View File

@ -6,6 +6,6 @@ public class OldStyleQualityPatch {
//Used by app.revanced.patches.youtube.layout.oldqualitylayout.patch.OldQualityLayoutPatch
public static boolean useOldStyleQualitySettings() {
return SettingsEnum.OLD_STYLE_QUALITY_SETTINGS_BOOLEAN.getBoolean();
return SettingsEnum.OLD_STYLE_QUALITY_SETTINGS.getBoolean();
}
}

View File

@ -7,7 +7,7 @@ public class OverrideCodecPatch {
//ToDo: Write Patch for it.
//See https://drive.google.com/file/d/14d2R-5JF97gOZggoobVEVazPWbORbZVp/view?usp=sharing for where it needs to be used.
public static boolean isOverrideCodedUsed() {
return SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getBoolean();
return SettingsEnum.CODEC_OVERRIDE.getBoolean();
}
}

View File

@ -6,7 +6,7 @@ public class SeekbarTappingPatch {
//Used by app.revanced.patches.youtube.interaction.seekbar.patch.EnableSeekbarTappingPatch
public static boolean isTapSeekingEnabled() {
return SettingsEnum.TAP_SEEKING_ENABLED_BOOLEAN.getBoolean();
return SettingsEnum.TAP_SEEKING_ENABLED.getBoolean();
}
}

View File

@ -1,12 +1,14 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.adremover.whitelist.Whitelist;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.whitelist.Whitelist;
public class VideoAdsPatch {
//Used by app.revanced.patches.youtube.ad.general.video.patch.VideoAdsPatch
//depends on Whitelist Patch. Still needs to be written
public static boolean shouldShowAds() {
return Whitelist.shouldShowAds();
return SettingsEnum.VIDEO_ADS_SHOWN.getBoolean() && Whitelist.shouldShowAds();
}
}

View File

@ -5,19 +5,19 @@ import app.revanced.integrations.settings.SettingsEnum;
public class VideoBufferPatch {
public static int getMaxBuffer() {
int confVal = SettingsEnum.MAX_BUFFER_INTEGER.getInt();
int confVal = SettingsEnum.MAX_BUFFER.getInt();
if (confVal < 1) confVal = 1;
return confVal;
}
public static int getPlaybackBuffer() {
int confVal = SettingsEnum.PLAYBACK_MAX_BUFFER_INTEGER.getInt();
int confVal = SettingsEnum.PLAYBACK_MAX_BUFFER.getInt();
if (confVal < 1) confVal = 1;
return confVal;
}
public static int getReBuffer() {
int confVal = SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER.getInt();
int confVal = SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER.getInt();
if (confVal < 1) confVal = 1;
return confVal;
}

View File

@ -1,17 +1,118 @@
package app.revanced.integrations.patches;
import app.revanced.integrations.videoplayer.videosettings.VideoQuality;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
public class VideoQualityPatch {
public static final int[] videoResolutions = {0, 144, 240, 360, 480, 720, 1080, 1440, 2160};
private static Boolean userChangedQuality = false;
//ToDo: Write Patch for it.
//See https://drive.google.com/file/d/1goodaU0JWrO9BAOUn6El-Id1SNuMGHR9/view?usp=sharing for where it needs to be used.
public static int setVideoQuality(Object[] qualities, int quality, Object qInterface) {
return VideoQuality.setVideoQuality(qualities, quality, qInterface);
int preferredQuality;
Field[] fields;
if (!ReVancedUtils.isNewVideoStarted() || userChangedQuality || qInterface == null) {
if (SettingsEnum.DEBUG.getBoolean() && userChangedQuality) {
LogHelper.debug(VideoQualityPatch.class, "Skipping quality change because user changed it: " + quality);
}
userChangedQuality = false;
return quality;
}
ReVancedUtils.setNewVideo(false);
LogHelper.debug(VideoQualityPatch.class, "Quality: " + quality);
Context context = ReVancedUtils.getContext();
if (context == null) {
LogHelper.printException(VideoQualityPatch.class, "Context is null or settings not initialized, returning quality: " + quality);
return quality;
}
if (isConnectedWifi(context)) {
preferredQuality = SettingsEnum.PREFERRED_RESOLUTION_WIFI.getInt();
LogHelper.debug(VideoQualityPatch.class, "Wi-Fi connection detected, preferred quality: " + preferredQuality);
} else if (isConnectedMobile(context)) {
preferredQuality = SettingsEnum.PREFERRED_RESOLUTION_MOBILE.getInt();
LogHelper.debug(VideoQualityPatch.class, "Mobile data connection detected, preferred quality: " + preferredQuality);
} else {
LogHelper.debug(VideoQualityPatch.class, "No Internet connection!");
return quality;
}
if (preferredQuality == -2) {
return quality;
}
Class<?> intType = Integer.TYPE;
ArrayList<Integer> iStreamQualities = new ArrayList<>();
try {
for (Object streamQuality : qualities) {
for (Field field : streamQuality.getClass().getFields()) {
if (field.getType().isAssignableFrom(intType)) {
int value = field.getInt(streamQuality);
if (field.getName().length() <= 2) {
iStreamQualities.add(value);
}
}
}
}
} catch (Exception ignored) {
}
Collections.sort(iStreamQualities);
int index = 0;
for (int streamQuality2 : iStreamQualities) {
LogHelper.debug(VideoQualityPatch.class, "Quality at index " + index + ": " + streamQuality2);
index++;
}
for (Integer iStreamQuality : iStreamQualities) {
int streamQuality3 = iStreamQuality;
if (streamQuality3 <= preferredQuality) {
quality = streamQuality3;
}
}
if (quality == -2) {
return quality;
}
int qualityIndex = iStreamQualities.indexOf(quality);
LogHelper.debug(VideoQualityPatch.class, "Index of quality " + quality + " is " + qualityIndex);
try {
Class<?> cl = qInterface.getClass();
Method m = cl.getMethod("x", Integer.TYPE);
m.invoke(qInterface, iStreamQualities.get(qualityIndex));
LogHelper.debug(VideoQualityPatch.class, "Quality changed to: " + qualityIndex);
return qualityIndex;
} catch (Exception ex) {
LogHelper.printException(VideoQualityPatch.class, "Failed to set quality", ex);
return qualityIndex;
}
}
//See https://drive.google.com/file/d/1_cgCf603XKk4gEbbsmWGtndNt5UJ0np7/view?usp=sharing for usage
public static void userChangedQuality() {
VideoQuality.userChangedQuality();
userChangedQuality = true;
}
private static NetworkInfo getNetworkInfo(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
return cm.getActiveNetworkInfo();
}
private static boolean isConnectedWifi(Context context) {
NetworkInfo info = getNetworkInfo(context);
return info != null && info.isConnected() && info.getType() == 1;
}
private static boolean isConnectedMobile(Context context) {
NetworkInfo info = getNetworkInfo(context);
return info != null && info.isConnected() && info.getType() == 0;
}
}

View File

@ -1,10 +1,4 @@
package app.revanced.integrations.videoplayer.videosettings;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.utils.ReVancedUtils;
package app.revanced.integrations.patches;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@ -12,8 +6,12 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
/* loaded from: classes6.dex */
public class VideoSpeed {
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
public class VideoSpeedPatch {
public static final float[] videoSpeeds = {0.25f, 0.5f, 0.75f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 3.0f, 4.0f, 5.0f};
private static Boolean userChangedSpeed = false;
@ -24,9 +22,9 @@ public class VideoSpeed {
return speed;
}
ReVancedUtils.setNewVideo(false);
LogHelper.debug(VideoSpeed.class, "Speed: " + speed);
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getFloat();
LogHelper.debug(VideoSpeed.class, "Preferred speed: " + preferredSpeed);
LogHelper.debug(VideoSpeedPatch.class, "Speed: " + speed);
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED.getFloat();
LogHelper.debug(VideoSpeedPatch.class, "Preferred speed: " + preferredSpeed);
if (preferredSpeed == -2.0f) {
return speed;
}
@ -50,18 +48,18 @@ public class VideoSpeed {
int index = 0;
while (it.hasNext()) {
float streamSpeed2 = it.next();
LogHelper.debug(VideoSpeed.class, "Speed at index " + index + ": " + streamSpeed2);
LogHelper.debug(VideoSpeedPatch.class, "Speed at index " + index + ": " + streamSpeed2);
index++;
}
int speed3 = -1;
for (float streamSpeed3 : iStreamSpeeds) {
if (streamSpeed3 <= preferredSpeed) {
speed3++;
LogHelper.debug(VideoSpeed.class, "Speed loop at index " + speed3 + ": " + streamSpeed3);
LogHelper.debug(VideoSpeedPatch.class, "Speed loop at index " + speed3 + ": " + streamSpeed3);
}
}
if (speed3 == -1) {
LogHelper.debug(VideoSpeed.class, "Speed was not found");
LogHelper.debug(VideoSpeedPatch.class, "Speed was not found");
speed2 = 3;
} else {
speed2 = speed3;
@ -70,14 +68,14 @@ public class VideoSpeed {
Method[] declaredMethods = qInterface.getClass().getDeclaredMethods();
for (Method method : declaredMethods) {
if (method.getName().length() <= 2) {
LogHelper.debug(VideoSpeed.class, "Method name: " + method.getName());
LogHelper.debug(VideoSpeedPatch.class, "Method name: " + method.getName());
try {
try {
method.invoke(qInterface, videoSpeeds[speed2]);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {
} catch (Exception e6) {
e = e6;
LogHelper.printException(VideoSpeed.class, e.getMessage());
LogHelper.printException(VideoSpeedPatch.class, e.getMessage());
return speed2;
}
} catch (Exception ignored) {
@ -87,7 +85,7 @@ public class VideoSpeed {
} catch (Exception e10) {
e = e10;
}
LogHelper.debug(VideoSpeed.class, "Speed changed to: " + speed2);
LogHelper.debug(VideoSpeedPatch.class, "Speed changed to: " + speed2);
return speed2;
}
@ -98,16 +96,16 @@ public class VideoSpeed {
public static float getSpeedValue(Object[] speeds, int speed) {
int i = 0;
if (!ReVancedUtils.isNewVideoStarted() || userChangedSpeed) {
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean() && userChangedSpeed) {
LogHelper.debug(VideoSpeed.class, "Skipping speed change because user changed it: " + speed);
if (SettingsEnum.DEBUG.getBoolean() && userChangedSpeed) {
LogHelper.debug(VideoSpeedPatch.class, "Skipping speed change because user changed it: " + speed);
}
userChangedSpeed = false;
return -1.0f;
}
ReVancedUtils.setNewVideo(false);
LogHelper.debug(VideoSpeed.class, "Speed: " + speed);
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getFloat();
LogHelper.debug(VideoSpeed.class, "Preferred speed: " + preferredSpeed);
LogHelper.debug(VideoSpeedPatch.class, "Speed: " + speed);
float preferredSpeed = SettingsEnum.PREFERRED_VIDEO_SPEED.getFloat();
LogHelper.debug(VideoSpeedPatch.class, "Preferred speed: " + preferredSpeed);
if (preferredSpeed == -2.0f) {
return -1.0f;
}
@ -138,7 +136,7 @@ public class VideoSpeed {
int index = 0;
for (Float iStreamSpeed : iStreamSpeeds) {
float streamSpeed2 = iStreamSpeed;
LogHelper.debug(VideoSpeed.class, "Speed at index " + index + ": " + streamSpeed2);
LogHelper.debug(VideoSpeedPatch.class, "Speed at index " + index + ": " + streamSpeed2);
index++;
}
int newSpeedIndex = -1;
@ -146,18 +144,18 @@ public class VideoSpeed {
float streamSpeed3 = iStreamSpeed;
if (streamSpeed3 <= preferredSpeed) {
newSpeedIndex++;
LogHelper.debug(VideoSpeed.class, "Speed loop at index " + newSpeedIndex + ": " + streamSpeed3);
LogHelper.debug(VideoSpeedPatch.class, "Speed loop at index " + newSpeedIndex + ": " + streamSpeed3);
}
}
if (newSpeedIndex == -1) {
LogHelper.debug(VideoSpeed.class, "Speed was not found");
LogHelper.debug(VideoSpeedPatch.class, "Speed was not found");
newSpeedIndex = 3;
}
if (newSpeedIndex == speed) {
LogHelper.debug(VideoSpeed.class, "Trying to set speed to what it already is, skipping...: " + newSpeedIndex);
LogHelper.debug(VideoSpeedPatch.class, "Trying to set speed to what it already is, skipping...: " + newSpeedIndex);
return -1.0f;
}
LogHelper.debug(VideoSpeed.class, "Speed changed to: " + newSpeedIndex);
LogHelper.debug(VideoSpeedPatch.class, "Speed changed to: " + newSpeedIndex);
return getSpeedByIndex(newSpeedIndex);
}
@ -171,5 +169,4 @@ public class VideoSpeed {
return 1.0f;
}
}
}

View File

@ -22,7 +22,7 @@ public class Registration {
}
public void saveUserId(String userId) {
SettingsEnum.RYD_USER_ID_STRING.saveValue(userId);
SettingsEnum.RYD_USER_ID.saveValue(userId);
}
public static String solvePuzzle(String challenge, int difficulty) {
@ -69,7 +69,7 @@ public class Registration {
}
private String fetchUserId() {
this.userId = SettingsEnum.RYD_USER_ID_STRING.getString();
this.userId = SettingsEnum.RYD_USER_ID.getString();
if (this.userId == null) {
this.userId = register();
}

View File

@ -34,7 +34,7 @@ public class ReturnYouTubeDislikes {
static {
Context context = ReVancedUtils.getContext();
isEnabled = SettingsEnum.RYD_ENABLED_BOOLEAN.getBoolean();
isEnabled = SettingsEnum.RYD_ENABLED.getBoolean();
if (isEnabled) {
registration = new Registration();
voting = new Voting(registration);

View File

@ -20,14 +20,14 @@ public class Dialogs {
}
private static void rydFirstRun(Activity activity) {
boolean enabled = SettingsEnum.RYD_ENABLED_BOOLEAN.getBoolean();
boolean hintShown = SettingsEnum.RYD_HINT_SHOWN_BOOLEAN.getBoolean();
boolean enabled = SettingsEnum.RYD_ENABLED.getBoolean();
boolean hintShown = SettingsEnum.RYD_HINT_SHOWN.getBoolean();
// If RYD is enabled or hint has been shown, exit
if (enabled || hintShown) {
// If RYD is enabled but hint hasn't been shown, mark it as shown
if (enabled && !hintShown) {
SettingsEnum.RYD_HINT_SHOWN_BOOLEAN.saveValue(true);
SettingsEnum.RYD_HINT_SHOWN.saveValue(true);
}
return;
}
@ -44,15 +44,15 @@ public class Dialogs {
builder.setMessage(str("revanced_ryd_firstrun"));
builder.setPositiveButton(str("revanced_enable"),
(dialog, id) -> {
SettingsEnum.RYD_HINT_SHOWN_BOOLEAN.saveValue(true);
SettingsEnum.RYD_ENABLED_BOOLEAN.saveValue(true);
SettingsEnum.RYD_HINT_SHOWN.saveValue(true);
SettingsEnum.RYD_ENABLED.saveValue(true);
dialog.dismiss();
});
builder.setNegativeButton(str("revanced_disable"),
(dialog, id) -> {
SettingsEnum.RYD_HINT_SHOWN_BOOLEAN.saveValue(true);
SettingsEnum.RYD_ENABLED_BOOLEAN.saveValue(false);
SettingsEnum.RYD_HINT_SHOWN.saveValue(true);
SettingsEnum.RYD_ENABLED.saveValue(false);
dialog.dismiss();
});

View File

@ -1,7 +1,7 @@
package app.revanced.integrations.ryd.requests;
import static app.revanced.integrations.sponsorblock.player.VideoInformation.dislikeCount;
import static app.revanced.integrations.adremover.whitelist.requests.Requester.parseJson;
import static app.revanced.integrations.whitelist.requests.Requester.parseJson;
import android.os.Handler;
import android.os.Looper;
@ -17,8 +17,8 @@ import java.nio.charset.StandardCharsets;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.ryd.Registration;
import app.revanced.integrations.ryd.ReturnYouTubeDislikes;
import app.revanced.integrations.adremover.whitelist.requests.Requester;
import app.revanced.integrations.adremover.whitelist.requests.Route;
import app.revanced.integrations.whitelist.requests.Requester;
import app.revanced.integrations.whitelist.requests.Route;
public class RYDRequester {
private static final String RYD_API_URL = "https://returnyoutubedislikeapi.com/";

View File

@ -1,9 +1,9 @@
package app.revanced.integrations.ryd.requests;
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.GET;
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.POST;
import static app.revanced.integrations.whitelist.requests.Route.Method.GET;
import static app.revanced.integrations.whitelist.requests.Route.Method.POST;
import app.revanced.integrations.adremover.whitelist.requests.Route;
import app.revanced.integrations.whitelist.requests.Route;
public class RYDRoutes {
public static final Route SEND_VOTE = new Route(POST, "interact/vote");

View File

@ -0,0 +1,10 @@
package app.revanced.integrations.settings;
public enum ReturnType {
BOOLEAN,
INTEGER,
STRING,
LONG,
FLOAT;
}

View File

@ -1,92 +0,0 @@
package app.revanced.integrations.settings;
public class Settings {
//Methods not used in latest Vanced source code, can be useful for future patches
/*
private static Object AutoRepeatClass;
public static boolean getVerticalZoomToFit(boolean original) {
ReadSettings();
if (!settingsInitialized.booleanValue()) {
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
return original;
} else if (!verticalZoomToFit.booleanValue()) {
return original;
} else {
LogHelper.debug("Settings", "getVerticalZoomToFit: Enabled");
return true;
}
}
public static int getMinimizedVideo(int original) {
int preferredType = SettingsEnum.PREFERRED_MINIMIZED_VIDEO_PREVIEW_INTEGER.getInt();
if (preferredType == -2) {
return original;
}
if (preferredType == 0 || preferredType == 1) {
return preferredType;
}
return original;
}
public static boolean getThemeStatus() {
ReadSettings();
if (!settingsInitialized.booleanValue()) {
LogHelper.printException("Settings", "Context is null, returning false!");
return false;
} else if (!isDarkApp.booleanValue()) {
return false;
} else {
LogHelper.debug("Settings", "getThemeStatus: Is themed");
return true;
}
}
public static boolean accessibilitySeek(boolean original) {
ReadSettings();
if (!settingsInitialized.booleanValue()) {
LogHelper.printException("Settings", "Context is null, returning " + original + "!");
return original;
}
Boolean seek = Boolean.valueOf(original);
if (accessibilitySeek.booleanValue()) {
seek = true;
}
LogHelper.debug("Settings", "accessibilitySeek: " + seek);
return seek.booleanValue();
}
public static void setOldLayout(SharedPreferences sharedPreferences, String config, long timeStamp) {
if (!SettingsEnum.OLD_LAYOUT_ENABLED_BOOLEAN.getBoolean()) {
sharedPreferences.edit().putString("com.google.android.libraries.youtube.innertube.cold_config_group", config).putLong("com.google.android.libraries.youtube.innertube.cold_stored_timestamp", timeStamp).apply();
LogHelper.debug("Settings", "setOldLayout: true");
return;
}
if (sharedPreferences.contains("com.google.android.libraries.youtube.innertube.cold_config_group")) {
sharedPreferences.edit().putString("com.google.android.libraries.youtube.innertube.cold_config_group_backup", sharedPreferences.getString("com.google.android.libraries.youtube.innertube.cold_config_group", null)).remove("com.google.android.libraries.youtube.innertube.cold_config_group").apply();
}
LogHelper.debug("Settings", "setOldLayout: false");
}
public static boolean autoCaptions(boolean original) {
ReadSettings();
if (!settingsInitialized.booleanValue()) {
Log.e("XGlobals", "Context is null, returning " + original + "!");
return original;
}
Boolean captions = Boolean.valueOf(original);
if (prefAutoCaptions.booleanValue()) {
captions = true;
}
if (debug.booleanValue()) {
Log.d("XGlobals", "autoCaptions: " + captions);
}
return captions.booleanValue();
}
*/
}

View File

@ -1,6 +1,7 @@
package app.revanced.integrations.settings;
import android.content.Context;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
@ -12,149 +13,161 @@ import app.revanced.integrations.utils.SharedPrefHelper;
public enum SettingsEnum {
//Codec Override
CODEC_OVERRIDE_BOOLEAN("revanced_override_codec_enabled", true),
CODEC_OVERRIDE("revanced_override_codec_enabled", true, ReturnType.BOOLEAN),
//Video Settings
OLD_STYLE_QUALITY_SETTINGS_BOOLEAN("revanced_use_old_style_quality_settings", true),
OVERRIDE_RESOLUTION_TO_MAX_BOOLEAN("revanced_override_resolution_max", false),
PREFERRED_RESOLUTION_WIFI_INTEGER("revanced_pref_video_quality_wifi", -2),
PREFERRED_RESOLUTION_MOBILE_INTEGER("revanced_pref_video_quality_mobile", -2),
PREFERRED_VIDEO_SPEED_FLOAT("revanced_pref_video_speed", -2.0f),
OLD_STYLE_QUALITY_SETTINGS("revanced_use_old_style_quality_settings", true, ReturnType.BOOLEAN),
OVERRIDE_RESOLUTION_TO_MAX("revanced_override_resolution_max", false, ReturnType.BOOLEAN),
PREFERRED_RESOLUTION_WIFI("revanced_pref_video_quality_wifi", -2, ReturnType.INTEGER),
PREFERRED_RESOLUTION_MOBILE("revanced_pref_video_quality_mobile", -2, ReturnType.INTEGER),
PREFERRED_VIDEO_SPEED("revanced_pref_video_speed", -2.0f, ReturnType.FLOAT),
//Whitelist Settings
ENABLE_WHITELIST_BOOLEAN("revanced_whitelist_ads_enabled", false),
ENABLE_WHITELIST("revanced_whitelist_ads_enabled", false, ReturnType.BOOLEAN),
//Ad settings
HOME_ADS_SHOWN_BOOLEAN("revanced_home_ads_enabled", false),
VIDEO_ADS_SHOWN_BOOLEAN("revanced_video_ads_enabled", false),
ADREMOVER_AD_REMOVAL_BOOLEAN("revanced_adremover_ad_removal", true),
ADREMOVER_MERCHANDISE_REMOVAL_BOOLEAN("revanced_adremover_merchandise", true),
ADREMOVER_COMMUNITY_POSTS_REMOVAL_BOOLEAN("revanced_adremover_community_posts_removal", false),
ADREMOVER_COMPACT_BANNER_REMOVAL_BOOLEAN("revanced_adremover_compact_banner_removal", true),
ADREMOVER_COMMENTS_REMOVAL_BOOLEAN("revanced_adremover_comments_removal", false),
ADREMOVER_MOVIE_REMOVAL_BOOLEAN("revanced_adremover_movie", true),
ADREMOVER_FEED_SURVEY_REMOVAL_BOOLEAN("revanced_adremover_feed_survey", true),
ADREMOVER_SHORTS_SHELF_BOOLEAN("revanced_adremover_shorts_shelf", true),
ADREMOVER_COMMUNITY_GUIDELINES_BOOLEAN("revanced_adremover_community_guidelines", true),
HOME_ADS_SHOWN("revanced_home_ads_enabled", false, ReturnType.BOOLEAN),
VIDEO_ADS_SHOWN("revanced_video_ads_enabled", false, ReturnType.BOOLEAN),
ADREMOVER_AD_REMOVAL("revanced_adremover_ad_removal", true, ReturnType.BOOLEAN),
ADREMOVER_MERCHANDISE_REMOVAL("revanced_adremover_merchandise", true, ReturnType.BOOLEAN),
ADREMOVER_COMMUNITY_POSTS_REMOVAL("revanced_adremover_community_posts_removal", false, ReturnType.BOOLEAN),
ADREMOVER_COMPACT_BANNER_REMOVAL("revanced_adremover_compact_banner_removal", true, ReturnType.BOOLEAN),
ADREMOVER_COMMENTS_REMOVAL("revanced_adremover_comments_removal", false, ReturnType.BOOLEAN),
ADREMOVER_MOVIE_REMOVAL("revanced_adremover_movie", true, ReturnType.BOOLEAN),
ADREMOVER_FEED_SURVEY_REMOVAL("revanced_adremover_feed_survey", true, ReturnType.BOOLEAN),
ADREMOVER_SHORTS_SHELF("revanced_adremover_shorts_shelf", true, ReturnType.BOOLEAN),
ADREMOVER_COMMUNITY_GUIDELINES("revanced_adremover_community_guidelines", true, ReturnType.BOOLEAN),
//ToDo: These Settings have to be added to revanced_prefs.xml
ADREMOVER_EMERGENCY_BOX_REMOVAL_BOOLEAN("revanced_adremover_emergency_box_removal", true),
ADREMOVER_INFO_PANEL_REMOVAL_BOOLEAN("revanced_adremover_info_panel", true),
ADREMOVER_MEDICAL_PANEL_REMOVAL_BOOLEAN("revanced_adremover_medical_panel", true),
ADREMOVER_PAID_CONTECT_REMOVAL_BOOLEAN("revanced_adremover_paid_content", true),
ADREMOVER_SUGGESTED_FOR_YOU_REMOVAL_BOOLEAN("revanced_adremover_suggested", true),
ADREMOVER_HIDE_SUGGESTIONS_BOOLEAN("revanced_adremover_hide_suggestions", true),
ADREMOVER_HIDE_LATEST_POSTS_BOOLEAN("revanced_adremover_hide_latest_posts", true),
ADREMOVER_EMERGENCY_BOX_REMOVAL("revanced_adremover_emergency_box_removal", true, ReturnType.BOOLEAN),
ADREMOVER_INFO_PANEL_REMOVAL("revanced_adremover_info_panel", true, ReturnType.BOOLEAN),
ADREMOVER_MEDICAL_PANEL_REMOVAL("revanced_adremover_medical_panel", true, ReturnType.BOOLEAN),
ADREMOVER_PAID_CONTECT_REMOVAL("revanced_adremover_paid_content", true, ReturnType.BOOLEAN),
ADREMOVER_SUGGESTED_FOR_YOU_REMOVAL("revanced_adremover_suggested", true, ReturnType.BOOLEAN),
ADREMOVER_HIDE_SUGGESTIONS("revanced_adremover_hide_suggestions", true, ReturnType.BOOLEAN),
ADREMOVER_HIDE_LATEST_POSTS("revanced_adremover_hide_latest_posts", true, ReturnType.BOOLEAN),
//Layout settings
REEL_BUTTON_SHOWN_BOOLEAN("revanced_reel_button_enabled", false),
INFO_CARDS_SHOWN_BOOLEAN("revanced_info_cards_enabled", false),
BRANDING_SHOWN_BOOLEAN("revanced_branding_watermark_enabled", false),
CAST_BUTTON_SHOWN_BOOLEAN("revanced_cast_button_enabled", false),
USE_TABLET_MINIPLAYER_BOOLEAN("revanced_tablet_miniplayer", false),
CREATE_BUTTON_SHOWN_BOOLEAN("revanced_create_button_enabled", false),
USE_NEW_ACTIONBAR_BOOLEAN("revanced_new_actionbar", true),
SHORTS_BUTTON_SHOWN_BOOLEAN("revanced_shorts_button_enabled", false),
REEL_BUTTON_SHOWN("revanced_reel_button_enabled", false, ReturnType.BOOLEAN),
INFO_CARDS_SHOWN("revanced_info_cards_enabled", false, ReturnType.BOOLEAN),
BRANDING_SHOWN("revanced_branding_watermark_enabled", false, ReturnType.BOOLEAN),
CAST_BUTTON_SHOWN("revanced_cast_button_enabled", false, ReturnType.BOOLEAN),
USE_TABLET_MINIPLAYER("revanced_tablet_miniplayer", false, ReturnType.BOOLEAN),
CREATE_BUTTON_SHOWN("revanced_create_button_enabled", false, ReturnType.BOOLEAN),
USE_NEW_ACTIONBAR("revanced_new_actionbar", true, ReturnType.BOOLEAN),
SHORTS_BUTTON_SHOWN("revanced_shorts_button_enabled", false, ReturnType.BOOLEAN),
//Misc. Settings
AUTOREPEAT_BUTTON_SHOWN_BOOLEAN("revanced_pref_auto_repeat_button", false),
PREFERRED_AUTO_REPEAT_BOOLEAN("revanced_pref_auto_repeat", true),
USE_HDR_AUTO_BRIGHTNESS_BOOLEAN("revanced_pref_hdr_autobrightness", true),
TAP_SEEKING_ENABLED_BOOLEAN("revanced_enable_tap_seeking", true),
AUTOREPEAT_BUTTON_SHOWN("revanced_pref_auto_repeat_button", false, ReturnType.BOOLEAN),
AUTO_CAPTIONS_ENABLED("revanced_pref_auto_captions", false, ReturnType.BOOLEAN),
PREFERRED_AUTO_REPEAT("revanced_pref_auto_repeat", true, ReturnType.BOOLEAN),
USE_HDR_AUTO_BRIGHTNESS("revanced_pref_hdr_autobrightness", true, ReturnType.BOOLEAN),
TAP_SEEKING_ENABLED("revanced_enable_tap_seeking", true, ReturnType.BOOLEAN),
//Swipe controls
ENABLE_SWIPE_BRIGHTNESS_BOOLEAN("revanced_enable_swipe_brightness", true),
ENABLE_SWIPE_VOLUME_BOOLEAN("revanced_enable_swipe_volume", true),
ENABLE_PRESS_TO_SWIPE_BOOLEAN("revanced_enable_press_to_swipe", false),
ENABLE_SWIPE_HAPTIC_FEEDBACK_BOOLEAN("revanced_enable_swipe_haptic_feedback", true),
SWIPE_OVERLAY_TIMEOUT_LONG("revanced_swipe_overlay_timeout", 500L),
SWIPE_OVERLAY_TEXT_SIZE_FLOAT("revanced_swipe_overlay_text_size", 22f),
SWIPE_OVERLAY_BACKGROUND_ALPHA_INTEGER("revanced_swipe_overlay_background_alpha", 127),
SWIPE_MAGNITUDE_THRESHOLD_FLOAT("revanced_swipe_magnitude_threshold", 30f),
ENABLE_SWIPE_BRIGHTNESS("revanced_enable_swipe_brightness", true, ReturnType.BOOLEAN),
ENABLE_SWIPE_VOLUME("revanced_enable_swipe_volume", true, ReturnType.BOOLEAN),
ENABLE_PRESS_TO_SWIPE("revanced_enable_press_to_swipe", false, ReturnType.BOOLEAN),
ENABLE_SWIPE_HAPTIC_FEEDBACK("revanced_enable_swipe_haptic_feedback", true, ReturnType.BOOLEAN),
SWIPE_OVERLAY_TIMEOUT("revanced_swipe_overlay_timeout", 500L, ReturnType.LONG),
SWIPE_OVERLAY_TEXT_SIZE("revanced_swipe_overlay_text_size", 22f, ReturnType.FLOAT),
SWIPE_OVERLAY_BACKGROUND_ALPHA("revanced_swipe_overlay_background_alpha", 127, ReturnType.INTEGER),
SWIPE_MAGNITUDE_THRESHOLD("revanced_swipe_magnitude_threshold", 30f, ReturnType.FLOAT),
//Buffer Settings
MAX_BUFFER_INTEGER("revanced_pref_max_buffer_ms", 120000),
PLAYBACK_MAX_BUFFER_INTEGER("revanced_pref_buffer_for_playback_ms", 2500),
MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER("revanced_pref_buffer_for_playback_after_rebuffer_ms", 5000),
MAX_BUFFER("revanced_pref_max_buffer_ms", 120000, ReturnType.INTEGER),
PLAYBACK_MAX_BUFFER("revanced_pref_buffer_for_playback_ms", 2500, ReturnType.INTEGER),
MAX_PLAYBACK_BUFFER_AFTER_REBUFFER("revanced_pref_buffer_for_playback_after_rebuffer_ms", 5000, ReturnType.INTEGER),
//ReVanced General Settings
DEBUG_BOOLEAN("revanced_debug_enabled", false),
USE_DARK_THEME_BOOLEAN("app_theme_dark", false),
DEBUG("revanced_debug_enabled", true, ReturnType.BOOLEAN),
USE_DARK_THEME("app_theme_dark", false, ReturnType.BOOLEAN),
//RYD Settings
RYD_USER_ID_STRING("ryd_userId", null, SharedPrefHelper.SharedPrefNames.RYD),
RYD_ENABLED_BOOLEAN("ryd_enabled", true, SharedPrefHelper.SharedPrefNames.RYD),
RYD_HINT_SHOWN_BOOLEAN("ryd_hint_shown", false, SharedPrefHelper.SharedPrefNames.RYD),
RYD_USER_ID("ryd_userId", null, SharedPrefHelper.SharedPrefNames.RYD, ReturnType.STRING),
RYD_ENABLED("ryd_enabled", true, SharedPrefHelper.SharedPrefNames.RYD, ReturnType.BOOLEAN),
RYD_HINT_SHOWN("ryd_hint_shown", false, SharedPrefHelper.SharedPrefNames.RYD, ReturnType.BOOLEAN),
//SponsorBlock Settings
SB_ENABLED_BOOLEAN("sb-enabled", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_SHOW_TOAST_WHEN_SKIP_BOOLEAN("show-toast", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_COUNT_SKIPS_BOOLEAN("count-skips", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_UUID_STRING("uuid", null, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_ADJUST_NEW_SEGMENT_STEP_INTEGER("new-segment-step-accuracy", 150, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_MIN_DURATION_FLOAT("sb-min-duration", 0F, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_SPONSOR_BLOCK_HINT_SHOWN_BOOLEAN("sb_hint_shown", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_SEEN_GUIDELINES_BOOLEAN("sb-seen-gl", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_NEW_SEGMENT_ENABLED_BOOLEAN("sb-new-segment-enabled", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_VOTING_ENABLED_BOOLEAN("sb-voting-enabled", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_SKIPPED_SEGMENTS_INTEGER("sb-skipped-segments", 0, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_SKIPPED_SEGMENTS_TIME_LONG("sb-skipped-segments-time", 0L, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_SHOW_TIME_WITHOUT_SEGMENTS_BOOLEAN("sb-length-without-segments", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_IS_VIP_BOOLEAN("sb-is-vip", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_LAST_VIP_CHECK_LONG("sb-last-vip-check", 0L, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_SHOW_BROWSER_BUTTON_BOOLEAN("sb-browser-button", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK),
SB_API_URL_STRING("sb-api-url", "https://sponsor.ajay.app/api/", SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK);
SB_ENABLED("sb-enabled", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
SB_SHOW_TOAST_WHEN_SKIP("show-toast", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
SB_COUNT_SKIPS("count-skips", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
SB_UUID("uuid", null, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.STRING),
SB_ADJUST_NEW_SEGMENT_STEP("new-segment-step-accuracy", 150, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.INTEGER),
SB_MIN_DURATION("sb-min-duration", 0F, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.FLOAT),
SB_SPONSOR_BLOCK_HINT_SHOWN("sb_hint_shown", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
SB_SEEN_GUIDELINES("sb-seen-gl", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
SB_NEW_SEGMENT_ENABLED("sb-new-segment-enabled", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
SB_VOTING_ENABLED("sb-voting-enabled", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
SB_SKIPPED_SEGMENTS("sb-skipped-segments", 0, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.INTEGER),
SB_SKIPPED_SEGMENTS_TIME("sb-skipped-segments-time", 0L, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.LONG),
SB_SHOW_TIME_WITHOUT_SEGMENTS("sb-length-without-segments", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
SB_IS_VIP("sb-is-vip", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
SB_LAST_VIP_CHECK("sb-last-vip-check", 0L, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.LONG),
SB_SHOW_BROWSER_BUTTON("sb-browser-button", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
SB_API_URL("sb-api-url", "https://sponsor.ajay.app/api/", SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.STRING);
private final String path;
private final Object defaultValue;
private final SharedPrefHelper.SharedPrefNames sharedPref;
private final ReturnType returnType;
private Object value = null;
private static boolean loaded = false;
SettingsEnum(String path, Object defaultValue) {
SettingsEnum(String path, Object defaultValue, ReturnType returnType) {
this.path = path;
this.defaultValue = defaultValue;
this.sharedPref = SharedPrefHelper.SharedPrefNames.YOUTUBE;
this.returnType = returnType;
}
SettingsEnum(String path, Object defaultValue, SharedPrefHelper.SharedPrefNames prefName) {
SettingsEnum(String path, Object defaultValue, SharedPrefHelper.SharedPrefNames prefName, ReturnType returnType) {
this.path = path;
this.defaultValue = defaultValue;
this.sharedPref = prefName;
this.returnType = returnType;
}
public static void loadSettings() {
if (loaded) return;
static {
load();
}
private static void load() {
Context context = ReVancedUtils.getContext();
if (context != null) {
if (context == null) {
Log.e("revanced: SettingsEnum", "Context returned null! Setings NOT initialized");
} else {
for (SettingsEnum setting : values()) {
Object value;
if (setting.name().endsWith("BOOLEAN")) {
value = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath(), (boolean)setting.getDefaultValue());
} else if (setting.name().endsWith("INTEGER")) {
value = SharedPrefHelper.getInt(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath(), (int)setting.getDefaultValue());
} else if (setting.name().endsWith("STRING")) {
value = SharedPrefHelper.getString(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath(), (String)setting.getDefaultValue());
} else if (setting.name().endsWith("LONG")) {
value = SharedPrefHelper.getLong(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath(), (long)setting.getDefaultValue());
} else if (setting.name().endsWith(("FLOAT"))) {
value = SharedPrefHelper.getFloat(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath(), (float)setting.getDefaultValue());
} else {
LogHelper.printException(SettingsEnum.class, "Setting does not end with a valid Type. Name is: " + setting.name());
continue;
Object value = setting.getDefaultValue();
//LogHelper is not initialized here
Log.d("revanced: SettingsEnum", "Loading Setting: " + setting.name());
switch (setting.getReturnType()) {
case FLOAT:
value = SharedPrefHelper.getFloat(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath(), (float) setting.getDefaultValue());
break;
case LONG:
value = SharedPrefHelper.getLong(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath(), (long) setting.getDefaultValue());
break;
case BOOLEAN:
value = SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath(), (boolean) setting.getDefaultValue());
break;
case INTEGER:
value = SharedPrefHelper.getInt(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath(), (int) setting.getDefaultValue());
break;
case STRING:
value = SharedPrefHelper.getString(context, SharedPrefHelper.SharedPrefNames.YOUTUBE, setting.getPath(), (String) setting.getDefaultValue());
break;
default:
LogHelper.printException(SettingsEnum.class, "Setting does not have a valid Type. Name is: " + setting.name());
break;
}
if (value == null) value = setting.getDefaultValue();
setting.setValue(value);
}
loaded = true;
}
}
public static boolean isLoaded() {
return loaded;
//LogHelper is not initialized here
Log.d("revanced: SettingsEnum", "Loaded Setting: " + setting.name() + " Value: " + value);
}
}
}
public static List<SettingsEnum> getAdRemovalSettings() {
@ -172,21 +185,27 @@ public enum SettingsEnum {
}
public void saveValue(Object newValue) {
loadSettings();
Context context = ReVancedUtils.getContext();
if (context != null) {
if (name().endsWith("BOOLEAN")) {
SharedPrefHelper.saveBoolean(context, sharedPref, getPath(), (Boolean) newValue);
} else if (name().endsWith("INTEGER")) {
SharedPrefHelper.saveInt(context, sharedPref, getPath(), (int) newValue);
} else if (name().endsWith("STRING")) {
SharedPrefHelper.saveString(context, sharedPref, getPath(), (String) newValue);
} else if (name().endsWith("LONG")) {
SharedPrefHelper.saveLong(context, sharedPref, getPath(), (Long) newValue);
} else if (name().endsWith(("FLOAT"))) {
SharedPrefHelper.saveFloat(context, sharedPref, getPath(), (Float) newValue);
} else {
LogHelper.printException(SettingsEnum.class, "Setting does not end with a valid Type. Name is: " + name());
switch (getReturnType()) {
case BOOLEAN:
SharedPrefHelper.saveBoolean(context, sharedPref, getPath(), (Boolean) newValue);
break;
case INTEGER:
SharedPrefHelper.saveInt(context, sharedPref, getPath(), (int) newValue);
break;
case STRING:
SharedPrefHelper.saveString(context, sharedPref, getPath(), (String) newValue);
break;
case LONG:
SharedPrefHelper.saveLong(context, sharedPref, getPath(), (Long) newValue);
break;
case FLOAT:
SharedPrefHelper.saveFloat(context, sharedPref, getPath(), (Float) newValue);
break;
default:
LogHelper.printException(SettingsEnum.class, "Setting does not have with a valid Type. Name is: " + name());
break;
}
value = newValue;
} else {
@ -195,30 +214,22 @@ public enum SettingsEnum {
}
public int getInt() {
SettingsEnum.loadSettings();
if (value == null) value = -1;
return (int) value;
}
public String getString() {
SettingsEnum.loadSettings();
return (String) value;
}
public boolean getBoolean() {
SettingsEnum.loadSettings();
return (Boolean) value;
}
public Long getLong() {
SettingsEnum.loadSettings();
if (value == null) value = -1L;
return (Long) value;
}
public Float getFloat() {
SettingsEnum.loadSettings();
if (value == null) value = -1.0f;
return (Float) value;
}
@ -230,4 +241,8 @@ public enum SettingsEnum {
return path;
}
private ReturnType getReturnType() {
return returnType;
}
}

View File

@ -32,9 +32,9 @@ public class RYDSettingsFragment extends PreferenceFragment {
{
SwitchPreference preference = new SwitchPreference(context);
preferenceScreen.addPreference(preference);
preference.setKey(SettingsEnum.RYD_ENABLED_BOOLEAN.getPath());
preference.setKey(SettingsEnum.RYD_ENABLED.getPath());
preference.setDefaultValue(false);
preference.setChecked(SettingsEnum.RYD_ENABLED_BOOLEAN.getBoolean());
preference.setChecked(SettingsEnum.RYD_ENABLED.getBoolean());
preference.setTitle(str("revanced_ryd_title"));
preference.setSummary(str("revanced_ryd_summary"));
preference.setOnPreferenceChangeListener((pref, newValue) -> {
@ -45,12 +45,12 @@ public class RYDSettingsFragment extends PreferenceFragment {
}
// Clear hint
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
if (SettingsEnum.DEBUG.getBoolean()) {
SwitchPreference preference = new SwitchPreference(context);
preferenceScreen.addPreference(preference);
preference.setKey(SettingsEnum.RYD_HINT_SHOWN_BOOLEAN.getPath());
preference.setKey(SettingsEnum.RYD_HINT_SHOWN.getPath());
preference.setDefaultValue(false);
preference.setChecked(SettingsEnum.RYD_HINT_SHOWN_BOOLEAN.getBoolean());
preference.setChecked(SettingsEnum.RYD_HINT_SHOWN.getBoolean());
preference.setTitle("Hint debug");
preference.setSummary("Debug toggle for clearing the hint shown preference");
preference.setOnPreferenceChangeListener((pref, newValue) -> true);

View File

@ -8,6 +8,7 @@ import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Process;
import android.preference.EditTextPreference;
@ -22,10 +23,9 @@ import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.ScreenSizeHelper;
import app.revanced.integrations.videoplayer.autorepeat.AutoRepeat;
import app.revanced.integrations.videoplayer.videourl.Copy;
import app.revanced.integrations.videoplayer.videourl.CopyWithTimeStamp;
import app.revanced.integrations.videoplayer.AutoRepeat;
import app.revanced.integrations.videoplayer.Copy;
import app.revanced.integrations.videoplayer.CopyWithTimeStamp;
public class ReVancedSettingsFragment extends PreferenceFragment {
@ -56,92 +56,92 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
private final CharSequence[] buttonLocationentryValues = {"NONE", "PLAYER", "BUTTON_BAR", "BOTH"};
SharedPreferences.OnSharedPreferenceChangeListener listener = (sharedPreferences, str) -> {
if (str.equals(SettingsEnum.DEBUG_BOOLEAN.getPath())) {
SettingsEnum.DEBUG_BOOLEAN.setValue(((SwitchPreference) findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.HOME_ADS_SHOWN_BOOLEAN.getPath())) {
SettingsEnum.HOME_ADS_SHOWN_BOOLEAN.setValue(((SwitchPreference) adsSettingsPreferenceScreen.findPreference(str)).isChecked());
if (str.equals(SettingsEnum.DEBUG.getPath())) {
SettingsEnum.DEBUG.setValue(((SwitchPreference) findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.HOME_ADS_SHOWN.getPath())) {
SettingsEnum.HOME_ADS_SHOWN.setValue(((SwitchPreference) adsSettingsPreferenceScreen.findPreference(str)).isChecked());
if (ReVancedUtils.getContext() != null && settingsInitialized) {
rebootDialog(getActivity());
}
} else if (str.equals(SettingsEnum.VIDEO_ADS_SHOWN_BOOLEAN.getPath())) {
SettingsEnum.VIDEO_ADS_SHOWN_BOOLEAN.setValue(((SwitchPreference) adsSettingsPreferenceScreen.findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.VIDEO_ADS_SHOWN.getPath())) {
SettingsEnum.VIDEO_ADS_SHOWN.setValue(((SwitchPreference) adsSettingsPreferenceScreen.findPreference(str)).isChecked());
if (ReVancedUtils.getContext() != null && settingsInitialized) {
rebootDialog(getActivity());
}
} else if (str.equals(SettingsEnum.REEL_BUTTON_SHOWN_BOOLEAN.getPath())) {
SettingsEnum.REEL_BUTTON_SHOWN_BOOLEAN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.REEL_BUTTON_SHOWN.getPath())) {
SettingsEnum.REEL_BUTTON_SHOWN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked());
if (ReVancedUtils.getContext() != null && settingsInitialized) {
rebootDialog(getActivity());
}
} else if (str.equals(SettingsEnum.INFO_CARDS_SHOWN_BOOLEAN.getPath())) {
SettingsEnum.INFO_CARDS_SHOWN_BOOLEAN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.BRANDING_SHOWN_BOOLEAN.getPath())) {
SettingsEnum.BRANDING_SHOWN_BOOLEAN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.CAST_BUTTON_SHOWN_BOOLEAN.getPath())) {
SettingsEnum.CAST_BUTTON_SHOWN_BOOLEAN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.USE_TABLET_MINIPLAYER_BOOLEAN.getPath())) {
SettingsEnum.USE_TABLET_MINIPLAYER_BOOLEAN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.INFO_CARDS_SHOWN.getPath())) {
SettingsEnum.INFO_CARDS_SHOWN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.BRANDING_SHOWN.getPath())) {
SettingsEnum.BRANDING_SHOWN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.CAST_BUTTON_SHOWN.getPath())) {
SettingsEnum.CAST_BUTTON_SHOWN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.USE_TABLET_MINIPLAYER.getPath())) {
SettingsEnum.USE_TABLET_MINIPLAYER.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked());
if (ReVancedUtils.getContext() != null && settingsInitialized) {
rebootDialog(getActivity());
}
} else if (str.equals(SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.getPath())) {
} else if (str.equals(SettingsEnum.CREATE_BUTTON_SHOWN.getPath())) {
SwitchPreference switchPreference = (SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str);
SettingsEnum.CREATE_BUTTON_SHOWN_BOOLEAN.setValue(switchPreference.isChecked());
SettingsEnum.CREATE_BUTTON_SHOWN.setValue(switchPreference.isChecked());
if (ReVancedUtils.getContext() != null && settingsInitialized) {
rebootDialog(getActivity());
}
} else if (str.equals(SettingsEnum.USE_NEW_ACTIONBAR_BOOLEAN.getPath())) {
SettingsEnum.USE_NEW_ACTIONBAR_BOOLEAN.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.USE_NEW_ACTIONBAR.getPath())) {
SettingsEnum.USE_NEW_ACTIONBAR.setValue(((SwitchPreference) layoutSettingsPreferenceScreen.findPreference(str)).isChecked());
if (ReVancedUtils.getContext() != null && settingsInitialized) {
rebootDialog(getActivity());
}
} else if (str.equals(SettingsEnum.CODEC_OVERRIDE_BOOLEAN.getPath())) {
SettingsEnum.CODEC_OVERRIDE_BOOLEAN.setValue(((SwitchPreference) findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.CODEC_OVERRIDE.getPath())) {
SettingsEnum.CODEC_OVERRIDE.setValue(((SwitchPreference) findPreference(str)).isChecked());
if (ReVancedUtils.getContext() != null && settingsInitialized) {
rebootDialog(getActivity());
}
} else if (str.equals(SettingsEnum.PREFERRED_RESOLUTION_WIFI_INTEGER.getPath())) {
} else if (str.equals(SettingsEnum.PREFERRED_RESOLUTION_WIFI.getPath())) {
ListPreference listPreference2 = (ListPreference) videoSettingsPreferenceScreen.findPreference(str);
int index = SettingsEnum.PREFERRED_RESOLUTION_WIFI_INTEGER.getInt();
int index = SettingsEnum.PREFERRED_RESOLUTION_WIFI.getInt();
listPreference2.setDefaultValue(index);
listPreference2.setSummary(videoQualityEntries[listPreference2.findIndexOfValue(String.valueOf(index))]);
SettingsEnum.PREFERRED_RESOLUTION_WIFI_INTEGER.setValue(index);
} else if (str.equals(SettingsEnum.PREFERRED_RESOLUTION_MOBILE_INTEGER.getPath())) {
SettingsEnum.PREFERRED_RESOLUTION_WIFI.setValue(index);
} else if (str.equals(SettingsEnum.PREFERRED_RESOLUTION_MOBILE.getPath())) {
ListPreference listPreference2 = (ListPreference) videoSettingsPreferenceScreen.findPreference(str);
int index = SettingsEnum.PREFERRED_RESOLUTION_MOBILE_INTEGER.getInt();
int index = SettingsEnum.PREFERRED_RESOLUTION_MOBILE.getInt();
listPreference2.setDefaultValue(index);
listPreference2.setSummary(videoQualityEntries[listPreference2.findIndexOfValue(String.valueOf(index))]);
SettingsEnum.PREFERRED_RESOLUTION_MOBILE_INTEGER.setValue(index);
} else if (str.equals(SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getPath())) {
SettingsEnum.PREFERRED_RESOLUTION_MOBILE.setValue(index);
} else if (str.equals(SettingsEnum.PREFERRED_VIDEO_SPEED.getPath())) {
ListPreference listPreference4 = (ListPreference) videoSettingsPreferenceScreen.findPreference(str);
Float value = SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.getFloat();
Float value = SettingsEnum.PREFERRED_VIDEO_SPEED.getFloat();
listPreference4.setDefaultValue(value);
listPreference4.setSummary(videoSpeedEntries[listPreference4.findIndexOfValue(String.valueOf(value))]);
SettingsEnum.PREFERRED_VIDEO_SPEED_FLOAT.setValue(value);
} else if (str.equals(SettingsEnum.MAX_BUFFER_INTEGER.getPath())) {
SettingsEnum.PREFERRED_VIDEO_SPEED.setValue(value);
} else if (str.equals(SettingsEnum.MAX_BUFFER.getPath())) {
EditTextPreference editTextPreference3 = (EditTextPreference) bufferSettingsPreferenceScreen.findPreference(str);
if (editTextPreference3 != null) {
editTextPreference3.setSummary(editTextPreference3.getText());
SettingsEnum.MAX_BUFFER_INTEGER.setValue(Integer.parseInt(editTextPreference3.getText()));
SettingsEnum.MAX_BUFFER.setValue(Integer.parseInt(editTextPreference3.getText()));
}
} else if (str.equals(SettingsEnum.PLAYBACK_MAX_BUFFER_INTEGER.getPath())) {
} else if (str.equals(SettingsEnum.PLAYBACK_MAX_BUFFER.getPath())) {
EditTextPreference editTextPreference4 = (EditTextPreference) ReVancedSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference(str);
if (editTextPreference4 != null) {
editTextPreference4.setSummary(editTextPreference4.getText());
SettingsEnum.PLAYBACK_MAX_BUFFER_INTEGER.setValue(Integer.parseInt(editTextPreference4.getText()));
SettingsEnum.PLAYBACK_MAX_BUFFER.setValue(Integer.parseInt(editTextPreference4.getText()));
}
} else if (str.equals(SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER.getPath())) {
} else if (str.equals(SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER.getPath())) {
EditTextPreference editTextPreference5 = (EditTextPreference) ReVancedSettingsFragment.this.bufferSettingsPreferenceScreen.findPreference(str);
if (editTextPreference5 != null) {
editTextPreference5.setSummary(editTextPreference5.getText());
SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER_INTEGER.setValue(Integer.parseInt(editTextPreference5.getText()));
SettingsEnum.MAX_PLAYBACK_BUFFER_AFTER_REBUFFER.setValue(Integer.parseInt(editTextPreference5.getText()));
}
} else if (str.equals(SettingsEnum.USE_HDR_AUTO_BRIGHTNESS_BOOLEAN.getPath())) {
SettingsEnum.USE_HDR_AUTO_BRIGHTNESS_BOOLEAN.setValue(((SwitchPreference) miscsPreferenceScreen.findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getPath())) {
SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.setValue(((SwitchPreference) xSwipeControlPreferenceScreen.findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.getPath())) {
SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.setValue(((SwitchPreference) xSwipeControlPreferenceScreen.findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.USE_HDR_AUTO_BRIGHTNESS.getPath())) {
SettingsEnum.USE_HDR_AUTO_BRIGHTNESS.setValue(((SwitchPreference) miscsPreferenceScreen.findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.ENABLE_SWIPE_BRIGHTNESS.getPath())) {
SettingsEnum.ENABLE_SWIPE_BRIGHTNESS.setValue(((SwitchPreference) xSwipeControlPreferenceScreen.findPreference(str)).isChecked());
} else if (str.equals(SettingsEnum.ENABLE_SWIPE_VOLUME.getPath())) {
SettingsEnum.ENABLE_SWIPE_VOLUME.setValue(((SwitchPreference) xSwipeControlPreferenceScreen.findPreference(str)).isChecked());
} else if ("revanced_ryd_enabled".equals(str) && ReVancedUtils.getContext() != null && settingsInitialized) {
rebootDialog(ReVancedSettingsFragment.this.getActivity());
} else if (str.equals("pref_auto_repeat_button")) {
@ -164,10 +164,10 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
int identifier = getResources().getIdentifier("revanced_prefs", "xml", getPackageName());
addPreferencesFromResource(identifier);
String stringByName = ReVancedUtils.getStringByName(getActivity(), "quality_auto");
String stringByName = getStringByName(getActivity(), "quality_auto");
this.videoQualityEntries[0] = stringByName;
this.videoSpeedEntries[0] = stringByName;
String stringByName2 = ReVancedUtils.getStringByName(getActivity(), "pref_subtitles_scale_normal");
String stringByName2 = getStringByName(getActivity(), "pref_subtitles_scale_normal");
if (stringByName2.equals("")) {
this.videoSpeedEntries[4] = "Normal";
} else {
@ -215,22 +215,21 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
Preference findPreference = findPreference("pref_about_field");
this.codecDefault.setOnPreferenceClickListener(preference -> {
SettingsEnum.CODEC_OVERRIDE_BOOLEAN.saveValue(false);
SettingsEnum.CODEC_OVERRIDE.saveValue(false);
return false;
});
this.codecVP9.setOnPreferenceClickListener(preference -> {
SettingsEnum.CODEC_OVERRIDE_BOOLEAN.saveValue(true);
SettingsEnum.CODEC_OVERRIDE.saveValue(true);
return false;
});
if (ScreenSizeHelper.isTablet(ReVancedUtils.getContext())) {
if (ReVancedUtils.isTablet(ReVancedUtils.getContext())) {
if (this.layoutSettingsPreferenceScreen.findPreference("tablet_miniplayer") != null) {
this.layoutSettingsPreferenceScreen.removePreference(this.tabletMiniplayer);
}
}
this.sharedPreferences.edit().putBoolean("revanced_initialized", true);
this.settingsInitialized = true;
} catch (Throwable th) {
@ -312,7 +311,17 @@ public class ReVancedSettingsFragment extends PreferenceFragment {
}
private void rebootDialog(final Activity activity) {
new AlertDialog.Builder(activity).setMessage(ReVancedUtils.getStringByName(activity, "pref_refresh_config")).setPositiveButton(ReVancedUtils.getStringByName(activity, "in_app_update_restart_button"), (dialog, id) -> reboot(activity, ReVancedSettingsFragment.homeActivityClass)).setNegativeButton(ReVancedUtils.getStringByName(activity, "sign_in_cancel"), null).show();
new AlertDialog.Builder(activity).setMessage(getStringByName(activity, "pref_refresh_config")).setPositiveButton(getStringByName(activity, "in_app_update_restart_button"), (dialog, id) -> reboot(activity, ReVancedSettingsFragment.homeActivityClass)).setNegativeButton(getStringByName(activity, "sign_in_cancel"), null).show();
}
private String getStringByName(Context context, String name) {
try {
Resources res = context.getResources();
return res.getString(res.getIdentifier(name, "string", context.getPackageName()));
} catch (Throwable exception) {
LogHelper.printException(ReVancedUtils.class, "Resource not found.", exception);
return "";
}
}
}

View File

@ -27,8 +27,7 @@ import java.lang.ref.WeakReference;
import java.text.DecimalFormat;
import java.util.ArrayList;
import app.revanced.integrations.adremover.whitelist.WhitelistType;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.whitelist.WhitelistType;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
@ -59,9 +58,9 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
{
SwitchPreference preference = new SwitchPreference(context);
preferenceScreen.addPreference(preference);
preference.setKey(SettingsEnum.SB_ENABLED_BOOLEAN.getPath());
preference.setDefaultValue(SettingsEnum.SB_ENABLED_BOOLEAN.getDefaultValue());
preference.setChecked(SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean());
preference.setKey(SettingsEnum.SB_ENABLED.getPath());
preference.setDefaultValue(SettingsEnum.SB_ENABLED.getDefaultValue());
preference.setChecked(SettingsEnum.SB_ENABLED.getBoolean());
preference.setTitle(str("enable_sb"));
preference.setSummary(str("enable_sb_sum"));
preference.setOnPreferenceChangeListener((preference1, newValue) -> {
@ -72,12 +71,12 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
}
// Clear hint
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
if (SettingsEnum.DEBUG.getBoolean()) {
SwitchPreference preference = new SwitchPreference(context);
preferenceScreen.addPreference(preference);
preference.setKey(SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN_BOOLEAN.getPath());
preference.setKey(SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN.getPath());
preference.setDefaultValue(false);
preference.setChecked(SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN_BOOLEAN.getBoolean());
preference.setChecked(SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN.getBoolean());
preference.setTitle("Hint debug");
preference.setSummary("Debug toggle for clearing the hint shown preference");
preference.setOnPreferenceChangeListener((pref, newValue) -> true);
@ -86,15 +85,15 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
{
SwitchPreference preference = new SwitchPreference(context);
preferenceScreen.addPreference(preference);
preference.setKey(SettingsEnum.SB_NEW_SEGMENT_ENABLED_BOOLEAN.getPath());
preference.setDefaultValue(SettingsEnum.SB_NEW_SEGMENT_ENABLED_BOOLEAN.getBoolean());
preference.setChecked(SettingsEnum.SB_NEW_SEGMENT_ENABLED_BOOLEAN.getBoolean());
preference.setKey(SettingsEnum.SB_NEW_SEGMENT_ENABLED.getPath());
preference.setDefaultValue(SettingsEnum.SB_NEW_SEGMENT_ENABLED.getBoolean());
preference.setChecked(SettingsEnum.SB_NEW_SEGMENT_ENABLED.getBoolean());
preference.setTitle(str("enable_segmadding"));
preference.setSummary(str("enable_segmadding_sum"));
preferencesToDisableWhenSBDisabled.add(preference);
preference.setOnPreferenceChangeListener((preference12, o) -> {
final boolean value = (Boolean) o;
if (value && !SettingsEnum.SB_SEEN_GUIDELINES_BOOLEAN.getBoolean()) {
if (value && !SettingsEnum.SB_SEEN_GUIDELINES.getBoolean()) {
new AlertDialog.Builder(preference12.getContext())
.setTitle(str("sb_guidelines_popup_title"))
.setMessage(str("sb_guidelines_popup_content"))
@ -111,9 +110,9 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
preferenceScreen.addPreference(preference);
preference.setTitle(str("enable_voting"));
preference.setSummary(str("enable_voting_sum"));
preference.setKey(SettingsEnum.SB_VOTING_ENABLED_BOOLEAN.getPath());
preference.setDefaultValue(SettingsEnum.SB_VOTING_ENABLED_BOOLEAN.getBoolean());
preference.setChecked(SettingsEnum.SB_VOTING_ENABLED_BOOLEAN.getBoolean());
preference.setKey(SettingsEnum.SB_VOTING_ENABLED.getPath());
preference.setDefaultValue(SettingsEnum.SB_VOTING_ENABLED.getBoolean());
preference.setChecked(SettingsEnum.SB_VOTING_ENABLED.getBoolean());
preferencesToDisableWhenSBDisabled.add(preference);
}
@ -122,12 +121,12 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
addStatsCategory(context, preferenceScreen);
addAboutCategory(context, preferenceScreen);
enableCategoriesIfNeeded(SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean());
enableCategoriesIfNeeded(SettingsEnum.SB_ENABLED.getBoolean());
}
private void openGuidelines() {
final Context context = getActivity();
SettingsEnum.SB_SEEN_GUIDELINES_BOOLEAN.saveValue(true);
SettingsEnum.SB_SEEN_GUIDELINES.saveValue(true);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://wiki.sponsor.ajay.app/w/Guidelines"));
@ -243,8 +242,8 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
Preference preference = new SwitchPreference(context);
preference.setTitle(str("general_skiptoast"));
preference.setSummary(str("general_skiptoast_sum"));
preference.setKey(SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP_BOOLEAN.getPath());
preference.setDefaultValue(SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP_BOOLEAN.getBoolean());
preference.setKey(SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP.getPath());
preference.setDefaultValue(SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP.getBoolean());
preference.setOnPreferenceClickListener(preference12 -> {
Toast.makeText(preference12.getContext(), str("skipped_sponsor"), Toast.LENGTH_SHORT).show();
return false;
@ -257,8 +256,8 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
Preference preference = new SwitchPreference(context);
preference.setTitle(str("general_skipcount"));
preference.setSummary(str("general_skipcount_sum"));
preference.setKey(SettingsEnum.SB_COUNT_SKIPS_BOOLEAN.getPath());
preference.setDefaultValue(SettingsEnum.SB_COUNT_SKIPS_BOOLEAN.getBoolean());
preference.setKey(SettingsEnum.SB_COUNT_SKIPS.getPath());
preference.setDefaultValue(SettingsEnum.SB_COUNT_SKIPS.getBoolean());
preferencesToDisableWhenSBDisabled.add(preference);
screen.addPreference(preference);
}
@ -267,8 +266,8 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
Preference preference = new SwitchPreference(context);
preference.setTitle(str("general_time_without_sb"));
preference.setSummary(str("general_time_without_sb_sum"));
preference.setKey(SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS_BOOLEAN.getPath());
preference.setDefaultValue(SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS_BOOLEAN.getBoolean());
preference.setKey(SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS.getPath());
preference.setDefaultValue(SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS.getBoolean());
preferencesToDisableWhenSBDisabled.add(preference);
screen.addPreference(preference);
}
@ -286,8 +285,8 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
Preference preference = new SwitchPreference(context);
preference.setTitle(str("general_browser_button"));
preference.setSummary(str("general_browser_button_sum"));
preference.setKey(SettingsEnum.SB_SHOW_BROWSER_BUTTON_BOOLEAN.getPath());
preference.setDefaultValue(SettingsEnum.SB_SHOW_BROWSER_BUTTON_BOOLEAN.getBoolean());
preference.setKey(SettingsEnum.SB_SHOW_BROWSER_BUTTON.getPath());
preference.setDefaultValue(SettingsEnum.SB_SHOW_BROWSER_BUTTON.getBoolean());
preferencesToDisableWhenSBDisabled.add(preference);
screen.addPreference(preference);
}
@ -297,8 +296,8 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
preference.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
preference.setTitle(str("general_adjusting"));
preference.setSummary(str("general_adjusting_sum"));
preference.setKey(SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP_INTEGER.getPath());
preference.setDefaultValue(SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP_INTEGER.getInt());
preference.setKey(SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP.getPath());
preference.setDefaultValue(SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP.getInt());
screen.addPreference(preference);
preferencesToDisableWhenSBDisabled.add(preference);
}
@ -308,8 +307,8 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
preference.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
preference.setTitle(str("general_min_duration"));
preference.setSummary(str("general_min_duration_sum"));
preference.setKey(SettingsEnum.SB_MIN_DURATION_FLOAT.getPath());
preference.setDefaultValue(SettingsEnum.SB_MIN_DURATION_FLOAT.getFloat());
preference.setKey(SettingsEnum.SB_MIN_DURATION.getPath());
preference.setDefaultValue(SettingsEnum.SB_MIN_DURATION.getFloat());
screen.addPreference(preference);
preferencesToDisableWhenSBDisabled.add(preference);
}
@ -318,8 +317,8 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
Preference preference = new EditTextPreference(context);
preference.setTitle(str("general_uuid"));
preference.setSummary(str("general_uuid_sum"));
preference.setKey(SettingsEnum.SB_UUID_STRING.getPath());
preference.setDefaultValue(SettingsEnum.SB_UUID_STRING.getString());
preference.setKey(SettingsEnum.SB_UUID.getPath());
preference.setDefaultValue(SettingsEnum.SB_UUID.getString());
screen.addPreference(preference);
preferencesToDisableWhenSBDisabled.add(preference);
}
@ -332,7 +331,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
preference.setOnPreferenceClickListener(preference1 -> {
EditText editText = new EditText(context);
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
editText.setText(SettingsEnum.SB_API_URL_STRING.getString());
editText.setText(SettingsEnum.SB_API_URL.getString());
API_URL_CHANGE_LISTENER.setEditTextRef(editText);
new AlertDialog.Builder(context)
@ -379,7 +378,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
switch (which) {
case DialogInterface.BUTTON_NEUTRAL:
SettingsEnum.SB_API_URL_STRING.saveValue(SettingsEnum.SB_API_URL_STRING.getDefaultValue());
SettingsEnum.SB_API_URL.saveValue(SettingsEnum.SB_API_URL.getDefaultValue());
Toast.makeText(applicationContext, str("api_url_reset"), Toast.LENGTH_SHORT).show();
break;
case DialogInterface.BUTTON_POSITIVE:
@ -392,7 +391,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
if (textAsString.isEmpty() || !Patterns.WEB_URL.matcher(textAsString).matches()) {
invalidToast.show();
} else {
SettingsEnum.SB_API_URL_STRING.saveValue(textAsString);
SettingsEnum.SB_API_URL.saveValue(textAsString);
Toast.makeText(applicationContext, str("api_url_changed"), Toast.LENGTH_SHORT).show();
}
}

View File

@ -24,11 +24,10 @@ import java.util.TimerTask;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.player.VideoInformation;
import app.revanced.integrations.adremover.whitelist.Whitelist;
import app.revanced.integrations.whitelist.Whitelist;
import app.revanced.integrations.sponsorblock.objects.SponsorSegment;
import app.revanced.integrations.sponsorblock.requests.SBRequester;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.SharedPrefHelper;
@SuppressLint({"LongLogTag"})
public class PlayerController {
@ -64,7 +63,7 @@ public class PlayerController {
Context context = ReVancedUtils.getContext();
SponsorBlockSettings.update(context);
if (!SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean()) {
if (!SettingsEnum.SB_ENABLED.getBoolean()) {
currentVideoId = null;
return;
}
@ -135,7 +134,7 @@ public class PlayerController {
public static void setCurrentVideoTime(long millis) {
LogHelper.debug(PlayerController.class, "setCurrentVideoTime: current video time: " + millis);
VideoInformation.lastKnownVideoTime = millis;
if (!SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean()) return;
if (!SettingsEnum.SB_ENABLED.getBoolean()) return;
lastKnownVideoTime = millis;
if (millis <= 0) return;
//findAndSkipSegment(false);
@ -198,13 +197,13 @@ public class PlayerController {
if (segment.category != SponsorBlockSettings.SegmentInfo.UNSUBMITTED) {
Context context = ReVancedUtils.getContext();
if (context != null) {
long newSkippedTime = SettingsEnum.SB_SKIPPED_SEGMENTS_TIME_LONG.getLong() + (segment.end - segment.start);
SettingsEnum.SB_SKIPPED_SEGMENTS_INTEGER.saveValue(SettingsEnum.SB_SKIPPED_SEGMENTS_INTEGER.getInt() + 1);
SettingsEnum.SB_SKIPPED_SEGMENTS_TIME_LONG.saveValue(newSkippedTime);
long newSkippedTime = SettingsEnum.SB_SKIPPED_SEGMENTS_TIME.getLong() + (segment.end - segment.start);
SettingsEnum.SB_SKIPPED_SEGMENTS.saveValue(SettingsEnum.SB_SKIPPED_SEGMENTS.getInt() + 1);
SettingsEnum.SB_SKIPPED_SEGMENTS_TIME.saveValue(newSkippedTime);
}
}
new Thread(() -> {
if (SettingsEnum.SB_COUNT_SKIPS_BOOLEAN.getBoolean() &&
if (SettingsEnum.SB_COUNT_SKIPS.getBoolean() &&
segment.category != SponsorBlockSettings.SegmentInfo.UNSUBMITTED &&
millis - segment.start < 2000) {
// Only skips from the start should count as a view
@ -417,7 +416,7 @@ public class PlayerController {
// lastSkippedSegment = segment;
LogHelper.debug(PlayerController.class, "Skipping segment: " + segment.toString());
if (SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP_BOOLEAN.getBoolean() && !wasClicked)
if (SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP.getBoolean() && !wasClicked)
SkipSegmentView.notifySkipped(segment);
skipToMillisecond(segment.end + 2);

View File

@ -97,7 +97,7 @@ public class ShieldButton {
}
static boolean shouldBeShown() {
return SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean() && SettingsEnum.SB_NEW_SEGMENT_ENABLED_BOOLEAN.getBoolean();
return SettingsEnum.SB_ENABLED.getBoolean() && SettingsEnum.SB_NEW_SEGMENT_ENABLED.getBoolean();
}
//region Helpers

View File

@ -30,7 +30,7 @@ public class SponsorBlockSettings {
SharedPreferences preferences = SharedPrefHelper.getPreferences(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK);
if (!SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean()) {
if (!SettingsEnum.SB_ENABLED.getBoolean()) {
SkipSegmentView.hide();
NewSegmentHelperLayout.hide();
SponsorBlockUtils.hideShieldButton();
@ -40,7 +40,7 @@ public class SponsorBlockSettings {
SponsorBlockUtils.showShieldButton();
}
if (!SettingsEnum.SB_NEW_SEGMENT_ENABLED_BOOLEAN.getBoolean()) {
if (!SettingsEnum.SB_NEW_SEGMENT_ENABLED.getBoolean()) {
NewSegmentHelperLayout.hide();
SponsorBlockUtils.hideShieldButton();
} else {
@ -48,7 +48,7 @@ public class SponsorBlockSettings {
}
if (!SettingsEnum.SB_VOTING_ENABLED_BOOLEAN.getBoolean())
if (!SettingsEnum.SB_VOTING_ENABLED.getBoolean())
SponsorBlockUtils.hideVoteButton();
else
SponsorBlockUtils.showVoteButton();
@ -85,13 +85,13 @@ public class SponsorBlockSettings {
else
sponsorBlockUrlCategories = "[%22" + TextUtils.join("%22,%22", enabledCategories) + "%22]";
String uuid = SettingsEnum.SB_UUID_STRING.getString();
String uuid = SettingsEnum.SB_UUID.getString();
if (uuid == null) {
uuid = (UUID.randomUUID().toString() +
UUID.randomUUID().toString() +
UUID.randomUUID().toString())
.replace("-", "");
SettingsEnum.SB_UUID_STRING.saveValue(uuid);
SettingsEnum.SB_UUID.saveValue(uuid);
}
}

View File

@ -43,7 +43,6 @@ import java.util.List;
import java.util.Objects;
import java.util.TimeZone;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.sponsorblock.player.PlayerType;
import app.revanced.integrations.utils.LogHelper;
@ -202,7 +201,7 @@ public abstract class SponsorBlockUtils {
for (int i = 0; i < voteOptions.length; i++) {
VoteOption voteOption = voteOptions[i];
String title = voteOption.title;
if (SettingsEnum.SB_IS_VIP_BOOLEAN.getBoolean() && segment.isLocked && voteOption.shouldHighlight) {
if (SettingsEnum.SB_IS_VIP.getBoolean() && segment.isLocked && voteOption.shouldHighlight) {
items[i] = Html.fromHtml(String.format("<font color=\"%s\">%s</font>", LOCKED_COLOR, title));
} else {
items[i] = title;
@ -227,7 +226,7 @@ public abstract class SponsorBlockUtils {
};
private static final Runnable submitRunnable = () -> {
messageToToast = null;
final String uuid = SettingsEnum.SB_UUID_STRING.getString();
final String uuid = SettingsEnum.SB_UUID.getString();
final long start = newSponsorSegmentStartMillis;
final long end = newSponsorSegmentEndMillis;
final String videoId = getCurrentVideoId();
@ -404,7 +403,7 @@ public abstract class SponsorBlockUtils {
}
public static String appendTimeWithoutSegments(String totalTime) {
if (videoHasSegments && (SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean() && SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS_BOOLEAN.getBoolean()) && !TextUtils.isEmpty(totalTime) && getCurrentVideoLength() > 1) {
if (videoHasSegments && (SettingsEnum.SB_ENABLED.getBoolean() && SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS.getBoolean()) && !TextUtils.isEmpty(totalTime) && getCurrentVideoLength() > 1) {
if (timeWithoutSegments.isEmpty()) {
timeWithoutSegments = getTimeWithoutSegments(sponsorSegmentsOfCurrentVideo);
}
@ -416,7 +415,7 @@ public abstract class SponsorBlockUtils {
public static String getTimeWithoutSegments(SponsorSegment[] sponsorSegmentsOfCurrentVideo) {
long currentVideoLength = getCurrentVideoLength();
if (!(SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean() && SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS_BOOLEAN.getBoolean()) || sponsorSegmentsOfCurrentVideo == null || currentVideoLength <= 1) {
if (!(SettingsEnum.SB_ENABLED.getBoolean() && SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS.getBoolean()) || sponsorSegmentsOfCurrentVideo == null || currentVideoLength <= 1) {
return "";
}
long timeWithoutSegments = currentVideoLength + 500; // YouTube:tm:
@ -496,10 +495,10 @@ public abstract class SponsorBlockUtils {
{
Preference preference = new Preference(context);
category.addPreference(preference);
String formatted = FORMATTER.format(SettingsEnum.SB_SKIPPED_SEGMENTS_INTEGER.getInt());
String formatted = FORMATTER.format(SettingsEnum.SB_SKIPPED_SEGMENTS.getInt());
long hoursSaved = SettingsEnum.SB_SKIPPED_SEGMENTS_TIME_LONG.getLong() / 3600000;
double minutesSaved = (SettingsEnum.SB_SKIPPED_SEGMENTS_TIME_LONG.getLong() / 60000d) % 60;
long hoursSaved = SettingsEnum.SB_SKIPPED_SEGMENTS_TIME.getLong() / 3600000;
double minutesSaved = (SettingsEnum.SB_SKIPPED_SEGMENTS_TIME.getLong() / 60000d) % 60;
String formattedSaved = String.format(SAVED_TEMPLATE, hoursSaved, minutesSaved, minutesStr);
preference.setTitle(fromHtml(str("stats_self_saved", formatted)));
@ -542,20 +541,20 @@ public abstract class SponsorBlockUtils {
editor.putString(category.key, behaviour.key);
}
SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP_BOOLEAN.saveValue(!settingsJson.getBoolean("dontShowNotice"));
SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS_BOOLEAN.saveValue(settingsJson.getBoolean("showTimeWithSkips"));
SettingsEnum.SB_COUNT_SKIPS_BOOLEAN.saveValue(settingsJson.getBoolean("trackViewCount"));
SettingsEnum.SB_IS_VIP_BOOLEAN.saveValue(settingsJson.getBoolean("isVip"));
SettingsEnum.SB_MIN_DURATION_FLOAT.saveValue(Float.valueOf(settingsJson.getString("minDuration")));
SettingsEnum.SB_UUID_STRING.saveValue(settingsJson.getString("userID"));
SettingsEnum.SB_LAST_VIP_CHECK_LONG.saveValue(settingsJson.getLong("lastIsVipUpdate"));
SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP.saveValue(!settingsJson.getBoolean("dontShowNotice"));
SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS.saveValue(settingsJson.getBoolean("showTimeWithSkips"));
SettingsEnum.SB_COUNT_SKIPS.saveValue(settingsJson.getBoolean("trackViewCount"));
SettingsEnum.SB_IS_VIP.saveValue(settingsJson.getBoolean("isVip"));
SettingsEnum.SB_MIN_DURATION.saveValue(Float.valueOf(settingsJson.getString("minDuration")));
SettingsEnum.SB_UUID.saveValue(settingsJson.getString("userID"));
SettingsEnum.SB_LAST_VIP_CHECK.saveValue(settingsJson.getLong("lastIsVipUpdate"));
String serverAddress = settingsJson.getString("serverAddress");
if (serverAddress.equalsIgnoreCase("https://sponsor.ajay.app")) {
serverAddress = (String) SettingsEnum.SB_API_URL_STRING.getDefaultValue();
serverAddress = (String) SettingsEnum.SB_API_URL.getDefaultValue();
}
SettingsEnum.SB_API_URL_STRING.saveValue(serverAddress);
SettingsEnum.SB_API_URL.saveValue(serverAddress);
Toast.makeText(context, str("settings_import_successful"), Toast.LENGTH_SHORT).show();
} catch (Exception ex) {
@ -586,16 +585,16 @@ public abstract class SponsorBlockUtils {
categorySelectionsArray.put(behaviorObject);
}
}
json.put("dontShowNotice", !SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP_BOOLEAN.getBoolean());
json.put("dontShowNotice", !SettingsEnum.SB_SHOW_TOAST_WHEN_SKIP.getBoolean());
json.put("barTypes", barTypesObject);
json.put("showTimeWithSkips", SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS_BOOLEAN.getBoolean());
json.put("minDuration", SettingsEnum.SB_MIN_DURATION_FLOAT.getFloat());
json.put("trackViewCount", SettingsEnum.SB_COUNT_SKIPS_BOOLEAN.getBoolean());
json.put("showTimeWithSkips", SettingsEnum.SB_SHOW_TIME_WITHOUT_SEGMENTS.getBoolean());
json.put("minDuration", SettingsEnum.SB_MIN_DURATION.getFloat());
json.put("trackViewCount", SettingsEnum.SB_COUNT_SKIPS.getBoolean());
json.put("categorySelections", categorySelectionsArray);
json.put("userID", SettingsEnum.SB_UUID_STRING.getString());
json.put("isVip", SettingsEnum.SB_IS_VIP_BOOLEAN.getBoolean());
json.put("lastIsVipUpdate", SettingsEnum.SB_LAST_VIP_CHECK_LONG.getLong());
json.put("serverAddress", SettingsEnum.SB_API_URL_STRING.getString());
json.put("userID", SettingsEnum.SB_UUID.getString());
json.put("isVip", SettingsEnum.SB_IS_VIP.getBoolean());
json.put("lastIsVipUpdate", SettingsEnum.SB_LAST_VIP_CHECK.getLong());
json.put("serverAddress", SettingsEnum.SB_API_URL.getString());
return json.toString();
} catch (Exception ex) {
@ -606,7 +605,7 @@ public abstract class SponsorBlockUtils {
}
public static boolean isSBButtonEnabled(Context context, String key) {
return SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean() && SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, key, false);
return SettingsEnum.SB_ENABLED.getBoolean() && SharedPrefHelper.getBoolean(context, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, key, false);
}
public enum VoteOption {

View File

@ -1,4 +1,4 @@
package app.revanced.integrations.utils;
package app.revanced.integrations.sponsorblock;
import android.content.Context;
import android.content.res.Resources;
@ -8,6 +8,9 @@ import android.view.ViewGroup;
import android.widget.FrameLayout;
import app.revanced.integrations.sponsorblock.player.PlayerType;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.SharedPrefHelper;
/* loaded from: classes6.dex */
public class SwipeHelper {
@ -19,7 +22,7 @@ public class SwipeHelper {
try {
_frameLayout = (FrameLayout) obj;
Context appContext = ReVancedUtils.getContext();
if (ScreenSizeHelper.isTablet(appContext) || SharedPrefHelper.getBoolean(appContext, SharedPrefHelper.SharedPrefNames.YOUTUBE,"pref_xfenster_tablet", false)) {
if (ReVancedUtils.isTablet(appContext) || SharedPrefHelper.getBoolean(appContext, SharedPrefHelper.SharedPrefNames.YOUTUBE,"pref_xfenster_tablet", false)) {
isTabletMode = true;
}
} catch (Exception e) {

View File

@ -94,7 +94,7 @@ public class VotingButton {
}
static boolean shouldBeShown() {
return SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean() && SettingsEnum.SB_VOTING_ENABLED_BOOLEAN.getBoolean();
return SettingsEnum.SB_ENABLED.getBoolean() && SettingsEnum.SB_VOTING_ENABLED.getBoolean();
}
//region Helpers

View File

@ -22,14 +22,14 @@ public class Dialogs {
private static void sbFirstRun(Activity activity) {
Context context = ReVancedUtils.getContext();
boolean enabled = SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean();
boolean hintShown = SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN_BOOLEAN.getBoolean();
boolean enabled = SettingsEnum.SB_ENABLED.getBoolean();
boolean hintShown = SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN.getBoolean();
// If SB is enabled or hint has been shown, exit
if (enabled || hintShown) {
// If SB is enabled but hint hasn't been shown, mark it as shown
if (enabled && !hintShown) {
SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN_BOOLEAN.saveValue(true);
SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN.saveValue(true);
}
return;
}
@ -46,15 +46,15 @@ public class Dialogs {
builder.setMessage(str("vanced_sb_firstrun"));
builder.setPositiveButton(str("vanced_enable"),
(dialog, id) -> {
SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN_BOOLEAN.saveValue(true);
SettingsEnum.SB_ENABLED_BOOLEAN.saveValue(true);
SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN.saveValue(true);
SettingsEnum.SB_ENABLED.saveValue(true);
dialog.dismiss();
});
builder.setNegativeButton(str("vanced_disable"),
(dialog, id) -> {
SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN_BOOLEAN.saveValue(true);
SettingsEnum.SB_ENABLED_BOOLEAN.saveValue(false);
SettingsEnum.SB_SPONSOR_BLOCK_HINT_SHOWN.saveValue(true);
SettingsEnum.SB_ENABLED.saveValue(false);
dialog.dismiss();
});

View File

@ -11,9 +11,9 @@ import android.widget.ImageView;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.player.VideoInformation;
import app.revanced.integrations.adremover.whitelist.Whitelist;
import app.revanced.integrations.adremover.whitelist.WhitelistType;
import app.revanced.integrations.adremover.whitelist.requests.WhitelistRequester;
import app.revanced.integrations.whitelist.Whitelist;
import app.revanced.integrations.whitelist.WhitelistType;
import app.revanced.integrations.whitelist.requests.WhitelistRequester;
import app.revanced.integrations.utils.SharedPrefHelper;
import app.revanced.integrations.utils.ReVancedUtils;

View File

@ -70,7 +70,7 @@ public class NewSegmentLayout extends FrameLayout {
@Override
public void onClick(View v) {
LogHelper.debug(NewSegmentLayout.class, "Rewind button clicked");
PlayerController.skipRelativeMilliseconds(-SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP_INTEGER.getInt());
PlayerController.skipRelativeMilliseconds(-SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP.getInt());
}
});
}
@ -81,7 +81,7 @@ public class NewSegmentLayout extends FrameLayout {
@Override
public void onClick(View v) {
LogHelper.debug(NewSegmentLayout.class, "Forward button clicked");
PlayerController.skipRelativeMilliseconds(SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP_INTEGER.getInt());
PlayerController.skipRelativeMilliseconds(SettingsEnum.SB_ADJUST_NEW_SEGMENT_STEP.getInt());
}
});
}

View File

@ -19,7 +19,7 @@ public class SBBrowserButton extends SlimButton {
public SBBrowserButton(Context context, ViewGroup container) {
super(context, container, SLIM_METADATA_BUTTON_ID,
SponsorBlockUtils.isSBButtonEnabled(context, SettingsEnum.SB_SHOW_BROWSER_BUTTON_BOOLEAN.getPath()));
SponsorBlockUtils.isSBButtonEnabled(context, SettingsEnum.SB_SHOW_BROWSER_BUTTON.getPath()));
initialize();
}

View File

@ -11,9 +11,9 @@ import android.widget.ImageView;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.player.VideoInformation;
import app.revanced.integrations.adremover.whitelist.Whitelist;
import app.revanced.integrations.adremover.whitelist.WhitelistType;
import app.revanced.integrations.adremover.whitelist.requests.WhitelistRequester;
import app.revanced.integrations.whitelist.Whitelist;
import app.revanced.integrations.whitelist.WhitelistType;
import app.revanced.integrations.whitelist.requests.WhitelistRequester;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.sponsorblock.SponsorBlockUtils;

View File

@ -9,8 +9,8 @@ import android.view.ViewGroup;
import com.google.android.apps.youtube.app.ui.SlimMetadataScrollableButtonContainerLayout;
import app.revanced.integrations.adremover.whitelist.Whitelist;
import app.revanced.integrations.adremover.whitelist.WhitelistType;
import app.revanced.integrations.whitelist.Whitelist;
import app.revanced.integrations.whitelist.WhitelistType;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.SharedPrefHelper;
@ -76,9 +76,9 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
copyWithTimestampButton.setVisible(ButtonVisibility.isVisibleInContainer(context, "pref_copy_video_url_timestamp_button_list"));
return;
}
if (SettingsEnum.SB_ENABLED_BOOLEAN.getPath().equals(key)) {
if (SettingsEnum.SB_ENABLED.getPath().equals(key)) {
if (sbWhitelistButton != null) {
if (SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean()) {
if (SettingsEnum.SB_ENABLED.getBoolean()) {
toggleWhitelistButton();
} else {
Whitelist.setEnabled(WhitelistType.SPONSORBLOCK, false);
@ -86,14 +86,14 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
}
}
if (sbBrowserButton != null) {
if (SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean()) {
if (SettingsEnum.SB_ENABLED.getBoolean()) {
toggleBrowserButton();
} else {
sbBrowserButton.setVisible(false);
}
}
}
if (SettingsEnum.SB_SHOW_BROWSER_BUTTON_BOOLEAN.getPath().equals(key) && sbBrowserButton != null) {
if (SettingsEnum.SB_SHOW_BROWSER_BUTTON.getPath().equals(key) && sbBrowserButton != null) {
toggleBrowserButton();
return;
}
@ -129,6 +129,6 @@ public class SlimButtonContainer extends SlimMetadataScrollableButtonContainerLa
}
private void toggleBrowserButton() {
sbBrowserButton.setVisible(SettingsEnum.SB_SHOW_BROWSER_BUTTON_BOOLEAN.getBoolean());
sbBrowserButton.setVisible(SettingsEnum.SB_SHOW_BROWSER_BUTTON.getBoolean());
}
}

View File

@ -11,7 +11,7 @@ import java.lang.ref.WeakReference;
import app.revanced.integrations.sponsorblock.player.PlayerType;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.SwipeHelper;
import app.revanced.integrations.sponsorblock.SwipeHelper;
public class SponsorBlockView {

View File

@ -16,16 +16,14 @@ import org.json.JSONArray;
import org.json.JSONObject;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.HttpURLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import app.revanced.integrations.adremover.whitelist.requests.Requester;
import app.revanced.integrations.adremover.whitelist.requests.Route;
import app.revanced.integrations.whitelist.requests.Requester;
import app.revanced.integrations.whitelist.requests.Route;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.sponsorblock.PlayerController;
import app.revanced.integrations.sponsorblock.SponsorBlockSettings;
@ -33,8 +31,6 @@ import app.revanced.integrations.sponsorblock.SponsorBlockUtils;
import app.revanced.integrations.sponsorblock.SponsorBlockUtils.VoteOption;
import app.revanced.integrations.sponsorblock.objects.SponsorSegment;
import app.revanced.integrations.sponsorblock.objects.UserStats;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.SharedPrefHelper;
public class SBRequester {
private static final String TIME_TEMPLATE = "%.3f";
@ -58,7 +54,7 @@ public class SBRequester {
long start = (long) (segment.getDouble(0) * 1000);
long end = (long) (segment.getDouble(1) * 1000);
long minDuration = (long) (SettingsEnum.SB_MIN_DURATION_FLOAT.getFloat() * 1000);
long minDuration = (long) (SettingsEnum.SB_MIN_DURATION.getFloat() * 1000);
if ((end - start) < minDuration)
continue;
@ -129,7 +125,7 @@ public class SBRequester {
new Thread(() -> {
try {
String segmentUuid = segment.UUID;
String uuid = SettingsEnum.SB_UUID_STRING.getString();
String uuid = SettingsEnum.SB_UUID.getString();
String vote = Integer.toString(voteOption == VoteOption.UPVOTE ? 1 : 0);
runOnMainThread(() -> Toast.makeText(context, str("vote_started"), Toast.LENGTH_SHORT).show());
@ -159,14 +155,14 @@ public class SBRequester {
}
public static void retrieveUserStats(PreferenceCategory category, Preference loadingPreference) {
if (!SettingsEnum.SB_ENABLED_BOOLEAN.getBoolean()) {
if (!SettingsEnum.SB_ENABLED.getBoolean()) {
loadingPreference.setTitle(str("stats_sb_disabled"));
return;
}
new Thread(() -> {
try {
JSONObject json = getJSONObject(SBRoutes.GET_USER_STATS, SettingsEnum.SB_UUID_STRING.getString());
JSONObject json = getJSONObject(SBRoutes.GET_USER_STATS, SettingsEnum.SB_UUID.getString());
UserStats stats = new UserStats(json.getString("userName"), json.getDouble("minutesSaved"), json.getInt("segmentCount"),
json.getInt("viewCount"));
SponsorBlockUtils.addUserStats(category, loadingPreference, stats);
@ -179,7 +175,7 @@ public class SBRequester {
public static void setUsername(String username, EditTextPreference preference, Runnable toastRunnable) {
new Thread(() -> {
try {
HttpURLConnection connection = getConnectionFromRoute(SBRoutes.CHANGE_USERNAME, SettingsEnum.SB_UUID_STRING.getString(), username);
HttpURLConnection connection = getConnectionFromRoute(SBRoutes.CHANGE_USERNAME, SettingsEnum.SB_UUID.getString(), username);
int responseCode = connection.getResponseCode();
if (responseCode == 200) {
@ -201,14 +197,14 @@ public class SBRequester {
public static void runVipCheck() {
long now = System.currentTimeMillis();
if (now < (SettingsEnum.SB_LAST_VIP_CHECK_LONG.getLong() + TimeUnit.DAYS.toMillis(3))) {
if (now < (SettingsEnum.SB_LAST_VIP_CHECK.getLong() + TimeUnit.DAYS.toMillis(3))) {
return;
}
try {
JSONObject json = getJSONObject(SBRoutes.IS_USER_VIP, SettingsEnum.SB_UUID_STRING.getString());
JSONObject json = getJSONObject(SBRoutes.IS_USER_VIP, SettingsEnum.SB_UUID.getString());
boolean vip = json.getBoolean("vip");
SettingsEnum.SB_IS_VIP_BOOLEAN.saveValue(vip);
SettingsEnum.SB_LAST_VIP_CHECK_LONG.saveValue(now);
SettingsEnum.SB_IS_VIP.saveValue(vip);
SettingsEnum.SB_LAST_VIP_CHECK.saveValue(now);
} catch (Exception ex) {
ex.printStackTrace();
}
@ -217,7 +213,7 @@ public class SBRequester {
// helpers
private static HttpURLConnection getConnectionFromRoute(Route route, String... params) throws IOException {
return Requester.getConnectionFromRoute(SettingsEnum.SB_API_URL_STRING.getString(), route, params);
return Requester.getConnectionFromRoute(SettingsEnum.SB_API_URL.getString(), route, params);
}
private static JSONObject getJSONObject(Route route, String... params) throws Exception {

View File

@ -1,9 +1,9 @@
package app.revanced.integrations.sponsorblock.requests;
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.GET;
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.POST;
import static app.revanced.integrations.whitelist.requests.Route.Method.GET;
import static app.revanced.integrations.whitelist.requests.Route.Method.POST;
import app.revanced.integrations.adremover.whitelist.requests.Route;
import app.revanced.integrations.whitelist.requests.Route;
public class SBRoutes {
public static final Route IS_USER_VIP = new Route(GET, "isUserVIP?userID={user_id}");

View File

@ -11,7 +11,7 @@ import app.revanced.integrations.shared.PlayerType
* @param context the context to create in
*/
class SwipeControlsConfigurationProvider(
private val context: Context
private val context: Context
) {
//region swipe enable
/**
@ -24,13 +24,13 @@ class SwipeControlsConfigurationProvider(
* should swipe controls for volume be enabled?
*/
val enableVolumeControls: Boolean
get() = SettingsEnum.ENABLE_SWIPE_VOLUME_BOOLEAN.boolean
get() = SettingsEnum.ENABLE_SWIPE_VOLUME.boolean
/**
* should swipe controls for volume be enabled?
*/
val enableBrightnessControl: Boolean
get() = SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.boolean
get() = SettingsEnum.ENABLE_SWIPE_BRIGHTNESS.boolean
/**
* is the video player currently in fullscreen mode?
@ -44,13 +44,14 @@ class SwipeControlsConfigurationProvider(
* should press-to-swipe be enabled?
*/
val shouldEnablePressToSwipe: Boolean
get() = SettingsEnum.ENABLE_PRESS_TO_SWIPE_BOOLEAN.boolean
get() = SettingsEnum.ENABLE_PRESS_TO_SWIPE.boolean
/**
* threshold for swipe detection
* this may be called rapidly in onScroll, so we have to load it once and then leave it constant
*/
val swipeMagnitudeThreshold: Float = SettingsEnum.SWIPE_MAGNITUDE_THRESHOLD_FLOAT.float
val swipeMagnitudeThreshold: Float
get() = SettingsEnum.SWIPE_MAGNITUDE_THRESHOLD.float
//endregion
//region overlay adjustments
@ -59,25 +60,25 @@ class SwipeControlsConfigurationProvider(
* should the overlay enable haptic feedback?
*/
val shouldEnableHapticFeedback: Boolean
get() = SettingsEnum.ENABLE_SWIPE_HAPTIC_FEEDBACK_BOOLEAN.boolean
get() = SettingsEnum.ENABLE_SWIPE_HAPTIC_FEEDBACK.boolean
/**
* how long the overlay should be shown on changes
*/
val overlayShowTimeoutMillis: Long
get() = SettingsEnum.SWIPE_OVERLAY_TIMEOUT_LONG.long
get() = SettingsEnum.SWIPE_OVERLAY_TIMEOUT.long
/**
* text size for the overlay, in sp
*/
val overlayTextSize: Float
get() = SettingsEnum.SWIPE_OVERLAY_TEXT_SIZE_FLOAT.float
get() = SettingsEnum.SWIPE_OVERLAY_TEXT_SIZE.float
/**
* get the background color for text on the overlay, as a color int
*/
val overlayTextBackgroundColor: Int
get() = Color.argb(SettingsEnum.SWIPE_OVERLAY_BACKGROUND_ALPHA_INTEGER.int, 0, 0, 0)
get() = Color.argb(SettingsEnum.SWIPE_OVERLAY_BACKGROUND_ALPHA.int, 0, 0, 0)
/**
* get the foreground color for text on the overlay, as a color int

View File

@ -2,7 +2,6 @@ package app.revanced.integrations.utils;
import android.util.Log;
import app.revanced.integrations.settings.Settings;
import app.revanced.integrations.settings.SettingsEnum;
public class LogHelper {
@ -10,20 +9,20 @@ public class LogHelper {
//ToDo: Get Calling classname using Reflection
public static void debug(Class clazz, String message) {
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
Log.d("ReVanced: " + (clazz != null ? clazz.getSimpleName() : ""), message);
if (SettingsEnum.DEBUG.getBoolean()) {
Log.d("revanced: " + (clazz != null ? clazz.getSimpleName() : ""), message);
}
}
public static void printException(Class clazz, String message, Throwable ex) {
Log.e("ReVanced: " + (clazz != null ? clazz.getSimpleName() : ""), message, ex);
Log.e("revanced: " + (clazz != null ? clazz.getSimpleName() : ""), message, ex);
}
public static void printException(Class clazz, String message) {
Log.e("ReVanced: " + (clazz != null ? clazz.getSimpleName() : ""), message);
Log.e("revanced: " + (clazz != null ? clazz.getSimpleName() : ""), message);
}
public static void info(Class clazz, String message) {
Log.i("ReVanced: " + (clazz != null ? clazz.getSimpleName() : ""), message);
Log.i("revanced: " + (clazz != null ? clazz.getSimpleName() : ""), message);
}
}

View File

@ -12,9 +12,7 @@ import android.os.Looper;
import com.google.android.apps.youtube.app.YouTubeTikTokRoot_Application;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.sponsorblock.player.PlayerType;
import app.revanced.integrations.videoplayer.videosettings.VideoSpeed;
public class ReVancedUtils {
@ -41,16 +39,6 @@ public class ReVancedUtils {
return newVideo;
}
public static String getStringByName(Context context, String name) {
try {
Resources res = context.getResources();
return res.getString(res.getIdentifier(name, "string", context.getPackageName()));
} catch (Throwable exception) {
LogHelper.printException(ReVancedUtils.class, "Resource not found.", exception);
return "";
}
}
public static Integer getResourceIdByName(Context context, String type, String name) {
try {
Resources res = context.getResources();
@ -78,35 +66,6 @@ public class ReVancedUtils {
new Handler(Looper.getMainLooper()).post(runnable);
}
public static void CheckForMicroG(Activity activity) {
AlertDialog.Builder builder;
if (!appInstalledOrNot("com.mgoogle.android.gms")) {
LogHelper.debug(ReVancedUtils.class, "Custom MicroG installation undetected");
if (Build.VERSION.SDK_INT >= 21) {
builder = new AlertDialog.Builder(activity, 16974374);
} else {
builder = new AlertDialog.Builder(activity);
}
builder.setTitle("Someone is not reading...").setMessage("You didn't install the MicroG as instructed, you can't login without it.\n\nInstall it and try again.").setPositiveButton("Close", new DialogInterface.OnClickListener() { // from class: app.revanced.integrations.settings.Settings.1
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialog, int id) {
}
}).show();
} else {
LogHelper.debug(ReVancedUtils.class, "Custom MicroG installation detected");
}
}
private static boolean appInstalledOrNot(String uri) {
try {
PackageManager pm = getContext().getPackageManager();
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
public static Context getContext() {
Context context = YouTubeTikTokRoot_Application.getAppContext();
if (context != null) {
@ -116,4 +75,8 @@ public class ReVancedUtils {
return null;
}
}
public static boolean isTablet(Context context) {
return context.getResources().getConfiguration().smallestScreenWidthDp >= 600;
}
}

View File

@ -1,14 +0,0 @@
package app.revanced.integrations.utils;
import android.content.Context;
/* loaded from: classes6.dex */
public class ScreenSizeHelper {
public static boolean isTablet(Context context) {
return smallestWidthDp(context) >= 600;
}
private static int smallestWidthDp(Context context) {
return context.getResources().getConfiguration().smallestScreenWidthDp;
}
}

View File

@ -29,46 +29,26 @@ public class SharedPrefHelper {
sharedPreferences.edit().putFloat(key, value).apply();
}
public static String getString(Context context, SharedPrefNames prefName, String key) {
return getString(context, prefName, key, null);
}
public static String getString(Context context, SharedPrefNames prefName, String key, String _default) {
SharedPreferences sharedPreferences = getPreferences(context, prefName);
return (sharedPreferences.getString(key, _default));
}
public static Boolean getBoolean(Context context, SharedPrefNames prefName, String key) {
return getBoolean(context, prefName, key, false);
}
public static Boolean getBoolean(Context context, SharedPrefNames prefName, String key, Boolean _default) {
SharedPreferences sharedPreferences = getPreferences(context, prefName);
return (sharedPreferences.getBoolean(key, _default));
}
public static Long getLong(Context context, SharedPrefNames prefName, String key) {
return getLong(context, prefName, key, -1L);
}
public static Long getLong(Context context, SharedPrefNames prefName, String key, Long _default) {
SharedPreferences sharedPreferences = getPreferences(context, prefName);
return sharedPreferences.getLong(key, _default);
}
public static Float getFloat(Context context, SharedPrefNames prefName, String key) {
return getFloat(context, prefName, key, -1.0F);
}
public static Float getFloat(Context context, SharedPrefNames prefName, String key, Float _default) {
SharedPreferences sharedPreferences = getPreferences(context, prefName);
return sharedPreferences.getFloat(key, _default);
}
public static Integer getInt(Context context, SharedPrefNames prefName, String key) {
return getInt(context, prefName, key, -1);
}
public static Integer getInt(Context context, SharedPrefNames prefName, String key, Integer _default) {
SharedPreferences sharedPreferences = getPreferences(context, prefName);
return sharedPreferences.getInt(key, _default);

View File

@ -1,9 +1,5 @@
package app.revanced.integrations.utils;
import android.os.Build;
import java.util.Objects;
/* loaded from: classes6.dex */
public class ThemeHelper {
private static int themeValue;

View File

@ -1,4 +1,4 @@
package app.revanced.integrations.videoplayer.autorepeat;
package app.revanced.integrations.videoplayer;
import android.content.Context;
@ -13,12 +13,11 @@ import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.SharedPrefHelper;
import app.revanced.integrations.videoplayer.videourl.Copy;
import app.revanced.integrations.videoplayer.videourl.CopyWithTimeStamp;
import java.lang.ref.WeakReference;
/* loaded from: classes6.dex */
//ToDo: Refactor
public class AutoRepeat {
static WeakReference<ImageView> _autoRepeatBtn = new WeakReference<>(null);
static ConstraintLayout _constraintLayout;
@ -91,7 +90,7 @@ public class AutoRepeat {
public static void changeSelected(boolean selected, boolean onlyView) {
ImageView iView = _autoRepeatBtn.get();
if (_constraintLayout != null && iView != null) {
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
if (SettingsEnum.DEBUG.getBoolean()) {
StringBuilder sb = new StringBuilder();
sb.append("Changing selected state to: ");
sb.append(selected ? "SELECTED" : "NONE");

View File

@ -1,4 +1,4 @@
package app.revanced.integrations.videoplayer.videourl;
package app.revanced.integrations.videoplayer;
import android.content.Context;
import android.view.View;
@ -16,6 +16,7 @@ import app.revanced.integrations.utils.SharedPrefHelper;
import java.lang.ref.WeakReference;
/* loaded from: classes6.dex */
//ToDo: Refactor
public class Copy {
static WeakReference<ImageView> _button = new WeakReference<>(null);
static ConstraintLayout _constraintLayout;

View File

@ -1,4 +1,4 @@
package app.revanced.integrations.videoplayer.videourl;
package app.revanced.integrations.videoplayer;
import android.content.Context;
@ -17,6 +17,7 @@ import app.revanced.integrations.utils.SharedPrefHelper;
import java.lang.ref.WeakReference;
/* loaded from: classes6.dex */
//ToDo: Refactor
public class CopyWithTimeStamp {
static WeakReference<ImageView> _button = new WeakReference<>(null);
static ConstraintLayout _constraintLayout;

View File

@ -1,67 +0,0 @@
package app.revanced.integrations.videoplayer.videosettings;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
/* loaded from: classes6.dex */
public class Connectivity {
public static NetworkInfo getNetworkInfo(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
return cm.getActiveNetworkInfo();
}
public static boolean isConnected(Context context) {
NetworkInfo info = getNetworkInfo(context);
return info != null && info.isConnected();
}
public static boolean isConnectedWifi(Context context) {
NetworkInfo info = getNetworkInfo(context);
return info != null && info.isConnected() && info.getType() == 1;
}
public static boolean isConnectedMobile(Context context) {
NetworkInfo info = getNetworkInfo(context);
return info != null && info.isConnected() && info.getType() == 0;
}
public static boolean isConnectedFast(Context context) {
NetworkInfo info = getNetworkInfo(context);
return info != null && info.isConnected() && isConnectionFast(info.getType(), info.getSubtype());
}
public static boolean isConnectionFast(int type, int subType) {
if (type == 1) {
return true;
}
if (type != 0) {
return false;
}
switch (subType) {
case 1:
return false;
case 2:
return false;
case 3:
case 5:
case 6:
case 8:
case 9:
case 10:
case 12:
case 13:
case 14:
case 15:
return true;
case 4:
return false;
case 7:
return false;
case 11:
return false;
default:
return false;
}
}
}

View File

@ -1,98 +0,0 @@
package app.revanced.integrations.videoplayer.videosettings;
import android.content.Context;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.utils.ReVancedUtils;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
/* loaded from: classes6.dex */
public class VideoQuality {
public static final int[] videoResolutions = {0, 144, 240, 360, 480, 720, 1080, 1440, 2160};
private static Boolean userChangedQuality = false;
public static void userChangedQuality() {
userChangedQuality = true;
}
public static int setVideoQuality(Object[] qualities, int quality, Object qInterface) {
int preferredQuality;
Field[] fields;
if (!ReVancedUtils.isNewVideoStarted() || userChangedQuality || qInterface == null) {
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean() && userChangedQuality) {
LogHelper.debug(VideoQuality.class, "Skipping quality change because user changed it: " + quality);
}
userChangedQuality = false;
return quality;
}
ReVancedUtils.setNewVideo(false);
LogHelper.debug(VideoQuality.class, "Quality: " + quality);
Context context = ReVancedUtils.getContext();
if (context == null) {
LogHelper.printException(VideoQuality.class, "Context is null or settings not initialized, returning quality: " + quality);
return quality;
}
if (Connectivity.isConnectedWifi(context)) {
preferredQuality = SettingsEnum.PREFERRED_RESOLUTION_WIFI_INTEGER.getInt();
LogHelper.debug(VideoQuality.class, "Wi-Fi connection detected, preferred quality: " + preferredQuality);
} else if (Connectivity.isConnectedMobile(context)) {
preferredQuality = SettingsEnum.PREFERRED_RESOLUTION_MOBILE_INTEGER.getInt();
LogHelper.debug(VideoQuality.class, "Mobile data connection detected, preferred quality: " + preferredQuality);
} else {
LogHelper.debug(VideoQuality.class, "No Internet connection!");
return quality;
}
if (preferredQuality == -2) {
return quality;
}
Class<?> intType = Integer.TYPE;
ArrayList<Integer> iStreamQualities = new ArrayList<>();
try {
for (Object streamQuality : qualities) {
for (Field field : streamQuality.getClass().getFields()) {
if (field.getType().isAssignableFrom(intType)) {
int value = field.getInt(streamQuality);
if (field.getName().length() <= 2) {
iStreamQualities.add(value);
}
}
}
}
} catch (Exception ignored) {
}
Collections.sort(iStreamQualities);
int index = 0;
for (int streamQuality2 : iStreamQualities) {
LogHelper.debug(VideoQuality.class, "Quality at index " + index + ": " + streamQuality2);
index++;
}
for (Integer iStreamQuality : iStreamQualities) {
int streamQuality3 = iStreamQuality;
if (streamQuality3 <= preferredQuality) {
quality = streamQuality3;
}
}
if (quality == -2) {
return quality;
}
int qualityIndex = iStreamQualities.indexOf(quality);
LogHelper.debug(VideoQuality.class, "Index of quality " + quality + " is " + qualityIndex);
try {
Class<?> cl = qInterface.getClass();
Method m = cl.getMethod("x", Integer.TYPE);
m.invoke(qInterface, iStreamQualities.get(qualityIndex));
LogHelper.debug(VideoQuality.class, "Quality changed to: " + qualityIndex);
return qualityIndex;
} catch (Exception ex) {
LogHelper.printException(VideoQuality.class, "Failed to set quality", ex);
return qualityIndex;
}
}
}

View File

@ -1,4 +1,4 @@
package app.revanced.integrations.utils;
package app.revanced.integrations.whitelist;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

View File

@ -1,4 +1,4 @@
package app.revanced.integrations.adremover.whitelist;
package app.revanced.integrations.whitelist;
import static app.revanced.integrations.sponsorblock.player.VideoInformation.channelName;
import static app.revanced.integrations.sponsorblock.player.ui.SlimButtonContainer.adBlockButton;
@ -22,7 +22,6 @@ import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.player.ChannelModel;
import app.revanced.integrations.sponsorblock.player.VideoInformation;
import app.revanced.integrations.utils.ObjectSerializer;
import app.revanced.integrations.utils.ReVancedUtils;
import app.revanced.integrations.utils.SharedPrefHelper;
@ -44,10 +43,10 @@ public class Whitelist {
LogHelper.debug(Whitelist.class, "channel name set to " + channelName);
VideoInformation.channelName = channelName;
if (enabledMap.get(WhitelistType.ADS) && adBlockButton != null) {
if (enabledMap.containsKey(WhitelistType.ADS) && enabledMap.get(WhitelistType.ADS) && adBlockButton != null) {
adBlockButton.changeEnabled(shouldShowAds());
}
if (enabledMap.get(WhitelistType.SPONSORBLOCK) && sbWhitelistButton != null) {
if (enabledMap.containsKey(WhitelistType.SPONSORBLOCK) && enabledMap.get(WhitelistType.SPONSORBLOCK) && sbWhitelistButton != null) {
sbWhitelistButton.changeEnabled(isChannelSBWhitelisted());
}
}
@ -75,7 +74,7 @@ public class Whitelist {
}
try {
ArrayList<ChannelModel> deserializedChannels = (ArrayList<ChannelModel>) ObjectSerializer.deserialize(serializedChannels);
if (SettingsEnum.DEBUG_BOOLEAN.getBoolean()) {
if (SettingsEnum.DEBUG.getBoolean()) {
LogHelper.debug(Whitelist.class, serializedChannels);
for (ChannelModel channel : deserializedChannels) {
LogHelper.debug(Whitelist.class, String.format("Whitelisted channel %s (%s) for type %s", channel.getAuthor(), channel.getChannelId(), whitelistType));
@ -95,14 +94,14 @@ public class Whitelist {
}
Map<WhitelistType, Boolean> enabledMap = new EnumMap<>(WhitelistType.class);
for (WhitelistType whitelistType : WhitelistType.values()) {
enabledMap.put(whitelistType, SharedPrefHelper.getBoolean(context, whitelistType.getSharedPreferencesName(), whitelistType.getPreferenceEnabledName()));
enabledMap.put(whitelistType, SharedPrefHelper.getBoolean(context, whitelistType.getSharedPreferencesName(), whitelistType.getPreferenceEnabledName(), false));
}
return enabledMap;
}
private static boolean isWhitelisted(WhitelistType whitelistType) {
boolean isEnabled = false;
if(enabledMap.containsKey(whitelistType) && enabledMap.get(whitelistType) != null) {
if (enabledMap.containsKey(whitelistType) && enabledMap.get(whitelistType) != null) {
isEnabled = enabledMap.get(whitelistType);
}
if (!isEnabled) {
@ -110,7 +109,6 @@ public class Whitelist {
}
if (channelName == null || channelName.trim().isEmpty()) {
LogHelper.debug(Whitelist.class, String.format("Can't check whitelist status for %s because channel name was missing", whitelistType));
return false;
}
List<ChannelModel> whitelistedChannels = whitelistMap.get(whitelistType);

View File

@ -1,4 +1,4 @@
package app.revanced.integrations.adremover.whitelist;
package app.revanced.integrations.whitelist;
import static app.revanced.integrations.sponsorblock.StringRef.str;

View File

@ -1,4 +1,4 @@
package app.revanced.integrations.adremover.whitelist.requests;
package app.revanced.integrations.whitelist.requests;
import org.json.JSONArray;
import org.json.JSONObject;

View File

@ -1,4 +1,4 @@
package app.revanced.integrations.adremover.whitelist.requests;
package app.revanced.integrations.whitelist.requests;
public class Route {
private final String route;

View File

@ -1,4 +1,4 @@
package app.revanced.integrations.adremover.whitelist.requests;
package app.revanced.integrations.whitelist.requests;
import static app.revanced.integrations.sponsorblock.player.VideoInformation.currentVideoId;
import static app.revanced.integrations.utils.ReVancedUtils.runOnMainThread;
@ -21,8 +21,8 @@ import java.nio.charset.StandardCharsets;
import app.revanced.integrations.utils.LogHelper;
import app.revanced.integrations.sponsorblock.player.ChannelModel;
import app.revanced.integrations.adremover.whitelist.Whitelist;
import app.revanced.integrations.adremover.whitelist.WhitelistType;
import app.revanced.integrations.whitelist.Whitelist;
import app.revanced.integrations.whitelist.WhitelistType;
import app.revanced.integrations.BuildConfig;
public class WhitelistRequester {

View File

@ -1,6 +1,6 @@
package app.revanced.integrations.adremover.whitelist.requests;
package app.revanced.integrations.whitelist.requests;
import static app.revanced.integrations.adremover.whitelist.requests.Route.Method.POST;
import static app.revanced.integrations.whitelist.requests.Route.Method.POST;
public class WhitelistRoutes {
public static final Route GET_CHANNEL_DETAILS = new Route(POST, "player?key={api_key}");

View File

@ -17,6 +17,7 @@
<ListPreference android:title="@string/revanced_preferred_video_quality_wifi_title" android:key="revanced_pref_video_quality_wifi" android:summary="@string/revanced_preferred_video_quality_wifi_summary" />
<ListPreference android:title="@string/revanced_preferred_video_quality_mobile_title" android:key="revanced_pref_video_quality_mobile" android:summary="@string/revanced_preferred_video_quality_mobile_summary" />
<ListPreference android:title="@string/revanced_preferred_video_speed_title" android:key="revanced_pref_video_speed" android:summary="@string/revanced_preferred_video_speed_summary" />
<SwitchPreference android:title="Auto captions" android:key="revanced_pref_auto_captions" android:defaultValue="false" android:summaryOn="Auto captions are turned on" android:summaryOff="Auto captions are turned off" />
</PreferenceScreen>
<PreferenceScreen android:title="@string/revanced_video_ad_settings_title" android:key="video_ad_settings">
<SwitchPreference android:title="@string/revanced_videoadwhitelisting_title" android:key="revanced_whitelist_ads_enabled" android:defaultValue="false" android:summaryOn="@string/revanced_videoadwhitelisting_summary_on" android:summaryOff="@string/revanced_videoadwhitelisting_summary_off" />