Remove round preference
This commit is contained in:
@@ -37,6 +37,7 @@ import org.solovyev.android.prefs.CharacterPreference;
|
||||
import org.solovyev.android.prefs.IntegerPreference;
|
||||
import org.solovyev.android.prefs.Preference;
|
||||
import org.solovyev.android.prefs.StringPreference;
|
||||
import org.solovyev.common.NumberFormatter;
|
||||
import org.solovyev.common.text.EnumMapper;
|
||||
import org.solovyev.common.text.NumberMapper;
|
||||
|
||||
@@ -93,7 +94,7 @@ public class Engine implements SharedPreferences.OnSharedPreferenceChangeListene
|
||||
public Engine(@Nonnull JsclMathEngine mathEngine) {
|
||||
this.mathEngine = mathEngine;
|
||||
|
||||
this.mathEngine.setRoundResult(true);
|
||||
this.mathEngine.setPrecision(5);
|
||||
this.mathEngine.setGroupingSeparator(JsclMathEngine.GROUPING_SEPARATOR_DEFAULT);
|
||||
}
|
||||
|
||||
@@ -193,13 +194,24 @@ public class Engine implements SharedPreferences.OnSharedPreferenceChangeListene
|
||||
final boolean scientific = preferences.getBoolean("engine.output.science_notation", false);
|
||||
Preferences.Output.notation.putPreference(editor, scientific ? Notation.sci : Notation.dec);
|
||||
}
|
||||
migratePreference(preferences, Preferences.Output.round, "org.solovyev.android.calculator.CalculatorModel_round_result", editor);
|
||||
if (preferences.contains("org.solovyev.android.calculator.CalculatorModel_round_result")) {
|
||||
final boolean round = preferences.getBoolean("org.solovyev.android.calculator.CalculatorModel_round_result", true);
|
||||
if (!round) {
|
||||
Preferences.Output.precision.putPreference(editor, NumberFormatter.MAX_PRECISION);
|
||||
}
|
||||
}
|
||||
} else if (oldVersion == 1) {
|
||||
migratePreference(preferences, Preferences.Output.separator, "engine.groupingSeparator", editor);
|
||||
if (preferences.contains("engine.output.scientificNotation")) {
|
||||
final boolean scientific = preferences.getBoolean("engine.output.scientificNotation", false);
|
||||
Preferences.Output.notation.putPreference(editor, scientific ? Notation.sci : Notation.dec);
|
||||
}
|
||||
if (preferences.contains("engine.output.round")) {
|
||||
final boolean round = preferences.getBoolean("engine.output.round", true);
|
||||
if (!round) {
|
||||
Preferences.Output.precision.putPreference(editor, NumberFormatter.MAX_PRECISION);
|
||||
}
|
||||
}
|
||||
}
|
||||
Preferences.version.putDefault(editor);
|
||||
editor.apply();
|
||||
@@ -228,7 +240,6 @@ public class Engine implements SharedPreferences.OnSharedPreferenceChangeListene
|
||||
|
||||
mathEngine.setPrecision(Preferences.Output.precision.getPreference(preferences));
|
||||
mathEngine.setNotation(Preferences.Output.notation.getPreference(preferences).id);
|
||||
mathEngine.setRoundResult(Preferences.Output.round.getPreference(preferences));
|
||||
mathEngine.setGroupingSeparator(Preferences.Output.separator.getPreference(preferences));
|
||||
|
||||
bus.post(ChangedEvent.INSTANCE);
|
||||
@@ -284,7 +295,6 @@ public class Engine implements SharedPreferences.OnSharedPreferenceChangeListene
|
||||
preferenceKeys.add(numeralBase.getKey());
|
||||
preferenceKeys.add(angleUnit.getKey());
|
||||
preferenceKeys.add(Output.precision.getKey());
|
||||
preferenceKeys.add(Output.round.getKey());
|
||||
preferenceKeys.add(Output.notation.getKey());
|
||||
preferenceKeys.add(Output.separator.getKey());
|
||||
}
|
||||
@@ -296,7 +306,6 @@ public class Engine implements SharedPreferences.OnSharedPreferenceChangeListene
|
||||
|
||||
public static class Output {
|
||||
public static final StringPreference<Integer> precision = StringPreference.ofTypedValue("engine.output.precision", "5", NumberMapper.of(Integer.class));
|
||||
public static final BooleanPreference round = BooleanPreference.of("engine.output.round", true);
|
||||
public static final StringPreference<Notation> notation = StringPreference.ofEnum("engine.output.notation", Notation.dec, Notation.class);
|
||||
public static final CharacterPreference separator = CharacterPreference.of("engine.output.separator", JsclMathEngine.GROUPING_SEPARATOR_DEFAULT);
|
||||
}
|
||||
|
@@ -17,10 +17,10 @@ import org.solovyev.android.calculator.Named;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.calculator.text.NaturalComparator;
|
||||
import org.solovyev.android.views.DiscreteSeekBar;
|
||||
import org.solovyev.common.NumberFormatter;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import jscl.JsclMathEngine;
|
||||
|
||||
import static org.solovyev.android.calculator.Engine.Preferences.Output;
|
||||
|
||||
@@ -112,7 +112,7 @@ public class NumberFormatPreference extends DialogPreference {
|
||||
private ArrayAdapter<Named<Character>> makeSeparatorAdapter() {
|
||||
final Context context = getContext();
|
||||
final ArrayAdapter<Named<Character>> adapter = App.makeSimpleSpinnerAdapter(context);
|
||||
adapter.add(Named.create(JsclMathEngine.GROUPING_SEPARATOR_NO, R.string.p_grouping_separator_no, context));
|
||||
adapter.add(Named.create(NumberFormatter.NO_GROUPING, R.string.p_grouping_separator_no, context));
|
||||
adapter.add(Named.create('\'', R.string.p_grouping_separator_apostrophe, context));
|
||||
adapter.add(Named.create(' ', R.string.p_grouping_separator_space, context));
|
||||
return adapter;
|
||||
|
@@ -13,7 +13,6 @@ import android.view.View;
|
||||
import android.widget.ListView;
|
||||
|
||||
import org.solovyev.android.calculator.AdView;
|
||||
import org.solovyev.android.calculator.Engine;
|
||||
import org.solovyev.android.calculator.Preferences;
|
||||
import org.solovyev.android.calculator.Preferences.Gui.Theme;
|
||||
import org.solovyev.android.calculator.R;
|
||||
@@ -135,8 +134,6 @@ public class PreferencesFragment extends org.solovyev.android.material.preferenc
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onSharedPreferenceChanged(preferences, Engine.Preferences.Output.round.getKey());
|
||||
}
|
||||
|
||||
private void prepareLayoutPreference(int preference) {
|
||||
@@ -221,12 +218,6 @@ public class PreferencesFragment extends org.solovyev.android.material.preferenc
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
||||
if (Engine.Preferences.Output.round.getKey().equals(key)) {
|
||||
final Preference preference = findPreference(Engine.Preferences.Output.precision.getKey());
|
||||
if (preference != null) {
|
||||
preference.setEnabled(preferences.getBoolean(key, Engine.Preferences.Output.round.getDefaultValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -26,6 +26,7 @@ import android.content.SharedPreferences;
|
||||
|
||||
import org.solovyev.android.calculator.Engine;
|
||||
import org.solovyev.android.calculator.Preferences;
|
||||
import org.solovyev.common.NumberFormatter;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -41,7 +42,7 @@ enum CalculatorMode {
|
||||
Preferences.Gui.mode.putPreference(editor, Preferences.Gui.Mode.simple);
|
||||
Engine.Preferences.angleUnit.putPreference(editor, AngleUnit.deg);
|
||||
Engine.Preferences.Output.notation.putPreference(editor, Engine.Notation.dec);
|
||||
Engine.Preferences.Output.round.putPreference(editor, true);
|
||||
Engine.Preferences.Output.precision.putPreference(editor, 5);
|
||||
|
||||
editor.apply();
|
||||
}
|
||||
@@ -55,7 +56,7 @@ enum CalculatorMode {
|
||||
Preferences.Gui.mode.putPreference(editor, Preferences.Gui.Mode.engineer);
|
||||
Engine.Preferences.angleUnit.putPreference(editor, AngleUnit.rad);
|
||||
Engine.Preferences.Output.notation.putPreference(editor, Engine.Notation.eng);
|
||||
Engine.Preferences.Output.round.putPreference(editor, false);
|
||||
Engine.Preferences.Output.precision.putPreference(editor, NumberFormatter.MAX_PRECISION);
|
||||
|
||||
editor.apply();
|
||||
}
|
||||
|
Reference in New Issue
Block a user