@@ -28,16 +28,14 @@ public interface Availability {
28
28
/**
29
29
* Availability based on a single parent setting being enabled.
30
30
*/
31
- @ NonNull
32
- public static Availability parent (@ NonNull BooleanSetting parent ) {
31
+ public static Availability parent (BooleanSetting parent ) {
33
32
return parent ::get ;
34
33
}
35
34
36
35
/**
37
36
* Availability based on all parents being enabled.
38
37
*/
39
- @ NonNull
40
- public static Availability parentsAll (@ NonNull BooleanSetting ... parents ) {
38
+ public static Availability parentsAll (BooleanSetting ... parents ) {
41
39
return () -> {
42
40
for (BooleanSetting parent : parents ) {
43
41
if (!parent .get ()) return false ;
@@ -49,8 +47,7 @@ public static Availability parentsAll(@NonNull BooleanSetting... parents) {
49
47
/**
50
48
* Availability based on any parent being enabled.
51
49
*/
52
- @ NonNull
53
- public static Availability parentsAny (@ NonNull BooleanSetting ... parents ) {
50
+ public static Availability parentsAny (BooleanSetting ... parents ) {
54
51
return () -> {
55
52
for (BooleanSetting parent : parents ) {
56
53
if (parent .get ()) return true ;
@@ -79,7 +76,7 @@ public interface ImportExportCallback {
79
76
/**
80
77
* Adds a callback for {@link #importFromJSON(Context, String)} and {@link #exportToJson(Context)}.
81
78
*/
82
- public static void addImportExportCallback (@ NonNull ImportExportCallback callback ) {
79
+ public static void addImportExportCallback (ImportExportCallback callback ) {
83
80
importExportCallbacks .add (Objects .requireNonNull (callback ));
84
81
}
85
82
@@ -100,22 +97,20 @@ public static void addImportExportCallback(@NonNull ImportExportCallback callbac
100
97
public static final SharedPrefCategory preferences = new SharedPrefCategory ("revanced_prefs" );
101
98
102
99
@ Nullable
103
- public static Setting <?> getSettingFromPath (@ NonNull String str ) {
100
+ public static Setting <?> getSettingFromPath (String str ) {
104
101
return PATH_TO_SETTINGS .get (str );
105
102
}
106
103
107
104
/**
108
105
* @return All settings that have been created.
109
106
*/
110
- @ NonNull
111
107
public static List <Setting <?>> allLoadedSettings () {
112
108
return Collections .unmodifiableList (SETTINGS );
113
109
}
114
110
115
111
/**
116
112
* @return All settings that have been created, sorted by keys.
117
113
*/
118
- @ NonNull
119
114
private static List <Setting <?>> allLoadedSettingsSorted () {
120
115
Collections .sort (SETTINGS , (Setting <?> o1 , Setting <?> o2 ) -> o1 .key .compareTo (o2 .key ));
121
116
return allLoadedSettings ();
@@ -124,13 +119,11 @@ private static List<Setting<?>> allLoadedSettingsSorted() {
124
119
/**
125
120
* The key used to store the value in the shared preferences.
126
121
*/
127
- @ NonNull
128
122
public final String key ;
129
123
130
124
/**
131
125
* The default value of the setting.
132
126
*/
133
- @ NonNull
134
127
public final T defaultValue ;
135
128
136
129
/**
@@ -161,7 +154,6 @@ private static List<Setting<?>> allLoadedSettingsSorted() {
161
154
/**
162
155
* The value of the setting.
163
156
*/
164
- @ NonNull
165
157
protected volatile T value ;
166
158
167
159
public Setting (String key , T defaultValue ) {
@@ -199,8 +191,8 @@ public Setting(String key, T defaultValue, boolean rebootApp, String userDialogM
199
191
* @param userDialogMessage Confirmation message to display, if the user tries to change the setting from the default value.
200
192
* @param availability Condition that must be true, for this setting to be available to configure.
201
193
*/
202
- public Setting (@ NonNull String key ,
203
- @ NonNull T defaultValue ,
194
+ public Setting (String key ,
195
+ T defaultValue ,
204
196
boolean rebootApp ,
205
197
boolean includeWithImportExport ,
206
198
@ Nullable String userDialogMessage ,
@@ -227,7 +219,7 @@ public Setting(@NonNull String key,
227
219
/**
228
220
* Migrate a setting value if the path is renamed but otherwise the old and new settings are identical.
229
221
*/
230
- public static <T > void migrateOldSettingToNew (@ NonNull Setting <T > oldSetting , @ NonNull Setting <T > newSetting ) {
222
+ public static <T > void migrateOldSettingToNew (Setting <T > oldSetting , Setting <T > newSetting ) {
231
223
if (oldSetting == newSetting ) throw new IllegalArgumentException ();
232
224
233
225
if (!oldSetting .isSetToDefault ()) {
@@ -243,7 +235,7 @@ public static <T> void migrateOldSettingToNew(@NonNull Setting<T> oldSetting, @N
243
235
* This method will be deleted in the future.
244
236
*/
245
237
@ SuppressWarnings ("rawtypes" )
246
- public static void migrateFromOldPreferences (@ NonNull SharedPrefCategory oldPrefs , @ NonNull Setting setting , String settingKey ) {
238
+ public static void migrateFromOldPreferences (SharedPrefCategory oldPrefs , Setting setting , String settingKey ) {
247
239
if (!oldPrefs .preferences .contains (settingKey )) {
248
240
return ; // Nothing to do.
249
241
}
@@ -285,7 +277,7 @@ public static void migrateFromOldPreferences(@NonNull SharedPrefCategory oldPref
285
277
* This intentionally is a static method to deter
286
278
* accidental usage when {@link #save(Object)} was intended.
287
279
*/
288
- public static void privateSetValueFromString (@ NonNull Setting <?> setting , @ NonNull String newValue ) {
280
+ public static void privateSetValueFromString (Setting <?> setting , String newValue ) {
289
281
setting .setValueFromString (newValue );
290
282
291
283
// Clear the preference value since default is used, to allow changing
@@ -299,7 +291,7 @@ public static void privateSetValueFromString(@NonNull Setting<?> setting, @NonNu
299
291
/**
300
292
* Sets the value of {@link #value}, but do not save to {@link #preferences}.
301
293
*/
302
- protected abstract void setValueFromString (@ NonNull String newValue );
294
+ protected abstract void setValueFromString (String newValue );
303
295
304
296
/**
305
297
* Load and set the value of {@link #value}.
@@ -309,7 +301,7 @@ public static void privateSetValueFromString(@NonNull Setting<?> setting, @NonNu
309
301
/**
310
302
* Persistently saves the value.
311
303
*/
312
- public final void save (@ NonNull T newValue ) {
304
+ public final void save (T newValue ) {
313
305
if (value .equals (newValue )) {
314
306
return ;
315
307
}
@@ -406,7 +398,6 @@ protected void writeToJSON(JSONObject json, String importExportKey) throws JSONE
406
398
json .put (importExportKey , value );
407
399
}
408
400
409
- @ NonNull
410
401
public static String exportToJson (@ Nullable Context alertDialogContext ) {
411
402
try {
412
403
JSONObject json = new JSONObject ();
@@ -445,7 +436,7 @@ public static String exportToJson(@Nullable Context alertDialogContext) {
445
436
/**
446
437
* @return if any settings that require a reboot were changed.
447
438
*/
448
- public static boolean importFromJSON (@ NonNull Context alertDialogContext , @ NonNull String settingsJsonString ) {
439
+ public static boolean importFromJSON (Context alertDialogContext , String settingsJsonString ) {
449
440
try {
450
441
if (!settingsJsonString .matches ("[\\ s\\ S]*\\ {" )) {
451
442
settingsJsonString = '{' + settingsJsonString + '}' ; // Restore outer JSON braces
0 commit comments