Preferences migration fix
This commit is contained in:
parent
3eef4c5049
commit
b75e89e36f
@ -27,15 +27,9 @@ import android.content.SharedPreferences;
|
|||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.StringRes;
|
import android.support.annotation.StringRes;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
import jscl.AngleUnit;
|
|
||||||
import jscl.JsclMathEngine;
|
|
||||||
import jscl.MathEngine;
|
|
||||||
import jscl.NumeralBase;
|
|
||||||
import jscl.math.operator.Operator;
|
|
||||||
import jscl.text.Identifier;
|
|
||||||
import jscl.text.Parser;
|
|
||||||
import midpcalc.Real;
|
|
||||||
import org.solovyev.android.Check;
|
import org.solovyev.android.Check;
|
||||||
import org.solovyev.android.calculator.functions.FunctionsRegistry;
|
import org.solovyev.android.calculator.functions.FunctionsRegistry;
|
||||||
import org.solovyev.android.calculator.math.MathType;
|
import org.solovyev.android.calculator.math.MathType;
|
||||||
@ -50,10 +44,6 @@ import org.solovyev.common.text.CharacterMapper;
|
|||||||
import org.solovyev.common.text.EnumMapper;
|
import org.solovyev.common.text.EnumMapper;
|
||||||
import org.solovyev.common.text.NumberMapper;
|
import org.solovyev.common.text.NumberMapper;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -61,6 +51,20 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import jscl.AngleUnit;
|
||||||
|
import jscl.JsclMathEngine;
|
||||||
|
import jscl.MathEngine;
|
||||||
|
import jscl.NumeralBase;
|
||||||
|
import jscl.math.operator.Operator;
|
||||||
|
import jscl.text.Identifier;
|
||||||
|
import jscl.text.Parser;
|
||||||
|
import midpcalc.Real;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class Engine implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public class Engine implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
@ -210,6 +214,8 @@ public class Engine implements SharedPreferences.OnSharedPreferenceChangeListene
|
|||||||
Preferences.Output.precision.putPreference(editor, NumberFormatter.MAX_PRECISION);
|
Preferences.Output.precision.putPreference(editor, NumberFormatter.MAX_PRECISION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// #initPreferences rely on all changes to be committed
|
||||||
|
editor.apply();
|
||||||
initPreferences(editor);
|
initPreferences(editor);
|
||||||
} else if (oldVersion == 1) {
|
} else if (oldVersion == 1) {
|
||||||
migratePreference(preferences, Preferences.Output.separator, "engine.groupingSeparator", editor);
|
migratePreference(preferences, Preferences.Output.separator, "engine.groupingSeparator", editor);
|
||||||
@ -223,6 +229,8 @@ public class Engine implements SharedPreferences.OnSharedPreferenceChangeListene
|
|||||||
Preferences.Output.precision.putPreference(editor, NumberFormatter.MAX_PRECISION);
|
Preferences.Output.precision.putPreference(editor, NumberFormatter.MAX_PRECISION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// #initPreferences rely on all changes to be committed
|
||||||
|
editor.apply();
|
||||||
// preferences should be initialized again as:
|
// preferences should be initialized again as:
|
||||||
// 1. It was forgotten for 0 version
|
// 1. It was forgotten for 0 version
|
||||||
// 2. There is a bunch of new preferences
|
// 2. There is a bunch of new preferences
|
||||||
|
Loading…
Reference in New Issue
Block a user