From 77167e366c06b23125d80b721558b73502ca2ad1 Mon Sep 17 00:00:00 2001 From: Sergey Solovyev Date: Wed, 21 Nov 2012 12:01:57 +0400 Subject: [PATCH] CalculatorLocatorImpl -> Locator --- .../AbstractCalculatorMathRegistry.java | 2 +- .../calculator/CalculatorEngineImpl.java | 2 +- .../calculator/CalculatorFixableError.java | 6 +-- .../CalculatorFunctionsMathRegistry.java | 4 +- .../android/calculator/CalculatorImpl.java | 40 +++++++++---------- .../calculator/CalculatorKeyboardImpl.java | 20 +++++----- .../calculator/CalculatorSpecialButton.java | 28 ++++++------- .../android/calculator/CalculatorUtils.java | 2 +- .../calculator/CalculatorVarsRegistry.java | 4 +- .../ListCalculatorEventContainer.java | 4 +- ...alculatorLocatorImpl.java => Locator.java} | 6 +-- .../calculator/ToJsclTextProcessor.java | 8 ++-- .../history/CalculatorHistoryImpl.java | 2 +- .../android/calculator/math/MathType.java | 10 ++--- .../android/calculator/model/AFunction.java | 4 +- .../text/FromJsclSimplifyTextProcessor.java | 4 +- .../calculator/AbstractCalculatorTest.java | 4 +- .../calculator/CalculatorEditorImplTest.java | 2 +- .../calculator/CalculatorTestUtils.java | 12 +++--- .../FromJsclSimplifyTextProcessorTest.java | 10 ++--- .../history/CalculatorHistoryImplTest.java | 4 +- .../model/AndroidCalculatorEngineTest.java | 40 +++++++++---------- .../calculator/model/NumeralBaseTest.java | 8 ++-- .../model/ToJsclTextProcessorTest.java | 4 +- .../calculator/AbstractCalculatorHelper.java | 6 +-- .../android/calculator/AndroidCalculator.java | 4 +- .../AndroidCalculatorEditorView.java | 7 ++-- .../AndroidCalculatorPreferenceService.java | 4 +- .../calculator/CalculatorActivity.java | 6 +-- .../CalculatorActivityHelperImpl.java | 4 +- .../CalculatorActivityLauncher.java | 10 ++--- .../calculator/CalculatorApplication.java | 10 ++--- .../android/calculator/CalculatorButtons.java | 16 ++++---- .../calculator/CalculatorDisplayFragment.java | 2 +- .../calculator/CalculatorDisplayMenuItem.java | 2 +- .../CalculatorDisplayOnClickListener.java | 2 +- .../calculator/CalculatorEditorFragment.java | 2 +- .../CalculatorFragmentHelperImpl.java | 8 ++-- .../CalculatorKeyboardFragment.java | 6 +-- .../calculator/ConversionMenuItem.java | 6 +-- .../calculator/CursorDragProcessor.java | 4 +- .../android/calculator/EvalDragProcessor.java | 2 +- ...efaultExternalCalculatorIntentHandler.java | 10 ++--- .../external/ExternalCalculatorHelper.java | 4 +- .../function/FunctionEditDialogFragment.java | 6 +-- .../function/FunctionEditorSaver.java | 8 ++-- .../AbstractCalculatorHistoryFragment.java | 6 +-- .../history/CalculatorHistoryFragment.java | 6 +-- .../CalculatorSavedHistoryFragment.java | 6 +-- .../history/HistoryItemMenuItem.java | 11 +++-- .../edit/CalculatorFunctionsFragment.java | 12 +++--- .../edit/CalculatorOperatorsFragment.java | 16 ++++---- .../math/edit/CalculatorVarsFragment.java | 16 ++++---- .../math/edit/MathEntityRemover.java | 8 ++-- .../math/edit/VarEditDialogFragment.java | 6 +-- .../calculator/math/edit/VarEditorSaver.java | 6 +-- .../plot/CalculatorPlotFragment.java | 6 +-- .../android/calculator/plot/PlotUtils.java | 4 +- .../calculator/view/AngleUnitsButton.java | 4 +- .../view/CalculatorAdditionalTitle.java | 6 +-- .../view/NumeralBaseConverterDialog.java | 12 +++--- .../calculator/view/NumeralBasesButton.java | 4 +- .../calculator/view/TextHighlighter.java | 4 +- .../AbstractCalculatorWidgetProvider.java | 4 +- .../widget/CalculatorWidgetHelper.java | 6 +-- .../widget/CalculatorWidgetIntentHandler.java | 4 +- .../calculator/widget/WidgetButton.java | 6 +-- .../AndroidCalculatorEditorViewTest.java | 2 +- .../calculator/CalculatorTestUtils.java | 8 ++-- .../calculator/TextHighlighterTest.java | 2 +- 70 files changed, 261 insertions(+), 263 deletions(-) rename calculatorpp-core/src/main/java/org/solovyev/android/calculator/{CalculatorLocatorImpl.java => Locator.java} (94%) diff --git a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/AbstractCalculatorMathRegistry.java b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/AbstractCalculatorMathRegistry.java index c40f159d..4025556f 100644 --- a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/AbstractCalculatorMathRegistry.java +++ b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/AbstractCalculatorMathRegistry.java @@ -70,7 +70,7 @@ public abstract class AbstractCalculatorMathRegistry messages = new ArrayList(); while (messageRegistry.hasMessage()) { @@ -273,7 +273,7 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { if ( currentTime - lastPreferenceCheck > PREFERENCE_CHECK_INTERVAL ) { 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) { final CalculatorEventData eventDataId = nextEventData(); - final CalculatorDisplayViewState displayViewState = CalculatorLocatorImpl.getInstance().getDisplay().getViewState(); - final NumeralBase from = CalculatorLocatorImpl.getInstance().getEngine().getNumeralBase(); + final CalculatorDisplayViewState displayViewState = Locator.getInstance().getDisplay().getViewState(); + final NumeralBase from = Locator.getInstance().getEngine().getNumeralBase(); calculationsExecutor.execute(new Runnable() { @Override @@ -511,17 +511,17 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { case use_constant: final IConstant constant = (IConstant)data; - CalculatorLocatorImpl.getInstance().getKeyboard().buttonPressed(constant.getName()); + Locator.getInstance().getKeyboard().buttonPressed(constant.getName()); break; case use_operator: final Operator operator = (Operator)data; - CalculatorLocatorImpl.getInstance().getKeyboard().buttonPressed(operator.getName()); + Locator.getInstance().getKeyboard().buttonPressed(operator.getName()); break; case use_function: final Function function = (Function)data; - CalculatorLocatorImpl.getInstance().getKeyboard().buttonPressed(function.getName()); + Locator.getInstance().getKeyboard().buttonPressed(function.getName()); break; } @@ -532,7 +532,7 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { if (newState.isValid()) { final String result = newState.getStringResult(); if ( !StringUtils.isEmpty(result) ) { - final CalculatorMathRegistry varsRegistry = CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry(); + final CalculatorMathRegistry varsRegistry = Locator.getInstance().getEngine().getVarsRegistry(); final IConstant ansVar = varsRegistry.get(CalculatorVarsRegistry.ANS); final Var.Builder varBuilder; @@ -561,7 +561,7 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { @Override public void doHistoryAction(@NotNull HistoryAction historyAction) { - final CalculatorHistory history = CalculatorLocatorImpl.getInstance().getHistory(); + final CalculatorHistory history = Locator.getInstance().getHistory(); if (history.isActionAvailable(historyAction)) { final CalculatorHistoryState newState = history.doAction(historyAction, getCurrentHistoryState()); if (newState != null) { @@ -591,11 +591,11 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { @NotNull private CalculatorEditor getEditor() { - return CalculatorLocatorImpl.getInstance().getEditor(); + return Locator.getInstance().getEditor(); } @NotNull private CalculatorDisplay getDisplay() { - return CalculatorLocatorImpl.getInstance().getDisplay(); + return Locator.getInstance().getDisplay(); } } diff --git a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardImpl.java b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardImpl.java index 62631536..b41ac768 100644 --- a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardImpl.java +++ b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorKeyboardImpl.java @@ -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); } } @@ -73,7 +73,7 @@ public class CalculatorKeyboardImpl implements CalculatorKeyboard { @Override public void roundBracketsButtonPressed() { - final CalculatorEditor editor = CalculatorLocatorImpl.getInstance().getEditor(); + final CalculatorEditor editor = Locator.getInstance().getEditor(); CalculatorEditorViewState viewState = editor.getViewState(); final int cursorPosition = viewState.getSelection(); @@ -89,36 +89,36 @@ public class CalculatorKeyboardImpl implements CalculatorKeyboard { @Override public void pasteButtonPressed() { - final String text = CalculatorLocatorImpl.getInstance().getClipboard().getText(); + final String text = Locator.getInstance().getClipboard().getText(); if (text != null) { - CalculatorLocatorImpl.getInstance().getEditor().insert(text); + Locator.getInstance().getEditor().insert(text); } } @Override public void clearButtonPressed() { - CalculatorLocatorImpl.getInstance().getEditor().clear(); + Locator.getInstance().getEditor().clear(); } @Override public void copyButtonPressed() { - final CalculatorDisplayViewState displayViewState = CalculatorLocatorImpl.getInstance().getDisplay().getViewState(); + final CalculatorDisplayViewState displayViewState = Locator.getInstance().getDisplay().getViewState(); if (displayViewState.isValid()) { final CharSequence text = displayViewState.getText(); if (!StringUtils.isEmpty(text)) { - CalculatorLocatorImpl.getInstance().getClipboard().setText(text); - CalculatorLocatorImpl.getInstance().getNotifier().showMessage(CalculatorMessage.newInfoMessage(CalculatorMessages.result_copied)); + Locator.getInstance().getClipboard().setText(text); + Locator.getInstance().getNotifier().showMessage(CalculatorMessage.newInfoMessage(CalculatorMessages.result_copied)); } } } @Override public void moveCursorLeft() { - CalculatorLocatorImpl.getInstance().getEditor().moveCursorLeft(); + Locator.getInstance().getEditor().moveCursorLeft(); } @Override public void moveCursorRight() { - CalculatorLocatorImpl.getInstance().getEditor().moveCursorRight(); + Locator.getInstance().getEditor().moveCursorRight(); } } diff --git a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorSpecialButton.java b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorSpecialButton.java index ecb910f7..d290afec 100644 --- a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorSpecialButton.java +++ b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorSpecialButton.java @@ -16,13 +16,13 @@ public enum CalculatorSpecialButton { history("history") { @Override 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") { @Override 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("▶") { @@ -40,27 +40,27 @@ public enum CalculatorSpecialButton { settings("settings") { @Override 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") { @Override 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") { @Override 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") { @Override public void onClick(@NotNull CalculatorKeyboard keyboard) { - CalculatorLocatorImpl.getInstance().getEditor().erase(); + Locator.getInstance().getEditor().erase(); } }, paste("paste") { @@ -78,7 +78,7 @@ public enum CalculatorSpecialButton { equals("=") { @Override public void onClick(@NotNull CalculatorKeyboard keyboard) { - CalculatorLocatorImpl.getInstance().getCalculator().evaluate(); + Locator.getInstance().getCalculator().evaluate(); } }, clear("clear") { @@ -90,44 +90,44 @@ public enum CalculatorSpecialButton { functions("functions") { @Override 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") { @Override 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") { @Override public void onClick(@NotNull CalculatorKeyboard keyboard) { - CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.open_app, null); + Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.open_app, null); } }, vars("vars") { @Override 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") { @Override 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") { @Override 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") { @Override public void onClick(@NotNull CalculatorKeyboard keyboard) { - CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_operators_detached, null); + Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_operators_detached, null); } }; diff --git a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorUtils.java b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorUtils.java index 6da2594f..c33552ad 100644 --- a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorUtils.java +++ b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorUtils.java @@ -32,7 +32,7 @@ public final class CalculatorUtils { final Set notSystemConstants = new HashSet(); 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()) { notSystemConstants.add(constant); } diff --git a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorVarsRegistry.java b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorVarsRegistry.java index 80ee81ce..d98165d8 100644 --- a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorVarsRegistry.java +++ b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorVarsRegistry.java @@ -55,9 +55,9 @@ public class CalculatorVarsRegistry extends AbstractCalculatorMathRegistry calculatorEvents) { final List listeners = this.listeners.getListeners(); - //final CalculatorLogger logger = CalculatorLocatorImpl.getInstance().getLogger(); + //final CalculatorLogger logger = Locator.getInstance().getLogger(); 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) { /*long startTime = System.currentTimeMillis();*/ listener.onCalculatorEvent(e.getCalculatorEventData(), e.getCalculatorEventType(), e.getData()); diff --git a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorLocatorImpl.java b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/Locator.java similarity index 94% rename from calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorLocatorImpl.java rename to calculatorpp-core/src/main/java/org/solovyev/android/calculator/Locator.java index e427a45e..91967c2b 100644 --- a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorLocatorImpl.java +++ b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/Locator.java @@ -8,7 +8,7 @@ import org.solovyev.android.calculator.history.CalculatorHistory; * Date: 20.09.12 * Time: 12:45 */ -public class CalculatorLocatorImpl implements CalculatorLocator { +public class Locator implements CalculatorLocator { @NotNull private CalculatorEngine calculatorEngine; @@ -38,12 +38,12 @@ public class CalculatorLocatorImpl implements CalculatorLocator { private CalculatorClipboard calculatorClipboard = new DummyCalculatorClipboard(); @NotNull - private static final CalculatorLocator instance = new CalculatorLocatorImpl(); + private static final CalculatorLocator instance = new Locator(); @NotNull private CalculatorPreferenceService calculatorPreferenceService; - public CalculatorLocatorImpl() { + public Locator() { } @Override diff --git a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/ToJsclTextProcessor.java b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/ToJsclTextProcessor.java index 1c4f94f2..abca4ab1 100644 --- a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/ToJsclTextProcessor.java +++ b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/ToJsclTextProcessor.java @@ -53,7 +53,7 @@ public class ToJsclTextProcessor implements TextProcessor 0 ) { throw new CalculatorParseException(i, s, new CalculatorMessage(CalculatorMessages.msg_005, MessageType.error, mathTypeBefore.getMatch())); } @@ -107,9 +107,9 @@ public class ToJsclTextProcessor implements TextProcessor getTokens() { - return CalculatorLocatorImpl.getInstance().getEngine().getPostfixFunctionsRegistry().getNames(); + return Locator.getInstance().getEngine().getPostfixFunctionsRegistry().getNames(); } }, @@ -101,7 +101,7 @@ public enum MathType { @NotNull @Override public List getTokens() { - return CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry().getNames(); + return Locator.getInstance().getEngine().getFunctionsRegistry().getNames(); } }, @@ -109,7 +109,7 @@ public enum MathType { @NotNull @Override public List getTokens() { - return CalculatorLocatorImpl.getInstance().getEngine().getOperatorsRegistry().getNames(); + return Locator.getInstance().getEngine().getOperatorsRegistry().getNames(); } }, @@ -117,7 +117,7 @@ public enum MathType { @NotNull @Override public List getTokens() { - return CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().getNames(); + return Locator.getInstance().getEngine().getVarsRegistry().getNames(); } @Override diff --git a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/model/AFunction.java b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/model/AFunction.java index 6ee10a7b..a6f35175 100644 --- a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/model/AFunction.java +++ b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/model/AFunction.java @@ -13,7 +13,7 @@ import org.simpleframework.xml.Element; import org.simpleframework.xml.ElementList; import org.simpleframework.xml.Root; 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.MathPersistenceEntity; import org.solovyev.common.math.MathEntity; @@ -268,7 +268,7 @@ public class AFunction implements IFunction, MathPersistenceEntity, Serializable result.name = name; try { - result.content = CalculatorLocatorImpl.getInstance().getCalculator().prepareExpression(value).toString(); + result.content = Locator.getInstance().getCalculator().prepareExpression(value).toString(); } catch (CalculatorParseException e) { throw new CreationException(e); } diff --git a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/text/FromJsclSimplifyTextProcessor.java b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/text/FromJsclSimplifyTextProcessor.java index a6b8e300..3c3245b6 100644 --- a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/text/FromJsclSimplifyTextProcessor.java +++ b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/text/FromJsclSimplifyTextProcessor.java @@ -3,7 +3,7 @@ package org.solovyev.android.calculator.text; import jscl.math.Generic; import org.jetbrains.annotations.NotNull; 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.CalculatorParseException; @@ -57,7 +57,7 @@ public class FromJsclSimplifyTextProcessor implements TextProcessor need to notify editor 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) { if (!viewStateChange) { // external text change => need to notify editor - CalculatorLocatorImpl.getInstance().getEditor().setText(String.valueOf(s)); + Locator.getInstance().getEditor().setText(String.valueOf(s)); } } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/AndroidCalculatorPreferenceService.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/AndroidCalculatorPreferenceService.java index c243da14..d4112703 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/AndroidCalculatorPreferenceService.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/AndroidCalculatorPreferenceService.java @@ -75,7 +75,7 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application); 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 @@ -89,6 +89,6 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application); 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())); } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java index 251ef93f..bbeb8499 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java @@ -80,12 +80,12 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar preferences.registerOnSharedPreferenceChangeListener(this); - CalculatorLocatorImpl.getInstance().getPreferenceService().checkPreferredPreferences(false); + Locator.getInstance().getPreferenceService().checkPreferredPreferences(false); } @NotNull private AndroidCalculator getCalculator() { - return ((AndroidCalculator) CalculatorLocatorImpl.getInstance().getCalculator()); + return ((AndroidCalculator) Locator.getInstance().getCalculator()); } private static void firstTimeInit(@NotNull SharedPreferences preferences, @NotNull Context context) { @@ -267,7 +267,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar @NotNull private static CalculatorKeyboard getKeyboard() { - return CalculatorLocatorImpl.getInstance().getKeyboard(); + return Locator.getInstance().getKeyboard(); } @SuppressWarnings({"UnusedDeclaration"}) diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java index 3771a881..0e1c9744 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java @@ -68,7 +68,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple super.onCreate(activity); if (activity instanceof CalculatorEventListener) { - CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener) activity); + Locator.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener) activity); } final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); @@ -172,7 +172,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple super.onDestroy(activity); if (activity instanceof CalculatorEventListener) { - CalculatorLocatorImpl.getInstance().getCalculator().removeCalculatorEventListener((CalculatorEventListener) activity); + Locator.getInstance().getCalculator().removeCalculatorEventListener((CalculatorEventListener) activity); } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityLauncher.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityLauncher.java index b80aa6d2..164882cd 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityLauncher.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorActivityLauncher.java @@ -120,13 +120,13 @@ public class CalculatorActivityLauncher { context.startActivity(intent); } } 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 { - CalculatorLocatorImpl.getInstance().getNotifier().showMessage(R.string.empty_var_error, MessageType.error); + Locator.getInstance().getNotifier().showMessage(R.string.empty_var_error, MessageType.error); } } 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); } else { - CalculatorLocatorImpl.getInstance().getNotifier().showMessage(R.string.empty_function_error, MessageType.error); + Locator.getInstance().getNotifier().showMessage(R.string.empty_function_error, MessageType.error); } } else { - CalculatorLocatorImpl.getInstance().getNotifier().showMessage(R.string.not_valid_result, MessageType.error); + Locator.getInstance().getNotifier().showMessage(R.string.not_valid_result, MessageType.error); } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java index 98364902..3f70b4c1 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java @@ -87,7 +87,7 @@ public class CalculatorApplication extends android.app.Application { final AndroidCalculator calculator = new AndroidCalculator(this); - CalculatorLocatorImpl.getInstance().init(calculator, + Locator.getInstance().init(calculator, new AndroidCalculatorEngine(this), new AndroidCalculatorClipboard(this), new AndroidCalculatorNotifier(this), @@ -96,11 +96,11 @@ public class CalculatorApplication extends android.app.Application { new AndroidCalculatorPreferenceService(this), new AndroidCalculatorKeyboard(this, new CalculatorKeyboardImpl(calculator))); - CalculatorLocatorImpl.getInstance().getCalculator().init(); + Locator.getInstance().getCalculator().init(); // in order to not to be garbage collected widgetHelper = new CalculatorWidgetHelper(); - CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener(widgetHelper); + Locator.getInstance().getCalculator().addCalculatorEventListener(widgetHelper); BillingDB.init(CalculatorApplication.this); @@ -130,8 +130,8 @@ public class CalculatorApplication extends android.app.Application { } }).start(); - CalculatorLocatorImpl.getInstance().getLogger().debug(TAG, "Application started!"); - CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage(TAG, "Application started!"); + Locator.getInstance().getLogger().debug(TAG, "Application started!"); + Locator.getInstance().getNotifier().showDebugMessage(TAG, "Application started!"); } private void setTheme(@NotNull SharedPreferences preferences) { diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java index ee4b8cc3..90736d8a 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java @@ -54,12 +54,12 @@ public final class CalculatorButtons { static void initMultiplicationButton(@NotNull View root) { final View multiplicationButton = root.findViewById(R.id.multiplicationButton); 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) { - 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 private static CalculatorKeyboard getKeyboard() { - return CalculatorLocatorImpl.getInstance().getKeyboard(); + return Locator.getInstance().getKeyboard(); } static class VarsDragProcessor implements SimpleOnDragListener.DragProcessor { @@ -132,7 +132,7 @@ public final class CalculatorButtons { boolean result = false; if (dragDirection == DragDirection.up) { - CalculatorActivityLauncher.createVar(context, CalculatorLocatorImpl.getInstance().getDisplay()); + CalculatorActivityLauncher.createVar(context, Locator.getInstance().getDisplay()); result = true; } @@ -150,7 +150,7 @@ public final class CalculatorButtons { AngleUnitsChanger(@NotNull Context context) { this.context = context; - this.processor = new DigitButtonDragProcessor(CalculatorLocatorImpl.getInstance().getKeyboard()); + this.processor = new DigitButtonDragProcessor(Locator.getInstance().getKeyboard()); } @Override @@ -172,7 +172,7 @@ public final class CalculatorButtons { final AngleUnit oldAngleUnits = AndroidCalculatorEngine.Preferences.angleUnit.getPreference(preferences); if (oldAngleUnits != angleUnits) { - CalculatorLocatorImpl.getInstance().getPreferenceService().setAngleUnits(angleUnits); + Locator.getInstance().getPreferenceService().setAngleUnits(angleUnits); } result = true; @@ -216,7 +216,7 @@ public final class CalculatorButtons { final NumeralBase oldNumeralBase = AndroidCalculatorEngine.Preferences.numeralBase.getPreference(preferences); if (oldNumeralBase != numeralBase) { - CalculatorLocatorImpl.getInstance().getPreferenceService().setNumeralBase(numeralBase); + Locator.getInstance().getPreferenceService().setNumeralBase(numeralBase); } result = true; @@ -247,7 +247,7 @@ public final class CalculatorButtons { boolean result = false; if (dragDirection == DragDirection.up) { - CalculatorActivityLauncher.createFunction(context, CalculatorLocatorImpl.getInstance().getDisplay()); + CalculatorActivityLauncher.createFunction(context, Locator.getInstance().getDisplay()); result = true; } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorDisplayFragment.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorDisplayFragment.java index 6a04f56e..9c443562 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorDisplayFragment.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorDisplayFragment.java @@ -43,7 +43,7 @@ public class CalculatorDisplayFragment extends SherlockFragment { public void onViewCreated(View root, Bundle savedInstanceState) { super.onViewCreated(root, savedInstanceState); - ((AndroidCalculator) CalculatorLocatorImpl.getInstance().getCalculator()).setDisplay(getActivity()); + ((AndroidCalculator) Locator.getInstance().getCalculator()).setDisplay(getActivity()); fragmentHelper.onViewCreated(this, root); } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorDisplayMenuItem.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorDisplayMenuItem.java index f085b960..00d6ff48 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorDisplayMenuItem.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorDisplayMenuItem.java @@ -19,7 +19,7 @@ public enum CalculatorDisplayMenuItem implements LabeledMenuItem { if (operation == JsclOperation.numeric) { if (generic.getConstants().isEmpty()) { // conversion possible => return true - final NumeralBase fromNumeralBase = CalculatorLocatorImpl.getInstance().getEngine().getNumeralBase(); + final NumeralBase fromNumeralBase = Locator.getInstance().getEngine().getNumeralBase(); 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 { final Generic result = data.getResult(); if (result != null) { - CalculatorLocatorImpl.getInstance().getCalculator().convert(result, this.toNumeralBase); + Locator.getInstance().getCalculator().convert(result, this.toNumeralBase); } } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CursorDragProcessor.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CursorDragProcessor.java index 967e8a71..5ece5d70 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CursorDragProcessor.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CursorDragProcessor.java @@ -30,10 +30,10 @@ public class CursorDragProcessor implements SimpleOnDragListener.DragProcessor{ if (dragButton instanceof DirectionDragButton) { String text = ((DirectionDragButton) dragButton).getText(dragDirection); if ("◀◀".equals(text)) { - CalculatorLocatorImpl.getInstance().getEditor().setCursorOnStart(); + Locator.getInstance().getEditor().setCursorOnStart(); result = true; } else if ("▶▶".equals(text)) { - CalculatorLocatorImpl.getInstance().getEditor().setCursorOnEnd(); + Locator.getInstance().getEditor().setCursorOnEnd(); result = true; } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/EvalDragProcessor.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/EvalDragProcessor.java index a105fea5..4447adf1 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/EvalDragProcessor.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/EvalDragProcessor.java @@ -31,7 +31,7 @@ public class EvalDragProcessor implements SimpleOnDragListener.DragProcessor { if (dragButton instanceof DirectionDragButton) { String text = ((DirectionDragButton) dragButton).getText(dragDirection); if ("≡".equals(text)) { - CalculatorLocatorImpl.getInstance().getCalculator().simplify(); + Locator.getInstance().getCalculator().simplify(); result = true; } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/external/DefaultExternalCalculatorIntentHandler.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/external/DefaultExternalCalculatorIntentHandler.java index ecd1c90b..3c019cb9 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/external/DefaultExternalCalculatorIntentHandler.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/external/DefaultExternalCalculatorIntentHandler.java @@ -4,9 +4,9 @@ import android.content.Context; import android.content.Intent; import android.os.Parcelable; import org.jetbrains.annotations.NotNull; +import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.CalculatorDisplayViewState; import org.solovyev.android.calculator.CalculatorEditorViewState; -import org.solovyev.android.calculator.CalculatorLocatorImpl; import org.solovyev.common.MutableObject; /** @@ -35,7 +35,7 @@ public class DefaultExternalCalculatorIntentHandler implements ExternalCalculato public void onIntent(@NotNull Context context, @NotNull Intent intent) { if (ExternalCalculatorHelper.EDITOR_STATE_CHANGED_ACTION.equals(intent.getAction())) { - CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage(TAG, "Editor state changed broadcast received!"); + Locator.getInstance().getNotifier().showDebugMessage(TAG, "Editor state changed broadcast received!"); final Long eventId = intent.getLongExtra(ExternalCalculatorHelper.EVENT_ID_EXTRA, 0L); @@ -54,7 +54,7 @@ public class DefaultExternalCalculatorIntentHandler implements ExternalCalculato } } } else if (ExternalCalculatorHelper.DISPLAY_STATE_CHANGED_ACTION.equals(intent.getAction())) { - CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage(TAG, "Display state changed broadcast received!"); + Locator.getInstance().getNotifier().showDebugMessage(TAG, "Display state changed broadcast received!"); final Long eventId = intent.getLongExtra(ExternalCalculatorHelper.EVENT_ID_EXTRA, 0L); boolean updateDisplay = false; @@ -81,10 +81,10 @@ public class DefaultExternalCalculatorIntentHandler implements ExternalCalculato } 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) { - updateState(context, editorViewState, CalculatorLocatorImpl.getInstance().getDisplay().getViewState()); + updateState(context, editorViewState, Locator.getInstance().getDisplay().getViewState()); } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/external/ExternalCalculatorHelper.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/external/ExternalCalculatorHelper.java index 5f0357d3..4c59a60d 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/external/ExternalCalculatorHelper.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/external/ExternalCalculatorHelper.java @@ -42,7 +42,7 @@ public class ExternalCalculatorHelper { intent.putExtra(EVENT_ID_EXTRA, calculatorEventData.getEventId()); intent.putExtra(EDITOR_STATE_EXTRA, (Parcelable) new ParcelableCalculatorEditorViewState(editorViewState)); context.sendBroadcast(intent); - CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage(TAG, "Editor state changed broadcast sent"); + Locator.getInstance().getNotifier().showDebugMessage(TAG, "Editor state changed broadcast sent"); } } @@ -55,7 +55,7 @@ public class ExternalCalculatorHelper { intent.putExtra(EVENT_ID_EXTRA, calculatorEventData.getEventId()); intent.putExtra(DISPLAY_STATE_EXTRA, (Parcelable) new ParcelableCalculatorDisplayViewState(displayViewState)); context.sendBroadcast(intent); - CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage(TAG, "Display state changed broadcast sent"); + Locator.getInstance().getNotifier().showDebugMessage(TAG, "Display state changed broadcast sent"); } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/function/FunctionEditDialogFragment.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/function/FunctionEditDialogFragment.java index c1007e3f..13045002 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/function/FunctionEditDialogFragment.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/function/FunctionEditDialogFragment.java @@ -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 ) { // CREATE MODE @@ -130,12 +130,12 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul public void onResume() { super.onResume(); - CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener(this); + Locator.getInstance().getCalculator().addCalculatorEventListener(this); } @Override public void onPause() { - CalculatorLocatorImpl.getInstance().getCalculator().removeCalculatorEventListener(this); + Locator.getInstance().getCalculator().removeCalculatorEventListener(this); super.onPause(); } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/function/FunctionEditorSaver.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/function/FunctionEditorSaver.java index 6f6317d9..84d3b475 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/function/FunctionEditorSaver.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/function/FunctionEditorSaver.java @@ -8,8 +8,8 @@ import jscl.math.function.Function; import jscl.math.function.IFunction; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.CalculatorFunctionsMathRegistry; -import org.solovyev.android.calculator.CalculatorLocatorImpl; import org.solovyev.android.calculator.CalculatorMathRegistry; import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.math.edit.VarEditorSaver; @@ -101,14 +101,14 @@ public class FunctionEditorSaver implements View.OnClickListener { } if (error != null) { - CalculatorLocatorImpl.getInstance().getNotifier().showMessage(error, MessageType.error); + Locator.getInstance().getNotifier().showMessage(error, MessageType.error); } else { try { CalculatorFunctionsMathRegistry.saveFunction(mathRegistry, new BuilderAdapter(builder), editedInstance, source, true); } catch (CustomFunctionCalculationException e) { - CalculatorLocatorImpl.getInstance().getNotifier().showMessage(e); + Locator.getInstance().getNotifier().showMessage(e); } catch (AFunction.Builder.CreationException e) { - CalculatorLocatorImpl.getInstance().getNotifier().showMessage(e); + Locator.getInstance().getNotifier().showMessage(e); } } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java index 314f471d..7bbe516e 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java @@ -219,7 +219,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag boolean result = false; try { historyState.setSaved(true); - if ( CollectionsUtils.contains(historyState, CalculatorLocatorImpl.getInstance().getHistory().getSavedHistory(), new Equalizer() { + if ( CollectionsUtils.contains(historyState, Locator.getInstance().getHistory().getSavedHistory(), new Equalizer() { @Override public boolean equals(@Nullable CalculatorHistoryState first, @Nullable CalculatorHistoryState second) { return first != null && second != null && @@ -237,7 +237,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag } 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 @@ -339,7 +339,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag clear_history(org.solovyev.android.calculator.R.id.history_menu_clear_history) { @Override 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); } }; diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/history/CalculatorHistoryFragment.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/history/CalculatorHistoryFragment.java index a579a577..a16aaacd 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/history/CalculatorHistoryFragment.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/history/CalculatorHistoryFragment.java @@ -8,7 +8,7 @@ package org.solovyev.android.calculator.history; import android.preference.PreferenceManager; 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.R; import org.solovyev.android.calculator.about.CalculatorFragmentType; @@ -36,12 +36,12 @@ public class CalculatorHistoryFragment extends AbstractCalculatorHistoryFragment @Override protected List getHistoryItems() { final boolean showIntermediateCalculations = CalculatorPreferences.History.showIntermediateCalculations.getPreference(PreferenceManager.getDefaultSharedPreferences(getActivity())); - return new ArrayList(CalculatorLocatorImpl.getInstance().getHistory().getStates(showIntermediateCalculations)); + return new ArrayList(Locator.getInstance().getHistory().getStates(showIntermediateCalculations)); } @Override protected void clearHistory() { - CalculatorLocatorImpl.getInstance().getHistory().clear(); + Locator.getInstance().getHistory().clear(); getAdapter().clear(); } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/history/CalculatorSavedHistoryFragment.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/history/CalculatorSavedHistoryFragment.java index 98fcec90..c2d26e00 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/history/CalculatorSavedHistoryFragment.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/history/CalculatorSavedHistoryFragment.java @@ -7,7 +7,7 @@ package org.solovyev.android.calculator.history; 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.about.CalculatorFragmentType; @@ -33,12 +33,12 @@ public class CalculatorSavedHistoryFragment extends AbstractCalculatorHistoryFra @NotNull @Override protected List getHistoryItems() { - return new ArrayList(CalculatorLocatorImpl.getInstance().getHistory().getSavedHistory()); + return new ArrayList(Locator.getInstance().getHistory().getSavedHistory()); } @Override protected void clearHistory() { - CalculatorLocatorImpl.getInstance().getHistory().clearSavedHistory(); + Locator.getInstance().getHistory().clearSavedHistory(); getAdapter().clear(); } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/history/HistoryItemMenuItem.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/history/HistoryItemMenuItem.java index 0a93fac8..7cfad817 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/history/HistoryItemMenuItem.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/history/HistoryItemMenuItem.java @@ -11,14 +11,13 @@ import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.text.ClipboardManager; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; 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.menu.LabeledMenuItem; import org.solovyev.common.text.StringUtils; @@ -93,7 +92,7 @@ public enum HistoryItemMenuItem implements LabeledMenuItem final CalculatorHistoryState historyState = data.getHistoryState(); if (historyState.isSaved()) { 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(); data.getAdapter().notifyDataSetChanged(); } @@ -119,14 +118,14 @@ public enum HistoryItemMenuItem implements LabeledMenuItem @Override public void onClick(DialogInterface dialog, int which) { if (save) { - final CalculatorHistoryState savedHistoryItem = CalculatorLocatorImpl.getInstance().getHistory().addSavedState(historyState); + final CalculatorHistoryState savedHistoryItem = Locator.getInstance().getHistory().addSavedState(historyState); 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 //data.getAdapter().add(savedHistoryItem); } else { historyState.setComment(comment.getText().toString()); - CalculatorLocatorImpl.getInstance().getHistory().save(); + Locator.getInstance().getHistory().save(); } data.getAdapter().notifyDataSetChanged(); Toast.makeText(context, context.getText(R.string.c_history_saved), Toast.LENGTH_LONG).show(); diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsFragment.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsFragment.java index 2a519f52..68a1d79a 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsFragment.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsFragment.java @@ -72,7 +72,7 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment< protected List> getMenuItemsOnLongClick(@NotNull Function item) { List> result = new ArrayList>(Arrays.asList(LongClickMenuItem.values())); - final CalculatorMathRegistry functionsRegistry = CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry(); + final CalculatorMathRegistry functionsRegistry = Locator.getInstance().getEngine().getFunctionsRegistry(); if ( StringUtils.isEmpty(functionsRegistry.getDescription(item.getName())) ) { result.remove(LongClickMenuItem.copy_description); } @@ -88,18 +88,18 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment< @NotNull @Override protected MathEntityDescriptionGetter getDescriptionGetter() { - return new MathEntityDescriptionGetterImpl(CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry()); + return new MathEntityDescriptionGetterImpl(Locator.getInstance().getEngine().getFunctionsRegistry()); } @NotNull @Override protected List getMathEntities() { - return new ArrayList(CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry().getEntities()); + return new ArrayList(Locator.getInstance().getEngine().getFunctionsRegistry().getEntities()); } @Override protected String getMathEntityCategory(@NotNull Function function) { - return CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry().getCategory(function); + return Locator.getInstance().getEngine().getFunctionsRegistry().getCategory(function); } @Override @@ -223,7 +223,7 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment< use(R.string.c_use) { @Override 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) { @Override 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)) { final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE); clipboard.setText(text); diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorOperatorsFragment.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorOperatorsFragment.java index 1817515f..fd7938d9 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorOperatorsFragment.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorOperatorsFragment.java @@ -5,8 +5,8 @@ import android.content.Context; import android.text.ClipboardManager; import jscl.math.operator.Operator; import org.jetbrains.annotations.NotNull; +import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.CalculatorEventType; -import org.solovyev.android.calculator.CalculatorLocatorImpl; import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.about.CalculatorFragmentType; import org.solovyev.android.menu.AMenuItem; @@ -58,17 +58,17 @@ public class CalculatorOperatorsFragment extends AbstractMathEntityListFragment< protected List getMathEntities() { final List result = new ArrayList(); - result.addAll(CalculatorLocatorImpl.getInstance().getEngine().getOperatorsRegistry().getEntities()); - result.addAll(CalculatorLocatorImpl.getInstance().getEngine().getPostfixFunctionsRegistry().getEntities()); + result.addAll(Locator.getInstance().getEngine().getOperatorsRegistry().getEntities()); + result.addAll(Locator.getInstance().getEngine().getPostfixFunctionsRegistry().getEntities()); return result; } @Override 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) { - result = CalculatorLocatorImpl.getInstance().getEngine().getPostfixFunctionsRegistry().getCategory(operator); + result = Locator.getInstance().getEngine().getPostfixFunctionsRegistry().getCategory(operator); } return result; @@ -80,9 +80,9 @@ public class CalculatorOperatorsFragment extends AbstractMathEntityListFragment< @Override 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)) { - result = CalculatorLocatorImpl.getInstance().getEngine().getPostfixFunctionsRegistry().getDescription(mathEntityName); + result = Locator.getInstance().getEngine().getPostfixFunctionsRegistry().getDescription(mathEntityName); } return result; @@ -102,7 +102,7 @@ public class CalculatorOperatorsFragment extends AbstractMathEntityListFragment< use(R.string.c_use) { @Override 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); } }, diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java index c814b733..5ebf84b5 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java @@ -75,7 +75,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment getMathEntities() { - final List result = new ArrayList(CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry().getEntities()); + final List result = new ArrayList(Locator.getInstance().getEngine().getVarsRegistry().getEntities()); CollectionsUtils.removeAll(result, new JPredicate() { @Override @@ -114,7 +114,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment implements View.OnClickList @Nullable DialogInterface.OnClickListener callbackOnCancel, @NotNull Context context, @NotNull Object source) { - return new MathEntityRemover(constant, callbackOnCancel, false, CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry(), context, source, Params.newConstantInstance()); + return new MathEntityRemover(constant, callbackOnCancel, false, Locator.getInstance().getEngine().getVarsRegistry(), context, source, Params.newConstantInstance()); } public static MathEntityRemover newFunctionRemover(@NotNull Function function, @Nullable DialogInterface.OnClickListener callbackOnCancel, @NotNull Context context, @NotNull Object source) { - return new MathEntityRemover(function, callbackOnCancel, false, CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry(), context, source, Params.newFunctionInstance()); + return new MathEntityRemover(function, callbackOnCancel, false, Locator.getInstance().getEngine().getFunctionsRegistry(), context, source, Params.newFunctionInstance()); } /* @@ -117,7 +117,7 @@ public class MathEntityRemover implements View.OnClickList varsRegistry.remove(mathEntity); varsRegistry.save(); - CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(params.getCalculatorEventType(), mathEntity, source); + Locator.getInstance().getCalculator().fireCalculatorEvent(params.getCalculatorEventType(), mathEntity, source); } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/VarEditDialogFragment.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/VarEditDialogFragment.java index 32a8f2d4..2bc38249 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/VarEditDialogFragment.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/VarEditDialogFragment.java @@ -45,12 +45,12 @@ public class VarEditDialogFragment extends DialogFragment implements CalculatorE public void onResume() { super.onResume(); - CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener(this); + Locator.getInstance().getCalculator().addCalculatorEventListener(this); } @Override public void onPause() { - CalculatorLocatorImpl.getInstance().getCalculator().removeCalculatorEventListener(this); + Locator.getInstance().getCalculator().removeCalculatorEventListener(this); super.onPause(); } @@ -110,7 +110,7 @@ public class VarEditDialogFragment extends DialogFragment implements CalculatorE } }); - root.findViewById(R.id.save_button).setOnClickListener(new VarEditorSaver(varBuilder, constant, root, CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry(), this)); + root.findViewById(R.id.save_button).setOnClickListener(new VarEditorSaver(varBuilder, constant, root, Locator.getInstance().getEngine().getVarsRegistry(), this)); if ( constant == null ) { // CREATE MODE diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/VarEditorSaver.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/VarEditorSaver.java index 7bbf1828..00b773ee 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/VarEditorSaver.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/math/edit/VarEditorSaver.java @@ -14,7 +14,7 @@ import jscl.text.ParseException; import jscl.text.Parser; import org.jetbrains.annotations.NotNull; 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.CalculatorVarsRegistry; import org.solovyev.android.calculator.R; @@ -117,7 +117,7 @@ public class VarEditorSaver implements View.OnClickListene } if (error != null) { - CalculatorLocatorImpl.getInstance().getNotifier().showMessage(error, MessageType.error); + Locator.getInstance().getNotifier().showMessage(error, MessageType.error); } else { CalculatorVarsRegistry.saveVariable(mathRegistry, varBuilder, editedInstance, source, true); } @@ -129,7 +129,7 @@ public class VarEditorSaver implements View.OnClickListene if (!StringUtils.isEmpty(name)) { try { 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; } catch (ParseException e) { // not valid name; diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java index 9fe26403..e07dfe36 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java @@ -152,10 +152,10 @@ public class CalculatorPlotFragment extends CalculatorFragment implements Calcul result = PreparedInput.newInstance(input, expression, variable, fromInputArgs, plotBoundaries); } catch (ParseException e) { result = PreparedInput.newErrorInstance(fromInputArgs); - CalculatorLocatorImpl.getInstance().getNotifier().showMessage(e); + Locator.getInstance().getNotifier().showMessage(e); } catch (CalculatorParseException e) { result = PreparedInput.newErrorInstance(fromInputArgs); - CalculatorLocatorImpl.getInstance().getNotifier().showMessage(e); + Locator.getInstance().getNotifier().showMessage(e); } return result; @@ -184,7 +184,7 @@ public class CalculatorPlotFragment extends CalculatorFragment implements Calcul super.onViewCreated(view, savedInstanceState); if (input == null) { - this.preparedInput = prepareInputFromDisplay(CalculatorLocatorImpl.getInstance().getDisplay().getViewState(), savedInstanceState); + this.preparedInput = prepareInputFromDisplay(Locator.getInstance().getDisplay().getViewState(), savedInstanceState); } else { this.preparedInput = prepareInput(input, true, savedInstanceState); } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/plot/PlotUtils.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/plot/PlotUtils.java index e719d343..c531ec99 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/plot/PlotUtils.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/plot/PlotUtils.java @@ -25,7 +25,7 @@ import org.achartengine.renderer.XYSeriesRenderer; import org.achartengine.util.MathHelper; import org.jetbrains.annotations.NotNull; 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.common.msg.MessageType; import org.solovyev.common.text.StringUtils; @@ -207,7 +207,7 @@ public final class PlotUtils { if (StringUtils.isEmpty(message)) { 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(); } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/view/AngleUnitsButton.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/view/AngleUnitsButton.java index 1af61666..6389938d 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/view/AngleUnitsButton.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/view/AngleUnitsButton.java @@ -12,7 +12,7 @@ import android.graphics.Paint; import android.text.TextPaint; import android.util.AttributeSet; 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.view.drag.DirectionDragButton; @@ -34,7 +34,7 @@ public class AngleUnitsButton extends DirectionDragButton { super.initDirectionTextPaint(basePaint, directionTextData, resources); 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)); } else { directionTextPaint.setColor(resources.getColor(R.color.cpp_default_text_color)); diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/view/CalculatorAdditionalTitle.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/view/CalculatorAdditionalTitle.java index 3093c46f..7c70e4af 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/view/CalculatorAdditionalTitle.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/view/CalculatorAdditionalTitle.java @@ -12,7 +12,7 @@ import android.util.AttributeSet; import android.widget.TextView; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.solovyev.android.calculator.CalculatorLocatorImpl; +import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.model.AndroidCalculatorEngine; /** @@ -40,8 +40,8 @@ public class CalculatorAdditionalTitle extends TextView implements SharedPrefere @Override 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)); } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/view/NumeralBaseConverterDialog.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/view/NumeralBaseConverterDialog.java index 0e87118c..9f9b080d 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/view/NumeralBaseConverterDialog.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/view/NumeralBaseConverterDialog.java @@ -6,7 +6,7 @@ import android.view.View; import android.view.WindowManager; import org.jetbrains.annotations.NotNull; 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.R; import org.solovyev.android.calculator.ToJsclTextProcessor; @@ -41,12 +41,12 @@ public class NumeralBaseConverterDialog { String value = initialFromValue; try { 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) { - b.setFromValue(UnitImpl.newInstance(value, CalculatorNumeralBase.valueOf(CalculatorLocatorImpl.getInstance().getEngine().getNumeralBase()))); + b.setFromValue(UnitImpl.newInstance(value, CalculatorNumeralBase.valueOf(Locator.getInstance().getEngine().getNumeralBase()))); } } 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()); @@ -67,11 +67,11 @@ public class NumeralBaseConverterDialog { public void onClick(@NotNull Unit fromUnits, @NotNull Unit toUnits) { 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; } - CalculatorLocatorImpl.getInstance().getKeyboard().buttonPressed(toUnitsValue); + Locator.getInstance().getKeyboard().buttonPressed(toUnitsValue); final AlertDialog alertDialog = alertDialogHolder.getObject(); if (alertDialog != null) { alertDialog.dismiss(); diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java index c009706b..e874de69 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java @@ -12,7 +12,7 @@ import android.graphics.Paint; import android.text.TextPaint; import android.util.AttributeSet; 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.view.drag.DirectionDragButton; @@ -34,7 +34,7 @@ public class NumeralBasesButton extends DirectionDragButton { super.initDirectionTextPaint(basePaint, directionTextData, resources); 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)); } else { directionTextPaint.setColor(resources.getColor(R.color.cpp_default_text_color)); diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/view/TextHighlighter.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/view/TextHighlighter.java index be605976..47c1f342 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/view/TextHighlighter.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/view/TextHighlighter.java @@ -108,9 +108,9 @@ public class TextHighlighter implements TextProcessor|" + 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); } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/widget/CalculatorWidgetHelper.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/widget/CalculatorWidgetHelper.java index b38b27f3..517d9a36 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/widget/CalculatorWidgetHelper.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/widget/CalculatorWidgetHelper.java @@ -18,7 +18,7 @@ public class CalculatorWidgetHelper implements CalculatorEventListener { private final CalculatorEventHolder lastEvent = new CalculatorEventHolder(CalculatorUtils.createFirstEventDataId()); public CalculatorWidgetHelper() { - CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener(this); + Locator.getInstance().getCalculator().addCalculatorEventListener(this); } @Override @@ -31,7 +31,7 @@ public class CalculatorWidgetHelper implements CalculatorEventListener { final CalculatorEditorChangeEventData editorChangeData = (CalculatorEditorChangeEventData) data; final CalculatorEditorViewState newEditorState = editorChangeData.getNewValue(); - CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage(TAG, "Editor state changed: " + newEditorState.getText()); + Locator.getInstance().getNotifier().showDebugMessage(TAG, "Editor state changed: " + newEditorState.getText()); ExternalCalculatorHelper.onEditorStateChanged(CalculatorApplication.getInstance(), calculatorEventData, newEditorState); break; @@ -40,7 +40,7 @@ public class CalculatorWidgetHelper implements CalculatorEventListener { final CalculatorDisplayChangeEventData displayChangeData = (CalculatorDisplayChangeEventData) data; final CalculatorDisplayViewState newDisplayState = displayChangeData.getNewValue(); - CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage(TAG, "Display state changed: " + newDisplayState.getText()); + Locator.getInstance().getNotifier().showDebugMessage(TAG, "Display state changed: " + newDisplayState.getText()); ExternalCalculatorHelper.onDisplayStateChanged(CalculatorApplication.getInstance(), calculatorEventData, newDisplayState); break; diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/widget/CalculatorWidgetIntentHandler.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/widget/CalculatorWidgetIntentHandler.java index 1f166e4f..0d58cbc1 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/widget/CalculatorWidgetIntentHandler.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/widget/CalculatorWidgetIntentHandler.java @@ -3,7 +3,7 @@ package org.solovyev.android.calculator.widget; import android.content.Context; import android.content.Intent; 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.ExternalCalculatorStateUpdater; @@ -30,7 +30,7 @@ public class CalculatorWidgetIntentHandler extends DefaultExternalCalculatorInte button.onClick(context); } } 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()); } } diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/widget/WidgetButton.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/widget/WidgetButton.java index 1ec7108d..3d165348 100644 --- a/calculatorpp/src/main/java/org/solovyev/android/calculator/widget/WidgetButton.java +++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/widget/WidgetButton.java @@ -3,7 +3,7 @@ package org.solovyev.android.calculator.widget; import android.content.Context; import org.jetbrains.annotations.NotNull; 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.R; @@ -79,8 +79,8 @@ public enum WidgetButton { } public void onClick(@NotNull Context context) { - CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage("Calculator++ Widget", "Button pressed: " + text); - CalculatorLocatorImpl.getInstance().getKeyboard().buttonPressed(text); + Locator.getInstance().getNotifier().showDebugMessage("Calculator++ Widget", "Button pressed: " + text); + Locator.getInstance().getKeyboard().buttonPressed(text); } @Nullable diff --git a/calculatorpp/src/test/java/org/solovyev/android/calculator/AndroidCalculatorEditorViewTest.java b/calculatorpp/src/test/java/org/solovyev/android/calculator/AndroidCalculatorEditorViewTest.java index 3cdb278c..e3d8129b 100644 --- a/calculatorpp/src/test/java/org/solovyev/android/calculator/AndroidCalculatorEditorViewTest.java +++ b/calculatorpp/src/test/java/org/solovyev/android/calculator/AndroidCalculatorEditorViewTest.java @@ -61,7 +61,7 @@ public class AndroidCalculatorEditorViewTest { for ( int j = 0; j < count; j++ ) { try { int textLength = random.nextInt(maxTextLength); - CalculatorLocatorImpl.getInstance().getEditor().insert(StringUtils.generateRandomString(textLength), textLength); + Locator.getInstance().getEditor().insert(StringUtils.generateRandomString(textLength), textLength); } catch (Throwable e) { System.out.println(e); error.set(true); diff --git a/calculatorpp/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java b/calculatorpp/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java index 71229446..ac5e2fc1 100644 --- a/calculatorpp/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java +++ b/calculatorpp/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java @@ -15,8 +15,8 @@ import org.solovyev.android.calculator.history.CalculatorHistory; public class CalculatorTestUtils { public static void staticSetUp(@Nullable Context context) throws Exception { - CalculatorLocatorImpl.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class)); - CalculatorLocatorImpl.getInstance().getEngine().init(); + Locator.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class)); + Locator.getInstance().getEngine().init(); if ( context != null ) { initViews(context); @@ -26,11 +26,11 @@ public class CalculatorTestUtils { public static void initViews(@NotNull Context context) { final AndroidCalculatorEditorView editor = new AndroidCalculatorEditorView(context); editor.init(context); - CalculatorLocatorImpl.getInstance().getEditor().setView(editor); + Locator.getInstance().getEditor().setView(editor); final AndroidCalculatorDisplayView display = new AndroidCalculatorDisplayView(context); display.init(context); - CalculatorLocatorImpl.getInstance().getDisplay().setView(display); + Locator.getInstance().getDisplay().setView(display); } public static void staticSetUp() throws Exception { diff --git a/calculatorpp/src/test/java/org/solovyev/android/calculator/TextHighlighterTest.java b/calculatorpp/src/test/java/org/solovyev/android/calculator/TextHighlighterTest.java index db49a160..a252357d 100644 --- a/calculatorpp/src/test/java/org/solovyev/android/calculator/TextHighlighterTest.java +++ b/calculatorpp/src/test/java/org/solovyev/android/calculator/TextHighlighterTest.java @@ -98,7 +98,7 @@ public class TextHighlighterTest { Assert.assertEquals("0x:FF33233FFE", textHighlighter.process("0x:FF33233FFE").toString()); Assert.assertEquals("0x: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 { me.setNumeralBase(NumeralBase.hex); Assert.assertEquals("E", textHighlighter.process("E").toString());