fix: sponsorblock settings not getting saved (#112)

This commit is contained in:
Joey Peter 2022-07-31 21:21:19 +02:00 committed by GitHub
parent 6eaf9fee65
commit 256302e914
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 18 deletions

View File

@ -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),

View File

@ -28,14 +28,6 @@ public class ReVancedSettingActivity {
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;
@ -51,13 +43,6 @@ public class ReVancedSettingActivity {
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();
}

View File

@ -90,6 +90,7 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
.setPositiveButton(str("sb_guidelines_popup_open"), (dialogInterface, i) -> openGuidelines())
.show();
}
SettingsEnum.SB_NEW_SEGMENT_ENABLED.saveValue(value);
return true;
});
}
@ -103,6 +104,11 @@ public class SponsorBlockSettingsFragment extends PreferenceFragment implements
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);