Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
3a01528376
@ -11,14 +11,21 @@ import android.text.Html;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import jscl.math.Generic;
|
import jscl.math.Generic;
|
||||||
|
import jscl.math.function.Constant;
|
||||||
|
import jscl.math.function.IConstant;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.solovyev.android.calculator.jscl.JsclOperation;
|
import org.solovyev.android.calculator.jscl.JsclOperation;
|
||||||
import org.solovyev.android.calculator.model.CalculatorEngine;
|
import org.solovyev.android.calculator.model.CalculatorEngine;
|
||||||
import org.solovyev.android.calculator.model.CalculatorParseException;
|
import org.solovyev.android.calculator.model.CalculatorParseException;
|
||||||
import org.solovyev.android.calculator.model.TextProcessor;
|
import org.solovyev.android.calculator.model.TextProcessor;
|
||||||
|
import org.solovyev.android.view.AMenuBuilder;
|
||||||
|
import org.solovyev.android.view.AMenuItem;
|
||||||
import org.solovyev.android.view.AutoResizeTextView;
|
import org.solovyev.android.view.AutoResizeTextView;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
* Date: 9/17/11
|
* Date: 9/17/11
|
||||||
@ -26,6 +33,69 @@ import org.solovyev.android.view.AutoResizeTextView;
|
|||||||
*/
|
*/
|
||||||
public class CalculatorDisplay extends AutoResizeTextView implements ICalculatorDisplay{
|
public class CalculatorDisplay extends AutoResizeTextView implements ICalculatorDisplay{
|
||||||
|
|
||||||
|
public static enum Menu implements AMenuItem<CalculatorDisplay> {
|
||||||
|
to_bin(0) {
|
||||||
|
@Override
|
||||||
|
public void doAction(@NotNull CalculatorDisplay data, @NotNull Context context) {
|
||||||
|
//To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isItemVisibleFor(@NotNull Generic generic, @NotNull JsclOperation operation) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
plot(R.string.c_plot_graph) {
|
||||||
|
@Override
|
||||||
|
public void doAction(@NotNull CalculatorDisplay data, @NotNull Context context) {
|
||||||
|
//To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isItemVisibleFor(@NotNull Generic generic, @NotNull JsclOperation operation) {
|
||||||
|
boolean result = false;
|
||||||
|
|
||||||
|
if (operation == JsclOperation.simplify) {
|
||||||
|
final Set<Constant> notSystemConstants = new HashSet<Constant>();
|
||||||
|
for (Constant constant : generic.getConstants()) {
|
||||||
|
IConstant var = CalculatorEngine.instance.getVarsRegistry().get(constant.getName());
|
||||||
|
if (var != null && !var.isSystem() && !var.isDefined()) {
|
||||||
|
notSystemConstants.add(constant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (notSystemConstants.size() == 1) {
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private final int captionId;
|
||||||
|
|
||||||
|
Menu(int captionId) {
|
||||||
|
this.captionId = captionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isItemVisible(@NotNull CalculatorDisplay display) {
|
||||||
|
//noinspection ConstantConditions
|
||||||
|
return display.isValid() && display.getGenericResult() != null && isItemVisibleFor(display.getGenericResult(), display.getJsclOperation());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isItemVisibleFor(@NotNull Generic generic, @NotNull JsclOperation operation) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public String getCaption(@NotNull Context context) {
|
||||||
|
return context.getString(captionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean valid = true;
|
private boolean valid = true;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
Loading…
Reference in New Issue
Block a user