registries
This commit is contained in:
parent
78a1cc4942
commit
4134204e67
@ -1,232 +1,236 @@
|
|||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
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.history.CalculatorHistoryState;
|
import org.solovyev.android.calculator.history.CalculatorHistoryState;
|
||||||
import org.solovyev.android.calculator.view.AngleUnitsButton;
|
import org.solovyev.android.calculator.view.AngleUnitsButton;
|
||||||
import org.solovyev.android.calculator.view.NumeralBasesButton;
|
import org.solovyev.android.calculator.view.NumeralBasesButton;
|
||||||
import org.solovyev.android.calculator.view.OnDragListenerVibrator;
|
import org.solovyev.android.calculator.view.OnDragListenerVibrator;
|
||||||
import org.solovyev.android.history.HistoryDragProcessor;
|
import org.solovyev.android.history.HistoryDragProcessor;
|
||||||
import org.solovyev.android.view.drag.*;
|
import org.solovyev.android.view.drag.*;
|
||||||
import org.solovyev.common.Announcer;
|
import org.solovyev.common.Announcer;
|
||||||
import org.solovyev.common.math.Point2d;
|
import org.solovyev.common.math.Point2d;
|
||||||
|
|
||||||
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.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
* Date: 9/28/12
|
* Date: 9/28/12
|
||||||
* Time: 12:12 AM
|
* Time: 12:12 AM
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private CalculatorPreferences.Gui.Layout layout;
|
private CalculatorPreferences.Gui.Layout layout;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private CalculatorPreferences.Gui.Theme theme;
|
private CalculatorPreferences.Gui.Theme theme;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Vibrator vibrator;
|
private Vibrator vibrator;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final Announcer<DragPreferencesChangeListener> dpclRegister = new Announcer<DragPreferencesChangeListener>(DragPreferencesChangeListener.class);
|
private final Announcer<DragPreferencesChangeListener> dpclRegister = new Announcer<DragPreferencesChangeListener>(DragPreferencesChangeListener.class);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private String logTag = "CalculatorActivity";
|
private String logTag = "CalculatorActivity";
|
||||||
|
|
||||||
protected AbstractCalculatorHelper() {
|
protected AbstractCalculatorHelper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractCalculatorHelper(@NotNull String logTag) {
|
protected AbstractCalculatorHelper(@NotNull String logTag) {
|
||||||
this.logTag = logTag;
|
this.logTag = logTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onCreate(@NotNull Activity activity) {
|
protected void onCreate(@NotNull Activity activity) {
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||||
|
|
||||||
vibrator = (Vibrator) activity.getSystemService(Activity.VIBRATOR_SERVICE);
|
vibrator = (Vibrator) activity.getSystemService(Activity.VIBRATOR_SERVICE);
|
||||||
layout = CalculatorPreferences.Gui.layout.getPreferenceNoError(preferences);
|
layout = CalculatorPreferences.Gui.layout.getPreferenceNoError(preferences);
|
||||||
theme = CalculatorPreferences.Gui.theme.getPreferenceNoError(preferences);
|
theme = CalculatorPreferences.Gui.theme.getPreferenceNoError(preferences);
|
||||||
|
|
||||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logDebug(@NotNull String message) {
|
public void logDebug(@NotNull String message) {
|
||||||
Log.d(logTag, message);
|
Log.d(logTag, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processButtons(@NotNull final Activity activity, @NotNull View root) {
|
public void logError(@NotNull String message) {
|
||||||
dpclRegister.clear();
|
Log.e(logTag, message);
|
||||||
|
}
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
|
||||||
final SimpleOnDragListener.Preferences dragPreferences = SimpleOnDragListener.getPreferences(preferences, activity);
|
public void processButtons(@NotNull final Activity activity, @NotNull View root) {
|
||||||
|
dpclRegister.clear();
|
||||||
setOnDragListeners(root, dragPreferences, preferences);
|
|
||||||
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||||
final OnDragListener historyOnDragListener = new OnDragListenerVibrator(newOnDragListener(new HistoryDragProcessor<CalculatorHistoryState>(getCalculator()), dragPreferences), vibrator, preferences);
|
final SimpleOnDragListener.Preferences dragPreferences = SimpleOnDragListener.getPreferences(preferences, activity);
|
||||||
final DragButton historyButton = getButton(root, R.id.historyButton);
|
|
||||||
if (historyButton != null) {
|
setOnDragListeners(root, dragPreferences, preferences);
|
||||||
historyButton.setOnDragListener(historyOnDragListener);
|
|
||||||
}
|
final OnDragListener historyOnDragListener = new OnDragListenerVibrator(newOnDragListener(new HistoryDragProcessor<CalculatorHistoryState>(getCalculator()), dragPreferences), vibrator, preferences);
|
||||||
|
final DragButton historyButton = getButton(root, R.id.historyButton);
|
||||||
final DragButton subtractionButton = getButton(root, R.id.subtractionButton);
|
if (historyButton != null) {
|
||||||
if (subtractionButton != null) {
|
historyButton.setOnDragListener(historyOnDragListener);
|
||||||
subtractionButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new SimpleOnDragListener.DragProcessor() {
|
}
|
||||||
@Override
|
|
||||||
public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) {
|
final DragButton subtractionButton = getButton(root, R.id.subtractionButton);
|
||||||
if (dragDirection == DragDirection.down) {
|
if (subtractionButton != null) {
|
||||||
CalculatorActivity.operatorsButtonClickHandler(activity);
|
subtractionButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new SimpleOnDragListener.DragProcessor() {
|
||||||
return true;
|
@Override
|
||||||
}
|
public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) {
|
||||||
return false;
|
if (dragDirection == DragDirection.down) {
|
||||||
}
|
CalculatorActivity.operatorsButtonClickHandler(activity);
|
||||||
}, dragPreferences), vibrator, preferences));
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
final OnDragListener toPositionOnDragListener = new OnDragListenerVibrator(new SimpleOnDragListener(new CursorDragProcessor(), dragPreferences), vibrator, preferences);
|
}
|
||||||
|
}, dragPreferences), vibrator, preferences));
|
||||||
final DragButton rightButton = getButton(root, R.id.rightButton);
|
}
|
||||||
if (rightButton != null) {
|
|
||||||
rightButton.setOnDragListener(toPositionOnDragListener);
|
final OnDragListener toPositionOnDragListener = new OnDragListenerVibrator(new SimpleOnDragListener(new CursorDragProcessor(), dragPreferences), vibrator, preferences);
|
||||||
}
|
|
||||||
|
final DragButton rightButton = getButton(root, R.id.rightButton);
|
||||||
final DragButton leftButton = getButton(root, R.id.leftButton);
|
if (rightButton != null) {
|
||||||
if (leftButton != null) {
|
rightButton.setOnDragListener(toPositionOnDragListener);
|
||||||
leftButton.setOnDragListener(toPositionOnDragListener);
|
}
|
||||||
}
|
|
||||||
|
final DragButton leftButton = getButton(root, R.id.leftButton);
|
||||||
final DragButton equalsButton = getButton(root, R.id.equalsButton);
|
if (leftButton != null) {
|
||||||
if (equalsButton != null) {
|
leftButton.setOnDragListener(toPositionOnDragListener);
|
||||||
equalsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new EvalDragProcessor(), dragPreferences), vibrator, preferences));
|
}
|
||||||
}
|
|
||||||
|
final DragButton equalsButton = getButton(root, R.id.equalsButton);
|
||||||
final AngleUnitsButton angleUnitsButton = (AngleUnitsButton) getButton(root, R.id.sixDigitButton);
|
if (equalsButton != null) {
|
||||||
if (angleUnitsButton != null) {
|
equalsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new EvalDragProcessor(), dragPreferences), vibrator, preferences));
|
||||||
angleUnitsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.AngleUnitsChanger(activity), dragPreferences), vibrator, preferences));
|
}
|
||||||
}
|
|
||||||
|
final AngleUnitsButton angleUnitsButton = (AngleUnitsButton) getButton(root, R.id.sixDigitButton);
|
||||||
final NumeralBasesButton clearButton = (NumeralBasesButton) getButton(root, R.id.clearButton);
|
if (angleUnitsButton != null) {
|
||||||
if (clearButton != null) {
|
angleUnitsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.AngleUnitsChanger(activity), dragPreferences), vibrator, preferences));
|
||||||
clearButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.NumeralBasesChanger(activity), dragPreferences), vibrator, preferences));
|
}
|
||||||
}
|
|
||||||
|
final NumeralBasesButton clearButton = (NumeralBasesButton) getButton(root, R.id.clearButton);
|
||||||
final DragButton varsButton = getButton(root, R.id.varsButton);
|
if (clearButton != null) {
|
||||||
if (varsButton != null) {
|
clearButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.NumeralBasesChanger(activity), dragPreferences), vibrator, preferences));
|
||||||
varsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.VarsDragProcessor(activity), dragPreferences), vibrator, preferences));
|
}
|
||||||
}
|
|
||||||
|
final DragButton varsButton = getButton(root, R.id.varsButton);
|
||||||
final DragButton roundBracketsButton = getButton(root, R.id.roundBracketsButton);
|
if (varsButton != null) {
|
||||||
if (roundBracketsButton != null) {
|
varsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.VarsDragProcessor(activity), dragPreferences), vibrator, preferences));
|
||||||
roundBracketsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.RoundBracketsDragProcessor(), dragPreferences), vibrator, preferences));
|
}
|
||||||
}
|
|
||||||
|
final DragButton roundBracketsButton = getButton(root, R.id.roundBracketsButton);
|
||||||
if (layout == CalculatorPreferences.Gui.Layout.simple) {
|
if (roundBracketsButton != null) {
|
||||||
toggleButtonDirectionText(root, R.id.oneDigitButton, false, DragDirection.up, DragDirection.down);
|
roundBracketsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.RoundBracketsDragProcessor(), dragPreferences), vibrator, preferences));
|
||||||
toggleButtonDirectionText(root, R.id.twoDigitButton, false, DragDirection.up, DragDirection.down);
|
}
|
||||||
toggleButtonDirectionText(root, R.id.threeDigitButton, false, DragDirection.up, DragDirection.down);
|
|
||||||
|
if (layout == CalculatorPreferences.Gui.Layout.simple) {
|
||||||
toggleButtonDirectionText(root, R.id.sixDigitButton, false, DragDirection.up, DragDirection.down);
|
toggleButtonDirectionText(root, R.id.oneDigitButton, false, DragDirection.up, DragDirection.down);
|
||||||
toggleButtonDirectionText(root, R.id.sevenDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
toggleButtonDirectionText(root, R.id.twoDigitButton, false, DragDirection.up, DragDirection.down);
|
||||||
toggleButtonDirectionText(root, R.id.eightDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
toggleButtonDirectionText(root, R.id.threeDigitButton, false, DragDirection.up, DragDirection.down);
|
||||||
|
|
||||||
toggleButtonDirectionText(root, R.id.clearButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
toggleButtonDirectionText(root, R.id.sixDigitButton, false, DragDirection.up, DragDirection.down);
|
||||||
|
toggleButtonDirectionText(root, R.id.sevenDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
||||||
toggleButtonDirectionText(root, R.id.fourDigitButton, false, DragDirection.down);
|
toggleButtonDirectionText(root, R.id.eightDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
||||||
toggleButtonDirectionText(root, R.id.fiveDigitButton, false, DragDirection.down);
|
|
||||||
|
toggleButtonDirectionText(root, R.id.clearButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
||||||
toggleButtonDirectionText(root, R.id.nineDigitButton, false, DragDirection.left);
|
|
||||||
|
toggleButtonDirectionText(root, R.id.fourDigitButton, false, DragDirection.down);
|
||||||
toggleButtonDirectionText(root, R.id.multiplicationButton, false, DragDirection.left);
|
toggleButtonDirectionText(root, R.id.fiveDigitButton, false, DragDirection.down);
|
||||||
toggleButtonDirectionText(root, R.id.plusButton, false, DragDirection.down, DragDirection.up);
|
|
||||||
}
|
toggleButtonDirectionText(root, R.id.nineDigitButton, false, DragDirection.left);
|
||||||
|
|
||||||
CalculatorButtons.processButtons(true, theme, root);
|
toggleButtonDirectionText(root, R.id.multiplicationButton, false, DragDirection.left);
|
||||||
CalculatorButtons.toggleEqualsButton(preferences, activity);
|
toggleButtonDirectionText(root, R.id.plusButton, false, DragDirection.down, DragDirection.up);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleButtonDirectionText(@NotNull View root, int id, boolean showDirectionText, @NotNull DragDirection... dragDirections) {
|
CalculatorButtons.processButtons(true, theme, root);
|
||||||
final View v = getButton(root, id);
|
CalculatorButtons.toggleEqualsButton(preferences, activity);
|
||||||
if (v instanceof DirectionDragButton ) {
|
}
|
||||||
final DirectionDragButton button = (DirectionDragButton)v;
|
|
||||||
for (DragDirection dragDirection : dragDirections) {
|
private void toggleButtonDirectionText(@NotNull View root, int id, boolean showDirectionText, @NotNull DragDirection... dragDirections) {
|
||||||
button.showDirectionText(showDirectionText, dragDirection);
|
final View v = getButton(root, id);
|
||||||
}
|
if (v instanceof DirectionDragButton ) {
|
||||||
}
|
final DirectionDragButton button = (DirectionDragButton)v;
|
||||||
}
|
for (DragDirection dragDirection : dragDirections) {
|
||||||
|
button.showDirectionText(showDirectionText, dragDirection);
|
||||||
@NotNull
|
}
|
||||||
private Calculator getCalculator() {
|
}
|
||||||
return CalculatorLocatorImpl.getInstance().getCalculator();
|
}
|
||||||
}
|
|
||||||
|
@NotNull
|
||||||
|
private Calculator getCalculator() {
|
||||||
private void setOnDragListeners(@NotNull View root, @NotNull SimpleOnDragListener.Preferences dragPreferences, @NotNull SharedPreferences preferences) {
|
return CalculatorLocatorImpl.getInstance().getCalculator();
|
||||||
final OnDragListener onDragListener = new OnDragListenerVibrator(newOnDragListener(new DigitButtonDragProcessor(getKeyboard()), dragPreferences), vibrator, preferences);
|
}
|
||||||
|
|
||||||
final List<Integer> dragButtonIds = new ArrayList<Integer>();
|
|
||||||
|
private void setOnDragListeners(@NotNull View root, @NotNull SimpleOnDragListener.Preferences dragPreferences, @NotNull SharedPreferences preferences) {
|
||||||
for (Field field : R.id.class.getDeclaredFields()) {
|
final OnDragListener onDragListener = new OnDragListenerVibrator(newOnDragListener(new DigitButtonDragProcessor(getKeyboard()), dragPreferences), vibrator, preferences);
|
||||||
int modifiers = field.getModifiers();
|
|
||||||
if (Modifier.isFinal(modifiers) && Modifier.isStatic(modifiers)) {
|
final List<Integer> dragButtonIds = new ArrayList<Integer>();
|
||||||
try {
|
|
||||||
int viewId = field.getInt(R.id.class);
|
for (Field field : R.id.class.getDeclaredFields()) {
|
||||||
final View view = root.findViewById(viewId);
|
int modifiers = field.getModifiers();
|
||||||
if (view instanceof DragButton) {
|
if (Modifier.isFinal(modifiers) && Modifier.isStatic(modifiers)) {
|
||||||
dragButtonIds.add(viewId);
|
try {
|
||||||
}
|
int viewId = field.getInt(R.id.class);
|
||||||
} catch (IllegalAccessException e) {
|
final View view = root.findViewById(viewId);
|
||||||
Log.e(R.id.class.getName(), e.getMessage());
|
if (view instanceof DragButton) {
|
||||||
}
|
dragButtonIds.add(viewId);
|
||||||
}
|
}
|
||||||
}
|
} catch (IllegalAccessException e) {
|
||||||
|
Log.e(R.id.class.getName(), e.getMessage());
|
||||||
for (Integer dragButtonId : dragButtonIds) {
|
}
|
||||||
final DragButton button = getButton(root, dragButtonId);
|
}
|
||||||
if (button != null) {
|
}
|
||||||
button.setOnDragListener(onDragListener);
|
|
||||||
}
|
for (Integer dragButtonId : dragButtonIds) {
|
||||||
}
|
final DragButton button = getButton(root, dragButtonId);
|
||||||
}
|
if (button != null) {
|
||||||
|
button.setOnDragListener(onDragListener);
|
||||||
@NotNull
|
}
|
||||||
private CalculatorKeyboard getKeyboard() {
|
}
|
||||||
return CalculatorLocatorImpl.getInstance().getKeyboard();
|
}
|
||||||
}
|
|
||||||
|
@NotNull
|
||||||
@Nullable
|
private CalculatorKeyboard getKeyboard() {
|
||||||
private <T extends DragButton> T getButton(@NotNull View root, int buttonId) {
|
return CalculatorLocatorImpl.getInstance().getKeyboard();
|
||||||
return (T) root.findViewById(buttonId);
|
}
|
||||||
}
|
|
||||||
|
@Nullable
|
||||||
@NotNull
|
private <T extends DragButton> T getButton(@NotNull View root, int buttonId) {
|
||||||
private SimpleOnDragListener newOnDragListener(@NotNull SimpleOnDragListener.DragProcessor dragProcessor,
|
return (T) root.findViewById(buttonId);
|
||||||
@NotNull SimpleOnDragListener.Preferences dragPreferences) {
|
}
|
||||||
final SimpleOnDragListener onDragListener = new SimpleOnDragListener(dragProcessor, dragPreferences);
|
|
||||||
dpclRegister.addListener(onDragListener);
|
@NotNull
|
||||||
return onDragListener;
|
private SimpleOnDragListener newOnDragListener(@NotNull SimpleOnDragListener.DragProcessor dragProcessor,
|
||||||
}
|
@NotNull SimpleOnDragListener.Preferences dragPreferences) {
|
||||||
|
final SimpleOnDragListener onDragListener = new SimpleOnDragListener(dragProcessor, dragPreferences);
|
||||||
@Override
|
dpclRegister.addListener(onDragListener);
|
||||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
return onDragListener;
|
||||||
if (key != null && key.startsWith("org.solovyev.android.calculator.DragButtonCalibrationActivity")) {
|
}
|
||||||
dpclRegister.announce().onDragPreferencesChange(SimpleOnDragListener.getPreferences(preferences, CalculatorApplication.getInstance()));
|
|
||||||
}
|
@Override
|
||||||
}
|
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
||||||
|
if (key != null && key.startsWith("org.solovyev.android.calculator.DragButtonCalibrationActivity")) {
|
||||||
public void onDestroy(@NotNull Activity activity) {
|
dpclRegister.announce().onDragPreferencesChange(SimpleOnDragListener.getPreferences(preferences, CalculatorApplication.getInstance()));
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
}
|
||||||
|
}
|
||||||
preferences.unregisterOnSharedPreferenceChangeListener(this);
|
|
||||||
}
|
public void onDestroy(@NotNull Activity activity) {
|
||||||
}
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||||
|
|
||||||
|
preferences.unregisterOnSharedPreferenceChangeListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -27,7 +27,7 @@ public enum AndroidFunctionCategory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public AndroidFunctionCategory valueOf( @NotNull FunctionCategory functionCategory ) {
|
public static AndroidFunctionCategory valueOf( @NotNull FunctionCategory functionCategory ) {
|
||||||
for (AndroidFunctionCategory androidFunctionCategory : values()) {
|
for (AndroidFunctionCategory androidFunctionCategory : values()) {
|
||||||
if ( androidFunctionCategory.name().equals(functionCategory.name()) ) {
|
if ( androidFunctionCategory.name().equals(functionCategory.name()) ) {
|
||||||
return androidFunctionCategory;
|
return androidFunctionCategory;
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: serso
|
||||||
|
* Date: 10/7/12
|
||||||
|
* Time: 7:41 PM
|
||||||
|
*/
|
||||||
|
public enum AndroidOperatorCategory {
|
||||||
|
|
||||||
|
derivatives(R.string.derivatives),
|
||||||
|
other(R.string.other),
|
||||||
|
my(R.string.c_fun_category_my),
|
||||||
|
common(R.string.c_fun_category_common);
|
||||||
|
|
||||||
|
private final int captionId;
|
||||||
|
|
||||||
|
AndroidOperatorCategory(int captionId) {
|
||||||
|
this.captionId = captionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCaptionId() {
|
||||||
|
return captionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static AndroidOperatorCategory valueOf(@NotNull OperatorCategory operatorCategory) {
|
||||||
|
for (AndroidOperatorCategory androidOperatorCategory : values()) {
|
||||||
|
if ( androidOperatorCategory.name().equals(operatorCategory.name()) ) {
|
||||||
|
return androidOperatorCategory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
||||||
|
* For more information, please, contact se.solovyev@gmail.com
|
||||||
|
* or visit http://se.solovyev.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
|
import jscl.math.operator.*;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.solovyev.common.JBuilder;
|
||||||
|
import org.solovyev.common.math.MathRegistry;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: serso
|
||||||
|
* Date: 11/17/11
|
||||||
|
* Time: 11:29 PM
|
||||||
|
*/
|
||||||
|
public class AndroidOperatorsMathRegistry extends AbstractCalculatorMathRegistry<Operator, MathPersistenceEntity> {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static final Map<String, String> substitutes = new HashMap<String, String>();
|
||||||
|
static {
|
||||||
|
substitutes.put("Σ", "sum");
|
||||||
|
substitutes.put("∏", "product");
|
||||||
|
substitutes.put("∂", "derivative");
|
||||||
|
substitutes.put("∫ab", "integral_ab");
|
||||||
|
substitutes.put("∫", "integral");
|
||||||
|
substitutes.put("Σ", "sum");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static final String OPERATOR_DESCRIPTION_PREFIX = "c_op_description_";
|
||||||
|
|
||||||
|
public AndroidOperatorsMathRegistry(@NotNull MathRegistry<Operator> functionsRegistry,
|
||||||
|
@NotNull MathEntityDao<MathPersistenceEntity> mathEntityDao) {
|
||||||
|
super(functionsRegistry, OPERATOR_DESCRIPTION_PREFIX, mathEntityDao);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
protected Map<String, String> getSubstitutes() {
|
||||||
|
return substitutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCategory(@NotNull Operator operator) {
|
||||||
|
for (OperatorCategory category : OperatorCategory.values()) {
|
||||||
|
if ( category.isInCategory(operator) ) {
|
||||||
|
return category.name();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load() {
|
||||||
|
// not supported yet
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
protected JBuilder<? extends Operator> createBuilder(@NotNull MathPersistenceEntity entity) {
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save() {
|
||||||
|
// not supported yet
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected MathPersistenceEntity transform(@NotNull Operator entity) {
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
protected MathEntityPersistenceContainer<MathPersistenceEntity> createPersistenceContainer() {
|
||||||
|
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
**********************************************************************
|
||||||
|
*
|
||||||
|
* STATIC
|
||||||
|
*
|
||||||
|
**********************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
@ -58,4 +58,5 @@ public interface CalculatorActivityHelper {
|
|||||||
|
|
||||||
void processButtons(@NotNull Activity activity, @NotNull View root);
|
void processButtons(@NotNull Activity activity, @NotNull View root);
|
||||||
|
|
||||||
|
void logError(@NotNull String message);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,78 @@
|
|||||||
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
|
import jscl.math.operator.*;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.solovyev.common.collections.CollectionsUtils;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: serso
|
||||||
|
* Date: 10/7/12
|
||||||
|
* Time: 7:40 PM
|
||||||
|
*/
|
||||||
|
public enum OperatorCategory {
|
||||||
|
|
||||||
|
derivatives(100){
|
||||||
|
@Override
|
||||||
|
public boolean isInCategory(@NotNull Operator operator) {
|
||||||
|
return operator instanceof Derivative || operator instanceof Integral || operator instanceof IndefiniteIntegral;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
other(200) {
|
||||||
|
@Override
|
||||||
|
public boolean isInCategory(@NotNull Operator operator) {
|
||||||
|
return operator instanceof Sum || operator instanceof Product;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
my(0) {
|
||||||
|
@Override
|
||||||
|
public boolean isInCategory(@NotNull Operator operator) {
|
||||||
|
return !operator.isSystem();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
common(50) {
|
||||||
|
@Override
|
||||||
|
public boolean isInCategory(@NotNull Operator operator) {
|
||||||
|
for (OperatorCategory category : values()) {
|
||||||
|
if ( category != this ) {
|
||||||
|
if ( category.isInCategory(operator) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private final int tabOrder;
|
||||||
|
|
||||||
|
OperatorCategory(int tabOrder) {
|
||||||
|
this.tabOrder = tabOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract boolean isInCategory(@NotNull Operator operator);
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static List<OperatorCategory> getCategoriesByTabOrder() {
|
||||||
|
final List<OperatorCategory> result = CollectionsUtils.asList(OperatorCategory.values());
|
||||||
|
|
||||||
|
Collections.sort(result, new Comparator<OperatorCategory>() {
|
||||||
|
@Override
|
||||||
|
public int compare(OperatorCategory category, OperatorCategory category1) {
|
||||||
|
return category.tabOrder - category1.tabOrder;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// todo serso: current solution (as creating operators is not implemented yet)
|
||||||
|
result.remove(my);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@
|
|||||||
package org.solovyev.android.calculator.math.edit;
|
package org.solovyev.android.calculator.math.edit;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -33,7 +34,12 @@ public class CalculatorFunctionsActivity extends SherlockFragmentActivity implem
|
|||||||
final CalculatorFragmentType fragmentType = CalculatorFragmentType.functions;
|
final CalculatorFragmentType fragmentType = CalculatorFragmentType.functions;
|
||||||
|
|
||||||
for (FunctionCategory category : FunctionCategory.getCategoriesByTabOrder()) {
|
for (FunctionCategory category : FunctionCategory.getCategoriesByTabOrder()) {
|
||||||
activityHelper.addTab(this, fragmentType.createSubFragmentTag(category.name()), fragmentType.getFragmentClass(), AbstractMathEntityListFragment.createBundleFor(category.name()), category.getCaptionId(), R.id.main_layout);
|
final AndroidFunctionCategory androidCategory = AndroidFunctionCategory.valueOf(category);
|
||||||
|
if (androidCategory != null) {
|
||||||
|
activityHelper.addTab(this, fragmentType.createSubFragmentTag(category.name()), fragmentType.getFragmentClass(), AbstractMathEntityListFragment.createBundleFor(category.name()), androidCategory.getCaptionId(), R.id.main_layout);
|
||||||
|
} else {
|
||||||
|
Log.e(CalculatorFunctionsActivity.class.getSimpleName(), "Unable to find android function category for " + category);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,78 +1,82 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
||||||
* For more information, please, contact se.solovyev@gmail.com
|
* For more information, please, contact se.solovyev@gmail.com
|
||||||
* or visit http://se.solovyev.org
|
* or visit http://se.solovyev.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.solovyev.android.calculator.math.edit;
|
package org.solovyev.android.calculator.math.edit;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||||
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.*;
|
import org.solovyev.android.calculator.*;
|
||||||
import org.solovyev.android.calculator.about.CalculatorFragmentType;
|
import org.solovyev.android.calculator.about.CalculatorFragmentType;
|
||||||
import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
|
import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
|
||||||
import org.solovyev.android.calculator.model.AndroidOperatorsMathRegistry;
|
|
||||||
|
/**
|
||||||
/**
|
* User: serso
|
||||||
* User: serso
|
* Date: 12/21/11
|
||||||
* Date: 12/21/11
|
* Time: 10:33 PM
|
||||||
* Time: 10:33 PM
|
*/
|
||||||
*/
|
public class CalculatorOperatorsActivity extends SherlockFragmentActivity implements CalculatorEventListener {
|
||||||
public class CalculatorOperatorsActivity extends SherlockFragmentActivity implements CalculatorEventListener {
|
|
||||||
|
@NotNull
|
||||||
@NotNull
|
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryActivity.class.getSimpleName());
|
||||||
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryActivity.class.getSimpleName());
|
|
||||||
|
@Override
|
||||||
@Override
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
super.onCreate(savedInstanceState);
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
activityHelper.onCreate(this, savedInstanceState);
|
||||||
activityHelper.onCreate(this, savedInstanceState);
|
|
||||||
|
final CalculatorFragmentType fragmentType = CalculatorFragmentType.operators;
|
||||||
final CalculatorFragmentType fragmentType = CalculatorFragmentType.operators;
|
|
||||||
|
for (OperatorCategory category : OperatorCategory.getCategoriesByTabOrder()) {
|
||||||
for (AndroidOperatorsMathRegistry.Category category : AndroidOperatorsMathRegistry.Category.getCategoriesByTabOrder()) {
|
final AndroidOperatorCategory androidCategory = AndroidOperatorCategory.valueOf(category);
|
||||||
activityHelper.addTab(this, fragmentType.createSubFragmentTag(category.name()), fragmentType.getFragmentClass(), AbstractMathEntityListFragment.createBundleFor(category.name()), category.getCaptionId(), R.id.main_layout);
|
if (androidCategory != null) {
|
||||||
}
|
activityHelper.addTab(this, fragmentType.createSubFragmentTag(category.name()), fragmentType.getFragmentClass(), AbstractMathEntityListFragment.createBundleFor(category.name()), androidCategory.getCaptionId(), R.id.main_layout);
|
||||||
}
|
} else {
|
||||||
|
activityHelper.logError("Unable to find android operator category for " + category);
|
||||||
@Override
|
}
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
}
|
||||||
super.onSaveInstanceState(outState);
|
}
|
||||||
|
|
||||||
activityHelper.onSaveInstanceState(this, outState);
|
@Override
|
||||||
}
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
activityHelper.onSaveInstanceState(this, outState);
|
||||||
super.onResume();
|
}
|
||||||
|
|
||||||
activityHelper.onResume(this);
|
@Override
|
||||||
}
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
activityHelper.onResume(this);
|
||||||
this.activityHelper.onPause(this);
|
}
|
||||||
|
|
||||||
super.onPause();
|
@Override
|
||||||
}
|
protected void onPause() {
|
||||||
|
this.activityHelper.onPause(this);
|
||||||
|
|
||||||
@Override
|
super.onPause();
|
||||||
protected void onDestroy() {
|
}
|
||||||
super.onDestroy();
|
|
||||||
|
|
||||||
this.activityHelper.onDestroy(this);
|
@Override
|
||||||
}
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
@Override
|
|
||||||
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) {
|
this.activityHelper.onDestroy(this);
|
||||||
switch (calculatorEventType) {
|
}
|
||||||
case use_operator:
|
|
||||||
this.finish();
|
@Override
|
||||||
break;
|
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) {
|
||||||
}
|
switch (calculatorEventType) {
|
||||||
}
|
case use_operator:
|
||||||
}
|
this.finish();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,165 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
|
||||||
* For more information, please, contact se.solovyev@gmail.com
|
|
||||||
* or visit http://se.solovyev.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.solovyev.android.calculator.model;
|
|
||||||
|
|
||||||
import jscl.math.operator.*;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.solovyev.android.calculator.*;
|
|
||||||
import org.solovyev.common.JBuilder;
|
|
||||||
import org.solovyev.common.collections.CollectionsUtils;
|
|
||||||
import org.solovyev.common.math.MathRegistry;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User: serso
|
|
||||||
* Date: 11/17/11
|
|
||||||
* Time: 11:29 PM
|
|
||||||
*/
|
|
||||||
public class AndroidOperatorsMathRegistry extends AbstractCalculatorMathRegistry<Operator, MathPersistenceEntity> {
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private static final Map<String, String> substitutes = new HashMap<String, String>();
|
|
||||||
static {
|
|
||||||
substitutes.put("Σ", "sum");
|
|
||||||
substitutes.put("∏", "product");
|
|
||||||
substitutes.put("∂", "derivative");
|
|
||||||
substitutes.put("∫ab", "integral_ab");
|
|
||||||
substitutes.put("∫", "integral");
|
|
||||||
substitutes.put("Σ", "sum");
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private static final String OPERATOR_DESCRIPTION_PREFIX = "c_op_description_";
|
|
||||||
|
|
||||||
protected AndroidOperatorsMathRegistry(@NotNull MathRegistry<Operator> functionsRegistry,
|
|
||||||
@NotNull MathEntityDao<MathPersistenceEntity> mathEntityDao) {
|
|
||||||
super(functionsRegistry, OPERATOR_DESCRIPTION_PREFIX, mathEntityDao);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected Map<String, String> getSubstitutes() {
|
|
||||||
return substitutes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCategory(@NotNull Operator operator) {
|
|
||||||
for (Category category : Category.values()) {
|
|
||||||
if ( category.isInCategory(operator) ) {
|
|
||||||
return category.name();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load() {
|
|
||||||
// not supported yet
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected JBuilder<? extends Operator> createBuilder(@NotNull MathPersistenceEntity entity) {
|
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save() {
|
|
||||||
// not supported yet
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected MathPersistenceEntity transform(@NotNull Operator entity) {
|
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected MathEntityPersistenceContainer<MathPersistenceEntity> createPersistenceContainer() {
|
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
**********************************************************************
|
|
||||||
*
|
|
||||||
* STATIC
|
|
||||||
*
|
|
||||||
**********************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static enum Category {
|
|
||||||
|
|
||||||
derivatives(R.string.derivatives, 100){
|
|
||||||
@Override
|
|
||||||
boolean isInCategory(@NotNull Operator operator) {
|
|
||||||
return operator instanceof Derivative || operator instanceof Integral || operator instanceof IndefiniteIntegral;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
other(R.string.other, 200) {
|
|
||||||
@Override
|
|
||||||
boolean isInCategory(@NotNull Operator operator) {
|
|
||||||
return operator instanceof Sum || operator instanceof Product;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
my(R.string.c_fun_category_my, 0) {
|
|
||||||
@Override
|
|
||||||
boolean isInCategory(@NotNull Operator operator) {
|
|
||||||
return !operator.isSystem();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
common(R.string.c_fun_category_common, 50) {
|
|
||||||
@Override
|
|
||||||
boolean isInCategory(@NotNull Operator operator) {
|
|
||||||
for (Category category : values()) {
|
|
||||||
if ( category != this ) {
|
|
||||||
if ( category.isInCategory(operator) ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private final int captionId;
|
|
||||||
|
|
||||||
private final int tabOrder;
|
|
||||||
|
|
||||||
Category(int captionId, int tabOrder) {
|
|
||||||
this.captionId = captionId;
|
|
||||||
this.tabOrder = tabOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCaptionId() {
|
|
||||||
return captionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract boolean isInCategory(@NotNull Operator operator);
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static List<Category> getCategoriesByTabOrder() {
|
|
||||||
final List<Category> result = CollectionsUtils.asList(Category.values());
|
|
||||||
|
|
||||||
Collections.sort(result, new Comparator<Category>() {
|
|
||||||
@Override
|
|
||||||
public int compare(Category category, Category category1) {
|
|
||||||
return category.tabOrder - category1.tabOrder;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// todo serso: current solution (as creating operators is not implemented yet)
|
|
||||||
result.remove(my);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,10 +8,7 @@ package org.solovyev.android.calculator.model;
|
|||||||
|
|
||||||
import jscl.math.operator.Operator;
|
import jscl.math.operator.Operator;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.solovyev.android.calculator.AbstractCalculatorMathRegistry;
|
import org.solovyev.android.calculator.*;
|
||||||
import org.solovyev.android.calculator.MathEntityDao;
|
|
||||||
import org.solovyev.android.calculator.MathEntityPersistenceContainer;
|
|
||||||
import org.solovyev.android.calculator.MathPersistenceEntity;
|
|
||||||
import org.solovyev.common.JBuilder;
|
import org.solovyev.common.JBuilder;
|
||||||
import org.solovyev.common.math.MathRegistry;
|
import org.solovyev.common.math.MathRegistry;
|
||||||
|
|
||||||
@ -51,7 +48,7 @@ public class AndroidPostfixFunctionsRegistry extends AbstractCalculatorMathRegis
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCategory(@NotNull Operator operator) {
|
public String getCategory(@NotNull Operator operator) {
|
||||||
for (AndroidOperatorsMathRegistry.Category category : AndroidOperatorsMathRegistry.Category.values()) {
|
for (OperatorCategory category : OperatorCategory.values()) {
|
||||||
if ( category.isInCategory(operator) ) {
|
if ( category.isInCategory(operator) ) {
|
||||||
return category.name();
|
return category.name();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user