mirror of
https://github.com/revanced/revanced-integrations.git
synced 2025-01-04 00:55:49 +01:00
fix(YouTube - SponsorBlock): Handle if the user enters an invalid number into any SB settings
This commit is contained in:
parent
9e11ba11d9
commit
01f084d87a
@ -257,13 +257,19 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
newSegmentStep.setSummary(str("revanced_sb_general_adjusting_sum"));
|
||||
newSegmentStep.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
newSegmentStep.setOnPreferenceChangeListener((preference1, newValue) -> {
|
||||
final int newAdjustmentValue = Integer.parseInt(newValue.toString());
|
||||
if (newAdjustmentValue == 0) {
|
||||
Utils.showToastLong(str("revanced_sb_general_adjusting_invalid"));
|
||||
return false;
|
||||
try {
|
||||
final int newAdjustmentValue = Integer.parseInt(newValue.toString());
|
||||
if (newAdjustmentValue != 0) {
|
||||
Settings.SB_CREATE_NEW_SEGMENT_STEP.save(newAdjustmentValue);
|
||||
return true;
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
Logger.printInfo(() -> "Invalid new segment step", ex);
|
||||
}
|
||||
Settings.SB_CREATE_NEW_SEGMENT_STEP.save(newAdjustmentValue);
|
||||
return true;
|
||||
|
||||
Utils.showToastLong(str("revanced_sb_general_adjusting_invalid"));
|
||||
updateUI();
|
||||
return false;
|
||||
});
|
||||
category.addPreference(newSegmentStep);
|
||||
|
||||
@ -309,8 +315,17 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
minSegmentDuration.setSummary(str("revanced_sb_general_min_duration_sum"));
|
||||
minSegmentDuration.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||||
minSegmentDuration.setOnPreferenceChangeListener((preference1, newValue) -> {
|
||||
Settings.SB_SEGMENT_MIN_DURATION.save(Float.valueOf(newValue.toString()));
|
||||
return true;
|
||||
try {
|
||||
Float minTimeDuration = Float.valueOf(newValue.toString());
|
||||
Settings.SB_SEGMENT_MIN_DURATION.save(minTimeDuration);
|
||||
return true;
|
||||
} catch (NumberFormatException ex) {
|
||||
Logger.printInfo(() -> "Invalid minimum segment duration", ex);
|
||||
}
|
||||
|
||||
Utils.showToastLong(str("revanced_sb_general_min_duration_invalid"));
|
||||
updateUI();
|
||||
return false;
|
||||
});
|
||||
category.addPreference(minSegmentDuration);
|
||||
|
||||
@ -323,6 +338,7 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment {
|
||||
Utils.showToastLong(str("revanced_sb_general_uuid_invalid"));
|
||||
return false;
|
||||
}
|
||||
|
||||
Settings.SB_PRIVATE_USER_ID.save(newUUID);
|
||||
updateUI();
|
||||
fetchAndDisplayStats();
|
||||
|
Loading…
Reference in New Issue
Block a user