This commit is contained in:
serso
2011-10-08 16:43:13 +04:00
parent 06f5d549a9
commit aee46bb4e3
33 changed files with 560 additions and 346 deletions

View File

@@ -23,6 +23,11 @@ public class CalculatorEditor extends EditText {
private boolean highlightText = true;
private final static int BASE_COLOUR = Color.WHITE;
private final static int BASE_COLOUR_RED_COMPONENT = Color.red(BASE_COLOUR);
private final static int BASE_COLOUR_GREEN_COMPONENT = Color.green(BASE_COLOUR);
private final static int BASE_COLOUR_BLUE_COMPONENT = Color.blue(BASE_COLOUR);
public CalculatorEditor(Context context) {
super(context);
}
@@ -135,13 +140,11 @@ public class CalculatorEditor extends EditText {
}
private String getColor(int numberOfOpenGroupSymbols, int numberOfOpenings) {
final int baseColor = Color.WHITE;
double c = 0.7;
double c = 1;
int offset = ((int) (255 * c)) * numberOfOpenings / (numberOfOpenGroupSymbols + 1);
int i = ((int) (255 * c)) * numberOfOpenings / (numberOfOpenGroupSymbols + 1);
int result = Color.rgb(Color.red(baseColor) - i, Color.green(baseColor) - i, Color.blue(baseColor) - i);
int result = Color.rgb(BASE_COLOUR_RED_COMPONENT - offset, BASE_COLOUR_GREEN_COMPONENT - offset, BASE_COLOUR_BLUE_COMPONENT - offset);
return "#" + Integer.toHexString(result).substring(2);
}

View File

@@ -6,13 +6,10 @@
package org.solovyev.android.calculator;
import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import android.text.ClipboardManager;
import android.text.InputType;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
@@ -38,7 +35,7 @@ import org.solovyev.common.utils.history.SimpleHistoryHelper;
public class CalculatorView implements CursorControl, HistoryControl<CalculatorHistoryState> {
// millis to wait before evaluation after user edit action
public static final int EVAL_DELAY_MILLIS = 700;
public static final int EVAL_DELAY_MILLIS = 1000;
@NotNull
private final CalculatorEditor editor;
@@ -55,11 +52,7 @@ public class CalculatorView implements CursorControl, HistoryControl<CalculatorH
public CalculatorView(@NotNull final Activity activity, @NotNull CalculatorModel calculator) {
this.calculatorModel = calculator;
final InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
this.editor = (CalculatorEditor) activity.findViewById(R.id.editText);
this.editor.setInputType(InputType.TYPE_NULL);
imm.hideSoftInputFromWindow(this.editor.getWindowToken(), 0);
this.display = (CalculatorDisplay) activity.findViewById(R.id.resultEditText);
this.display.setOnClickListener(new View.OnClickListener() {