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

View File

@ -13,15 +13,7 @@
a:orientation="vertical" a:orientation="vertical"
a:layout_gravity="center"> a:layout_gravity="center">
<LinearLayout a:layout_weight="2" a:layout_width="match_parent" a:layout_height="0dp"> <include layout="@layout/calc_editor"/>
<org.solovyev.android.calculator.CalculatorEditor
a:id="@+id/editText"
style="@style/display_style"
a:inputType="textMultiLine"
a:singleLine="false"/>
</LinearLayout>
<LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp"> <LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
@ -33,21 +25,13 @@
a:onClick="moveLeftButtonClickHandler"/> a:onClick="moveLeftButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/eraseButton" <org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/eraseButton"
a:text="↚" a:text="@string/c_erase"
a:layout_weight="1.5" a:layout_weight="1.5"
style="@style/control_button_style" style="@style/control_button_style"
a:onClick="eraseButtonClickHandler"/> a:onClick="eraseButtonClickHandler"/>
<org.solovyev.android.calculator.CalculatorDisplay <include layout="@layout/calc_display"/>
a:id="@+id/resultEditText"
style="@style/display_style"
a:gravity="right|top"
a:layout_weight="1"
a:minLines="1"
a:maxLines="1"
a:textStyle="bold"
a:scrollHorizontally="true"
a:scrollbars="none"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/clearButton" <org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/clearButton"
a:text="@string/c_clear" a:text="@string/c_clear"
@ -67,129 +51,38 @@
<LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp"> <LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/oneDigitButton" <include layout="@layout/calc_one_digit_button"/>
a:text="1" <include layout="@layout/calc_two_digit_button"/>
calc:textUp="sin" <include layout="@layout/calc_three_digit_button"/>
calc:textDown="asin" <include layout="@layout/calc_multiplication_button"/>
style="@style/digit_button_style" <include layout="@layout/calc_division_button"/>
a:onClick="digitButtonClickHandler"/> <include layout="@layout/calc_equals_button"/>
<include layout="@layout/calc_paste_button"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/twoDigitButton"
a:text="2"
calc:textUp="cos"
calc:textDown="acos" style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/threeDigitButton" a:text="3" calc:textUp="tan"
calc:textDown="atan" style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/multiplicationButton" a:text="×"
calc:textUp="^"
calc:textDown="^2" style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/divisionButton" a:text="/"
calc:textUp="√"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/equalsButton"
a:text="="
a:layout_width="fill_parent"
style="@style/control_button_style"
a:onClick="numericButtonClickHandler"/>
<ImageButton a:id="@+id/pasteButton"
a:src="@drawable/paste"
style="@style/control_button_style"
a:onClick="pasteButtonClickHandler"/>
</LinearLayout> </LinearLayout>
<LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp"> <LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/fourDigitButton" <include layout="@layout/calc_four_digit_button"/>
a:text="4" <include layout="@layout/calc_five_digit_button"/>
calc:textUp="sinh" <include layout="@layout/calc_six_digit_button"/>
calc:textDown="asinh" <include layout="@layout/calc_plus_button"/>
style="@style/digit_button_style" <include layout="@layout/calc_subtraction_button"/>
a:onClick="digitButtonClickHandler"/> <include layout="@layout/calc_square_brackets_button"/>
<include layout="@layout/calc_history_button"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/fiveDigitButton"
a:text="5"
calc:textUp="cosh"
calc:textDown="acosh"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/sixDigitButton" a:text="6"
calc:textUp="tanh"
calc:textDown="atanh"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/plusButton" a:text="+"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/minusButton" a:text="-"
calc:textUp="{"
calc:textDown="}"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/squareBracketsButton" a:text="[]"
calc:textUp="["
calc:textDown="]" style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/historyButton"
a:text=""
calc:textUp="@string/c_undo"
calc:textDown="@string/c_redo"
style="@style/control_button_style"/>
</LinearLayout> </LinearLayout>
<LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp"> <LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/sevenDigitButton" a:text="7" <include layout="@layout/calc_seven_digit_button"/>
calc:textUp="i" <include layout="@layout/calc_eight_digit_button"/>
calc:textDown="" <include layout="@layout/calc_nine_digit_button"/>
style="@style/digit_button_style" <include layout="@layout/calc_zero_digit_button"/>
a:onClick="digitButtonClickHandler"/> <include layout="@layout/calc_round_brackets_button"/>
<include layout="@layout/calc_vars_button"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/eightDigitButton" a:text="8"
calc:textUp="ln"
calc:textDown=""
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/nineDigitButton" a:text="9"
calc:textDown="e"
calc:textUp="π"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/zeroDigitButton" a:text="0"
calc:textUp="."
calc:textDown=","
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/roundBracketsButton" a:text="()"
calc:textUp="("
calc:textDown=")" style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton
a:id="@+id/varsButton"
a:text="π,e,…"
a:textStyle="italic"
a:onClick="varsButtonClickHandler"
style="@style/control_button_style"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:text="" style="@style/control_button_style"/> <org.solovyev.android.view.widgets.DirectionDragButton a:text="" style="@style/control_button_style"/>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:orientation="vertical" a:orientation="vertical"
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="match_parent" a:layout_height="match_parent"
@ -13,195 +12,69 @@
a:orientation="vertical" a:orientation="vertical"
a:layout_gravity="center"> a:layout_gravity="center">
<LinearLayout a:layout_weight="2" a:layout_width="match_parent" a:layout_height="0dp"> <include layout="@layout/calc_editor"/>
<org.solovyev.android.calculator.CalculatorEditor
a:id="@+id/editText"
style="@style/display_style"
a:inputType="textMultiLine"
a:singleLine="false"/>
</LinearLayout>
<LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp"> <LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
<org.solovyev.android.view.widgets.DirectionDragButton
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/equalsButton" xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/equalsButton"
a:text="=" a:text="="
a:layout_width="fill_parent"
a:layout_weight="4" a:layout_weight="4"
style="@style/control_button_style" style="@style/control_button_style"
a:onClick="numericButtonClickHandler"/> a:onClick="numericButtonClickHandler"/>
<org.solovyev.android.calculator.CalculatorDisplay <include layout="@layout/calc_display"/>
a:id="@+id/resultEditText"
style="@style/display_style"
a:gravity="right|top"
a:layout_weight="1"
a:minLines="1"
a:maxLines="1"
a:textStyle="bold"
a:scrollHorizontally="true"
a:scrollbars="none"/>
</LinearLayout> </LinearLayout>
<LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp"> <LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/oneDigitButton" a:text="1" calc:textUp="sin" <include layout="@layout/calc_one_digit_button"/>
calc:textDown="asin" style="@style/digit_button_style" <include layout="@layout/calc_two_digit_button"/>
a:onClick="digitButtonClickHandler"/> <include layout="@layout/calc_three_digit_button"/>
<include layout="@layout/calc_multiplication_button"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/twoDigitButton" a:text="2" calc:textUp="cos" <include layout="@layout/calc_clear_button"/>
calc:textDown="acos" style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/threeDigitButton" a:text="3" calc:textUp="tan"
calc:textDown="atan" style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/multiplicationButton" a:text="×"
calc:textUp="^"
calc:textDown="^2" style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/clearButton"
a:text="@string/c_clear"
style="@style/control_button_style"
a:onClick="clearButtonClickHandler"/>
</LinearLayout> </LinearLayout>
<LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp"> <LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/fourDigitButton" <include layout="@layout/calc_four_digit_button"/>
a:text="4" <include layout="@layout/calc_five_digit_button"/>
calc:textUp="sinh" <include layout="@layout/calc_six_digit_button"/>
calc:textDown="asinh" <include layout="@layout/calc_division_button"/>
style="@style/digit_button_style" <include layout="@layout/calc_erase_button"/>
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/fiveDigitButton"
a:text="5"
calc:textUp="cosh"
calc:textDown="acosh"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/sixDigitButton" a:text="6"
calc:textUp="tanh"
calc:textDown="atanh"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/divisionButton" a:text="/"
calc:textUp="√"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/eraseButton"
a:text="↚"
style="@style/control_button_style"
a:onClick="eraseButtonClickHandler"/>
</LinearLayout> </LinearLayout>
<LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp"> <LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/sevenDigitButton" a:text="7" <include layout="@layout/calc_seven_digit_button"/>
calc:textUp="i" <include layout="@layout/calc_eight_digit_button"/>
calc:textDown="" <include layout="@layout/calc_nine_digit_button"/>
style="@style/digit_button_style" <include layout="@layout/calc_plus_button"/>
a:onClick="digitButtonClickHandler"/> <include layout="@layout/calc_paste_button"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/eightDigitButton" a:text="8"
calc:textUp="ln"
calc:textDown=""
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/nineDigitButton" a:text="9"
calc:textDown="e"
calc:textUp="π"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/plusButton" a:text="+"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<ImageButton a:id="@+id/pasteButton"
a:src="@drawable/paste"
style="@style/control_button_style"
a:onClick="pasteButtonClickHandler"/>
</LinearLayout> </LinearLayout>
<LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp"> <LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/roundBracketsButton" a:text="()" <include layout="@layout/calc_round_brackets_button"/>
calc:textUp="(" <include layout="@layout/calc_zero_digit_button"/>
calc:textDown=")" style="@style/digit_button_style" <include layout="@layout/calc_square_brackets_button"/>
a:onClick="digitButtonClickHandler"/> <include layout="@layout/calc_subtraction_button"/>
<include layout="@layout/calc_history_button"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/zeroDigitButton" a:text="0"
calc:textUp="."
calc:textDown=","
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/squareBracketsButton" a:text="[]"
calc:textUp="["
calc:textDown="]" style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/subtractionButton" a:text="-"
calc:textUp="{"
calc:textDown="}"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/historyButton"
a:text=""
calc:textUp="@string/c_undo"
calc:textDown="@string/c_redo"
style="@style/control_button_style"/>
</LinearLayout> </LinearLayout>
<LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp"> <LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
<include layout="@layout/calc_left_button"/>
<!-- <org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/numericButton" a:text="numeric" <include layout="@layout/calc_right_button"/>
style="@style/digit_button_style" <include layout="@layout/calc_vars_button"/>
a:onClick="numericButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/simplifyButton" a:text="simplify"
style="@style/digit_button_style"
a:onClick="simplifyButtonClickHandler"/>-->
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/leftButton"
calc:textUp="↞"
a:text="←"
style="@style/control_button_style"
a:onClick="moveLeftButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton
a:id="@+id/rightButton"
calc:textUp="↠"
a:text="→"
style="@style/control_button_style"
a:onClick="moveRightButtonClickHandler"/>
<org.solovyev.android.view.widgets.DirectionDragButton
a:id="@+id/varsButton"
a:text="π,e,…"
a:textStyle="italic"
a:onClick="varsButtonClickHandler"
style="@style/control_button_style"/>
<org.solovyev.android.view.widgets.DirectionDragButton a:text="" style="@style/control_button_style"/> <org.solovyev.android.view.widgets.DirectionDragButton a:text="" style="@style/control_button_style"/>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/clearButton"
a:text="@string/c_clear"
style="@style/control_button_style"
a:onClick="clearButtonClickHandler"/>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.calculator.CalculatorDisplay
xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/resultEditText"
style="@style/display_style"
a:layout_weight="1"
a:minLines="1"
a:maxLines="1"
a:textStyle="bold"
a:scrollHorizontally="true"
a:scrollbars="none"/>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/divisionButton" a:text="/"
calc:textUp="√"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_weight="2"
a:layout_width="match_parent"
a:layout_height="0dp">
<org.solovyev.android.calculator.CalculatorEditor
a:id="@+id/editText"
style="@style/editor_style"
a:inputType="textMultiLine"
a:maxLines="4"
a:scrollbars="vertical"
a:hint ="@string/c_calc_editor_hint"/>
</LinearLayout>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/eightDigitButton" a:text="8"
calc:textUp="ln"
calc:textDown=""
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton
xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/equalsButton"
a:text="="
a:layout_width="match_parent"
a:layout_height="match_parent"
style="@style/control_button_style"
a:onClick="numericButtonClickHandler"/>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/eraseButton"
a:text="@string/c_erase"
style="@style/control_button_style"
a:onClick="eraseButtonClickHandler"/>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/fiveDigitButton"
a:text="5"
calc:textUp="cosh"
calc:textDown="acosh"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/fourDigitButton"
a:text="4"
calc:textUp="sinh"
calc:textDown="asinh"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/historyButton"
a:text=""
calc:textUp="@string/c_undo"
calc:textDown="@string/c_redo"
style="@style/control_button_style"/>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/leftButton"
calc:textUp="↞"
a:text="←"
style="@style/control_button_style"
a:onClick="moveLeftButtonClickHandler"/>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/multiplicationButton"
a:text="×"
calc:textUp="^"
calc:textDown="^2"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/nineDigitButton" a:text="9"
calc:textDown="e"
calc:textUp="π"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/oneDigitButton"
a:text="1"
calc:textUp="sin"
calc:textDown="asin"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<ImageButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/pasteButton"
a:src="@drawable/paste"
style="@style/control_button_style"
a:padding="6dp"
a:onClick="pasteButtonClickHandler"/>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/plusButton" a:text="+"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/rightButton"
calc:textUp="↠"
a:text="→"
style="@style/control_button_style"
a:onClick="moveRightButtonClickHandler"/>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/roundBracketsButton" a:text="()"
calc:textUp="("
calc:textDown=")" style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/sevenDigitButton" a:text="7"
calc:textUp="i"
calc:textDown=""
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/sixDigitButton" a:text="6"
calc:textUp="tanh"
calc:textDown="atanh"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/squareBracketsButton" a:text="[]"
calc:textUp="["
calc:textDown="]" style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/subtractionButton" a:text="-"
calc:textUp="{"
calc:textDown="}"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/threeDigitButton"
a:text="3"
calc:textUp="tan"
calc:textDown="atan"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/twoDigitButton"
a:text="2"
calc:textUp="cos"
calc:textDown="acos"
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/varsButton"
a:text="π,e,…"
a:textStyle="italic"
a:onClick="varsButtonClickHandler"
style="@style/control_button_style"/>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/zeroDigitButton" a:text="0"
calc:textUp="."
calc:textDown=","
style="@style/digit_button_style"
a:onClick="digitButtonClickHandler"/>

