From a3929945a8d94f9b80e28bfc0ba44c433a086ef1 Mon Sep 17 00:00:00 2001 From: serso Date: Sat, 8 Oct 2011 16:43:13 +0400 Subject: [PATCH] layout --- res/layout-land/main.xml | 189 +++----------- res/layout-port/main.xml | 239 ++++-------------- res/layout/calc_clear_button.xml | 14 + res/layout/calc_display.xml | 18 ++ res/layout/calc_division_button.xml | 14 + res/layout/calc_editor.xml | 22 ++ res/layout/calc_eight_digit_button.xml | 15 ++ res/layout/calc_equals_button.xml | 15 ++ res/layout/calc_erase_button.xml | 14 + res/layout/calc_five_digit_button.xml | 15 ++ res/layout/calc_four_digit_button.xml | 15 ++ res/layout/calc_history_button.xml | 14 + res/layout/calc_left_button.xml | 15 ++ res/layout/calc_multiplication_button.xml | 16 ++ res/layout/calc_nine_digit_button.xml | 15 ++ res/layout/calc_one_digit_button.xml | 16 ++ res/layout/calc_paste_button.xml | 15 ++ res/layout/calc_plus_button.xml | 12 + res/layout/calc_right_button.xml | 15 ++ res/layout/calc_round_brackets_button.xml | 14 + res/layout/calc_seven_digit_button.xml | 15 ++ res/layout/calc_six_digit_button.xml | 15 ++ res/layout/calc_square_brackets_button.xml | 14 + res/layout/calc_subtraction_button.xml | 14 + res/layout/calc_three_digit_button.xml | 16 ++ res/layout/calc_two_digit_button.xml | 16 ++ res/layout/calc_vars_button.xml | 14 + res/layout/calc_zero_digit_button.xml | 15 ++ res/values/strings.xml | 4 +- res/values/styles.xml | 12 +- .../android/calculator/CalculatorEditor.java | 13 +- .../android/calculator/CalculatorView.java | 9 +- .../calculator/model/CalculatorModelTest.java | 47 ++++ 33 files changed, 560 insertions(+), 346 deletions(-) create mode 100644 res/layout/calc_clear_button.xml create mode 100644 res/layout/calc_display.xml create mode 100644 res/layout/calc_division_button.xml create mode 100644 res/layout/calc_editor.xml create mode 100644 res/layout/calc_eight_digit_button.xml create mode 100644 res/layout/calc_equals_button.xml create mode 100644 res/layout/calc_erase_button.xml create mode 100644 res/layout/calc_five_digit_button.xml create mode 100644 res/layout/calc_four_digit_button.xml create mode 100644 res/layout/calc_history_button.xml create mode 100644 res/layout/calc_left_button.xml create mode 100644 res/layout/calc_multiplication_button.xml create mode 100644 res/layout/calc_nine_digit_button.xml create mode 100644 res/layout/calc_one_digit_button.xml create mode 100644 res/layout/calc_paste_button.xml create mode 100644 res/layout/calc_plus_button.xml create mode 100644 res/layout/calc_right_button.xml create mode 100644 res/layout/calc_round_brackets_button.xml create mode 100644 res/layout/calc_seven_digit_button.xml create mode 100644 res/layout/calc_six_digit_button.xml create mode 100644 res/layout/calc_square_brackets_button.xml create mode 100644 res/layout/calc_subtraction_button.xml create mode 100644 res/layout/calc_three_digit_button.xml create mode 100644 res/layout/calc_two_digit_button.xml create mode 100644 res/layout/calc_vars_button.xml create mode 100644 res/layout/calc_zero_digit_button.xml diff --git a/res/layout-land/main.xml b/res/layout-land/main.xml index ad76b96a..114fbc00 100644 --- a/res/layout-land/main.xml +++ b/res/layout-land/main.xml @@ -13,183 +13,76 @@ a:orientation="vertical" a:layout_gravity="center"> - - - - - + + calc:textUp="↞" + a:text="←" + a:layout_weight="1.5" + style="@style/control_button_style" + a:onClick="moveLeftButtonClickHandler"/> + a:text="@string/c_erase" + a:layout_weight="1.5" + style="@style/control_button_style" + a:onClick="eraseButtonClickHandler"/> + + - + a:text="@string/c_clear" + a:layout_weight="1.5" + style="@style/control_button_style" + a:onClick="clearButtonClickHandler"/> + calc:textUp="↠" + a:text="→" + a:layout_weight="1.5" + style="@style/control_button_style" + a:onClick="moveRightButtonClickHandler"/> - + + + + + + + - - - - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + diff --git a/res/layout-port/main.xml b/res/layout-port/main.xml index 8c1eb2bc..de58d175 100644 --- a/res/layout-port/main.xml +++ b/res/layout-port/main.xml @@ -1,7 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - + a:onClick="numericButtonClickHandler"/> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/layout/calc_clear_button.xml b/res/layout/calc_clear_button.xml new file mode 100644 index 00000000..b23a7d5a --- /dev/null +++ b/res/layout/calc_clear_button.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_display.xml b/res/layout/calc_display.xml new file mode 100644 index 00000000..4cd8b0ed --- /dev/null +++ b/res/layout/calc_display.xml @@ -0,0 +1,18 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_division_button.xml b/res/layout/calc_division_button.xml new file mode 100644 index 00000000..af34e07e --- /dev/null +++ b/res/layout/calc_division_button.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_editor.xml b/res/layout/calc_editor.xml new file mode 100644 index 00000000..96b36dea --- /dev/null +++ b/res/layout/calc_editor.xml @@ -0,0 +1,22 @@ + + + + + + + + + \ No newline at end of file diff --git a/res/layout/calc_eight_digit_button.xml b/res/layout/calc_eight_digit_button.xml new file mode 100644 index 00000000..8f3a85c1 --- /dev/null +++ b/res/layout/calc_eight_digit_button.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_equals_button.xml b/res/layout/calc_equals_button.xml new file mode 100644 index 00000000..11a5eb96 --- /dev/null +++ b/res/layout/calc_equals_button.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/res/layout/calc_erase_button.xml b/res/layout/calc_erase_button.xml new file mode 100644 index 00000000..13d49758 --- /dev/null +++ b/res/layout/calc_erase_button.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_five_digit_button.xml b/res/layout/calc_five_digit_button.xml new file mode 100644 index 00000000..e0298ed0 --- /dev/null +++ b/res/layout/calc_five_digit_button.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/res/layout/calc_four_digit_button.xml b/res/layout/calc_four_digit_button.xml new file mode 100644 index 00000000..0e91a73d --- /dev/null +++ b/res/layout/calc_four_digit_button.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/res/layout/calc_history_button.xml b/res/layout/calc_history_button.xml new file mode 100644 index 00000000..ee4bacc1 --- /dev/null +++ b/res/layout/calc_history_button.xml @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/res/layout/calc_left_button.xml b/res/layout/calc_left_button.xml new file mode 100644 index 00000000..b4b3d283 --- /dev/null +++ b/res/layout/calc_left_button.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_multiplication_button.xml b/res/layout/calc_multiplication_button.xml new file mode 100644 index 00000000..2f098764 --- /dev/null +++ b/res/layout/calc_multiplication_button.xml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_nine_digit_button.xml b/res/layout/calc_nine_digit_button.xml new file mode 100644 index 00000000..5551abe5 --- /dev/null +++ b/res/layout/calc_nine_digit_button.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_one_digit_button.xml b/res/layout/calc_one_digit_button.xml new file mode 100644 index 00000000..a8122356 --- /dev/null +++ b/res/layout/calc_one_digit_button.xml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_paste_button.xml b/res/layout/calc_paste_button.xml new file mode 100644 index 00000000..e2d73b8c --- /dev/null +++ b/res/layout/calc_paste_button.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_plus_button.xml b/res/layout/calc_plus_button.xml new file mode 100644 index 00000000..c0124cb7 --- /dev/null +++ b/res/layout/calc_plus_button.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/res/layout/calc_right_button.xml b/res/layout/calc_right_button.xml new file mode 100644 index 00000000..a3166423 --- /dev/null +++ b/res/layout/calc_right_button.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_round_brackets_button.xml b/res/layout/calc_round_brackets_button.xml new file mode 100644 index 00000000..e721bedc --- /dev/null +++ b/res/layout/calc_round_brackets_button.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_seven_digit_button.xml b/res/layout/calc_seven_digit_button.xml new file mode 100644 index 00000000..04813bc1 --- /dev/null +++ b/res/layout/calc_seven_digit_button.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_six_digit_button.xml b/res/layout/calc_six_digit_button.xml new file mode 100644 index 00000000..8246edb7 --- /dev/null +++ b/res/layout/calc_six_digit_button.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_square_brackets_button.xml b/res/layout/calc_square_brackets_button.xml new file mode 100644 index 00000000..360d83aa --- /dev/null +++ b/res/layout/calc_square_brackets_button.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_subtraction_button.xml b/res/layout/calc_subtraction_button.xml new file mode 100644 index 00000000..cc48a901 --- /dev/null +++ b/res/layout/calc_subtraction_button.xml @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/res/layout/calc_three_digit_button.xml b/res/layout/calc_three_digit_button.xml new file mode 100644 index 00000000..c35e6e78 --- /dev/null +++ b/res/layout/calc_three_digit_button.xml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_two_digit_button.xml b/res/layout/calc_two_digit_button.xml new file mode 100644 index 00000000..7df28622 --- /dev/null +++ b/res/layout/calc_two_digit_button.xml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_vars_button.xml b/res/layout/calc_vars_button.xml new file mode 100644 index 00000000..78efa2b0 --- /dev/null +++ b/res/layout/calc_vars_button.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/res/layout/calc_zero_digit_button.xml b/res/layout/calc_zero_digit_button.xml new file mode 100644 index 00000000..3bb1b7f7 --- /dev/null +++ b/res/layout/calc_zero_digit_button.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 105168f3..e531f851 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -27,7 +27,8 @@ undo redo - clr + CE + C paste vars @@ -57,4 +58,5 @@ Ratio of any circle\'s circumference to its diameter Unique real number such that the value of the derivative (slope of the tangent line) of the function f(x) = e^x at the point x = 0 is equal to 1 Imaginary unit, defined such that i^2 = −1 + diff --git a/res/values/styles.xml b/res/values/styles.xml index a51fe817..a333480e 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -26,7 +26,7 @@ 30dp - + + diff --git a/src/main/java/org/solovyev/android/calculator/CalculatorEditor.java b/src/main/java/org/solovyev/android/calculator/CalculatorEditor.java index 468e4ec5..17b63185 100644 --- a/src/main/java/org/solovyev/android/calculator/CalculatorEditor.java +++ b/src/main/java/org/solovyev/android/calculator/CalculatorEditor.java @@ -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); } diff --git a/src/main/java/org/solovyev/android/calculator/CalculatorView.java b/src/main/java/org/solovyev/android/calculator/CalculatorView.java index 1e96d7d1..8bb34d08 100644 --- a/src/main/java/org/solovyev/android/calculator/CalculatorView.java +++ b/src/main/java/org/solovyev/android/calculator/CalculatorView.java @@ -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 { // 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