1313public enum SettingsEnum {
1414
1515 //Codec Override
16- CODEC_OVERRIDE ("revanced_override_codec_enabled" , true , ReturnType .BOOLEAN ),
16+ CODEC_OVERRIDE ("revanced_override_codec_enabled" , false , ReturnType .BOOLEAN ),
1717
1818 //Video Settings
1919 OLD_STYLE_QUALITY_SETTINGS ("revanced_use_old_style_quality_settings" , true , ReturnType .BOOLEAN ),
@@ -24,37 +24,37 @@ public enum SettingsEnum {
2424 ENABLE_WHITELIST ("revanced_whitelist_ads_enabled" , false , ReturnType .BOOLEAN ),
2525
2626 //Ad settings
27- HOME_ADS_SHOWN ("revanced_home_ads_enabled" , false , ReturnType .BOOLEAN ),
28- VIDEO_ADS_SHOWN ("revanced_video_ads_enabled" , false , ReturnType .BOOLEAN ),
29- ADREMOVER_AD_REMOVAL ("revanced_adremover_ad_removal" , true , ReturnType .BOOLEAN ),
30- ADREMOVER_MERCHANDISE_REMOVAL ("revanced_adremover_merchandise" , true , ReturnType .BOOLEAN ),
31- ADREMOVER_COMMUNITY_POSTS_REMOVAL ("revanced_adremover_community_posts_removal" , true , ReturnType .BOOLEAN ),
32- ADREMOVER_COMPACT_BANNER_REMOVAL ("revanced_adremover_compact_banner_removal" , true , ReturnType .BOOLEAN ),
33- ADREMOVER_COMMENTS_REMOVAL ("revanced_adremover_comments_removal" , false , ReturnType .BOOLEAN ),
34- ADREMOVER_MOVIE_REMOVAL ("revanced_adremover_movie" , true , ReturnType .BOOLEAN ),
35- ADREMOVER_FEED_SURVEY_REMOVAL ("revanced_adremover_feed_survey" , true , ReturnType .BOOLEAN ),
36- ADREMOVER_SHORTS_SHELF ("revanced_adremover_shorts_shelf" , true , ReturnType .BOOLEAN ),
37- ADREMOVER_COMMUNITY_GUIDELINES ("revanced_adremover_community_guidelines" , true , ReturnType .BOOLEAN ),
38- ADREMOVER_EMERGENCY_BOX_REMOVAL ("revanced_adremover_emergency_box_removal" , true , ReturnType .BOOLEAN ),
39- ADREMOVER_INFO_PANEL_REMOVAL ("revanced_adremover_info_panel" , true , ReturnType .BOOLEAN ),
40- ADREMOVER_MEDICAL_PANEL_REMOVAL ("revanced_adremover_medical_panel" , true , ReturnType .BOOLEAN ),
41- ADREMOVER_PAID_CONTECT_REMOVAL ("revanced_adremover_paid_content" , true , ReturnType .BOOLEAN ),
42- ADREMOVER_SUGGESTED_FOR_YOU_REMOVAL ("revanced_adremover_suggested" , true , ReturnType .BOOLEAN ),
43- ADREMOVER_HIDE_SUGGESTIONS ("revanced_adremover_hide_suggestions" , true , ReturnType .BOOLEAN ),
44- ADREMOVER_HIDE_LATEST_POSTS ("revanced_adremover_hide_latest_posts" , true , ReturnType .BOOLEAN ),
45- ADREMOVER_HIDE_CHANNEL_GUIDELINES ("revanced_adremover_hide_channel_guidelines" , true , ReturnType .BOOLEAN ),
27+ HOME_ADS_SHOWN ("revanced_home_ads_enabled" , false , ReturnType .BOOLEAN , true ),
28+ VIDEO_ADS_SHOWN ("revanced_video_ads_enabled" , false , ReturnType .BOOLEAN , true ),
29+ ADREMOVER_AD_REMOVAL ("revanced_adremover_ad_removal" , true , ReturnType .BOOLEAN , true ),
30+ ADREMOVER_MERCHANDISE_REMOVAL ("revanced_adremover_merchandise" , true , ReturnType .BOOLEAN , true ),
31+ ADREMOVER_COMMUNITY_POSTS_REMOVAL ("revanced_adremover_community_posts_removal" , true , ReturnType .BOOLEAN , true ),
32+ ADREMOVER_COMPACT_BANNER_REMOVAL ("revanced_adremover_compact_banner_removal" , true , ReturnType .BOOLEAN , true ),
33+ ADREMOVER_COMMENTS_REMOVAL ("revanced_adremover_comments_removal" , false , ReturnType .BOOLEAN , true ),
34+ ADREMOVER_MOVIE_REMOVAL ("revanced_adremover_movie" , true , ReturnType .BOOLEAN , true ),
35+ ADREMOVER_FEED_SURVEY_REMOVAL ("revanced_adremover_feed_survey" , true , ReturnType .BOOLEAN , true ),
36+ ADREMOVER_SHORTS_SHELF ("revanced_adremover_shorts_shelf" , true , ReturnType .BOOLEAN , true ),
37+ ADREMOVER_COMMUNITY_GUIDELINES ("revanced_adremover_community_guidelines" , true , ReturnType .BOOLEAN , true ),
38+ ADREMOVER_EMERGENCY_BOX_REMOVAL ("revanced_adremover_emergency_box_removal" , true , ReturnType .BOOLEAN , true ),
39+ ADREMOVER_INFO_PANEL_REMOVAL ("revanced_adremover_info_panel" , true , ReturnType .BOOLEAN , true ),
40+ ADREMOVER_MEDICAL_PANEL_REMOVAL ("revanced_adremover_medical_panel" , true , ReturnType .BOOLEAN , true ),
41+ ADREMOVER_PAID_CONTECT_REMOVAL ("revanced_adremover_paid_content" , true , ReturnType .BOOLEAN , true ),
42+ ADREMOVER_SUGGESTED_FOR_YOU_REMOVAL ("revanced_adremover_suggested" , true , ReturnType .BOOLEAN , true ),
43+ ADREMOVER_HIDE_SUGGESTIONS ("revanced_adremover_hide_suggestions" , true , ReturnType .BOOLEAN , true ),
44+ ADREMOVER_HIDE_LATEST_POSTS ("revanced_adremover_hide_latest_posts" , true , ReturnType .BOOLEAN , true ),
45+ ADREMOVER_HIDE_CHANNEL_GUIDELINES ("revanced_adremover_hide_channel_guidelines" , true , ReturnType .BOOLEAN , true ),
4646
4747 //Layout settings
48- REEL_BUTTON_SHOWN ("revanced_reel_button_enabled" , false , ReturnType .BOOLEAN ),
48+ REEL_BUTTON_SHOWN ("revanced_reel_button_enabled" , false , ReturnType .BOOLEAN , true ),
4949 INFO_CARDS_SHOWN ("revanced_info_cards_enabled" , false , ReturnType .BOOLEAN ),
5050 BRANDING_SHOWN ("revanced_branding_watermark_enabled" , false , ReturnType .BOOLEAN ),
51- CAST_BUTTON_SHOWN ("revanced_cast_button_enabled" , false , ReturnType .BOOLEAN ),
52- AUTOPLAY_BUTTON_SHOWN ("revanced_autoplay_button_enabled" , false , ReturnType .BOOLEAN ),
51+ CAST_BUTTON_SHOWN ("revanced_cast_button_enabled" , false , ReturnType .BOOLEAN , true ),
52+ AUTOPLAY_BUTTON_SHOWN ("revanced_autoplay_button_enabled" , false , ReturnType .BOOLEAN , true ),
5353 //ToDo: Not used atm, Patch missing
5454 USE_TABLET_MINIPLAYER ("revanced_tablet_miniplayer" , false , ReturnType .BOOLEAN ),
55- CREATE_BUTTON_SHOWN ("revanced_create_button_enabled" , false , ReturnType .BOOLEAN ),
56- USE_NEW_ACTIONBAR ("revanced_new_actionbar" , true , ReturnType .BOOLEAN ),
57- SHORTS_BUTTON_SHOWN ("revanced_shorts_button_enabled" , false , ReturnType .BOOLEAN ),
55+ CREATE_BUTTON_SHOWN ("revanced_create_button_enabled" , false , ReturnType .BOOLEAN , true ),
56+ USE_NEW_ACTIONBAR ("revanced_new_actionbar" , false , ReturnType .BOOLEAN , true ),
57+ SHORTS_BUTTON_SHOWN ("revanced_shorts_button_enabled" , false , ReturnType .BOOLEAN , true ),
5858 FULLSCREEN_PANELS_SHOWN ("revanced_fullscreen_panels_enabled" , false , ReturnType .BOOLEAN ), //ToDo: Add to prefs
5959
6060 //Misc. Settings
@@ -81,7 +81,7 @@ public enum SettingsEnum {
8181 MAX_PLAYBACK_BUFFER_AFTER_REBUFFER ("revanced_pref_buffer_for_playback_after_rebuffer_ms" , 5000 , ReturnType .INTEGER ),
8282
8383 //ReVanced General Settings
84- DEBUG ("revanced_debug_enabled" , false , ReturnType .BOOLEAN ),
84+ DEBUG ("revanced_debug_enabled" , false , ReturnType .BOOLEAN , true ),
8585 USE_DARK_THEME ("app_theme_dark" , false , ReturnType .BOOLEAN ),
8686
8787 //RYD Settings
@@ -92,7 +92,7 @@ public enum SettingsEnum {
9292 SB_ENABLED ("sb-enabled" , true , SharedPrefHelper .SharedPrefNames .SPONSOR_BLOCK , ReturnType .BOOLEAN ),
9393 SB_SHOW_TOAST_WHEN_SKIP ("show-toast" , true , SharedPrefHelper .SharedPrefNames .SPONSOR_BLOCK , ReturnType .BOOLEAN ),
9494 SB_COUNT_SKIPS ("count-skips" , true , SharedPrefHelper .SharedPrefNames .SPONSOR_BLOCK , ReturnType .BOOLEAN ),
95- SB_UUID ("uuid" , null , SharedPrefHelper .SharedPrefNames .SPONSOR_BLOCK , ReturnType .STRING ),
95+ SB_UUID ("uuid" , "" , SharedPrefHelper .SharedPrefNames .SPONSOR_BLOCK , ReturnType .STRING ),
9696 SB_ADJUST_NEW_SEGMENT_STEP ("new-segment-step-accuracy" , 150 , SharedPrefHelper .SharedPrefNames .SPONSOR_BLOCK , ReturnType .INTEGER ),
9797 SB_MIN_DURATION ("sb-min-duration" , 0F , SharedPrefHelper .SharedPrefNames .SPONSOR_BLOCK , ReturnType .FLOAT ),
9898 SB_SEEN_GUIDELINES ("sb-seen-gl" , false , SharedPrefHelper .SharedPrefNames .SPONSOR_BLOCK , ReturnType .BOOLEAN ),
@@ -110,6 +110,7 @@ public enum SettingsEnum {
110110 private final Object defaultValue ;
111111 private final SharedPrefHelper .SharedPrefNames sharedPref ;
112112 private final ReturnType returnType ;
113+ private final boolean rebootApp ;
113114
114115 private Object value = null ;
115116
@@ -118,13 +119,23 @@ public enum SettingsEnum {
118119 this .defaultValue = defaultValue ;
119120 this .sharedPref = SharedPrefHelper .SharedPrefNames .YOUTUBE ;
120121 this .returnType = returnType ;
122+ this .rebootApp = false ;
121123 }
122124
123125 SettingsEnum (String path , Object defaultValue , SharedPrefHelper .SharedPrefNames prefName , ReturnType returnType ) {
124126 this .path = path ;
125127 this .defaultValue = defaultValue ;
126128 this .sharedPref = prefName ;
127129 this .returnType = returnType ;
130+ this .rebootApp = false ;
131+ }
132+
133+ SettingsEnum (String path , Object defaultValue , ReturnType returnType , Boolean rebootApp ) {
134+ this .path = path ;
135+ this .defaultValue = defaultValue ;
136+ this .sharedPref = SharedPrefHelper .SharedPrefNames .YOUTUBE ;
137+ this .returnType = returnType ;
138+ this .rebootApp = rebootApp ;
128139 }
129140
130141 static {
@@ -136,36 +147,40 @@ private static void load() {
136147 if (context == null ) {
137148 Log .e ("revanced: SettingsEnum" , "Context returned null! Setings NOT initialized" );
138149 } else {
139- for (SettingsEnum setting : values ()) {
140- Object value = setting .getDefaultValue ();
141-
142- //LogHelper is not initialized here
143- Log .d ("revanced: SettingsEnum" , "Loading Setting: " + setting .name ());
144-
145- switch (setting .getReturnType ()) {
146- case FLOAT :
147- value = SharedPrefHelper .getFloat (context , SharedPrefHelper .SharedPrefNames .YOUTUBE , setting .getPath (), (float ) setting .getDefaultValue ());
148- break ;
149- case LONG :
150- value = SharedPrefHelper .getLong (context , SharedPrefHelper .SharedPrefNames .YOUTUBE , setting .getPath (), (long ) setting .getDefaultValue ());
151- break ;
152- case BOOLEAN :
153- value = SharedPrefHelper .getBoolean (context , SharedPrefHelper .SharedPrefNames .YOUTUBE , setting .getPath (), (boolean ) setting .getDefaultValue ());
154- break ;
155- case INTEGER :
156- value = SharedPrefHelper .getInt (context , SharedPrefHelper .SharedPrefNames .YOUTUBE , setting .getPath (), (int ) setting .getDefaultValue ());
157- break ;
158- case STRING :
159- value = SharedPrefHelper .getString (context , SharedPrefHelper .SharedPrefNames .YOUTUBE , setting .getPath (), (String ) setting .getDefaultValue ());
160- break ;
161- default :
162- LogHelper .printException (SettingsEnum .class , "Setting does not have a valid Type. Name is: " + setting .name ());
163- break ;
150+ try {
151+ for (SettingsEnum setting : values ()) {
152+ Object value = setting .getDefaultValue ();
153+
154+ //LogHelper is not initialized here
155+ Log .d ("revanced: SettingsEnum" , "Loading Setting: " + setting .name ());
156+
157+ switch (setting .getReturnType ()) {
158+ case FLOAT :
159+ value = SharedPrefHelper .getFloat (context , setting .sharedPref , setting .getPath (), (float ) setting .getDefaultValue ());
160+ break ;
161+ case LONG :
162+ value = SharedPrefHelper .getLong (context , setting .sharedPref , setting .getPath (), (long ) setting .getDefaultValue ());
163+ break ;
164+ case BOOLEAN :
165+ value = SharedPrefHelper .getBoolean (context , setting .sharedPref , setting .getPath (), (boolean ) setting .getDefaultValue ());
166+ break ;
167+ case INTEGER :
168+ value = SharedPrefHelper .getInt (context , setting .sharedPref , setting .getPath (), (int ) setting .getDefaultValue ());
169+ break ;
170+ case STRING :
171+ value = SharedPrefHelper .getString (context , setting .sharedPref , setting .getPath (), (String ) setting .getDefaultValue ());
172+ break ;
173+ default :
174+ LogHelper .printException (SettingsEnum .class , "Setting does not have a valid Type. Name is: " + setting .name ());
175+ break ;
176+ }
177+ setting .setValue (value );
178+
179+ //LogHelper is not initialized here
180+ Log .d ("revanced: SettingsEnum" , "Loaded Setting: " + setting .name () + " Value: " + value );
164181 }
165- setting .setValue (value );
166-
167- //LogHelper is not initialized here
168- Log .d ("revanced: SettingsEnum" , "Loaded Setting: " + setting .name () + " Value: " + value );
182+ } catch (Throwable th ) {
183+ LogHelper .printException (SettingsEnum .class , "Error during load()!" , th );
169184 }
170185 }
171186 }
@@ -187,25 +202,10 @@ public void setValue(Object newValue) {
187202 public void saveValue (Object newValue ) {
188203 Context context = ReVancedUtils .getContext ();
189204 if (context != null ) {
190- switch (getReturnType ()) {
191- case BOOLEAN :
192- SharedPrefHelper .saveBoolean (context , sharedPref , getPath (), (Boolean ) newValue );
193- break ;
194- case INTEGER :
195- SharedPrefHelper .saveInt (context , sharedPref , getPath (), (int ) newValue );
196- break ;
197- case STRING :
198- SharedPrefHelper .saveString (context , sharedPref , getPath (), (String ) newValue );
199- break ;
200- case LONG :
201- SharedPrefHelper .saveLong (context , sharedPref , getPath (), (Long ) newValue );
202- break ;
203- case FLOAT :
204- SharedPrefHelper .saveFloat (context , sharedPref , getPath (), (Float ) newValue );
205- break ;
206- default :
207- LogHelper .printException (SettingsEnum .class , "Setting does not have with a valid Type. Name is: " + name ());
208- break ;
205+ if (returnType == ReturnType .BOOLEAN ) {
206+ SharedPrefHelper .saveBoolean (context , sharedPref , path , (Boolean ) newValue );
207+ } else {
208+ SharedPrefHelper .saveString (context , sharedPref , path , newValue + "" );
209209 }
210210 value = newValue ;
211211 } else {
@@ -245,4 +245,8 @@ public ReturnType getReturnType() {
245245 return returnType ;
246246 }
247247
248+ public boolean shouldRebootOnChange () {
249+ return rebootApp ;
250+ }
251+
248252}
0 commit comments