mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 07:20:39 +00:00
migrate existent keys
This commit is contained in:
parent
9945005008
commit
f65489c922
2 changed files with 39 additions and 1 deletions
|
@ -20,12 +20,15 @@ const List<NdValue> ndValues = [
|
|||
NdValue(16),
|
||||
NdValue(32),
|
||||
NdValue(64),
|
||||
NdValue(100),
|
||||
NdValue(128),
|
||||
NdValue(256),
|
||||
NdValue(400),
|
||||
NdValue(512),
|
||||
NdValue(1024),
|
||||
NdValue(2048),
|
||||
NdValue(4096),
|
||||
NdValue(6310),
|
||||
NdValue(8192),
|
||||
NdValue(10000),
|
||||
];
|
||||
|
|
|
@ -25,7 +25,42 @@ class UserPreferencesService {
|
|||
|
||||
final SharedPreferences _sharedPreferences;
|
||||
|
||||
UserPreferencesService(this._sharedPreferences);
|
||||
UserPreferencesService(this._sharedPreferences) {
|
||||
final legacyIsoIndex = _sharedPreferences.getInt("curIsoIndex");
|
||||
if (legacyIsoIndex != null) {
|
||||
iso = isoValues[legacyIsoIndex];
|
||||
_sharedPreferences.remove("curIsoIndex");
|
||||
}
|
||||
|
||||
final legacyNdIndex = _sharedPreferences.getInt("curndIndex");
|
||||
if (legacyNdIndex != null) {
|
||||
/// Legacy ND list has 1 extra value at the end, so this check is needed
|
||||
if (legacyNdIndex < ndValues.length) {
|
||||
ndFilter = ndValues[legacyNdIndex];
|
||||
}
|
||||
_sharedPreferences.remove("curndIndex");
|
||||
}
|
||||
|
||||
final legacyCameraCalibration = _sharedPreferences.getDouble("cameraCalibr");
|
||||
if (legacyCameraCalibration != null) {
|
||||
cameraEvCalibration = legacyCameraCalibration;
|
||||
_sharedPreferences.remove("cameraCalibr");
|
||||
}
|
||||
|
||||
final legacyLightSensorCalibration = _sharedPreferences.getDouble("sensorCalibr");
|
||||
if (legacyLightSensorCalibration != null) {
|
||||
lightSensorEvCalibration = legacyLightSensorCalibration;
|
||||
_sharedPreferences.remove("sensorCalibr");
|
||||
}
|
||||
|
||||
final legacyHaptics = _sharedPreferences.getBool("vibrate");
|
||||
if (legacyHaptics != null) {
|
||||
haptics = legacyHaptics;
|
||||
_sharedPreferences.remove("vibrate");
|
||||
}
|
||||
|
||||
// TODO remove all unused keys
|
||||
}
|
||||
|
||||
IsoValue get iso => isoValues.firstWhere((v) => v.value == (_sharedPreferences.getInt(_isoKey) ?? 100));
|
||||
set iso(IsoValue value) => _sharedPreferences.setInt(_isoKey, value.value);
|
||||
|
|
Loading…
Reference in a new issue