Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
fix: make all patches toggleable with settings (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJeterLP authored Jul 18, 2022
1 parent 0e01041 commit 6d3d274
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package app.revanced.integrations.patches;

import android.view.View;

import app.revanced.integrations.settings.SettingsEnum;

public class FullscreenPanelsRemoverPatch {

public int getFullsceenPanelsVisibility() {
return SettingsEnum.FULLSCREEN_PANELS_SHOWN.getBoolean() ? View.VISIBLE : View.GONE;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package app.revanced.integrations.patches;

import app.revanced.integrations.settings.SettingsEnum;

public class HideAutoplayButtonPatch {

public static boolean isButtonShown() {
return SettingsEnum.AUTOPLAY_BUTTON_SHOWN.getBoolean();
}

public static boolean isButtonHidden() {
return !isButtonShown();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

public class HideInfoCardSuggestionsPatch {

public static int hideInfoCardSuggestions() {
return SettingsEnum.INFO_CARDS_SHOWN.getBoolean() ? View.VISIBLE : View.GONE;
public static void hideInfoCardSuggestions(View view) {
if (!SettingsEnum.INFO_CARDS_SHOWN.getBoolean()) {
view.setVisibility(View.GONE);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package app.revanced.integrations.patches;

import app.revanced.integrations.settings.SettingsEnum;

public class MinimizedPlaybackPatch {

public static boolean isMinimizedPlaybackEnabled() {
return SettingsEnum.ENABLE_MINIMIZED_PLAYBACK.getBoolean();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,20 @@ public enum SettingsEnum {
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),
AUTOPLAY_BUTTON_SHOWN("revanced_autoplay_button_enabled", false, ReturnType.BOOLEAN), //ToDo: Add to prefs
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),
FULLSCREEN_PANELS_SHOWN("revanced_fullscreen_panels_enabled", false, ReturnType.BOOLEAN), //ToDo: Add to prefs

//Misc. Settings
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),
ENABLE_MINIMIZED_PLAYBACK("revanced_enable_minimized_playback", true, ReturnType.BOOLEAN),

//Swipe controls
ENABLE_SWIPE_BRIGHTNESS("revanced_enable_swipe_brightness", true, ReturnType.BOOLEAN),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package app.revanced.integrations.sponsorblock;

import android.content.Context;
import android.content.res.Resources;


import androidx.annotation.NonNull;

import java.util.HashMap;
Expand All @@ -14,17 +12,6 @@ public class StringRef {
private static Resources resources;
private static String packageName;

/**
* Called in Application onCreate, should be called as soon as possible when after application startup
*
* @param context Any context, it will be used to obtain string resources
*/
public static void setContext(Context context) {
if (context == null) return;
resources = context.getApplicationContext().getResources();
packageName = context.getPackageName();
}

private static final HashMap<String, StringRef> strings = new HashMap<>();

/**
Expand Down

0 comments on commit 6d3d274

Please sign in to comment.