View File

@ -27,7 +27,8 @@
<string name="c_undo">undo</string> <string name="c_undo">undo</string>
<string name="c_redo">redo</string> <string name="c_redo">redo</string>
<string name="c_clear">clr</string> <string name="c_clear">CE</string>
<string name="c_erase">C</string>
<string name="c_paste">paste</string> <string name="c_paste">paste</string>
<string name="c_vars">vars</string> <string name="c_vars">vars</string>
@ -57,4 +58,5 @@
<string name="c_pi_description">Ratio of any circle\'s circumference to its diameter</string> <string name="c_pi_description">Ratio of any circle\'s circumference to its diameter</string>
<string name="c_e_description">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</string> <string name="c_e_description">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</string>
<string name="c_i_description">Imaginary unit, defined such that i^2 = 1</string> <string name="c_i_description">Imaginary unit, defined such that i^2 = 1</string>
<string name="c_calc_editor_hint"></string>
</resources> </resources>

View File

@ -26,7 +26,7 @@
<item name="android:textSize">30dp</item> <item name="android:textSize">30dp</item>
</style> </style>
<style name="display_style"> <style name="editor_style">
<item name="android:textSize">25dp</item> <item name="android:textSize">25dp</item>
<item name="android:background">#000000</item> <item name="android:background">#000000</item>
<item name="android:textColor">@color/text_color</item> <item name="android:textColor">@color/text_color</item>
@ -36,4 +36,14 @@
<item name="android:layout_height">match_parent</item> <item name="android:layout_height">match_parent</item>
</style> </style>
<style name="display_style">
<item name="android:textSize">25dp</item>
<item name="android:background">#000000</item>
<item name="android:textColor">@color/text_color</item>
<item name="android:gravity">right|center_vertical</item>
<item name="android:padding">5dp</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
</style>
</resources> </resources>

