Merge branch 'dev' into dev-overlay-app
Conflicts: calculatorpp-core/src/main/java/org/solovyev/android/calculator/Locator.java calculatorpp-core/src/test/java/org/solovyev/android/calculator/AbstractCalculatorTest.java calculatorpp-core/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java calculatorpp/src/main/java/org/solovyev/android/calculator/external/DefaultExternalCalculatorIntentHandler.java calculatorpp/src/main/java/org/solovyev/android/calculator/external/ExternalCalculatorHelper.java calculatorpp/src/main/java/org/solovyev/android/calculator/widget/CalculatorWidgetHelper.java calculatorpp/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java
This commit is contained in:
		| @@ -70,7 +70,7 @@ public abstract class AbstractCalculatorMathRegistry<T extends MathEntity, P ext | |||||||
|                     try { |                     try { | ||||||
|                         add(createBuilder(entity)); |                         add(createBuilder(entity)); | ||||||
|                     } catch (CustomFunctionCalculationException e) { |                     } catch (CustomFunctionCalculationException e) { | ||||||
|                         CalculatorLocatorImpl.getInstance().getLogger().error(null, e.getMessage(), e); |                         Locator.getInstance().getLogger().error(null, e.getMessage(), e); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -165,7 +165,7 @@ public class CalculatorEngineImpl implements CalculatorEngine { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void softReset() { |     public void softReset() { | ||||||
|         CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.engine_preferences_changed, null); |         Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.engine_preferences_changed, null); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* |     /* | ||||||
|   | |||||||
| @@ -18,21 +18,21 @@ public enum CalculatorFixableError { | |||||||
|     must_be_rad(Messages.msg_23, Messages.msg_24, Messages.msg_25) { |     must_be_rad(Messages.msg_23, Messages.msg_24, Messages.msg_25) { | ||||||
|         @Override |         @Override | ||||||
|         public void fix() { |         public void fix() { | ||||||
|             CalculatorLocatorImpl.getInstance().getPreferenceService().setAngleUnits(AngleUnit.rad); |             Locator.getInstance().getPreferenceService().setAngleUnits(AngleUnit.rad); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     preferred_numeral_base() { |     preferred_numeral_base() { | ||||||
|         @Override |         @Override | ||||||
|         public void fix() { |         public void fix() { | ||||||
|             CalculatorLocatorImpl.getInstance().getPreferenceService().setPreferredNumeralBase(); |             Locator.getInstance().getPreferenceService().setPreferredNumeralBase(); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     preferred_angle_units() { |     preferred_angle_units() { | ||||||
|         @Override |         @Override | ||||||
|         public void fix() { |         public void fix() { | ||||||
|             CalculatorLocatorImpl.getInstance().getPreferenceService().setPreferredAngleUnits(); |             Locator.getInstance().getPreferenceService().setPreferredAngleUnits(); | ||||||
|         } |         } | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -67,9 +67,9 @@ public class CalculatorFunctionsMathRegistry extends AbstractCalculatorMathRegis | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if (editedInstance == null) { | 		if (editedInstance == null) { | ||||||
| 			CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.function_added, addedFunction, source); | 			Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.function_added, addedFunction, source); | ||||||
| 		} else { | 		} else { | ||||||
| 			CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.function_changed, ChangeImpl.newInstance(editedInstance, addedFunction), source); | 			Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.function_changed, ChangeImpl.newInstance(editedInstance, addedFunction), source); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -153,11 +153,11 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { | |||||||
|         final CalculatorEventData eventDataId = nextEventData(); |         final CalculatorEventData eventDataId = nextEventData(); | ||||||
|  |  | ||||||
|         calculationsExecutor.execute(new Runnable() { |         calculationsExecutor.execute(new Runnable() { | ||||||
|             @Override | 			@Override | ||||||
|             public void run() { | 			public void run() { | ||||||
|                 CalculatorImpl.this.evaluate(eventDataId.getSequenceId(), operation, expression, null); | 				CalculatorImpl.this.evaluate(eventDataId.getSequenceId(), operation, expression, null); | ||||||
|             } | 			} | ||||||
|         }); | 		}); | ||||||
|  |  | ||||||
|         return eventDataId; |         return eventDataId; | ||||||
|     } |     } | ||||||
| @@ -179,8 +179,8 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void init() { |     public void init() { | ||||||
|         CalculatorLocatorImpl.getInstance().getEngine().init(); |         Locator.getInstance().getEngine().init(); | ||||||
|         CalculatorLocatorImpl.getInstance().getHistory().load(); |         Locator.getInstance().getHistory().load(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setCalculateOnFly(boolean calculateOnFly) { |     public void setCalculateOnFly(boolean calculateOnFly) { | ||||||
| @@ -218,10 +218,10 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { | |||||||
|  |  | ||||||
|                 try { |                 try { | ||||||
|  |  | ||||||
| 					final CalculatorMathEngine mathEngine = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine(); | 					final CalculatorMathEngine mathEngine = Locator.getInstance().getEngine().getMathEngine(); | ||||||
|  |  | ||||||
| 					final MessageRegistry messageRegistry = new ListMessageRegistry(); | 					final MessageRegistry messageRegistry = new ListMessageRegistry(); | ||||||
| 					CalculatorLocatorImpl.getInstance().getEngine().getMathEngine0().setMessageRegistry(messageRegistry); | 					Locator.getInstance().getEngine().getMathEngine0().setMessageRegistry(messageRegistry); | ||||||
|  |  | ||||||
| 					final Generic result = operation.evaluateGeneric(jsclExpression, mathEngine); | 					final Generic result = operation.evaluateGeneric(jsclExpression, mathEngine); | ||||||
|  |  | ||||||
| @@ -229,7 +229,7 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { | |||||||
|                     result.toString(); |                     result.toString(); | ||||||
|  |  | ||||||
|                     if (messageRegistry.hasMessage()) { |                     if (messageRegistry.hasMessage()) { | ||||||
|                         final CalculatorLogger logger = CalculatorLocatorImpl.getInstance().getLogger(); |                         final CalculatorLogger logger = Locator.getInstance().getLogger(); | ||||||
|                         try { |                         try { | ||||||
|                             final List<Message> messages = new ArrayList<Message>(); |                             final List<Message> messages = new ArrayList<Message>(); | ||||||
|                             while (messageRegistry.hasMessage()) { |                             while (messageRegistry.hasMessage()) { | ||||||
| @@ -273,7 +273,7 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { | |||||||
|  |  | ||||||
|         if ( currentTime - lastPreferenceCheck > PREFERENCE_CHECK_INTERVAL ) { |         if ( currentTime - lastPreferenceCheck > PREFERENCE_CHECK_INTERVAL ) { | ||||||
|             lastPreferenceCheck = currentTime; |             lastPreferenceCheck = currentTime; | ||||||
|             CalculatorLocatorImpl.getInstance().getPreferenceService().checkPreferredPreferences(false); |             Locator.getInstance().getPreferenceService().checkPreferredPreferences(false); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -335,8 +335,8 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { | |||||||
|                                          @NotNull final NumeralBase to) { |                                          @NotNull final NumeralBase to) { | ||||||
|         final CalculatorEventData eventDataId = nextEventData(); |         final CalculatorEventData eventDataId = nextEventData(); | ||||||
|  |  | ||||||
|         final CalculatorDisplayViewState displayViewState = CalculatorLocatorImpl.getInstance().getDisplay().getViewState(); |         final CalculatorDisplayViewState displayViewState = Locator.getInstance().getDisplay().getViewState(); | ||||||
|         final NumeralBase from = CalculatorLocatorImpl.getInstance().getEngine().getNumeralBase(); |         final NumeralBase from = Locator.getInstance().getEngine().getNumeralBase(); | ||||||
|  |  | ||||||
|         calculationsExecutor.execute(new Runnable() { |         calculationsExecutor.execute(new Runnable() { | ||||||
|             @Override |             @Override | ||||||
| @@ -511,17 +511,17 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { | |||||||
|  |  | ||||||
|             case use_constant: |             case use_constant: | ||||||
|                 final IConstant constant = (IConstant)data; |                 final IConstant constant = (IConstant)data; | ||||||
|                 CalculatorLocatorImpl.getInstance().getKeyboard().buttonPressed(constant.getName()); |                 Locator.getInstance().getKeyboard().buttonPressed(constant.getName()); | ||||||
|                 break; |                 break; | ||||||
|  |  | ||||||
|             case use_operator: |             case use_operator: | ||||||
|                 final Operator operator = (Operator)data; |                 final Operator operator = (Operator)data; | ||||||
|                 CalculatorLocatorImpl.getInstance().getKeyboard().buttonPressed(operator.getName()); |                 Locator.getInstance().getKeyboard().buttonPressed(operator.getName()); | ||||||
|                 break; |                 break; | ||||||
|  |  | ||||||
|             case use_function: |             case use_function: | ||||||
|                 final Function function = (Function)data; |                 final Function function = (Function)data; | ||||||
|                 CalculatorLocatorImpl.getInstance().getKeyboard().buttonPressed(function.getName()); |                 Locator.getInstance().getKeyboard().buttonPressed(function.getName()); | ||||||
|                 break; |                 break; | ||||||
|  |  | ||||||
|         } |         } | ||||||
| @@ -532,7 +532,7 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { | |||||||
|         if (newState.isValid()) { |         if (newState.isValid()) { | ||||||
|             final String result = newState.getStringResult(); |             final String result = newState.getStringResult(); | ||||||
|             if ( !StringUtils.isEmpty(result) ) { |             if ( !StringUtils.isEmpty(result) ) { | ||||||
|                 final CalculatorMathRegistry<IConstant> varsRegistry = CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry(); |                 final CalculatorMathRegistry<IConstant> varsRegistry = Locator.getInstance().getEngine().getVarsRegistry(); | ||||||
|                 final IConstant ansVar = varsRegistry.get(CalculatorVarsRegistry.ANS); |                 final IConstant ansVar = varsRegistry.get(CalculatorVarsRegistry.ANS); | ||||||
|  |  | ||||||
|                 final Var.Builder varBuilder; |                 final Var.Builder varBuilder; | ||||||
| @@ -561,7 +561,7 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void doHistoryAction(@NotNull HistoryAction historyAction) { |     public void doHistoryAction(@NotNull HistoryAction historyAction) { | ||||||
|         final CalculatorHistory history = CalculatorLocatorImpl.getInstance().getHistory(); |         final CalculatorHistory history = Locator.getInstance().getHistory(); | ||||||
|         if (history.isActionAvailable(historyAction)) { |         if (history.isActionAvailable(historyAction)) { | ||||||
|             final CalculatorHistoryState newState = history.doAction(historyAction, getCurrentHistoryState()); |             final CalculatorHistoryState newState = history.doAction(historyAction, getCurrentHistoryState()); | ||||||
|             if (newState != null) { |             if (newState != null) { | ||||||
| @@ -591,11 +591,11 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { | |||||||
|  |  | ||||||
|     @NotNull |     @NotNull | ||||||
|     private CalculatorEditor getEditor() { |     private CalculatorEditor getEditor() { | ||||||
|         return CalculatorLocatorImpl.getInstance().getEditor(); |         return Locator.getInstance().getEditor(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @NotNull |     @NotNull | ||||||
|     private CalculatorDisplay getDisplay() { |     private CalculatorDisplay getDisplay() { | ||||||
|         return CalculatorLocatorImpl.getInstance().getDisplay(); |         return Locator.getInstance().getDisplay(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -53,7 +53,7 @@ public class CalculatorKeyboardImpl implements CalculatorKeyboard { | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 final CalculatorEditor editor = CalculatorLocatorImpl.getInstance().getEditor(); |                 final CalculatorEditor editor = Locator.getInstance().getEditor(); | ||||||
|                 editor.insert(textToBeInserted.toString(), cursorPositionOffset); |                 editor.insert(textToBeInserted.toString(), cursorPositionOffset); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @@ -73,7 +73,7 @@ public class CalculatorKeyboardImpl implements CalculatorKeyboard { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void roundBracketsButtonPressed() { |     public void roundBracketsButtonPressed() { | ||||||
|         final CalculatorEditor editor = CalculatorLocatorImpl.getInstance().getEditor(); |         final CalculatorEditor editor = Locator.getInstance().getEditor(); | ||||||
|         CalculatorEditorViewState viewState = editor.getViewState(); |         CalculatorEditorViewState viewState = editor.getViewState(); | ||||||
|  |  | ||||||
|         final int cursorPosition = viewState.getSelection(); |         final int cursorPosition = viewState.getSelection(); | ||||||
| @@ -89,36 +89,36 @@ public class CalculatorKeyboardImpl implements CalculatorKeyboard { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void pasteButtonPressed() { |     public void pasteButtonPressed() { | ||||||
|         final String text = CalculatorLocatorImpl.getInstance().getClipboard().getText(); |         final String text = Locator.getInstance().getClipboard().getText(); | ||||||
|         if (text != null) { |         if (text != null) { | ||||||
|             CalculatorLocatorImpl.getInstance().getEditor().insert(text); |             Locator.getInstance().getEditor().insert(text); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void clearButtonPressed() { |     public void clearButtonPressed() { | ||||||
|         CalculatorLocatorImpl.getInstance().getEditor().clear(); |         Locator.getInstance().getEditor().clear(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void copyButtonPressed() { |     public void copyButtonPressed() { | ||||||
|         final CalculatorDisplayViewState displayViewState = CalculatorLocatorImpl.getInstance().getDisplay().getViewState(); |         final CalculatorDisplayViewState displayViewState = Locator.getInstance().getDisplay().getViewState(); | ||||||
|         if (displayViewState.isValid()) { |         if (displayViewState.isValid()) { | ||||||
|             final CharSequence text = displayViewState.getText(); |             final CharSequence text = displayViewState.getText(); | ||||||
|             if (!StringUtils.isEmpty(text)) { |             if (!StringUtils.isEmpty(text)) { | ||||||
|                 CalculatorLocatorImpl.getInstance().getClipboard().setText(text); |                 Locator.getInstance().getClipboard().setText(text); | ||||||
|                 CalculatorLocatorImpl.getInstance().getNotifier().showMessage(CalculatorMessage.newInfoMessage(CalculatorMessages.result_copied)); |                 Locator.getInstance().getNotifier().showMessage(CalculatorMessage.newInfoMessage(CalculatorMessages.result_copied)); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void moveCursorLeft() { |     public void moveCursorLeft() { | ||||||
|         CalculatorLocatorImpl.getInstance().getEditor().moveCursorLeft(); |         Locator.getInstance().getEditor().moveCursorLeft(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void moveCursorRight() { |     public void moveCursorRight() { | ||||||
|         CalculatorLocatorImpl.getInstance().getEditor().moveCursorRight(); |         Locator.getInstance().getEditor().moveCursorRight(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -16,13 +16,13 @@ public enum CalculatorSpecialButton { | |||||||
|     history("history") { |     history("history") { | ||||||
|         @Override |         @Override | ||||||
|         public void onClick(@NotNull CalculatorKeyboard keyboard) { |         public void onClick(@NotNull CalculatorKeyboard keyboard) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_history, null); |             Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_history, null); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|     history_detached("history_detached") { |     history_detached("history_detached") { | ||||||
|         @Override |         @Override | ||||||
|         public void onClick(@NotNull CalculatorKeyboard keyboard) { |         public void onClick(@NotNull CalculatorKeyboard keyboard) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_history_detached, null); |             Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_history_detached, null); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|     cursor_right("▶") { |     cursor_right("▶") { | ||||||
| @@ -40,27 +40,27 @@ public enum CalculatorSpecialButton { | |||||||
|     settings("settings") { |     settings("settings") { | ||||||
|         @Override |         @Override | ||||||
|         public void onClick(@NotNull CalculatorKeyboard keyboard) { |         public void onClick(@NotNull CalculatorKeyboard keyboard) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_settings, null); |             Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_settings, null); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     settings_detached("settings_detached") { |     settings_detached("settings_detached") { | ||||||
|         @Override |         @Override | ||||||
|         public void onClick(@NotNull CalculatorKeyboard keyboard) { |         public void onClick(@NotNull CalculatorKeyboard keyboard) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_settings_detached, null); |             Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_settings_detached, null); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     like("like") { |     like("like") { | ||||||
|         @Override |         @Override | ||||||
|         public void onClick(@NotNull CalculatorKeyboard keyboard) { |         public void onClick(@NotNull CalculatorKeyboard keyboard) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_like_dialog, null); |             Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_like_dialog, null); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|     erase("erase") { |     erase("erase") { | ||||||
|         @Override |         @Override | ||||||
|         public void onClick(@NotNull CalculatorKeyboard keyboard) { |         public void onClick(@NotNull CalculatorKeyboard keyboard) { | ||||||
|             CalculatorLocatorImpl.getInstance().getEditor().erase(); |             Locator.getInstance().getEditor().erase(); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|     paste("paste") { |     paste("paste") { | ||||||
| @@ -78,7 +78,7 @@ public enum CalculatorSpecialButton { | |||||||
|     equals("=") { |     equals("=") { | ||||||
|         @Override |         @Override | ||||||
|         public void onClick(@NotNull CalculatorKeyboard keyboard) { |         public void onClick(@NotNull CalculatorKeyboard keyboard) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().evaluate(); |             Locator.getInstance().getCalculator().evaluate(); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|     clear("clear") { |     clear("clear") { | ||||||
| @@ -90,44 +90,44 @@ public enum CalculatorSpecialButton { | |||||||
|     functions("functions") { |     functions("functions") { | ||||||
|         @Override |         @Override | ||||||
|         public void onClick(@NotNull CalculatorKeyboard keyboard) { |         public void onClick(@NotNull CalculatorKeyboard keyboard) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_functions, null); |             Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_functions, null); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|     functions_detached("functions_detached") { |     functions_detached("functions_detached") { | ||||||
|         @Override |         @Override | ||||||
|         public void onClick(@NotNull CalculatorKeyboard keyboard) { |         public void onClick(@NotNull CalculatorKeyboard keyboard) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_functions_detached, null); |             Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_functions_detached, null); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|     open_app("open_app") { |     open_app("open_app") { | ||||||
|         @Override |         @Override | ||||||
|         public void onClick(@NotNull CalculatorKeyboard keyboard) { |         public void onClick(@NotNull CalculatorKeyboard keyboard) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.open_app, null); |             Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.open_app, null); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|     vars("vars") { |     vars("vars") { | ||||||
|         @Override |         @Override | ||||||
|         public void onClick(@NotNull CalculatorKeyboard keyboard) { |         public void onClick(@NotNull CalculatorKeyboard keyboard) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_vars, null); |             Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_vars, null); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|     vars_detached("vars_detached") { |     vars_detached("vars_detached") { | ||||||
|         @Override |         @Override | ||||||
|         public void onClick(@NotNull CalculatorKeyboard keyboard) { |         public void onClick(@NotNull CalculatorKeyboard keyboard) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_vars_detached, null); |             Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_vars_detached, null); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|     operators("operators") { |     operators("operators") { | ||||||
|         @Override |         @Override | ||||||
|         public void onClick(@NotNull CalculatorKeyboard keyboard) { |         public void onClick(@NotNull CalculatorKeyboard keyboard) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_operators, null); |             Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_operators, null); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     operators_detached("operators_detached") { |     operators_detached("operators_detached") { | ||||||
|         @Override |         @Override | ||||||
|         public void onClick(@NotNull CalculatorKeyboard keyboard) { |         public void onClick(@NotNull CalculatorKeyboard keyboard) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_operators_detached, null); |             Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_operators_detached, null); | ||||||
|         } |         } | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -32,7 +32,7 @@ public final class CalculatorUtils { | |||||||
|         final Set<Constant> notSystemConstants = new HashSet<Constant>(); |         final Set<Constant> notSystemConstants = new HashSet<Constant>(); | ||||||
|  |  | ||||||
|         for (Constant constant : expression.getConstants()) { |         for (Constant constant : expression.getConstants()) { | ||||||
|             IConstant var = CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().get(constant.getName()); |             IConstant var = Locator.getInstance().getEngine().getVarsRegistry().get(constant.getName()); | ||||||
|             if (var != null && !var.isSystem() && !var.isDefined()) { |             if (var != null && !var.isSystem() && !var.isDefined()) { | ||||||
|                 notSystemConstants.add(constant); |                 notSystemConstants.add(constant); | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -55,9 +55,9 @@ public class CalculatorVarsRegistry extends AbstractCalculatorMathRegistry<ICons | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (editedInstance == null) { |         if (editedInstance == null) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.constant_added, addedVar, source); |             Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.constant_added, addedVar, source); | ||||||
|         } else { |         } else { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.constant_changed, ChangeImpl.newInstance(editedInstance, addedVar), source); |             Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.constant_changed, ChangeImpl.newInstance(editedInstance, addedVar), source); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -39,10 +39,10 @@ public class ListCalculatorEventContainer implements CalculatorEventContainer { | |||||||
|     public void fireCalculatorEvents(@NotNull List<CalculatorEvent> calculatorEvents) { |     public void fireCalculatorEvents(@NotNull List<CalculatorEvent> calculatorEvents) { | ||||||
|         final List<CalculatorEventListener> listeners = this.listeners.getListeners(); |         final List<CalculatorEventListener> listeners = this.listeners.getListeners(); | ||||||
|  |  | ||||||
|         //final CalculatorLogger logger = CalculatorLocatorImpl.getInstance().getLogger(); |         //final CalculatorLogger logger = Locator.getInstance().getLogger(); | ||||||
|  |  | ||||||
|         for (CalculatorEvent e : calculatorEvents) { |         for (CalculatorEvent e : calculatorEvents) { | ||||||
|             //CalculatorLocatorImpl.getInstance().getLogger().debug(TAG, "Event fired: " + e.getCalculatorEventType()); |             //Locator.getInstance().getLogger().debug(TAG, "Event fired: " + e.getCalculatorEventType()); | ||||||
|             for (CalculatorEventListener listener : listeners) { |             for (CalculatorEventListener listener : listeners) { | ||||||
|                 /*long startTime = System.currentTimeMillis();*/ |                 /*long startTime = System.currentTimeMillis();*/ | ||||||
|                 listener.onCalculatorEvent(e.getCalculatorEventData(), e.getCalculatorEventType(), e.getData()); |                 listener.onCalculatorEvent(e.getCalculatorEventData(), e.getCalculatorEventType(), e.getData()); | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ import org.solovyev.android.calculator.history.CalculatorHistory; | |||||||
|  * Date: 20.09.12 |  * Date: 20.09.12 | ||||||
|  * Time: 12:45 |  * Time: 12:45 | ||||||
|  */ |  */ | ||||||
| public class CalculatorLocatorImpl implements CalculatorLocator { | public class Locator implements CalculatorLocator { | ||||||
| 
 | 
 | ||||||
|     @NotNull |     @NotNull | ||||||
|     private CalculatorEngine calculatorEngine; |     private CalculatorEngine calculatorEngine; | ||||||
| @@ -39,15 +39,15 @@ public class CalculatorLocatorImpl implements CalculatorLocator { | |||||||
|     private CalculatorClipboard calculatorClipboard = new DummyCalculatorClipboard(); |     private CalculatorClipboard calculatorClipboard = new DummyCalculatorClipboard(); | ||||||
| 
 | 
 | ||||||
|     @NotNull |     @NotNull | ||||||
|     private static final CalculatorLocator instance = new CalculatorLocatorImpl(); |     private static final CalculatorLocator instance = new Locator(); | ||||||
| 
 | 
 | ||||||
|     @NotNull |     @NotNull | ||||||
|     private CalculatorPreferenceService calculatorPreferenceService; |     private CalculatorPreferenceService calculatorPreferenceService; | ||||||
| 
 | 
 | ||||||
| 	@NotNull | 	@NotNull | ||||||
|     private CalculatorExternalListenersContainer calculatorExternalListenersContainer; | 	private CalculatorExternalListenersContainer calculatorExternalListenersContainer; | ||||||
| 
 | 
 | ||||||
|     public CalculatorLocatorImpl() { | 	public Locator() { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
| @@ -53,7 +53,7 @@ public class ToJsclTextProcessor implements TextProcessor<PreparedExpression, St | |||||||
| 		MathType.Result mathTypeResult = null; | 		MathType.Result mathTypeResult = null; | ||||||
| 		MathType.Result mathTypeBefore; | 		MathType.Result mathTypeBefore; | ||||||
|  |  | ||||||
| 		final LiteNumberBuilder nb = new LiteNumberBuilder(CalculatorLocatorImpl.getInstance().getEngine()); | 		final LiteNumberBuilder nb = new LiteNumberBuilder(Locator.getInstance().getEngine()); | ||||||
| 		for (int i = 0; i < s.length(); i++) { | 		for (int i = 0; i < s.length(); i++) { | ||||||
| 			if (s.charAt(i) == ' ') continue; | 			if (s.charAt(i) == ' ') continue; | ||||||
| 			startsWithFinder.setI(i); | 			startsWithFinder.setI(i); | ||||||
| @@ -77,7 +77,7 @@ public class ToJsclTextProcessor implements TextProcessor<PreparedExpression, St | |||||||
|                     (mathTypeBefore.getMathType() == MathType.function || mathTypeBefore.getMathType() == MathType.operator) && |                     (mathTypeBefore.getMathType() == MathType.function || mathTypeBefore.getMathType() == MathType.operator) && | ||||||
|                     CollectionsUtils.find(MathType.openGroupSymbols, startsWithFinder) != null) { |                     CollectionsUtils.find(MathType.openGroupSymbols, startsWithFinder) != null) { | ||||||
|                 final String functionName = mathTypeBefore.getMatch(); |                 final String functionName = mathTypeBefore.getMatch(); | ||||||
|                 final Function function = CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry().get(functionName); |                 final Function function = Locator.getInstance().getEngine().getFunctionsRegistry().get(functionName); | ||||||
|                 if ( function == null || function.getMinParameters() > 0 ) { |                 if ( function == null || function.getMinParameters() > 0 ) { | ||||||
|                     throw new CalculatorParseException(i, s, new CalculatorMessage(CalculatorMessages.msg_005, MessageType.error, mathTypeBefore.getMatch())); |                     throw new CalculatorParseException(i, s, new CalculatorMessage(CalculatorMessages.msg_005, MessageType.error, mathTypeBefore.getMatch())); | ||||||
|                 } |                 } | ||||||
| @@ -107,9 +107,9 @@ public class ToJsclTextProcessor implements TextProcessor<PreparedExpression, St | |||||||
| 			if (functionName == null) { | 			if (functionName == null) { | ||||||
| 				String operatorName = CollectionsUtils.find(MathType.operator.getTokens(), startsWithFinder); | 				String operatorName = CollectionsUtils.find(MathType.operator.getTokens(), startsWithFinder); | ||||||
| 				if (operatorName == null) { | 				if (operatorName == null) { | ||||||
| 					String varName = CollectionsUtils.find(CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().getNames(), startsWithFinder); | 					String varName = CollectionsUtils.find(Locator.getInstance().getEngine().getVarsRegistry().getNames(), startsWithFinder); | ||||||
| 					if (varName != null) { | 					if (varName != null) { | ||||||
| 						final IConstant var = CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().get(varName); | 						final IConstant var = Locator.getInstance().getEngine().getVarsRegistry().get(varName); | ||||||
| 						if (var != null) { | 						if (var != null) { | ||||||
| 							if (!var.isDefined()) { | 							if (!var.isDefined()) { | ||||||
| 								undefinedVars.add(var); | 								undefinedVars.add(var); | ||||||
|   | |||||||
| @@ -99,7 +99,7 @@ public class CalculatorHistoryImpl implements CalculatorHistory { | |||||||
|     public void addState(@Nullable CalculatorHistoryState currentState) { |     public void addState(@Nullable CalculatorHistoryState currentState) { | ||||||
|         synchronized (history) { |         synchronized (history) { | ||||||
|             history.addState(currentState); |             history.addState(currentState); | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.history_state_added, currentState); |             Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.history_state_added, currentState); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ import jscl.NumeralBase; | |||||||
| import jscl.math.function.Constants; | import jscl.math.function.Constants; | ||||||
| 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.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.common.JPredicate; | import org.solovyev.common.JPredicate; | ||||||
| import org.solovyev.common.StartsWithFinder; | import org.solovyev.common.StartsWithFinder; | ||||||
| import org.solovyev.android.calculator.CalculatorParseException; | import org.solovyev.android.calculator.CalculatorParseException; | ||||||
| @@ -57,7 +57,7 @@ public enum MathType { | |||||||
| 		@NotNull | 		@NotNull | ||||||
| 		@Override | 		@Override | ||||||
| 		public List<String> getTokens() { | 		public List<String> getTokens() { | ||||||
| 			return CalculatorLocatorImpl.getInstance().getEngine().getPostfixFunctionsRegistry().getNames(); | 			return Locator.getInstance().getEngine().getPostfixFunctionsRegistry().getNames(); | ||||||
| 		} | 		} | ||||||
| 	}, | 	}, | ||||||
|  |  | ||||||
| @@ -101,7 +101,7 @@ public enum MathType { | |||||||
| 		@NotNull | 		@NotNull | ||||||
| 		@Override | 		@Override | ||||||
| 		public List<String> getTokens() { | 		public List<String> getTokens() { | ||||||
| 			return CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry().getNames(); | 			return Locator.getInstance().getEngine().getFunctionsRegistry().getNames(); | ||||||
| 		} | 		} | ||||||
| 	}, | 	}, | ||||||
|  |  | ||||||
| @@ -109,7 +109,7 @@ public enum MathType { | |||||||
| 		@NotNull | 		@NotNull | ||||||
| 		@Override | 		@Override | ||||||
| 		public List<String> getTokens() { | 		public List<String> getTokens() { | ||||||
| 			return CalculatorLocatorImpl.getInstance().getEngine().getOperatorsRegistry().getNames(); | 			return Locator.getInstance().getEngine().getOperatorsRegistry().getNames(); | ||||||
| 		} | 		} | ||||||
| 	}, | 	}, | ||||||
|  |  | ||||||
| @@ -117,7 +117,7 @@ public enum MathType { | |||||||
| 		@NotNull | 		@NotNull | ||||||
| 		@Override | 		@Override | ||||||
| 		public List<String> getTokens() { | 		public List<String> getTokens() { | ||||||
| 			return CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().getNames(); | 			return Locator.getInstance().getEngine().getVarsRegistry().getNames(); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		@Override | 		@Override | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ import org.simpleframework.xml.Element; | |||||||
| import org.simpleframework.xml.ElementList; | import org.simpleframework.xml.ElementList; | ||||||
| import org.simpleframework.xml.Root; | import org.simpleframework.xml.Root; | ||||||
| import org.simpleframework.xml.Transient; | import org.simpleframework.xml.Transient; | ||||||
| import org.solovyev.android.calculator.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.CalculatorParseException; | import org.solovyev.android.calculator.CalculatorParseException; | ||||||
| import org.solovyev.android.calculator.MathPersistenceEntity; | import org.solovyev.android.calculator.MathPersistenceEntity; | ||||||
| import org.solovyev.common.math.MathEntity; | import org.solovyev.common.math.MathEntity; | ||||||
| @@ -268,7 +268,7 @@ public class AFunction implements IFunction, MathPersistenceEntity, Serializable | |||||||
|  |  | ||||||
| 			result.name = name; | 			result.name = name; | ||||||
| 			try { | 			try { | ||||||
| 				result.content = CalculatorLocatorImpl.getInstance().getCalculator().prepareExpression(value).toString(); | 				result.content = Locator.getInstance().getCalculator().prepareExpression(value).toString(); | ||||||
| 			} catch (CalculatorParseException e) { | 			} catch (CalculatorParseException e) { | ||||||
| 				throw new CreationException(e); | 				throw new CreationException(e); | ||||||
| 			} | 			} | ||||||
|   | |||||||
| @@ -3,7 +3,7 @@ package org.solovyev.android.calculator.text; | |||||||
| import jscl.math.Generic; | import jscl.math.Generic; | ||||||
| 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.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.math.MathType; | import org.solovyev.android.calculator.math.MathType; | ||||||
| import org.solovyev.android.calculator.CalculatorParseException; | import org.solovyev.android.calculator.CalculatorParseException; | ||||||
|  |  | ||||||
| @@ -57,7 +57,7 @@ public class FromJsclSimplifyTextProcessor implements TextProcessor<String, Gene | |||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 				if (needMultiplicationSign(mathTypeBefore == null ? null : mathTypeBefore.getMathType(), mathTypeAfter == null ? null : mathTypeAfter.getMathType())) { | 				if (needMultiplicationSign(mathTypeBefore == null ? null : mathTypeBefore.getMathType(), mathTypeAfter == null ? null : mathTypeAfter.getMathType())) { | ||||||
| 					sb.append(CalculatorLocatorImpl.getInstance().getEngine().getMultiplicationSign()); | 					sb.append(Locator.getInstance().getEngine().getMultiplicationSign()); | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
| 			} else { | 			} else { | ||||||
|   | |||||||
| @@ -12,8 +12,8 @@ import org.solovyev.android.calculator.history.CalculatorHistory; | |||||||
| public class AbstractCalculatorTest { | public class AbstractCalculatorTest { | ||||||
|  |  | ||||||
|     protected void setUp() throws Exception { |     protected void setUp() throws Exception { | ||||||
|         CalculatorLocatorImpl.getInstance().init(new CalculatorImpl(), CalculatorTestUtils.newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class), Mockito.mock(CalculatorExternalListenersContainer.class)); | 		Locator.getInstance().init(new CalculatorImpl(), CalculatorTestUtils.newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class), Mockito.mock(CalculatorExternalListenersContainer.class)); | ||||||
|         CalculatorLocatorImpl.getInstance().getEngine().init(); | 		Locator.getInstance().getEngine().init(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ public class CalculatorEditorImplTest extends AbstractCalculatorTest { | |||||||
|     @Before |     @Before | ||||||
|     public void setUp() throws Exception { |     public void setUp() throws Exception { | ||||||
|         super.setUp(); |         super.setUp(); | ||||||
|         this.calculatorEditor = new CalculatorEditorImpl(CalculatorLocatorImpl.getInstance().getCalculator()); |         this.calculatorEditor = new CalculatorEditorImpl(Locator.getInstance().getCalculator()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Test |     @Test | ||||||
|   | |||||||
| @@ -28,22 +28,22 @@ public class FromJsclSimplifyTextProcessorTest extends AbstractCalculatorTest { | |||||||
| 		//Assert.assertEquals("((e)(e))", tp.process("((2.718281828459045)*(2.718281828459045))")); | 		//Assert.assertEquals("((e)(e))", tp.process("((2.718281828459045)*(2.718281828459045))")); | ||||||
| 		DecimalFormatSymbols decimalGroupSymbols = new DecimalFormatSymbols(); | 		DecimalFormatSymbols decimalGroupSymbols = new DecimalFormatSymbols(); | ||||||
| 		decimalGroupSymbols.setGroupingSeparator(' '); | 		decimalGroupSymbols.setGroupingSeparator(' '); | ||||||
|         CalculatorLocatorImpl.getInstance().getEngine().setDecimalGroupSymbols(decimalGroupSymbols); |         Locator.getInstance().getEngine().setDecimalGroupSymbols(decimalGroupSymbols); | ||||||
| 		//Assert.assertEquals("123 456 789e", tp.process("123456789*2.718281828459045")); | 		//Assert.assertEquals("123 456 789e", tp.process("123456789*2.718281828459045")); | ||||||
| 		//Assert.assertEquals("123 456 789e", tp.process("123 456 789 * 2.718281828459045")); | 		//Assert.assertEquals("123 456 789e", tp.process("123 456 789 * 2.718281828459045")); | ||||||
| 		//Assert.assertEquals("t11e", tp.process("t11*2.718281828459045")); | 		//Assert.assertEquals("t11e", tp.process("t11*2.718281828459045")); | ||||||
| 		//Assert.assertEquals("e", tp.process("2.718281828459045")); | 		//Assert.assertEquals("e", tp.process("2.718281828459045")); | ||||||
| 		//Assert.assertEquals("tee", tp.process("t2.718281828459045*2.718281828459045")); | 		//Assert.assertEquals("tee", tp.process("t2.718281828459045*2.718281828459045")); | ||||||
|  |  | ||||||
| 		CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("t2.718281828459045", "2")); | 		Locator.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("t2.718281828459045", "2")); | ||||||
| 		CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("t", (String)null)); | 		Locator.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("t", (String)null)); | ||||||
| 		//Assert.assertEquals("t2.718281828459045e", tp.process("t2.718281828459045*2.718281828459045")); | 		//Assert.assertEquals("t2.718281828459045e", tp.process("t2.718281828459045*2.718281828459045")); | ||||||
| 		//Assert.assertEquals("ee", tp.process("2.718281828459045*2.718281828459045")); | 		//Assert.assertEquals("ee", tp.process("2.718281828459045*2.718281828459045")); | ||||||
| 		Assert.assertEquals("t×", tp.process("t*")); | 		Assert.assertEquals("t×", tp.process("t*")); | ||||||
| 		Assert.assertEquals("×t", tp.process("*t")); | 		Assert.assertEquals("×t", tp.process("*t")); | ||||||
| 		Assert.assertEquals("t2", tp.process("t*2")); | 		Assert.assertEquals("t2", tp.process("t*2")); | ||||||
| 		Assert.assertEquals("2t", tp.process("2*t")); | 		Assert.assertEquals("2t", tp.process("2*t")); | ||||||
| 		CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("t", (String) null)); | 		Locator.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("t", (String) null)); | ||||||
| 		Assert.assertEquals("t×", tp.process("t*")); | 		Assert.assertEquals("t×", tp.process("t*")); | ||||||
| 		Assert.assertEquals("×t", tp.process("*t")); | 		Assert.assertEquals("×t", tp.process("*t")); | ||||||
|  |  | ||||||
| @@ -56,7 +56,7 @@ public class FromJsclSimplifyTextProcessorTest extends AbstractCalculatorTest { | |||||||
| 		Assert.assertEquals("t^[2×2t]", tp.process("t^[2*2*t]")); | 		Assert.assertEquals("t^[2×2t]", tp.process("t^[2*2*t]")); | ||||||
| 		Assert.assertEquals("2t^2[2t]", tp.process("2*t^2[2*t]")); | 		Assert.assertEquals("2t^2[2t]", tp.process("2*t^2[2*t]")); | ||||||
|  |  | ||||||
| 		CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("k", (String) null)); | 		Locator.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("k", (String) null)); | ||||||
| 		Assert.assertEquals("(t+2k)[k+2t]", tp.process("(t+2*k)*[k+2*t]")); | 		Assert.assertEquals("(t+2k)[k+2t]", tp.process("(t+2*k)*[k+2*t]")); | ||||||
| 		Assert.assertEquals("(te+2k)e[k+2te]", tp.process("(t*e+2*k)*e*[k+2*t*e]")); | 		Assert.assertEquals("(te+2k)e[k+2te]", tp.process("(t*e+2*k)*e*[k+2*t*e]")); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ import org.junit.BeforeClass; | |||||||
| import org.junit.Test; | import org.junit.Test; | ||||||
| import org.solovyev.android.calculator.CalculatorDisplayViewStateImpl; | import org.solovyev.android.calculator.CalculatorDisplayViewStateImpl; | ||||||
| import org.solovyev.android.calculator.CalculatorEditorViewStateImpl; | import org.solovyev.android.calculator.CalculatorEditorViewStateImpl; | ||||||
| import org.solovyev.android.calculator.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.CalculatorTestUtils; | import org.solovyev.android.calculator.CalculatorTestUtils; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
| @@ -25,7 +25,7 @@ public class CalculatorHistoryImplTest { | |||||||
|  |  | ||||||
|     @Test |     @Test | ||||||
|     public void testGetStates() throws Exception { |     public void testGetStates() throws Exception { | ||||||
|         CalculatorHistory calculatorHistory = new CalculatorHistoryImpl(CalculatorLocatorImpl.getInstance().getCalculator()); |         CalculatorHistory calculatorHistory = new CalculatorHistoryImpl(Locator.getInstance().getCalculator()); | ||||||
|  |  | ||||||
|         addState(calculatorHistory, "1"); |         addState(calculatorHistory, "1"); | ||||||
|         addState(calculatorHistory, "12"); |         addState(calculatorHistory, "12"); | ||||||
|   | |||||||
| @@ -18,8 +18,8 @@ import junit.framework.Assert; | |||||||
| import org.junit.BeforeClass; | import org.junit.BeforeClass; | ||||||
| import org.junit.Test; | import org.junit.Test; | ||||||
| import org.solovyev.android.calculator.AbstractCalculatorTest; | import org.solovyev.android.calculator.AbstractCalculatorTest; | ||||||
|  | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.CalculatorEvalException; | import org.solovyev.android.calculator.CalculatorEvalException; | ||||||
| import org.solovyev.android.calculator.CalculatorLocatorImpl; |  | ||||||
| import org.solovyev.android.calculator.CalculatorTestUtils; | import org.solovyev.android.calculator.CalculatorTestUtils; | ||||||
| import org.solovyev.android.calculator.jscl.JsclOperation; | import org.solovyev.android.calculator.jscl.JsclOperation; | ||||||
|  |  | ||||||
| @@ -40,13 +40,13 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest { | |||||||
| 	@BeforeClass | 	@BeforeClass | ||||||
| 	public static void staticSetUp() throws Exception { | 	public static void staticSetUp() throws Exception { | ||||||
|         CalculatorTestUtils.staticSetUp(); |         CalculatorTestUtils.staticSetUp(); | ||||||
|         CalculatorLocatorImpl.getInstance().getEngine().setPrecision(3); |         Locator.getInstance().getEngine().setPrecision(3); | ||||||
| 	} | 	} | ||||||
|      |      | ||||||
|  |  | ||||||
| 	@Test | 	@Test | ||||||
| 	public void testDegrees() throws Exception { | 	public void testDegrees() throws Exception { | ||||||
| 		final MathEngine cm = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine0(); | 		final MathEngine cm = Locator.getInstance().getEngine().getMathEngine0(); | ||||||
|  |  | ||||||
| 		final AngleUnit defaultAngleUnit = cm.getAngleUnits(); | 		final AngleUnit defaultAngleUnit = cm.getAngleUnits(); | ||||||
| 		try { | 		try { | ||||||
| @@ -67,7 +67,7 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest { | |||||||
|  |  | ||||||
| /*	@Test | /*	@Test | ||||||
| 	public void testLongExecution() throws Exception { | 	public void testLongExecution() throws Exception { | ||||||
| 		final MathEngine cm = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine0(); | 		final MathEngine cm = Locator.getInstance().getEngine().getMathEngine0(); | ||||||
|  |  | ||||||
| 		try { | 		try { | ||||||
| 			cm.evaluate( "3^10^10^10"); | 			cm.evaluate( "3^10^10^10"); | ||||||
| @@ -110,7 +110,7 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest { | |||||||
|  |  | ||||||
| 	@Test | 	@Test | ||||||
| 	public void testEvaluate() throws Exception { | 	public void testEvaluate() throws Exception { | ||||||
| 		final MathEngine cm = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine0(); | 		final MathEngine cm = Locator.getInstance().getEngine().getMathEngine0(); | ||||||
|  |  | ||||||
| 		CalculatorTestUtils.assertEval("cos(t)+10%", "cos(t)+10%", JsclOperation.simplify); | 		CalculatorTestUtils.assertEval("cos(t)+10%", "cos(t)+10%", JsclOperation.simplify); | ||||||
|  |  | ||||||
| @@ -171,7 +171,7 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest { | |||||||
|         CalculatorTestUtils.assertError("(-1)i!"); |         CalculatorTestUtils.assertError("(-1)i!"); | ||||||
|         CalculatorTestUtils.assertEval("24i", "4!i"); |         CalculatorTestUtils.assertEval("24i", "4!i"); | ||||||
|  |  | ||||||
| 		CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("si", 5d)); | 		Locator.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("si", 5d)); | ||||||
|  |  | ||||||
| 		try { | 		try { | ||||||
| 			cm.setAngleUnits(AngleUnit.rad); | 			cm.setAngleUnits(AngleUnit.rad); | ||||||
| @@ -185,14 +185,14 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest { | |||||||
| 			cm.setAngleUnits(defaultAngleUnit); | 			cm.setAngleUnits(defaultAngleUnit); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("s", 1d)); | 		Locator.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("s", 1d)); | ||||||
| 		CalculatorTestUtils.assertEval("5", cm.evaluate( "si")); | 		CalculatorTestUtils.assertEval("5", cm.evaluate( "si")); | ||||||
|  |  | ||||||
| 		CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("k", 3.5d)); | 		Locator.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("k", 3.5d)); | ||||||
| 		CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("k1", 4d)); | 		Locator.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("k1", 4d)); | ||||||
| 		CalculatorTestUtils.assertEval("4", "k11"); | 		CalculatorTestUtils.assertEval("4", "k11"); | ||||||
|  |  | ||||||
| 		CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("t", (String) null)); | 		Locator.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("t", (String) null)); | ||||||
| 		CalculatorTestUtils.assertEval("11t", "t11"); | 		CalculatorTestUtils.assertEval("11t", "t11"); | ||||||
| 		CalculatorTestUtils.assertEval("11et", "t11e"); | 		CalculatorTestUtils.assertEval("11et", "t11e"); | ||||||
| 		CalculatorTestUtils.assertEval("∞", "∞"); | 		CalculatorTestUtils.assertEval("∞", "∞"); | ||||||
| @@ -238,10 +238,10 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest { | |||||||
| 			cm.setTimeout(3000); | 			cm.setTimeout(3000); | ||||||
| 		}*/ | 		}*/ | ||||||
|  |  | ||||||
| 		CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("t", (String) null)); | 		Locator.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("t", (String) null)); | ||||||
| 		CalculatorTestUtils.assertEval("2t", "∂(t^2,t)", JsclOperation.simplify); | 		CalculatorTestUtils.assertEval("2t", "∂(t^2,t)", JsclOperation.simplify); | ||||||
| 		CalculatorTestUtils.assertEval("2t", "∂(t^2,t)"); | 		CalculatorTestUtils.assertEval("2t", "∂(t^2,t)"); | ||||||
| 		CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("t", "2")); | 		Locator.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("t", "2")); | ||||||
| 		CalculatorTestUtils.assertEval("2t", "∂(t^2,t)", JsclOperation.simplify); | 		CalculatorTestUtils.assertEval("2t", "∂(t^2,t)", JsclOperation.simplify); | ||||||
| 		CalculatorTestUtils.assertEval("4", "∂(t^2,t)"); | 		CalculatorTestUtils.assertEval("4", "∂(t^2,t)"); | ||||||
|  |  | ||||||
| @@ -256,7 +256,7 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest { | |||||||
|  |  | ||||||
| 	@Test | 	@Test | ||||||
| 	public void testFormatting() throws Exception { | 	public void testFormatting() throws Exception { | ||||||
| 		final MathEngine ce = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine0(); | 		final MathEngine ce = Locator.getInstance().getEngine().getMathEngine0(); | ||||||
|  |  | ||||||
| 		CalculatorTestUtils.assertEval("12 345", ce.simplify( "12345")); | 		CalculatorTestUtils.assertEval("12 345", ce.simplify( "12345")); | ||||||
|  |  | ||||||
| @@ -264,7 +264,7 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest { | |||||||
|  |  | ||||||
| 	@Test | 	@Test | ||||||
| 	public void testI() throws ParseException, CalculatorEvalException { | 	public void testI() throws ParseException, CalculatorEvalException { | ||||||
| 		final MathEngine cm = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine0(); | 		final MathEngine cm = Locator.getInstance().getEngine().getMathEngine0(); | ||||||
|  |  | ||||||
| 		CalculatorTestUtils.assertEval("-i", cm.evaluate( "i^3")); | 		CalculatorTestUtils.assertEval("-i", cm.evaluate( "i^3")); | ||||||
| 		for (int i = 0; i < 1000; i++) { | 		for (int i = 0; i < 1000; i++) { | ||||||
| @@ -289,7 +289,7 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest { | |||||||
|  |  | ||||||
| 	@Test | 	@Test | ||||||
| 	public void testEmptyFunction() throws Exception { | 	public void testEmptyFunction() throws Exception { | ||||||
| 		final MathEngine cm = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine0(); | 		final MathEngine cm = Locator.getInstance().getEngine().getMathEngine0(); | ||||||
| 		try { | 		try { | ||||||
| 			cm.evaluate( "cos(cos(cos(cos(acos(acos(acos(acos(acos(acos(acos(acos(cos(cos(cos(cos(cosh(acos(cos(cos(cos(cos(cos(acos(acos(acos(acos(acos(acos(acos(acos(cos(cos(cos(cos(cosh(acos(cos())))))))))))))))))))))))))))))))))))))"); | 			cm.evaluate( "cos(cos(cos(cos(acos(acos(acos(acos(acos(acos(acos(acos(cos(cos(cos(cos(cosh(acos(cos(cos(cos(cos(cos(acos(acos(acos(acos(acos(acos(acos(acos(cos(cos(cos(cos(cosh(acos(cos())))))))))))))))))))))))))))))))))))))"); | ||||||
| 			Assert.fail(); | 			Assert.fail(); | ||||||
| @@ -310,7 +310,7 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest { | |||||||
| 			cm.setAngleUnits(defaultAngleUnit); | 			cm.setAngleUnits(defaultAngleUnit); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("si", 5d)); | 		Locator.getInstance().getEngine().getVarsRegistry().add(new Var.Builder("si", 5d)); | ||||||
| 		CalculatorTestUtils.assertEval("5", cm.evaluate( "si")); | 		CalculatorTestUtils.assertEval("5", cm.evaluate( "si")); | ||||||
|  |  | ||||||
|         CalculatorTestUtils.assertError("sin"); |         CalculatorTestUtils.assertError("sin"); | ||||||
| @@ -318,7 +318,7 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest { | |||||||
|  |  | ||||||
| 	@Test | 	@Test | ||||||
| 	public void testRounding() throws Exception { | 	public void testRounding() throws Exception { | ||||||
| 		final MathEngine cm = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine0(); | 		final MathEngine cm = Locator.getInstance().getEngine().getMathEngine0(); | ||||||
|  |  | ||||||
| 		try { | 		try { | ||||||
| 			DecimalFormatSymbols decimalGroupSymbols = new DecimalFormatSymbols(Locale.getDefault()); | 			DecimalFormatSymbols decimalGroupSymbols = new DecimalFormatSymbols(Locale.getDefault()); | ||||||
| @@ -342,7 +342,7 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest { | |||||||
|  |  | ||||||
| 	@Test | 	@Test | ||||||
| 	public void testComparisonFunction() throws Exception { | 	public void testComparisonFunction() throws Exception { | ||||||
| 		final MathEngine cm = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine0(); | 		final MathEngine cm = Locator.getInstance().getEngine().getMathEngine0(); | ||||||
|  |  | ||||||
| 		CalculatorTestUtils.assertEval("0",  "eq(0, 1)"); | 		CalculatorTestUtils.assertEval("0",  "eq(0, 1)"); | ||||||
| 		CalculatorTestUtils.assertEval("1",  "eq(1, 1)"); | 		CalculatorTestUtils.assertEval("1",  "eq(1, 1)"); | ||||||
| @@ -379,7 +379,7 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest { | |||||||
|  |  | ||||||
| 	@Test | 	@Test | ||||||
| 	public void testNumeralSystems() throws Exception { | 	public void testNumeralSystems() throws Exception { | ||||||
| 		final MathEngine cm = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine0(); | 		final MathEngine cm = Locator.getInstance().getEngine().getMathEngine0(); | ||||||
|  |  | ||||||
| 		CalculatorTestUtils.assertEval("11 259 375",  "0x:ABCDEF"); | 		CalculatorTestUtils.assertEval("11 259 375",  "0x:ABCDEF"); | ||||||
| 		CalculatorTestUtils.assertEval("30 606 154.462",  "0x:ABCDEF*e"); | 		CalculatorTestUtils.assertEval("30 606 154.462",  "0x:ABCDEF*e"); | ||||||
| @@ -408,7 +408,7 @@ public class AndroidCalculatorEngineTest extends AbstractCalculatorTest { | |||||||
|  |  | ||||||
| 	@Test | 	@Test | ||||||
| 	public void testLog() throws Exception { | 	public void testLog() throws Exception { | ||||||
| 		final MathEngine cm = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine0(); | 		final MathEngine cm = Locator.getInstance().getEngine().getMathEngine0(); | ||||||
|  |  | ||||||
| 		CalculatorTestUtils.assertEval("∞", Expression.valueOf("1/0").numeric().toString()); | 		CalculatorTestUtils.assertEval("∞", Expression.valueOf("1/0").numeric().toString()); | ||||||
| 		CalculatorTestUtils.assertEval("∞", Expression.valueOf("ln(10)/ln(1)").numeric().toString()); | 		CalculatorTestUtils.assertEval("∞", Expression.valueOf("ln(10)/ln(1)").numeric().toString()); | ||||||
|   | |||||||
| @@ -27,7 +27,7 @@ public class NumeralBaseTest extends AbstractCalculatorTest { | |||||||
| 	@BeforeClass | 	@BeforeClass | ||||||
| 	public static void staticSetUp() throws Exception { | 	public static void staticSetUp() throws Exception { | ||||||
| 		CalculatorTestUtils.staticSetUp(); | 		CalculatorTestUtils.staticSetUp(); | ||||||
|         CalculatorLocatorImpl.getInstance().getEngine().setPrecision(3); |         Locator.getInstance().getEngine().setPrecision(3); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@Test | 	@Test | ||||||
| @@ -97,11 +97,11 @@ public class NumeralBaseTest extends AbstractCalculatorTest { | |||||||
| 		final String bin = "0b:" + line[2].toUpperCase(); | 		final String bin = "0b:" + line[2].toUpperCase(); | ||||||
|  |  | ||||||
| 		final String decExpression = converter.convert(dec); | 		final String decExpression = converter.convert(dec); | ||||||
| 		final String decResult = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine().evaluate(decExpression); | 		final String decResult = Locator.getInstance().getEngine().getMathEngine().evaluate(decExpression); | ||||||
| 		final String hexExpression = converter.convert(hex); | 		final String hexExpression = converter.convert(hex); | ||||||
| 		final String hexResult = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine().evaluate(hexExpression); | 		final String hexResult = Locator.getInstance().getEngine().getMathEngine().evaluate(hexExpression); | ||||||
| 		final String binExpression = converter.convert(bin); | 		final String binExpression = converter.convert(bin); | ||||||
| 		final String binResult = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine().evaluate(binExpression); | 		final String binResult = Locator.getInstance().getEngine().getMathEngine().evaluate(binExpression); | ||||||
|  |  | ||||||
| 		Assert.assertEquals("dec-hex: " + decExpression + " : " + hexExpression, decResult, hexResult); | 		Assert.assertEquals("dec-hex: " + decExpression + " : " + hexExpression, decResult, hexResult); | ||||||
| 		Assert.assertEquals("dec-bin: " + decExpression + " : " + binExpression, decResult, binResult); | 		Assert.assertEquals("dec-bin: " + decExpression + " : " + binExpression, decResult, binResult); | ||||||
|   | |||||||
| @@ -65,10 +65,10 @@ public class ToJsclTextProcessorTest extends AbstractCalculatorTest { | |||||||
| 		Assert.assertEquals( "EE", preprocessor.process("EE").toString()); | 		Assert.assertEquals( "EE", preprocessor.process("EE").toString()); | ||||||
|  |  | ||||||
| 		try { | 		try { | ||||||
| 			CalculatorLocatorImpl.getInstance().getEngine().setNumeralBase(NumeralBase.hex); | 			Locator.getInstance().getEngine().setNumeralBase(NumeralBase.hex); | ||||||
| 			Assert.assertEquals( "22F*exp(F)", preprocessor.process("22Fexp(F)").toString()); | 			Assert.assertEquals( "22F*exp(F)", preprocessor.process("22Fexp(F)").toString()); | ||||||
| 		} finally { | 		} finally { | ||||||
| 			CalculatorLocatorImpl.getInstance().getEngine().setNumeralBase(NumeralBase.dec); | 			Locator.getInstance().getEngine().setNumeralBase(NumeralBase.dec); | ||||||
| 		} | 		} | ||||||
| 		Assert.assertEquals( "0x:ABCDEF", preprocessor.process("0x:ABCDEF").toString()); | 		Assert.assertEquals( "0x:ABCDEF", preprocessor.process("0x:ABCDEF").toString()); | ||||||
| 		Assert.assertEquals( "0x:ABCDEF", preprocessor.process("0x:A BC DEF").toString()); | 		Assert.assertEquals( "0x:ABCDEF", preprocessor.process("0x:A BC DEF").toString()); | ||||||
|   | |||||||
| @@ -90,7 +90,7 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh | |||||||
|                 @Override |                 @Override | ||||||
|                 public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) { |                 public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) { | ||||||
|                     if (dragDirection == DragDirection.down) { |                     if (dragDirection == DragDirection.down) { | ||||||
|                         CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_operators, null); |                         Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_operators, null); | ||||||
|                         return true; |                         return true; | ||||||
|                     } |                     } | ||||||
|                     return false; |                     return false; | ||||||
| @@ -178,7 +178,7 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh | |||||||
|  |  | ||||||
|     @NotNull |     @NotNull | ||||||
|     private Calculator getCalculator() { |     private Calculator getCalculator() { | ||||||
|         return CalculatorLocatorImpl.getInstance().getCalculator(); |         return Locator.getInstance().getCalculator(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -212,7 +212,7 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh | |||||||
|  |  | ||||||
|     @NotNull |     @NotNull | ||||||
|     private CalculatorKeyboard getKeyboard() { |     private CalculatorKeyboard getKeyboard() { | ||||||
|         return CalculatorLocatorImpl.getInstance().getKeyboard(); |         return Locator.getInstance().getKeyboard(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nullable |     @Nullable | ||||||
|   | |||||||
| @@ -65,7 +65,7 @@ public class AndroidCalculator implements Calculator, CalculatorEventListener, S | |||||||
|  |  | ||||||
|     public void setDisplay(@NotNull Context context, @NotNull AndroidCalculatorDisplayView displayView) { |     public void setDisplay(@NotNull Context context, @NotNull AndroidCalculatorDisplayView displayView) { | ||||||
|         displayView.init(context); |         displayView.init(context); | ||||||
|         CalculatorLocatorImpl.getInstance().getDisplay().setView(displayView); |         Locator.getInstance().getDisplay().setView(displayView); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setEditor(@NotNull Activity activity) { |     public void setEditor(@NotNull Activity activity) { | ||||||
| @@ -75,7 +75,7 @@ public class AndroidCalculator implements Calculator, CalculatorEventListener, S | |||||||
|  |  | ||||||
|     public void setEditor(@NotNull Context context, @NotNull AndroidCalculatorEditorView editorView) { |     public void setEditor(@NotNull Context context, @NotNull AndroidCalculatorEditorView editorView) { | ||||||
|         editorView.init(context); |         editorView.init(context); | ||||||
|         CalculatorLocatorImpl.getInstance().getEditor().setView(editorView); |         Locator.getInstance().getEditor().setView(editorView); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,7 +16,6 @@ import android.text.Html; | |||||||
| import android.text.TextWatcher; | import android.text.TextWatcher; | ||||||
| import android.util.AttributeSet; | import android.util.AttributeSet; | ||||||
| import android.util.Log; | import android.util.Log; | ||||||
| import android.util.TypedValue; |  | ||||||
| import android.view.ContextMenu; | import android.view.ContextMenu; | ||||||
| import android.widget.EditText; | import android.widget.EditText; | ||||||
| import org.jetbrains.annotations.NotNull; | import org.jetbrains.annotations.NotNull; | ||||||
| @@ -128,7 +127,7 @@ public class AndroidCalculatorEditorView extends EditText implements SharedPrefe | |||||||
|  |  | ||||||
|     public void setHighlightText(boolean highlightText) { |     public void setHighlightText(boolean highlightText) { | ||||||
|         this.highlightText = highlightText; |         this.highlightText = highlightText; | ||||||
|         CalculatorLocatorImpl.getInstance().getEditor().updateViewState(); |         Locator.getInstance().getEditor().updateViewState(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -186,7 +185,7 @@ public class AndroidCalculatorEditorView extends EditText implements SharedPrefe | |||||||
|                 if (!viewStateChange) { |                 if (!viewStateChange) { | ||||||
|                     // external text change => need to notify editor |                     // external text change => need to notify editor | ||||||
|                     super.onSelectionChanged(selStart, selEnd); |                     super.onSelectionChanged(selStart, selEnd); | ||||||
|                     CalculatorLocatorImpl.getInstance().getEditor().setSelection(selStart); |                     Locator.getInstance().getEditor().setSelection(selStart); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @@ -197,7 +196,7 @@ public class AndroidCalculatorEditorView extends EditText implements SharedPrefe | |||||||
|             synchronized (viewLock) { |             synchronized (viewLock) { | ||||||
|                 if (!viewStateChange) { |                 if (!viewStateChange) { | ||||||
|                     // external text change => need to notify editor |                     // external text change => need to notify editor | ||||||
|                     CalculatorLocatorImpl.getInstance().getEditor().setText(String.valueOf(s)); |                     Locator.getInstance().getEditor().setText(String.valueOf(s)); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -75,7 +75,7 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS | |||||||
|         final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application); |         final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application); | ||||||
|         AndroidCalculatorEngine.Preferences.angleUnit.putPreference(preferences, angleUnit); |         AndroidCalculatorEngine.Preferences.angleUnit.putPreference(preferences, angleUnit); | ||||||
|  |  | ||||||
|         CalculatorLocatorImpl.getInstance().getNotifier().showMessage(new AndroidMessage(R.string.c_angle_units_changed_to, MessageType.info, application, angleUnit.name())); |         Locator.getInstance().getNotifier().showMessage(new AndroidMessage(R.string.c_angle_units_changed_to, MessageType.info, application, angleUnit.name())); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -89,6 +89,6 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS | |||||||
|         final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application); |         final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application); | ||||||
|         AndroidCalculatorEngine.Preferences.numeralBase.putPreference(preferences, numeralBase); |         AndroidCalculatorEngine.Preferences.numeralBase.putPreference(preferences, numeralBase); | ||||||
|  |  | ||||||
|         CalculatorLocatorImpl.getInstance().getNotifier().showMessage(new AndroidMessage(R.string.c_numeral_base_changed_to, MessageType.info, application, numeralBase.name())); |         Locator.getInstance().getNotifier().showMessage(new AndroidMessage(R.string.c_numeral_base_changed_to, MessageType.info, application, numeralBase.name())); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -80,12 +80,12 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar | |||||||
|  |  | ||||||
|         preferences.registerOnSharedPreferenceChangeListener(this); |         preferences.registerOnSharedPreferenceChangeListener(this); | ||||||
|  |  | ||||||
|         CalculatorLocatorImpl.getInstance().getPreferenceService().checkPreferredPreferences(false); |         Locator.getInstance().getPreferenceService().checkPreferredPreferences(false); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @NotNull |     @NotNull | ||||||
|     private AndroidCalculator getCalculator() { |     private AndroidCalculator getCalculator() { | ||||||
|         return ((AndroidCalculator) CalculatorLocatorImpl.getInstance().getCalculator()); |         return ((AndroidCalculator) Locator.getInstance().getCalculator()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static void firstTimeInit(@NotNull SharedPreferences preferences, @NotNull Context context) { |     private static void firstTimeInit(@NotNull SharedPreferences preferences, @NotNull Context context) { | ||||||
| @@ -267,7 +267,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar | |||||||
|  |  | ||||||
|     @NotNull |     @NotNull | ||||||
|     private static CalculatorKeyboard getKeyboard() { |     private static CalculatorKeyboard getKeyboard() { | ||||||
|         return CalculatorLocatorImpl.getInstance().getKeyboard(); |         return Locator.getInstance().getKeyboard(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @SuppressWarnings({"UnusedDeclaration"}) |     @SuppressWarnings({"UnusedDeclaration"}) | ||||||
|   | |||||||
| @@ -68,7 +68,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple | |||||||
|         super.onCreate(activity); |         super.onCreate(activity); | ||||||
|  |  | ||||||
|         if (activity instanceof CalculatorEventListener) { |         if (activity instanceof CalculatorEventListener) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener) activity); |             Locator.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener) activity); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); |         final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); | ||||||
| @@ -172,7 +172,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple | |||||||
|         super.onDestroy(activity); |         super.onDestroy(activity); | ||||||
|  |  | ||||||
|         if (activity instanceof CalculatorEventListener) { |         if (activity instanceof CalculatorEventListener) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().removeCalculatorEventListener((CalculatorEventListener) activity); |             Locator.getInstance().getCalculator().removeCalculatorEventListener((CalculatorEventListener) activity); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -120,13 +120,13 @@ public class CalculatorActivityLauncher { | |||||||
|                         context.startActivity(intent); |                         context.startActivity(intent); | ||||||
|                     } |                     } | ||||||
|                 } else { |                 } else { | ||||||
|                     CalculatorLocatorImpl.getInstance().getNotifier().showMessage(R.string.c_value_is_not_a_number, MessageType.error); |                     Locator.getInstance().getNotifier().showMessage(R.string.c_value_is_not_a_number, MessageType.error); | ||||||
| 				} | 				} | ||||||
| 			} else { | 			} else { | ||||||
|                 CalculatorLocatorImpl.getInstance().getNotifier().showMessage(R.string.empty_var_error, MessageType.error); |                 Locator.getInstance().getNotifier().showMessage(R.string.empty_var_error, MessageType.error); | ||||||
| 			} | 			} | ||||||
| 		} else { | 		} else { | ||||||
|             CalculatorLocatorImpl.getInstance().getNotifier().showMessage(R.string.not_valid_result, MessageType.error); |             Locator.getInstance().getNotifier().showMessage(R.string.not_valid_result, MessageType.error); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -140,10 +140,10 @@ public class CalculatorActivityLauncher { | |||||||
|                 FunctionEditDialogFragment.showDialog(FunctionEditDialogFragment.Input.newFromDisplay(viewState), context); |                 FunctionEditDialogFragment.showDialog(FunctionEditDialogFragment.Input.newFromDisplay(viewState), context); | ||||||
|  |  | ||||||
|             } else { |             } else { | ||||||
|                 CalculatorLocatorImpl.getInstance().getNotifier().showMessage(R.string.empty_function_error, MessageType.error); |                 Locator.getInstance().getNotifier().showMessage(R.string.empty_function_error, MessageType.error); | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             CalculatorLocatorImpl.getInstance().getNotifier().showMessage(R.string.not_valid_result, MessageType.error); |             Locator.getInstance().getNotifier().showMessage(R.string.not_valid_result, MessageType.error); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -54,12 +54,12 @@ public final class CalculatorButtons { | |||||||
|     static void initMultiplicationButton(@NotNull View root) { |     static void initMultiplicationButton(@NotNull View root) { | ||||||
|         final View multiplicationButton = root.findViewById(R.id.multiplicationButton); |         final View multiplicationButton = root.findViewById(R.id.multiplicationButton); | ||||||
|         if ( multiplicationButton instanceof Button) { |         if ( multiplicationButton instanceof Button) { | ||||||
|             ((Button) multiplicationButton).setText(CalculatorLocatorImpl.getInstance().getEngine().getMultiplicationSign()); |             ((Button) multiplicationButton).setText(Locator.getInstance().getEngine().getMultiplicationSign()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void initMultiplicationButton(@NotNull RemoteViews views) { |     public static void initMultiplicationButton(@NotNull RemoteViews views) { | ||||||
|         views.setTextViewText(R.id.multiplicationButton, CalculatorLocatorImpl.getInstance().getEngine().getMultiplicationSign()); |         views.setTextViewText(R.id.multiplicationButton, Locator.getInstance().getEngine().getMultiplicationSign()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -112,7 +112,7 @@ public final class CalculatorButtons { | |||||||
|  |  | ||||||
|     @NotNull |     @NotNull | ||||||
|     private static CalculatorKeyboard getKeyboard() { |     private static CalculatorKeyboard getKeyboard() { | ||||||
|         return CalculatorLocatorImpl.getInstance().getKeyboard(); |         return Locator.getInstance().getKeyboard(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     static class VarsDragProcessor implements SimpleOnDragListener.DragProcessor { |     static class VarsDragProcessor implements SimpleOnDragListener.DragProcessor { | ||||||
| @@ -132,7 +132,7 @@ public final class CalculatorButtons { | |||||||
|             boolean result = false; |             boolean result = false; | ||||||
|  |  | ||||||
|             if (dragDirection == DragDirection.up) { |             if (dragDirection == DragDirection.up) { | ||||||
|                 CalculatorActivityLauncher.createVar(context, CalculatorLocatorImpl.getInstance().getDisplay()); |                 CalculatorActivityLauncher.createVar(context, Locator.getInstance().getDisplay()); | ||||||
|                 result = true; |                 result = true; | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -150,7 +150,7 @@ public final class CalculatorButtons { | |||||||
|  |  | ||||||
|         AngleUnitsChanger(@NotNull Context context) { |         AngleUnitsChanger(@NotNull Context context) { | ||||||
|             this.context = context; |             this.context = context; | ||||||
|             this.processor = new DigitButtonDragProcessor(CalculatorLocatorImpl.getInstance().getKeyboard()); |             this.processor = new DigitButtonDragProcessor(Locator.getInstance().getKeyboard()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
| @@ -172,7 +172,7 @@ public final class CalculatorButtons { | |||||||
|  |  | ||||||
|                             final AngleUnit oldAngleUnits = AndroidCalculatorEngine.Preferences.angleUnit.getPreference(preferences); |                             final AngleUnit oldAngleUnits = AndroidCalculatorEngine.Preferences.angleUnit.getPreference(preferences); | ||||||
|                             if (oldAngleUnits != angleUnits) { |                             if (oldAngleUnits != angleUnits) { | ||||||
|                                 CalculatorLocatorImpl.getInstance().getPreferenceService().setAngleUnits(angleUnits); |                                 Locator.getInstance().getPreferenceService().setAngleUnits(angleUnits); | ||||||
|                             } |                             } | ||||||
|  |  | ||||||
|                             result = true; |                             result = true; | ||||||
| @@ -216,7 +216,7 @@ public final class CalculatorButtons { | |||||||
|  |  | ||||||
|                         final NumeralBase oldNumeralBase = AndroidCalculatorEngine.Preferences.numeralBase.getPreference(preferences); |                         final NumeralBase oldNumeralBase = AndroidCalculatorEngine.Preferences.numeralBase.getPreference(preferences); | ||||||
|                         if (oldNumeralBase != numeralBase) { |                         if (oldNumeralBase != numeralBase) { | ||||||
|                             CalculatorLocatorImpl.getInstance().getPreferenceService().setNumeralBase(numeralBase); |                             Locator.getInstance().getPreferenceService().setNumeralBase(numeralBase); | ||||||
|                         } |                         } | ||||||
|  |  | ||||||
|                         result = true; |                         result = true; | ||||||
| @@ -247,7 +247,7 @@ public final class CalculatorButtons { | |||||||
|             boolean result = false; |             boolean result = false; | ||||||
|  |  | ||||||
|             if (dragDirection == DragDirection.up) { |             if (dragDirection == DragDirection.up) { | ||||||
|                 CalculatorActivityLauncher.createFunction(context, CalculatorLocatorImpl.getInstance().getDisplay()); |                 CalculatorActivityLauncher.createFunction(context, Locator.getInstance().getDisplay()); | ||||||
|                 result = true; |                 result = true; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -43,7 +43,7 @@ public class CalculatorDisplayFragment extends SherlockFragment { | |||||||
|     public void onViewCreated(View root, Bundle savedInstanceState) { |     public void onViewCreated(View root, Bundle savedInstanceState) { | ||||||
|         super.onViewCreated(root, savedInstanceState); |         super.onViewCreated(root, savedInstanceState); | ||||||
|  |  | ||||||
|         ((AndroidCalculator) CalculatorLocatorImpl.getInstance().getCalculator()).setDisplay(getActivity()); |         ((AndroidCalculator) Locator.getInstance().getCalculator()).setDisplay(getActivity()); | ||||||
|  |  | ||||||
|         fragmentHelper.onViewCreated(this, root); |         fragmentHelper.onViewCreated(this, root); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ public enum CalculatorDisplayMenuItem implements LabeledMenuItem<CalculatorDispl | |||||||
|     copy(R.string.c_copy) { |     copy(R.string.c_copy) { | ||||||
|         @Override |         @Override | ||||||
|         public void onClick(@NotNull CalculatorDisplayViewState data, @NotNull Context context) { |         public void onClick(@NotNull CalculatorDisplayViewState data, @NotNull Context context) { | ||||||
|             CalculatorLocatorImpl.getInstance().getKeyboard().copyButtonPressed(); |             Locator.getInstance().getKeyboard().copyButtonPressed(); | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|   | |||||||
| @@ -26,7 +26,7 @@ public class CalculatorDisplayOnClickListener implements View.OnClickListener { | |||||||
|     @Override |     @Override | ||||||
|     public void onClick(View v) { |     public void onClick(View v) { | ||||||
|         if (v instanceof CalculatorDisplayView) { |         if (v instanceof CalculatorDisplayView) { | ||||||
|             final CalculatorDisplay cd = CalculatorLocatorImpl.getInstance().getDisplay(); |             final CalculatorDisplay cd = Locator.getInstance().getDisplay(); | ||||||
|  |  | ||||||
|             final CalculatorDisplayViewState displayViewState = cd.getViewState(); |             final CalculatorDisplayViewState displayViewState = cd.getViewState(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -38,7 +38,7 @@ public class CalculatorEditorFragment extends SherlockFragment { | |||||||
|  |  | ||||||
|         fragmentHelper.onViewCreated(this, view); |         fragmentHelper.onViewCreated(this, view); | ||||||
|  |  | ||||||
|         ((AndroidCalculator) CalculatorLocatorImpl.getInstance().getCalculator()).setEditor(getActivity()); |         ((AndroidCalculator) Locator.getInstance().getCalculator()).setEditor(getActivity()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -63,7 +63,7 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple | |||||||
|  |  | ||||||
|         if (listenersOnCreate) { |         if (listenersOnCreate) { | ||||||
|             if ( fragment instanceof CalculatorEventListener ) { |             if ( fragment instanceof CalculatorEventListener ) { | ||||||
|                 CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener) fragment); |                 Locator.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener) fragment); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -72,7 +72,7 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple | |||||||
|     public void onResume(@NotNull Fragment fragment) { |     public void onResume(@NotNull Fragment fragment) { | ||||||
|         if (!listenersOnCreate) { |         if (!listenersOnCreate) { | ||||||
|             if ( fragment instanceof CalculatorEventListener ) { |             if ( fragment instanceof CalculatorEventListener ) { | ||||||
|                 CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener) fragment); |                 Locator.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener) fragment); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -81,7 +81,7 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple | |||||||
|     public void onPause(@NotNull Fragment fragment) { |     public void onPause(@NotNull Fragment fragment) { | ||||||
|         if (!listenersOnCreate) { |         if (!listenersOnCreate) { | ||||||
|             if ( fragment instanceof CalculatorEventListener ) { |             if ( fragment instanceof CalculatorEventListener ) { | ||||||
|                 CalculatorLocatorImpl.getInstance().getCalculator().removeCalculatorEventListener((CalculatorEventListener) fragment); |                 Locator.getInstance().getCalculator().removeCalculatorEventListener((CalculatorEventListener) fragment); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -114,7 +114,7 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple | |||||||
|  |  | ||||||
|         if (listenersOnCreate) { |         if (listenersOnCreate) { | ||||||
|             if ( fragment instanceof CalculatorEventListener ) { |             if ( fragment instanceof CalculatorEventListener ) { | ||||||
|                 CalculatorLocatorImpl.getInstance().getCalculator().removeCalculatorEventListener((CalculatorEventListener) fragment); |                 Locator.getInstance().getCalculator().removeCalculatorEventListener((CalculatorEventListener) fragment); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -131,17 +131,17 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar | |||||||
|  |  | ||||||
|     @Nullable |     @Nullable | ||||||
|     private static AndroidCalculatorDisplayView getCalculatorDisplayView() { |     private static AndroidCalculatorDisplayView getCalculatorDisplayView() { | ||||||
|         return (AndroidCalculatorDisplayView) CalculatorLocatorImpl.getInstance().getDisplay().getView(); |         return (AndroidCalculatorDisplayView) Locator.getInstance().getDisplay().getView(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @NotNull |     @NotNull | ||||||
|     private Calculator getCalculator() { |     private Calculator getCalculator() { | ||||||
|         return CalculatorLocatorImpl.getInstance().getCalculator(); |         return Locator.getInstance().getCalculator(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @NotNull |     @NotNull | ||||||
|     private static CalculatorKeyboard getKeyboard() { |     private static CalculatorKeyboard getKeyboard() { | ||||||
|         return CalculatorLocatorImpl.getInstance().getKeyboard(); |         return Locator.getInstance().getKeyboard(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -31,9 +31,9 @@ enum ConversionMenuItem implements AMenuItem<CalculatorDisplayViewState> { | |||||||
|         if (operation == JsclOperation.numeric) { |         if (operation == JsclOperation.numeric) { | ||||||
|             if (generic.getConstants().isEmpty()) { |             if (generic.getConstants().isEmpty()) { | ||||||
|                 // conversion possible => return true |                 // conversion possible => return true | ||||||
|                 final NumeralBase fromNumeralBase = CalculatorLocatorImpl.getInstance().getEngine().getNumeralBase(); |                 final NumeralBase fromNumeralBase = Locator.getInstance().getEngine().getNumeralBase(); | ||||||
|                 if (fromNumeralBase != toNumeralBase) { |                 if (fromNumeralBase != toNumeralBase) { | ||||||
|                     result = CalculatorLocatorImpl.getInstance().getCalculator().isConversionPossible(generic, fromNumeralBase, this.toNumeralBase); |                     result = Locator.getInstance().getCalculator().isConversionPossible(generic, fromNumeralBase, this.toNumeralBase); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @@ -46,7 +46,7 @@ enum ConversionMenuItem implements AMenuItem<CalculatorDisplayViewState> { | |||||||
|         final Generic result = data.getResult(); |         final Generic result = data.getResult(); | ||||||
|  |  | ||||||
|         if (result != null) { |         if (result != null) { | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().convert(result, this.toNumeralBase); |             Locator.getInstance().getCalculator().convert(result, this.toNumeralBase); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -30,10 +30,10 @@ public class CursorDragProcessor implements SimpleOnDragListener.DragProcessor{ | |||||||
| 		if (dragButton instanceof DirectionDragButton) { | 		if (dragButton instanceof DirectionDragButton) { | ||||||
| 			String text = ((DirectionDragButton) dragButton).getText(dragDirection); | 			String text = ((DirectionDragButton) dragButton).getText(dragDirection); | ||||||
| 			if ("◀◀".equals(text)) { | 			if ("◀◀".equals(text)) { | ||||||
| 				CalculatorLocatorImpl.getInstance().getEditor().setCursorOnStart(); | 				Locator.getInstance().getEditor().setCursorOnStart(); | ||||||
| 				result = true; | 				result = true; | ||||||
| 			} else if ("▶▶".equals(text)) { | 			} else if ("▶▶".equals(text)) { | ||||||
|                 CalculatorLocatorImpl.getInstance().getEditor().setCursorOnEnd(); |                 Locator.getInstance().getEditor().setCursorOnEnd(); | ||||||
| 				result = true; | 				result = true; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -31,7 +31,7 @@ public class EvalDragProcessor implements SimpleOnDragListener.DragProcessor { | |||||||
| 		if (dragButton instanceof DirectionDragButton) { | 		if (dragButton instanceof DirectionDragButton) { | ||||||
| 			String text = ((DirectionDragButton) dragButton).getText(dragDirection); | 			String text = ((DirectionDragButton) dragButton).getText(dragDirection); | ||||||
| 			if ("≡".equals(text)) { | 			if ("≡".equals(text)) { | ||||||
| 				CalculatorLocatorImpl.getInstance().getCalculator().simplify(); | 				Locator.getInstance().getCalculator().simplify(); | ||||||
| 				result = true; | 				result = true; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -4,9 +4,9 @@ import android.content.Context; | |||||||
| import android.content.Intent; | import android.content.Intent; | ||||||
| import android.os.Parcelable; | import android.os.Parcelable; | ||||||
| import org.jetbrains.annotations.NotNull; | import org.jetbrains.annotations.NotNull; | ||||||
|  | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.CalculatorDisplayViewState; | import org.solovyev.android.calculator.CalculatorDisplayViewState; | ||||||
| import org.solovyev.android.calculator.CalculatorEditorViewState; | import org.solovyev.android.calculator.CalculatorEditorViewState; | ||||||
| import org.solovyev.android.calculator.CalculatorLocatorImpl; |  | ||||||
| import org.solovyev.common.MutableObject; | import org.solovyev.common.MutableObject; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -81,10 +81,10 @@ public class DefaultExternalCalculatorIntentHandler implements ExternalCalculato | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected void onDisplayStateChanged(@NotNull Context context, @NotNull CalculatorDisplayViewState displayViewState) { |     protected void onDisplayStateChanged(@NotNull Context context, @NotNull CalculatorDisplayViewState displayViewState) { | ||||||
|         updateState(context, CalculatorLocatorImpl.getInstance().getEditor().getViewState(), displayViewState); |         updateState(context, Locator.getInstance().getEditor().getViewState(), displayViewState); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected void onEditorStateChanged(@NotNull Context context, @NotNull CalculatorEditorViewState editorViewState) { |     protected void onEditorStateChanged(@NotNull Context context, @NotNull CalculatorEditorViewState editorViewState) { | ||||||
|         updateState(context, editorViewState, CalculatorLocatorImpl.getInstance().getDisplay().getViewState()); |         updateState(context, editorViewState, Locator.getInstance().getDisplay().getViewState()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -103,7 +103,7 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul | |||||||
| 			} | 			} | ||||||
| 		}); | 		}); | ||||||
|  |  | ||||||
| 		root.findViewById(R.id.save_button).setOnClickListener(new FunctionEditorSaver(builder, function, root, CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry(), this)); | 		root.findViewById(R.id.save_button).setOnClickListener(new FunctionEditorSaver(builder, function, root, Locator.getInstance().getEngine().getFunctionsRegistry(), this)); | ||||||
|  |  | ||||||
| 		if ( function == null ) { | 		if ( function == null ) { | ||||||
| 			// CREATE MODE | 			// CREATE MODE | ||||||
| @@ -130,12 +130,12 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul | |||||||
|     public void onResume() { |     public void onResume() { | ||||||
|         super.onResume(); |         super.onResume(); | ||||||
|  |  | ||||||
|         CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener(this); |         Locator.getInstance().getCalculator().addCalculatorEventListener(this); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onPause() { |     public void onPause() { | ||||||
|         CalculatorLocatorImpl.getInstance().getCalculator().removeCalculatorEventListener(this); |         Locator.getInstance().getCalculator().removeCalculatorEventListener(this); | ||||||
|  |  | ||||||
|         super.onPause(); |         super.onPause(); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -8,8 +8,8 @@ import jscl.math.function.Function; | |||||||
| import jscl.math.function.IFunction; | import jscl.math.function.IFunction; | ||||||
| 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.Locator; | ||||||
| import org.solovyev.android.calculator.CalculatorFunctionsMathRegistry; | import org.solovyev.android.calculator.CalculatorFunctionsMathRegistry; | ||||||
| import org.solovyev.android.calculator.CalculatorLocatorImpl; |  | ||||||
| import org.solovyev.android.calculator.CalculatorMathRegistry; | import org.solovyev.android.calculator.CalculatorMathRegistry; | ||||||
| import org.solovyev.android.calculator.R; | import org.solovyev.android.calculator.R; | ||||||
| import org.solovyev.android.calculator.math.edit.VarEditorSaver; | import org.solovyev.android.calculator.math.edit.VarEditorSaver; | ||||||
| @@ -101,14 +101,14 @@ public class FunctionEditorSaver implements View.OnClickListener { | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if (error != null) { | 		if (error != null) { | ||||||
| 			CalculatorLocatorImpl.getInstance().getNotifier().showMessage(error, MessageType.error); | 			Locator.getInstance().getNotifier().showMessage(error, MessageType.error); | ||||||
| 		} else { | 		} else { | ||||||
|             try { |             try { | ||||||
|                 CalculatorFunctionsMathRegistry.saveFunction(mathRegistry, new BuilderAdapter(builder), editedInstance, source, true); |                 CalculatorFunctionsMathRegistry.saveFunction(mathRegistry, new BuilderAdapter(builder), editedInstance, source, true); | ||||||
|             } catch (CustomFunctionCalculationException e) { |             } catch (CustomFunctionCalculationException e) { | ||||||
|                 CalculatorLocatorImpl.getInstance().getNotifier().showMessage(e); |                 Locator.getInstance().getNotifier().showMessage(e); | ||||||
|             } catch (AFunction.Builder.CreationException e) { |             } catch (AFunction.Builder.CreationException e) { | ||||||
| 				CalculatorLocatorImpl.getInstance().getNotifier().showMessage(e); | 				Locator.getInstance().getNotifier().showMessage(e); | ||||||
| 			} | 			} | ||||||
|         } |         } | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -219,7 +219,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag | |||||||
| 		boolean result = false; | 		boolean result = false; | ||||||
| 		try { | 		try { | ||||||
| 			historyState.setSaved(true); | 			historyState.setSaved(true); | ||||||
| 			if ( CollectionsUtils.contains(historyState, CalculatorLocatorImpl.getInstance().getHistory().getSavedHistory(), new Equalizer<CalculatorHistoryState>() { | 			if ( CollectionsUtils.contains(historyState, Locator.getInstance().getHistory().getSavedHistory(), new Equalizer<CalculatorHistoryState>() { | ||||||
| 				@Override | 				@Override | ||||||
| 				public boolean equals(@Nullable CalculatorHistoryState first, @Nullable CalculatorHistoryState second) { | 				public boolean equals(@Nullable CalculatorHistoryState first, @Nullable CalculatorHistoryState second) { | ||||||
| 					return first != null && second != null && | 					return first != null && second != null && | ||||||
| @@ -237,7 +237,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public static void useHistoryItem(@NotNull final CalculatorHistoryState historyState) { | 	public static void useHistoryItem(@NotNull final CalculatorHistoryState historyState) { | ||||||
|         CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_history_state, historyState); |         Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_history_state, historyState); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@NotNull | 	@NotNull | ||||||
| @@ -339,7 +339,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag | |||||||
|         clear_history(org.solovyev.android.calculator.R.id.history_menu_clear_history) { |         clear_history(org.solovyev.android.calculator.R.id.history_menu_clear_history) { | ||||||
|             @Override |             @Override | ||||||
|             public void onClick(@NotNull MenuItem data, @NotNull Context context) { |             public void onClick(@NotNull MenuItem data, @NotNull Context context) { | ||||||
|                 CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.clear_history_requested, null); |                 Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.clear_history_requested, null); | ||||||
|             } |             } | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ package org.solovyev.android.calculator.history; | |||||||
|  |  | ||||||
| import android.preference.PreferenceManager; | import android.preference.PreferenceManager; | ||||||
| import org.jetbrains.annotations.NotNull; | import org.jetbrains.annotations.NotNull; | ||||||
| import org.solovyev.android.calculator.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.CalculatorPreferences; | import org.solovyev.android.calculator.CalculatorPreferences; | ||||||
| import org.solovyev.android.calculator.R; | import org.solovyev.android.calculator.R; | ||||||
| import org.solovyev.android.calculator.about.CalculatorFragmentType; | import org.solovyev.android.calculator.about.CalculatorFragmentType; | ||||||
| @@ -36,12 +36,12 @@ public class CalculatorHistoryFragment extends AbstractCalculatorHistoryFragment | |||||||
| 	@Override | 	@Override | ||||||
| 	protected List<CalculatorHistoryState> getHistoryItems() { | 	protected List<CalculatorHistoryState> getHistoryItems() { | ||||||
|         final boolean showIntermediateCalculations = CalculatorPreferences.History.showIntermediateCalculations.getPreference(PreferenceManager.getDefaultSharedPreferences(getActivity())); |         final boolean showIntermediateCalculations = CalculatorPreferences.History.showIntermediateCalculations.getPreference(PreferenceManager.getDefaultSharedPreferences(getActivity())); | ||||||
| 		return new ArrayList<CalculatorHistoryState>(CalculatorLocatorImpl.getInstance().getHistory().getStates(showIntermediateCalculations)); | 		return new ArrayList<CalculatorHistoryState>(Locator.getInstance().getHistory().getStates(showIntermediateCalculations)); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| 	protected void clearHistory() { | 	protected void clearHistory() { | ||||||
|         CalculatorLocatorImpl.getInstance().getHistory().clear(); |         Locator.getInstance().getHistory().clear(); | ||||||
| 		getAdapter().clear(); | 		getAdapter().clear(); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
| package org.solovyev.android.calculator.history; | package org.solovyev.android.calculator.history; | ||||||
|  |  | ||||||
| import org.jetbrains.annotations.NotNull; | import org.jetbrains.annotations.NotNull; | ||||||
| import org.solovyev.android.calculator.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.R; | import org.solovyev.android.calculator.R; | ||||||
| import org.solovyev.android.calculator.about.CalculatorFragmentType; | import org.solovyev.android.calculator.about.CalculatorFragmentType; | ||||||
|  |  | ||||||
| @@ -33,12 +33,12 @@ public class CalculatorSavedHistoryFragment extends AbstractCalculatorHistoryFra | |||||||
| 	@NotNull | 	@NotNull | ||||||
| 	@Override | 	@Override | ||||||
| 	protected List<CalculatorHistoryState> getHistoryItems() { | 	protected List<CalculatorHistoryState> getHistoryItems() { | ||||||
| 		return new ArrayList<CalculatorHistoryState>(CalculatorLocatorImpl.getInstance().getHistory().getSavedHistory()); | 		return new ArrayList<CalculatorHistoryState>(Locator.getInstance().getHistory().getSavedHistory()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| 	protected void clearHistory() { | 	protected void clearHistory() { | ||||||
|         CalculatorLocatorImpl.getInstance().getHistory().clearSavedHistory(); |         Locator.getInstance().getHistory().clearSavedHistory(); | ||||||
| 		getAdapter().clear(); | 		getAdapter().clear(); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -11,14 +11,13 @@ import android.app.AlertDialog; | |||||||
| import android.content.Context; | import android.content.Context; | ||||||
| import android.content.DialogInterface; | import android.content.DialogInterface; | ||||||
| import android.text.ClipboardManager; | import android.text.ClipboardManager; | ||||||
| import android.util.Log; |  | ||||||
| import android.view.LayoutInflater; | import android.view.LayoutInflater; | ||||||
| import android.view.View; | import android.view.View; | ||||||
| import android.widget.EditText; | import android.widget.EditText; | ||||||
| import android.widget.TextView; | import android.widget.TextView; | ||||||
| import android.widget.Toast; | import android.widget.Toast; | ||||||
| import org.jetbrains.annotations.NotNull; | import org.jetbrains.annotations.NotNull; | ||||||
| import org.solovyev.android.calculator.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.R; | import org.solovyev.android.calculator.R; | ||||||
| import org.solovyev.android.menu.LabeledMenuItem; | import org.solovyev.android.menu.LabeledMenuItem; | ||||||
| import org.solovyev.common.text.StringUtils; | import org.solovyev.common.text.StringUtils; | ||||||
| @@ -93,7 +92,7 @@ public enum HistoryItemMenuItem implements LabeledMenuItem<HistoryItemMenuData> | |||||||
| 			final CalculatorHistoryState historyState = data.getHistoryState(); | 			final CalculatorHistoryState historyState = data.getHistoryState(); | ||||||
| 			if (historyState.isSaved()) { | 			if (historyState.isSaved()) { | ||||||
| 				data.getAdapter().remove(historyState); | 				data.getAdapter().remove(historyState); | ||||||
| 				CalculatorLocatorImpl.getInstance().getHistory().removeSavedHistory(historyState); | 				Locator.getInstance().getHistory().removeSavedHistory(historyState); | ||||||
| 				Toast.makeText(context, context.getText(R.string.c_history_was_removed), Toast.LENGTH_LONG).show(); | 				Toast.makeText(context, context.getText(R.string.c_history_was_removed), Toast.LENGTH_LONG).show(); | ||||||
| 				data.getAdapter().notifyDataSetChanged(); | 				data.getAdapter().notifyDataSetChanged(); | ||||||
| 			} | 			} | ||||||
| @@ -119,14 +118,14 @@ public enum HistoryItemMenuItem implements LabeledMenuItem<HistoryItemMenuData> | |||||||
| 					@Override | 					@Override | ||||||
| 					public void onClick(DialogInterface dialog, int which) { | 					public void onClick(DialogInterface dialog, int which) { | ||||||
| 						if (save) { | 						if (save) { | ||||||
| 							final CalculatorHistoryState savedHistoryItem = CalculatorLocatorImpl.getInstance().getHistory().addSavedState(historyState); | 							final CalculatorHistoryState savedHistoryItem = Locator.getInstance().getHistory().addSavedState(historyState); | ||||||
| 							savedHistoryItem.setComment(comment.getText().toString()); | 							savedHistoryItem.setComment(comment.getText().toString()); | ||||||
|                             CalculatorLocatorImpl.getInstance().getHistory().save(); |                             Locator.getInstance().getHistory().save(); | ||||||
| 							// we don't need to add element to the adapter as adapter of another activity must be updated and not this | 							// we don't need to add element to the adapter as adapter of another activity must be updated and not this | ||||||
| 							//data.getAdapter().add(savedHistoryItem); | 							//data.getAdapter().add(savedHistoryItem); | ||||||
| 						} else { | 						} else { | ||||||
| 							historyState.setComment(comment.getText().toString()); | 							historyState.setComment(comment.getText().toString()); | ||||||
|                             CalculatorLocatorImpl.getInstance().getHistory().save(); |                             Locator.getInstance().getHistory().save(); | ||||||
| 						} | 						} | ||||||
| 						data.getAdapter().notifyDataSetChanged(); | 						data.getAdapter().notifyDataSetChanged(); | ||||||
| 						Toast.makeText(context, context.getText(R.string.c_history_saved), Toast.LENGTH_LONG).show(); | 						Toast.makeText(context, context.getText(R.string.c_history_saved), Toast.LENGTH_LONG).show(); | ||||||
|   | |||||||
| @@ -72,7 +72,7 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment< | |||||||
| 	protected List<LabeledMenuItem<Function>> getMenuItemsOnLongClick(@NotNull Function item) { | 	protected List<LabeledMenuItem<Function>> getMenuItemsOnLongClick(@NotNull Function item) { | ||||||
| 		List<LabeledMenuItem<Function>> result = new ArrayList<LabeledMenuItem<Function>>(Arrays.asList(LongClickMenuItem.values())); | 		List<LabeledMenuItem<Function>> result = new ArrayList<LabeledMenuItem<Function>>(Arrays.asList(LongClickMenuItem.values())); | ||||||
|  |  | ||||||
|         final CalculatorMathRegistry<Function> functionsRegistry = CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry(); |         final CalculatorMathRegistry<Function> functionsRegistry = Locator.getInstance().getEngine().getFunctionsRegistry(); | ||||||
|         if ( StringUtils.isEmpty(functionsRegistry.getDescription(item.getName())) ) { |         if ( StringUtils.isEmpty(functionsRegistry.getDescription(item.getName())) ) { | ||||||
| 			result.remove(LongClickMenuItem.copy_description); | 			result.remove(LongClickMenuItem.copy_description); | ||||||
| 		} | 		} | ||||||
| @@ -88,18 +88,18 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment< | |||||||
| 	@NotNull | 	@NotNull | ||||||
| 	@Override | 	@Override | ||||||
| 	protected MathEntityDescriptionGetter getDescriptionGetter() { | 	protected MathEntityDescriptionGetter getDescriptionGetter() { | ||||||
| 		return new MathEntityDescriptionGetterImpl(CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry()); | 		return new MathEntityDescriptionGetterImpl(Locator.getInstance().getEngine().getFunctionsRegistry()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@NotNull | 	@NotNull | ||||||
| 	@Override | 	@Override | ||||||
| 	protected List<Function> getMathEntities() { | 	protected List<Function> getMathEntities() { | ||||||
| 		return new ArrayList<Function>(CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry().getEntities()); | 		return new ArrayList<Function>(Locator.getInstance().getEngine().getFunctionsRegistry().getEntities()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| 	protected String getMathEntityCategory(@NotNull Function function) { | 	protected String getMathEntityCategory(@NotNull Function function) { | ||||||
| 		return CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry().getCategory(function); | 		return Locator.getInstance().getEngine().getFunctionsRegistry().getCategory(function); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -223,7 +223,7 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment< | |||||||
|         use(R.string.c_use) { |         use(R.string.c_use) { | ||||||
|             @Override |             @Override | ||||||
|             public void onClick(@NotNull Function function, @NotNull Context context) { |             public void onClick(@NotNull Function function, @NotNull Context context) { | ||||||
|                 CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_function, function); |                 Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_function, function); | ||||||
|             } |             } | ||||||
|         }, |         }, | ||||||
|  |  | ||||||
| @@ -246,7 +246,7 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment< | |||||||
|         copy_description(R.string.c_copy_description) { |         copy_description(R.string.c_copy_description) { | ||||||
|             @Override |             @Override | ||||||
|             public void onClick(@NotNull Function function, @NotNull Context context) { |             public void onClick(@NotNull Function function, @NotNull Context context) { | ||||||
|                 final String text = CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry().getDescription(function.getName()); |                 final String text = Locator.getInstance().getEngine().getFunctionsRegistry().getDescription(function.getName()); | ||||||
|                 if (!StringUtils.isEmpty(text)) { |                 if (!StringUtils.isEmpty(text)) { | ||||||
|                     final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE); |                     final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE); | ||||||
|                     clipboard.setText(text); |                     clipboard.setText(text); | ||||||
|   | |||||||
| @@ -5,8 +5,8 @@ import android.content.Context; | |||||||
| import android.text.ClipboardManager; | import android.text.ClipboardManager; | ||||||
| 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.Locator; | ||||||
| import org.solovyev.android.calculator.CalculatorEventType; | import org.solovyev.android.calculator.CalculatorEventType; | ||||||
| import org.solovyev.android.calculator.CalculatorLocatorImpl; |  | ||||||
| import org.solovyev.android.calculator.R; | import org.solovyev.android.calculator.R; | ||||||
| import org.solovyev.android.calculator.about.CalculatorFragmentType; | import org.solovyev.android.calculator.about.CalculatorFragmentType; | ||||||
| import org.solovyev.android.menu.AMenuItem; | import org.solovyev.android.menu.AMenuItem; | ||||||
| @@ -58,17 +58,17 @@ public class CalculatorOperatorsFragment extends AbstractMathEntityListFragment< | |||||||
|     protected List<Operator> getMathEntities() { |     protected List<Operator> getMathEntities() { | ||||||
|         final List<Operator> result = new ArrayList<Operator>(); |         final List<Operator> result = new ArrayList<Operator>(); | ||||||
|  |  | ||||||
|         result.addAll(CalculatorLocatorImpl.getInstance().getEngine().getOperatorsRegistry().getEntities()); |         result.addAll(Locator.getInstance().getEngine().getOperatorsRegistry().getEntities()); | ||||||
|         result.addAll(CalculatorLocatorImpl.getInstance().getEngine().getPostfixFunctionsRegistry().getEntities()); |         result.addAll(Locator.getInstance().getEngine().getPostfixFunctionsRegistry().getEntities()); | ||||||
|  |  | ||||||
|         return result; |         return result; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected String getMathEntityCategory(@NotNull Operator operator) { |     protected String getMathEntityCategory(@NotNull Operator operator) { | ||||||
|         String result = CalculatorLocatorImpl.getInstance().getEngine().getOperatorsRegistry().getCategory(operator); |         String result = Locator.getInstance().getEngine().getOperatorsRegistry().getCategory(operator); | ||||||
|         if (result == null) { |         if (result == null) { | ||||||
|             result = CalculatorLocatorImpl.getInstance().getEngine().getPostfixFunctionsRegistry().getCategory(operator); |             result = Locator.getInstance().getEngine().getPostfixFunctionsRegistry().getCategory(operator); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return result; |         return result; | ||||||
| @@ -80,9 +80,9 @@ public class CalculatorOperatorsFragment extends AbstractMathEntityListFragment< | |||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public String getDescription(@NotNull Context context, @NotNull String mathEntityName) { |         public String getDescription(@NotNull Context context, @NotNull String mathEntityName) { | ||||||
|             String result = CalculatorLocatorImpl.getInstance().getEngine().getOperatorsRegistry().getDescription(mathEntityName); |             String result = Locator.getInstance().getEngine().getOperatorsRegistry().getDescription(mathEntityName); | ||||||
|             if (StringUtils.isEmpty(result)) { |             if (StringUtils.isEmpty(result)) { | ||||||
|                 result = CalculatorLocatorImpl.getInstance().getEngine().getPostfixFunctionsRegistry().getDescription(mathEntityName); |                 result = Locator.getInstance().getEngine().getPostfixFunctionsRegistry().getDescription(mathEntityName); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             return result; |             return result; | ||||||
| @@ -102,7 +102,7 @@ public class CalculatorOperatorsFragment extends AbstractMathEntityListFragment< | |||||||
|         use(R.string.c_use) { |         use(R.string.c_use) { | ||||||
|             @Override |             @Override | ||||||
|             public void onClick(@NotNull Operator data, @NotNull Context context) { |             public void onClick(@NotNull Operator data, @NotNull Context context) { | ||||||
|                 CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_operator, data); |                 Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_operator, data); | ||||||
|             } |             } | ||||||
|         }, |         }, | ||||||
|  |  | ||||||
|   | |||||||
| @@ -75,7 +75,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons | |||||||
|             result.remove(LongClickMenuItem.remove); |             result.remove(LongClickMenuItem.remove); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (StringUtils.isEmpty(CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().getDescription(item.getName()))) { |         if (StringUtils.isEmpty(Locator.getInstance().getEngine().getVarsRegistry().getDescription(item.getName()))) { | ||||||
|             result.remove(LongClickMenuItem.copy_description); |             result.remove(LongClickMenuItem.copy_description); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -89,7 +89,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons | |||||||
|     @NotNull |     @NotNull | ||||||
|     @Override |     @Override | ||||||
|     protected MathEntityDescriptionGetter getDescriptionGetter() { |     protected MathEntityDescriptionGetter getDescriptionGetter() { | ||||||
|         return new MathEntityDescriptionGetterImpl(CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry()); |         return new MathEntityDescriptionGetterImpl(Locator.getInstance().getEngine().getVarsRegistry()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @SuppressWarnings({"UnusedDeclaration"}) |     @SuppressWarnings({"UnusedDeclaration"}) | ||||||
| @@ -100,7 +100,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons | |||||||
|     @NotNull |     @NotNull | ||||||
|     @Override |     @Override | ||||||
|     protected List<IConstant> getMathEntities() { |     protected List<IConstant> getMathEntities() { | ||||||
|         final List<IConstant> result = new ArrayList<IConstant>(CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().getEntities()); |         final List<IConstant> result = new ArrayList<IConstant>(Locator.getInstance().getEngine().getVarsRegistry().getEntities()); | ||||||
|  |  | ||||||
|         CollectionsUtils.removeAll(result, new JPredicate<IConstant>() { |         CollectionsUtils.removeAll(result, new JPredicate<IConstant>() { | ||||||
|             @Override |             @Override | ||||||
| @@ -114,7 +114,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected String getMathEntityCategory(@NotNull IConstant var) { |     protected String getMathEntityCategory(@NotNull IConstant var) { | ||||||
|         return CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().getCategory(var); |         return Locator.getInstance().getEngine().getVarsRegistry().getCategory(var); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static boolean isValidValue(@NotNull String value) { |     public static boolean isValidValue(@NotNull String value) { | ||||||
| @@ -227,7 +227,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons | |||||||
|         use(R.string.c_use) { |         use(R.string.c_use) { | ||||||
|             @Override |             @Override | ||||||
|             public void onClick(@NotNull IConstant data, @NotNull Context context) { |             public void onClick(@NotNull IConstant data, @NotNull Context context) { | ||||||
|                 CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_constant, data); |                 Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_constant, data); | ||||||
|             } |             } | ||||||
|         }, |         }, | ||||||
|  |  | ||||||
| @@ -251,7 +251,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons | |||||||
|                 final String text = data.getValue(); |                 final String text = data.getValue(); | ||||||
|                 if (!StringUtils.isEmpty(text)) { |                 if (!StringUtils.isEmpty(text)) { | ||||||
|                     assert text != null; |                     assert text != null; | ||||||
|                     CalculatorLocatorImpl.getInstance().getClipboard().setText(text); |                     Locator.getInstance().getClipboard().setText(text); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         }, |         }, | ||||||
| @@ -259,10 +259,10 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons | |||||||
|         copy_description(R.string.c_copy_description) { |         copy_description(R.string.c_copy_description) { | ||||||
|             @Override |             @Override | ||||||
|             public void onClick(@NotNull IConstant data, @NotNull Context context) { |             public void onClick(@NotNull IConstant data, @NotNull Context context) { | ||||||
|                 final String text = CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().getDescription(data.getName()); |                 final String text = Locator.getInstance().getEngine().getVarsRegistry().getDescription(data.getName()); | ||||||
|                 if (!StringUtils.isEmpty(text)) { |                 if (!StringUtils.isEmpty(text)) { | ||||||
|                     assert text != null; |                     assert text != null; | ||||||
|                     CalculatorLocatorImpl.getInstance().getClipboard().setText(text); |                     Locator.getInstance().getClipboard().setText(text); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         }; |         }; | ||||||
|   | |||||||
| @@ -16,7 +16,7 @@ import jscl.math.function.IConstant; | |||||||
| 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.CalculatorEventType; | import org.solovyev.android.calculator.CalculatorEventType; | ||||||
| import org.solovyev.android.calculator.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.CalculatorMathRegistry; | import org.solovyev.android.calculator.CalculatorMathRegistry; | ||||||
| import org.solovyev.android.calculator.R; | import org.solovyev.android.calculator.R; | ||||||
| import org.solovyev.common.math.MathEntity; | import org.solovyev.common.math.MathEntity; | ||||||
| @@ -76,14 +76,14 @@ public class MathEntityRemover<T extends MathEntity> implements View.OnClickList | |||||||
|                                                                   @Nullable DialogInterface.OnClickListener callbackOnCancel, |                                                                   @Nullable DialogInterface.OnClickListener callbackOnCancel, | ||||||
|                                                                   @NotNull Context context, |                                                                   @NotNull Context context, | ||||||
|                                                                   @NotNull Object source) { |                                                                   @NotNull Object source) { | ||||||
|         return new MathEntityRemover<IConstant>(constant, callbackOnCancel, false, CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry(), context, source, Params.newConstantInstance()); |         return new MathEntityRemover<IConstant>(constant, callbackOnCancel, false, Locator.getInstance().getEngine().getVarsRegistry(), context, source, Params.newConstantInstance()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static MathEntityRemover<Function> newFunctionRemover(@NotNull Function function, |     public static MathEntityRemover<Function> newFunctionRemover(@NotNull Function function, | ||||||
|                                                                   @Nullable DialogInterface.OnClickListener callbackOnCancel, |                                                                   @Nullable DialogInterface.OnClickListener callbackOnCancel, | ||||||
|                                                                   @NotNull Context context, |                                                                   @NotNull Context context, | ||||||
|                                                                   @NotNull Object source) { |                                                                   @NotNull Object source) { | ||||||
|         return new MathEntityRemover<Function>(function, callbackOnCancel, false, CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry(), context, source, Params.newFunctionInstance()); |         return new MathEntityRemover<Function>(function, callbackOnCancel, false, Locator.getInstance().getEngine().getFunctionsRegistry(), context, source, Params.newFunctionInstance()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* |     /* | ||||||
| @@ -117,7 +117,7 @@ public class MathEntityRemover<T extends MathEntity> implements View.OnClickList | |||||||
|             varsRegistry.remove(mathEntity); |             varsRegistry.remove(mathEntity); | ||||||
|             varsRegistry.save(); |             varsRegistry.save(); | ||||||
|  |  | ||||||
|             CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(params.getCalculatorEventType(), mathEntity, source); |             Locator.getInstance().getCalculator().fireCalculatorEvent(params.getCalculatorEventType(), mathEntity, source); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -45,12 +45,12 @@ public class VarEditDialogFragment extends DialogFragment implements CalculatorE | |||||||
|     public void onResume() { |     public void onResume() { | ||||||
|         super.onResume(); |         super.onResume(); | ||||||
|  |  | ||||||
|         CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener(this); |         Locator.getInstance().getCalculator().addCalculatorEventListener(this); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onPause() { |     public void onPause() { | ||||||
|         CalculatorLocatorImpl.getInstance().getCalculator().removeCalculatorEventListener(this); |         Locator.getInstance().getCalculator().removeCalculatorEventListener(this); | ||||||
|  |  | ||||||
|         super.onPause(); |         super.onPause(); | ||||||
|     } |     } | ||||||
| @@ -110,7 +110,7 @@ public class VarEditDialogFragment extends DialogFragment implements CalculatorE | |||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         root.findViewById(R.id.save_button).setOnClickListener(new VarEditorSaver<IConstant>(varBuilder, constant, root, CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry(), this)); |         root.findViewById(R.id.save_button).setOnClickListener(new VarEditorSaver<IConstant>(varBuilder, constant, root, Locator.getInstance().getEngine().getVarsRegistry(), this)); | ||||||
|  |  | ||||||
|         if ( constant == null ) { |         if ( constant == null ) { | ||||||
|             // CREATE MODE |             // CREATE MODE | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ import jscl.text.ParseException; | |||||||
| import jscl.text.Parser; | import jscl.text.Parser; | ||||||
| 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.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.CalculatorMathRegistry; | import org.solovyev.android.calculator.CalculatorMathRegistry; | ||||||
| import org.solovyev.android.calculator.CalculatorVarsRegistry; | import org.solovyev.android.calculator.CalculatorVarsRegistry; | ||||||
| import org.solovyev.android.calculator.R; | import org.solovyev.android.calculator.R; | ||||||
| @@ -117,7 +117,7 @@ public class VarEditorSaver<T extends MathEntity> implements View.OnClickListene | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (error != null) { |         if (error != null) { | ||||||
|             CalculatorLocatorImpl.getInstance().getNotifier().showMessage(error, MessageType.error); |             Locator.getInstance().getNotifier().showMessage(error, MessageType.error); | ||||||
|         } else { |         } else { | ||||||
|             CalculatorVarsRegistry.saveVariable(mathRegistry, varBuilder, editedInstance, source, true); |             CalculatorVarsRegistry.saveVariable(mathRegistry, varBuilder, editedInstance, source, true); | ||||||
|         } |         } | ||||||
| @@ -129,7 +129,7 @@ public class VarEditorSaver<T extends MathEntity> implements View.OnClickListene | |||||||
| 		if (!StringUtils.isEmpty(name)) { | 		if (!StringUtils.isEmpty(name)) { | ||||||
| 			try { | 			try { | ||||||
| 				assert name != null; | 				assert name != null; | ||||||
| 				Identifier.parser.parse(Parser.Parameters.newInstance(name, new MutableInt(0), CalculatorLocatorImpl.getInstance().getEngine().getMathEngine0()), null); | 				Identifier.parser.parse(Parser.Parameters.newInstance(name, new MutableInt(0), Locator.getInstance().getEngine().getMathEngine0()), null); | ||||||
| 				result = true; | 				result = true; | ||||||
| 			} catch (ParseException e) { | 			} catch (ParseException e) { | ||||||
| 				// not valid name; | 				// not valid name; | ||||||
|   | |||||||
| @@ -152,10 +152,10 @@ public class CalculatorPlotFragment extends CalculatorFragment implements Calcul | |||||||
|             result = PreparedInput.newInstance(input, expression, variable, fromInputArgs, plotBoundaries); |             result = PreparedInput.newInstance(input, expression, variable, fromInputArgs, plotBoundaries); | ||||||
|         } catch (ParseException e) { |         } catch (ParseException e) { | ||||||
|             result = PreparedInput.newErrorInstance(fromInputArgs); |             result = PreparedInput.newErrorInstance(fromInputArgs); | ||||||
|             CalculatorLocatorImpl.getInstance().getNotifier().showMessage(e); |             Locator.getInstance().getNotifier().showMessage(e); | ||||||
|         } catch (CalculatorParseException e) { |         } catch (CalculatorParseException e) { | ||||||
|             result = PreparedInput.newErrorInstance(fromInputArgs); |             result = PreparedInput.newErrorInstance(fromInputArgs); | ||||||
|             CalculatorLocatorImpl.getInstance().getNotifier().showMessage(e); |             Locator.getInstance().getNotifier().showMessage(e); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return result; |         return result; | ||||||
| @@ -184,7 +184,7 @@ public class CalculatorPlotFragment extends CalculatorFragment implements Calcul | |||||||
|         super.onViewCreated(view, savedInstanceState); |         super.onViewCreated(view, savedInstanceState); | ||||||
|  |  | ||||||
|         if (input == null) { |         if (input == null) { | ||||||
|             this.preparedInput = prepareInputFromDisplay(CalculatorLocatorImpl.getInstance().getDisplay().getViewState(), savedInstanceState); |             this.preparedInput = prepareInputFromDisplay(Locator.getInstance().getDisplay().getViewState(), savedInstanceState); | ||||||
|         } else { |         } else { | ||||||
|             this.preparedInput = prepareInput(input, true, savedInstanceState); |             this.preparedInput = prepareInput(input, true, savedInstanceState); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ import org.achartengine.renderer.XYSeriesRenderer; | |||||||
| import org.achartengine.util.MathHelper; | import org.achartengine.util.MathHelper; | ||||||
| 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.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.R; | import org.solovyev.android.calculator.R; | ||||||
| import org.solovyev.common.msg.MessageType; | import org.solovyev.common.msg.MessageType; | ||||||
| import org.solovyev.common.text.StringUtils; | import org.solovyev.common.text.StringUtils; | ||||||
| @@ -207,7 +207,7 @@ public final class PlotUtils { | |||||||
|         if (StringUtils.isEmpty(message)) { |         if (StringUtils.isEmpty(message)) { | ||||||
|             message = e.getMessage(); |             message = e.getMessage(); | ||||||
|         } |         } | ||||||
|         CalculatorLocatorImpl.getInstance().getNotifier().showMessage(R.string.arithmetic_error_while_plot, MessageType.error, Arrays.asList(message)); |         Locator.getInstance().getNotifier().showMessage(R.string.arithmetic_error_while_plot, MessageType.error, Arrays.asList(message)); | ||||||
|         calculatorPlotFragment.onError(); |         calculatorPlotFragment.onError(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ import android.graphics.Paint; | |||||||
| import android.text.TextPaint; | import android.text.TextPaint; | ||||||
| import android.util.AttributeSet; | import android.util.AttributeSet; | ||||||
| import org.jetbrains.annotations.NotNull; | import org.jetbrains.annotations.NotNull; | ||||||
| import org.solovyev.android.calculator.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.R; | import org.solovyev.android.calculator.R; | ||||||
| import org.solovyev.android.view.drag.DirectionDragButton; | import org.solovyev.android.view.drag.DirectionDragButton; | ||||||
|  |  | ||||||
| @@ -34,7 +34,7 @@ public class AngleUnitsButton extends DirectionDragButton { | |||||||
| 		super.initDirectionTextPaint(basePaint, directionTextData, resources); | 		super.initDirectionTextPaint(basePaint, directionTextData, resources); | ||||||
|  |  | ||||||
| 		final TextPaint directionTextPaint = directionTextData.getPaint(); | 		final TextPaint directionTextPaint = directionTextData.getPaint(); | ||||||
| 		if (CalculatorLocatorImpl.getInstance().getEngine().getAngleUnits().name().equals(directionTextData.getText())) { | 		if (Locator.getInstance().getEngine().getAngleUnits().name().equals(directionTextData.getText())) { | ||||||
| 			directionTextPaint.setColor(resources.getColor(R.color.cpp_selected_angle_unit_text_color)); | 			directionTextPaint.setColor(resources.getColor(R.color.cpp_selected_angle_unit_text_color)); | ||||||
| 		} else { | 		} else { | ||||||
| 			directionTextPaint.setColor(resources.getColor(R.color.cpp_default_text_color)); | 			directionTextPaint.setColor(resources.getColor(R.color.cpp_default_text_color)); | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ import android.util.AttributeSet; | |||||||
| import android.widget.TextView; | import android.widget.TextView; | ||||||
| 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.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.model.AndroidCalculatorEngine; | import org.solovyev.android.calculator.model.AndroidCalculatorEngine; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -40,8 +40,8 @@ public class CalculatorAdditionalTitle extends TextView implements SharedPrefere | |||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| 	public void onSharedPreferenceChanged(SharedPreferences preferences, @Nullable String key) { | 	public void onSharedPreferenceChanged(SharedPreferences preferences, @Nullable String key) { | ||||||
| 		setText(((AndroidCalculatorEngine) CalculatorLocatorImpl.getInstance().getEngine()).getNumeralBaseFromPrefs(preferences) | 		setText(((AndroidCalculatorEngine) Locator.getInstance().getEngine()).getNumeralBaseFromPrefs(preferences) | ||||||
|                 + " / " + |                 + " / " + | ||||||
|                 ((AndroidCalculatorEngine) CalculatorLocatorImpl.getInstance().getEngine()).getAngleUnitsFromPrefs(preferences)); |                 ((AndroidCalculatorEngine) Locator.getInstance().getEngine()).getAngleUnitsFromPrefs(preferences)); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ import android.view.View; | |||||||
| import android.view.WindowManager; | import android.view.WindowManager; | ||||||
| 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.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.CalculatorParseException; | import org.solovyev.android.calculator.CalculatorParseException; | ||||||
| import org.solovyev.android.calculator.R; | import org.solovyev.android.calculator.R; | ||||||
| import org.solovyev.android.calculator.ToJsclTextProcessor; | import org.solovyev.android.calculator.ToJsclTextProcessor; | ||||||
| @@ -41,12 +41,12 @@ public class NumeralBaseConverterDialog { | |||||||
|             String value = initialFromValue; |             String value = initialFromValue; | ||||||
|             try { |             try { | ||||||
|                 value = ToJsclTextProcessor.getInstance().process(value).getExpression(); |                 value = ToJsclTextProcessor.getInstance().process(value).getExpression(); | ||||||
|                 b.setFromValue(UnitImpl.newInstance(value, CalculatorNumeralBase.valueOf(CalculatorLocatorImpl.getInstance().getEngine().getNumeralBase()))); |                 b.setFromValue(UnitImpl.newInstance(value, CalculatorNumeralBase.valueOf(Locator.getInstance().getEngine().getNumeralBase()))); | ||||||
|             } catch (CalculatorParseException e) { |             } catch (CalculatorParseException e) { | ||||||
|                 b.setFromValue(UnitImpl.newInstance(value, CalculatorNumeralBase.valueOf(CalculatorLocatorImpl.getInstance().getEngine().getNumeralBase()))); |                 b.setFromValue(UnitImpl.newInstance(value, CalculatorNumeralBase.valueOf(Locator.getInstance().getEngine().getNumeralBase()))); | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             b.setFromValue(UnitImpl.newInstance("", CalculatorNumeralBase.valueOf(CalculatorLocatorImpl.getInstance().getEngine().getNumeralBase()))); |             b.setFromValue(UnitImpl.newInstance("", CalculatorNumeralBase.valueOf(Locator.getInstance().getEngine().getNumeralBase()))); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         b.setConverter(CalculatorNumeralBase.getConverter()); |         b.setConverter(CalculatorNumeralBase.getConverter()); | ||||||
| @@ -67,11 +67,11 @@ public class NumeralBaseConverterDialog { | |||||||
|             public void onClick(@NotNull Unit<String> fromUnits, @NotNull Unit<String> toUnits) { |             public void onClick(@NotNull Unit<String> fromUnits, @NotNull Unit<String> toUnits) { | ||||||
|                 String toUnitsValue = toUnits.getValue(); |                 String toUnitsValue = toUnits.getValue(); | ||||||
|  |  | ||||||
|                 if (!toUnits.getUnitType().equals(CalculatorNumeralBase.valueOf(CalculatorLocatorImpl.getInstance().getEngine().getNumeralBase()))) { |                 if (!toUnits.getUnitType().equals(CalculatorNumeralBase.valueOf(Locator.getInstance().getEngine().getNumeralBase()))) { | ||||||
|                     toUnitsValue = ((CalculatorNumeralBase) toUnits.getUnitType()).getNumeralBase().getJsclPrefix() + toUnitsValue; |                     toUnitsValue = ((CalculatorNumeralBase) toUnits.getUnitType()).getNumeralBase().getJsclPrefix() + toUnitsValue; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 CalculatorLocatorImpl.getInstance().getKeyboard().buttonPressed(toUnitsValue); |                 Locator.getInstance().getKeyboard().buttonPressed(toUnitsValue); | ||||||
|                 final AlertDialog alertDialog = alertDialogHolder.getObject(); |                 final AlertDialog alertDialog = alertDialogHolder.getObject(); | ||||||
|                 if (alertDialog != null) { |                 if (alertDialog != null) { | ||||||
|                     alertDialog.dismiss(); |                     alertDialog.dismiss(); | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ import android.graphics.Paint; | |||||||
| import android.text.TextPaint; | import android.text.TextPaint; | ||||||
| import android.util.AttributeSet; | import android.util.AttributeSet; | ||||||
| import org.jetbrains.annotations.NotNull; | import org.jetbrains.annotations.NotNull; | ||||||
| import org.solovyev.android.calculator.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.R; | import org.solovyev.android.calculator.R; | ||||||
| import org.solovyev.android.view.drag.DirectionDragButton; | import org.solovyev.android.view.drag.DirectionDragButton; | ||||||
|  |  | ||||||
| @@ -34,7 +34,7 @@ public class NumeralBasesButton extends DirectionDragButton { | |||||||
| 		super.initDirectionTextPaint(basePaint, directionTextData, resources); | 		super.initDirectionTextPaint(basePaint, directionTextData, resources); | ||||||
|  |  | ||||||
| 		final TextPaint directionTextPaint = directionTextData.getPaint(); | 		final TextPaint directionTextPaint = directionTextData.getPaint(); | ||||||
| 		if (CalculatorLocatorImpl.getInstance().getEngine().getNumeralBase().name().equals(directionTextData.getText())) { | 		if (Locator.getInstance().getEngine().getNumeralBase().name().equals(directionTextData.getText())) { | ||||||
| 			directionTextPaint.setColor(resources.getColor(R.color.cpp_selected_angle_unit_text_color)); | 			directionTextPaint.setColor(resources.getColor(R.color.cpp_selected_angle_unit_text_color)); | ||||||
| 		} else { | 		} else { | ||||||
| 			directionTextPaint.setColor(resources.getColor(R.color.cpp_default_text_color)); | 			directionTextPaint.setColor(resources.getColor(R.color.cpp_default_text_color)); | ||||||
|   | |||||||
| @@ -108,9 +108,9 @@ public class TextHighlighter implements TextProcessor<TextHighlighter.Result, St | |||||||
|  |  | ||||||
| 		final AbstractNumberBuilder numberBuilder; | 		final AbstractNumberBuilder numberBuilder; | ||||||
| 		if (!formatNumber) { | 		if (!formatNumber) { | ||||||
| 			numberBuilder = new LiteNumberBuilder(CalculatorLocatorImpl.getInstance().getEngine()); | 			numberBuilder = new LiteNumberBuilder(Locator.getInstance().getEngine()); | ||||||
| 		} else { | 		} else { | ||||||
| 			numberBuilder = new NumberBuilder(CalculatorLocatorImpl.getInstance().getEngine()); | 			numberBuilder = new NumberBuilder(Locator.getInstance().getEngine()); | ||||||
| 		} | 		} | ||||||
| 		for (int i = 0; i < text.length(); i++) { | 		for (int i = 0; i < text.length(); i++) { | ||||||
| 			MathType.Result mathType = MathType.getType(text, i, numberBuilder.isHexMode()); | 			MathType.Result mathType = MathType.getType(text, i, numberBuilder.isHexMode()); | ||||||
|   | |||||||
| @@ -88,7 +88,7 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem | |||||||
|                          @NotNull int[] appWidgetIds) { |                          @NotNull int[] appWidgetIds) { | ||||||
|         super.onUpdate(context, appWidgetManager, appWidgetIds); |         super.onUpdate(context, appWidgetManager, appWidgetIds); | ||||||
|  |  | ||||||
|         updateWidget(context, appWidgetManager, appWidgetIds, CalculatorLocatorImpl.getInstance().getEditor().getViewState(), CalculatorLocatorImpl.getInstance().getDisplay().getViewState()); |         updateWidget(context, appWidgetManager, appWidgetIds, Locator.getInstance().getEditor().getViewState(), Locator.getInstance().getDisplay().getViewState()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -158,7 +158,7 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem | |||||||
|             // inject cursor |             // inject cursor | ||||||
|             newText = Html.fromHtml(text.substring(0, selection) + "<font color=\"#" + getCursorColor(context) + "\">|</font>" + text.substring(selection)); |             newText = Html.fromHtml(text.substring(0, selection) + "<font color=\"#" + getCursorColor(context) + "\">|</font>" + text.substring(selection)); | ||||||
|         } |         } | ||||||
|         CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage(TAG, "New editor state: " + text); |         Locator.getInstance().getNotifier().showDebugMessage(TAG, "New editor state: " + text); | ||||||
|         views.setTextViewText(R.id.calculator_editor, newText); |         views.setTextViewText(R.id.calculator_editor, newText); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -0,0 +1,50 @@ | |||||||
|  | package org.solovyev.android.calculator.widget; | ||||||
|  |  | ||||||
|  | import org.jetbrains.annotations.NotNull; | ||||||
|  | import org.jetbrains.annotations.Nullable; | ||||||
|  | import org.solovyev.android.calculator.*; | ||||||
|  | import org.solovyev.android.calculator.external.ExternalCalculatorHelper; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * User: serso | ||||||
|  |  * Date: 10/19/12 | ||||||
|  |  * Time: 11:11 PM | ||||||
|  |  */ | ||||||
|  | public class CalculatorWidgetHelper implements CalculatorEventListener { | ||||||
|  |  | ||||||
|  |     private static final String TAG = "Calculator++ Widget Helper"; | ||||||
|  |  | ||||||
|  |     @NotNull | ||||||
|  |     private final CalculatorEventHolder lastEvent = new CalculatorEventHolder(CalculatorUtils.createFirstEventDataId()); | ||||||
|  |  | ||||||
|  |     public CalculatorWidgetHelper() { | ||||||
|  |         CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener(this); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { | ||||||
|  |         final CalculatorEventHolder.Result result = lastEvent.apply(calculatorEventData); | ||||||
|  |         if (result.isNewAfter()) { | ||||||
|  |             switch (calculatorEventType) { | ||||||
|  |                 case editor_state_changed_light: | ||||||
|  |                 case editor_state_changed: | ||||||
|  |                     final CalculatorEditorChangeEventData editorChangeData = (CalculatorEditorChangeEventData) data; | ||||||
|  |                     final CalculatorEditorViewState newEditorState = editorChangeData.getNewValue(); | ||||||
|  |  | ||||||
|  |                     CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage(TAG, "Editor state changed: " + newEditorState.getText()); | ||||||
|  |  | ||||||
|  |                     ExternalCalculatorHelper.onEditorStateChanged(CalculatorApplication.getInstance(), calculatorEventData, newEditorState); | ||||||
|  |                     break; | ||||||
|  |  | ||||||
|  |                 case display_state_changed: | ||||||
|  |                     final CalculatorDisplayChangeEventData displayChangeData = (CalculatorDisplayChangeEventData) data; | ||||||
|  |                     final CalculatorDisplayViewState newDisplayState = displayChangeData.getNewValue(); | ||||||
|  |  | ||||||
|  |                     CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage(TAG, "Display state changed: " + newDisplayState.getText()); | ||||||
|  |  | ||||||
|  |                     ExternalCalculatorHelper.onDisplayStateChanged(CalculatorApplication.getInstance(), calculatorEventData, newDisplayState); | ||||||
|  |                     break; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -3,7 +3,7 @@ package org.solovyev.android.calculator.widget; | |||||||
| import android.content.Context; | import android.content.Context; | ||||||
| import android.content.Intent; | import android.content.Intent; | ||||||
| import org.jetbrains.annotations.NotNull; | import org.jetbrains.annotations.NotNull; | ||||||
| import org.solovyev.android.calculator.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.external.DefaultExternalCalculatorIntentHandler; | import org.solovyev.android.calculator.external.DefaultExternalCalculatorIntentHandler; | ||||||
| import org.solovyev.android.calculator.external.ExternalCalculatorStateUpdater; | import org.solovyev.android.calculator.external.ExternalCalculatorStateUpdater; | ||||||
|  |  | ||||||
| @@ -30,7 +30,7 @@ public class CalculatorWidgetIntentHandler extends DefaultExternalCalculatorInte | |||||||
|                 button.onClick(context); |                 button.onClick(context); | ||||||
|             } |             } | ||||||
|         } else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(intent.getAction())) { |         } else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(intent.getAction())) { | ||||||
|             updateState(context, CalculatorLocatorImpl.getInstance().getEditor().getViewState(), CalculatorLocatorImpl.getInstance().getDisplay().getViewState()); |             updateState(context, Locator.getInstance().getEditor().getViewState(), Locator.getInstance().getDisplay().getViewState()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -3,7 +3,7 @@ package org.solovyev.android.calculator.widget; | |||||||
| import android.content.Context; | import android.content.Context; | ||||||
| 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.CalculatorLocatorImpl; | import org.solovyev.android.calculator.Locator; | ||||||
| import org.solovyev.android.calculator.CalculatorSpecialButton; | import org.solovyev.android.calculator.CalculatorSpecialButton; | ||||||
| import org.solovyev.android.calculator.R; | import org.solovyev.android.calculator.R; | ||||||
|  |  | ||||||
| @@ -79,8 +79,8 @@ public enum WidgetButton { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void onClick(@NotNull Context context) { |     public void onClick(@NotNull Context context) { | ||||||
|         CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage("Calculator++ Widget", "Button pressed: " + text); |         Locator.getInstance().getNotifier().showDebugMessage("Calculator++ Widget", "Button pressed: " + text); | ||||||
|         CalculatorLocatorImpl.getInstance().getKeyboard().buttonPressed(text); |         Locator.getInstance().getKeyboard().buttonPressed(text); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Nullable |     @Nullable | ||||||
|   | |||||||
| @@ -61,7 +61,7 @@ public class AndroidCalculatorEditorViewTest { | |||||||
|                     for ( int j = 0; j < count; j++ ) { |                     for ( int j = 0; j < count; j++ ) { | ||||||
|                         try { |                         try { | ||||||
|                             int textLength = random.nextInt(maxTextLength); |                             int textLength = random.nextInt(maxTextLength); | ||||||
|                             CalculatorLocatorImpl.getInstance().getEditor().insert(StringUtils.generateRandomString(textLength), textLength); |                             Locator.getInstance().getEditor().insert(StringUtils.generateRandomString(textLength), textLength); | ||||||
|                         } catch (Throwable e) { |                         } catch (Throwable e) { | ||||||
|                             System.out.println(e); |                             System.out.println(e); | ||||||
|                             error.set(true); |                             error.set(true); | ||||||
|   | |||||||
| @@ -98,7 +98,7 @@ public class TextHighlighterTest { | |||||||
| 		Assert.assertEquals("<b>0x:</b>FF33233FFE", textHighlighter.process("0x:FF33233FFE").toString()); | 		Assert.assertEquals("<b>0x:</b>FF33233FFE", textHighlighter.process("0x:FF33233FFE").toString()); | ||||||
| 		Assert.assertEquals("<b>0x:</b>FF33 233 FFE", textHighlighter.process("0x:FF33 233 FFE").toString()); | 		Assert.assertEquals("<b>0x:</b>FF33 233 FFE", textHighlighter.process("0x:FF33 233 FFE").toString()); | ||||||
|  |  | ||||||
| 		final MathEngine me = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine0(); | 		final MathEngine me = Locator.getInstance().getEngine().getMathEngine0(); | ||||||
| 		try { | 		try { | ||||||
| 			me.setNumeralBase(NumeralBase.hex); | 			me.setNumeralBase(NumeralBase.hex); | ||||||
| 			Assert.assertEquals("E", textHighlighter.process("E").toString()); | 			Assert.assertEquals("E", textHighlighter.process("E").toString()); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sergey Solovyev
					Sergey Solovyev