CalculatorLocatorImpl -> Locator
This commit is contained in:
@@ -90,7 +90,7 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
|
||||
@Override
|
||||
public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) {
|
||||
if (dragDirection == DragDirection.down) {
|
||||
CalculatorLocatorImpl.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_operators, null);
|
||||
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_operators, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -178,7 +178,7 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
|
||||
|
||||
@NotNull
|
||||
private Calculator getCalculator() {
|
||||
return CalculatorLocatorImpl.getInstance().getCalculator();
|
||||
return Locator.getInstance().getCalculator();
|
||||
}
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
|
||||
|
||||
@NotNull
|
||||
private CalculatorKeyboard getKeyboard() {
|
||||
return CalculatorLocatorImpl.getInstance().getKeyboard();
|
||||
return Locator.getInstance().getKeyboard();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@@ -65,7 +65,7 @@ public class AndroidCalculator implements Calculator, CalculatorEventListener, S
|
||||
|
||||
public void setDisplay(@NotNull Context context, @NotNull AndroidCalculatorDisplayView displayView) {
|
||||
displayView.init(context);
|
||||
CalculatorLocatorImpl.getInstance().getDisplay().setView(displayView);
|
||||
Locator.getInstance().getDisplay().setView(displayView);
|
||||
}
|
||||
|
||||
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) {
|
||||
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.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ContextMenu;
|
||||
import android.widget.EditText;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -128,7 +127,7 @@ public class AndroidCalculatorEditorView extends EditText implements SharedPrefe
|
||||
|
||||
public void setHighlightText(boolean highlightText) {
|
||||
this.highlightText = highlightText;
|
||||
CalculatorLocatorImpl.getInstance().getEditor().updateViewState();
|
||||
Locator.getInstance().getEditor().updateViewState();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -186,7 +185,7 @@ public class AndroidCalculatorEditorView extends EditText implements SharedPrefe
|
||||
if (!viewStateChange) {
|
||||
// external text change => 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
@@ -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"})
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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) {
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ public enum CalculatorDisplayMenuItem implements LabeledMenuItem<CalculatorDispl
|
||||
copy(R.string.c_copy) {
|
||||
@Override
|
||||
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
|
||||
public void onClick(View v) {
|
||||
if (v instanceof CalculatorDisplayView) {
|
||||
final CalculatorDisplay cd = CalculatorLocatorImpl.getInstance().getDisplay();
|
||||
final CalculatorDisplay cd = Locator.getInstance().getDisplay();
|
||||
|
||||
final CalculatorDisplayViewState displayViewState = cd.getViewState();
|
||||
|
||||
|
@@ -38,7 +38,7 @@ public class CalculatorEditorFragment extends SherlockFragment {
|
||||
|
||||
fragmentHelper.onViewCreated(this, view);
|
||||
|
||||
((AndroidCalculator) CalculatorLocatorImpl.getInstance().getCalculator()).setEditor(getActivity());
|
||||
((AndroidCalculator) Locator.getInstance().getCalculator()).setEditor(getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -63,7 +63,7 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
|
||||
|
||||
if (listenersOnCreate) {
|
||||
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) {
|
||||
if (!listenersOnCreate) {
|
||||
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) {
|
||||
if (!listenersOnCreate) {
|
||||
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 ( 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
|
||||
private static AndroidCalculatorDisplayView getCalculatorDisplayView() {
|
||||
return (AndroidCalculatorDisplayView) CalculatorLocatorImpl.getInstance().getDisplay().getView();
|
||||
return (AndroidCalculatorDisplayView) Locator.getInstance().getDisplay().getView();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Calculator getCalculator() {
|
||||
return CalculatorLocatorImpl.getInstance().getCalculator();
|
||||
return Locator.getInstance().getCalculator();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
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 (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<CalculatorDisplayViewState> {
|
||||
final Generic result = data.getResult();
|
||||
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
||||
|
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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<CalculatorHistoryState>() {
|
||||
if ( CollectionsUtils.contains(historyState, Locator.getInstance().getHistory().getSavedHistory(), new Equalizer<CalculatorHistoryState>() {
|
||||
@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);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -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<CalculatorHistoryState> getHistoryItems() {
|
||||
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
|
||||
protected void clearHistory() {
|
||||
CalculatorLocatorImpl.getInstance().getHistory().clear();
|
||||
Locator.getInstance().getHistory().clear();
|
||||
getAdapter().clear();
|
||||
}
|
||||
}
|
||||
|
@@ -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<CalculatorHistoryState> getHistoryItems() {
|
||||
return new ArrayList<CalculatorHistoryState>(CalculatorLocatorImpl.getInstance().getHistory().getSavedHistory());
|
||||
return new ArrayList<CalculatorHistoryState>(Locator.getInstance().getHistory().getSavedHistory());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearHistory() {
|
||||
CalculatorLocatorImpl.getInstance().getHistory().clearSavedHistory();
|
||||
Locator.getInstance().getHistory().clearSavedHistory();
|
||||
getAdapter().clear();
|
||||
}
|
||||
}
|
||||
|
@@ -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<HistoryItemMenuData>
|
||||
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<HistoryItemMenuData>
|
||||
@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();
|
||||
|
@@ -72,7 +72,7 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment<
|
||||
protected List<LabeledMenuItem<Function>> getMenuItemsOnLongClick(@NotNull Function item) {
|
||||
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())) ) {
|
||||
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<Function> getMathEntities() {
|
||||
return new ArrayList<Function>(CalculatorLocatorImpl.getInstance().getEngine().getFunctionsRegistry().getEntities());
|
||||
return new ArrayList<Function>(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);
|
||||
|
@@ -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<Operator> getMathEntities() {
|
||||
final List<Operator> result = new ArrayList<Operator>();
|
||||
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
||||
|
@@ -75,7 +75,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
|
||||
@NotNull
|
||||
@Override
|
||||
protected MathEntityDescriptionGetter getDescriptionGetter() {
|
||||
return new MathEntityDescriptionGetterImpl(CalculatorLocatorImpl.getInstance().getEngine().getVarsRegistry());
|
||||
return new MathEntityDescriptionGetterImpl(Locator.getInstance().getEngine().getVarsRegistry());
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
@@ -100,7 +100,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
|
||||
@NotNull
|
||||
@Override
|
||||
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>() {
|
||||
@Override
|
||||
@@ -114,7 +114,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
|
||||
|
||||
@Override
|
||||
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) {
|
||||
@@ -227,7 +227,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
|
||||
use(R.string.c_use) {
|
||||
@Override
|
||||
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();
|
||||
if (!StringUtils.isEmpty(text)) {
|
||||
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) {
|
||||
@Override
|
||||
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)) {
|
||||
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.Nullable;
|
||||
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.R;
|
||||
import org.solovyev.common.math.MathEntity;
|
||||
@@ -76,14 +76,14 @@ public class MathEntityRemover<T extends MathEntity> implements View.OnClickList
|
||||
@Nullable DialogInterface.OnClickListener callbackOnCancel,
|
||||
@NotNull Context context,
|
||||
@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,
|
||||
@Nullable DialogInterface.OnClickListener callbackOnCancel,
|
||||
@NotNull Context context,
|
||||
@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.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() {
|
||||
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<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 ) {
|
||||
// CREATE MODE
|
||||
|
@@ -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<T extends MathEntity> 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<T extends MathEntity> 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;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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));
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
|
@@ -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<String> fromUnits, @NotNull Unit<String> 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();
|
||||
|
@@ -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));
|
||||
|
@@ -108,9 +108,9 @@ public class TextHighlighter implements TextProcessor<TextHighlighter.Result, St
|
||||
|
||||
final AbstractNumberBuilder numberBuilder;
|
||||
if (!formatNumber) {
|
||||
numberBuilder = new LiteNumberBuilder(CalculatorLocatorImpl.getInstance().getEngine());
|
||||
numberBuilder = new LiteNumberBuilder(Locator.getInstance().getEngine());
|
||||
} else {
|
||||
numberBuilder = new NumberBuilder(CalculatorLocatorImpl.getInstance().getEngine());
|
||||
numberBuilder = new NumberBuilder(Locator.getInstance().getEngine());
|
||||
}
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
MathType.Result mathType = MathType.getType(text, i, numberBuilder.isHexMode());
|
||||
|
@@ -85,7 +85,7 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem
|
||||
@NotNull int[] 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
|
||||
@@ -155,7 +155,7 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem
|
||||
// inject cursor
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user