View File

@ -23,6 +23,11 @@ public class CalculatorEditor extends EditText {
private boolean highlightText = true; 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) { public CalculatorEditor(Context context) {
super(context); super(context);
} }
@ -135,13 +140,11 @@ public class CalculatorEditor extends EditText {
} }
private String getColor(int numberOfOpenGroupSymbols, int numberOfOpenings) { 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(BASE_COLOUR_RED_COMPONENT - offset, BASE_COLOUR_GREEN_COMPONENT - offset, BASE_COLOUR_BLUE_COMPONENT - offset);
int result = Color.rgb(Color.red(baseColor) - i, Color.green(baseColor) - i, Color.blue(baseColor) - i);
return "#" + Integer.toHexString(result).substring(2); return "#" + Integer.toHexString(result).substring(2);
} }

View File

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

View File

@ -9,6 +9,7 @@ import bsh.EvalError;
import org.junit.Assert; import org.junit.Assert;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.simpleframework.xml.Attribute;
import org.solovyev.android.calculator.JsclOperation; import org.solovyev.android.calculator.JsclOperation;
/** /**
@ -79,4 +80,50 @@ public class CalculatorModelTest {
Assert.assertEquals("i", cm.createResultForComplexNumber("i")); Assert.assertEquals("i", cm.createResultForComplexNumber("i"));
} }
public interface TestInterface {
Integer getField();
}
public class TestClass implements TestInterface{
@Attribute(required = true)
private Integer field;
public TestClass() {
}
public TestClass(Integer field) {
this.field = field;
}
public Integer getField() {
return field;
}
public void setField(Integer field) {
this.field = field;
}
}
public class NewTestClass implements TestInterface{
@Attribute
private Integer field;
public NewTestClass() {
}
public NewTestClass(Integer field) {
this.field = field;
}
public Integer getField() {
return field;
}
public void setField(Integer field) {
this.field = field;
}
}
} }