Parse every enum setting with the one generic parser
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -237,8 +237,8 @@ public final class Settings {
|
|||||||
clientVersionSign = props.getProperty("clientVersionSign", clientVersionSign);
|
clientVersionSign = props.getProperty("clientVersionSign", clientVersionSign);
|
||||||
inputDevice = props.getProperty("inputDevice", inputDevice);
|
inputDevice = props.getProperty("inputDevice", inputDevice);
|
||||||
outputDevice = props.getProperty("outputDevice", outputDevice);
|
outputDevice = props.getProperty("outputDevice", outputDevice);
|
||||||
inputMode = parseMode(props.getProperty("inputMode"), inputMode);
|
inputMode = parseEnum(InputMode.class, props.getProperty("inputMode"), inputMode);
|
||||||
vadMode = parseVadMode(props.getProperty("vadMode"), vadMode);
|
vadMode = parseEnum(VadMode.class, props.getProperty("vadMode"), vadMode);
|
||||||
vadThresholdDb = parseD(props.getProperty("vadLevelDb"),
|
vadThresholdDb = parseD(props.getProperty("vadLevelDb"),
|
||||||
migrateThreshold(props.getProperty("vadThresholdDb"), vadThresholdDb));
|
migrateThreshold(props.getProperty("vadThresholdDb"), vadThresholdDb));
|
||||||
speechThreshold = parseD(props.getProperty("speechThreshold"), speechThreshold);
|
speechThreshold = parseD(props.getProperty("speechThreshold"), speechThreshold);
|
||||||
@@ -262,7 +262,7 @@ public final class Settings {
|
|||||||
soundPackDir = props.getProperty("soundPackDir", soundPackDir);
|
soundPackDir = props.getProperty("soundPackDir", soundPackDir);
|
||||||
iconPack = props.getProperty("iconPack", iconPack);
|
iconPack = props.getProperty("iconPack", iconPack);
|
||||||
iconPackDir = props.getProperty("iconPackDir", iconPackDir);
|
iconPackDir = props.getProperty("iconPackDir", iconPackDir);
|
||||||
appearance = parseAppearance(props.getProperty("appearance"), appearance);
|
appearance = parseEnum(Appearance.class, props.getProperty("appearance"), appearance);
|
||||||
uiScale = parseD(props.getProperty("uiScale"), uiScale);
|
uiScale = parseD(props.getProperty("uiScale"), uiScale);
|
||||||
showStatusBar = parseB(props.getProperty("showStatusBar"), showStatusBar);
|
showStatusBar = parseB(props.getProperty("showStatusBar"), showStatusBar);
|
||||||
showMasterVolumeSlider = parseB(props.getProperty("showMasterVolumeSlider"), showMasterVolumeSlider);
|
showMasterVolumeSlider = parseB(props.getProperty("showMasterVolumeSlider"), showMasterVolumeSlider);
|
||||||
@@ -338,33 +338,6 @@ public final class Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static InputMode parseMode(String v, InputMode def) {
|
|
||||||
if (v == null) return def;
|
|
||||||
try {
|
|
||||||
return InputMode.valueOf(v);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Appearance parseAppearance(String v, Appearance def) {
|
|
||||||
if (v == null) return def;
|
|
||||||
try {
|
|
||||||
return Appearance.valueOf(v);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static VadMode parseVadMode(String v, VadMode def) {
|
|
||||||
if (v == null) return def;
|
|
||||||
try {
|
|
||||||
return VadMode.valueOf(v);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a threshold saved under the old {@code vadThresholdDb} key, which was in
|
* Converts a threshold saved under the old {@code vadThresholdDb} key, which was in
|
||||||
* dBFS ({@code 20*log10(rms)}), to {@link com.ts3client.audio.InputLevel}'s scale, so
|
* dBFS ({@code 20*log10(rms)}), to {@link com.ts3client.audio.InputLevel}'s scale, so
|
||||||
|
|||||||
Reference in New Issue
Block a user