fixes + @NotNull -> @Nonnull

This commit is contained in:
Sergey Solovyev 2013-06-15 23:10:45 +04:00
parent e57ce8cf2c
commit 4658f42a8a
245 changed files with 2592 additions and 2652 deletions

View File

@ -2,4 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.solovyev.android.calculator.core" package="org.solovyev.android.calculator.core"
android:versionCode="1" android:versionCode="1"
android:versionName="1.0" /> android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="17" />
</manifest>

View File

@ -14,13 +14,13 @@ import android.support.v4.app.FragmentActivity;
import android.text.Html; import android.text.Html;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.TypedValue; import android.util.TypedValue;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.core.R; import org.solovyev.android.calculator.core.R;
import org.solovyev.android.calculator.text.TextProcessor; import org.solovyev.android.calculator.text.TextProcessor;
import org.solovyev.android.calculator.view.TextHighlighter; import org.solovyev.android.calculator.view.TextHighlighter;
import org.solovyev.android.view.AutoResizeTextView; import org.solovyev.android.view.AutoResizeTextView;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -39,7 +39,7 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
********************************************************************** **********************************************************************
*/ */
@NotNull @Nonnull
private final static TextProcessor<TextHighlighter.Result, String> textHighlighter = new TextHighlighter(Color.WHITE, false); private final static TextProcessor<TextHighlighter.Result, String> textHighlighter = new TextHighlighter(Color.WHITE, false);
/* /*
@ -50,18 +50,18 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
********************************************************************** **********************************************************************
*/ */
@NotNull @Nonnull
private volatile CalculatorDisplayViewState state = CalculatorDisplayViewStateImpl.newDefaultInstance(); private volatile CalculatorDisplayViewState state = CalculatorDisplayViewStateImpl.newDefaultInstance();
private volatile boolean viewStateChange = false; private volatile boolean viewStateChange = false;
@NotNull @Nonnull
private final Object lock = new Object(); private final Object lock = new Object();
@NotNull @Nonnull
private final Handler uiHandler = new Handler(); private final Handler uiHandler = new Handler();
@NotNull @Nonnull
private final ExecutorService bgExecutor = Executors.newSingleThreadExecutor(); private final ExecutorService bgExecutor = Executors.newSingleThreadExecutor();
private volatile boolean initialized = false; private volatile boolean initialized = false;
@ -97,7 +97,7 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
@Override @Override
public void setState(@NotNull final CalculatorDisplayViewState state) { public void setState(@Nonnull final CalculatorDisplayViewState state) {
uiHandler.post(new Runnable() { uiHandler.post(new Runnable() {
@Override @Override
@ -133,7 +133,7 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
}); });
} }
@NotNull @Nonnull
@Override @Override
public CalculatorDisplayViewState getState() { public CalculatorDisplayViewState getState() {
synchronized (lock) { synchronized (lock) {
@ -170,11 +170,11 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
resizeText(); resizeText();
} }
public synchronized void init(@NotNull Context context) { public synchronized void init(@Nonnull Context context) {
this.init(context, true); this.init(context, true);
} }
public synchronized void init(@NotNull Context context, boolean fromApp) { public synchronized void init(@Nonnull Context context, boolean fromApp) {
if (!initialized) { if (!initialized) {
if (fromApp) { if (fromApp) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);

View File

@ -18,13 +18,14 @@ import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.widget.EditText; import android.widget.EditText;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.text.TextProcessor; import org.solovyev.android.calculator.text.TextProcessor;
import org.solovyev.android.calculator.view.TextHighlighter; import org.solovyev.android.calculator.view.TextHighlighter;
import org.solovyev.android.prefs.BooleanPreference; import org.solovyev.android.prefs.BooleanPreference;
import org.solovyev.common.collections.Collections; import org.solovyev.common.collections.Collections;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/** /**
* User: serso * User: serso
* Date: 9/17/11 * Date: 9/17/11
@ -32,25 +33,26 @@ import org.solovyev.common.collections.Collections;
*/ */
public class AndroidCalculatorEditorView extends EditText implements SharedPreferences.OnSharedPreferenceChangeListener, CalculatorEditorView { public class AndroidCalculatorEditorView extends EditText implements SharedPreferences.OnSharedPreferenceChangeListener, CalculatorEditorView {
@NotNull @Nonnull
private static final BooleanPreference colorDisplay = BooleanPreference.of("org.solovyev.android.calculator.CalculatorModel_color_display", true); private static final BooleanPreference colorDisplay = BooleanPreference.of("org.solovyev.android.calculator.CalculatorModel_color_display", true);
private volatile boolean initialized = false; private volatile boolean initialized = false;
private boolean highlightText = true; private boolean highlightText = true;
@NotNull @Nonnull
private final static TextProcessor<TextHighlighter.Result, String> textHighlighter = new TextHighlighter(Color.WHITE, false); private final static TextProcessor<TextHighlighter.Result, String> textHighlighter = new TextHighlighter(Color.WHITE, false);
@NotNull @SuppressWarnings("UnusedDeclaration")
@Nonnull
private volatile CalculatorEditorViewState viewState = CalculatorEditorViewStateImpl.newDefaultInstance(); private volatile CalculatorEditorViewState viewState = CalculatorEditorViewStateImpl.newDefaultInstance();
private volatile boolean viewStateChange = false; private volatile boolean viewStateChange = false;
@Nullable @Nonnull
private final Object viewLock = new Object(); private final Object viewLock = new Object();
@NotNull @Nonnull
private final Handler uiHandler = new Handler(); private final Handler uiHandler = new Handler();
public AndroidCalculatorEditorView(Context context) { public AndroidCalculatorEditorView(Context context) {
@ -97,7 +99,7 @@ public class AndroidCalculatorEditorView extends EditText implements SharedPrefe
} }
@Nullable @Nullable
private CharSequence prepareText(@NotNull String text, boolean highlightText) { private CharSequence prepareText(@Nonnull String text, boolean highlightText) {
CharSequence result; CharSequence result;
if (highlightText) { if (highlightText) {
@ -137,7 +139,7 @@ public class AndroidCalculatorEditorView extends EditText implements SharedPrefe
} }
} }
public synchronized void init(@NotNull Context context) { public synchronized void init(@Nonnull Context context) {
if (!initialized) { if (!initialized) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
@ -152,57 +154,51 @@ public class AndroidCalculatorEditorView extends EditText implements SharedPrefe
} }
@Override @Override
public void setState(@NotNull final CalculatorEditorViewState viewState) { public void setState(@Nonnull final CalculatorEditorViewState viewState) {
if (viewLock != null) { synchronized (viewLock) {
synchronized (viewLock) {
final CharSequence text = prepareText(viewState.getText(), highlightText); final CharSequence text = prepareText(viewState.getText(), highlightText);
uiHandler.post(new Runnable() { uiHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
final AndroidCalculatorEditorView editorView = AndroidCalculatorEditorView.this; final AndroidCalculatorEditorView editorView = AndroidCalculatorEditorView.this;
synchronized (viewLock) { synchronized (viewLock) {
try { try {
editorView.viewStateChange = true; editorView.viewStateChange = true;
editorView.viewState = viewState; editorView.viewState = viewState;
editorView.setText(text, BufferType.EDITABLE); editorView.setText(text, BufferType.EDITABLE);
final int selection = CalculatorEditorImpl.correctSelection(viewState.getSelection(), editorView.getText()); final int selection = CalculatorEditorImpl.correctSelection(viewState.getSelection(), editorView.getText());
editorView.setSelection(selection); editorView.setSelection(selection);
} finally { } finally {
editorView.viewStateChange = false; editorView.viewStateChange = false;
}
} }
} }
}); }
} });
} }
} }
@Override @Override
protected void onSelectionChanged(int selStart, int selEnd) { protected void onSelectionChanged(int selStart, int selEnd) {
if (viewLock != null) { synchronized (viewLock) {
synchronized (viewLock) { if (!viewStateChange) {
if (!viewStateChange) { // external text change => need to notify editor
// external text change => need to notify editor super.onSelectionChanged(selStart, selEnd);
super.onSelectionChanged(selStart, selEnd);
if (selStart == selEnd) { if (selStart == selEnd) {
// only if cursor moving, if selection do nothing // only if cursor moving, if selection do nothing
Locator.getInstance().getEditor().setSelection(selStart); Locator.getInstance().getEditor().setSelection(selStart);
}
} }
} }
} }
} }
public void handleTextChange(Editable s) { public void handleTextChange(Editable s) {
if (viewLock != null) { synchronized (viewLock) {
synchronized (viewLock) { if (!viewStateChange) {
if (!viewStateChange) { // external text change => need to notify editor
// external text change => need to notify editor Locator.getInstance().getEditor().setText(String.valueOf(s));
Locator.getInstance().getEditor().setText(String.valueOf(s));
}
} }
} }
} }

View File

@ -1,8 +1,8 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.content.Context; import android.content.Context;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.core.R; import org.solovyev.android.calculator.core.R;
import java.util.HashMap; import java.util.HashMap;
@ -61,42 +61,42 @@ public enum CalculatorButton {
private final int buttonId; private final int buttonId;
@NotNull @Nonnull
private final String onClickText; private final String onClickText;
@Nullable @Nullable
private final String onLongClickText; private final String onLongClickText;
@NotNull @Nonnull
private static Map<Integer, CalculatorButton> buttonsByIds = new HashMap<Integer, CalculatorButton>(); private static Map<Integer, CalculatorButton> buttonsByIds = new HashMap<Integer, CalculatorButton>();
CalculatorButton(int buttonId, @NotNull CalculatorSpecialButton onClickButton, @Nullable CalculatorSpecialButton onLongClickButton) { CalculatorButton(int buttonId, @Nonnull CalculatorSpecialButton onClickButton, @Nullable CalculatorSpecialButton onLongClickButton) {
this(buttonId, onClickButton.getActionCode(), onLongClickButton == null ? null : onLongClickButton.getActionCode()); this(buttonId, onClickButton.getActionCode(), onLongClickButton == null ? null : onLongClickButton.getActionCode());
} }
CalculatorButton(int buttonId, @NotNull CalculatorSpecialButton onClickButton) { CalculatorButton(int buttonId, @Nonnull CalculatorSpecialButton onClickButton) {
this(buttonId, onClickButton, null); this(buttonId, onClickButton, null);
} }
CalculatorButton(int buttonId, @NotNull String onClickText, @Nullable String onLongClickText) { CalculatorButton(int buttonId, @Nonnull String onClickText, @Nullable String onLongClickText) {
this.buttonId = buttonId; this.buttonId = buttonId;
this.onClickText = onClickText; this.onClickText = onClickText;
this.onLongClickText = onLongClickText; this.onLongClickText = onLongClickText;
} }
CalculatorButton(int buttonId, @NotNull String onClickText) { CalculatorButton(int buttonId, @Nonnull String onClickText) {
this(buttonId, onClickText, null); this(buttonId, onClickText, null);
} }
public void onLongClick(@NotNull Context context) { public void onLongClick(@Nonnull Context context) {
Locator.getInstance().getNotifier().showDebugMessage("Calculator++ Widget", "Button pressed: " + onLongClickText); Locator.getInstance().getNotifier().showDebugMessage("Calculator++ Widget", "Button pressed: " + onLongClickText);
if (onLongClickText != null) { if (onLongClickText != null) {
Locator.getInstance().getKeyboard().buttonPressed(onLongClickText); Locator.getInstance().getKeyboard().buttonPressed(onLongClickText);
} }
} }
public void onClick(@NotNull Context context) { public void onClick(@Nonnull Context context) {
Locator.getInstance().getNotifier().showDebugMessage("Calculator++ Widget", "Button pressed: " + onClickText); Locator.getInstance().getNotifier().showDebugMessage("Calculator++ Widget", "Button pressed: " + onClickText);
Locator.getInstance().getKeyboard().buttonPressed(onClickText); Locator.getInstance().getKeyboard().buttonPressed(onClickText);
} }

View File

@ -13,8 +13,8 @@ import android.widget.Button;
import android.widget.RemoteViews; import android.widget.RemoteViews;
import jscl.AngleUnit; import jscl.AngleUnit;
import jscl.NumeralBase; import jscl.NumeralBase;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.Views; import org.solovyev.android.Views;
import org.solovyev.android.calculator.core.R; import org.solovyev.android.calculator.core.R;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
@ -36,36 +36,36 @@ public final class CalculatorButtons {
} }
public static void processButtons(@NotNull CalculatorPreferences.Gui.Theme theme, public static void processButtons(@Nonnull CalculatorPreferences.Gui.Theme theme,
@NotNull CalculatorPreferences.Gui.Layout layout, @Nonnull CalculatorPreferences.Gui.Layout layout,
@NotNull View root) { @Nonnull View root) {
if (layout == CalculatorPreferences.Gui.Layout.main_calculator_mobile) { if (layout == CalculatorPreferences.Gui.Layout.main_calculator_mobile) {
final float textSize = root.getContext().getResources().getDimension(R.dimen.cpp_keyboard_button_text_size_mobile); final float textSize = root.getContext().getResources().getDimension(R.dimen.cpp_keyboard_button_text_size_mobile);
Views.processViewsOfType(root, DragButton.class, new Views.ViewProcessor<DragButton>() { Views.processViewsOfType(root, DragButton.class, new Views.ViewProcessor<DragButton>() {
@Override @Override
public void process(@NotNull DragButton button) { public void process(@Nonnull DragButton button) {
button.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize); button.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
} }
}); });
} }
} }
static void initMultiplicationButton(@NotNull View root) { static void initMultiplicationButton(@Nonnull View root) {
final View multiplicationButton = root.findViewById(R.id.cpp_button_multiplication); final View multiplicationButton = root.findViewById(R.id.cpp_button_multiplication);
if (multiplicationButton instanceof Button) { if (multiplicationButton instanceof Button) {
((Button) multiplicationButton).setText(Locator.getInstance().getEngine().getMultiplicationSign()); ((Button) multiplicationButton).setText(Locator.getInstance().getEngine().getMultiplicationSign());
} }
} }
public static void initMultiplicationButton(@NotNull RemoteViews views) { public static void initMultiplicationButton(@Nonnull RemoteViews views) {
views.setTextViewText(R.id.cpp_button_multiplication, Locator.getInstance().getEngine().getMultiplicationSign()); views.setTextViewText(R.id.cpp_button_multiplication, Locator.getInstance().getEngine().getMultiplicationSign());
} }
public static void toggleEqualsButton(@Nullable SharedPreferences preferences, public static void toggleEqualsButton(@Nullable SharedPreferences preferences,
@NotNull Activity activity) { @Nonnull Activity activity) {
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences; preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences;
final boolean large = Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, activity.getResources().getConfiguration()) && final boolean large = Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, activity.getResources().getConfiguration()) &&
@ -97,7 +97,7 @@ public final class CalculatorButtons {
static class RoundBracketsDragProcessor implements SimpleOnDragListener.DragProcessor { static class RoundBracketsDragProcessor implements SimpleOnDragListener.DragProcessor {
@Override @Override
public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) { public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull Point2d startPoint2d, @Nonnull MotionEvent motionEvent) {
final boolean result; final boolean result;
if (dragDirection == DragDirection.left) { if (dragDirection == DragDirection.left) {
@ -111,25 +111,25 @@ public final class CalculatorButtons {
} }
} }
@NotNull @Nonnull
private static CalculatorKeyboard getKeyboard() { private static CalculatorKeyboard getKeyboard() {
return Locator.getInstance().getKeyboard(); return Locator.getInstance().getKeyboard();
} }
static class VarsDragProcessor implements SimpleOnDragListener.DragProcessor { static class VarsDragProcessor implements SimpleOnDragListener.DragProcessor {
@NotNull @Nonnull
private Context context; private Context context;
VarsDragProcessor(@NotNull Context context) { VarsDragProcessor(@Nonnull Context context) {
this.context = context; this.context = context;
} }
@Override @Override
public boolean processDragEvent(@NotNull DragDirection dragDirection, public boolean processDragEvent(@Nonnull DragDirection dragDirection,
@NotNull DragButton dragButton, @Nonnull DragButton dragButton,
@NotNull Point2d startPoint2d, @Nonnull Point2d startPoint2d,
@NotNull MotionEvent motionEvent) { @Nonnull MotionEvent motionEvent) {
boolean result = false; boolean result = false;
if (dragDirection == DragDirection.up) { if (dragDirection == DragDirection.up) {
@ -146,22 +146,22 @@ public final class CalculatorButtons {
static class AngleUnitsChanger implements SimpleOnDragListener.DragProcessor { static class AngleUnitsChanger implements SimpleOnDragListener.DragProcessor {
@NotNull @Nonnull
private final DigitButtonDragProcessor processor; private final DigitButtonDragProcessor processor;
@NotNull @Nonnull
private final Context context; private final Context context;
AngleUnitsChanger(@NotNull Context context) { AngleUnitsChanger(@Nonnull Context context) {
this.context = context; this.context = context;
this.processor = new DigitButtonDragProcessor(Locator.getInstance().getKeyboard()); this.processor = new DigitButtonDragProcessor(Locator.getInstance().getKeyboard());
} }
@Override @Override
public boolean processDragEvent(@NotNull DragDirection dragDirection, public boolean processDragEvent(@Nonnull DragDirection dragDirection,
@NotNull DragButton dragButton, @Nonnull DragButton dragButton,
@NotNull Point2d startPoint2d, @Nonnull Point2d startPoint2d,
@NotNull MotionEvent motionEvent) { @Nonnull MotionEvent motionEvent) {
boolean result = false; boolean result = false;
if (dragButton instanceof AngleUnitsButton) { if (dragButton instanceof AngleUnitsButton) {
@ -195,18 +195,18 @@ public final class CalculatorButtons {
static class NumeralBasesChanger implements SimpleOnDragListener.DragProcessor { static class NumeralBasesChanger implements SimpleOnDragListener.DragProcessor {
@NotNull @Nonnull
private final Context context; private final Context context;
NumeralBasesChanger(@NotNull Context context) { NumeralBasesChanger(@Nonnull Context context) {
this.context = context; this.context = context;
} }
@Override @Override
public boolean processDragEvent(@NotNull DragDirection dragDirection, public boolean processDragEvent(@Nonnull DragDirection dragDirection,
@NotNull DragButton dragButton, @Nonnull DragButton dragButton,
@NotNull Point2d startPoint2d, @Nonnull Point2d startPoint2d,
@NotNull MotionEvent motionEvent) { @Nonnull MotionEvent motionEvent) {
boolean result = false; boolean result = false;
if (dragButton instanceof NumeralBasesButton) { if (dragButton instanceof NumeralBasesButton) {
@ -236,18 +236,18 @@ public final class CalculatorButtons {
static class FunctionsDragProcessor implements SimpleOnDragListener.DragProcessor { static class FunctionsDragProcessor implements SimpleOnDragListener.DragProcessor {
@NotNull @Nonnull
private Context context; private Context context;
FunctionsDragProcessor(@NotNull Context context) { FunctionsDragProcessor(@Nonnull Context context) {
this.context = context; this.context = context;
} }
@Override @Override
public boolean processDragEvent(@NotNull DragDirection dragDirection, public boolean processDragEvent(@Nonnull DragDirection dragDirection,
@NotNull DragButton dragButton, @Nonnull DragButton dragButton,
@NotNull Point2d startPoint2d, @Nonnull Point2d startPoint2d,
@NotNull MotionEvent motionEvent) { @Nonnull MotionEvent motionEvent) {
boolean result = false; boolean result = false;
if (dragDirection == DragDirection.up) { if (dragDirection == DragDirection.up) {

View File

@ -2,7 +2,7 @@ package org.solovyev.android.calculator;
import android.content.Context; import android.content.Context;
import jscl.math.Generic; import jscl.math.Generic;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.core.R; import org.solovyev.android.calculator.core.R;
import org.solovyev.android.calculator.jscl.JsclOperation; import org.solovyev.android.calculator.jscl.JsclOperation;
import org.solovyev.android.calculator.plot.CalculatorPlotter; import org.solovyev.android.calculator.plot.CalculatorPlotter;
@ -18,50 +18,50 @@ public enum CalculatorDisplayMenuItem implements LabeledMenuItem<CalculatorDispl
copy(R.string.c_copy) { copy(R.string.c_copy) {
@Override @Override
public void onClick(@NotNull CalculatorDisplayViewState data, @NotNull Context context) { public void onClick(@Nonnull CalculatorDisplayViewState data, @Nonnull Context context) {
Locator.getInstance().getKeyboard().copyButtonPressed(); Locator.getInstance().getKeyboard().copyButtonPressed();
} }
}, },
convert_to_bin(R.string.convert_to_bin) { convert_to_bin(R.string.convert_to_bin) {
@Override @Override
public void onClick(@NotNull CalculatorDisplayViewState data, @NotNull Context context) { public void onClick(@Nonnull CalculatorDisplayViewState data, @Nonnull Context context) {
ConversionMenuItem.convert_to_bin.onClick(data, context); ConversionMenuItem.convert_to_bin.onClick(data, context);
} }
@Override @Override
protected boolean isItemVisibleFor(@NotNull Generic generic, @NotNull JsclOperation operation) { protected boolean isItemVisibleFor(@Nonnull Generic generic, @Nonnull JsclOperation operation) {
return ConversionMenuItem.convert_to_bin.isItemVisibleFor(generic, operation); return ConversionMenuItem.convert_to_bin.isItemVisibleFor(generic, operation);
} }
}, },
convert_to_dec(R.string.convert_to_dec) { convert_to_dec(R.string.convert_to_dec) {
@Override @Override
public void onClick(@NotNull CalculatorDisplayViewState data, @NotNull Context context) { public void onClick(@Nonnull CalculatorDisplayViewState data, @Nonnull Context context) {
ConversionMenuItem.convert_to_dec.onClick(data, context); ConversionMenuItem.convert_to_dec.onClick(data, context);
} }
@Override @Override
protected boolean isItemVisibleFor(@NotNull Generic generic, @NotNull JsclOperation operation) { protected boolean isItemVisibleFor(@Nonnull Generic generic, @Nonnull JsclOperation operation) {
return ConversionMenuItem.convert_to_dec.isItemVisibleFor(generic, operation); return ConversionMenuItem.convert_to_dec.isItemVisibleFor(generic, operation);
} }
}, },
convert_to_hex(R.string.convert_to_hex) { convert_to_hex(R.string.convert_to_hex) {
@Override @Override
public void onClick(@NotNull CalculatorDisplayViewState data, @NotNull Context context) { public void onClick(@Nonnull CalculatorDisplayViewState data, @Nonnull Context context) {
ConversionMenuItem.convert_to_hex.onClick(data, context); ConversionMenuItem.convert_to_hex.onClick(data, context);
} }
@Override @Override
protected boolean isItemVisibleFor(@NotNull Generic generic, @NotNull JsclOperation operation) { protected boolean isItemVisibleFor(@Nonnull Generic generic, @Nonnull JsclOperation operation) {
return ConversionMenuItem.convert_to_hex.isItemVisibleFor(generic, operation); return ConversionMenuItem.convert_to_hex.isItemVisibleFor(generic, operation);
} }
}, },
convert(R.string.c_convert) { convert(R.string.c_convert) {
@Override @Override
public void onClick(@NotNull CalculatorDisplayViewState data, @NotNull Context context) { public void onClick(@Nonnull CalculatorDisplayViewState data, @Nonnull Context context) {
final Generic result = data.getResult(); final Generic result = data.getResult();
if (result != null) { if (result != null) {
new NumeralBaseConverterDialog(result.toString()).show(context); new NumeralBaseConverterDialog(result.toString()).show(context);
@ -69,14 +69,14 @@ public enum CalculatorDisplayMenuItem implements LabeledMenuItem<CalculatorDispl
} }
@Override @Override
protected boolean isItemVisibleFor(@NotNull Generic generic, @NotNull JsclOperation operation) { protected boolean isItemVisibleFor(@Nonnull Generic generic, @Nonnull JsclOperation operation) {
return operation == JsclOperation.numeric && generic.getConstants().isEmpty(); return operation == JsclOperation.numeric && generic.getConstants().isEmpty();
} }
}, },
plot(R.string.c_plot) { plot(R.string.c_plot) {
@Override @Override
public void onClick(@NotNull CalculatorDisplayViewState data, @NotNull Context context) { public void onClick(@Nonnull CalculatorDisplayViewState data, @Nonnull Context context) {
final Generic expression = data.getResult(); final Generic expression = data.getResult();
assert expression != null; assert expression != null;
@ -85,7 +85,7 @@ public enum CalculatorDisplayMenuItem implements LabeledMenuItem<CalculatorDispl
} }
@Override @Override
protected boolean isItemVisibleFor(@NotNull Generic generic, @NotNull JsclOperation operation) { protected boolean isItemVisibleFor(@Nonnull Generic generic, @Nonnull JsclOperation operation) {
return Locator.getInstance().getPlotter().isPlotPossibleFor(generic); return Locator.getInstance().getPlotter().isPlotPossibleFor(generic);
} }
@ -97,18 +97,18 @@ public enum CalculatorDisplayMenuItem implements LabeledMenuItem<CalculatorDispl
this.captionId = captionId; this.captionId = captionId;
} }
public final boolean isItemVisible(@NotNull CalculatorDisplayViewState displayViewState) { public final boolean isItemVisible(@Nonnull CalculatorDisplayViewState displayViewState) {
//noinspection ConstantConditions //noinspection ConstantConditions
return displayViewState.isValid() && displayViewState.getResult() != null && isItemVisibleFor(displayViewState.getResult(), displayViewState.getOperation()); return displayViewState.isValid() && displayViewState.getResult() != null && isItemVisibleFor(displayViewState.getResult(), displayViewState.getOperation());
} }
protected boolean isItemVisibleFor(@NotNull Generic generic, @NotNull JsclOperation operation) { protected boolean isItemVisibleFor(@Nonnull Generic generic, @Nonnull JsclOperation operation) {
return true; return true;
} }
@NotNull @Nonnull
@Override @Override
public String getCaption(@NotNull Context context) { public String getCaption(@Nonnull Context context) {
return context.getString(captionId); return context.getString(captionId);
} }
} }

View File

@ -2,7 +2,7 @@ package org.solovyev.android.calculator;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.view.View; import android.view.View;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.menu.ContextMenuBuilder; import org.solovyev.android.menu.ContextMenuBuilder;
import org.solovyev.android.menu.ListContextMenu; import org.solovyev.android.menu.ListContextMenu;
@ -16,10 +16,10 @@ import java.util.List;
*/ */
public class CalculatorDisplayOnClickListener implements View.OnClickListener { public class CalculatorDisplayOnClickListener implements View.OnClickListener {
@NotNull @Nonnull
private final FragmentActivity activity; private final FragmentActivity activity;
public CalculatorDisplayOnClickListener(@NotNull FragmentActivity activity) { public CalculatorDisplayOnClickListener(@Nonnull FragmentActivity activity) {
this.activity = activity; this.activity = activity;
} }

View File

@ -3,7 +3,7 @@ package org.solovyev.android.calculator;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import jscl.AngleUnit; import jscl.AngleUnit;
import jscl.NumeralBase; import jscl.NumeralBase;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.prefs.*; import org.solovyev.android.prefs.*;
@ -59,13 +59,13 @@ public final class CalculatorPreferences {
public static final Preference<Boolean> autoOrientation = BooleanPreference.of("autoOrientation", true); public static final Preference<Boolean> autoOrientation = BooleanPreference.of("autoOrientation", true);
public static final Preference<Boolean> hideNumeralBaseDigits = BooleanPreference.of("hideNumeralBaseDigits", true); public static final Preference<Boolean> hideNumeralBaseDigits = BooleanPreference.of("hideNumeralBaseDigits", true);
@NotNull @Nonnull
public static Theme getTheme(@NotNull SharedPreferences preferences) { public static Theme getTheme(@Nonnull SharedPreferences preferences) {
return theme.getPreferenceNoError(preferences); return theme.getPreferenceNoError(preferences);
} }
@NotNull @Nonnull
public static Layout getLayout(@NotNull SharedPreferences preferences) { public static Layout getLayout(@Nonnull SharedPreferences preferences) {
return layout.getPreferenceNoError(preferences); return layout.getPreferenceNoError(preferences);
} }
@ -78,23 +78,23 @@ public final class CalculatorPreferences {
metro_purple_theme(ThemeType.metro, R.style.cpp_metro_purple_theme), metro_purple_theme(ThemeType.metro, R.style.cpp_metro_purple_theme),
metro_green_theme(ThemeType.metro, R.style.cpp_metro_green_theme); metro_green_theme(ThemeType.metro, R.style.cpp_metro_green_theme);
@NotNull @Nonnull
private final ThemeType themeType; private final ThemeType themeType;
@NotNull @Nonnull
private final Integer themeId; private final Integer themeId;
Theme(@NotNull ThemeType themeType, @NotNull Integer themeId) { Theme(@Nonnull ThemeType themeType, @Nonnull Integer themeId) {
this.themeType = themeType; this.themeType = themeType;
this.themeId = themeId; this.themeId = themeId;
} }
@NotNull @Nonnull
public ThemeType getThemeType() { public ThemeType getThemeType() {
return themeType; return themeType;
} }
@NotNull @Nonnull
public Integer getThemeId() { public Integer getThemeId() {
return themeId; return themeId;
} }
@ -136,7 +136,7 @@ public final class CalculatorPreferences {
} }
static void setDefaultValues(@NotNull SharedPreferences preferences) { static void setDefaultValues(@Nonnull SharedPreferences preferences) {
if (!AndroidCalculatorEngine.Preferences.groupingSeparator.isSet(preferences)) { if (!AndroidCalculatorEngine.Preferences.groupingSeparator.isSet(preferences)) {
final Locale locale = Locale.getDefault(); final Locale locale = Locale.getDefault();
@ -206,7 +206,7 @@ public final class CalculatorPreferences {
} }
private static void applyDefaultPreference(@NotNull SharedPreferences preferences, @NotNull Preference<?> preference) { private static void applyDefaultPreference(@Nonnull SharedPreferences preferences, @Nonnull Preference<?> preference) {
preference.tryPutDefault(preferences); preference.tryPutDefault(preferences);
} }

View File

@ -3,7 +3,7 @@ package org.solovyev.android.calculator;
import android.content.Context; import android.content.Context;
import jscl.NumeralBase; import jscl.NumeralBase;
import jscl.math.Generic; import jscl.math.Generic;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.jscl.JsclOperation; import org.solovyev.android.calculator.jscl.JsclOperation;
import org.solovyev.android.menu.AMenuItem; import org.solovyev.android.menu.AMenuItem;
@ -18,14 +18,14 @@ enum ConversionMenuItem implements AMenuItem<CalculatorDisplayViewState> {
convert_to_dec(NumeralBase.dec), convert_to_dec(NumeralBase.dec),
convert_to_hex(NumeralBase.hex); convert_to_hex(NumeralBase.hex);
@NotNull @Nonnull
private final NumeralBase toNumeralBase; private final NumeralBase toNumeralBase;
ConversionMenuItem(@NotNull NumeralBase toNumeralBase) { ConversionMenuItem(@Nonnull NumeralBase toNumeralBase) {
this.toNumeralBase = toNumeralBase; this.toNumeralBase = toNumeralBase;
} }
protected boolean isItemVisibleFor(@NotNull Generic generic, @NotNull JsclOperation operation) { protected boolean isItemVisibleFor(@Nonnull Generic generic, @Nonnull JsclOperation operation) {
boolean result = false; boolean result = false;
if (operation == JsclOperation.numeric) { if (operation == JsclOperation.numeric) {
@ -42,7 +42,7 @@ enum ConversionMenuItem implements AMenuItem<CalculatorDisplayViewState> {
} }
@Override @Override
public void onClick(@NotNull CalculatorDisplayViewState data, @NotNull Context context) { public void onClick(@Nonnull CalculatorDisplayViewState data, @Nonnull Context context) {
final Generic result = data.getResult(); final Generic result = data.getResult();
if (result != null) { if (result != null) {

View File

@ -6,7 +6,7 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.view.MotionEvent; import android.view.MotionEvent;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.view.drag.DirectionDragButton; import org.solovyev.android.view.drag.DirectionDragButton;
import org.solovyev.android.view.drag.DragButton; import org.solovyev.android.view.drag.DragButton;
import org.solovyev.android.view.drag.DragDirection; import org.solovyev.android.view.drag.DragDirection;
@ -20,15 +20,15 @@ import org.solovyev.common.math.Point2d;
*/ */
public class DigitButtonDragProcessor implements SimpleOnDragListener.DragProcessor { public class DigitButtonDragProcessor implements SimpleOnDragListener.DragProcessor {
@NotNull @Nonnull
private CalculatorKeyboard calculatorKeyboard; private CalculatorKeyboard calculatorKeyboard;
public DigitButtonDragProcessor(@NotNull CalculatorKeyboard calculatorKeyboard) { public DigitButtonDragProcessor(@Nonnull CalculatorKeyboard calculatorKeyboard) {
this.calculatorKeyboard = calculatorKeyboard; this.calculatorKeyboard = calculatorKeyboard;
} }
@Override @Override
public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) { public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull Point2d startPoint2d, @Nonnull MotionEvent motionEvent) {
assert dragButton instanceof DirectionDragButton; assert dragButton instanceof DirectionDragButton;
calculatorKeyboard.buttonPressed(((DirectionDragButton) dragButton).getText(dragDirection)); calculatorKeyboard.buttonPressed(((DirectionDragButton) dragButton).getText(dragDirection));
return true; return true;

View File

@ -2,8 +2,8 @@ package org.solovyev.android.calculator;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.common.msg.Message; import org.solovyev.common.msg.Message;
import org.solovyev.common.msg.MessageType; import org.solovyev.common.msg.MessageType;
@ -16,7 +16,7 @@ public class FixableMessage implements Parcelable {
public static final Creator<FixableMessage> CREATOR = new Creator<FixableMessage>() { public static final Creator<FixableMessage> CREATOR = new Creator<FixableMessage>() {
@Override @Override
public FixableMessage createFromParcel(@NotNull Parcel in) { public FixableMessage createFromParcel(@Nonnull Parcel in) {
return FixableMessage.fromParcel(in); return FixableMessage.fromParcel(in);
} }
@ -26,8 +26,8 @@ public class FixableMessage implements Parcelable {
} }
}; };
@NotNull @Nonnull
private static FixableMessage fromParcel(@NotNull Parcel in) { private static FixableMessage fromParcel(@Nonnull Parcel in) {
final String message = in.readString(); final String message = in.readString();
final MessageType messageType = (MessageType) in.readSerializable(); final MessageType messageType = (MessageType) in.readSerializable();
final FixableError fixableError = (FixableError) in.readSerializable(); final FixableError fixableError = (FixableError) in.readSerializable();
@ -35,16 +35,16 @@ public class FixableMessage implements Parcelable {
return new FixableMessage(message, messageType, fixableError); return new FixableMessage(message, messageType, fixableError);
} }
@NotNull @Nonnull
private final String message; private final String message;
@NotNull @Nonnull
private final MessageType messageType; private final MessageType messageType;
@Nullable @Nullable
private final FixableError fixableError; private final FixableError fixableError;
public FixableMessage(@NotNull Message message) { public FixableMessage(@Nonnull Message message) {
this.message = message.getLocalizedMessage(); this.message = message.getLocalizedMessage();
int messageLevel = message.getMessageLevel().getMessageLevel(); int messageLevel = message.getMessageLevel().getMessageLevel();
if (messageLevel < MessageType.info.getMessageLevel()) { if (messageLevel < MessageType.info.getMessageLevel()) {
@ -57,8 +57,8 @@ public class FixableMessage implements Parcelable {
this.fixableError = CalculatorFixableError.getErrorByMessageCode(message.getMessageCode()); this.fixableError = CalculatorFixableError.getErrorByMessageCode(message.getMessageCode());
} }
public FixableMessage(@NotNull String message, public FixableMessage(@Nonnull String message,
@NotNull MessageType messageType, @Nonnull MessageType messageType,
@Nullable FixableError fixableError) { @Nullable FixableError fixableError) {
this.message = message; this.message = message;
this.messageType = messageType; this.messageType = messageType;
@ -71,18 +71,18 @@ public class FixableMessage implements Parcelable {
} }
@Override @Override
public void writeToParcel(@NotNull Parcel out, int flags) { public void writeToParcel(@Nonnull Parcel out, int flags) {
out.writeString(message); out.writeString(message);
out.writeSerializable(messageType); out.writeSerializable(messageType);
out.writeSerializable(fixableError); out.writeSerializable(fixableError);
} }
@NotNull @Nonnull
public String getMessage() { public String getMessage() {
return message; return message;
} }
@NotNull @Nonnull
public MessageType getMessageType() { public MessageType getMessageType() {
return messageType; return messageType;
} }

View File

@ -14,7 +14,7 @@ import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.TextView; import android.widget.TextView;
import com.actionbarsherlock.app.SherlockActivity; import com.actionbarsherlock.app.SherlockActivity;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.core.R; import org.solovyev.android.calculator.core.R;
import org.solovyev.common.msg.Message; import org.solovyev.common.msg.Message;
import org.solovyev.common.text.Strings; import org.solovyev.common.text.Strings;
@ -32,7 +32,7 @@ public class FixableMessagesDialog extends SherlockActivity {
private static final String INPUT = "input"; private static final String INPUT = "input";
@NotNull @Nonnull
private Input input = new Input(Collections.<FixableMessage>emptyList(), false); private Input input = new Input(Collections.<FixableMessage>emptyList(), false);
public FixableMessagesDialog() { public FixableMessagesDialog() {
@ -70,7 +70,7 @@ public class FixableMessagesDialog extends SherlockActivity {
}); });
} }
private void parseIntent(@NotNull Intent intent) { private void parseIntent(@Nonnull Intent intent) {
final Input input = intent.getParcelableExtra(INPUT); final Input input = intent.getParcelableExtra(INPUT);
if (input != null) { if (input != null) {
this.input = input; this.input = input;
@ -113,7 +113,7 @@ public class FixableMessagesDialog extends SherlockActivity {
} }
@Override @Override
protected void onNewIntent(@NotNull Intent intent) { protected void onNewIntent(@Nonnull Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
parseIntent(intent); parseIntent(intent);
} }
@ -126,8 +126,8 @@ public class FixableMessagesDialog extends SherlockActivity {
********************************************************************** **********************************************************************
*/ */
public static void showDialogForMessages(@NotNull List<Message> messages, public static void showDialogForMessages(@Nonnull List<Message> messages,
@NotNull Context context, @Nonnull Context context,
boolean showCheckbox) { boolean showCheckbox) {
if (!messages.isEmpty()) { if (!messages.isEmpty()) {
final Intent intent = new Intent(context, FixableMessagesDialog.class); final Intent intent = new Intent(context, FixableMessagesDialog.class);
@ -139,8 +139,8 @@ public class FixableMessagesDialog extends SherlockActivity {
} }
} }
public static void showDialog(@NotNull List<FixableMessage> messages, public static void showDialog(@Nonnull List<FixableMessage> messages,
@NotNull Context context, @Nonnull Context context,
boolean showCheckbox) { boolean showCheckbox) {
if (!messages.isEmpty()) { if (!messages.isEmpty()) {
final Intent intent = new Intent(context, FixableMessagesDialog.class); final Intent intent = new Intent(context, FixableMessagesDialog.class);
@ -156,7 +156,7 @@ public class FixableMessagesDialog extends SherlockActivity {
public static final Creator<Input> CREATOR = new Creator<Input>() { public static final Creator<Input> CREATOR = new Creator<Input>() {
@Override @Override
public Input createFromParcel(@NotNull Parcel in) { public Input createFromParcel(@Nonnull Parcel in) {
return Input.fromParcel(in); return Input.fromParcel(in);
} }
@ -166,8 +166,8 @@ public class FixableMessagesDialog extends SherlockActivity {
} }
}; };
@NotNull @Nonnull
private static Input fromParcel(@NotNull Parcel in) { private static Input fromParcel(@Nonnull Parcel in) {
final List<FixableMessage> messages = new ArrayList<FixableMessage>(); final List<FixableMessage> messages = new ArrayList<FixableMessage>();
boolean showCheckbox = in.readInt() == 1; boolean showCheckbox = in.readInt() == 1;
in.readTypedList(messages, FixableMessage.CREATOR); in.readTypedList(messages, FixableMessage.CREATOR);
@ -175,17 +175,17 @@ public class FixableMessagesDialog extends SherlockActivity {
} }
@NotNull @Nonnull
private List<FixableMessage> messages = new ArrayList<FixableMessage>(); private List<FixableMessage> messages = new ArrayList<FixableMessage>();
private boolean showCheckbox; private boolean showCheckbox;
private Input(@NotNull List<FixableMessage> messages, boolean showCheckbox) { private Input(@Nonnull List<FixableMessage> messages, boolean showCheckbox) {
this.messages = messages; this.messages = messages;
this.showCheckbox = showCheckbox; this.showCheckbox = showCheckbox;
} }
@NotNull @Nonnull
public List<FixableMessage> getMessages() { public List<FixableMessage> getMessages() {
return messages; return messages;
} }
@ -196,13 +196,13 @@ public class FixableMessagesDialog extends SherlockActivity {
} }
@Override @Override
public void writeToParcel(@NotNull Parcel out, int flags) { public void writeToParcel(@Nonnull Parcel out, int flags) {
out.writeInt(showCheckbox ? 1 : 0); out.writeInt(showCheckbox ? 1 : 0);
out.writeTypedList(messages); out.writeTypedList(messages);
} }
@NotNull @Nonnull
public static Input fromMessages(@NotNull List<Message> messages, boolean showCheckbox) { public static Input fromMessages(@Nonnull List<Message> messages, boolean showCheckbox) {
final List<FixableMessage> stringMessages = new ArrayList<FixableMessage>(messages.size()); final List<FixableMessage> stringMessages = new ArrayList<FixableMessage>(messages.size());
for (Message message : messages) { for (Message message : messages) {
stringMessages.add(new FixableMessage(message)); stringMessages.add(new FixableMessage(message));
@ -218,14 +218,14 @@ public class FixableMessagesDialog extends SherlockActivity {
private class FixErrorOnClickListener implements View.OnClickListener { private class FixErrorOnClickListener implements View.OnClickListener {
@NotNull @Nonnull
private final List<FixableMessage> messages; private final List<FixableMessage> messages;
@NotNull @Nonnull
private final FixableMessage currentMessage; private final FixableMessage currentMessage;
public FixErrorOnClickListener(@NotNull List<FixableMessage> messages, public FixErrorOnClickListener(@Nonnull List<FixableMessage> messages,
@NotNull FixableMessage message) { @Nonnull FixableMessage message) {
this.messages = messages; this.messages = messages;
this.currentMessage = message; this.currentMessage = message;
} }

View File

@ -3,8 +3,8 @@ package org.solovyev.android.calculator;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import jscl.math.Generic; import jscl.math.Generic;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.jscl.JsclOperation; import org.solovyev.android.calculator.jscl.JsclOperation;
/** /**
@ -16,7 +16,7 @@ public final class ParcelableCalculatorDisplayViewState implements CalculatorDis
public static final Creator<ParcelableCalculatorDisplayViewState> CREATOR = new Creator<ParcelableCalculatorDisplayViewState>() { public static final Creator<ParcelableCalculatorDisplayViewState> CREATOR = new Creator<ParcelableCalculatorDisplayViewState>() {
@Override @Override
public ParcelableCalculatorDisplayViewState createFromParcel(@NotNull Parcel in) { public ParcelableCalculatorDisplayViewState createFromParcel(@Nonnull Parcel in) {
return ParcelableCalculatorDisplayViewState.fromParcel(in); return ParcelableCalculatorDisplayViewState.fromParcel(in);
} }
@ -26,8 +26,8 @@ public final class ParcelableCalculatorDisplayViewState implements CalculatorDis
} }
}; };
@NotNull @Nonnull
private static ParcelableCalculatorDisplayViewState fromParcel(@NotNull Parcel in) { private static ParcelableCalculatorDisplayViewState fromParcel(@Nonnull Parcel in) {
final int selection = in.readInt(); final int selection = in.readInt();
final boolean valid = in.readInt() == 1; final boolean valid = in.readInt() == 1;
final String stringResult = in.readString(); final String stringResult = in.readString();
@ -44,15 +44,15 @@ public final class ParcelableCalculatorDisplayViewState implements CalculatorDis
return new ParcelableCalculatorDisplayViewState(calculatorDisplayViewState); return new ParcelableCalculatorDisplayViewState(calculatorDisplayViewState);
} }
@NotNull @Nonnull
private CalculatorDisplayViewState viewState; private CalculatorDisplayViewState viewState;
public ParcelableCalculatorDisplayViewState(@NotNull CalculatorDisplayViewState viewState) { public ParcelableCalculatorDisplayViewState(@Nonnull CalculatorDisplayViewState viewState) {
this.viewState = viewState; this.viewState = viewState;
} }
@Override @Override
@NotNull @Nonnull
public String getText() { public String getText() {
return viewState.getText(); return viewState.getText();
} }
@ -80,7 +80,7 @@ public final class ParcelableCalculatorDisplayViewState implements CalculatorDis
} }
@Override @Override
@NotNull @Nonnull
public JsclOperation getOperation() { public JsclOperation getOperation() {
return viewState.getOperation(); return viewState.getOperation();
} }
@ -97,7 +97,7 @@ public final class ParcelableCalculatorDisplayViewState implements CalculatorDis
} }
@Override @Override
public void writeToParcel(@NotNull Parcel out, int flags) { public void writeToParcel(@Nonnull Parcel out, int flags) {
out.writeInt(viewState.getSelection()); out.writeInt(viewState.getSelection());
out.writeInt(viewState.isValid() ? 1 : 0); out.writeInt(viewState.isValid() ? 1 : 0);
out.writeString(viewState.getStringResult()); out.writeString(viewState.getStringResult());

View File

@ -2,7 +2,7 @@ package org.solovyev.android.calculator;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
/** /**
* User: serso * User: serso
@ -13,7 +13,7 @@ public final class ParcelableCalculatorEditorViewState implements CalculatorEdit
public static final Creator<ParcelableCalculatorEditorViewState> CREATOR = new Creator<ParcelableCalculatorEditorViewState>() { public static final Creator<ParcelableCalculatorEditorViewState> CREATOR = new Creator<ParcelableCalculatorEditorViewState>() {
@Override @Override
public ParcelableCalculatorEditorViewState createFromParcel(@NotNull Parcel in) { public ParcelableCalculatorEditorViewState createFromParcel(@Nonnull Parcel in) {
return ParcelableCalculatorEditorViewState.fromParcel(in); return ParcelableCalculatorEditorViewState.fromParcel(in);
} }
@ -23,22 +23,22 @@ public final class ParcelableCalculatorEditorViewState implements CalculatorEdit
} }
}; };
@NotNull @Nonnull
private CalculatorEditorViewState viewState; private CalculatorEditorViewState viewState;
public ParcelableCalculatorEditorViewState(@NotNull CalculatorEditorViewState viewState) { public ParcelableCalculatorEditorViewState(@Nonnull CalculatorEditorViewState viewState) {
this.viewState = viewState; this.viewState = viewState;
} }
@NotNull @Nonnull
private static ParcelableCalculatorEditorViewState fromParcel(@NotNull Parcel in) { private static ParcelableCalculatorEditorViewState fromParcel(@Nonnull Parcel in) {
final String text = in.readString(); final String text = in.readString();
final int selection = in.readInt(); final int selection = in.readInt();
return new ParcelableCalculatorEditorViewState(CalculatorEditorViewStateImpl.newInstance(text, selection)); return new ParcelableCalculatorEditorViewState(CalculatorEditorViewStateImpl.newInstance(text, selection));
} }
@Override @Override
@NotNull @Nonnull
public String getText() { public String getText() {
return viewState.getText(); return viewState.getText();
} }
@ -54,7 +54,7 @@ public final class ParcelableCalculatorEditorViewState implements CalculatorEdit
} }
@Override @Override
public void writeToParcel(@NotNull Parcel out, int flags) { public void writeToParcel(@Nonnull Parcel out, int flags) {
out.writeString(viewState.getText()); out.writeString(viewState.getText());
out.writeInt(viewState.getSelection()); out.writeInt(viewState.getSelection());
} }

View File

@ -2,8 +2,8 @@ package org.solovyev.android.calculator;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.common.msg.MessageLevel; import org.solovyev.common.msg.MessageLevel;
import org.solovyev.common.msg.MessageType; import org.solovyev.common.msg.MessageType;
@ -24,7 +24,7 @@ public final class ParcelableDialogData implements DialogData, Parcelable {
public final static Creator<ParcelableDialogData> CREATOR = new Creator<ParcelableDialogData>() { public final static Creator<ParcelableDialogData> CREATOR = new Creator<ParcelableDialogData>() {
@Override @Override
public ParcelableDialogData createFromParcel(@NotNull Parcel in) { public ParcelableDialogData createFromParcel(@Nonnull Parcel in) {
return fromParcel(in); return fromParcel(in);
} }
@ -42,7 +42,7 @@ public final class ParcelableDialogData implements DialogData, Parcelable {
********************************************************************** **********************************************************************
*/ */
@NotNull @Nonnull
private DialogData nestedData; private DialogData nestedData;
/* /*
@ -53,12 +53,12 @@ public final class ParcelableDialogData implements DialogData, Parcelable {
********************************************************************** **********************************************************************
*/ */
public ParcelableDialogData(@NotNull DialogData nestedData) { public ParcelableDialogData(@Nonnull DialogData nestedData) {
this.nestedData = nestedData; this.nestedData = nestedData;
} }
@NotNull @Nonnull
public static ParcelableDialogData wrap(@NotNull DialogData nestedData) { public static ParcelableDialogData wrap(@Nonnull DialogData nestedData) {
if (nestedData instanceof ParcelableDialogData) { if (nestedData instanceof ParcelableDialogData) {
return ((ParcelableDialogData) nestedData); return ((ParcelableDialogData) nestedData);
} else { } else {
@ -66,21 +66,21 @@ public final class ParcelableDialogData implements DialogData, Parcelable {
} }
} }
@NotNull @Nonnull
public static ParcelableDialogData fromParcel(@NotNull Parcel in) { public static ParcelableDialogData fromParcel(@Nonnull Parcel in) {
final String message = in.readString(); final String message = in.readString();
final MessageType messageType = MessageType.values()[in.readInt()]; final MessageType messageType = MessageType.values()[in.readInt()];
final String title = in.readString(); final String title = in.readString();
return wrap(StringDialogData.newInstance(message, messageType, title)); return wrap(StringDialogData.newInstance(message, messageType, title));
} }
@NotNull @Nonnull
@Override @Override
public String getMessage() { public String getMessage() {
return nestedData.getMessage(); return nestedData.getMessage();
} }
@NotNull @Nonnull
@Override @Override
public MessageLevel getMessageLevel() { public MessageLevel getMessageLevel() {
return nestedData.getMessageLevel(); return nestedData.getMessageLevel();
@ -98,7 +98,7 @@ public final class ParcelableDialogData implements DialogData, Parcelable {
} }
@Override @Override
public void writeToParcel(@NotNull Parcel out, int flags) { public void writeToParcel(@Nonnull Parcel out, int flags) {
out.writeString(this.getMessage()); out.writeString(this.getMessage());
out.writeInt(this.getMessageLevel().getMessageLevel()); out.writeInt(this.getMessageLevel().getMessageLevel());
out.writeString(this.getTitle()); out.writeString(this.getTitle());

View File

@ -3,11 +3,11 @@ package org.solovyev.android.calculator.external;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Parcelable; import android.os.Parcelable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.App; import org.solovyev.android.App;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -39,19 +39,19 @@ public class AndroidExternalListenersContainer implements CalculatorExternalList
private static final String TAG = "Calculator++ External Listener Helper"; private static final String TAG = "Calculator++ External Listener Helper";
@NotNull @Nonnull
private final Set<Class<?>> externalListeners = new HashSet<Class<?>>(); private final Set<Class<?>> externalListeners = new HashSet<Class<?>>();
@NotNull @Nonnull
private final CalculatorEventHolder lastEvent = new CalculatorEventHolder(CalculatorUtils.createFirstEventDataId()); private final CalculatorEventHolder lastEvent = new CalculatorEventHolder(CalculatorUtils.createFirstEventDataId());
public AndroidExternalListenersContainer(@NotNull Calculator calculator) { public AndroidExternalListenersContainer(@Nonnull Calculator calculator) {
calculator.addCalculatorEventListener(this); calculator.addCalculatorEventListener(this);
} }
public void onEditorStateChanged(@NotNull Context context, public void onEditorStateChanged(@Nonnull Context context,
@NotNull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventData calculatorEventData,
@NotNull CalculatorEditorViewState editorViewState) { @Nonnull CalculatorEditorViewState editorViewState) {
for (Class<?> externalListener : getExternalListenersSync()) { for (Class<?> externalListener : getExternalListenersSync()) {
final Intent intent = new Intent(EDITOR_STATE_CHANGED_ACTION); final Intent intent = new Intent(EDITOR_STATE_CHANGED_ACTION);
@ -63,9 +63,9 @@ public class AndroidExternalListenersContainer implements CalculatorExternalList
} }
} }
private void onDisplayStateChanged(@NotNull Context context, private void onDisplayStateChanged(@Nonnull Context context,
@NotNull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventData calculatorEventData,
@NotNull CalculatorDisplayViewState displayViewState) { @Nonnull CalculatorDisplayViewState displayViewState) {
for (Class<?> externalListener : getExternalListenersSync()) { for (Class<?> externalListener : getExternalListenersSync()) {
final Intent intent = new Intent(DISPLAY_STATE_CHANGED_ACTION); final Intent intent = new Intent(DISPLAY_STATE_CHANGED_ACTION);
intent.setClass(context, externalListener); intent.setClass(context, externalListener);
@ -76,7 +76,7 @@ public class AndroidExternalListenersContainer implements CalculatorExternalList
} }
} }
@NotNull @Nonnull
private Set<Class<?>> getExternalListenersSync() { private Set<Class<?>> getExternalListenersSync() {
synchronized (externalListeners) { synchronized (externalListeners) {
return new HashSet<Class<?>>(externalListeners); return new HashSet<Class<?>>(externalListeners);
@ -84,21 +84,21 @@ public class AndroidExternalListenersContainer implements CalculatorExternalList
} }
@Override @Override
public void addExternalListener(@NotNull Class<?> externalCalculatorClass) { public void addExternalListener(@Nonnull Class<?> externalCalculatorClass) {
synchronized (externalListeners) { synchronized (externalListeners) {
externalListeners.add(externalCalculatorClass); externalListeners.add(externalCalculatorClass);
} }
} }
@Override @Override
public boolean removeExternalListener(@NotNull Class<?> externalCalculatorClass) { public boolean removeExternalListener(@Nonnull Class<?> externalCalculatorClass) {
synchronized (externalListeners) { synchronized (externalListeners) {
return externalListeners.remove(externalCalculatorClass); return externalListeners.remove(externalCalculatorClass);
} }
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
final CalculatorEventHolder.Result result = lastEvent.apply(calculatorEventData); final CalculatorEventHolder.Result result = lastEvent.apply(calculatorEventData);
if (result.isNewAfter()) { if (result.isNewAfter()) {
switch (calculatorEventType) { switch (calculatorEventType) {

View File

@ -3,7 +3,7 @@ package org.solovyev.android.calculator.external;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Parcelable; import android.os.Parcelable;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.CalculatorDisplayViewState; import org.solovyev.android.calculator.CalculatorDisplayViewState;
import org.solovyev.android.calculator.CalculatorEditorViewState; import org.solovyev.android.calculator.CalculatorEditorViewState;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
@ -18,21 +18,21 @@ public class DefaultExternalCalculatorIntentHandler implements ExternalCalculato
private static final String TAG = ExternalCalculatorIntentHandler.class.getSimpleName(); private static final String TAG = ExternalCalculatorIntentHandler.class.getSimpleName();
@NotNull @Nonnull
private final MutableObject<Long> lastDisplayEventId = new MutableObject<Long>(0L); private final MutableObject<Long> lastDisplayEventId = new MutableObject<Long>(0L);
@NotNull @Nonnull
private final MutableObject<Long> lastEditorEventId = new MutableObject<Long>(0L); private final MutableObject<Long> lastEditorEventId = new MutableObject<Long>(0L);
@NotNull @Nonnull
private final ExternalCalculatorStateUpdater stateUpdater; private final ExternalCalculatorStateUpdater stateUpdater;
public DefaultExternalCalculatorIntentHandler(@NotNull ExternalCalculatorStateUpdater stateUpdater) { public DefaultExternalCalculatorIntentHandler(@Nonnull ExternalCalculatorStateUpdater stateUpdater) {
this.stateUpdater = stateUpdater; this.stateUpdater = stateUpdater;
} }
@Override @Override
public void onIntent(@NotNull Context context, @NotNull Intent intent) { public void onIntent(@Nonnull Context context, @Nonnull Intent intent) {
if (AndroidExternalListenersContainer.EDITOR_STATE_CHANGED_ACTION.equals(intent.getAction())) { if (AndroidExternalListenersContainer.EDITOR_STATE_CHANGED_ACTION.equals(intent.getAction())) {
Locator.getInstance().getNotifier().showDebugMessage(TAG, "Editor state changed broadcast received!"); Locator.getInstance().getNotifier().showDebugMessage(TAG, "Editor state changed broadcast received!");
@ -76,17 +76,17 @@ public class DefaultExternalCalculatorIntentHandler implements ExternalCalculato
} }
} }
protected void updateState(@NotNull Context context, protected void updateState(@Nonnull Context context,
@NotNull CalculatorEditorViewState editorViewState, @Nonnull CalculatorEditorViewState editorViewState,
@NotNull CalculatorDisplayViewState displayViewState) { @Nonnull CalculatorDisplayViewState displayViewState) {
stateUpdater.updateState(context, editorViewState, displayViewState); stateUpdater.updateState(context, editorViewState, displayViewState);
} }
protected void onDisplayStateChanged(@NotNull Context context, @NotNull CalculatorDisplayViewState displayViewState) { protected void onDisplayStateChanged(@Nonnull Context context, @Nonnull CalculatorDisplayViewState displayViewState) {
updateState(context, Locator.getInstance().getEditor().getViewState(), displayViewState); updateState(context, Locator.getInstance().getEditor().getViewState(), displayViewState);
} }
protected void onEditorStateChanged(@NotNull Context context, @NotNull CalculatorEditorViewState editorViewState) { protected void onEditorStateChanged(@Nonnull Context context, @Nonnull CalculatorEditorViewState editorViewState) {
updateState(context, editorViewState, Locator.getInstance().getDisplay().getViewState()); updateState(context, editorViewState, Locator.getInstance().getDisplay().getViewState());
} }
} }

View File

@ -2,7 +2,7 @@ package org.solovyev.android.calculator.external;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
/** /**
* User: serso * User: serso
@ -11,5 +11,5 @@ import org.jetbrains.annotations.NotNull;
*/ */
public interface ExternalCalculatorIntentHandler { public interface ExternalCalculatorIntentHandler {
void onIntent(@NotNull Context context, @NotNull Intent intent); void onIntent(@Nonnull Context context, @Nonnull Intent intent);
} }

View File

@ -1,7 +1,7 @@
package org.solovyev.android.calculator.external; package org.solovyev.android.calculator.external;
import android.content.Context; import android.content.Context;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.CalculatorDisplayViewState; import org.solovyev.android.calculator.CalculatorDisplayViewState;
import org.solovyev.android.calculator.CalculatorEditorViewState; import org.solovyev.android.calculator.CalculatorEditorViewState;
@ -12,7 +12,7 @@ import org.solovyev.android.calculator.CalculatorEditorViewState;
*/ */
public interface ExternalCalculatorStateUpdater { public interface ExternalCalculatorStateUpdater {
void updateState(@NotNull Context context, void updateState(@Nonnull Context context,
@NotNull CalculatorEditorViewState editorState, @Nonnull CalculatorEditorViewState editorState,
@NotNull CalculatorDisplayViewState displayState); @Nonnull CalculatorDisplayViewState displayState);
} }

View File

@ -16,7 +16,7 @@ import jscl.NumeralBase;
import jscl.math.function.Function; import jscl.math.function.Function;
import jscl.math.function.IConstant; import jscl.math.function.IConstant;
import jscl.math.operator.Operator; import jscl.math.operator.Operator;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.core.R; import org.solovyev.android.calculator.core.R;
import org.solovyev.android.prefs.BooleanPreference; import org.solovyev.android.prefs.BooleanPreference;
@ -85,22 +85,22 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen
preferenceKeys.add(maxCalculationTime.getKey()); preferenceKeys.add(maxCalculationTime.getKey());
} }
@NotNull @Nonnull
public static List<String> getPreferenceKeys() { public static List<String> getPreferenceKeys() {
return Collections.unmodifiableList(preferenceKeys); return Collections.unmodifiableList(preferenceKeys);
} }
} }
@NotNull @Nonnull
private final Context context; private final Context context;
@NotNull @Nonnull
private final CalculatorEngine calculatorEngine; private final CalculatorEngine calculatorEngine;
@NotNull @Nonnull
private final Object lock; private final Object lock;
public AndroidCalculatorEngine(@NotNull Application application) { public AndroidCalculatorEngine(@Nonnull Application application) {
this.context = application; this.context = application;
PreferenceManager.getDefaultSharedPreferences(application).registerOnSharedPreferenceChangeListener(this); PreferenceManager.getDefaultSharedPreferences(application).registerOnSharedPreferenceChangeListener(this);
@ -117,42 +117,42 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen
} }
@Override @Override
@NotNull @Nonnull
public CalculatorMathRegistry<IConstant> getVarsRegistry() { public CalculatorMathRegistry<IConstant> getVarsRegistry() {
return calculatorEngine.getVarsRegistry(); return calculatorEngine.getVarsRegistry();
} }
@Override @Override
@NotNull @Nonnull
public CalculatorMathRegistry<Function> getFunctionsRegistry() { public CalculatorMathRegistry<Function> getFunctionsRegistry() {
return calculatorEngine.getFunctionsRegistry(); return calculatorEngine.getFunctionsRegistry();
} }
@Override @Override
@NotNull @Nonnull
public CalculatorMathRegistry<Operator> getOperatorsRegistry() { public CalculatorMathRegistry<Operator> getOperatorsRegistry() {
return calculatorEngine.getOperatorsRegistry(); return calculatorEngine.getOperatorsRegistry();
} }
@Override @Override
@NotNull @Nonnull
public CalculatorMathRegistry<Operator> getPostfixFunctionsRegistry() { public CalculatorMathRegistry<Operator> getPostfixFunctionsRegistry() {
return calculatorEngine.getPostfixFunctionsRegistry(); return calculatorEngine.getPostfixFunctionsRegistry();
} }
@Override @Override
@NotNull @Nonnull
public CalculatorMathEngine getMathEngine() { public CalculatorMathEngine getMathEngine() {
return calculatorEngine.getMathEngine(); return calculatorEngine.getMathEngine();
} }
@NotNull @Nonnull
@Override @Override
public MathEngine getMathEngine0() { public MathEngine getMathEngine0() {
return calculatorEngine.getMathEngine0(); return calculatorEngine.getMathEngine0();
} }
@NotNull @Nonnull
@Override @Override
public NumeralBase getNumeralBase() { public NumeralBase getNumeralBase() {
return calculatorEngine.getNumeralBase(); return calculatorEngine.getNumeralBase();
@ -196,47 +196,47 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen
} }
@Override @Override
public void setPrecision(@NotNull Integer precision) { public void setPrecision(@Nonnull Integer precision) {
calculatorEngine.setPrecision(precision); calculatorEngine.setPrecision(precision);
} }
@Override @Override
public void setRoundResult(@NotNull Boolean round) { public void setRoundResult(@Nonnull Boolean round) {
calculatorEngine.setRoundResult(round); calculatorEngine.setRoundResult(round);
} }
@NotNull @Nonnull
@Override @Override
public AngleUnit getAngleUnits() { public AngleUnit getAngleUnits() {
return calculatorEngine.getAngleUnits(); return calculatorEngine.getAngleUnits();
} }
@Override @Override
public void setAngleUnits(@NotNull AngleUnit angleUnits) { public void setAngleUnits(@Nonnull AngleUnit angleUnits) {
calculatorEngine.setAngleUnits(angleUnits); calculatorEngine.setAngleUnits(angleUnits);
} }
@Override @Override
public void setNumeralBase(@NotNull NumeralBase numeralBase) { public void setNumeralBase(@Nonnull NumeralBase numeralBase) {
calculatorEngine.setNumeralBase(numeralBase); calculatorEngine.setNumeralBase(numeralBase);
} }
@Override @Override
public void setMultiplicationSign(@NotNull String multiplicationSign) { public void setMultiplicationSign(@Nonnull String multiplicationSign) {
calculatorEngine.setMultiplicationSign(multiplicationSign); calculatorEngine.setMultiplicationSign(multiplicationSign);
} }
@Override @Override
public void setScienceNotation(@NotNull Boolean scienceNotation) { public void setScienceNotation(@Nonnull Boolean scienceNotation) {
calculatorEngine.setScienceNotation(scienceNotation); calculatorEngine.setScienceNotation(scienceNotation);
} }
@Override @Override
public void setTimeout(@NotNull Integer timeout) { public void setTimeout(@Nonnull Integer timeout) {
calculatorEngine.setTimeout(timeout); calculatorEngine.setTimeout(timeout);
} }
private void softReset(@NotNull SharedPreferences preferences) { private void softReset(@Nonnull SharedPreferences preferences) {
this.setPrecision(Preferences.precision.getPreference(preferences)); this.setPrecision(Preferences.precision.getPreference(preferences));
this.setRoundResult(Preferences.roundResult.getPreference(preferences)); this.setRoundResult(Preferences.roundResult.getPreference(preferences));
this.setAngleUnits(getAngleUnitsFromPrefs(preferences)); this.setAngleUnits(getAngleUnitsFromPrefs(preferences));
@ -254,23 +254,23 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen
} }
} }
@NotNull @Nonnull
public NumeralBase getNumeralBaseFromPrefs(@NotNull SharedPreferences preferences) { public NumeralBase getNumeralBaseFromPrefs(@Nonnull SharedPreferences preferences) {
return Preferences.numeralBase.getPreference(preferences); return Preferences.numeralBase.getPreference(preferences);
} }
@NotNull @Nonnull
public AngleUnit getAngleUnitsFromPrefs(@NotNull SharedPreferences preferences) { public AngleUnit getAngleUnitsFromPrefs(@Nonnull SharedPreferences preferences) {
return Preferences.angleUnit.getPreference(preferences); return Preferences.angleUnit.getPreference(preferences);
} }
//for tests only //for tests only
public void setDecimalGroupSymbols(@NotNull DecimalFormatSymbols decimalGroupSymbols) { public void setDecimalGroupSymbols(@Nonnull DecimalFormatSymbols decimalGroupSymbols) {
this.calculatorEngine.setDecimalGroupSymbols(decimalGroupSymbols); this.calculatorEngine.setDecimalGroupSymbols(decimalGroupSymbols);
} }
@Override @Override
@NotNull @Nonnull
public String getMultiplicationSign() { public String getMultiplicationSign() {
return calculatorEngine.getMultiplicationSign(); return calculatorEngine.getMultiplicationSign();
} }

View File

@ -5,8 +5,8 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Resources; import android.content.res.Resources;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.simpleframework.xml.Serializer; import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister; import org.simpleframework.xml.core.Persister;
import org.solovyev.android.App; import org.solovyev.android.App;
@ -23,20 +23,20 @@ import java.io.StringWriter;
*/ */
public class AndroidMathEntityDao<T extends MathPersistenceEntity> implements MathEntityDao<T> { public class AndroidMathEntityDao<T extends MathPersistenceEntity> implements MathEntityDao<T> {
@NotNull @Nonnull
private static final String TAG = AndroidMathEntityDao.class.getSimpleName(); private static final String TAG = AndroidMathEntityDao.class.getSimpleName();
@Nullable @Nullable
private final Integer preferenceStringId; private final Integer preferenceStringId;
@NotNull @Nonnull
private final Context context; private final Context context;
@Nullable @Nullable
private final Class<? extends MathEntityPersistenceContainer<T>> persistenceContainerClass; private final Class<? extends MathEntityPersistenceContainer<T>> persistenceContainerClass;
public AndroidMathEntityDao(@Nullable Integer preferenceStringId, public AndroidMathEntityDao(@Nullable Integer preferenceStringId,
@NotNull Application application, @Nonnull Application application,
@Nullable Class<? extends MathEntityPersistenceContainer<T>> persistenceContainerClass) { @Nullable Class<? extends MathEntityPersistenceContainer<T>> persistenceContainerClass) {
this.preferenceStringId = preferenceStringId; this.preferenceStringId = preferenceStringId;
this.context = application; this.context = application;
@ -44,7 +44,7 @@ public class AndroidMathEntityDao<T extends MathPersistenceEntity> implements Ma
} }
@Override @Override
public void save(@NotNull MathEntityPersistenceContainer<T> container) { public void save(@Nonnull MathEntityPersistenceContainer<T> container) {
if (preferenceStringId != null) { if (preferenceStringId != null) {
final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
final SharedPreferences.Editor editor = settings.edit(); final SharedPreferences.Editor editor = settings.edit();
@ -86,7 +86,7 @@ public class AndroidMathEntityDao<T extends MathPersistenceEntity> implements Ma
} }
@Nullable @Nullable
public String getDescription(@NotNull String descriptionId) { public String getDescription(@Nonnull String descriptionId) {
final Resources resources = context.getResources(); final Resources resources = context.getResources();
final int stringId = resources.getIdentifier(descriptionId, "string", App.getApplication().getClass().getPackage().getName()); final int stringId = resources.getIdentifier(descriptionId, "string", App.getApplication().getClass().getPackage().getName());

View File

@ -4,8 +4,8 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import jscl.math.Generic; import jscl.math.Generic;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.CalculatorPreferences; import org.solovyev.android.calculator.CalculatorPreferences;
import java.util.List; import java.util.List;
@ -17,11 +17,11 @@ import java.util.List;
*/ */
public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPreferences.OnSharedPreferenceChangeListener { public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPreferences.OnSharedPreferenceChangeListener {
@NotNull @Nonnull
private final CalculatorPlotter plotter; private final CalculatorPlotter plotter;
public AndroidCalculatorPlotter(@NotNull Context context, public AndroidCalculatorPlotter(@Nonnull Context context,
@NotNull CalculatorPlotter plotter) { @Nonnull CalculatorPlotter plotter) {
this.plotter = plotter; this.plotter = plotter;
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
@ -31,72 +31,72 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
} }
@Override @Override
@NotNull @Nonnull
public PlotData getPlotData() { public PlotData getPlotData() {
return plotter.getPlotData(); return plotter.getPlotData();
} }
@Override @Override
public boolean addFunction(@NotNull Generic expression) { public boolean addFunction(@Nonnull Generic expression) {
return plotter.addFunction(expression); return plotter.addFunction(expression);
} }
@Override @Override
public boolean addFunction(@NotNull PlotFunction plotFunction) { public boolean addFunction(@Nonnull PlotFunction plotFunction) {
return plotter.addFunction(plotFunction); return plotter.addFunction(plotFunction);
} }
@Override @Override
public boolean addFunction(@NotNull XyFunction xyFunction) { public boolean addFunction(@Nonnull XyFunction xyFunction) {
return plotter.addFunction(xyFunction); return plotter.addFunction(xyFunction);
} }
@Override @Override
public boolean addFunction(@NotNull XyFunction xyFunction, @NotNull PlotLineDef functionLineDef) { public boolean addFunction(@Nonnull XyFunction xyFunction, @Nonnull PlotLineDef functionLineDef) {
return plotter.addFunction(xyFunction, functionLineDef); return plotter.addFunction(xyFunction, functionLineDef);
} }
@Override @Override
public boolean updateFunction(@NotNull PlotFunction newFunction) { public boolean updateFunction(@Nonnull PlotFunction newFunction) {
return plotter.updateFunction(newFunction); return plotter.updateFunction(newFunction);
} }
@Override @Override
public boolean updateFunction(@NotNull XyFunction xyFunction, @NotNull PlotLineDef functionLineDef) { public boolean updateFunction(@Nonnull XyFunction xyFunction, @Nonnull PlotLineDef functionLineDef) {
return plotter.updateFunction(xyFunction, functionLineDef); return plotter.updateFunction(xyFunction, functionLineDef);
} }
@Override @Override
public boolean removeFunction(@NotNull PlotFunction plotFunction) { public boolean removeFunction(@Nonnull PlotFunction plotFunction) {
return plotter.removeFunction(plotFunction); return plotter.removeFunction(plotFunction);
} }
@Override @Override
public boolean removeFunction(@NotNull XyFunction xyFunction) { public boolean removeFunction(@Nonnull XyFunction xyFunction) {
return plotter.removeFunction(xyFunction); return plotter.removeFunction(xyFunction);
} }
@NotNull @Nonnull
@Override @Override
public PlotFunction pin(@NotNull PlotFunction plotFunction) { public PlotFunction pin(@Nonnull PlotFunction plotFunction) {
return plotter.pin(plotFunction); return plotter.pin(plotFunction);
} }
@NotNull @Nonnull
@Override @Override
public PlotFunction unpin(@NotNull PlotFunction plotFunction) { public PlotFunction unpin(@Nonnull PlotFunction plotFunction) {
return plotter.unpin(plotFunction); return plotter.unpin(plotFunction);
} }
@NotNull @Nonnull
@Override @Override
public PlotFunction show(@NotNull PlotFunction plotFunction) { public PlotFunction show(@Nonnull PlotFunction plotFunction) {
return plotter.show(plotFunction); return plotter.show(plotFunction);
} }
@NotNull @Nonnull
@Override @Override
public PlotFunction hide(@NotNull PlotFunction plotFunction) { public PlotFunction hide(@Nonnull PlotFunction plotFunction) {
return plotter.hide(plotFunction); return plotter.hide(plotFunction);
} }
@ -107,18 +107,18 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
@Nullable @Nullable
@Override @Override
public PlotFunction getFunctionById(@NotNull String functionId) { public PlotFunction getFunctionById(@Nonnull String functionId) {
return plotter.getFunctionById(functionId); return plotter.getFunctionById(functionId);
} }
@Override @Override
@NotNull @Nonnull
public List<PlotFunction> getFunctions() { public List<PlotFunction> getFunctions() {
return plotter.getFunctions(); return plotter.getFunctions();
} }
@Override @Override
@NotNull @Nonnull
public List<PlotFunction> getVisibleFunctions() { public List<PlotFunction> getVisibleFunctions() {
return plotter.getVisibleFunctions(); return plotter.getVisibleFunctions();
} }
@ -129,7 +129,7 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
} }
@Override @Override
public void plot(@NotNull Generic expression) { public void plot(@Nonnull Generic expression) {
plotter.plot(expression); plotter.plot(expression);
} }
@ -139,7 +139,7 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
} }
@Override @Override
public boolean isPlotPossibleFor(@NotNull Generic expression) { public boolean isPlotPossibleFor(@Nonnull Generic expression) {
return plotter.isPlotPossibleFor(expression); return plotter.isPlotPossibleFor(expression);
} }
@ -159,12 +159,12 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
} }
@Override @Override
public void savePlotBoundaries(@NotNull PlotBoundaries plotBoundaries) { public void savePlotBoundaries(@Nonnull PlotBoundaries plotBoundaries) {
plotter.savePlotBoundaries(plotBoundaries); plotter.savePlotBoundaries(plotBoundaries);
} }
@Override @Override
public void setPlotBoundaries(@NotNull PlotBoundaries plotBoundaries) { public void setPlotBoundaries(@Nonnull PlotBoundaries plotBoundaries) {
plotter.setPlotBoundaries(plotBoundaries); plotter.setPlotBoundaries(plotBoundaries);
} }

View File

@ -2,8 +2,8 @@ package org.solovyev.android.calculator.plot;
import android.graphics.DashPathEffect; import android.graphics.DashPathEffect;
import android.graphics.Paint; import android.graphics.Paint;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
/** /**
* User: serso * User: serso
@ -14,43 +14,43 @@ public enum AndroidPlotLineStyle {
solid(PlotLineStyle.solid) { solid(PlotLineStyle.solid) {
@Override @Override
public void applyToPaint(@NotNull Paint paint) { public void applyToPaint(@Nonnull Paint paint) {
paint.setPathEffect(null); paint.setPathEffect(null);
} }
}, },
dashed(PlotLineStyle.dashed) { dashed(PlotLineStyle.dashed) {
@Override @Override
public void applyToPaint(@NotNull Paint paint) { public void applyToPaint(@Nonnull Paint paint) {
paint.setPathEffect(new DashPathEffect(new float[]{10, 20}, 0)); paint.setPathEffect(new DashPathEffect(new float[]{10, 20}, 0));
} }
}, },
dotted(PlotLineStyle.dotted) { dotted(PlotLineStyle.dotted) {
@Override @Override
public void applyToPaint(@NotNull Paint paint) { public void applyToPaint(@Nonnull Paint paint) {
paint.setPathEffect(new DashPathEffect(new float[]{5, 1}, 0)); paint.setPathEffect(new DashPathEffect(new float[]{5, 1}, 0));
} }
}, },
dash_dotted(PlotLineStyle.dash_dotted) { dash_dotted(PlotLineStyle.dash_dotted) {
@Override @Override
public void applyToPaint(@NotNull Paint paint) { public void applyToPaint(@Nonnull Paint paint) {
paint.setPathEffect(new DashPathEffect(new float[]{10, 20, 5, 1}, 0)); paint.setPathEffect(new DashPathEffect(new float[]{10, 20, 5, 1}, 0));
} }
}; };
@NotNull @Nonnull
private final PlotLineStyle plotLineStyle; private final PlotLineStyle plotLineStyle;
AndroidPlotLineStyle(@NotNull PlotLineStyle plotLineStyle) { AndroidPlotLineStyle(@Nonnull PlotLineStyle plotLineStyle) {
this.plotLineStyle = plotLineStyle; this.plotLineStyle = plotLineStyle;
} }
public abstract void applyToPaint(@NotNull Paint paint); public abstract void applyToPaint(@Nonnull Paint paint);
@Nullable @Nullable
public static AndroidPlotLineStyle valueOf(@NotNull PlotLineStyle plotLineStyle) { public static AndroidPlotLineStyle valueOf(@Nonnull PlotLineStyle plotLineStyle) {
for (AndroidPlotLineStyle androidPlotLineStyle : values()) { for (AndroidPlotLineStyle androidPlotLineStyle : values()) {
if (androidPlotLineStyle.plotLineStyle == plotLineStyle) { if (androidPlotLineStyle.plotLineStyle == plotLineStyle) {
return androidPlotLineStyle; return androidPlotLineStyle;

View File

@ -11,7 +11,7 @@ import android.content.res.Resources;
import android.graphics.Paint; import android.graphics.Paint;
import android.text.TextPaint; import android.text.TextPaint;
import android.util.AttributeSet; import android.util.AttributeSet;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.core.R; import org.solovyev.android.calculator.core.R;
import org.solovyev.android.view.drag.DirectionDragButton; import org.solovyev.android.view.drag.DirectionDragButton;
@ -23,14 +23,14 @@ import org.solovyev.android.view.drag.DirectionDragButton;
*/ */
public class AngleUnitsButton extends DirectionDragButton { public class AngleUnitsButton extends DirectionDragButton {
public AngleUnitsButton(Context context, @NotNull AttributeSet attrs) { public AngleUnitsButton(Context context, @Nonnull AttributeSet attrs) {
super(context, attrs); super(context, attrs);
} }
@Override @Override
protected void initDirectionTextPaint(@NotNull Paint basePaint, protected void initDirectionTextPaint(@Nonnull Paint basePaint,
@NotNull DirectionTextData directionTextData, @Nonnull DirectionTextData directionTextData,
@NotNull Resources resources) { @Nonnull Resources resources) {
super.initDirectionTextPaint(basePaint, directionTextData, resources); super.initDirectionTextPaint(basePaint, directionTextData, resources);
final TextPaint directionTextPaint = directionTextData.getPaint(); final TextPaint directionTextPaint = directionTextData.getPaint();

View File

@ -4,8 +4,8 @@ import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.CalculatorParseException; import org.solovyev.android.calculator.CalculatorParseException;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.ToJsclTextProcessor; import org.solovyev.android.calculator.ToJsclTextProcessor;
@ -32,7 +32,7 @@ public class NumeralBaseConverterDialog {
this.initialFromValue = initialFromValue; this.initialFromValue = initialFromValue;
} }
public void show(@NotNull Context context) { public void show(@Nonnull Context context) {
final UnitConverterViewBuilder b = new UnitConverterViewBuilder(); final UnitConverterViewBuilder b = new UnitConverterViewBuilder();
b.setFromUnitTypes(Arrays.asList(CalculatorNumeralBase.values())); b.setFromUnitTypes(Arrays.asList(CalculatorNumeralBase.values()));
b.setToUnitTypes(Arrays.asList(CalculatorNumeralBase.values())); b.setToUnitTypes(Arrays.asList(CalculatorNumeralBase.values()));
@ -64,7 +64,7 @@ public class NumeralBaseConverterDialog {
b.setCustomButtonData(new UnitConverterViewBuilder.CustomButtonData(context.getString(R.string.c_use_short), new UnitConverterViewBuilder.CustomButtonOnClickListener() { b.setCustomButtonData(new UnitConverterViewBuilder.CustomButtonData(context.getString(R.string.c_use_short), new UnitConverterViewBuilder.CustomButtonOnClickListener() {
@Override @Override
public void onClick(@NotNull Unit<String> fromUnits, @NotNull Unit<String> toUnits) { public void onClick(@Nonnull Unit<String> fromUnits, @Nonnull Unit<String> toUnits) {
String toUnitsValue = toUnits.getValue(); String toUnitsValue = toUnits.getValue();
if (!toUnits.getUnitType().equals(CalculatorNumeralBase.valueOf(Locator.getInstance().getEngine().getNumeralBase()))) { if (!toUnits.getUnitType().equals(CalculatorNumeralBase.valueOf(Locator.getInstance().getEngine().getNumeralBase()))) {

View File

@ -11,7 +11,7 @@ import android.content.res.Resources;
import android.graphics.Paint; import android.graphics.Paint;
import android.text.TextPaint; import android.text.TextPaint;
import android.util.AttributeSet; import android.util.AttributeSet;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.core.R; import org.solovyev.android.calculator.core.R;
import org.solovyev.android.view.drag.DirectionDragButton; import org.solovyev.android.view.drag.DirectionDragButton;
@ -23,14 +23,14 @@ import org.solovyev.android.view.drag.DirectionDragButton;
*/ */
public class NumeralBasesButton extends DirectionDragButton { public class NumeralBasesButton extends DirectionDragButton {
public NumeralBasesButton(Context context, @NotNull AttributeSet attrs) { public NumeralBasesButton(Context context, @Nonnull AttributeSet attrs) {
super(context, attrs); super(context, attrs);
} }
@Override @Override
protected void initDirectionTextPaint(@NotNull Paint basePaint, protected void initDirectionTextPaint(@Nonnull Paint basePaint,
@NotNull DirectionTextData directionTextData, @Nonnull DirectionTextData directionTextData,
@NotNull Resources resources) { @Nonnull Resources resources) {
super.initDirectionTextPaint(basePaint, directionTextData, resources); super.initDirectionTextPaint(basePaint, directionTextData, resources);
final TextPaint directionTextPaint = directionTextData.getPaint(); final TextPaint directionTextPaint = directionTextData.getPaint();

View File

@ -6,8 +6,8 @@
package org.solovyev.android.calculator.view; package org.solovyev.android.calculator.view;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.calculator.text.TextProcessor; import org.solovyev.android.calculator.text.TextProcessor;
@ -31,7 +31,7 @@ public class TextHighlighter implements TextProcessor<TextHighlighter.Result, St
public static class Result implements CharSequence { public static class Result implements CharSequence {
@NotNull @Nonnull
private final CharSequence charSequence; private final CharSequence charSequence;
@Nullable @Nullable
@ -39,7 +39,7 @@ public class TextHighlighter implements TextProcessor<TextHighlighter.Result, St
private final int offset; private final int offset;
public Result(@NotNull CharSequence charSequence, int offset) { public Result(@Nonnull CharSequence charSequence, int offset) {
this.charSequence = charSequence; this.charSequence = charSequence;
this.offset = offset; this.offset = offset;
} }
@ -67,7 +67,7 @@ public class TextHighlighter implements TextProcessor<TextHighlighter.Result, St
return string; return string;
} }
@NotNull @Nonnull
public CharSequence getCharSequence() { public CharSequence getCharSequence() {
return charSequence; return charSequence;
} }
@ -94,9 +94,9 @@ public class TextHighlighter implements TextProcessor<TextHighlighter.Result, St
this.colorBlue = color & 0xFF; this.colorBlue = color & 0xFF;
} }
@NotNull @Nonnull
@Override @Override
public Result process(@NotNull String text) throws CalculatorParseException { public Result process(@Nonnull String text) throws CalculatorParseException {
final CharSequence result; final CharSequence result;
int maxNumberOfOpenGroupSymbols = 0; int maxNumberOfOpenGroupSymbols = 0;
@ -185,7 +185,7 @@ public class TextHighlighter implements TextProcessor<TextHighlighter.Result, St
return new Result(result, resultOffset); return new Result(result, resultOffset);
} }
private int processHighlightedText(@NotNull StringBuilder result, int i, @NotNull String match, @NotNull String tag, @Nullable Map<String, String> tagAttributes) { private int processHighlightedText(@Nonnull StringBuilder result, int i, @Nonnull String match, @Nonnull String tag, @Nullable Map<String, String> tagAttributes) {
result.append("<").append(tag); result.append("<").append(tag);
if (tagAttributes != null && !tagAttributes.entrySet().isEmpty()) { if (tagAttributes != null && !tagAttributes.entrySet().isEmpty()) {
@ -203,7 +203,7 @@ public class TextHighlighter implements TextProcessor<TextHighlighter.Result, St
} }
} }
private int processBracketGroup(@NotNull StringBuilder result, @NotNull CharSequence s, int i, int numberOfOpenings, int maxNumberOfGroups) { private int processBracketGroup(@Nonnull StringBuilder result, @Nonnull CharSequence s, int i, int numberOfOpenings, int maxNumberOfGroups) {
result.append("<font color=\"").append(getColor(maxNumberOfGroups, numberOfOpenings)).append("\">"); result.append("<font color=\"").append(getColor(maxNumberOfGroups, numberOfOpenings)).append("\">");

View File

@ -8,8 +8,8 @@ import android.text.TextWatcher;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.*; import android.widget.*;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.core.R; import org.solovyev.android.calculator.core.R;
import org.solovyev.android.view.ViewBuilder; import org.solovyev.android.view.ViewBuilder;
import org.solovyev.android.view.ViewFromLayoutBuilder; import org.solovyev.android.view.ViewFromLayoutBuilder;
@ -25,16 +25,16 @@ import java.util.List;
*/ */
public class UnitConverterViewBuilder implements ViewBuilder<View> { public class UnitConverterViewBuilder implements ViewBuilder<View> {
@NotNull @Nonnull
private List<? extends UnitType<String>> fromUnitTypes = Collections.emptyList(); private List<? extends UnitType<String>> fromUnitTypes = Collections.emptyList();
@NotNull @Nonnull
private List<? extends UnitType<String>> toUnitTypes = Collections.emptyList(); private List<? extends UnitType<String>> toUnitTypes = Collections.emptyList();
@Nullable @Nullable
private Unit<String> fromValue; private Unit<String> fromValue;
@NotNull @Nonnull
private UnitConverter<String> converter = UnitConverter.Dummy.getInstance(); private UnitConverter<String> converter = UnitConverter.Dummy.getInstance();
@Nullable @Nullable
@ -43,11 +43,11 @@ public class UnitConverterViewBuilder implements ViewBuilder<View> {
@Nullable @Nullable
private CustomButtonData customButtonData; private CustomButtonData customButtonData;
public void setFromUnitTypes(@NotNull List<? extends UnitType<String>> fromUnitTypes) { public void setFromUnitTypes(@Nonnull List<? extends UnitType<String>> fromUnitTypes) {
this.fromUnitTypes = fromUnitTypes; this.fromUnitTypes = fromUnitTypes;
} }
public void setToUnitTypes(@NotNull List<? extends UnitType<String>> toUnitTypes) { public void setToUnitTypes(@Nonnull List<? extends UnitType<String>> toUnitTypes) {
this.toUnitTypes = toUnitTypes; this.toUnitTypes = toUnitTypes;
} }
@ -55,7 +55,7 @@ public class UnitConverterViewBuilder implements ViewBuilder<View> {
this.fromValue = fromValue; this.fromValue = fromValue;
} }
public void setConverter(@NotNull UnitConverter<String> converter) { public void setConverter(@Nonnull UnitConverter<String> converter) {
this.converter = converter; this.converter = converter;
} }
@ -67,9 +67,9 @@ public class UnitConverterViewBuilder implements ViewBuilder<View> {
this.customButtonData = customButtonData; this.customButtonData = customButtonData;
} }
@NotNull @Nonnull
@Override @Override
public View build(@NotNull final Context context) { public View build(@Nonnull final Context context) {
final View main = ViewFromLayoutBuilder.newInstance(R.layout.cpp_unit_converter).build(context); final View main = ViewFromLayoutBuilder.newInstance(R.layout.cpp_unit_converter).build(context);
final Spinner fromSpinner = (Spinner) main.findViewById(R.id.unit_types_from); final Spinner fromSpinner = (Spinner) main.findViewById(R.id.unit_types_from);
@ -137,10 +137,10 @@ public class UnitConverterViewBuilder implements ViewBuilder<View> {
return main; return main;
} }
private void fillSpinner(@NotNull final View main, private void fillSpinner(@Nonnull final View main,
@NotNull final Context context, @Nonnull final Context context,
final int spinnerId, final int spinnerId,
@NotNull List<? extends UnitType<String>> unitTypes) { @Nonnull List<? extends UnitType<String>> unitTypes) {
final Spinner spinner = (Spinner) main.findViewById(spinnerId); final Spinner spinner = (Spinner) main.findViewById(spinnerId);
final ArrayAdapter<UnitType<String>> adapter = new ArrayAdapter<UnitType<String>>(context, android.R.layout.simple_spinner_item); final ArrayAdapter<UnitType<String>> adapter = new ArrayAdapter<UnitType<String>>(context, android.R.layout.simple_spinner_item);
@ -161,7 +161,7 @@ public class UnitConverterViewBuilder implements ViewBuilder<View> {
spinner.setAdapter(adapter); spinner.setAdapter(adapter);
} }
private static void doConversion(@NotNull View main, @NotNull Context context, @NotNull UnitConverter<String> converter) { private static void doConversion(@Nonnull View main, @Nonnull Context context, @Nonnull UnitConverter<String> converter) {
final EditText fromEditText = (EditText) main.findViewById(R.id.units_from); final EditText fromEditText = (EditText) main.findViewById(R.id.units_from);
final EditText toEditText = (EditText) main.findViewById(R.id.units_to); final EditText toEditText = (EditText) main.findViewById(R.id.units_to);
@ -174,46 +174,46 @@ public class UnitConverterViewBuilder implements ViewBuilder<View> {
} }
} }
@NotNull @Nonnull
private static Unit<String> getToUnit(@NotNull View main) { private static Unit<String> getToUnit(@Nonnull View main) {
final EditText toUnits = (EditText) main.findViewById(R.id.units_to); final EditText toUnits = (EditText) main.findViewById(R.id.units_to);
return UnitImpl.newInstance(toUnits.getText().toString(), getToUnitType(main)); return UnitImpl.newInstance(toUnits.getText().toString(), getToUnitType(main));
} }
@NotNull @Nonnull
private static UnitType<String> getToUnitType(@NotNull View main) { private static UnitType<String> getToUnitType(@Nonnull View main) {
final Spinner toSpinner = (Spinner) main.findViewById(R.id.unit_types_to); final Spinner toSpinner = (Spinner) main.findViewById(R.id.unit_types_to);
return (UnitType<String>) toSpinner.getSelectedItem(); return (UnitType<String>) toSpinner.getSelectedItem();
} }
@NotNull @Nonnull
private static Unit<String> getFromUnit(@NotNull View main) { private static Unit<String> getFromUnit(@Nonnull View main) {
final EditText fromUnits = (EditText) main.findViewById(R.id.units_from); final EditText fromUnits = (EditText) main.findViewById(R.id.units_from);
return UnitImpl.newInstance(fromUnits.getText().toString(), getFromUnitType(main)); return UnitImpl.newInstance(fromUnits.getText().toString(), getFromUnitType(main));
} }
@NotNull @Nonnull
private static UnitType<String> getFromUnitType(@NotNull View main) { private static UnitType<String> getFromUnitType(@Nonnull View main) {
final Spinner fromSpinner = (Spinner) main.findViewById(R.id.unit_types_from); final Spinner fromSpinner = (Spinner) main.findViewById(R.id.unit_types_from);
return (UnitType<String>) fromSpinner.getSelectedItem(); return (UnitType<String>) fromSpinner.getSelectedItem();
} }
public static class CustomButtonData { public static class CustomButtonData {
@NotNull @Nonnull
private String text; private String text;
@NotNull @Nonnull
private CustomButtonOnClickListener clickListener; private CustomButtonOnClickListener clickListener;
public CustomButtonData(@NotNull String text, @NotNull CustomButtonOnClickListener clickListener) { public CustomButtonData(@Nonnull String text, @Nonnull CustomButtonOnClickListener clickListener) {
this.text = text; this.text = text;
this.clickListener = clickListener; this.clickListener = clickListener;
} }
} }
public static interface CustomButtonOnClickListener { public static interface CustomButtonOnClickListener {
void onClick(@NotNull Unit<String> fromUnits, @NotNull Unit<String> toUnits); void onClick(@Nonnull Unit<String> fromUnits, @Nonnull Unit<String> toUnits);
} }
} }

View File

@ -2,4 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.solovyev.android.calculator.onscreen" package="org.solovyev.android.calculator.onscreen"
android:versionCode="1" android:versionCode="1"
android:versionName="1.0" /> android:versionName="1.0">
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="17" />
</manifest>

View File

@ -5,7 +5,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.CalculatorPreferences; import org.solovyev.android.calculator.CalculatorPreferences;
/** /**
@ -19,8 +19,8 @@ public final class CalculatorOnscreenBroadcastReceiver extends BroadcastReceiver
} }
@Override @Override
public void onReceive(@NotNull Context context, public void onReceive(@Nonnull Context context,
@NotNull Intent intent) { @Nonnull Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
if (CalculatorPreferences.OnscreenCalculator.startOnBoot.getPreferenceNoError(preferences)) { if (CalculatorPreferences.OnscreenCalculator.startOnBoot.getPreferenceNoError(preferences)) {

View File

@ -9,8 +9,8 @@ import android.os.IBinder;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.WindowManager; import android.view.WindowManager;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.Views; import org.solovyev.android.Views;
import org.solovyev.android.calculator.CalculatorDisplayViewState; import org.solovyev.android.calculator.CalculatorDisplayViewState;
import org.solovyev.android.calculator.CalculatorEditorViewState; import org.solovyev.android.calculator.CalculatorEditorViewState;
@ -29,14 +29,14 @@ public class CalculatorOnscreenService extends Service implements ExternalCalcul
private static final int NOTIFICATION_ID = 9031988; // my birthday =) private static final int NOTIFICATION_ID = 9031988; // my birthday =)
@NotNull @Nonnull
private final ExternalCalculatorIntentHandler intentHandler = new DefaultExternalCalculatorIntentHandler(this); private final ExternalCalculatorIntentHandler intentHandler = new DefaultExternalCalculatorIntentHandler(this);
public static final Class<CalculatorOnscreenBroadcastReceiver> INTENT_LISTENER_CLASS = CalculatorOnscreenBroadcastReceiver.class; public static final Class<CalculatorOnscreenBroadcastReceiver> INTENT_LISTENER_CLASS = CalculatorOnscreenBroadcastReceiver.class;
@Nullable @Nullable
private static String cursorColor; private static String cursorColor;
@NotNull @Nonnull
private CalculatorOnscreenView view; private CalculatorOnscreenView view;
private boolean compatibilityStart = true; private boolean compatibilityStart = true;
@ -89,7 +89,7 @@ public class CalculatorOnscreenService extends Service implements ExternalCalcul
Locator.getInstance().getExternalListenersContainer().addExternalListener(getIntentListenerClass()); Locator.getInstance().getExternalListenersContainer().addExternalListener(getIntentListenerClass());
} }
@NotNull @Nonnull
private static Class<?> getIntentListenerClass() { private static Class<?> getIntentListenerClass() {
return INTENT_LISTENER_CLASS; return INTENT_LISTENER_CLASS;
} }
@ -108,13 +108,13 @@ public class CalculatorOnscreenService extends Service implements ExternalCalcul
} }
@Override @Override
public void updateState(@NotNull Context context, @NotNull CalculatorEditorViewState editorState, @NotNull CalculatorDisplayViewState displayState) { public void updateState(@Nonnull Context context, @Nonnull CalculatorEditorViewState editorState, @Nonnull CalculatorDisplayViewState displayState) {
view.updateDisplayState(displayState); view.updateDisplayState(displayState);
view.updateEditorState(editorState); view.updateEditorState(editorState);
} }
@NotNull @Nonnull
private static String getCursorColor(@NotNull Context context) { private static String getCursorColor(@Nonnull Context context) {
if (cursorColor == null) { if (cursorColor == null) {
cursorColor = Integer.toHexString(context.getResources().getColor(R.color.cpp_onscreen_cursor_color)).substring(2); cursorColor = Integer.toHexString(context.getResources().getColor(R.color.cpp_onscreen_cursor_color)).substring(2);
} }
@ -166,7 +166,7 @@ public class CalculatorOnscreenService extends Service implements ExternalCalcul
} }
} }
private boolean isInitIntent(@NotNull Intent intent) { private boolean isInitIntent(@Nonnull Intent intent) {
return intent.getAction().equals(AndroidExternalListenersContainer.INIT_ACTION); return intent.getAction().equals(AndroidExternalListenersContainer.INIT_ACTION);
} }
@ -200,19 +200,19 @@ public class CalculatorOnscreenService extends Service implements ExternalCalcul
nm.notify(NOTIFICATION_ID, builder.getNotification()); nm.notify(NOTIFICATION_ID, builder.getNotification());
} }
public static void showNotification(@NotNull Context context) { public static void showNotification(@Nonnull Context context) {
final Intent intent = new Intent(AndroidExternalListenersContainer.INIT_ACTION); final Intent intent = new Intent(AndroidExternalListenersContainer.INIT_ACTION);
intent.setClass(context, getIntentListenerClass()); intent.setClass(context, getIntentListenerClass());
context.sendBroadcast(intent); context.sendBroadcast(intent);
} }
public static void showOnscreenView(@NotNull Context context) { public static void showOnscreenView(@Nonnull Context context) {
final Intent intent = createShowOnscreenViewIntent(context); final Intent intent = createShowOnscreenViewIntent(context);
context.sendBroadcast(intent); context.sendBroadcast(intent);
} }
@NotNull @Nonnull
private static Intent createShowOnscreenViewIntent(@NotNull Context context) { private static Intent createShowOnscreenViewIntent(@Nonnull Context context) {
final Intent intent = new Intent(AndroidExternalListenersContainer.INIT_ACTION); final Intent intent = new Intent(AndroidExternalListenersContainer.INIT_ACTION);
intent.setClass(context, getIntentListenerClass()); intent.setClass(context, getIntentListenerClass());
intent.putExtra(AndroidExternalListenersContainer.INIT_ACTION_CREATE_VIEW_EXTRA, true); intent.putExtra(AndroidExternalListenersContainer.INIT_ACTION_CREATE_VIEW_EXTRA, true);

View File

@ -5,7 +5,7 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.Android; import org.solovyev.android.Android;
import org.solovyev.android.App; import org.solovyev.android.App;
import org.solovyev.android.calculator.AbstractFixableError; import org.solovyev.android.calculator.AbstractFixableError;
@ -38,7 +38,7 @@ public class CalculatorOnscreenStartActivity extends Activity {
public static class RemoveIconFixableError extends AbstractFixableError { public static class RemoveIconFixableError extends AbstractFixableError {
public RemoveIconFixableError(@NotNull Context context) { public RemoveIconFixableError(@Nonnull Context context) {
super(context.getString(R.string.cpp_onscreen_remove_icon_button_text)); super(context.getString(R.string.cpp_onscreen_remove_icon_button_text));
} }

View File

@ -11,8 +11,8 @@ import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.ImageView; import android.widget.ImageView;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.prefs.Preference; import org.solovyev.android.prefs.Preference;
@ -50,28 +50,28 @@ public class CalculatorOnscreenView {
********************************************************************** **********************************************************************
*/ */
@NotNull @Nonnull
private View root; private View root;
@NotNull @Nonnull
private View content; private View content;
@NotNull @Nonnull
private View header; private View header;
@NotNull @Nonnull
private AndroidCalculatorEditorView editorView; private AndroidCalculatorEditorView editorView;
@NotNull @Nonnull
private AndroidCalculatorDisplayView displayView; private AndroidCalculatorDisplayView displayView;
@NotNull @Nonnull
private Context context; private Context context;
@NotNull @Nonnull
private CalculatorOnscreenViewState state = CalculatorOnscreenViewState.newDefaultState(); private CalculatorOnscreenViewState state = CalculatorOnscreenViewState.newDefaultState();
@NotNull @Nonnull
private String cursorColor; private String cursorColor;
@Nullable @Nullable
@ -107,9 +107,9 @@ public class CalculatorOnscreenView {
private CalculatorOnscreenView() { private CalculatorOnscreenView() {
} }
public static CalculatorOnscreenView newInstance(@NotNull Context context, public static CalculatorOnscreenView newInstance(@Nonnull Context context,
@NotNull CalculatorOnscreenViewState state, @Nonnull CalculatorOnscreenViewState state,
@NotNull String cursorColor, @Nonnull String cursorColor,
@Nullable OnscreenViewListener viewListener) { @Nullable OnscreenViewListener viewListener) {
final CalculatorOnscreenView result = new CalculatorOnscreenView(); final CalculatorOnscreenView result = new CalculatorOnscreenView();
@ -136,12 +136,12 @@ public class CalculatorOnscreenView {
********************************************************************** **********************************************************************
*/ */
public void updateDisplayState(@NotNull CalculatorDisplayViewState displayState) { public void updateDisplayState(@Nonnull CalculatorDisplayViewState displayState) {
checkInit(); checkInit();
displayView.setState(displayState); displayView.setState(displayState);
} }
public void updateEditorState(@NotNull CalculatorEditorViewState editorState) { public void updateEditorState(@Nonnull CalculatorEditorViewState editorState) {
checkInit(); checkInit();
editorView.setState(editorState); editorView.setState(editorState);
} }
@ -312,13 +312,13 @@ public class CalculatorOnscreenView {
} }
} }
public static void persistState(@NotNull Context context, @NotNull CalculatorOnscreenViewState state) { public static void persistState(@Nonnull Context context, @Nonnull CalculatorOnscreenViewState state) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
viewStatePreference.putPreference(preferences, state); viewStatePreference.putPreference(preferences, state);
} }
@Nullable @Nullable
public static CalculatorOnscreenViewState readState(@NotNull Context context) { public static CalculatorOnscreenViewState readState(@Nonnull Context context) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
if (viewStatePreference.isSet(preferences)) { if (viewStatePreference.isSet(preferences)) {
return viewStatePreference.getPreference(preferences); return viewStatePreference.getPreference(preferences);
@ -344,12 +344,12 @@ public class CalculatorOnscreenView {
} }
} }
@NotNull @Nonnull
private WindowManager getWindowManager() { private WindowManager getWindowManager() {
return ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)); return ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE));
} }
@NotNull @Nonnull
public CalculatorOnscreenViewState getCurrentState(boolean useRealSize) { public CalculatorOnscreenViewState getCurrentState(boolean useRealSize) {
final WindowManager.LayoutParams params = (WindowManager.LayoutParams) root.getLayoutParams(); final WindowManager.LayoutParams params = (WindowManager.LayoutParams) root.getLayoutParams();
if (useRealSize) { if (useRealSize) {
@ -389,7 +389,7 @@ public class CalculatorOnscreenView {
********************************************************************** **********************************************************************
*/ */
@NotNull @Nonnull
private final WindowManager wm; private final WindowManager wm;
private int orientation; private int orientation;
@ -400,7 +400,7 @@ public class CalculatorOnscreenView {
private long time = 0; private long time = 0;
@NotNull @Nonnull
private final View view; private final View view;
private int displayWidth; private int displayWidth;
@ -415,8 +415,8 @@ public class CalculatorOnscreenView {
********************************************************************** **********************************************************************
*/ */
public WindowDragTouchListener(@NotNull WindowManager wm, public WindowDragTouchListener(@Nonnull WindowManager wm,
@NotNull View view) { @Nonnull View view) {
this.wm = wm; this.wm = wm;
this.view = view; this.view = view;
initDisplayParams(); initDisplayParams();
@ -503,7 +503,7 @@ public class CalculatorOnscreenView {
return δx >= DIST_EPS && δx < DIST_MAX; return δx >= DIST_EPS && δx < DIST_MAX;
} }
@NotNull @Nonnull
private static String toString(float x, float y) { private static String toString(float x, float y) {
return "(" + formatFloat(x) + ", " + formatFloat(y) + ")"; return "(" + formatFloat(x) + ", " + formatFloat(y) + ")";
} }

View File

@ -4,8 +4,8 @@ import android.content.SharedPreferences;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.util.Log; import android.util.Log;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.solovyev.android.prefs.AbstractPreference; import org.solovyev.android.prefs.AbstractPreference;
@ -23,7 +23,7 @@ public class CalculatorOnscreenViewState implements Parcelable {
private static final String TAG = CalculatorOnscreenViewState.class.getSimpleName(); private static final String TAG = CalculatorOnscreenViewState.class.getSimpleName();
public static final Parcelable.Creator<CalculatorOnscreenViewState> CREATOR = new Parcelable.Creator<CalculatorOnscreenViewState>() { public static final Parcelable.Creator<CalculatorOnscreenViewState> CREATOR = new Parcelable.Creator<CalculatorOnscreenViewState>() {
public CalculatorOnscreenViewState createFromParcel(@NotNull Parcel in) { public CalculatorOnscreenViewState createFromParcel(@Nonnull Parcel in) {
return CalculatorOnscreenViewState.fromParcel(in); return CalculatorOnscreenViewState.fromParcel(in);
} }
@ -43,8 +43,8 @@ public class CalculatorOnscreenViewState implements Parcelable {
private CalculatorOnscreenViewState() { private CalculatorOnscreenViewState() {
} }
@NotNull @Nonnull
private static CalculatorOnscreenViewState fromParcel(@NotNull Parcel in) { private static CalculatorOnscreenViewState fromParcel(@Nonnull Parcel in) {
final CalculatorOnscreenViewState result = new CalculatorOnscreenViewState(); final CalculatorOnscreenViewState result = new CalculatorOnscreenViewState();
result.width = in.readInt(); result.width = in.readInt();
result.height = in.readInt(); result.height = in.readInt();
@ -53,12 +53,12 @@ public class CalculatorOnscreenViewState implements Parcelable {
return result; return result;
} }
@NotNull @Nonnull
public static CalculatorOnscreenViewState newDefaultState() { public static CalculatorOnscreenViewState newDefaultState() {
return newInstance(200, 400, 0, 0); return newInstance(200, 400, 0, 0);
} }
@NotNull @Nonnull
public static CalculatorOnscreenViewState newInstance(int width, int height, int x, int y) { public static CalculatorOnscreenViewState newInstance(int width, int height, int x, int y) {
final CalculatorOnscreenViewState result = new CalculatorOnscreenViewState(); final CalculatorOnscreenViewState result = new CalculatorOnscreenViewState();
result.width = width; result.width = width;
@ -106,7 +106,7 @@ public class CalculatorOnscreenViewState implements Parcelable {
} }
@Override @Override
public void writeToParcel(@NotNull Parcel out, int flags) { public void writeToParcel(@Nonnull Parcel out, int flags) {
out.writeInt(width); out.writeInt(width);
out.writeInt(height); out.writeInt(height);
out.writeInt(x); out.writeInt(x);
@ -125,13 +125,13 @@ public class CalculatorOnscreenViewState implements Parcelable {
public static class Preference extends AbstractPreference<CalculatorOnscreenViewState> { public static class Preference extends AbstractPreference<CalculatorOnscreenViewState> {
public Preference(@NotNull String key, @Nullable CalculatorOnscreenViewState defaultValue) { public Preference(@Nonnull String key, @Nullable CalculatorOnscreenViewState defaultValue) {
super(key, defaultValue); super(key, defaultValue);
} }
@Nullable @Nullable
@Override @Override
protected CalculatorOnscreenViewState getPersistedValue(@NotNull SharedPreferences preferences) { protected CalculatorOnscreenViewState getPersistedValue(@Nonnull SharedPreferences preferences) {
try { try {
final CalculatorOnscreenViewState result = new CalculatorOnscreenViewState(); final CalculatorOnscreenViewState result = new CalculatorOnscreenViewState();
final JSONObject jsonObject = new JSONObject(preferences.getString(getKey(), "{}")); final JSONObject jsonObject = new JSONObject(preferences.getString(getKey(), "{}"));
@ -149,7 +149,7 @@ public class CalculatorOnscreenViewState implements Parcelable {
} }
@Override @Override
protected void putPersistedValue(@NotNull SharedPreferences.Editor editor, @NotNull CalculatorOnscreenViewState value) { protected void putPersistedValue(@Nonnull SharedPreferences.Editor editor, @Nonnull CalculatorOnscreenViewState value) {
final Map<String, Object> properties = new HashMap<String, Object>(); final Map<String, Object> properties = new HashMap<String, Object>();
properties.put("width", value.getWidth()); properties.put("width", value.getWidth());
properties.put("height", value.getHeight()); properties.put("height", value.getHeight());

View File

@ -2,4 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.solovyev.android.calculator.widget" package="org.solovyev.android.calculator.widget"
android:versionCode="1" android:versionCode="1"
android:versionName="1.0" /> android:versionName="1.0">
<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="17" />
</manifest>

View File

@ -8,12 +8,13 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.text.Html; import android.text.Html;
import android.widget.RemoteViews; import android.widget.RemoteViews;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.external.ExternalCalculatorIntentHandler; import org.solovyev.android.calculator.external.ExternalCalculatorIntentHandler;
import org.solovyev.android.calculator.external.ExternalCalculatorStateUpdater; import org.solovyev.android.calculator.external.ExternalCalculatorStateUpdater;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/** /**
* User: Solovyev_S * User: Solovyev_S
* Date: 19.10.12 * Date: 19.10.12
@ -37,7 +38,7 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem
@Nullable @Nullable
private String cursorColor; private String cursorColor;
@NotNull @Nonnull
private ExternalCalculatorIntentHandler intentHandler = new CalculatorWidgetIntentHandler(this); private ExternalCalculatorIntentHandler intentHandler = new CalculatorWidgetIntentHandler(this);
@ -70,8 +71,8 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem
getCursorColor(context); getCursorColor(context);
} }
@NotNull @Nonnull
private String getCursorColor(@NotNull Context context) { private String getCursorColor(@Nonnull Context context) {
if (cursorColor == null) { if (cursorColor == null) {
cursorColor = Integer.toHexString(context.getResources().getColor(R.color.cpp_widget_cursor_color)).substring(2); cursorColor = Integer.toHexString(context.getResources().getColor(R.color.cpp_widget_cursor_color)).substring(2);
} }
@ -79,34 +80,34 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem
} }
@Override @Override
public void onUpdate(@NotNull Context context, public void onUpdate(@Nonnull Context context,
@NotNull AppWidgetManager appWidgetManager, @Nonnull AppWidgetManager appWidgetManager,
@NotNull int[] appWidgetIds) { @Nonnull int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds); super.onUpdate(context, appWidgetManager, appWidgetIds);
updateWidget(context, appWidgetManager, appWidgetIds, Locator.getInstance().getEditor().getViewState(), Locator.getInstance().getDisplay().getViewState()); updateWidget(context, appWidgetManager, appWidgetIds, Locator.getInstance().getEditor().getViewState(), Locator.getInstance().getDisplay().getViewState());
} }
@Override @Override
public void updateState(@NotNull Context context, public void updateState(@Nonnull Context context,
@NotNull CalculatorEditorViewState editorState, @Nonnull CalculatorEditorViewState editorState,
@NotNull CalculatorDisplayViewState displayState) { @Nonnull CalculatorDisplayViewState displayState) {
final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
final int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, getComponentClass())); final int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, getComponentClass()));
updateWidget(context, appWidgetManager, appWidgetIds, editorState, displayState); updateWidget(context, appWidgetManager, appWidgetIds, editorState, displayState);
} }
@NotNull @Nonnull
protected Class<? extends AbstractCalculatorWidgetProvider> getComponentClass() { protected Class<? extends AbstractCalculatorWidgetProvider> getComponentClass() {
return this.getClass(); return this.getClass();
} }
private void updateWidget(@NotNull Context context, private void updateWidget(@Nonnull Context context,
@NotNull AppWidgetManager appWidgetManager, @Nonnull AppWidgetManager appWidgetManager,
@NotNull int[] appWidgetIds, @Nonnull int[] appWidgetIds,
@NotNull CalculatorEditorViewState editorState, @Nonnull CalculatorEditorViewState editorState,
@NotNull CalculatorDisplayViewState displayState) { @Nonnull CalculatorDisplayViewState displayState) {
for (int appWidgetId : appWidgetIds) { for (int appWidgetId : appWidgetIds) {
final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout); final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
@ -136,7 +137,7 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem
this.intentHandler.onIntent(context, intent); this.intentHandler.onIntent(context, intent);
} }
private void updateDisplayState(@NotNull Context context, @NotNull RemoteViews views, @NotNull CalculatorDisplayViewState displayState) { private void updateDisplayState(@Nonnull Context context, @Nonnull RemoteViews views, @Nonnull CalculatorDisplayViewState displayState) {
if (displayState.isValid()) { if (displayState.isValid()) {
views.setTextViewText(R.id.calculator_display, displayState.getText()); views.setTextViewText(R.id.calculator_display, displayState.getText());
views.setTextColor(R.id.calculator_display, context.getResources().getColor(R.color.cpp_default_text_color)); views.setTextColor(R.id.calculator_display, context.getResources().getColor(R.color.cpp_default_text_color));
@ -145,7 +146,7 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem
} }
} }
private void updateEditorState(@NotNull Context context, @NotNull RemoteViews views, @NotNull CalculatorEditorViewState editorState) { private void updateEditorState(@Nonnull Context context, @Nonnull RemoteViews views, @Nonnull CalculatorEditorViewState editorState) {
String text = editorState.getText(); String text = editorState.getText();
CharSequence newText = text; CharSequence newText = text;

View File

@ -2,7 +2,7 @@ package org.solovyev.android.calculator.widget;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.CalculatorButton; import org.solovyev.android.calculator.CalculatorButton;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.external.DefaultExternalCalculatorIntentHandler; import org.solovyev.android.calculator.external.DefaultExternalCalculatorIntentHandler;
@ -15,12 +15,12 @@ import org.solovyev.android.calculator.external.ExternalCalculatorStateUpdater;
*/ */
public class CalculatorWidgetIntentHandler extends DefaultExternalCalculatorIntentHandler { public class CalculatorWidgetIntentHandler extends DefaultExternalCalculatorIntentHandler {
public CalculatorWidgetIntentHandler(@NotNull ExternalCalculatorStateUpdater stateUpdater) { public CalculatorWidgetIntentHandler(@Nonnull ExternalCalculatorStateUpdater stateUpdater) {
super(stateUpdater); super(stateUpdater);
} }
@Override @Override
public void onIntent(@NotNull Context context, @NotNull Intent intent) { public void onIntent(@Nonnull Context context, @Nonnull Intent intent) {
super.onIntent(context, intent); super.onIntent(context, intent);
if (AbstractCalculatorWidgetProvider.BUTTON_PRESSED_ACTION.equals(intent.getAction())) { if (AbstractCalculatorWidgetProvider.BUTTON_PRESSED_ACTION.equals(intent.getAction())) {

View File

@ -1,277 +1,176 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="117" android:versionName="1.6.3-SNAPSHOT" package="org.solovyev.android.calculator">
android:installLocation="auto"
android:versionCode="117"
android:versionName="1.6.2"
package="org.solovyev.android.calculator">
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="com.android.vending.BILLING" /> <uses-permission android:name="com.android.vending.BILLING"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!--TODO: REMOVE IN PRODUCTION--> <!--TODO: REMOVE IN PRODUCTION-->
<!--<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>--> <!--<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>-->
<!-- for onscreen --> <!-- for onscreen -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<supports-screens android:smallScreens="true" /> <supports-screens android:smallScreens="true"/>
<supports-screens android:normalScreens="true" /> <supports-screens android:normalScreens="true"/>
<supports-screens android:largeScreens="true" /> <supports-screens android:largeScreens="true"/>
<supports-screens android:xlargeScreens="true" /> <supports-screens android:xlargeScreens="true"/>
<supports-screens android:anyDensity="true" /> <supports-screens android:anyDensity="true"/>
<uses-sdk <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="17"/>
android:minSdkVersion="4"
android:targetSdkVersion="8" />
<application <application android:allowBackup="true" android:debuggable="true" android:hardwareAccelerated="false" android:icon="@drawable/icon" android:label="@string/c_app_name" android:name=".CalculatorApplication" android:theme="@style/cpp_metro_blue_theme">
android:debuggable="false"
android:hardwareAccelerated="false"
android:icon="@drawable/icon"
android:label="@string/c_app_name"
android:name=".CalculatorApplication"
android:theme="@style/cpp_metro_blue_theme">
<activity <activity android:clearTaskOnLaunch="true" android:label="@string/c_app_name" android:name=".CalculatorActivity" android:windowSoftInputMode="adjustPan">
android:clearTaskOnLaunch="true"
android:label="@string/c_app_name"
android:name=".CalculatorActivity"
android:windowSoftInputMode="adjustPan">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity android:clearTaskOnLaunch="true" android:label="@string/c_app_name" android:name=".CalculatorActivityMobile" android:windowSoftInputMode="adjustPan"/>
android:clearTaskOnLaunch="true"
android:label="@string/c_app_name"
android:name=".CalculatorActivityMobile"
android:windowSoftInputMode="adjustPan" />
<!-- settings must use action bar icon--> <!-- settings must use action bar icon-->
<activity <activity android:icon="@drawable/ab_icon" android:label="@string/c_app_settings" android:name=".preferences.CalculatorPreferencesActivity"/>
android:icon="@drawable/ab_icon"
android:label="@string/c_app_settings"
android:name=".preferences.CalculatorPreferencesActivity" />
<activity <activity android:label="@string/c_history" android:name=".history.CalculatorHistoryActivity"/>
android:label="@string/c_history"
android:name=".history.CalculatorHistoryActivity" />
<activity <activity android:excludeFromRecents="true" android:finishOnTaskLaunch="true" android:label="@string/calculation_messages_dialog_title" android:launchMode="singleTask" android:name=".FixableMessagesDialog" android:theme="@style/cpp_gray_dialog_theme"/>
android:excludeFromRecents="true"
android:finishOnTaskLaunch="true"
android:label="@string/calculation_messages_dialog_title"
android:launchMode="singleTask"
android:name=".FixableMessagesDialog"
android:theme="@style/cpp_gray_dialog_theme" />
<activity <activity android:label="@string/c_about" android:name=".about.CalculatorAboutActivity"/>
android:label="@string/c_about"
android:name=".about.CalculatorAboutActivity" />
<activity <activity android:label="@string/c_help" android:name=".help.CalculatorHelpActivity"/>
android:label="@string/c_help"
android:name=".help.CalculatorHelpActivity" />
<activity <activity android:label="@string/c_functions" android:name=".math.edit.CalculatorFunctionsActivity"/>
android:label="@string/c_functions"
android:name=".math.edit.CalculatorFunctionsActivity" />
<activity <activity android:label="@string/c_operators" android:name=".math.edit.CalculatorOperatorsActivity"/>
android:label="@string/c_operators"
android:name=".math.edit.CalculatorOperatorsActivity" />
<activity <activity android:label="@string/c_vars_and_constants" android:name=".math.edit.CalculatorVarsActivity"/>
android:label="@string/c_vars_and_constants"
android:name=".math.edit.CalculatorVarsActivity" />
<activity <activity android:label="@string/c_plot_graph" android:name=".plot.CalculatorPlotActivity"/>
android:label="@string/c_plot_graph" <activity android:label="@string/cpp_plot_functions" android:launchMode="singleTop" android:name=".plot.CalculatorPlotFunctionsActivity" android:theme="@style/cpp_gray_dialog_theme"/>
android:name=".plot.CalculatorPlotActivity" /> <activity android:label="@string/cpp_plot_function_settings" android:launchMode="singleTop" android:name=".plot.CalculatorPlotFunctionSettingsActivity" android:theme="@style/cpp_gray_dialog_theme"/>
<activity <activity android:label="@string/cpp_plot_range" android:launchMode="singleTop" android:name=".plot.CalculatorPlotRangeActivity" android:theme="@style/cpp_gray_dialog_theme"/>
android:label="@string/cpp_plot_functions"
android:launchMode="singleTop"
android:name=".plot.CalculatorPlotFunctionsActivity"
android:theme="@style/cpp_gray_dialog_theme" />
<activity
android:label="@string/cpp_plot_function_settings"
android:launchMode="singleTop"
android:name=".plot.CalculatorPlotFunctionSettingsActivity"
android:theme="@style/cpp_gray_dialog_theme" />
<activity
android:label="@string/cpp_plot_range"
android:launchMode="singleTop"
android:name=".plot.CalculatorPlotRangeActivity"
android:theme="@style/cpp_gray_dialog_theme" />
<activity <activity android:label="@string/cpp_purchase_title" android:launchMode="singleTop" android:name=".preferences.CalculatorPurchaseDialogActivity" android:theme="@style/cpp_gray_dialog_theme"/>
android:label="@string/cpp_purchase_title"
android:launchMode="singleTop"
android:name=".preferences.CalculatorPurchaseDialogActivity"
android:theme="@style/cpp_gray_dialog_theme" />
<activity <activity android:launchMode="singleTop" android:name=".CalculatorDialogActivity" android:theme="@style/cpp_gray_dialog_theme"/>
android:launchMode="singleTop"
android:name=".CalculatorDialogActivity"
android:theme="@style/cpp_gray_dialog_theme" />
<!-- todo serso: strings--> <!-- todo serso: strings-->
<activity <activity android:label="@string/c_plot_graph" android:name=".matrix.CalculatorMatrixActivity"/>
android:label="@string/c_plot_graph"
android:name=".matrix.CalculatorMatrixActivity" />
<activity <activity android:name=".widget.CalculatorWidgetConfigurationActivity" android:theme="@style/cpp_metro_blue_theme">
android:name=".widget.CalculatorWidgetConfigurationActivity"
android:theme="@style/cpp_metro_blue_theme">
<intent-filter> <intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" /> <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
</intent-filter> </intent-filter>
</activity> </activity>
<!-- settings must use action bar icon--> <!-- settings must use action bar icon-->
<activity <activity android:icon="@drawable/ab_icon" android:label="@string/c_settings" android:name=".plot.CalculatorPlotPreferenceActivity"/>
android:icon="@drawable/ab_icon"
android:label="@string/c_settings"
android:name=".plot.CalculatorPlotPreferenceActivity" />
<!-- ONSCREEN CONFIG --> <!-- ONSCREEN CONFIG -->
<activity <activity android:icon="@drawable/icon_onscreen" android:label="@string/c_app_name_on_screen" android:launchMode="singleInstance" android:name=".onscreen.CalculatorOnscreenStartActivity" android:theme="@style/cpp_gray_dialog_theme">
android:icon="@drawable/icon_onscreen"
android:label="@string/c_app_name_on_screen"
android:launchMode="singleInstance"
android:name=".onscreen.CalculatorOnscreenStartActivity"
android:theme="@style/cpp_gray_dialog_theme">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </activity>
<service android:name=".onscreen.CalculatorOnscreenService"> <service android:name=".onscreen.CalculatorOnscreenService">
<intent-filter> <intent-filter>
<action android:name="org.solovyev.android.calculator.INIT" /> <action android:name="org.solovyev.android.calculator.INIT"/>
<action android:name="org.solovyev.android.calculator.EDITOR_STATE_CHANGED" /> <action android:name="org.solovyev.android.calculator.EDITOR_STATE_CHANGED"/>
<action android:name="org.solovyev.android.calculator.DISPLAY_STATE_CHANGED" /> <action android:name="org.solovyev.android.calculator.DISPLAY_STATE_CHANGED"/>
</intent-filter> </intent-filter>
</service> </service>
<receiver android:name=".onscreen.CalculatorOnscreenBroadcastReceiver"> <receiver android:name=".onscreen.CalculatorOnscreenBroadcastReceiver">
<intent-filter> <intent-filter>
<action android:name="org.solovyev.android.calculator.INIT" /> <action android:name="org.solovyev.android.calculator.INIT"/>
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="org.solovyev.android.calculator.EDITOR_STATE_CHANGED" /> <action android:name="org.solovyev.android.calculator.EDITOR_STATE_CHANGED"/>
<action android:name="org.solovyev.android.calculator.DISPLAY_STATE_CHANGED" /> <action android:name="org.solovyev.android.calculator.DISPLAY_STATE_CHANGED"/>
</intent-filter> </intent-filter>
</receiver> </receiver>
<!-- WIDGET CONFIG --> <!-- WIDGET CONFIG -->
<receiver <receiver android:icon="@drawable/icon" android:label="@string/c_app_widget_3x3_name" android:name=".widget.CalculatorWidgetProvider">
android:icon="@drawable/icon"
android:label="@string/c_app_widget_3x3_name"
android:name=".widget.CalculatorWidgetProvider">
<intent-filter> <intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
<action android:name="org.solovyev.android.calculator.INIT" /> <action android:name="org.solovyev.android.calculator.INIT"/>
<action android:name="org.solovyev.android.calculator.EDITOR_STATE_CHANGED" /> <action android:name="org.solovyev.android.calculator.EDITOR_STATE_CHANGED"/>
<action android:name="org.solovyev.android.calculator.DISPLAY_STATE_CHANGED" /> <action android:name="org.solovyev.android.calculator.DISPLAY_STATE_CHANGED"/>
<action android:name="org.solovyev.android.calculator.widget.BUTTON_PRESSED" /> <action android:name="org.solovyev.android.calculator.widget.BUTTON_PRESSED"/>
</intent-filter> </intent-filter>
<meta-data <meta-data android:name="android.appwidget.provider" android:resource="@xml/calculator_widget_info_3x3"/>
android:name="android.appwidget.provider"
android:resource="@xml/calculator_widget_info_3x3" />
</receiver> </receiver>
<receiver <receiver android:icon="@drawable/icon" android:label="@string/c_app_widget_3x4_name" android:name=".widget.CalculatorWidgetProvider3x4">
android:icon="@drawable/icon"
android:label="@string/c_app_widget_3x4_name"
android:name=".widget.CalculatorWidgetProvider3x4">
<intent-filter> <intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
<action android:name="org.solovyev.android.calculator.INIT" /> <action android:name="org.solovyev.android.calculator.INIT"/>
<action android:name="org.solovyev.android.calculator.EDITOR_STATE_CHANGED" /> <action android:name="org.solovyev.android.calculator.EDITOR_STATE_CHANGED"/>
<action android:name="org.solovyev.android.calculator.DISPLAY_STATE_CHANGED" /> <action android:name="org.solovyev.android.calculator.DISPLAY_STATE_CHANGED"/>
<action android:name="org.solovyev.android.calculator.widget.BUTTON_PRESSED" /> <action android:name="org.solovyev.android.calculator.widget.BUTTON_PRESSED"/>
</intent-filter> </intent-filter>
<meta-data <meta-data android:name="android.appwidget.provider" android:resource="@xml/calculator_widget_info_3x4"/>
android:name="android.appwidget.provider"
android:resource="@xml/calculator_widget_info_3x4" />
</receiver> </receiver>
<receiver <receiver android:icon="@drawable/icon" android:label="@string/c_app_widget_4x4_name" android:name=".widget.CalculatorWidgetProvider4x4">
android:icon="@drawable/icon"
android:label="@string/c_app_widget_4x4_name"
android:name=".widget.CalculatorWidgetProvider4x4">
<intent-filter> <intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
<action android:name="org.solovyev.android.calculator.INIT" /> <action android:name="org.solovyev.android.calculator.INIT"/>
<action android:name="org.solovyev.android.calculator.EDITOR_STATE_CHANGED" /> <action android:name="org.solovyev.android.calculator.EDITOR_STATE_CHANGED"/>
<action android:name="org.solovyev.android.calculator.DISPLAY_STATE_CHANGED" /> <action android:name="org.solovyev.android.calculator.DISPLAY_STATE_CHANGED"/>
<action android:name="org.solovyev.android.calculator.widget.BUTTON_PRESSED" /> <action android:name="org.solovyev.android.calculator.widget.BUTTON_PRESSED"/>
</intent-filter> </intent-filter>
<meta-data <meta-data android:name="android.appwidget.provider" android:resource="@xml/calculator_widget_info_4x4"/>
android:name="android.appwidget.provider"
android:resource="@xml/calculator_widget_info_4x4" />
</receiver> </receiver>
<receiver <receiver android:icon="@drawable/icon" android:label="@string/c_app_widget_4x5_name" android:name=".widget.CalculatorWidgetProvider4x5">
android:icon="@drawable/icon"
android:label="@string/c_app_widget_4x5_name"
android:name=".widget.CalculatorWidgetProvider4x5">
<intent-filter> <intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> <action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
<action android:name="org.solovyev.android.calculator.INIT" /> <action android:name="org.solovyev.android.calculator.INIT"/>
<action android:name="org.solovyev.android.calculator.EDITOR_STATE_CHANGED" /> <action android:name="org.solovyev.android.calculator.EDITOR_STATE_CHANGED"/>
<action android:name="org.solovyev.android.calculator.DISPLAY_STATE_CHANGED" /> <action android:name="org.solovyev.android.calculator.DISPLAY_STATE_CHANGED"/>
<action android:name="org.solovyev.android.calculator.widget.BUTTON_PRESSED" /> <action android:name="org.solovyev.android.calculator.widget.BUTTON_PRESSED"/>
</intent-filter> </intent-filter>
<meta-data <meta-data android:name="android.appwidget.provider" android:resource="@xml/calculator_widget_info_4x5"/>
android:name="android.appwidget.provider"
android:resource="@xml/calculator_widget_info_4x5" />
</receiver> </receiver>
<!-- ADMOB + BILLING CONFIG --> <!-- ADMOB + BILLING CONFIG -->
<activity <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:name="com.google.ads.AdActivity"/>
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:name="com.google.ads.AdActivity" />
<service android:name="net.robotmedia.billing.BillingService" /> <service android:name="net.robotmedia.billing.BillingService"/>
<receiver android:name="net.robotmedia.billing.BillingReceiver"> <receiver android:name="net.robotmedia.billing.BillingReceiver">
<intent-filter> <intent-filter>
<action android:name="com.android.vending.billing.IN_APP_NOTIFY" /> <action android:name="com.android.vending.billing.IN_APP_NOTIFY"/>
<action android:name="com.android.vending.billing.RESPONSE_CODE" /> <action android:name="com.android.vending.billing.RESPONSE_CODE"/>
<action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED" /> <action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED"/>
</intent-filter> </intent-filter>
</receiver> </receiver>
<!-- ACRA CONFIG --> <!-- ACRA CONFIG -->
<activity <activity android:excludeFromRecents="true" android:finishOnTaskLaunch="true" android:launchMode="singleInstance" android:name="org.acra.CrashReportDialog" android:theme="@style/Theme.Sherlock.Dialog"/>
android:excludeFromRecents="true"
android:finishOnTaskLaunch="true"
android:launchMode="singleInstance"
android:name="org.acra.CrashReportDialog"
android:theme="@style/Theme.Sherlock.Dialog" />
</application> </application>
</manifest> </manifest>

View File

@ -122,15 +122,10 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.intellij</groupId>
<artifactId>annotations</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.pivotallabs</groupId> <groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId> <artifactId>robolectric</artifactId>
<version>1.1</version> <version>1.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>

View File

@ -9,8 +9,8 @@ import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.history.CalculatorHistoryState; import org.solovyev.android.calculator.history.CalculatorHistoryState;
import org.solovyev.android.calculator.view.AngleUnitsButton; import org.solovyev.android.calculator.view.AngleUnitsButton;
import org.solovyev.android.calculator.view.NumeralBasesButton; import org.solovyev.android.calculator.view.NumeralBasesButton;
@ -33,29 +33,29 @@ import java.util.List;
*/ */
public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSharedPreferenceChangeListener { public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSharedPreferenceChangeListener {
@NotNull @Nonnull
private CalculatorPreferences.Gui.Layout layout; private CalculatorPreferences.Gui.Layout layout;
@NotNull @Nonnull
private CalculatorPreferences.Gui.Theme theme; private CalculatorPreferences.Gui.Theme theme;
@Nullable @Nullable
private Vibrator vibrator; private Vibrator vibrator;
@NotNull @Nonnull
private final JListeners<DragPreferencesChangeListener> dpclRegister = Listeners.newHardRefListeners(); private final JListeners<DragPreferencesChangeListener> dpclRegister = Listeners.newHardRefListeners();
@NotNull @Nonnull
private String logTag = "CalculatorActivity"; private String logTag = "CalculatorActivity";
protected AbstractCalculatorHelper() { protected AbstractCalculatorHelper() {
} }
protected AbstractCalculatorHelper(@NotNull String logTag) { protected AbstractCalculatorHelper(@Nonnull String logTag) {
this.logTag = logTag; this.logTag = logTag;
} }
protected void onCreate(@NotNull Activity activity) { protected void onCreate(@Nonnull Activity activity) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
vibrator = (Vibrator) activity.getSystemService(Activity.VIBRATOR_SERVICE); vibrator = (Vibrator) activity.getSystemService(Activity.VIBRATOR_SERVICE);
@ -71,15 +71,15 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
} }
} }
public void logDebug(@NotNull String message) { public void logDebug(@Nonnull String message) {
Log.d(logTag, message); Log.d(logTag, message);
} }
public void logError(@NotNull String message) { public void logError(@Nonnull String message) {
Log.e(logTag, message); Log.e(logTag, message);
} }
public void processButtons(@NotNull final Activity activity, @NotNull View root) { public void processButtons(@Nonnull final Activity activity, @Nonnull View root) {
dpclRegister.removeListeners(); dpclRegister.removeListeners();
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
@ -97,7 +97,7 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
if (subtractionButton != null) { if (subtractionButton != null) {
subtractionButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new SimpleOnDragListener.DragProcessor() { subtractionButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new SimpleOnDragListener.DragProcessor() {
@Override @Override
public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) { public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull Point2d startPoint2d, @Nonnull MotionEvent motionEvent) {
if (dragDirection == DragDirection.down) { if (dragDirection == DragDirection.down) {
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_operators, null); Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_operators, null);
return true; return true;
@ -175,7 +175,7 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
NumeralBaseButtons.toggleNumericDigits(activity, preferences); NumeralBaseButtons.toggleNumericDigits(activity, preferences);
} }
private void toggleButtonDirectionText(@NotNull View root, int id, boolean showDirectionText, @NotNull DragDirection... dragDirections) { private void toggleButtonDirectionText(@Nonnull View root, int id, boolean showDirectionText, @Nonnull DragDirection... dragDirections) {
final View v = getButton(root, id); final View v = getButton(root, id);
if (v instanceof DirectionDragButton) { if (v instanceof DirectionDragButton) {
final DirectionDragButton button = (DirectionDragButton) v; final DirectionDragButton button = (DirectionDragButton) v;
@ -185,13 +185,13 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
} }
} }
@NotNull @Nonnull
private Calculator getCalculator() { private Calculator getCalculator() {
return Locator.getInstance().getCalculator(); return Locator.getInstance().getCalculator();
} }
private void setOnDragListeners(@NotNull View root, @NotNull SimpleOnDragListener.Preferences dragPreferences, @NotNull SharedPreferences preferences) { private void setOnDragListeners(@Nonnull View root, @Nonnull SimpleOnDragListener.Preferences dragPreferences, @Nonnull SharedPreferences preferences) {
final OnDragListener onDragListener = new OnDragListenerVibrator(newOnDragListener(new DigitButtonDragProcessor(getKeyboard()), dragPreferences), vibrator, preferences); final OnDragListener onDragListener = new OnDragListenerVibrator(newOnDragListener(new DigitButtonDragProcessor(getKeyboard()), dragPreferences), vibrator, preferences);
final List<Integer> dragButtonIds = new ArrayList<Integer>(); final List<Integer> dragButtonIds = new ArrayList<Integer>();
@ -219,19 +219,19 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
} }
} }
@NotNull @Nonnull
private CalculatorKeyboard getKeyboard() { private CalculatorKeyboard getKeyboard() {
return Locator.getInstance().getKeyboard(); return Locator.getInstance().getKeyboard();
} }
@Nullable @Nullable
private <T extends DragButton> T getButton(@NotNull View root, int buttonId) { private <T extends DragButton> T getButton(@Nonnull View root, int buttonId) {
return (T) root.findViewById(buttonId); return (T) root.findViewById(buttonId);
} }
@NotNull @Nonnull
private SimpleOnDragListener newOnDragListener(@NotNull SimpleOnDragListener.DragProcessor dragProcessor, private SimpleOnDragListener newOnDragListener(@Nonnull SimpleOnDragListener.DragProcessor dragProcessor,
@NotNull SimpleOnDragListener.Preferences dragPreferences) { @Nonnull SimpleOnDragListener.Preferences dragPreferences) {
final SimpleOnDragListener onDragListener = new SimpleOnDragListener(dragProcessor, dragPreferences); final SimpleOnDragListener onDragListener = new SimpleOnDragListener(dragProcessor, dragPreferences);
dpclRegister.addListener(onDragListener); dpclRegister.addListener(onDragListener);
return onDragListener; return onDragListener;
@ -247,7 +247,7 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
} }
} }
public void onDestroy(@NotNull Activity activity) { public void onDestroy(@Nonnull Activity activity) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
preferences.unregisterOnSharedPreferenceChangeListener(this); preferences.unregisterOnSharedPreferenceChangeListener(this);

View File

@ -7,8 +7,8 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import jscl.NumeralBase; import jscl.NumeralBase;
import jscl.math.Generic; import jscl.math.Generic;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.history.CalculatorHistoryState; import org.solovyev.android.calculator.history.CalculatorHistoryState;
import org.solovyev.android.calculator.jscl.JsclOperation; import org.solovyev.android.calculator.jscl.JsclOperation;
import org.solovyev.common.history.HistoryAction; import org.solovyev.common.history.HistoryAction;
@ -23,40 +23,40 @@ import java.util.List;
*/ */
public class AndroidCalculator implements Calculator, CalculatorEventListener, SharedPreferences.OnSharedPreferenceChangeListener { public class AndroidCalculator implements Calculator, CalculatorEventListener, SharedPreferences.OnSharedPreferenceChangeListener {
@NotNull @Nonnull
private final CalculatorImpl calculator = new CalculatorImpl(); private final CalculatorImpl calculator = new CalculatorImpl();
@NotNull @Nonnull
private final Application context; private final Application context;
public AndroidCalculator(@NotNull Application application) { public AndroidCalculator(@Nonnull Application application) {
this.context = application; this.context = application;
this.calculator.addCalculatorEventListener(this); this.calculator.addCalculatorEventListener(this);
PreferenceManager.getDefaultSharedPreferences(application).registerOnSharedPreferenceChangeListener(this); PreferenceManager.getDefaultSharedPreferences(application).registerOnSharedPreferenceChangeListener(this);
} }
public void init(@NotNull final Activity activity) { public void init(@Nonnull final Activity activity) {
setEditor(activity); setEditor(activity);
setDisplay(activity); setDisplay(activity);
} }
public void setDisplay(@NotNull Activity activity) { public void setDisplay(@Nonnull Activity activity) {
final AndroidCalculatorDisplayView displayView = (AndroidCalculatorDisplayView) activity.findViewById(R.id.calculator_display); final AndroidCalculatorDisplayView displayView = (AndroidCalculatorDisplayView) activity.findViewById(R.id.calculator_display);
setDisplay(activity, displayView); setDisplay(activity, displayView);
} }
public void setDisplay(@NotNull Context context, @NotNull AndroidCalculatorDisplayView displayView) { public void setDisplay(@Nonnull Context context, @Nonnull AndroidCalculatorDisplayView displayView) {
displayView.init(context); displayView.init(context);
Locator.getInstance().getDisplay().setView(displayView); Locator.getInstance().getDisplay().setView(displayView);
} }
public void setEditor(@NotNull Activity activity) { public void setEditor(@Nonnull Activity activity) {
final AndroidCalculatorEditorView editorView = (AndroidCalculatorEditorView) activity.findViewById(R.id.calculator_editor); final AndroidCalculatorEditorView editorView = (AndroidCalculatorEditorView) activity.findViewById(R.id.calculator_editor);
setEditor(activity, editorView); setEditor(activity, editorView);
} }
public void setEditor(@NotNull Context context, @NotNull AndroidCalculatorEditorView editorView) { public void setEditor(@Nonnull Context context, @Nonnull AndroidCalculatorEditorView editorView) {
editorView.init(context); editorView.init(context);
Locator.getInstance().getEditor().setView(editorView); Locator.getInstance().getEditor().setView(editorView);
} }
@ -71,49 +71,49 @@ public class AndroidCalculator implements Calculator, CalculatorEventListener, S
*/ */
@Override @Override
@NotNull @Nonnull
public CalculatorEventData evaluate(@NotNull JsclOperation operation, @NotNull String expression) { public CalculatorEventData evaluate(@Nonnull JsclOperation operation, @Nonnull String expression) {
return calculator.evaluate(operation, expression); return calculator.evaluate(operation, expression);
} }
@Override @Override
@NotNull @Nonnull
public CalculatorEventData evaluate(@NotNull JsclOperation operation, @NotNull String expression, @NotNull Long sequenceId) { public CalculatorEventData evaluate(@Nonnull JsclOperation operation, @Nonnull String expression, @Nonnull Long sequenceId) {
return calculator.evaluate(operation, expression, sequenceId); return calculator.evaluate(operation, expression, sequenceId);
} }
@Override @Override
public boolean isConversionPossible(@NotNull Generic generic, @NotNull NumeralBase from, @NotNull NumeralBase to) { public boolean isConversionPossible(@Nonnull Generic generic, @Nonnull NumeralBase from, @Nonnull NumeralBase to) {
return calculator.isConversionPossible(generic, from, to); return calculator.isConversionPossible(generic, from, to);
} }
@Override @Override
@NotNull @Nonnull
public CalculatorEventData convert(@NotNull Generic generic, @NotNull NumeralBase to) { public CalculatorEventData convert(@Nonnull Generic generic, @Nonnull NumeralBase to) {
return calculator.convert(generic, to); return calculator.convert(generic, to);
} }
@Override @Override
@NotNull @Nonnull
public CalculatorEventData fireCalculatorEvent(@NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public CalculatorEventData fireCalculatorEvent(@Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
return calculator.fireCalculatorEvent(calculatorEventType, data); return calculator.fireCalculatorEvent(calculatorEventType, data);
} }
@NotNull @Nonnull
@Override @Override
public CalculatorEventData fireCalculatorEvent(@NotNull CalculatorEventType calculatorEventType, @Nullable Object data, @NotNull Object source) { public CalculatorEventData fireCalculatorEvent(@Nonnull CalculatorEventType calculatorEventType, @Nullable Object data, @Nonnull Object source) {
return calculator.fireCalculatorEvent(calculatorEventType, data, source); return calculator.fireCalculatorEvent(calculatorEventType, data, source);
} }
@Override @Override
@NotNull @Nonnull
public CalculatorEventData fireCalculatorEvent(@NotNull CalculatorEventType calculatorEventType, @Nullable Object data, @NotNull Long sequenceId) { public CalculatorEventData fireCalculatorEvent(@Nonnull CalculatorEventType calculatorEventType, @Nullable Object data, @Nonnull Long sequenceId) {
return calculator.fireCalculatorEvent(calculatorEventType, data, sequenceId); return calculator.fireCalculatorEvent(calculatorEventType, data, sequenceId);
} }
@NotNull @Nonnull
@Override @Override
public PreparedExpression prepareExpression(@NotNull String expression) throws CalculatorParseException { public PreparedExpression prepareExpression(@Nonnull String expression) throws CalculatorParseException {
return calculator.prepareExpression(expression); return calculator.prepareExpression(expression);
} }
@ -126,37 +126,37 @@ public class AndroidCalculator implements Calculator, CalculatorEventListener, S
} }
@Override @Override
public void addCalculatorEventListener(@NotNull CalculatorEventListener calculatorEventListener) { public void addCalculatorEventListener(@Nonnull CalculatorEventListener calculatorEventListener) {
calculator.addCalculatorEventListener(calculatorEventListener); calculator.addCalculatorEventListener(calculatorEventListener);
} }
@Override @Override
public void removeCalculatorEventListener(@NotNull CalculatorEventListener calculatorEventListener) { public void removeCalculatorEventListener(@Nonnull CalculatorEventListener calculatorEventListener) {
calculator.removeCalculatorEventListener(calculatorEventListener); calculator.removeCalculatorEventListener(calculatorEventListener);
} }
@Override @Override
public void fireCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void fireCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
calculator.fireCalculatorEvent(calculatorEventData, calculatorEventType, data); calculator.fireCalculatorEvent(calculatorEventData, calculatorEventType, data);
} }
@Override @Override
public void fireCalculatorEvents(@NotNull List<CalculatorEvent> calculatorEvents) { public void fireCalculatorEvents(@Nonnull List<CalculatorEvent> calculatorEvents) {
calculator.fireCalculatorEvents(calculatorEvents); calculator.fireCalculatorEvents(calculatorEvents);
} }
@Override @Override
public void doHistoryAction(@NotNull HistoryAction historyAction) { public void doHistoryAction(@Nonnull HistoryAction historyAction) {
calculator.doHistoryAction(historyAction); calculator.doHistoryAction(historyAction);
} }
@Override @Override
public void setCurrentHistoryState(@NotNull CalculatorHistoryState editorHistoryState) { public void setCurrentHistoryState(@Nonnull CalculatorHistoryState editorHistoryState) {
calculator.setCurrentHistoryState(editorHistoryState); calculator.setCurrentHistoryState(editorHistoryState);
} }
@Override @Override
@NotNull @Nonnull
public CalculatorHistoryState getCurrentHistoryState() { public CalculatorHistoryState getCurrentHistoryState() {
return calculator.getCurrentHistoryState(); return calculator.getCurrentHistoryState();
} }
@ -167,7 +167,7 @@ public class AndroidCalculator implements Calculator, CalculatorEventListener, S
} }
@Override @Override
public void evaluate(@NotNull Long sequenceId) { public void evaluate(@Nonnull Long sequenceId) {
calculator.evaluate(sequenceId); calculator.evaluate(sequenceId);
} }
@ -177,7 +177,7 @@ public class AndroidCalculator implements Calculator, CalculatorEventListener, S
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
switch (calculatorEventType) { switch (calculatorEventType) {
case calculation_messages: case calculation_messages:
CalculatorActivityLauncher.showCalculationMessagesDialog(CalculatorApplication.getInstance(), (List<Message>) data); CalculatorActivityLauncher.showCalculationMessagesDialog(CalculatorApplication.getInstance(), (List<Message>) data);
@ -222,7 +222,7 @@ public class AndroidCalculator implements Calculator, CalculatorEventListener, S
} }
@Override @Override
public void onSharedPreferenceChanged(@NotNull SharedPreferences prefs, @NotNull String key) { public void onSharedPreferenceChanged(@Nonnull SharedPreferences prefs, @Nonnull String key) {
if (CalculatorPreferences.Calculations.calculateOnFly.getKey().equals(key)) { if (CalculatorPreferences.Calculations.calculateOnFly.getKey().equals(key)) {
this.calculator.setCalculateOnFly(CalculatorPreferences.Calculations.calculateOnFly.getPreference(prefs)); this.calculator.setCalculateOnFly(CalculatorPreferences.Calculations.calculateOnFly.getPreference(prefs));
} }

View File

@ -3,7 +3,7 @@ package org.solovyev.android.calculator;
import android.app.Application; import android.app.Application;
import android.content.Context; import android.content.Context;
import android.text.ClipboardManager; import android.text.ClipboardManager;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
/** /**
* User: serso * User: serso
@ -12,10 +12,10 @@ import org.jetbrains.annotations.NotNull;
*/ */
public class AndroidCalculatorClipboard implements CalculatorClipboard { public class AndroidCalculatorClipboard implements CalculatorClipboard {
@NotNull @Nonnull
private final Context context; private final Context context;
public AndroidCalculatorClipboard(@NotNull Application application) { public AndroidCalculatorClipboard(@Nonnull Application application) {
this.context = application; this.context = application;
} }
@ -30,13 +30,13 @@ public class AndroidCalculatorClipboard implements CalculatorClipboard {
} }
@Override @Override
public void setText(@NotNull String text) { public void setText(@Nonnull String text) {
final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(text); clipboard.setText(text);
} }
@Override @Override
public void setText(@NotNull CharSequence text) { public void setText(@Nonnull CharSequence text) {
final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(text); clipboard.setText(text);
} }

View File

@ -6,8 +6,8 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Vibrator; import android.os.Vibrator;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.view.VibratorContainer; import org.solovyev.android.view.VibratorContainer;
/** /**
@ -17,16 +17,16 @@ import org.solovyev.android.view.VibratorContainer;
*/ */
public class AndroidCalculatorKeyboard implements CalculatorKeyboard { public class AndroidCalculatorKeyboard implements CalculatorKeyboard {
@NotNull @Nonnull
private final CalculatorKeyboard calculatorKeyboard; private final CalculatorKeyboard calculatorKeyboard;
@NotNull @Nonnull
private final Context context; private final Context context;
private VibratorContainer vibrator; private VibratorContainer vibrator;
public AndroidCalculatorKeyboard(@NotNull Application application, public AndroidCalculatorKeyboard(@Nonnull Application application,
@NotNull CalculatorKeyboard calculatorKeyboard) { @Nonnull CalculatorKeyboard calculatorKeyboard) {
this.context = application; this.context = application;
this.calculatorKeyboard = calculatorKeyboard; this.calculatorKeyboard = calculatorKeyboard;
} }

View File

@ -1,8 +1,8 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.util.Log; import android.util.Log;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
/** /**
* User: serso * User: serso
@ -11,26 +11,26 @@ import org.jetbrains.annotations.Nullable;
*/ */
public class AndroidCalculatorLogger implements CalculatorLogger { public class AndroidCalculatorLogger implements CalculatorLogger {
@NotNull @Nonnull
private static final String TAG = "Calculatorpp"; private static final String TAG = "Calculatorpp";
@Override @Override
public void debug(@Nullable String tag, @NotNull String message) { public void debug(@Nullable String tag, @Nonnull String message) {
Log.d(getTag(tag), message); Log.d(getTag(tag), message);
} }
@NotNull @Nonnull
private String getTag(@Nullable String tag) { private String getTag(@Nullable String tag) {
return tag != null ? TAG + "/" + tag : TAG; return tag != null ? TAG + "/" + tag : TAG;
} }
@Override @Override
public void debug(@Nullable String tag, @Nullable String message, @NotNull Throwable e) { public void debug(@Nullable String tag, @Nullable String message, @Nonnull Throwable e) {
Log.d(getTag(tag), message, e); Log.d(getTag(tag), message, e);
} }
@Override @Override
public void error(@Nullable String tag, @Nullable String message, @NotNull Throwable e) { public void error(@Nullable String tag, @Nullable String message, @Nonnull Throwable e) {
Log.e(getTag(tag), message, e); Log.e(getTag(tag), message, e);
} }

View File

@ -3,8 +3,8 @@ package org.solovyev.android.calculator;
import android.app.Application; import android.app.Application;
import android.os.Handler; import android.os.Handler;
import android.widget.Toast; import android.widget.Toast;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.Threads; import org.solovyev.android.Threads;
import org.solovyev.android.msg.AndroidMessage; import org.solovyev.android.msg.AndroidMessage;
import org.solovyev.common.msg.Message; import org.solovyev.common.msg.Message;
@ -19,19 +19,19 @@ import java.util.List;
*/ */
public class AndroidCalculatorNotifier implements CalculatorNotifier { public class AndroidCalculatorNotifier implements CalculatorNotifier {
@NotNull @Nonnull
private final Application application; private final Application application;
@NotNull @Nonnull
private final Handler uiHandler = new Handler(); private final Handler uiHandler = new Handler();
private final boolean showDebugMessages; private final boolean showDebugMessages;
public AndroidCalculatorNotifier(@NotNull Application application) { public AndroidCalculatorNotifier(@Nonnull Application application) {
this(application, false); this(application, false);
} }
public AndroidCalculatorNotifier(@NotNull Application application, boolean showDebugMessages) { public AndroidCalculatorNotifier(@Nonnull Application application, boolean showDebugMessages) {
assert Threads.isUiThread(); assert Threads.isUiThread();
this.application = application; this.application = application;
@ -39,28 +39,28 @@ public class AndroidCalculatorNotifier implements CalculatorNotifier {
} }
@Override @Override
public void showMessage(@NotNull Message message) { public void showMessage(@Nonnull Message message) {
showMessageInUiThread(message.getLocalizedMessage()); showMessageInUiThread(message.getLocalizedMessage());
} }
@Override @Override
public void showMessage(@NotNull Integer messageCode, @NotNull MessageType messageType, @NotNull List<Object> parameters) { public void showMessage(@Nonnull Integer messageCode, @Nonnull MessageType messageType, @Nonnull List<Object> parameters) {
showMessage(new AndroidMessage(messageCode, messageType, application, parameters)); showMessage(new AndroidMessage(messageCode, messageType, application, parameters));
} }
@Override @Override
public void showMessage(@NotNull Integer messageCode, @NotNull MessageType messageType, @Nullable Object... parameters) { public void showMessage(@Nonnull Integer messageCode, @Nonnull MessageType messageType, @Nullable Object... parameters) {
showMessage(new AndroidMessage(messageCode, messageType, application, parameters)); showMessage(new AndroidMessage(messageCode, messageType, application, parameters));
} }
@Override @Override
public void showDebugMessage(@Nullable final String tag, @NotNull final String message) { public void showDebugMessage(@Nullable final String tag, @Nonnull final String message) {
if (showDebugMessages) { if (showDebugMessages) {
showMessageInUiThread(tag == null ? message : tag + ": " + message); showMessageInUiThread(tag == null ? message : tag + ": " + message);
} }
} }
private void showMessageInUiThread(@NotNull final String message) { private void showMessageInUiThread(@Nonnull final String message) {
if (Threads.isUiThread()) { if (Threads.isUiThread()) {
Toast.makeText(application, message, Toast.LENGTH_SHORT).show(); Toast.makeText(application, message, Toast.LENGTH_SHORT).show();
} else { } else {

View File

@ -5,7 +5,7 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import jscl.AngleUnit; import jscl.AngleUnit;
import jscl.NumeralBase; import jscl.NumeralBase;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.msg.AndroidMessage; import org.solovyev.android.msg.AndroidMessage;
import org.solovyev.common.msg.MessageType; import org.solovyev.common.msg.MessageType;
@ -23,10 +23,10 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS
// one hour // one hour
private static final Long PREFERRED_PREFS_INTERVAL_TIME = 1000L * 60L * 60L; private static final Long PREFERRED_PREFS_INTERVAL_TIME = 1000L * 60L * 60L;
@NotNull @Nonnull
private final Application application; private final Application application;
public AndroidCalculatorPreferenceService(@NotNull Application application) { public AndroidCalculatorPreferenceService(@Nonnull Application application) {
this.application = application; this.application = application;
} }
@ -58,7 +58,7 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS
} }
} }
private boolean isTimeForCheck(@NotNull Long currentTime, @NotNull SharedPreferences preferences) { private boolean isTimeForCheck(@Nonnull Long currentTime, @Nonnull SharedPreferences preferences) {
final Long lastPreferredPreferencesCheckTime = CalculatorPreferences.Calculations.lastPreferredPreferencesCheck.getPreference(preferences); final Long lastPreferredPreferencesCheckTime = CalculatorPreferences.Calculations.lastPreferredPreferencesCheck.getPreference(preferences);
return currentTime - lastPreferredPreferencesCheckTime > PREFERRED_PREFS_INTERVAL_TIME; return currentTime - lastPreferredPreferencesCheckTime > PREFERRED_PREFS_INTERVAL_TIME;
@ -71,7 +71,7 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS
} }
@Override @Override
public void setAngleUnits(@NotNull AngleUnit angleUnit) { public void setAngleUnits(@Nonnull AngleUnit angleUnit) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application);
AndroidCalculatorEngine.Preferences.angleUnit.putPreference(preferences, angleUnit); AndroidCalculatorEngine.Preferences.angleUnit.putPreference(preferences, angleUnit);
@ -85,7 +85,7 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS
} }
@Override @Override
public void setNumeralBase(@NotNull NumeralBase numeralBase) { public void setNumeralBase(@Nonnull NumeralBase numeralBase) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application);
AndroidCalculatorEngine.Preferences.numeralBase.putPreference(preferences, numeralBase); AndroidCalculatorEngine.Preferences.numeralBase.putPreference(preferences, numeralBase);

View File

@ -1,7 +1,7 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
/** /**
* User: serso * User: serso
@ -27,7 +27,7 @@ public enum AndroidFunctionCategory {
} }
@Nullable @Nullable
public static AndroidFunctionCategory valueOf(@NotNull FunctionCategory functionCategory) { public static AndroidFunctionCategory valueOf(@Nonnull FunctionCategory functionCategory) {
for (AndroidFunctionCategory androidFunctionCategory : values()) { for (AndroidFunctionCategory androidFunctionCategory : values()) {
if (androidFunctionCategory.name().equals(functionCategory.name())) { if (androidFunctionCategory.name().equals(functionCategory.name())) {
return androidFunctionCategory; return androidFunctionCategory;

View File

@ -2,7 +2,7 @@ package org.solovyev.android.calculator;
import android.app.Activity; import android.app.Activity;
import jscl.NumeralBase; import jscl.NumeralBase;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.units.CalculatorNumeralBase; import org.solovyev.android.calculator.units.CalculatorNumeralBase;
import org.solovyev.android.view.drag.DirectionDragButton; import org.solovyev.android.view.drag.DirectionDragButton;
import org.solovyev.android.view.drag.DragDirection; import org.solovyev.android.view.drag.DragDirection;
@ -19,7 +19,7 @@ import java.util.List;
public enum AndroidNumeralBase { public enum AndroidNumeralBase {
bin(CalculatorNumeralBase.bin) { bin(CalculatorNumeralBase.bin) {
@NotNull @Nonnull
@Override @Override
public List<Integer> getButtonIds() { public List<Integer> getButtonIds() {
return Arrays.asList(R.id.cpp_button_0, R.id.cpp_button_1); return Arrays.asList(R.id.cpp_button_0, R.id.cpp_button_1);
@ -27,7 +27,7 @@ public enum AndroidNumeralBase {
}, },
oct(CalculatorNumeralBase.oct) { oct(CalculatorNumeralBase.oct) {
@NotNull @Nonnull
@Override @Override
public List<Integer> getButtonIds() { public List<Integer> getButtonIds() {
final List<Integer> result = new ArrayList<Integer>(bin.getButtonIds()); final List<Integer> result = new ArrayList<Integer>(bin.getButtonIds());
@ -37,7 +37,7 @@ public enum AndroidNumeralBase {
}, },
dec(CalculatorNumeralBase.dec) { dec(CalculatorNumeralBase.dec) {
@NotNull @Nonnull
@Override @Override
public List<Integer> getButtonIds() { public List<Integer> getButtonIds() {
final List<Integer> result = new ArrayList<Integer>(oct.getButtonIds()); final List<Integer> result = new ArrayList<Integer>(oct.getButtonIds());
@ -48,17 +48,17 @@ public enum AndroidNumeralBase {
hex(CalculatorNumeralBase.hex) { hex(CalculatorNumeralBase.hex) {
@NotNull @Nonnull
private List<Integer> specialHexButtonIds = Arrays.asList(R.id.cpp_button_1, R.id.cpp_button_2, R.id.cpp_button_3, R.id.cpp_button_4, R.id.cpp_button_5, R.id.cpp_button_6); private List<Integer> specialHexButtonIds = Arrays.asList(R.id.cpp_button_1, R.id.cpp_button_2, R.id.cpp_button_3, R.id.cpp_button_4, R.id.cpp_button_5, R.id.cpp_button_6);
@NotNull @Nonnull
@Override @Override
public List<Integer> getButtonIds() { public List<Integer> getButtonIds() {
return dec.getButtonIds(); return dec.getButtonIds();
} }
@Override @Override
protected void toggleButton(boolean show, @NotNull DirectionDragButton button) { protected void toggleButton(boolean show, @Nonnull DirectionDragButton button) {
super.toggleButton(show, button); super.toggleButton(show, button);
if (specialHexButtonIds.contains(button.getId())) { if (specialHexButtonIds.contains(button.getId())) {
button.showDirectionText(show, DragDirection.left); button.showDirectionText(show, DragDirection.left);
@ -67,17 +67,17 @@ public enum AndroidNumeralBase {
} }
}; };
@NotNull @Nonnull
private final CalculatorNumeralBase calculatorNumeralBase; private final CalculatorNumeralBase calculatorNumeralBase;
private AndroidNumeralBase(@NotNull CalculatorNumeralBase calculatorNumeralBase) { private AndroidNumeralBase(@Nonnull CalculatorNumeralBase calculatorNumeralBase) {
this.calculatorNumeralBase = calculatorNumeralBase; this.calculatorNumeralBase = calculatorNumeralBase;
} }
@NotNull @Nonnull
public abstract List<Integer> getButtonIds(); public abstract List<Integer> getButtonIds();
public void toggleButtons(boolean show, @NotNull Activity activity) { public void toggleButtons(boolean show, @Nonnull Activity activity) {
for (Integer buttonId : getButtonIds()) { for (Integer buttonId : getButtonIds()) {
final DirectionDragButton button = (DirectionDragButton) activity.findViewById(buttonId); final DirectionDragButton button = (DirectionDragButton) activity.findViewById(buttonId);
if (button != null) { if (button != null) {
@ -86,18 +86,18 @@ public enum AndroidNumeralBase {
} }
} }
protected void toggleButton(boolean show, @NotNull DirectionDragButton button) { protected void toggleButton(boolean show, @Nonnull DirectionDragButton button) {
button.setShowText(show); button.setShowText(show);
button.invalidate(); button.invalidate();
} }
@NotNull @Nonnull
public NumeralBase getNumeralBase() { public NumeralBase getNumeralBase() {
return calculatorNumeralBase.getNumeralBase(); return calculatorNumeralBase.getNumeralBase();
} }
@NotNull @Nonnull
public static AndroidNumeralBase valueOf(@NotNull NumeralBase nb) { public static AndroidNumeralBase valueOf(@Nonnull NumeralBase nb) {
for (AndroidNumeralBase androidNumeralBase : values()) { for (AndroidNumeralBase androidNumeralBase : values()) {
if (androidNumeralBase.calculatorNumeralBase.getNumeralBase() == nb) { if (androidNumeralBase.calculatorNumeralBase.getNumeralBase() == nb) {
return androidNumeralBase; return androidNumeralBase;

View File

@ -1,7 +1,7 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
/** /**
* User: serso * User: serso
@ -26,7 +26,7 @@ public enum AndroidOperatorCategory {
} }
@Nullable @Nullable
public static AndroidOperatorCategory valueOf(@NotNull OperatorCategory operatorCategory) { public static AndroidOperatorCategory valueOf(@Nonnull OperatorCategory operatorCategory) {
for (AndroidOperatorCategory androidOperatorCategory : values()) { for (AndroidOperatorCategory androidOperatorCategory : values()) {
if (androidOperatorCategory.name().equals(operatorCategory.name())) { if (androidOperatorCategory.name().equals(operatorCategory.name())) {
return androidOperatorCategory; return androidOperatorCategory;

View File

@ -1,7 +1,7 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
/** /**
* User: serso * User: serso
@ -24,7 +24,7 @@ public enum AndroidVarCategory {
} }
@Nullable @Nullable
public static AndroidVarCategory valueOf(@NotNull VarCategory varCategory) { public static AndroidVarCategory valueOf(@Nonnull VarCategory varCategory) {
for (AndroidVarCategory androidVarCategory : values()) { for (AndroidVarCategory androidVarCategory : values()) {
if (androidVarCategory.name().equals(varCategory.name())) { if (androidVarCategory.name().equals(varCategory.name())) {
return androidVarCategory; return androidVarCategory;

View File

@ -21,8 +21,8 @@ import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.Activities; import org.solovyev.android.Activities;
import org.solovyev.android.Android; import org.solovyev.android.Android;
import org.solovyev.android.Threads; import org.solovyev.android.Threads;
@ -36,12 +36,12 @@ import org.solovyev.common.text.Strings;
public class CalculatorActivity extends SherlockFragmentActivity implements SharedPreferences.OnSharedPreferenceChangeListener, CalculatorEventListener { public class CalculatorActivity extends SherlockFragmentActivity implements SharedPreferences.OnSharedPreferenceChangeListener, CalculatorEventListener {
@NotNull @Nonnull
public static final String TAG = CalculatorActivity.class.getSimpleName(); public static final String TAG = CalculatorActivity.class.getSimpleName();
private boolean useBackAsPrev; private boolean useBackAsPrev;
@NotNull @Nonnull
private CalculatorActivityHelper activityHelper; private CalculatorActivityHelper activityHelper;
/** /**
@ -96,12 +96,12 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
return findViewById(R.id.main_second_pane) != null; return findViewById(R.id.main_second_pane) != null;
} }
@NotNull @Nonnull
private AndroidCalculator getCalculator() { private AndroidCalculator getCalculator() {
return ((AndroidCalculator) Locator.getInstance().getCalculator()); return ((AndroidCalculator) Locator.getInstance().getCalculator());
} }
private static void firstTimeInit(@NotNull SharedPreferences preferences, @NotNull Context context) { private static void firstTimeInit(@Nonnull SharedPreferences preferences, @Nonnull Context context) {
final Integer appOpenedCounter = CalculatorPreferences.appOpenedCounter.getPreference(preferences); final Integer appOpenedCounter = CalculatorPreferences.appOpenedCounter.getPreference(preferences);
if (appOpenedCounter != null) { if (appOpenedCounter != null) {
CalculatorPreferences.appOpenedCounter.putPreference(preferences, appOpenedCounter + 1); CalculatorPreferences.appOpenedCounter.putPreference(preferences, appOpenedCounter + 1);
@ -149,7 +149,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
} }
} }
private static boolean showSpecialWindow(@NotNull SharedPreferences preferences, @NotNull Preference<Boolean> specialWindowShownPref, int layoutId, int textViewId, @NotNull Context context) { private static boolean showSpecialWindow(@Nonnull SharedPreferences preferences, @Nonnull Preference<Boolean> specialWindowShownPref, int layoutId, int textViewId, @Nonnull Context context) {
boolean result = false; boolean result = false;
final Boolean specialWindowShown = specialWindowShownPref.getPreference(preferences); final Boolean specialWindowShown = specialWindowShownPref.getPreference(preferences);
@ -183,7 +183,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
} }
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
public void equalsButtonClickHandler(@NotNull View v) { public void equalsButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.equals); buttonPressed(CalculatorSpecialButton.equals);
} }
@ -252,47 +252,47 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
*/ */
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
public void elementaryButtonClickHandler(@NotNull View v) { public void elementaryButtonClickHandler(@Nonnull View v) {
throw new UnsupportedOperationException("Not implemented yet!"); throw new UnsupportedOperationException("Not implemented yet!");
} }
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
public void historyButtonClickHandler(@NotNull View v) { public void historyButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.history); buttonPressed(CalculatorSpecialButton.history);
} }
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
public void eraseButtonClickHandler(@NotNull View v) { public void eraseButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.erase); buttonPressed(CalculatorSpecialButton.erase);
} }
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
public void simplifyButtonClickHandler(@NotNull View v) { public void simplifyButtonClickHandler(@Nonnull View v) {
throw new UnsupportedOperationException("Not implemented yet!"); throw new UnsupportedOperationException("Not implemented yet!");
} }
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
public void pasteButtonClickHandler(@NotNull View v) { public void pasteButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.paste); buttonPressed(CalculatorSpecialButton.paste);
} }
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
public void copyButtonClickHandler(@NotNull View v) { public void copyButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.copy); buttonPressed(CalculatorSpecialButton.copy);
} }
@NotNull @Nonnull
private static CalculatorKeyboard getKeyboard() { private static CalculatorKeyboard getKeyboard() {
return Locator.getInstance().getKeyboard(); return Locator.getInstance().getKeyboard();
} }
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
public void clearButtonClickHandler(@NotNull View v) { public void clearButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.clear); buttonPressed(CalculatorSpecialButton.clear);
} }
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
public void digitButtonClickHandler(@NotNull View v) { public void digitButtonClickHandler(@Nonnull View v) {
Log.d(String.valueOf(v.getId()), "digitButtonClickHandler() for: " + v.getId() + ". Pressed: " + v.isPressed()); Log.d(String.valueOf(v.getId()), "digitButtonClickHandler() for: " + v.getId() + ". Pressed: " + v.isPressed());
if (v instanceof Button) { if (v instanceof Button) {
@ -300,36 +300,36 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
} }
} }
private void buttonPressed(@NotNull CalculatorSpecialButton button) { private void buttonPressed(@Nonnull CalculatorSpecialButton button) {
buttonPressed(button.getActionCode()); buttonPressed(button.getActionCode());
} }
private void buttonPressed(@NotNull String text) { private void buttonPressed(@Nonnull String text) {
getKeyboard().buttonPressed(text); getKeyboard().buttonPressed(text);
} }
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
public void functionsButtonClickHandler(@NotNull View v) { public void functionsButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.functions); buttonPressed(CalculatorSpecialButton.functions);
} }
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
public void operatorsButtonClickHandler(@NotNull View v) { public void operatorsButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.operators); buttonPressed(CalculatorSpecialButton.operators);
} }
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
public void varsButtonClickHandler(@NotNull View v) { public void varsButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.vars); buttonPressed(CalculatorSpecialButton.vars);
} }
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
public void likeButtonClickHandler(@NotNull View v) { public void likeButtonClickHandler(@Nonnull View v) {
buttonPressed(CalculatorSpecialButton.like); buttonPressed(CalculatorSpecialButton.like);
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
switch (calculatorEventType) { switch (calculatorEventType) {
case plot_graph: case plot_graph:
Threads.tryRunOnUiThread(this, new Runnable() { Threads.tryRunOnUiThread(this, new Runnable() {

View File

@ -5,8 +5,8 @@ import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.View; import android.view.View;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
/** /**
* User: serso * User: serso
@ -15,57 +15,57 @@ import org.jetbrains.annotations.Nullable;
*/ */
public interface CalculatorActivityHelper { public interface CalculatorActivityHelper {
void onCreate(@NotNull SherlockFragmentActivity activity, @Nullable Bundle savedInstanceState); void onCreate(@Nonnull SherlockFragmentActivity activity, @Nullable Bundle savedInstanceState);
void onCreate(@NotNull Activity activity, @Nullable Bundle savedInstanceState); void onCreate(@Nonnull Activity activity, @Nullable Bundle savedInstanceState);
void onSaveInstanceState(@NotNull SherlockFragmentActivity activity, @NotNull Bundle outState); void onSaveInstanceState(@Nonnull SherlockFragmentActivity activity, @Nonnull Bundle outState);
void onSaveInstanceState(@NotNull Activity activity, @NotNull Bundle outState); void onSaveInstanceState(@Nonnull Activity activity, @Nonnull Bundle outState);
int getLayoutId(); int getLayoutId();
@NotNull @Nonnull
CalculatorPreferences.Gui.Theme getTheme(); CalculatorPreferences.Gui.Theme getTheme();
@NotNull @Nonnull
CalculatorPreferences.Gui.Layout getLayout(); CalculatorPreferences.Gui.Layout getLayout();
void onResume(@NotNull SherlockFragmentActivity activity); void onResume(@Nonnull SherlockFragmentActivity activity);
void onResume(@NotNull Activity activity); void onResume(@Nonnull Activity activity);
void onPause(@NotNull Activity activity); void onPause(@Nonnull Activity activity);
void onPause(@NotNull SherlockFragmentActivity activity); void onPause(@Nonnull SherlockFragmentActivity activity);
void onDestroy(@NotNull SherlockFragmentActivity activity); void onDestroy(@Nonnull SherlockFragmentActivity activity);
void onDestroy(@NotNull Activity activity); void onDestroy(@Nonnull Activity activity);
void addTab(@NotNull SherlockFragmentActivity activity, void addTab(@Nonnull SherlockFragmentActivity activity,
@NotNull String tag, @Nonnull String tag,
@NotNull Class<? extends Fragment> fragmentClass, @Nonnull Class<? extends Fragment> fragmentClass,
@Nullable Bundle fragmentArgs, @Nullable Bundle fragmentArgs,
int captionResId, int captionResId,
int parentViewId); int parentViewId);
void addTab(@NotNull SherlockFragmentActivity activity, void addTab(@Nonnull SherlockFragmentActivity activity,
@NotNull CalculatorFragmentType fragmentType, @Nonnull CalculatorFragmentType fragmentType,
@Nullable Bundle fragmentArgs, @Nullable Bundle fragmentArgs,
int parentViewId); int parentViewId);
void setFragment(@NotNull SherlockFragmentActivity activity, void setFragment(@Nonnull SherlockFragmentActivity activity,
@NotNull CalculatorFragmentType fragmentType, @Nonnull CalculatorFragmentType fragmentType,
@Nullable Bundle fragmentArgs, @Nullable Bundle fragmentArgs,
int parentViewId); int parentViewId);
void logDebug(@NotNull String message); void logDebug(@Nonnull String message);
void processButtons(@NotNull Activity activity, @NotNull View root); void processButtons(@Nonnull Activity activity, @Nonnull View root);
void logError(@NotNull String message); void logError(@Nonnull String message);
void selectTab(@NotNull SherlockFragmentActivity activity, @NotNull CalculatorFragmentType fragmentType); void selectTab(@Nonnull SherlockFragmentActivity activity, @Nonnull CalculatorFragmentType fragmentType);
} }

View File

@ -16,8 +16,8 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.Activities; import org.solovyev.android.Activities;
import org.solovyev.android.Views; import org.solovyev.android.Views;
import org.solovyev.android.sherlock.tabs.ActionBarFragmentTabListener; import org.solovyev.android.sherlock.tabs.ActionBarFragmentTabListener;
@ -49,15 +49,15 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
private boolean homeIcon = false; private boolean homeIcon = false;
@NotNull @Nonnull
private CalculatorPreferences.Gui.Theme theme; private CalculatorPreferences.Gui.Theme theme;
@NotNull @Nonnull
private CalculatorPreferences.Gui.Layout layout; private CalculatorPreferences.Gui.Layout layout;
private int selectedNavigationIndex = 0; private int selectedNavigationIndex = 0;
public CalculatorActivityHelperImpl(int layoutId, @NotNull String logTag) { public CalculatorActivityHelperImpl(int layoutId, @Nonnull String logTag) {
super(logTag); super(logTag);
this.layoutId = layoutId; this.layoutId = layoutId;
} }
@ -68,7 +68,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
} }
@Override @Override
public void onCreate(@NotNull Activity activity, @Nullable Bundle savedInstanceState) { public void onCreate(@Nonnull Activity activity, @Nullable Bundle savedInstanceState) {
super.onCreate(activity); super.onCreate(activity);
if (activity instanceof CalculatorEventListener) { if (activity instanceof CalculatorEventListener) {
@ -94,7 +94,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
} }
@Override @Override
public void onCreate(@NotNull final SherlockFragmentActivity activity, @Nullable Bundle savedInstanceState) { public void onCreate(@Nonnull final SherlockFragmentActivity activity, @Nullable Bundle savedInstanceState) {
this.onCreate((Activity) activity, savedInstanceState); this.onCreate((Activity) activity, savedInstanceState);
final ActionBar actionBar = activity.getSupportActionBar(); final ActionBar actionBar = activity.getSupportActionBar();
@ -109,7 +109,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
} }
private void toggleTitle(@NotNull SherlockFragmentActivity activity, boolean showTitle) { private void toggleTitle(@Nonnull SherlockFragmentActivity activity, boolean showTitle) {
final ActionBar actionBar = activity.getSupportActionBar(); final ActionBar actionBar = activity.getSupportActionBar();
if (activity instanceof CalculatorActivity) { if (activity instanceof CalculatorActivity) {
@ -123,7 +123,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
} }
} }
public void restoreSavedTab(@NotNull SherlockFragmentActivity activity) { public void restoreSavedTab(@Nonnull SherlockFragmentActivity activity) {
final ActionBar actionBar = activity.getSupportActionBar(); final ActionBar actionBar = activity.getSupportActionBar();
if (selectedNavigationIndex >= 0 && selectedNavigationIndex < actionBar.getTabCount()) { if (selectedNavigationIndex >= 0 && selectedNavigationIndex < actionBar.getTabCount()) {
actionBar.setSelectedNavigationItem(selectedNavigationIndex); actionBar.setSelectedNavigationItem(selectedNavigationIndex);
@ -131,16 +131,16 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
} }
@Override @Override
public void onSaveInstanceState(@NotNull SherlockFragmentActivity activity, @NotNull Bundle outState) { public void onSaveInstanceState(@Nonnull SherlockFragmentActivity activity, @Nonnull Bundle outState) {
onSaveInstanceState((Activity) activity, outState); onSaveInstanceState((Activity) activity, outState);
} }
@Override @Override
public void onSaveInstanceState(@NotNull Activity activity, @NotNull Bundle outState) { public void onSaveInstanceState(@Nonnull Activity activity, @Nonnull Bundle outState) {
} }
@Override @Override
public void onResume(@NotNull Activity activity) { public void onResume(@Nonnull Activity activity) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
final CalculatorPreferences.Gui.Theme newTheme = CalculatorPreferences.Gui.theme.getPreference(preferences); final CalculatorPreferences.Gui.Theme newTheme = CalculatorPreferences.Gui.theme.getPreference(preferences);
@ -150,11 +150,11 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
} }
@Override @Override
public void onPause(@NotNull Activity activity) { public void onPause(@Nonnull Activity activity) {
} }
@Override @Override
public void onPause(@NotNull SherlockFragmentActivity activity) { public void onPause(@Nonnull SherlockFragmentActivity activity) {
onPause((Activity) activity); onPause((Activity) activity);
final int selectedNavigationIndex = activity.getSupportActionBar().getSelectedNavigationIndex(); final int selectedNavigationIndex = activity.getSupportActionBar().getSelectedNavigationIndex();
@ -167,13 +167,13 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
} }
@NotNull @Nonnull
private String getSavedTabPreferenceName(@NotNull Activity activity) { private String getSavedTabPreferenceName(@Nonnull Activity activity) {
return "tab_" + activity.getClass().getSimpleName(); return "tab_" + activity.getClass().getSimpleName();
} }
@Override @Override
public void onDestroy(@NotNull Activity activity) { public void onDestroy(@Nonnull Activity activity) {
super.onDestroy(activity); super.onDestroy(activity);
if (activity instanceof CalculatorEventListener) { if (activity instanceof CalculatorEventListener) {
@ -182,14 +182,14 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
} }
@Override @Override
public void onDestroy(@NotNull SherlockFragmentActivity activity) { public void onDestroy(@Nonnull SherlockFragmentActivity activity) {
this.onDestroy((Activity) activity); this.onDestroy((Activity) activity);
} }
@Override @Override
public void addTab(@NotNull SherlockFragmentActivity activity, public void addTab(@Nonnull SherlockFragmentActivity activity,
@NotNull String tag, @Nonnull String tag,
@NotNull Class<? extends Fragment> fragmentClass, @Nonnull Class<? extends Fragment> fragmentClass,
@Nullable Bundle fragmentArgs, @Nullable Bundle fragmentArgs,
int captionResId, int captionResId,
int parentViewId) { int parentViewId) {
@ -205,12 +205,12 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
} }
@Override @Override
public void addTab(@NotNull SherlockFragmentActivity activity, @NotNull CalculatorFragmentType fragmentType, @Nullable Bundle fragmentArgs, int parentViewId) { public void addTab(@Nonnull SherlockFragmentActivity activity, @Nonnull CalculatorFragmentType fragmentType, @Nullable Bundle fragmentArgs, int parentViewId) {
addTab(activity, fragmentType.getFragmentTag(), fragmentType.getFragmentClass(), fragmentArgs, fragmentType.getDefaultTitleResId(), parentViewId); addTab(activity, fragmentType.getFragmentTag(), fragmentType.getFragmentClass(), fragmentArgs, fragmentType.getDefaultTitleResId(), parentViewId);
} }
@Override @Override
public void setFragment(@NotNull SherlockFragmentActivity activity, @NotNull CalculatorFragmentType fragmentType, @Nullable Bundle fragmentArgs, int parentViewId) { public void setFragment(@Nonnull SherlockFragmentActivity activity, @Nonnull CalculatorFragmentType fragmentType, @Nullable Bundle fragmentArgs, int parentViewId) {
final FragmentManager fm = activity.getSupportFragmentManager(); final FragmentManager fm = activity.getSupportFragmentManager();
Fragment fragment = fm.findFragmentByTag(fragmentType.getFragmentTag()); Fragment fragment = fm.findFragmentByTag(fragmentType.getFragmentTag());
@ -230,7 +230,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
} }
@Override @Override
public void selectTab(@NotNull SherlockFragmentActivity activity, @NotNull CalculatorFragmentType fragmentType) { public void selectTab(@Nonnull SherlockFragmentActivity activity, @Nonnull CalculatorFragmentType fragmentType) {
final ActionBar actionBar = activity.getSupportActionBar(); final ActionBar actionBar = activity.getSupportActionBar();
for (int i = 0; i < actionBar.getTabCount(); i++) { for (int i = 0; i < actionBar.getTabCount(); i++) {
final ActionBar.Tab tab = actionBar.getTabAt(i); final ActionBar.Tab tab = actionBar.getTabAt(i);
@ -247,19 +247,19 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
} }
@Override @Override
@NotNull @Nonnull
public CalculatorPreferences.Gui.Theme getTheme() { public CalculatorPreferences.Gui.Theme getTheme() {
return theme; return theme;
} }
@Override @Override
@NotNull @Nonnull
public CalculatorPreferences.Gui.Layout getLayout() { public CalculatorPreferences.Gui.Layout getLayout() {
return layout; return layout;
} }
@Override @Override
public void onResume(@NotNull SherlockFragmentActivity activity) { public void onResume(@Nonnull SherlockFragmentActivity activity) {
onResume((Activity) activity); onResume((Activity) activity);
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
@ -267,7 +267,7 @@ public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper imple
restoreSavedTab(activity); restoreSavedTab(activity);
} }
private void addHelpInfo(@NotNull Activity activity, @NotNull View root) { private void addHelpInfo(@Nonnull Activity activity, @Nonnull View root) {
if (CalculatorApplication.isMonkeyRunner(activity)) { if (CalculatorApplication.isMonkeyRunner(activity)) {
if (root instanceof ViewGroup) { if (root instanceof ViewGroup) {
final TextView helperTextView = new TextView(activity); final TextView helperTextView = new TextView(activity);

View File

@ -12,8 +12,8 @@ import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import jscl.math.Generic; import jscl.math.Generic;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.Android; import org.solovyev.android.Android;
import org.solovyev.android.App; import org.solovyev.android.App;
import org.solovyev.android.calculator.about.CalculatorAboutActivity; import org.solovyev.android.calculator.about.CalculatorAboutActivity;
@ -41,72 +41,72 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
public CalculatorActivityLauncher() { public CalculatorActivityLauncher() {
} }
public static void showHistory(@NotNull final Context context) { public static void showHistory(@Nonnull final Context context) {
showHistory(context, false); showHistory(context, false);
} }
public static void showHistory(@NotNull final Context context, boolean detached) { public static void showHistory(@Nonnull final Context context, boolean detached) {
final Intent intent = new Intent(context, CalculatorHistoryActivity.class); final Intent intent = new Intent(context, CalculatorHistoryActivity.class);
Android.addIntentFlags(intent, detached, context); Android.addIntentFlags(intent, detached, context);
context.startActivity(intent); context.startActivity(intent);
} }
public static void showHelp(@NotNull final Context context) { public static void showHelp(@Nonnull final Context context) {
context.startActivity(new Intent(context, CalculatorHelpActivity.class)); context.startActivity(new Intent(context, CalculatorHelpActivity.class));
} }
public static void showSettings(@NotNull final Context context) { public static void showSettings(@Nonnull final Context context) {
showSettings(context, false); showSettings(context, false);
} }
public static void showSettings(@NotNull final Context context, boolean detached) { public static void showSettings(@Nonnull final Context context, boolean detached) {
final Intent intent = new Intent(context, CalculatorPreferencesActivity.class); final Intent intent = new Intent(context, CalculatorPreferencesActivity.class);
Android.addIntentFlags(intent, detached, context); Android.addIntentFlags(intent, detached, context);
context.startActivity(intent); context.startActivity(intent);
} }
public static void showAbout(@NotNull final Context context) { public static void showAbout(@Nonnull final Context context) {
context.startActivity(new Intent(context, CalculatorAboutActivity.class)); context.startActivity(new Intent(context, CalculatorAboutActivity.class));
} }
public static void showFunctions(@NotNull final Context context) { public static void showFunctions(@Nonnull final Context context) {
showFunctions(context, false); showFunctions(context, false);
} }
public static void showFunctions(@NotNull final Context context, boolean detached) { public static void showFunctions(@Nonnull final Context context, boolean detached) {
final Intent intent = new Intent(context, CalculatorFunctionsActivity.class); final Intent intent = new Intent(context, CalculatorFunctionsActivity.class);
Android.addIntentFlags(intent, detached, context); Android.addIntentFlags(intent, detached, context);
context.startActivity(intent); context.startActivity(intent);
} }
public static void showOperators(@NotNull final Context context) { public static void showOperators(@Nonnull final Context context) {
showOperators(context, false); showOperators(context, false);
} }
public static void showOperators(@NotNull final Context context, boolean detached) { public static void showOperators(@Nonnull final Context context, boolean detached) {
final Intent intent = new Intent(context, CalculatorOperatorsActivity.class); final Intent intent = new Intent(context, CalculatorOperatorsActivity.class);
Android.addIntentFlags(intent, detached, context); Android.addIntentFlags(intent, detached, context);
context.startActivity(intent); context.startActivity(intent);
} }
public static void showVars(@NotNull final Context context) { public static void showVars(@Nonnull final Context context) {
showVars(context, false); showVars(context, false);
} }
public static void showVars(@NotNull final Context context, boolean detached) { public static void showVars(@Nonnull final Context context, boolean detached) {
final Intent intent = new Intent(context, CalculatorVarsActivity.class); final Intent intent = new Intent(context, CalculatorVarsActivity.class);
Android.addIntentFlags(intent, detached, context); Android.addIntentFlags(intent, detached, context);
context.startActivity(intent); context.startActivity(intent);
} }
public static void plotGraph(@NotNull final Context context) { public static void plotGraph(@Nonnull final Context context) {
final Intent intent = new Intent(); final Intent intent = new Intent();
intent.setClass(context, CalculatorPlotActivity.class); intent.setClass(context, CalculatorPlotActivity.class);
Android.addIntentFlags(intent, false, context); Android.addIntentFlags(intent, false, context);
context.startActivity(intent); context.startActivity(intent);
} }
public static void tryCreateVar(@NotNull final Context context) { public static void tryCreateVar(@Nonnull final Context context) {
final CalculatorDisplay display = Locator.getInstance().getDisplay(); final CalculatorDisplay display = Locator.getInstance().getDisplay();
final CalculatorDisplayViewState viewState = display.getViewState(); final CalculatorDisplayViewState viewState = display.getViewState();
if (viewState.isValid()) { if (viewState.isValid()) {
@ -132,7 +132,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
} }
} }
public static void tryCreateFunction(@NotNull final Context context) { public static void tryCreateFunction(@Nonnull final Context context) {
final CalculatorDisplay display = Locator.getInstance().getDisplay(); final CalculatorDisplay display = Locator.getInstance().getDisplay();
final CalculatorDisplayViewState viewState = display.getViewState(); final CalculatorDisplayViewState viewState = display.getViewState();
@ -150,7 +150,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
} }
} }
@NotNull @Nonnull
private static CalculatorNotifier getNotifier() { private static CalculatorNotifier getNotifier() {
return Locator.getInstance().getNotifier(); return Locator.getInstance().getNotifier();
} }
@ -177,19 +177,19 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
} }
} }
public static void openApp(@NotNull Context context) { public static void openApp(@Nonnull Context context) {
final Intent intent = new Intent(context, CalculatorActivity.class); final Intent intent = new Intent(context, CalculatorActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(intent); context.startActivity(intent);
} }
public static void likeButtonPressed(@NotNull final Context context) { public static void likeButtonPressed(@Nonnull final Context context) {
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(CalculatorApplication.FACEBOOK_APP_URL)); final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(CalculatorApplication.FACEBOOK_APP_URL));
Android.addIntentFlags(intent, false, context); Android.addIntentFlags(intent, false, context);
context.startActivity(intent); context.startActivity(intent);
} }
public static void showCalculationMessagesDialog(@NotNull Context context, @NotNull List<Message> messages) { public static void showCalculationMessagesDialog(@Nonnull Context context, @Nonnull List<Message> messages) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (CalculatorPreferences.Calculations.showCalculationMessagesDialog.getPreference(prefs)) { if (CalculatorPreferences.Calculations.showCalculationMessagesDialog.getPreference(prefs)) {
@ -198,7 +198,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
final Context context; final Context context;
final Object source = calculatorEventData.getSource(); final Object source = calculatorEventData.getSource();
@ -261,7 +261,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
} }
} }
public static void showEvaluationError(@NotNull Context context, @NotNull final String errorMessage) { public static void showEvaluationError(@Nonnull Context context, @Nonnull final String errorMessage) {
final LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); final LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
final View errorMessageView = layoutInflater.inflate(R.layout.display_error_message, null); final View errorMessageView = layoutInflater.inflate(R.layout.display_error_message, null);

View File

@ -3,7 +3,7 @@ package org.solovyev.android.calculator;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
/** /**
* User: serso * User: serso

View File

@ -12,7 +12,7 @@ import net.robotmedia.billing.model.BillingDB;
import org.acra.ACRA; import org.acra.ACRA;
import org.acra.ReportingInteractionMode; import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes; import org.acra.annotation.ReportsCrashes;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.Android; import org.solovyev.android.Android;
import org.solovyev.android.App; import org.solovyev.android.App;
import org.solovyev.android.ServiceLocator; import org.solovyev.android.ServiceLocator;
@ -59,7 +59,7 @@ public class CalculatorApplication extends android.app.Application implements Sh
public static final String ADMOB_USER_ID = "a14f02cf9c80cbc"; public static final String ADMOB_USER_ID = "a14f02cf9c80cbc";
@NotNull @Nonnull
private static CalculatorApplication instance; private static CalculatorApplication instance;
/* /*
@ -70,10 +70,10 @@ public class CalculatorApplication extends android.app.Application implements Sh
********************************************************************** **********************************************************************
*/ */
@NotNull @Nonnull
private final List<CalculatorEventListener> listeners = new ArrayList<CalculatorEventListener>(); private final List<CalculatorEventListener> listeners = new ArrayList<CalculatorEventListener>();
@NotNull @Nonnull
protected final Handler uiHandler = new Handler(); protected final Handler uiHandler = new Handler();
/* /*
@ -171,32 +171,32 @@ public class CalculatorApplication extends android.app.Application implements Sh
Locator.getInstance().getNotifier().showDebugMessage(TAG, "Application started!"); Locator.getInstance().getNotifier().showDebugMessage(TAG, "Application started!");
} }
private void setTheme(@NotNull SharedPreferences preferences) { private void setTheme(@Nonnull SharedPreferences preferences) {
final CalculatorPreferences.Gui.Theme theme = CalculatorPreferences.Gui.getTheme(preferences); final CalculatorPreferences.Gui.Theme theme = CalculatorPreferences.Gui.getTheme(preferences);
setTheme(theme.getThemeId()); setTheme(theme.getThemeId());
} }
@NotNull @Nonnull
public CalculatorActivityHelper createActivityHelper(int layoutResId, @NotNull String logTag) { public CalculatorActivityHelper createActivityHelper(int layoutResId, @Nonnull String logTag) {
return new CalculatorActivityHelperImpl(layoutResId, logTag); return new CalculatorActivityHelperImpl(layoutResId, logTag);
} }
@NotNull @Nonnull
public CalculatorFragmentHelper createFragmentHelper(int layoutId) { public CalculatorFragmentHelper createFragmentHelper(int layoutId) {
return new CalculatorFragmentHelperImpl(layoutId); return new CalculatorFragmentHelperImpl(layoutId);
} }
@NotNull @Nonnull
public CalculatorFragmentHelper createFragmentHelper(int layoutId, int titleResId) { public CalculatorFragmentHelper createFragmentHelper(int layoutId, int titleResId) {
return new CalculatorFragmentHelperImpl(layoutId, titleResId); return new CalculatorFragmentHelperImpl(layoutId, titleResId);
} }
@NotNull @Nonnull
public CalculatorFragmentHelper createFragmentHelper(int layoutId, int titleResId, boolean listenersOnCreate) { public CalculatorFragmentHelper createFragmentHelper(int layoutId, int titleResId, boolean listenersOnCreate) {
return new CalculatorFragmentHelperImpl(layoutId, titleResId, listenersOnCreate); return new CalculatorFragmentHelperImpl(layoutId, titleResId, listenersOnCreate);
} }
@NotNull @Nonnull
public Handler getUiHandler() { public Handler getUiHandler() {
return uiHandler; return uiHandler;
} }
@ -209,12 +209,12 @@ public class CalculatorApplication extends android.app.Application implements Sh
********************************************************************** **********************************************************************
*/ */
@NotNull @Nonnull
public static CalculatorApplication getInstance() { public static CalculatorApplication getInstance() {
return instance; return instance;
} }
public static boolean isMonkeyRunner(@NotNull Context context) { public static boolean isMonkeyRunner(@Nonnull Context context) {
// NOTE: this code is only for monkeyrunner // NOTE: this code is only for monkeyrunner
return context.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD) == PackageManager.PERMISSION_GRANTED; return context.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD) == PackageManager.PERMISSION_GRANTED;
} }

View File

@ -9,8 +9,8 @@ import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.Android; import org.solovyev.android.Android;
import org.solovyev.android.fragments.FragmentUtils; import org.solovyev.android.fragments.FragmentUtils;
import org.solovyev.common.msg.MessageType; import org.solovyev.common.msg.MessageType;
@ -23,13 +23,13 @@ import org.solovyev.common.text.Strings;
*/ */
public class CalculatorDialogActivity extends SherlockFragmentActivity { public class CalculatorDialogActivity extends SherlockFragmentActivity {
@NotNull @Nonnull
private static final String TAG = CalculatorDialogActivity.class.getSimpleName(); private static final String TAG = CalculatorDialogActivity.class.getSimpleName();
@NotNull @Nonnull
private static final String DIALOG_DATA_EXTRA = "dialog_data"; private static final String DIALOG_DATA_EXTRA = "dialog_data";
public static void showDialog(@NotNull Context context, @NotNull DialogData dialogData) { public static void showDialog(@Nonnull Context context, @Nonnull DialogData dialogData) {
final Intent intent = new Intent(); final Intent intent = new Intent();
intent.setClass(context, CalculatorDialogActivity.class); intent.setClass(context, CalculatorDialogActivity.class);
intent.putExtra(DIALOG_DATA_EXTRA, ParcelableDialogData.wrap(dialogData)); intent.putExtra(DIALOG_DATA_EXTRA, ParcelableDialogData.wrap(dialogData));
@ -91,7 +91,7 @@ public class CalculatorDialogActivity extends SherlockFragmentActivity {
} }
@Override @Override
public void onViewCreated(@NotNull View root, Bundle savedInstanceState) { public void onViewCreated(@Nonnull View root, Bundle savedInstanceState) {
super.onViewCreated(root, savedInstanceState); super.onViewCreated(root, savedInstanceState);
final DialogData dialogData = readDialogData(getArguments()); final DialogData dialogData = readDialogData(getArguments());

View File

@ -7,7 +7,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.actionbarsherlock.app.SherlockFragment; import com.actionbarsherlock.app.SherlockFragment;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
/** /**
* User: Solovyev_S * User: Solovyev_S
@ -16,7 +16,7 @@ import org.jetbrains.annotations.NotNull;
*/ */
public class CalculatorDisplayFragment extends SherlockFragment { public class CalculatorDisplayFragment extends SherlockFragment {
@NotNull @Nonnull
private CalculatorFragmentHelper fragmentHelper; private CalculatorFragmentHelper fragmentHelper;
@Override @Override

View File

@ -11,7 +11,7 @@ import com.actionbarsherlock.app.SherlockFragment;
import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.menu.ActivityMenu; import org.solovyev.android.menu.ActivityMenu;
import org.solovyev.android.menu.ListActivityMenu; import org.solovyev.android.menu.ListActivityMenu;
import org.solovyev.android.sherlock.menu.SherlockMenuHelper; import org.solovyev.android.sherlock.menu.SherlockMenuHelper;
@ -23,10 +23,10 @@ import org.solovyev.android.sherlock.menu.SherlockMenuHelper;
*/ */
public class CalculatorEditorFragment extends SherlockFragment { public class CalculatorEditorFragment extends SherlockFragment {
@NotNull @Nonnull
private CalculatorFragmentHelper fragmentHelper; private CalculatorFragmentHelper fragmentHelper;
@NotNull @Nonnull
private ActivityMenu<Menu, MenuItem> menu = ListActivityMenu.fromEnum(CalculatorMenu.class, SherlockMenuHelper.getInstance()); private ActivityMenu<Menu, MenuItem> menu = ListActivityMenu.fromEnum(CalculatorMenu.class, SherlockMenuHelper.getInstance());
public CalculatorEditorFragment() { public CalculatorEditorFragment() {

View File

@ -6,7 +6,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.actionbarsherlock.app.SherlockFragment; import com.actionbarsherlock.app.SherlockFragment;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
/** /**
* User: Solovyev_S * User: Solovyev_S
@ -15,18 +15,18 @@ import org.jetbrains.annotations.NotNull;
*/ */
public abstract class CalculatorFragment extends SherlockFragment { public abstract class CalculatorFragment extends SherlockFragment {
@NotNull @Nonnull
private final CalculatorFragmentHelper fragmentHelper; private final CalculatorFragmentHelper fragmentHelper;
protected CalculatorFragment(int layoutResId, int titleResId) { protected CalculatorFragment(int layoutResId, int titleResId) {
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(layoutResId, titleResId); fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(layoutResId, titleResId);
} }
protected CalculatorFragment(@NotNull CalculatorFragmentType fragmentType) { protected CalculatorFragment(@Nonnull CalculatorFragmentType fragmentType) {
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId()); fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId());
} }
protected CalculatorFragment(@NotNull CalculatorFragmentHelper fragmentHelper) { protected CalculatorFragment(@Nonnull CalculatorFragmentHelper fragmentHelper) {
this.fragmentHelper = fragmentHelper; this.fragmentHelper = fragmentHelper;
} }

View File

@ -2,7 +2,7 @@ package org.solovyev.android.calculator;
import android.os.Bundle; import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
/** /**
* User: Solovyev_S * User: Solovyev_S
@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
*/ */
public abstract class CalculatorFragmentActivity extends SherlockFragmentActivity { public abstract class CalculatorFragmentActivity extends SherlockFragmentActivity {
@NotNull @Nonnull
private final CalculatorActivityHelper activityHelper; private final CalculatorActivityHelper activityHelper;
protected CalculatorFragmentActivity() { protected CalculatorFragmentActivity() {
@ -22,7 +22,7 @@ public abstract class CalculatorFragmentActivity extends SherlockFragmentActivit
this.activityHelper = CalculatorApplication.getInstance().createActivityHelper(layoutResId, getClass().getSimpleName()); this.activityHelper = CalculatorApplication.getInstance().createActivityHelper(layoutResId, getClass().getSimpleName());
} }
@NotNull @Nonnull
protected CalculatorActivityHelper getActivityHelper() { protected CalculatorActivityHelper getActivityHelper() {
return activityHelper; return activityHelper;
} }

View File

@ -4,8 +4,8 @@ import android.support.v4.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
/** /**
* User: serso * User: serso
@ -14,20 +14,20 @@ import org.jetbrains.annotations.Nullable;
*/ */
public interface CalculatorFragmentHelper { public interface CalculatorFragmentHelper {
boolean isPane(@NotNull Fragment fragment); boolean isPane(@Nonnull Fragment fragment);
void setPaneTitle(@NotNull Fragment fragment, int titleResId); void setPaneTitle(@Nonnull Fragment fragment, int titleResId);
void onCreate(@NotNull Fragment fragment); void onCreate(@Nonnull Fragment fragment);
@NotNull @Nonnull
View onCreateView(@NotNull Fragment fragment, @NotNull LayoutInflater inflater, @Nullable ViewGroup container); View onCreateView(@Nonnull Fragment fragment, @Nonnull LayoutInflater inflater, @Nullable ViewGroup container);
void onViewCreated(@NotNull Fragment fragment, @NotNull View root); void onViewCreated(@Nonnull Fragment fragment, @Nonnull View root);
void onResume(@NotNull Fragment fragment); void onResume(@Nonnull Fragment fragment);
void onPause(@NotNull Fragment fragment); void onPause(@Nonnull Fragment fragment);
void onDestroy(@NotNull Fragment fragment); void onDestroy(@Nonnull Fragment fragment);
} }

View File

@ -6,8 +6,8 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import com.google.ads.AdView; import com.google.ads.AdView;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.ads.AdsController; import org.solovyev.android.ads.AdsController;
/** /**
@ -42,11 +42,11 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
} }
@Override @Override
public boolean isPane(@NotNull Fragment fragment) { public boolean isPane(@Nonnull Fragment fragment) {
return fragment.getActivity() instanceof CalculatorActivity; return fragment.getActivity() instanceof CalculatorActivity;
} }
public void setPaneTitle(@NotNull Fragment fragment, int titleResId) { public void setPaneTitle(@Nonnull Fragment fragment, int titleResId) {
final TextView fragmentTitle = (TextView) fragment.getView().findViewById(R.id.fragment_title); final TextView fragmentTitle = (TextView) fragment.getView().findViewById(R.id.fragment_title);
if (fragmentTitle != null) { if (fragmentTitle != null) {
if (!isPane(fragment)) { if (!isPane(fragment)) {
@ -58,7 +58,7 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
} }
@Override @Override
public void onCreate(@NotNull Fragment fragment) { public void onCreate(@Nonnull Fragment fragment) {
super.onCreate(fragment.getActivity()); super.onCreate(fragment.getActivity());
if (listenersOnCreate) { if (listenersOnCreate) {
@ -69,7 +69,7 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
} }
@Override @Override
public void onResume(@NotNull Fragment fragment) { public void onResume(@Nonnull Fragment fragment) {
if (!listenersOnCreate) { if (!listenersOnCreate) {
if (fragment instanceof CalculatorEventListener) { if (fragment instanceof CalculatorEventListener) {
Locator.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener) fragment); Locator.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener) fragment);
@ -78,7 +78,7 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
} }
@Override @Override
public void onPause(@NotNull Fragment fragment) { public void onPause(@Nonnull Fragment fragment) {
if (!listenersOnCreate) { if (!listenersOnCreate) {
if (fragment instanceof CalculatorEventListener) { if (fragment instanceof CalculatorEventListener) {
Locator.getInstance().getCalculator().removeCalculatorEventListener((CalculatorEventListener) fragment); Locator.getInstance().getCalculator().removeCalculatorEventListener((CalculatorEventListener) fragment);
@ -87,7 +87,7 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
} }
@Override @Override
public void onViewCreated(@NotNull Fragment fragment, @NotNull View root) { public void onViewCreated(@Nonnull Fragment fragment, @Nonnull View root) {
final ViewGroup adParentView = (ViewGroup) root.findViewById(R.id.ad_parent_view); final ViewGroup adParentView = (ViewGroup) root.findViewById(R.id.ad_parent_view);
final ViewGroup mainFragmentLayout = (ViewGroup) root.findViewById(R.id.main_fragment_layout); final ViewGroup mainFragmentLayout = (ViewGroup) root.findViewById(R.id.main_fragment_layout);
@ -109,7 +109,7 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
} }
@Override @Override
public void onDestroy(@NotNull Fragment fragment) { public void onDestroy(@Nonnull Fragment fragment) {
super.onDestroy(fragment.getActivity()); super.onDestroy(fragment.getActivity());
if (listenersOnCreate) { if (listenersOnCreate) {
@ -123,9 +123,9 @@ public class CalculatorFragmentHelperImpl extends AbstractCalculatorHelper imple
} }
} }
@NotNull @Nonnull
@Override @Override
public View onCreateView(@NotNull Fragment fragment, @NotNull LayoutInflater inflater, @Nullable ViewGroup container) { public View onCreateView(@Nonnull Fragment fragment, @Nonnull LayoutInflater inflater, @Nullable ViewGroup container) {
return inflater.inflate(layoutId, container, false); return inflater.inflate(layoutId, container, false);
} }
} }

View File

@ -1,7 +1,7 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.about.CalculatorAboutFragment; import org.solovyev.android.calculator.about.CalculatorAboutFragment;
import org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment; import org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment;
import org.solovyev.android.calculator.help.CalculatorHelpFaqFragment; import org.solovyev.android.calculator.help.CalculatorHelpFaqFragment;
@ -51,14 +51,14 @@ public enum CalculatorFragmentType {
matrix_edit(CalculatorMatrixEditFragment.class, R.layout.matrix_edit_fragment, R.string.c_screens), matrix_edit(CalculatorMatrixEditFragment.class, R.layout.matrix_edit_fragment, R.string.c_screens),
release_notes(CalculatorReleaseNotesFragment.class, R.layout.release_notes_fragment, R.string.c_release_notes); release_notes(CalculatorReleaseNotesFragment.class, R.layout.release_notes_fragment, R.string.c_release_notes);
@NotNull @Nonnull
private Class<? extends Fragment> fragmentClass; private Class<? extends Fragment> fragmentClass;
private final int defaultLayoutId; private final int defaultLayoutId;
private int defaultTitleResId; private int defaultTitleResId;
private CalculatorFragmentType(@NotNull Class<? extends Fragment> fragmentClass, private CalculatorFragmentType(@Nonnull Class<? extends Fragment> fragmentClass,
int defaultLayoutId, int defaultLayoutId,
int defaultTitleResId) { int defaultTitleResId) {
this.fragmentClass = fragmentClass; this.fragmentClass = fragmentClass;
@ -66,7 +66,7 @@ public enum CalculatorFragmentType {
this.defaultTitleResId = defaultTitleResId; this.defaultTitleResId = defaultTitleResId;
} }
@NotNull @Nonnull
public String getFragmentTag() { public String getFragmentTag() {
return this.name(); return this.name();
} }
@ -75,7 +75,7 @@ public enum CalculatorFragmentType {
return defaultTitleResId; return defaultTitleResId;
} }
@NotNull @Nonnull
public Class<? extends Fragment> getFragmentClass() { public Class<? extends Fragment> getFragmentClass() {
return fragmentClass; return fragmentClass;
} }
@ -84,8 +84,8 @@ public enum CalculatorFragmentType {
return defaultLayoutId; return defaultLayoutId;
} }
@NotNull @Nonnull
public String createSubFragmentTag(@NotNull String subFragmentTag) { public String createSubFragmentTag(@Nonnull String subFragmentTag) {
return this.getFragmentTag() + "_" + subFragmentTag; return this.getFragmentTag() + "_" + subFragmentTag;
} }
} }

View File

@ -7,8 +7,8 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.actionbarsherlock.app.SherlockFragment; import com.actionbarsherlock.app.SherlockFragment;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
/** /**
@ -18,10 +18,10 @@ import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
*/ */
public class CalculatorKeyboardFragment extends SherlockFragment implements SharedPreferences.OnSharedPreferenceChangeListener { public class CalculatorKeyboardFragment extends SherlockFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@NotNull @Nonnull
private CalculatorPreferences.Gui.Theme theme; private CalculatorPreferences.Gui.Theme theme;
@NotNull @Nonnull
private CalculatorFragmentHelper fragmentHelper; private CalculatorFragmentHelper fragmentHelper;
@Override @Override
@ -83,7 +83,7 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar
} }
/* private static void setMarginsForView(@Nullable View view, int marginLeft, int marginBottom, @NotNull Context context) { /* private static void setMarginsForView(@Nullable View view, int marginLeft, int marginBottom, @Nonnull Context context) {
// IMPORTANT: this is workaround for probably android bug // IMPORTANT: this is workaround for probably android bug
// currently margin values set in styles are not applied for some reasons to the views (using include tag) => set them manually // currently margin values set in styles are not applied for some reasons to the views (using include tag) => set them manually
@ -134,12 +134,12 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar
return (AndroidCalculatorDisplayView) Locator.getInstance().getDisplay().getView(); return (AndroidCalculatorDisplayView) Locator.getInstance().getDisplay().getView();
} }
@NotNull @Nonnull
private Calculator getCalculator() { private Calculator getCalculator() {
return Locator.getInstance().getCalculator(); return Locator.getInstance().getCalculator();
} }
@NotNull @Nonnull
private static CalculatorKeyboard getKeyboard() { private static CalculatorKeyboard getKeyboard() {
return Locator.getInstance().getKeyboard(); return Locator.getInstance().getKeyboard();
} }

View File

@ -6,7 +6,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.actionbarsherlock.app.SherlockListFragment; import com.actionbarsherlock.app.SherlockListFragment;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
/** /**
* User: Solovyev_S * User: Solovyev_S
@ -15,18 +15,18 @@ import org.jetbrains.annotations.NotNull;
*/ */
public abstract class CalculatorListFragment extends SherlockListFragment { public abstract class CalculatorListFragment extends SherlockListFragment {
@NotNull @Nonnull
private final CalculatorFragmentHelper fragmentHelper; private final CalculatorFragmentHelper fragmentHelper;
protected CalculatorListFragment(int layoutResId, int titleResId) { protected CalculatorListFragment(int layoutResId, int titleResId) {
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(layoutResId, titleResId); fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(layoutResId, titleResId);
} }
protected CalculatorListFragment(@NotNull CalculatorFragmentType fragmentType) { protected CalculatorListFragment(@Nonnull CalculatorFragmentType fragmentType) {
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId()); fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId());
} }
protected CalculatorListFragment(@NotNull CalculatorFragmentHelper fragmentHelper) { protected CalculatorListFragment(@Nonnull CalculatorFragmentHelper fragmentHelper) {
this.fragmentHelper = fragmentHelper; this.fragmentHelper = fragmentHelper;
} }

View File

@ -4,7 +4,7 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.view.NumeralBaseConverterDialog; import org.solovyev.android.calculator.view.NumeralBaseConverterDialog;
import org.solovyev.android.menu.LabeledMenuItem; import org.solovyev.android.menu.LabeledMenuItem;
@ -17,35 +17,35 @@ enum CalculatorMenu implements LabeledMenuItem<MenuItem> {
settings(R.string.c_settings) { settings(R.string.c_settings) {
@Override @Override
public void onClick(@NotNull MenuItem data, @NotNull Context context) { public void onClick(@Nonnull MenuItem data, @Nonnull Context context) {
CalculatorActivityLauncher.showSettings(context); CalculatorActivityLauncher.showSettings(context);
} }
}, },
history(R.string.c_history) { history(R.string.c_history) {
@Override @Override
public void onClick(@NotNull MenuItem data, @NotNull Context context) { public void onClick(@Nonnull MenuItem data, @Nonnull Context context) {
CalculatorActivityLauncher.showHistory(context); CalculatorActivityLauncher.showHistory(context);
} }
}, },
plotter(R.string.cpp_plotter) { plotter(R.string.cpp_plotter) {
@Override @Override
public void onClick(@NotNull MenuItem data, @NotNull Context context) { public void onClick(@Nonnull MenuItem data, @Nonnull Context context) {
Locator.getInstance().getPlotter().plot(); Locator.getInstance().getPlotter().plot();
} }
}, },
conversion_tool(R.string.c_conversion_tool) { conversion_tool(R.string.c_conversion_tool) {
@Override @Override
public void onClick(@NotNull MenuItem data, @NotNull Context context) { public void onClick(@Nonnull MenuItem data, @Nonnull Context context) {
new NumeralBaseConverterDialog(null).show(context); new NumeralBaseConverterDialog(null).show(context);
} }
}, },
exit(R.string.c_exit) { exit(R.string.c_exit) {
@Override @Override
public void onClick(@NotNull MenuItem data, @NotNull Context context) { public void onClick(@Nonnull MenuItem data, @Nonnull Context context) {
if (context instanceof Activity) { if (context instanceof Activity) {
((Activity) context).finish(); ((Activity) context).finish();
} else { } else {
@ -56,14 +56,14 @@ enum CalculatorMenu implements LabeledMenuItem<MenuItem> {
help(R.string.c_help) { help(R.string.c_help) {
@Override @Override
public void onClick(@NotNull MenuItem data, @NotNull Context context) { public void onClick(@Nonnull MenuItem data, @Nonnull Context context) {
CalculatorActivityLauncher.showHelp(context); CalculatorActivityLauncher.showHelp(context);
} }
}, },
about(R.string.c_about) { about(R.string.c_about) {
@Override @Override
public void onClick(@NotNull MenuItem data, @NotNull Context context) { public void onClick(@Nonnull MenuItem data, @Nonnull Context context) {
CalculatorActivityLauncher.showAbout(context); CalculatorActivityLauncher.showAbout(context);
} }
}; };
@ -74,9 +74,9 @@ enum CalculatorMenu implements LabeledMenuItem<MenuItem> {
this.captionResId = captionResId; this.captionResId = captionResId;
} }
@NotNull @Nonnull
@Override @Override
public String getCaption(@NotNull Context context) { public String getCaption(@Nonnull Context context) {
return context.getString(captionResId); return context.getString(captionResId);
} }
} }

View File

@ -6,7 +6,7 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
/** /**
* User: serso * User: serso
@ -18,7 +18,7 @@ public final class CalculatorSecurity {
private CalculatorSecurity() { private CalculatorSecurity() {
} }
@NotNull @Nonnull
public static String getPK() { public static String getPK() {
final StringBuilder result = new StringBuilder(); final StringBuilder result = new StringBuilder();

View File

@ -6,8 +6,8 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.common.JPredicate; import org.solovyev.common.JPredicate;
/** /**
@ -19,10 +19,10 @@ public class CharacterAtPositionFinder implements JPredicate<Character> {
private int i; private int i;
@NotNull @Nonnull
private final String targetString; private final String targetString;
public CharacterAtPositionFinder(@NotNull String targetString, int i) { public CharacterAtPositionFinder(@Nonnull String targetString, int i) {
this.targetString = targetString; this.targetString = targetString;
this.i = i; this.i = i;
} }

View File

@ -6,7 +6,7 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.view.MotionEvent; import android.view.MotionEvent;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.view.drag.DirectionDragButton; import org.solovyev.android.view.drag.DirectionDragButton;
import org.solovyev.android.view.drag.DragButton; import org.solovyev.android.view.drag.DragButton;
import org.solovyev.android.view.drag.DragDirection; import org.solovyev.android.view.drag.DragDirection;
@ -24,7 +24,7 @@ public class CursorDragProcessor implements SimpleOnDragListener.DragProcessor {
} }
@Override @Override
public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) { public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull Point2d startPoint2d, @Nonnull MotionEvent motionEvent) {
boolean result = false; boolean result = false;
if (dragButton instanceof DirectionDragButton) { if (dragButton instanceof DirectionDragButton) {

View File

@ -7,7 +7,7 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.view.MotionEvent; import android.view.MotionEvent;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.view.drag.DirectionDragButton; import org.solovyev.android.view.drag.DirectionDragButton;
import org.solovyev.android.view.drag.DragButton; import org.solovyev.android.view.drag.DragButton;
import org.solovyev.android.view.drag.DragDirection; import org.solovyev.android.view.drag.DragDirection;
@ -25,7 +25,7 @@ public class EqualsDragProcessor implements SimpleOnDragListener.DragProcessor {
} }
@Override @Override
public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) { public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull Point2d startPoint2d, @Nonnull MotionEvent motionEvent) {
boolean result = false; boolean result = false;
if (dragButton instanceof DirectionDragButton) { if (dragButton instanceof DirectionDragButton) {

View File

@ -3,7 +3,7 @@ package org.solovyev.android.calculator;
import android.app.Activity; import android.app.Activity;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import jscl.NumeralBase; import jscl.NumeralBase;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
/** /**
@ -13,7 +13,7 @@ import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
*/ */
public class NumeralBaseButtons { public class NumeralBaseButtons {
public static void toggleNumericDigits(@NotNull Activity activity, @NotNull NumeralBase currentNumeralBase) { public static void toggleNumericDigits(@Nonnull Activity activity, @Nonnull NumeralBase currentNumeralBase) {
for (NumeralBase numeralBase : NumeralBase.values()) { for (NumeralBase numeralBase : NumeralBase.values()) {
if (currentNumeralBase != numeralBase) { if (currentNumeralBase != numeralBase) {
AndroidNumeralBase.valueOf(numeralBase).toggleButtons(false, activity); AndroidNumeralBase.valueOf(numeralBase).toggleButtons(false, activity);
@ -23,7 +23,7 @@ public class NumeralBaseButtons {
AndroidNumeralBase.valueOf(currentNumeralBase).toggleButtons(true, activity); AndroidNumeralBase.valueOf(currentNumeralBase).toggleButtons(true, activity);
} }
public static void toggleNumericDigits(@NotNull Activity activity, @NotNull SharedPreferences preferences) { public static void toggleNumericDigits(@Nonnull Activity activity, @Nonnull SharedPreferences preferences) {
if (CalculatorPreferences.Gui.hideNumeralBaseDigits.getPreference(preferences)) { if (CalculatorPreferences.Gui.hideNumeralBaseDigits.getPreference(preferences)) {
final NumeralBase nb = AndroidCalculatorEngine.Preferences.numeralBase.getPreference(preferences); final NumeralBase nb = AndroidCalculatorEngine.Preferences.numeralBase.getPreference(preferences);
toggleNumericDigits(activity, nb); toggleNumericDigits(activity, nb);

View File

@ -6,7 +6,7 @@
package org.solovyev.android.calculator.about; package org.solovyev.android.calculator.about;
import android.os.Bundle; import android.os.Bundle;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.CalculatorFragmentActivity; import org.solovyev.android.calculator.CalculatorFragmentActivity;
import org.solovyev.android.calculator.CalculatorFragmentType; import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;

View File

@ -12,7 +12,7 @@ import android.text.Html;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.Android; import org.solovyev.android.Android;
import org.solovyev.android.calculator.CalculatorApplication; import org.solovyev.android.calculator.CalculatorApplication;
import org.solovyev.android.calculator.CalculatorFragment; import org.solovyev.android.calculator.CalculatorFragment;
@ -41,13 +41,13 @@ public class CalculatorReleaseNotesFragment extends CalculatorFragment {
releaseNotes.setText(Html.fromHtml(getReleaseNotes(this.getActivity()))); releaseNotes.setText(Html.fromHtml(getReleaseNotes(this.getActivity())));
} }
@NotNull @Nonnull
public static String getReleaseNotes(@NotNull Context context) { public static String getReleaseNotes(@Nonnull Context context) {
return getReleaseNotes(context, 0); return getReleaseNotes(context, 0);
} }
@NotNull @Nonnull
public static String getReleaseNotes(@NotNull Context context, int minVersion) { public static String getReleaseNotes(@Nonnull Context context, int minVersion) {
final StringBuilder result = new StringBuilder(); final StringBuilder result = new StringBuilder();
final String releaseNotesForTitle = context.getString(R.string.c_release_notes_for_title); final String releaseNotesForTitle = context.getString(R.string.c_release_notes_for_title);

View File

@ -1,8 +1,8 @@
package org.solovyev.android.calculator.about; package org.solovyev.android.calculator.about;
import android.content.res.Resources; import android.content.res.Resources;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
/** /**
* User: serso * User: serso
@ -11,19 +11,19 @@ import org.jetbrains.annotations.Nullable;
*/ */
public class TextHelper { public class TextHelper {
@NotNull @Nonnull
public String packageName; public String packageName;
@NotNull @Nonnull
public Resources resources; public Resources resources;
public TextHelper(@NotNull Resources resources, @NotNull String packageName) { public TextHelper(@Nonnull Resources resources, @Nonnull String packageName) {
this.packageName = packageName; this.packageName = packageName;
this.resources = resources; this.resources = resources;
} }
@Nullable @Nullable
public String getText(@NotNull String stringName) { public String getText(@Nonnull String stringName) {
final int stringId = this.resources.getIdentifier(stringName, "string", this.packageName); final int stringId = this.resources.getIdentifier(stringName, "string", this.packageName);
try { try {
return resources.getString(stringId); return resources.getString(stringId);

View File

@ -17,8 +17,8 @@ import jscl.math.function.Constant;
import jscl.math.function.CustomFunction; import jscl.math.function.CustomFunction;
import jscl.math.function.Function; import jscl.math.function.Function;
import jscl.math.function.IFunction; import jscl.math.function.IFunction;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.math.edit.CalculatorFunctionsActivity; import org.solovyev.android.calculator.math.edit.CalculatorFunctionsActivity;
import org.solovyev.android.calculator.math.edit.CalculatorFunctionsFragment; import org.solovyev.android.calculator.math.edit.CalculatorFunctionsFragment;
@ -39,14 +39,14 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul
private static final String INPUT = "input"; private static final String INPUT = "input";
@NotNull @Nonnull
private Input input; private Input input;
public FunctionEditDialogFragment() { public FunctionEditDialogFragment() {
this(Input.newInstance()); this(Input.newInstance());
} }
public FunctionEditDialogFragment(@NotNull Input input) { public FunctionEditDialogFragment(@Nonnull Input input) {
this.input = input; this.input = input;
} }
@ -65,7 +65,7 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul
} }
@Override @Override
public void onViewCreated(@NotNull View root, Bundle savedInstanceState) { public void onViewCreated(@Nonnull View root, Bundle savedInstanceState) {
super.onViewCreated(root, savedInstanceState); super.onViewCreated(root, savedInstanceState);
final FunctionParamsView paramsView = (FunctionParamsView) root.findViewById(R.id.function_params_layout); final FunctionParamsView paramsView = (FunctionParamsView) root.findViewById(R.id.function_params_layout);
@ -120,7 +120,7 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul
} }
@Override @Override
public void onSaveInstanceState(@NotNull Bundle out) { public void onSaveInstanceState(@Nonnull Bundle out) {
super.onSaveInstanceState(out); super.onSaveInstanceState(out);
out.putParcelable(INPUT, FunctionEditorSaver.readInput(input.getFunction(), getView())); out.putParcelable(INPUT, FunctionEditorSaver.readInput(input.getFunction(), getView()));
@ -141,7 +141,7 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
switch (calculatorEventType) { switch (calculatorEventType) {
case function_removed: case function_removed:
case function_added: case function_added:
@ -162,7 +162,7 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul
********************************************************************** **********************************************************************
*/ */
public static void showDialog(@NotNull Input input, @NotNull Context context) { public static void showDialog(@Nonnull Input input, @Nonnull Context context) {
if (context instanceof SherlockFragmentActivity) { if (context instanceof SherlockFragmentActivity) {
FunctionEditDialogFragment.showDialog(input, ((SherlockFragmentActivity) context).getSupportFragmentManager()); FunctionEditDialogFragment.showDialog(input, ((SherlockFragmentActivity) context).getSupportFragmentManager());
} else { } else {
@ -173,7 +173,7 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul
} }
} }
public static void showDialog(@NotNull Input input, @NotNull FragmentManager fm) { public static void showDialog(@Nonnull Input input, @Nonnull FragmentManager fm) {
AndroidSherlockUtils.showDialog(new FunctionEditDialogFragment(input), "function-editor", fm); AndroidSherlockUtils.showDialog(new FunctionEditDialogFragment(input), "function-editor", fm);
} }
@ -181,7 +181,7 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul
public static final Parcelable.Creator<Input> CREATOR = new Creator<Input>() { public static final Parcelable.Creator<Input> CREATOR = new Creator<Input>() {
@Override @Override
public Input createFromParcel(@NotNull Parcel in) { public Input createFromParcel(@Nonnull Parcel in) {
return Input.fromParcel(in); return Input.fromParcel(in);
} }
@ -193,7 +193,7 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul
private static final Parcelable.Creator<String> STRING_CREATOR = new Creator<String>() { private static final Parcelable.Creator<String> STRING_CREATOR = new Creator<String>() {
@Override @Override
public String createFromParcel(@NotNull Parcel in) { public String createFromParcel(@Nonnull Parcel in) {
return in.readString(); return in.readString();
} }
@ -203,8 +203,8 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul
} }
}; };
@NotNull @Nonnull
private static Input fromParcel(@NotNull Parcel in) { private static Input fromParcel(@Nonnull Parcel in) {
final Input result = new Input(); final Input result = new Input();
result.name = in.readString(); result.name = in.readString();
result.content = in.readString(); result.content = in.readString();
@ -237,24 +237,24 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul
private Input() { private Input() {
} }
@NotNull @Nonnull
public static Input newInstance() { public static Input newInstance() {
return new Input(); return new Input();
} }
@NotNull @Nonnull
public static Input newFromFunction(@NotNull IFunction function) { public static Input newFromFunction(@Nonnull IFunction function) {
final Input result = new Input(); final Input result = new Input();
result.function = AFunction.fromIFunction(function); result.function = AFunction.fromIFunction(function);
return result; return result;
} }
@NotNull @Nonnull
public static Input newInstance(@Nullable IFunction function, public static Input newInstance(@Nullable IFunction function,
@Nullable String name, @Nullable String name,
@Nullable String value, @Nullable String value,
@Nullable String description, @Nullable String description,
@NotNull List<String> parameterNames) { @Nonnull List<String> parameterNames) {
final Input result = new Input(); final Input result = new Input();
if (function != null) { if (function != null) {
@ -299,7 +299,7 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul
} }
@Override @Override
public void writeToParcel(@NotNull Parcel out, int flags) { public void writeToParcel(@Nonnull Parcel out, int flags) {
out.writeString(name); out.writeString(name);
out.writeString(content); out.writeString(content);
out.writeString(description); out.writeString(description);
@ -307,8 +307,8 @@ public class FunctionEditDialogFragment extends DialogFragment implements Calcul
out.writeSerializable(function); out.writeSerializable(function);
} }
@NotNull @Nonnull
public static Input newFromDisplay(@NotNull CalculatorDisplayViewState viewState) { public static Input newFromDisplay(@Nonnull CalculatorDisplayViewState viewState) {
final Input result = new Input(); final Input result = new Input();
result.content = viewState.getText(); result.content = viewState.getText();

View File

@ -5,8 +5,8 @@ import android.widget.EditText;
import jscl.CustomFunctionCalculationException; import jscl.CustomFunctionCalculationException;
import jscl.math.function.Function; import jscl.math.function.Function;
import jscl.math.function.IFunction; import jscl.math.function.IFunction;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.CalculatorFunctionsMathRegistry; import org.solovyev.android.calculator.CalculatorFunctionsMathRegistry;
import org.solovyev.android.calculator.CalculatorMathRegistry; import org.solovyev.android.calculator.CalculatorMathRegistry;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
@ -21,27 +21,27 @@ import java.util.List;
public class FunctionEditorSaver implements View.OnClickListener { public class FunctionEditorSaver implements View.OnClickListener {
@NotNull @Nonnull
private final Object source; private final Object source;
@NotNull @Nonnull
private final AFunction.Builder builder; private final AFunction.Builder builder;
@Nullable @Nullable
private final IFunction editedInstance; private final IFunction editedInstance;
@NotNull @Nonnull
private final View view; private final View view;
@NotNull @Nonnull
private final CalculatorMathRegistry<Function> mathRegistry; private final CalculatorMathRegistry<Function> mathRegistry;
public FunctionEditorSaver(@NotNull AFunction.Builder builder, public FunctionEditorSaver(@Nonnull AFunction.Builder builder,
@Nullable IFunction editedInstance, @Nullable IFunction editedInstance,
@NotNull View view, @Nonnull View view,
@NotNull CalculatorMathRegistry<Function> registry, @Nonnull CalculatorMathRegistry<Function> registry,
@NotNull Object source) { @Nonnull Object source) {
this.builder = builder; this.builder = builder;
this.editedInstance = editedInstance; this.editedInstance = editedInstance;
@ -111,8 +111,8 @@ public class FunctionEditorSaver implements View.OnClickListener {
} }
} }
@NotNull @Nonnull
public static FunctionEditDialogFragment.Input readInput(@Nullable IFunction function, @NotNull View root) { public static FunctionEditDialogFragment.Input readInput(@Nullable IFunction function, @Nonnull View root) {
final EditText editName = (EditText) root.findViewById(R.id.function_edit_name); final EditText editName = (EditText) root.findViewById(R.id.function_edit_name);
String name = editName.getText().toString(); String name = editName.getText().toString();
@ -128,7 +128,7 @@ public class FunctionEditorSaver implements View.OnClickListener {
return FunctionEditDialogFragment.Input.newInstance(function, name, content, description, parameterNames); return FunctionEditDialogFragment.Input.newInstance(function, name, content, description, parameterNames);
} }
private boolean validateParameters(@NotNull List<String> parameterNames) { private boolean validateParameters(@Nonnull List<String> parameterNames) {
for (String parameterName : parameterNames) { for (String parameterName : parameterNames) {
if (!VarEditorSaver.isValidName(parameterName)) { if (!VarEditorSaver.isValidName(parameterName)) {
return false; return false;

View File

@ -9,8 +9,8 @@ import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import jscl.text.MutableInt; import jscl.text.MutableInt;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import java.util.ArrayList; import java.util.ArrayList;
@ -19,10 +19,10 @@ import java.util.List;
public class FunctionParamsView extends LinearLayout { public class FunctionParamsView extends LinearLayout {
@NotNull @Nonnull
private final MutableInt paramsCount = new MutableInt(0); private final MutableInt paramsCount = new MutableInt(0);
@NotNull @Nonnull
private final List<Integer> paramIds = new ArrayList<Integer>(10); private final List<Integer> paramIds = new ArrayList<Integer>(10);
private static final String PARAM_TAG_PREFIX = "function_param_"; private static final String PARAM_TAG_PREFIX = "function_param_";
@ -43,7 +43,7 @@ public class FunctionParamsView extends LinearLayout {
init(Collections.<String>emptyList()); init(Collections.<String>emptyList());
} }
public void init(@NotNull List<String> parameters) { public void init(@Nonnull List<String> parameters) {
this.setOrientation(VERTICAL); this.setOrientation(VERTICAL);
final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@ -110,7 +110,7 @@ public class FunctionParamsView extends LinearLayout {
} }
} }
private void downParam(@NotNull Integer id) { private void downParam(@Nonnull Integer id) {
synchronized (paramsCount) { synchronized (paramsCount) {
int index = paramIds.indexOf(id); int index = paramIds.indexOf(id);
if (index < paramIds.size() - 1) { if (index < paramIds.size() - 1) {
@ -119,7 +119,7 @@ public class FunctionParamsView extends LinearLayout {
} }
} }
private void upParam(@NotNull Integer id) { private void upParam(@Nonnull Integer id) {
synchronized (paramsCount) { synchronized (paramsCount) {
int index = paramIds.indexOf(id); int index = paramIds.indexOf(id);
if (index > 0) { if (index > 0) {
@ -139,25 +139,25 @@ public class FunctionParamsView extends LinearLayout {
} }
} }
private void swap(@NotNull TextView first, private void swap(@Nonnull TextView first,
@NotNull TextView second) { @Nonnull TextView second) {
final CharSequence tmp = first.getText(); final CharSequence tmp = first.getText();
first.setText(second.getText()); first.setText(second.getText());
second.setText(tmp); second.setText(tmp);
} }
@Nullable @Nullable
private View getParamView(@NotNull Integer id) { private View getParamView(@Nonnull Integer id) {
final String tag = getParamTag(id); final String tag = getParamTag(id);
return this.findViewWithTag(tag); return this.findViewWithTag(tag);
} }
@NotNull @Nonnull
private String getParamTag(@NotNull Integer index) { private String getParamTag(@Nonnull Integer index) {
return PARAM_TAG_PREFIX + index; return PARAM_TAG_PREFIX + index;
} }
public void removeParam(@NotNull Integer id) { public void removeParam(@Nonnull Integer id) {
synchronized (paramsCount) { synchronized (paramsCount) {
if (paramIds.contains(id)) { if (paramIds.contains(id)) {
final View editParamView = getParamView(id); final View editParamView = getParamView(id);
@ -169,7 +169,7 @@ public class FunctionParamsView extends LinearLayout {
} }
} }
@NotNull @Nonnull
public List<String> getParameterNames() { public List<String> getParameterNames() {
synchronized (paramsCount) { synchronized (paramsCount) {
final List<String> result = new ArrayList<String>(paramsCount.intValue()); final List<String> result = new ArrayList<String>(paramsCount.intValue());

View File

@ -7,7 +7,7 @@
package org.solovyev.android.calculator.help; package org.solovyev.android.calculator.help;
import android.os.Bundle; import android.os.Bundle;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.CalculatorFragmentActivity; import org.solovyev.android.calculator.CalculatorFragmentActivity;
import org.solovyev.android.calculator.CalculatorFragmentType; import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;

View File

@ -20,8 +20,8 @@ import com.actionbarsherlock.app.SherlockListFragment;
import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.jscl.JsclOperation; import org.solovyev.android.calculator.jscl.JsclOperation;
import org.solovyev.android.menu.*; import org.solovyev.android.menu.*;
@ -52,7 +52,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
********************************************************************** **********************************************************************
*/ */
@NotNull @Nonnull
private static final String TAG = "CalculatorHistoryFragment"; private static final String TAG = "CalculatorHistoryFragment";
public static final Comparator<CalculatorHistoryState> COMPARATOR = new Comparator<CalculatorHistoryState>() { public static final Comparator<CalculatorHistoryState> COMPARATOR = new Comparator<CalculatorHistoryState>() {
@ -79,15 +79,15 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
*/ */
@NotNull @Nonnull
private ArrayAdapter<CalculatorHistoryState> adapter; private ArrayAdapter<CalculatorHistoryState> adapter;
@NotNull @Nonnull
private CalculatorFragmentHelper fragmentHelper; private CalculatorFragmentHelper fragmentHelper;
private ActivityMenu<Menu, MenuItem> menu = ListActivityMenu.fromResource(org.solovyev.android.calculator.R.menu.history_menu, HistoryMenu.class, SherlockMenuHelper.getInstance()); private ActivityMenu<Menu, MenuItem> menu = ListActivityMenu.fromResource(org.solovyev.android.calculator.R.menu.history_menu, HistoryMenu.class, SherlockMenuHelper.getInstance());
protected AbstractCalculatorHistoryFragment(@NotNull CalculatorFragmentType fragmentType) { protected AbstractCalculatorHistoryFragment(@Nonnull CalculatorFragmentType fragmentType) {
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId(), false); fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId(), false);
} }
@ -102,7 +102,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
logDebug("onCreate"); logDebug("onCreate");
} }
private int logDebug(@NotNull String msg) { private int logDebug(@Nonnull String msg) {
return Log.d(TAG + ": " + getTag(), msg); return Log.d(TAG + ": " + getTag(), msg);
} }
@ -212,7 +212,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
public static boolean isAlreadySaved(@NotNull CalculatorHistoryState historyState) { public static boolean isAlreadySaved(@Nonnull CalculatorHistoryState historyState) {
assert !historyState.isSaved(); assert !historyState.isSaved();
boolean result = false; boolean result = false;
@ -235,11 +235,11 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
return result; return result;
} }
public static void useHistoryItem(@NotNull final CalculatorHistoryState historyState) { public static void useHistoryItem(@Nonnull final CalculatorHistoryState historyState) {
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_history_state, historyState); Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_history_state, historyState);
} }
@NotNull @Nonnull
private List<CalculatorHistoryState> getHistoryList() { private List<CalculatorHistoryState> getHistoryList() {
final List<CalculatorHistoryState> calculatorHistoryStates = getHistoryItems(); final List<CalculatorHistoryState> calculatorHistoryStates = getHistoryItems();
@ -258,11 +258,11 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
return calculatorHistoryStates; return calculatorHistoryStates;
} }
@NotNull @Nonnull
protected abstract List<CalculatorHistoryState> getHistoryItems(); protected abstract List<CalculatorHistoryState> getHistoryItems();
@NotNull @Nonnull
public static String getHistoryText(@NotNull CalculatorHistoryState state) { public static String getHistoryText(@Nonnull CalculatorHistoryState state) {
final StringBuilder result = new StringBuilder(); final StringBuilder result = new StringBuilder();
result.append(state.getEditorState().getText()); result.append(state.getEditorState().getText());
result.append(getIdentitySign(state.getDisplayState().getJsclOperation())); result.append(getIdentitySign(state.getDisplayState().getJsclOperation()));
@ -273,20 +273,20 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
return result.toString(); return result.toString();
} }
@NotNull @Nonnull
private static String getIdentitySign(@NotNull JsclOperation jsclOperation) { private static String getIdentitySign(@Nonnull JsclOperation jsclOperation) {
return jsclOperation == JsclOperation.simplify ? "" : "="; return jsclOperation == JsclOperation.simplify ? "" : "=";
} }
protected abstract void clearHistory(); protected abstract void clearHistory();
@NotNull @Nonnull
protected ArrayAdapter<CalculatorHistoryState> getAdapter() { protected ArrayAdapter<CalculatorHistoryState> getAdapter() {
return adapter; return adapter;
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
switch (calculatorEventType) { switch (calculatorEventType) {
case history_state_added: case history_state_added:
getActivity().runOnUiThread(new Runnable() { getActivity().runOnUiThread(new Runnable() {
@ -337,7 +337,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
clear_history(org.solovyev.android.calculator.R.id.history_menu_clear_history) { clear_history(org.solovyev.android.calculator.R.id.history_menu_clear_history) {
@Override @Override
public void onClick(@NotNull MenuItem data, @NotNull Context context) { public void onClick(@Nonnull MenuItem data, @Nonnull Context context) {
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.clear_history_requested, null); Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.clear_history_requested, null);
} }
}; };
@ -348,7 +348,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
this.itemId = itemId; this.itemId = itemId;
} }
@NotNull @Nonnull
@Override @Override
public Integer getItemId() { public Integer getItemId() {
return this.itemId; return this.itemId;

View File

@ -10,8 +10,8 @@ import android.app.Application;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.Calculator; import org.solovyev.android.calculator.Calculator;
import org.solovyev.android.calculator.CalculatorEventData; import org.solovyev.android.calculator.CalculatorEventData;
import org.solovyev.android.calculator.CalculatorEventType; import org.solovyev.android.calculator.CalculatorEventType;
@ -27,13 +27,13 @@ import java.util.List;
*/ */
public class AndroidCalculatorHistory implements CalculatorHistory { public class AndroidCalculatorHistory implements CalculatorHistory {
@NotNull @Nonnull
private final CalculatorHistoryImpl calculatorHistory; private final CalculatorHistoryImpl calculatorHistory;
@NotNull @Nonnull
private final Context context; private final Context context;
public AndroidCalculatorHistory(@NotNull Application application, @NotNull Calculator calculator) { public AndroidCalculatorHistory(@Nonnull Application application, @Nonnull Calculator calculator) {
this.context = application; this.context = application;
calculatorHistory = new CalculatorHistoryImpl(calculator); calculatorHistory = new CalculatorHistoryImpl(calculator);
} }
@ -63,7 +63,7 @@ public class AndroidCalculatorHistory implements CalculatorHistory {
save(); save();
} }
public void removeSavedHistory(@NotNull CalculatorHistoryState historyState) { public void removeSavedHistory(@Nonnull CalculatorHistoryState historyState) {
historyState.setSaved(false); historyState.setSaved(false);
calculatorHistory.removeSavedHistory(historyState); calculatorHistory.removeSavedHistory(historyState);
save(); save();
@ -100,12 +100,12 @@ public class AndroidCalculatorHistory implements CalculatorHistory {
} }
@Override @Override
public boolean isActionAvailable(@NotNull HistoryAction historyAction) { public boolean isActionAvailable(@Nonnull HistoryAction historyAction) {
return calculatorHistory.isActionAvailable(historyAction); return calculatorHistory.isActionAvailable(historyAction);
} }
@Override @Override
public CalculatorHistoryState doAction(@NotNull HistoryAction historyAction, @Nullable CalculatorHistoryState currentState) { public CalculatorHistoryState doAction(@Nonnull HistoryAction historyAction, @Nullable CalculatorHistoryState currentState) {
return calculatorHistory.doAction(historyAction, currentState); return calculatorHistory.doAction(historyAction, currentState);
} }
@ -114,13 +114,13 @@ public class AndroidCalculatorHistory implements CalculatorHistory {
calculatorHistory.addState(currentState); calculatorHistory.addState(currentState);
} }
@NotNull @Nonnull
@Override @Override
public List<CalculatorHistoryState> getStates() { public List<CalculatorHistoryState> getStates() {
return calculatorHistory.getStates(); return calculatorHistory.getStates();
} }
@NotNull @Nonnull
@Override @Override
public List<CalculatorHistoryState> getStates(boolean includeIntermediateStates) { public List<CalculatorHistoryState> getStates(boolean includeIntermediateStates) {
return calculatorHistory.getStates(includeIntermediateStates); return calculatorHistory.getStates(includeIntermediateStates);
@ -131,18 +131,18 @@ public class AndroidCalculatorHistory implements CalculatorHistory {
calculatorHistory.clear(); calculatorHistory.clear();
} }
@NotNull @Nonnull
public List<CalculatorHistoryState> getSavedHistory() { public List<CalculatorHistoryState> getSavedHistory() {
return calculatorHistory.getSavedHistory(); return calculatorHistory.getSavedHistory();
} }
@NotNull @Nonnull
public CalculatorHistoryState addSavedState(@NotNull CalculatorHistoryState historyState) { public CalculatorHistoryState addSavedState(@Nonnull CalculatorHistoryState historyState) {
return calculatorHistory.addSavedState(historyState); return calculatorHistory.addSavedState(historyState);
} }
@Override @Override
public void fromXml(@NotNull String xml) { public void fromXml(@Nonnull String xml) {
calculatorHistory.fromXml(xml); calculatorHistory.fromXml(xml);
} }
@ -152,7 +152,7 @@ public class AndroidCalculatorHistory implements CalculatorHistory {
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
calculatorHistory.onCalculatorEvent(calculatorEventData, calculatorEventType, data); calculatorHistory.onCalculatorEvent(calculatorEventData, calculatorEventType, data);
} }
} }

View File

@ -8,8 +8,8 @@ package org.solovyev.android.calculator.history;
import android.os.Bundle; import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
/** /**
@ -19,7 +19,7 @@ import org.solovyev.android.calculator.*;
*/ */
public class CalculatorHistoryActivity extends SherlockFragmentActivity implements CalculatorEventListener { public class CalculatorHistoryActivity extends SherlockFragmentActivity implements CalculatorEventListener {
@NotNull @Nonnull
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryActivity.class.getSimpleName()); private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryActivity.class.getSimpleName());
@Override @Override
@ -62,7 +62,7 @@ public class CalculatorHistoryActivity extends SherlockFragmentActivity implemen
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
if (calculatorEventType == CalculatorEventType.use_history_state) { if (calculatorEventType == CalculatorEventType.use_history_state) {
this.finish(); this.finish();
} }

View File

@ -7,7 +7,7 @@
package org.solovyev.android.calculator.history; package org.solovyev.android.calculator.history;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.CalculatorFragmentType; import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.CalculatorPreferences; import org.solovyev.android.calculator.CalculatorPreferences;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
@ -32,7 +32,7 @@ public class CalculatorHistoryFragment extends AbstractCalculatorHistoryFragment
return R.layout.history_item; return R.layout.history_item;
} }
@NotNull @Nonnull
@Override @Override
protected List<CalculatorHistoryState> getHistoryItems() { protected List<CalculatorHistoryState> getHistoryItems() {
final boolean showIntermediateCalculations = CalculatorPreferences.History.showIntermediateCalculations.getPreference(PreferenceManager.getDefaultSharedPreferences(getActivity())); final boolean showIntermediateCalculations = CalculatorPreferences.History.showIntermediateCalculations.getPreference(PreferenceManager.getDefaultSharedPreferences(getActivity()));

View File

@ -6,7 +6,7 @@
package org.solovyev.android.calculator.history; package org.solovyev.android.calculator.history;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.CalculatorFragmentType; import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
@ -30,7 +30,7 @@ public class CalculatorSavedHistoryFragment extends AbstractCalculatorHistoryFra
return R.layout.saved_history_item; return R.layout.saved_history_item;
} }
@NotNull @Nonnull
@Override @Override
protected List<CalculatorHistoryState> getHistoryItems() { protected List<CalculatorHistoryState> getHistoryItems() {
return new ArrayList<CalculatorHistoryState>(Locator.getInstance().getHistory().getSavedHistory()); return new ArrayList<CalculatorHistoryState>(Locator.getInstance().getHistory().getSavedHistory());

View File

@ -11,7 +11,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.TextView; import android.widget.TextView;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import org.solovyev.common.text.Strings; import org.solovyev.common.text.Strings;
@ -26,7 +26,7 @@ import java.util.List;
*/ */
public class HistoryArrayAdapter extends ArrayAdapter<CalculatorHistoryState> { public class HistoryArrayAdapter extends ArrayAdapter<CalculatorHistoryState> {
HistoryArrayAdapter(Context context, int resource, int textViewResourceId, @NotNull List<CalculatorHistoryState> historyList) { HistoryArrayAdapter(Context context, int resource, int textViewResourceId, @Nonnull List<CalculatorHistoryState> historyList) {
super(context, resource, textViewResourceId, historyList); super(context, resource, textViewResourceId, historyList);
} }

View File

@ -7,7 +7,7 @@
package org.solovyev.android.calculator.history; package org.solovyev.android.calculator.history;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
/** /**
* User: serso * User: serso
@ -16,23 +16,23 @@ import org.jetbrains.annotations.NotNull;
*/ */
public class HistoryItemMenuData { public class HistoryItemMenuData {
@NotNull @Nonnull
private final ArrayAdapter<CalculatorHistoryState> adapter; private final ArrayAdapter<CalculatorHistoryState> adapter;
@NotNull @Nonnull
private final CalculatorHistoryState historyState; private final CalculatorHistoryState historyState;
public HistoryItemMenuData(@NotNull CalculatorHistoryState historyState, ArrayAdapter<CalculatorHistoryState> adapter) { public HistoryItemMenuData(@Nonnull CalculatorHistoryState historyState, ArrayAdapter<CalculatorHistoryState> adapter) {
this.historyState = historyState; this.historyState = historyState;
this.adapter = adapter; this.adapter = adapter;
} }
@NotNull @Nonnull
public CalculatorHistoryState getHistoryState() { public CalculatorHistoryState getHistoryState() {
return historyState; return historyState;
} }
@NotNull @Nonnull
public ArrayAdapter<CalculatorHistoryState> getAdapter() { public ArrayAdapter<CalculatorHistoryState> getAdapter() {
return adapter; return adapter;
} }

View File

@ -16,7 +16,7 @@ import android.view.View;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import org.solovyev.android.menu.LabeledMenuItem; import org.solovyev.android.menu.LabeledMenuItem;
@ -31,14 +31,14 @@ public enum HistoryItemMenuItem implements LabeledMenuItem<HistoryItemMenuData>
use(R.string.c_use) { use(R.string.c_use) {
@Override @Override
public void onClick(@NotNull HistoryItemMenuData data, @NotNull Context context) { public void onClick(@Nonnull HistoryItemMenuData data, @Nonnull Context context) {
AbstractCalculatorHistoryFragment.useHistoryItem(data.getHistoryState()); AbstractCalculatorHistoryFragment.useHistoryItem(data.getHistoryState());
} }
}, },
copy_expression(R.string.c_copy_expression) { copy_expression(R.string.c_copy_expression) {
@Override @Override
public void onClick(@NotNull HistoryItemMenuData data, @NotNull Context context) { public void onClick(@Nonnull HistoryItemMenuData data, @Nonnull Context context) {
final CalculatorHistoryState calculatorHistoryState = data.getHistoryState(); final CalculatorHistoryState calculatorHistoryState = data.getHistoryState();
final String text = calculatorHistoryState.getEditorState().getText(); final String text = calculatorHistoryState.getEditorState().getText();
if (!Strings.isEmpty(text)) { if (!Strings.isEmpty(text)) {
@ -51,7 +51,7 @@ public enum HistoryItemMenuItem implements LabeledMenuItem<HistoryItemMenuData>
copy_result(R.string.c_copy_result) { copy_result(R.string.c_copy_result) {
@Override @Override
public void onClick(@NotNull HistoryItemMenuData data, @NotNull Context context) { public void onClick(@Nonnull HistoryItemMenuData data, @Nonnull Context context) {
final CalculatorHistoryState calculatorHistoryState = data.getHistoryState(); final CalculatorHistoryState calculatorHistoryState = data.getHistoryState();
final String text = calculatorHistoryState.getDisplayState().getEditorState().getText(); final String text = calculatorHistoryState.getDisplayState().getEditorState().getText();
if (!Strings.isEmpty(text)) { if (!Strings.isEmpty(text)) {
@ -64,7 +64,7 @@ public enum HistoryItemMenuItem implements LabeledMenuItem<HistoryItemMenuData>
save(R.string.c_save) { save(R.string.c_save) {
@Override @Override
public void onClick(@NotNull final HistoryItemMenuData data, @NotNull final Context context) { public void onClick(@Nonnull final HistoryItemMenuData data, @Nonnull final Context context) {
final CalculatorHistoryState historyState = data.getHistoryState(); final CalculatorHistoryState historyState = data.getHistoryState();
if (!historyState.isSaved()) { if (!historyState.isSaved()) {
createEditHistoryDialog(data, context, true); createEditHistoryDialog(data, context, true);
@ -76,7 +76,7 @@ public enum HistoryItemMenuItem implements LabeledMenuItem<HistoryItemMenuData>
edit(R.string.c_edit) { edit(R.string.c_edit) {
@Override @Override
public void onClick(@NotNull final HistoryItemMenuData data, @NotNull final Context context) { public void onClick(@Nonnull final HistoryItemMenuData data, @Nonnull final Context context) {
final CalculatorHistoryState historyState = data.getHistoryState(); final CalculatorHistoryState historyState = data.getHistoryState();
if (historyState.isSaved()) { if (historyState.isSaved()) {
createEditHistoryDialog(data, context, false); createEditHistoryDialog(data, context, false);
@ -88,7 +88,7 @@ public enum HistoryItemMenuItem implements LabeledMenuItem<HistoryItemMenuData>
remove(R.string.c_remove) { remove(R.string.c_remove) {
@Override @Override
public void onClick(@NotNull HistoryItemMenuData data, @NotNull Context context) { public void onClick(@Nonnull HistoryItemMenuData data, @Nonnull Context context) {
final CalculatorHistoryState historyState = data.getHistoryState(); final CalculatorHistoryState historyState = data.getHistoryState();
if (historyState.isSaved()) { if (historyState.isSaved()) {
data.getAdapter().remove(historyState); data.getAdapter().remove(historyState);
@ -99,7 +99,7 @@ public enum HistoryItemMenuItem implements LabeledMenuItem<HistoryItemMenuData>
} }
}; };
private static void createEditHistoryDialog(@NotNull final HistoryItemMenuData data, @NotNull final Context context, final boolean save) { private static void createEditHistoryDialog(@Nonnull final HistoryItemMenuData data, @Nonnull final Context context, final boolean save) {
final CalculatorHistoryState historyState = data.getHistoryState(); final CalculatorHistoryState historyState = data.getHistoryState();
final LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@ -142,9 +142,9 @@ public enum HistoryItemMenuItem implements LabeledMenuItem<HistoryItemMenuData>
this.captionId = captionId; this.captionId = captionId;
} }
@NotNull @Nonnull
@Override @Override
public String getCaption(@NotNull Context context) { public String getCaption(@Nonnull Context context) {
return context.getString(captionId); return context.getString(captionId);
} }
} }

View File

@ -8,8 +8,8 @@ package org.solovyev.android.calculator.history;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.Editor; import org.solovyev.android.calculator.Editor;
/** /**
@ -19,10 +19,10 @@ import org.solovyev.android.calculator.Editor;
*/ */
public class TextViewEditorAdapter implements Editor { public class TextViewEditorAdapter implements Editor {
@NotNull @Nonnull
private final TextView textView; private final TextView textView;
public TextViewEditorAdapter(@NotNull TextView textView) { public TextViewEditorAdapter(@Nonnull TextView textView) {
this.textView = textView; this.textView = textView;
} }

View File

@ -16,8 +16,8 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.*; import android.widget.*;
import com.actionbarsherlock.app.SherlockListFragment; import com.actionbarsherlock.app.SherlockListFragment;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.menu.AMenuItem; import org.solovyev.android.menu.AMenuItem;
import org.solovyev.android.menu.ContextMenuBuilder; import org.solovyev.android.menu.ContextMenuBuilder;
@ -67,13 +67,13 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
@Nullable @Nullable
private String category; private String category;
@NotNull @Nonnull
private final CalculatorFragmentHelper fragmentHelper; private final CalculatorFragmentHelper fragmentHelper;
@NotNull @Nonnull
private final Handler uiHandler = new Handler(); private final Handler uiHandler = new Handler();
protected AbstractMathEntityListFragment(@NotNull CalculatorFragmentType fragmentType) { protected AbstractMathEntityListFragment(@Nonnull CalculatorFragmentType fragmentType) {
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId()); fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(fragmentType.getDefaultLayoutId(), fragmentType.getDefaultTitleResId());
} }
@ -142,8 +142,8 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
super.onDestroy(); super.onDestroy();
} }
@NotNull @Nonnull
protected abstract List<LabeledMenuItem<T>> getMenuItemsOnLongClick(@NotNull T item); protected abstract List<LabeledMenuItem<T>> getMenuItemsOnLongClick(@Nonnull T item);
@Override @Override
public void onPause() { public void onPause() {
@ -164,7 +164,7 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
sort(); sort();
} }
@NotNull @Nonnull
private List<T> getMathEntitiesByCategory() { private List<T> getMathEntitiesByCategory() {
final List<T> result = getMathEntities(); final List<T> result = getMathEntities();
@ -182,14 +182,14 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
return t != null && (category == null || Objects.areEqual(getMathEntityCategory(t), category)); return t != null && (category == null || Objects.areEqual(getMathEntityCategory(t), category));
} }
@NotNull @Nonnull
protected abstract MathEntityDescriptionGetter getDescriptionGetter(); protected abstract MathEntityDescriptionGetter getDescriptionGetter();
@NotNull @Nonnull
protected abstract List<T> getMathEntities(); protected abstract List<T> getMathEntities();
@Nullable @Nullable
abstract String getMathEntityCategory(@NotNull T t); abstract String getMathEntityCategory(@Nonnull T t);
protected void sort() { protected void sort() {
final MathEntityArrayAdapter<T> localAdapter = adapter; final MathEntityArrayAdapter<T> localAdapter = adapter;
@ -207,14 +207,14 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
protected static class MathEntityArrayAdapter<T extends MathEntity> extends ArrayAdapter<T> { protected static class MathEntityArrayAdapter<T extends MathEntity> extends ArrayAdapter<T> {
@NotNull @Nonnull
private final MathEntityDescriptionGetter descriptionGetter; private final MathEntityDescriptionGetter descriptionGetter;
private MathEntityArrayAdapter(@NotNull MathEntityDescriptionGetter descriptionGetter, private MathEntityArrayAdapter(@Nonnull MathEntityDescriptionGetter descriptionGetter,
@NotNull Context context, @Nonnull Context context,
int resource, int resource,
int textViewResourceId, int textViewResourceId,
@NotNull List<T> objects) { @Nonnull List<T> objects) {
super(context, resource, textViewResourceId, objects); super(context, resource, textViewResourceId, objects);
this.descriptionGetter = descriptionGetter; this.descriptionGetter = descriptionGetter;
@ -236,7 +236,7 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
return result; return result;
} }
private void fillView(int position, @NotNull ViewGroup result) { private void fillView(int position, @Nonnull ViewGroup result) {
final T mathEntity = getItem(position); final T mathEntity = getItem(position);
final TextView text = (TextView) result.findViewById(R.id.math_entity_text); final TextView text = (TextView) result.findViewById(R.id.math_entity_text);
@ -256,15 +256,15 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
protected static class MathEntityDescriptionGetterImpl implements MathEntityDescriptionGetter { protected static class MathEntityDescriptionGetterImpl implements MathEntityDescriptionGetter {
@NotNull @Nonnull
private final CalculatorMathRegistry<?> mathRegistry; private final CalculatorMathRegistry<?> mathRegistry;
public MathEntityDescriptionGetterImpl(@NotNull CalculatorMathRegistry<?> mathRegistry) { public MathEntityDescriptionGetterImpl(@Nonnull CalculatorMathRegistry<?> mathRegistry) {
this.mathRegistry = mathRegistry; this.mathRegistry = mathRegistry;
} }
@Override @Override
public String getDescription(@NotNull Context context, @NotNull String mathEntityName) { public String getDescription(@Nonnull Context context, @Nonnull String mathEntityName) {
return this.mathRegistry.getDescription(mathEntityName); return this.mathRegistry.getDescription(mathEntityName);
} }
} }
@ -272,16 +272,16 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
protected static interface MathEntityDescriptionGetter { protected static interface MathEntityDescriptionGetter {
@Nullable @Nullable
String getDescription(@NotNull Context context, @NotNull String mathEntityName); String getDescription(@Nonnull Context context, @Nonnull String mathEntityName);
} }
public void addToAdapter(@NotNull T mathEntity) { public void addToAdapter(@Nonnull T mathEntity) {
if (this.adapter != null) { if (this.adapter != null) {
this.adapter.add(mathEntity); this.adapter.add(mathEntity);
} }
} }
public void removeFromAdapter(@NotNull T mathEntity) { public void removeFromAdapter(@Nonnull T mathEntity) {
if (this.adapter != null) { if (this.adapter != null) {
this.adapter.remove(mathEntity); this.adapter.remove(mathEntity);
} }
@ -298,7 +298,7 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
return adapter; return adapter;
} }
@NotNull @Nonnull
protected Handler getUiHandler() { protected Handler getUiHandler() {
return uiHandler; return uiHandler;
} }
@ -311,12 +311,12 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
********************************************************************** **********************************************************************
*/ */
static void createTab(@NotNull Context context, static void createTab(@Nonnull Context context,
@NotNull TabHost tabHost, @Nonnull TabHost tabHost,
@NotNull String tabId, @Nonnull String tabId,
@NotNull String categoryId, @Nonnull String categoryId,
int tabCaptionId, int tabCaptionId,
@NotNull Class<? extends Activity> activityClass, @Nonnull Class<? extends Activity> activityClass,
@Nullable Intent parentIntent) { @Nullable Intent parentIntent) {
TabHost.TabSpec spec; TabHost.TabSpec spec;
@ -336,18 +336,18 @@ public abstract class AbstractMathEntityListFragment<T extends MathEntity> exten
tabHost.addTab(spec); tabHost.addTab(spec);
} }
@NotNull @Nonnull
public static Bundle createBundleFor(@NotNull String categoryId) { public static Bundle createBundleFor(@Nonnull String categoryId) {
final Bundle result = new Bundle(1); final Bundle result = new Bundle(1);
putCategory(result, categoryId); putCategory(result, categoryId);
return result; return result;
} }
static void putCategory(@NotNull Bundle bundle, @NotNull String categoryId) { static void putCategory(@Nonnull Bundle bundle, @Nonnull String categoryId) {
bundle.putString(MATH_ENTITY_CATEGORY_EXTRA_STRING, categoryId); bundle.putString(MATH_ENTITY_CATEGORY_EXTRA_STRING, categoryId);
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
} }
} }

View File

@ -10,8 +10,8 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.history.CalculatorHistoryActivity; import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
@ -22,7 +22,7 @@ import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
*/ */
public class CalculatorFunctionsActivity extends SherlockFragmentActivity implements CalculatorEventListener { public class CalculatorFunctionsActivity extends SherlockFragmentActivity implements CalculatorEventListener {
@NotNull @Nonnull
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryActivity.class.getSimpleName()); private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryActivity.class.getSimpleName());
@Override @Override
@ -93,7 +93,7 @@ public class CalculatorFunctionsActivity extends SherlockFragmentActivity implem
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
switch (calculatorEventType) { switch (calculatorEventType) {
case use_function: case use_function:
this.finish(); this.finish();

View File

@ -17,8 +17,8 @@ import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import jscl.math.function.Function; import jscl.math.function.Function;
import jscl.math.function.IFunction; import jscl.math.function.IFunction;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.function.FunctionEditDialogFragment; import org.solovyev.android.calculator.function.FunctionEditDialogFragment;
import org.solovyev.android.menu.AMenuItem; import org.solovyev.android.menu.AMenuItem;
@ -66,9 +66,9 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment<
return LongClickMenuItem.use; return LongClickMenuItem.use;
} }
@NotNull @Nonnull
@Override @Override
protected List<LabeledMenuItem<Function>> getMenuItemsOnLongClick(@NotNull Function item) { protected List<LabeledMenuItem<Function>> getMenuItemsOnLongClick(@Nonnull Function item) {
List<LabeledMenuItem<Function>> result = new ArrayList<LabeledMenuItem<Function>>(Arrays.asList(LongClickMenuItem.values())); List<LabeledMenuItem<Function>> result = new ArrayList<LabeledMenuItem<Function>>(Arrays.asList(LongClickMenuItem.values()));
final CalculatorMathRegistry<Function> functionsRegistry = Locator.getInstance().getEngine().getFunctionsRegistry(); final CalculatorMathRegistry<Function> functionsRegistry = Locator.getInstance().getEngine().getFunctionsRegistry();
@ -85,25 +85,25 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment<
return result; return result;
} }
@NotNull @Nonnull
@Override @Override
protected MathEntityDescriptionGetter getDescriptionGetter() { protected MathEntityDescriptionGetter getDescriptionGetter() {
return new MathEntityDescriptionGetterImpl(Locator.getInstance().getEngine().getFunctionsRegistry()); return new MathEntityDescriptionGetterImpl(Locator.getInstance().getEngine().getFunctionsRegistry());
} }
@NotNull @Nonnull
@Override @Override
protected List<Function> getMathEntities() { protected List<Function> getMathEntities() {
return new ArrayList<Function>(Locator.getInstance().getEngine().getFunctionsRegistry().getEntities()); return new ArrayList<Function>(Locator.getInstance().getEngine().getFunctionsRegistry().getEntities());
} }
@Override @Override
protected String getMathEntityCategory(@NotNull Function function) { protected String getMathEntityCategory(@Nonnull Function function) {
return Locator.getInstance().getEngine().getFunctionsRegistry().getCategory(function); return Locator.getInstance().getEngine().getFunctionsRegistry().getCategory(function);
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
super.onCalculatorEvent(calculatorEventData, calculatorEventType, data); super.onCalculatorEvent(calculatorEventData, calculatorEventType, data);
switch (calculatorEventType) { switch (calculatorEventType) {
@ -122,7 +122,7 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment<
} }
private void processFunctionRemoved(@NotNull final Function function) { private void processFunctionRemoved(@Nonnull final Function function) {
if (this.isInCategory(function)) { if (this.isInCategory(function)) {
getUiHandler().post(new Runnable() { getUiHandler().post(new Runnable() {
@Override @Override
@ -134,7 +134,7 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment<
} }
} }
private void processFunctionChanged(@NotNull final Change<IFunction> change) { private void processFunctionChanged(@Nonnull final Change<IFunction> change) {
final IFunction newFunction = change.getNewValue(); final IFunction newFunction = change.getNewValue();
if (newFunction instanceof Function) { if (newFunction instanceof Function) {
@ -169,7 +169,7 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment<
} }
} }
private void processFunctionAdded(@NotNull final Function function) { private void processFunctionAdded(@Nonnull final Function function) {
if (this.isInCategory(function)) { if (this.isInCategory(function)) {
getUiHandler().post(new Runnable() { getUiHandler().post(new Runnable() {
@Override @Override
@ -222,14 +222,14 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment<
private static enum LongClickMenuItem implements LabeledMenuItem<Function> { private static enum LongClickMenuItem implements LabeledMenuItem<Function> {
use(R.string.c_use) { use(R.string.c_use) {
@Override @Override
public void onClick(@NotNull Function function, @NotNull Context context) { public void onClick(@Nonnull Function function, @Nonnull Context context) {
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_function, function); Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_function, function);
} }
}, },
edit(R.string.c_edit) { edit(R.string.c_edit) {
@Override @Override
public void onClick(@NotNull Function function, @NotNull Context context) { public void onClick(@Nonnull Function function, @Nonnull Context context) {
if (function instanceof IFunction) { if (function instanceof IFunction) {
FunctionEditDialogFragment.showDialog(FunctionEditDialogFragment.Input.newFromFunction((IFunction) function), ((SherlockFragmentActivity) context).getSupportFragmentManager()); FunctionEditDialogFragment.showDialog(FunctionEditDialogFragment.Input.newFromFunction((IFunction) function), ((SherlockFragmentActivity) context).getSupportFragmentManager());
} }
@ -238,14 +238,14 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment<
remove(R.string.c_remove) { remove(R.string.c_remove) {
@Override @Override
public void onClick(@NotNull Function function, @NotNull Context context) { public void onClick(@Nonnull Function function, @Nonnull Context context) {
MathEntityRemover.newFunctionRemover(function, null, context, context).showConfirmationDialog(); MathEntityRemover.newFunctionRemover(function, null, context, context).showConfirmationDialog();
} }
}, },
copy_description(R.string.c_copy_description) { copy_description(R.string.c_copy_description) {
@Override @Override
public void onClick(@NotNull Function function, @NotNull Context context) { public void onClick(@Nonnull Function function, @Nonnull Context context) {
final String text = Locator.getInstance().getEngine().getFunctionsRegistry().getDescription(function.getName()); final String text = Locator.getInstance().getEngine().getFunctionsRegistry().getDescription(function.getName());
if (!Strings.isEmpty(text)) { if (!Strings.isEmpty(text)) {
final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE); final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE);
@ -259,9 +259,9 @@ public class CalculatorFunctionsFragment extends AbstractMathEntityListFragment<
this.captionId = captionId; this.captionId = captionId;
} }
@NotNull @Nonnull
@Override @Override
public String getCaption(@NotNull Context context) { public String getCaption(@Nonnull Context context) {
return context.getString(captionId); return context.getString(captionId);
} }
} }

View File

@ -8,8 +8,8 @@ package org.solovyev.android.calculator.math.edit;
import android.os.Bundle; import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.history.CalculatorHistoryActivity; import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
@ -20,7 +20,7 @@ import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
*/ */
public class CalculatorOperatorsActivity extends SherlockFragmentActivity implements CalculatorEventListener { public class CalculatorOperatorsActivity extends SherlockFragmentActivity implements CalculatorEventListener {
@NotNull @Nonnull
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryActivity.class.getSimpleName()); private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryActivity.class.getSimpleName());
@Override @Override
@ -71,7 +71,7 @@ public class CalculatorOperatorsActivity extends SherlockFragmentActivity implem
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
switch (calculatorEventType) { switch (calculatorEventType) {
case use_operator: case use_operator:
this.finish(); this.finish();

View File

@ -4,7 +4,7 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.text.ClipboardManager; import android.text.ClipboardManager;
import jscl.math.operator.Operator; import jscl.math.operator.Operator;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.solovyev.android.calculator.CalculatorEventType; import org.solovyev.android.calculator.CalculatorEventType;
import org.solovyev.android.calculator.CalculatorFragmentType; import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
@ -34,9 +34,9 @@ public class CalculatorOperatorsFragment extends AbstractMathEntityListFragment<
return LongClickMenuItem.use; return LongClickMenuItem.use;
} }
@NotNull @Nonnull
@Override @Override
protected List<LabeledMenuItem<Operator>> getMenuItemsOnLongClick(@NotNull Operator item) { protected List<LabeledMenuItem<Operator>> getMenuItemsOnLongClick(@Nonnull Operator item) {
final List<LabeledMenuItem<Operator>> result = new ArrayList<LabeledMenuItem<Operator>>(Arrays.asList(LongClickMenuItem.values())); final List<LabeledMenuItem<Operator>> result = new ArrayList<LabeledMenuItem<Operator>>(Arrays.asList(LongClickMenuItem.values()));
if (Strings.isEmpty(OperatorDescriptionGetter.instance.getDescription(this.getActivity(), item.getName()))) { if (Strings.isEmpty(OperatorDescriptionGetter.instance.getDescription(this.getActivity(), item.getName()))) {
@ -46,14 +46,14 @@ public class CalculatorOperatorsFragment extends AbstractMathEntityListFragment<
return result; return result;
} }
@NotNull @Nonnull
@Override @Override
protected MathEntityDescriptionGetter getDescriptionGetter() { protected MathEntityDescriptionGetter getDescriptionGetter() {
return OperatorDescriptionGetter.instance; return OperatorDescriptionGetter.instance;
} }
@NotNull @Nonnull
@Override @Override
protected List<Operator> getMathEntities() { protected List<Operator> getMathEntities() {
final List<Operator> result = new ArrayList<Operator>(); final List<Operator> result = new ArrayList<Operator>();
@ -65,7 +65,7 @@ public class CalculatorOperatorsFragment extends AbstractMathEntityListFragment<
} }
@Override @Override
protected String getMathEntityCategory(@NotNull Operator operator) { protected String getMathEntityCategory(@Nonnull Operator operator) {
String result = Locator.getInstance().getEngine().getOperatorsRegistry().getCategory(operator); String result = Locator.getInstance().getEngine().getOperatorsRegistry().getCategory(operator);
if (result == null) { if (result == null) {
result = Locator.getInstance().getEngine().getPostfixFunctionsRegistry().getCategory(operator); result = Locator.getInstance().getEngine().getPostfixFunctionsRegistry().getCategory(operator);
@ -79,7 +79,7 @@ public class CalculatorOperatorsFragment extends AbstractMathEntityListFragment<
instance; instance;
@Override @Override
public String getDescription(@NotNull Context context, @NotNull String mathEntityName) { public String getDescription(@Nonnull Context context, @Nonnull String mathEntityName) {
String result = Locator.getInstance().getEngine().getOperatorsRegistry().getDescription(mathEntityName); String result = Locator.getInstance().getEngine().getOperatorsRegistry().getDescription(mathEntityName);
if (Strings.isEmpty(result)) { if (Strings.isEmpty(result)) {
result = Locator.getInstance().getEngine().getPostfixFunctionsRegistry().getDescription(mathEntityName); result = Locator.getInstance().getEngine().getPostfixFunctionsRegistry().getDescription(mathEntityName);
@ -101,14 +101,14 @@ public class CalculatorOperatorsFragment extends AbstractMathEntityListFragment<
use(R.string.c_use) { use(R.string.c_use) {
@Override @Override
public void onClick(@NotNull Operator data, @NotNull Context context) { public void onClick(@Nonnull Operator data, @Nonnull Context context) {
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_operator, data); Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_operator, data);
} }
}, },
copy_description(R.string.c_copy_description) { copy_description(R.string.c_copy_description) {
@Override @Override
public void onClick(@NotNull Operator data, @NotNull Context context) { public void onClick(@Nonnull Operator data, @Nonnull Context context) {
final String text = OperatorDescriptionGetter.instance.getDescription(context, data.getName()); final String text = OperatorDescriptionGetter.instance.getDescription(context, data.getName());
if (!Strings.isEmpty(text)) { if (!Strings.isEmpty(text)) {
final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE); final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE);
@ -122,9 +122,9 @@ public class CalculatorOperatorsFragment extends AbstractMathEntityListFragment<
this.captionId = captionId; this.captionId = captionId;
} }
@NotNull @Nonnull
@Override @Override
public String getCaption(@NotNull Context context) { public String getCaption(@Nonnull Context context) {
return context.getString(captionId); return context.getString(captionId);
} }
} }

View File

@ -9,8 +9,8 @@ package org.solovyev.android.calculator.math.edit;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.history.CalculatorHistoryActivity; import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
@ -21,7 +21,7 @@ import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
*/ */
public class CalculatorVarsActivity extends SherlockFragmentActivity implements CalculatorEventListener { public class CalculatorVarsActivity extends SherlockFragmentActivity implements CalculatorEventListener {
@NotNull @Nonnull
private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryActivity.class.getSimpleName()); private final CalculatorActivityHelper activityHelper = CalculatorApplication.getInstance().createActivityHelper(R.layout.main_empty, CalculatorHistoryActivity.class.getSimpleName());
@Override @Override
@ -94,7 +94,7 @@ public class CalculatorVarsActivity extends SherlockFragmentActivity implements
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
switch (calculatorEventType) { switch (calculatorEventType) {
case use_constant: case use_constant:
this.finish(); this.finish();

View File

@ -14,8 +14,8 @@ import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem; import com.actionbarsherlock.view.MenuItem;
import jscl.math.function.IConstant; import jscl.math.function.IConstant;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.menu.AMenuItem; import org.solovyev.android.menu.AMenuItem;
@ -64,9 +64,9 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
return LongClickMenuItem.use; return LongClickMenuItem.use;
} }
@NotNull @Nonnull
@Override @Override
protected List<LabeledMenuItem<IConstant>> getMenuItemsOnLongClick(@NotNull IConstant item) { protected List<LabeledMenuItem<IConstant>> getMenuItemsOnLongClick(@Nonnull IConstant item) {
final List<LabeledMenuItem<IConstant>> result = new ArrayList<LabeledMenuItem<IConstant>>(Arrays.asList(LongClickMenuItem.values())); final List<LabeledMenuItem<IConstant>> result = new ArrayList<LabeledMenuItem<IConstant>>(Arrays.asList(LongClickMenuItem.values()));
if (item.isSystem()) { if (item.isSystem()) {
@ -85,18 +85,18 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
return result; return result;
} }
@NotNull @Nonnull
@Override @Override
protected MathEntityDescriptionGetter getDescriptionGetter() { protected MathEntityDescriptionGetter getDescriptionGetter() {
return new MathEntityDescriptionGetterImpl(Locator.getInstance().getEngine().getVarsRegistry()); return new MathEntityDescriptionGetterImpl(Locator.getInstance().getEngine().getVarsRegistry());
} }
@SuppressWarnings({"UnusedDeclaration"}) @SuppressWarnings({"UnusedDeclaration"})
public void addVarButtonClickHandler(@NotNull View v) { public void addVarButtonClickHandler(@Nonnull View v) {
VarEditDialogFragment.showDialog(VarEditDialogFragment.Input.newInstance(), this.getActivity().getSupportFragmentManager()); VarEditDialogFragment.showDialog(VarEditDialogFragment.Input.newInstance(), this.getActivity().getSupportFragmentManager());
} }
@NotNull @Nonnull
@Override @Override
protected List<IConstant> getMathEntities() { protected List<IConstant> getMathEntities() {
final List<IConstant> result = new ArrayList<IConstant>(Locator.getInstance().getEngine().getVarsRegistry().getEntities()); final List<IConstant> result = new ArrayList<IConstant>(Locator.getInstance().getEngine().getVarsRegistry().getEntities());
@ -112,11 +112,11 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
} }
@Override @Override
protected String getMathEntityCategory(@NotNull IConstant var) { protected String getMathEntityCategory(@Nonnull IConstant var) {
return Locator.getInstance().getEngine().getVarsRegistry().getCategory(var); return Locator.getInstance().getEngine().getVarsRegistry().getCategory(var);
} }
public static boolean isValidValue(@NotNull String value) { public static boolean isValidValue(@Nonnull String value) {
try { try {
final PreparedExpression expression = ToJsclTextProcessor.getInstance().process(value); final PreparedExpression expression = ToJsclTextProcessor.getInstance().process(value);
final List<IConstant> constants = expression.getUndefinedVars(); final List<IConstant> constants = expression.getUndefinedVars();
@ -158,7 +158,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
super.onCalculatorEvent(calculatorEventData, calculatorEventType, data); super.onCalculatorEvent(calculatorEventData, calculatorEventType, data);
switch (calculatorEventType) { switch (calculatorEventType) {
@ -176,7 +176,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
} }
} }
private void processConstantRemoved(@NotNull final IConstant constant) { private void processConstantRemoved(@Nonnull final IConstant constant) {
if (this.isInCategory(constant)) { if (this.isInCategory(constant)) {
getUiHandler().post(new Runnable() { getUiHandler().post(new Runnable() {
@Override @Override
@ -188,7 +188,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
} }
} }
private void processConstantChanged(@NotNull final Change<IConstant> change) { private void processConstantChanged(@Nonnull final Change<IConstant> change) {
final IConstant newConstant = change.getNewValue(); final IConstant newConstant = change.getNewValue();
if (this.isInCategory(newConstant)) { if (this.isInCategory(newConstant)) {
getUiHandler().post(new Runnable() { getUiHandler().post(new Runnable() {
@ -202,7 +202,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
} }
} }
private void processConstantAdded(@NotNull final IConstant constant) { private void processConstantAdded(@Nonnull final IConstant constant) {
if (this.isInCategory(constant)) { if (this.isInCategory(constant)) {
getUiHandler().post(new Runnable() { getUiHandler().post(new Runnable() {
@Override @Override
@ -225,28 +225,28 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
private static enum LongClickMenuItem implements LabeledMenuItem<IConstant> { private static enum LongClickMenuItem implements LabeledMenuItem<IConstant> {
use(R.string.c_use) { use(R.string.c_use) {
@Override @Override
public void onClick(@NotNull IConstant data, @NotNull Context context) { public void onClick(@Nonnull IConstant data, @Nonnull Context context) {
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_constant, data); Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_constant, data);
} }
}, },
edit(R.string.c_edit) { edit(R.string.c_edit) {
@Override @Override
public void onClick(@NotNull IConstant constant, @NotNull Context context) { public void onClick(@Nonnull IConstant constant, @Nonnull Context context) {
VarEditDialogFragment.showDialog(VarEditDialogFragment.Input.newFromConstant(constant), ((SherlockFragmentActivity) context).getSupportFragmentManager()); VarEditDialogFragment.showDialog(VarEditDialogFragment.Input.newFromConstant(constant), ((SherlockFragmentActivity) context).getSupportFragmentManager());
} }
}, },
remove(R.string.c_remove) { remove(R.string.c_remove) {
@Override @Override
public void onClick(@NotNull IConstant constant, @NotNull Context context) { public void onClick(@Nonnull IConstant constant, @Nonnull Context context) {
MathEntityRemover.newConstantRemover(constant, null, context, context).showConfirmationDialog(); MathEntityRemover.newConstantRemover(constant, null, context, context).showConfirmationDialog();
} }
}, },
copy_value(R.string.c_copy_value) { copy_value(R.string.c_copy_value) {
@Override @Override
public void onClick(@NotNull IConstant data, @NotNull Context context) { public void onClick(@Nonnull IConstant data, @Nonnull Context context) {
final String text = data.getValue(); final String text = data.getValue();
if (!Strings.isEmpty(text)) { if (!Strings.isEmpty(text)) {
assert text != null; assert text != null;
@ -257,7 +257,7 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
copy_description(R.string.c_copy_description) { copy_description(R.string.c_copy_description) {
@Override @Override
public void onClick(@NotNull IConstant data, @NotNull Context context) { public void onClick(@Nonnull IConstant data, @Nonnull Context context) {
final String text = Locator.getInstance().getEngine().getVarsRegistry().getDescription(data.getName()); final String text = Locator.getInstance().getEngine().getVarsRegistry().getDescription(data.getName());
if (!Strings.isEmpty(text)) { if (!Strings.isEmpty(text)) {
assert text != null; assert text != null;
@ -271,9 +271,9 @@ public class CalculatorVarsFragment extends AbstractMathEntityListFragment<ICons
this.captionId = captionId; this.captionId = captionId;
} }
@NotNull @Nonnull
@Override @Override
public String getCaption(@NotNull Context context) { public String getCaption(@Nonnull Context context) {
return context.getString(captionId); return context.getString(captionId);
} }
} }

View File

@ -13,8 +13,8 @@ import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import jscl.math.function.Function; import jscl.math.function.Function;
import jscl.math.function.IConstant; import jscl.math.function.IConstant;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.CalculatorEventType; import org.solovyev.android.calculator.CalculatorEventType;
import org.solovyev.android.calculator.CalculatorMathRegistry; import org.solovyev.android.calculator.CalculatorMathRegistry;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
@ -28,7 +28,7 @@ import org.solovyev.common.math.MathEntity;
*/ */
public class MathEntityRemover<T extends MathEntity> implements View.OnClickListener, DialogInterface.OnClickListener { public class MathEntityRemover<T extends MathEntity> implements View.OnClickListener, DialogInterface.OnClickListener {
@NotNull @Nonnull
private final T mathEntity; private final T mathEntity;
@Nullable @Nullable
@ -36,16 +36,16 @@ public class MathEntityRemover<T extends MathEntity> implements View.OnClickList
private final boolean confirmed; private final boolean confirmed;
@NotNull @Nonnull
private final CalculatorMathRegistry<? super T> varsRegistry; private final CalculatorMathRegistry<? super T> varsRegistry;
@NotNull @Nonnull
private Context context; private Context context;
@NotNull @Nonnull
private final Object source; private final Object source;
@NotNull @Nonnull
private final Params params; private final Params params;
/* /*
@ -56,13 +56,13 @@ public class MathEntityRemover<T extends MathEntity> implements View.OnClickList
********************************************************************** **********************************************************************
*/ */
private MathEntityRemover(@NotNull T mathEntity, private MathEntityRemover(@Nonnull T mathEntity,
@Nullable DialogInterface.OnClickListener callbackOnCancel, @Nullable DialogInterface.OnClickListener callbackOnCancel,
boolean confirmed, boolean confirmed,
@NotNull CalculatorMathRegistry<? super T> varsRegistry, @Nonnull CalculatorMathRegistry<? super T> varsRegistry,
@NotNull Context context, @Nonnull Context context,
@NotNull Object source, @Nonnull Object source,
@NotNull Params params) { @Nonnull Params params) {
this.mathEntity = mathEntity; this.mathEntity = mathEntity;
this.callbackOnCancel = callbackOnCancel; this.callbackOnCancel = callbackOnCancel;
this.confirmed = confirmed; this.confirmed = confirmed;
@ -72,17 +72,17 @@ public class MathEntityRemover<T extends MathEntity> implements View.OnClickList
this.params = params; this.params = params;
} }
public static MathEntityRemover<IConstant> newConstantRemover(@NotNull IConstant constant, public static MathEntityRemover<IConstant> newConstantRemover(@Nonnull IConstant constant,
@Nullable DialogInterface.OnClickListener callbackOnCancel, @Nullable DialogInterface.OnClickListener callbackOnCancel,
@NotNull Context context, @Nonnull Context context,
@NotNull Object source) { @Nonnull Object source) {
return new MathEntityRemover<IConstant>(constant, callbackOnCancel, false, Locator.getInstance().getEngine().getVarsRegistry(), context, source, Params.newConstantInstance()); return new MathEntityRemover<IConstant>(constant, callbackOnCancel, false, Locator.getInstance().getEngine().getVarsRegistry(), context, source, Params.newConstantInstance());
} }
public static MathEntityRemover<Function> newFunctionRemover(@NotNull Function function, public static MathEntityRemover<Function> newFunctionRemover(@Nonnull Function function,
@Nullable DialogInterface.OnClickListener callbackOnCancel, @Nullable DialogInterface.OnClickListener callbackOnCancel,
@NotNull Context context, @Nonnull Context context,
@NotNull Object source) { @Nonnull Object source) {
return new MathEntityRemover<Function>(function, callbackOnCancel, false, Locator.getInstance().getEngine().getFunctionsRegistry(), context, source, Params.newFunctionInstance()); return new MathEntityRemover<Function>(function, callbackOnCancel, false, Locator.getInstance().getEngine().getFunctionsRegistry(), context, source, Params.newFunctionInstance());
} }

View File

@ -12,8 +12,8 @@ import android.view.WindowManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast; import android.widget.Toast;
import jscl.math.function.IConstant; import jscl.math.function.IConstant;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.*; import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.model.Var; import org.solovyev.android.calculator.model.Var;
import org.solovyev.android.sherlock.AndroidSherlockUtils; import org.solovyev.android.sherlock.AndroidSherlockUtils;
@ -25,14 +25,14 @@ import org.solovyev.android.sherlock.AndroidSherlockUtils;
*/ */
public class VarEditDialogFragment extends DialogFragment implements CalculatorEventListener { public class VarEditDialogFragment extends DialogFragment implements CalculatorEventListener {
@NotNull @Nonnull
private final Input input; private final Input input;
public VarEditDialogFragment() { public VarEditDialogFragment() {
this(Input.newInstance()); this(Input.newInstance());
} }
public VarEditDialogFragment(@NotNull Input input) { public VarEditDialogFragment(@Nonnull Input input) {
this.input = input; this.input = input;
} }
@ -56,7 +56,7 @@ public class VarEditDialogFragment extends DialogFragment implements CalculatorE
} }
@Override @Override
public void onViewCreated(@NotNull View root, Bundle savedInstanceState) { public void onViewCreated(@Nonnull View root, Bundle savedInstanceState) {
super.onViewCreated(root, savedInstanceState); super.onViewCreated(root, savedInstanceState);
final String errorMsg = this.getString(R.string.c_char_is_not_accepted); final String errorMsg = this.getString(R.string.c_char_is_not_accepted);
@ -126,7 +126,7 @@ public class VarEditDialogFragment extends DialogFragment implements CalculatorE
} }
@Override @Override
public void onCalculatorEvent(@NotNull CalculatorEventData calculatorEventData, @NotNull CalculatorEventType calculatorEventType, @Nullable Object data) { public void onCalculatorEvent(@Nonnull CalculatorEventData calculatorEventData, @Nonnull CalculatorEventType calculatorEventType, @Nullable Object data) {
switch (calculatorEventType) { switch (calculatorEventType) {
case constant_removed: case constant_removed:
case constant_added: case constant_added:
@ -147,7 +147,7 @@ public class VarEditDialogFragment extends DialogFragment implements CalculatorE
********************************************************************** **********************************************************************
*/ */
public static void showDialog(@NotNull Input input, @NotNull FragmentManager fm) { public static void showDialog(@Nonnull Input input, @Nonnull FragmentManager fm) {
AndroidSherlockUtils.showDialog(new VarEditDialogFragment(input), "constant-editor", fm); AndroidSherlockUtils.showDialog(new VarEditDialogFragment(input), "constant-editor", fm);
} }
@ -168,26 +168,26 @@ public class VarEditDialogFragment extends DialogFragment implements CalculatorE
private Input() { private Input() {
} }
@NotNull @Nonnull
public static Input newInstance() { public static Input newInstance() {
return new Input(); return new Input();
} }
@NotNull @Nonnull
public static Input newFromConstant(@NotNull IConstant constant) { public static Input newFromConstant(@Nonnull IConstant constant) {
final Input result = new Input(); final Input result = new Input();
result.constant = constant; result.constant = constant;
return result; return result;
} }
@NotNull @Nonnull
public static Input newFromValue(@Nullable String value) { public static Input newFromValue(@Nullable String value) {
final Input result = new Input(); final Input result = new Input();
result.value = value; result.value = value;
return result; return result;
} }
@NotNull @Nonnull
public static Input newInstance(@Nullable IConstant constant, @Nullable String name, @Nullable String value, @Nullable String description) { public static Input newInstance(@Nullable IConstant constant, @Nullable String name, @Nullable String value, @Nullable String description) {
final Input result = new Input(); final Input result = new Input();
result.constant = constant; result.constant = constant;

View File

@ -12,8 +12,8 @@ import jscl.text.Identifier;
import jscl.text.MutableInt; import jscl.text.MutableInt;
import jscl.text.ParseException; import jscl.text.ParseException;
import jscl.text.Parser; import jscl.text.Parser;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.CalculatorMathRegistry; import org.solovyev.android.calculator.CalculatorMathRegistry;
import org.solovyev.android.calculator.CalculatorVarsRegistry; import org.solovyev.android.calculator.CalculatorVarsRegistry;
import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.Locator;
@ -31,26 +31,26 @@ import org.solovyev.common.text.Strings;
*/ */
public class VarEditorSaver<T extends MathEntity> implements View.OnClickListener { public class VarEditorSaver<T extends MathEntity> implements View.OnClickListener {
@NotNull @Nonnull
private final MathEntityBuilder<? extends T> varBuilder; private final MathEntityBuilder<? extends T> varBuilder;
@Nullable @Nullable
private final T editedInstance; private final T editedInstance;
@NotNull @Nonnull
private final CalculatorMathRegistry<T> mathRegistry; private final CalculatorMathRegistry<T> mathRegistry;
@NotNull @Nonnull
private final Object source; private final Object source;
@NotNull @Nonnull
private View editView; private View editView;
public VarEditorSaver(@NotNull MathEntityBuilder<? extends T> varBuilder, public VarEditorSaver(@Nonnull MathEntityBuilder<? extends T> varBuilder,
@Nullable T editedInstance, @Nullable T editedInstance,
@NotNull View editView, @Nonnull View editView,
@NotNull CalculatorMathRegistry<T> mathRegistry, @Nonnull CalculatorMathRegistry<T> mathRegistry,
@NotNull Object source) { @Nonnull Object source) {
this.varBuilder = varBuilder; this.varBuilder = varBuilder;
this.editedInstance = editedInstance; this.editedInstance = editedInstance;
this.editView = editView; this.editView = editView;

View File

@ -2,8 +2,8 @@ package org.solovyev.android.calculator.matrix;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import org.solovyev.android.calculator.CalculatorFragment; import org.solovyev.android.calculator.CalculatorFragment;
import org.solovyev.android.calculator.CalculatorFragmentType; import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
@ -86,24 +86,24 @@ public class CalculatorMatrixEditFragment extends CalculatorFragment implements
} }
@Override @Override
public void onSaveInstanceState(@NotNull Bundle out) { public void onSaveInstanceState(@Nonnull Bundle out) {
super.onSaveInstanceState(out); super.onSaveInstanceState(out);
out.putSerializable(MATRIX, new Matrix(getMatrixView(getView()).toMatrix())); out.putSerializable(MATRIX, new Matrix(getMatrixView(getView()).toMatrix()));
} }
@NotNull @Nonnull
private MatrixView getMatrixView(@NotNull View root) { private MatrixView getMatrixView(@Nonnull View root) {
return (MatrixView) root.findViewById(R.id.matrix_layout); return (MatrixView) root.findViewById(R.id.matrix_layout);
} }
private void initPicker(@NotNull Picker<Integer> picker) { private void initPicker(@Nonnull Picker<Integer> picker) {
picker.setRange(new IntegerRange(MIN_COUNT, MAX_COUNT, 1, 0, null)); picker.setRange(new IntegerRange(MIN_COUNT, MAX_COUNT, 1, 0, null));
picker.setOnChangeListener(this); picker.setOnChangeListener(this);
} }
@Override @Override
public void onChanged(@NotNull Picker picker, @NotNull Integer value) { public void onChanged(@Nonnull Picker picker, @Nonnull Integer value) {
switch (picker.getId()) { switch (picker.getId()) {
case R.id.matrix_rows_count_picker: case R.id.matrix_rows_count_picker:
onRowsCountChange(value); onRowsCountChange(value);
@ -114,23 +114,23 @@ public class CalculatorMatrixEditFragment extends CalculatorFragment implements
} }
} }
private void onColsCountChange(@NotNull Integer newCols) { private void onColsCountChange(@Nonnull Integer newCols) {
getMatrixView(getView()).setMatrixCols(newCols); getMatrixView(getView()).setMatrixCols(newCols);
} }
private void onRowsCountChange(@NotNull Integer newRows) { private void onRowsCountChange(@Nonnull Integer newRows) {
getMatrixView(getView()).setMatrixRows(newRows); getMatrixView(getView()).setMatrixRows(newRows);
} }
public static class Matrix implements Serializable { public static class Matrix implements Serializable {
@NotNull @Nonnull
private String[][] bakingArray; private String[][] bakingArray;
public Matrix() { public Matrix() {
} }
public Matrix(@NotNull String[][] bakingArray) { public Matrix(@Nonnull String[][] bakingArray) {
this.bakingArray = bakingArray; this.bakingArray = bakingArray;
} }
} }

View File

@ -8,8 +8,8 @@ import android.widget.EditText;
import android.widget.TableLayout; import android.widget.TableLayout;
import android.widget.TableRow; import android.widget.TableRow;
import android.widget.TextView; import android.widget.TextView;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
/** /**
* User: Solovyev_S * User: Solovyev_S
@ -122,7 +122,7 @@ public class MatrixView extends TableLayout {
} }
} }
public void setMatrix(@NotNull Object[][] matrix) { public void setMatrix(@Nonnull Object[][] matrix) {
final int rows = matrix.length; final int rows = matrix.length;
final int cols = matrix[0].length; final int cols = matrix[0].length;
@ -134,7 +134,7 @@ public class MatrixView extends TableLayout {
} }
} }
@NotNull @Nonnull
public String[][] toMatrix() { public String[][] toMatrix() {
final String[][] result = new String[rows][cols]; final String[][] result = new String[rows][cols];
@ -223,11 +223,11 @@ public class MatrixView extends TableLayout {
} }
@Nullable @Nullable
private View getCell(@NotNull View view, int row, int col) { private View getCell(@Nonnull View view, int row, int col) {
return view.findViewWithTag(getCellTag(row, col)); return view.findViewWithTag(getCellTag(row, col));
} }
@NotNull @Nonnull
private String getRowTag(int row) { private String getRowTag(int row) {
if (row != NUMBER_INDEX) { if (row != NUMBER_INDEX) {
return "row_" + row; return "row_" + row;
@ -236,7 +236,7 @@ public class MatrixView extends TableLayout {
} }
} }
@NotNull @Nonnull
private View createRowView(int row, int cols) { private View createRowView(int row, int cols) {
final ViewGroup rowView = new TableRow(this.getContext()); final ViewGroup rowView = new TableRow(this.getContext());
@ -255,7 +255,7 @@ public class MatrixView extends TableLayout {
return rowView; return rowView;
} }
@NotNull @Nonnull
private View createCellView(int row, int col) { private View createCellView(int row, int col) {
final TextView result; final TextView result;
@ -277,7 +277,7 @@ public class MatrixView extends TableLayout {
} }
@NotNull @Nonnull
private String getCellTag(int row, int col) { private String getCellTag(int row, int col) {
if (row != NUMBER_INDEX) { if (row != NUMBER_INDEX) {
return "cell_" + row + "_" + col; return "cell_" + row + "_" + col;

Some files were not shown because too many files have changed in this diff Show More