Skip to content

Commit

Permalink
fix: sponsorblock settings not getting saved (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJeterLP committed Jul 31, 2022
1 parent 6eaf9fe commit 256302e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
Expand Up @@ -96,8 +96,8 @@ public enum SettingsEnum {
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_SEEN_GUIDELINES("sb-seen-gl", false, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
SB_NEW_SEGMENT_ENABLED("sb-new-segment-enabled", true, SharedPrefHelper.SharedPrefNames.SPONSOR_BLOCK, ReturnType.BOOLEAN),
SB_VOTING_ENABLED("sb-voting-enabled", true, 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", false, 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),
Expand Down
Expand Up @@ -28,14 +28,6 @@ public static void setTheme(LicenseActivity base) {
public static void initializeSettings(LicenseActivity base) {
base.setContentView(getIdentifier("xsettings_with_toolbar", "layout"));

try {
ImageButton imageButton = getImageButton(base.findViewById(getIdentifier("toolbar", "id")));
imageButton.setOnClickListener(view -> base.onBackPressed());
imageButton.setImageDrawable(base.getResources().getDrawable(getIdentifier(ThemeHelper.isDarkTheme() ? "quantum_ic_arrow_back_white_24" : "quantum_ic_arrow_back_grey600_24", "drawable"), null));
} catch (Exception e) {
LogHelper.printException(ReVancedSettingActivity.class, "Couldn't set Toolbar click handler", e);
}

PreferenceFragment preferenceFragment;
String preferenceIdentifier;

Expand All @@ -50,14 +42,7 @@ public static void initializeSettings(LicenseActivity base) {
preferenceIdentifier = "revanced_settings";
preferenceFragment = new ReVancedSettingsFragment();
}

try {
var resourceIdentifier = getIdentifier(preferenceIdentifier, "string");
getTextView(base.findViewById(getIdentifier("toolbar", "id"))).setText(resourceIdentifier);
} catch (Exception e) {
LogHelper.printException(ReVancedSettingActivity.class, "Couldn't set Toolbar title", e);
}


base.getFragmentManager().beginTransaction().replace(getIdentifier("xsettings_fragments", "id"), preferenceFragment).commit();
}

Expand Down
Expand Up @@ -90,6 +90,7 @@ public void onCreate(Bundle savedInstanceState) {
.setPositiveButton(str("sb_guidelines_popup_open"), (dialogInterface, i) -> openGuidelines())
.show();
}
SettingsEnum.SB_NEW_SEGMENT_ENABLED.saveValue(value);
return true;
});
}
Expand All @@ -103,6 +104,11 @@ public void onCreate(Bundle savedInstanceState) {
preference.setDefaultValue(SettingsEnum.SB_VOTING_ENABLED.getDefaultValue());
preference.setChecked(SettingsEnum.SB_VOTING_ENABLED.getBoolean());
preferencesToDisableWhenSBDisabled.add(preference);
preference.setOnPreferenceChangeListener((preference12, o) -> {
final boolean value = (Boolean) o;
SettingsEnum.SB_VOTING_ENABLED.saveValue(value);
return true;
});
}

addGeneralCategory(context, preferenceScreen);
Expand Down

0 comments on commit 256302e

Please sign in to comment.