default grouping separator + degree is closed
This commit is contained in:
parent
b0aa0c30ef
commit
3441495c29
@ -9,7 +9,6 @@
|
|||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/plusButton"
|
a:id="@+id/plusButton"
|
||||||
calc:directionTextScale="0.5"
|
calc:directionTextScale="0.5"
|
||||||
calc:textUp="°"
|
|
||||||
a:text="+"
|
a:text="+"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -23,6 +23,7 @@ import android.widget.TextView;
|
|||||||
import bsh.EvalError;
|
import bsh.EvalError;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.solovyev.android.calculator.math.MathType;
|
||||||
import org.solovyev.android.calculator.model.CalculatorEngine;
|
import org.solovyev.android.calculator.model.CalculatorEngine;
|
||||||
import org.solovyev.android.msg.AndroidMessageRegistry;
|
import org.solovyev.android.msg.AndroidMessageRegistry;
|
||||||
import org.solovyev.android.view.FontSizeAdjuster;
|
import org.solovyev.android.view.FontSizeAdjuster;
|
||||||
@ -33,10 +34,8 @@ import org.solovyev.common.utils.history.HistoryAction;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class CalculatorActivity extends Activity implements FontSizeAdjuster, SharedPreferences.OnSharedPreferenceChangeListener {
|
public class CalculatorActivity extends Activity implements FontSizeAdjuster, SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
@ -68,6 +67,8 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
|||||||
|
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
|
setDefaultValues(preferences);
|
||||||
|
|
||||||
setTheme(preferences);
|
setTheme(preferences);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
@ -96,6 +97,25 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
|||||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setDefaultValues(@NotNull SharedPreferences preferences) {
|
||||||
|
if ( !preferences.contains(CalculatorEngine.GROUPING_SEPARATOR_P_KEY) ) {
|
||||||
|
final Locale locale = Locale.getDefault();
|
||||||
|
if ( locale != null ) {
|
||||||
|
final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(locale);
|
||||||
|
int index = MathType.grouping_separator.getTokens().indexOf(String.valueOf(decimalFormatSymbols.getGroupingSeparator()));
|
||||||
|
final String groupingSeparator;
|
||||||
|
if ( index >= 0 ) {
|
||||||
|
groupingSeparator = MathType.grouping_separator.getTokens().get(index);
|
||||||
|
} else {
|
||||||
|
groupingSeparator = " ";
|
||||||
|
}
|
||||||
|
final SharedPreferences.Editor editor = preferences.edit();
|
||||||
|
editor.putString(CalculatorEngine.GROUPING_SEPARATOR_P_KEY, groupingSeparator);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private synchronized void setOnDragListeners(@NotNull SimpleOnDragListener.Preferences dragPreferences) {
|
private synchronized void setOnDragListeners(@NotNull SimpleOnDragListener.Preferences dragPreferences) {
|
||||||
final SimpleOnDragListener onDragListener = new SimpleOnDragListener(new DigitButtonDragProcessor(calculatorModel), dragPreferences);
|
final SimpleOnDragListener onDragListener = new SimpleOnDragListener(new DigitButtonDragProcessor(calculatorModel), dragPreferences);
|
||||||
dpclRegister.addListener(onDragListener);
|
dpclRegister.addListener(onDragListener);
|
||||||
|
@ -37,7 +37,12 @@ public enum MathType {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
grouping_separator(250, false, false, "'", " "),
|
grouping_separator(250, false, false, "'", " "){
|
||||||
|
@Override
|
||||||
|
public int processToJscl(@NotNull StringBuilder result, int i, @NotNull String match) throws ParseException {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
power_10(300, true, false, "E") {
|
power_10(300, true, false, "E") {
|
||||||
@Override
|
@Override
|
||||||
@ -47,6 +52,7 @@ public enum MathType {
|
|||||||
},
|
},
|
||||||
|
|
||||||
postfix_function(400, true, true, Functions.allPostfix) {
|
postfix_function(400, true, true, Functions.allPostfix) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getSubstituteToJscl(@NotNull String match) {
|
protected String getSubstituteToJscl(@NotNull String match) {
|
||||||
final String result;
|
final String result;
|
||||||
|
@ -41,7 +41,7 @@ public enum CalculatorEngine {
|
|||||||
|
|
||||||
instance;
|
instance;
|
||||||
|
|
||||||
private static final String GROUPING_SEPARATOR_P_KEY = "org.solovyev.android.calculator.CalculatorActivity_calc_grouping_separator";
|
public static final String GROUPING_SEPARATOR_P_KEY = "org.solovyev.android.calculator.CalculatorActivity_calc_grouping_separator";
|
||||||
private static final String GROUPING_SEPARATOR_DEFAULT = " ";
|
private static final String GROUPING_SEPARATOR_DEFAULT = " ";
|
||||||
|
|
||||||
private static final String RESULT_PRECISION_P_KEY = "org.solovyev.android.calculator.CalculatorModel_result_precision";
|
private static final String RESULT_PRECISION_P_KEY = "org.solovyev.android.calculator.CalculatorModel_result_precision";
|
||||||
|
Loading…
Reference in New Issue
Block a user