history changes
This commit is contained in:
parent
c4ecdbf8d3
commit
dc40632cc0
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<activity a:name=".CalculatorActivity"
|
<activity a:name=".CalculatorActivity"
|
||||||
a:label="@string/c_app_name">
|
a:label="@string/c_app_name">
|
||||||
s
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action a:name="android.intent.action.MAIN"/>
|
<action a:name="android.intent.action.MAIN"/>
|
||||||
<category a:name="android.intent.category.LAUNCHER"/>
|
<category a:name="android.intent.category.LAUNCHER"/>
|
||||||
@ -29,10 +29,18 @@
|
|||||||
a:label="@string/c_app_settings"
|
a:label="@string/c_app_settings"
|
||||||
a:configChanges="orientation|keyboardHidden"/>
|
a:configChanges="orientation|keyboardHidden"/>
|
||||||
|
|
||||||
<activity a:name=".CalculatorHistoryActivity"
|
<activity a:name=".history.CalculatorHistoryActivity"
|
||||||
a:label="@string/c_app_history"
|
a:label="@string/c_app_history"
|
||||||
a:configChanges="orientation|keyboardHidden"/>
|
a:configChanges="orientation|keyboardHidden"/>
|
||||||
|
|
||||||
|
<activity a:name=".history.HistoryActivityTab"
|
||||||
|
a:label="@string/c_history"
|
||||||
|
a:configChanges="orientation|keyboardHidden"/>
|
||||||
|
|
||||||
|
<activity a:name=".history.SavedHistoryActivityTab"
|
||||||
|
a:label="@string/c_saved_history"
|
||||||
|
a:configChanges="orientation|keyboardHidden"/>
|
||||||
|
|
||||||
<activity a:name=".AboutActivity"
|
<activity a:name=".AboutActivity"
|
||||||
a:label="@string/c_about"
|
a:label="@string/c_about"
|
||||||
a:configChanges="orientation|keyboardHidden"/>
|
a:configChanges="orientation|keyboardHidden"/>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:orientation="vertical"
|
a:orientation="vertical"
|
||||||
a:layout_width="fill_parent"
|
a:layout_width="fill_parent"
|
||||||
a:layout_height="fill_parent"
|
a:layout_height="fill_parent"
|
||||||
@ -24,11 +24,11 @@
|
|||||||
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/leftButton"
|
a:id="@+id/leftButton"
|
||||||
calc:textUp="◀◀"
|
c:textUp="◀◀"
|
||||||
a:text="◀"
|
a:text="◀"
|
||||||
calc:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
style="?controlButtonStyle"
|
style="?controlButtonStyle"
|
||||||
a:onClick="moveLeftButtonClickHandler"
|
a:onClick="moveLeftButtonClickHandler"
|
||||||
a:layout_width="0dp"
|
a:layout_width="0dp"
|
||||||
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<org.solovyev.android.view.widgets.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/eraseButton"
|
a:id="@+id/eraseButton"
|
||||||
a:drawableTop="@drawable/sym_keyboard_delete"
|
a:drawableTop="@drawable/sym_keyboard_delete"
|
||||||
style="?controlImageButtonStyle"
|
style="?controlImageButtonStyle"
|
||||||
@ -53,11 +53,13 @@
|
|||||||
a:layout_weight="4"/>
|
a:layout_weight="4"/>
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.NumeralBasesButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<org.solovyev.android.view.widgets.NumeralBasesButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/clearButton"
|
a:id="@+id/clearButton"
|
||||||
calc:textUp="dec"
|
c:textUp="dec"
|
||||||
|
c:textRight="oct"
|
||||||
a:text="@string/c_clear"
|
a:text="@string/c_clear"
|
||||||
calc:textDown="bin"
|
c:textDown="bin"
|
||||||
|
c:textLeft="hex"
|
||||||
a:textStyle="bold"
|
a:textStyle="bold"
|
||||||
style="?controlImageButtonStyle"
|
style="?controlImageButtonStyle"
|
||||||
a:onClick="clearButtonClickHandler"
|
a:onClick="clearButtonClickHandler"
|
||||||
@ -66,11 +68,11 @@
|
|||||||
a:layout_weight="1"/>
|
a:layout_weight="1"/>
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/rightButton"
|
a:id="@+id/rightButton"
|
||||||
calc:textUp="▶▶"
|
c:textUp="▶▶"
|
||||||
a:text="▶"
|
a:text="▶"
|
||||||
calc:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
style="?controlButtonStyle"
|
style="?controlButtonStyle"
|
||||||
a:onClick="moveRightButtonClickHandler"
|
a:onClick="moveRightButtonClickHandler"
|
||||||
a:layout_width="0dp"
|
a:layout_width="0dp"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:orientation="vertical"
|
a:orientation="vertical"
|
||||||
a:layout_width="fill_parent"
|
a:layout_width="fill_parent"
|
||||||
a:layout_height="fill_parent"
|
a:layout_height="fill_parent"
|
||||||
@ -18,11 +18,11 @@
|
|||||||
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/leftButton"
|
a:id="@+id/leftButton"
|
||||||
calc:textUp="◀◀"
|
c:textUp="◀◀"
|
||||||
a:text="◀"
|
a:text="◀"
|
||||||
calc:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
style="?controlButtonStyle"
|
style="?controlButtonStyle"
|
||||||
a:onClick="moveLeftButtonClickHandler"
|
a:onClick="moveLeftButtonClickHandler"
|
||||||
a:layout_width="0dp"
|
a:layout_width="0dp"
|
||||||
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<org.solovyev.android.view.widgets.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/eraseButton"
|
a:id="@+id/eraseButton"
|
||||||
a:drawableTop="@drawable/sym_keyboard_delete"
|
a:drawableTop="@drawable/sym_keyboard_delete"
|
||||||
style="?controlImageButtonStyle"
|
style="?controlImageButtonStyle"
|
||||||
@ -47,11 +47,13 @@
|
|||||||
a:layout_weight="4"/>
|
a:layout_weight="4"/>
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.NumeralBasesButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<org.solovyev.android.view.widgets.NumeralBasesButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/clearButton"
|
a:id="@+id/clearButton"
|
||||||
calc:textUp="dec"
|
c:textUp="dec"
|
||||||
|
c:textRight="oct"
|
||||||
a:text="@string/c_clear"
|
a:text="@string/c_clear"
|
||||||
calc:textDown="bin"
|
c:textDown="bin"
|
||||||
|
c:textLeft="hex"
|
||||||
a:textStyle="bold"
|
a:textStyle="bold"
|
||||||
style="?controlImageButtonStyle"
|
style="?controlImageButtonStyle"
|
||||||
a:onClick="clearButtonClickHandler"
|
a:onClick="clearButtonClickHandler"
|
||||||
@ -60,11 +62,11 @@
|
|||||||
a:layout_weight="1"/>
|
a:layout_weight="1"/>
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/rightButton"
|
a:id="@+id/rightButton"
|
||||||
calc:textUp="▶▶"
|
c:textUp="▶▶"
|
||||||
a:text="▶"
|
a:text="▶"
|
||||||
calc:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
style="?controlButtonStyle"
|
style="?controlButtonStyle"
|
||||||
a:onClick="moveRightButtonClickHandler"
|
a:onClick="moveRightButtonClickHandler"
|
||||||
a:layout_width="0dp"
|
a:layout_width="0dp"
|
||||||
|
@ -7,11 +7,13 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.NumeralBasesButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<org.solovyev.android.view.widgets.NumeralBasesButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/clearButton"
|
a:id="@+id/clearButton"
|
||||||
calc:textUp="dec"
|
c:textUp="dec"
|
||||||
|
c:textRight="oct"
|
||||||
a:text="@string/c_clear"
|
a:text="@string/c_clear"
|
||||||
calc:textDown="bin"
|
c:textDown="bin"
|
||||||
|
c:textLeft="hex"
|
||||||
a:textStyle="bold"
|
a:textStyle="bold"
|
||||||
style="?controlImageButtonStyle"
|
style="?controlImageButtonStyle"
|
||||||
a:onClick="clearButtonClickHandler"/>
|
a:onClick="clearButtonClickHandler"/>
|
@ -7,7 +7,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<org.solovyev.android.view.widgets.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/pasteButton"
|
a:id="@+id/pasteButton"
|
||||||
a:drawableTop="@drawable/copy"
|
a:drawableTop="@drawable/copy"
|
||||||
style="?controlImageButtonStyle"
|
style="?controlImageButtonStyle"
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/divisionButton"
|
a:id="@+id/divisionButton"
|
||||||
calc:textUp="%"
|
c:textUp="%"
|
||||||
a:text="/"
|
a:text="/"
|
||||||
calc:textDown="√"
|
c:textDown="√"
|
||||||
calc:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -7,7 +7,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<org.solovyev.android.view.widgets.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/pasteButton"
|
a:id="@+id/pasteButton"
|
||||||
a:drawableTop="@drawable/heart"
|
a:drawableTop="@drawable/heart"
|
||||||
style="?controlImageButtonStyle"
|
style="?controlImageButtonStyle"
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/squareBracketsButton"
|
a:id="@+id/squareBracketsButton"
|
||||||
a:text="."
|
a:text="."
|
||||||
calc:textUp=","
|
c:textUp=","
|
||||||
calc:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -7,11 +7,11 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/eightDigitButton" a:text="8"
|
a:id="@+id/eightDigitButton" a:text="8"
|
||||||
calc:textUp="ln"
|
c:textUp="ln"
|
||||||
calc:textLeft="0o:"
|
c:textLeft="0o:"
|
||||||
calc:textDown="lg"
|
c:textDown="lg"
|
||||||
calc:directionTextScale="0.5;0.5;0.5;0.33"
|
c:directionTextScale="0.5;0.5;0.5;0.33"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -6,5 +6,5 @@
|
|||||||
~ or visit http://se.solovyev.org
|
~ or visit http://se.solovyev.org
|
||||||
-->
|
-->
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
style="?controlButtonStyle"/>
|
style="?controlButtonStyle"/>
|
@ -7,11 +7,11 @@
|
|||||||
-->
|
-->
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton
|
<org.solovyev.android.view.widgets.DirectionDragButton
|
||||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/equalsButton"
|
a:id="@+id/equalsButton"
|
||||||
calc:textUp="≡"
|
c:textUp="≡"
|
||||||
a:text="="
|
a:text="="
|
||||||
calc:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
a:layout_width="fill_parent"
|
a:layout_width="fill_parent"
|
||||||
a:layout_height="fill_parent"
|
a:layout_height="fill_parent"
|
||||||
style="?controlButtonStyle"
|
style="?controlButtonStyle"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<org.solovyev.android.view.widgets.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/eraseButton"
|
a:id="@+id/eraseButton"
|
||||||
a:drawableTop="@drawable/sym_keyboard_delete"
|
a:drawableTop="@drawable/sym_keyboard_delete"
|
||||||
style="?controlImageButtonStyle"
|
style="?controlImageButtonStyle"
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
~ or visit http://se.solovyev.org
|
~ or visit http://se.solovyev.org
|
||||||
-->
|
-->
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/fiveDigitButton"
|
a:id="@+id/fiveDigitButton"
|
||||||
a:text="5"
|
a:text="5"
|
||||||
calc:textUp="t"
|
c:textUp="t"
|
||||||
calc:textLeft="E"
|
c:textLeft="E"
|
||||||
calc:textDown="j"
|
c:textDown="j"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -6,11 +6,11 @@
|
|||||||
~ or visit http://se.solovyev.org
|
~ or visit http://se.solovyev.org
|
||||||
-->
|
-->
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/fourDigitButton"
|
a:id="@+id/fourDigitButton"
|
||||||
a:text="4"
|
a:text="4"
|
||||||
calc:textUp="x"
|
c:textUp="x"
|
||||||
calc:textLeft="D"
|
c:textLeft="D"
|
||||||
calc:textDown="y"
|
c:textDown="y"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -7,7 +7,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/functionsButton"
|
a:id="@+id/functionsButton"
|
||||||
a:text="ƒ(x)"
|
a:text="ƒ(x)"
|
||||||
a:textStyle="italic"
|
a:textStyle="italic"
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
~ or visit http://se.solovyev.org
|
~ or visit http://se.solovyev.org
|
||||||
-->
|
-->
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/historyButton"
|
a:id="@+id/historyButton"
|
||||||
a:text="@string/c_history_button"
|
a:text="@string/c_history_button"
|
||||||
calc:textUp="@string/c_undo"
|
c:textUp="@string/c_undo"
|
||||||
calc:textDown="@string/c_redo"
|
c:textDown="@string/c_redo"
|
||||||
style="?controlButtonStyle"
|
style="?controlButtonStyle"
|
||||||
a:textStyle="bold"
|
a:textStyle="bold"
|
||||||
a:onClick="historyButtonClickHandler"/>
|
a:onClick="historyButtonClickHandler"/>
|
@ -7,10 +7,10 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/leftButton"
|
a:id="@+id/leftButton"
|
||||||
calc:textUp="◀◀"
|
c:textUp="◀◀"
|
||||||
a:text="◀"
|
a:text="◀"
|
||||||
calc:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
style="?controlButtonStyle"
|
style="?controlButtonStyle"
|
||||||
a:onClick="moveLeftButtonClickHandler"/>
|
a:onClick="moveLeftButtonClickHandler"/>
|
@ -7,12 +7,12 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/multiplicationButton"
|
a:id="@+id/multiplicationButton"
|
||||||
a:text="×"
|
a:text="×"
|
||||||
calc:textUp="^"
|
c:textUp="^"
|
||||||
calc:textDown="^2"
|
c:textDown="^2"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
calc:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
|
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -7,11 +7,11 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/nineDigitButton" a:text="9"
|
a:id="@+id/nineDigitButton" a:text="9"
|
||||||
calc:textDown="e"
|
c:textDown="e"
|
||||||
calc:textLeft="0x:"
|
c:textLeft="0x:"
|
||||||
calc:textUp="π"
|
c:textUp="π"
|
||||||
calc:directionTextScale="0.5;0.5;0.5;0.33"
|
c:directionTextScale="0.5;0.5;0.5;0.33"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -7,11 +7,11 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/oneDigitButton"
|
a:id="@+id/oneDigitButton"
|
||||||
a:text="1"
|
a:text="1"
|
||||||
calc:textUp="sin"
|
c:textUp="sin"
|
||||||
calc:textLeft="A"
|
c:textLeft="A"
|
||||||
calc:textDown="asin"
|
c:textDown="asin"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -7,7 +7,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<org.solovyev.android.view.widgets.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/pasteButton"
|
a:id="@+id/pasteButton"
|
||||||
a:drawableTop="@drawable/paste"
|
a:drawableTop="@drawable/paste"
|
||||||
style="?controlImageButtonStyle"
|
style="?controlImageButtonStyle"
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
~ or visit http://se.solovyev.org
|
~ or visit http://se.solovyev.org
|
||||||
-->
|
-->
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/plusButton"
|
a:id="@+id/plusButton"
|
||||||
calc:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
calc:textUp="°"
|
c:textUp="°"
|
||||||
calc:textDown="E"
|
c:textDown="E"
|
||||||
a:text="+"
|
a:text="+"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -7,10 +7,10 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/rightButton"
|
a:id="@+id/rightButton"
|
||||||
calc:textUp="▶▶"
|
c:textUp="▶▶"
|
||||||
a:text="▶"
|
a:text="▶"
|
||||||
calc:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
style="?controlButtonStyle"
|
style="?controlButtonStyle"
|
||||||
a:onClick="moveRightButtonClickHandler"/>
|
a:onClick="moveRightButtonClickHandler"/>
|
@ -7,11 +7,11 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/roundBracketsButton" a:text="()"
|
a:id="@+id/roundBracketsButton" a:text="()"
|
||||||
calc:textUp="("
|
c:textUp="("
|
||||||
calc:textDown=")"
|
c:textDown=")"
|
||||||
calc:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
|
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -7,11 +7,11 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/sevenDigitButton" a:text="7"
|
a:id="@+id/sevenDigitButton" a:text="7"
|
||||||
calc:textUp="i"
|
c:textUp="i"
|
||||||
calc:textLeft="0b:"
|
c:textLeft="0b:"
|
||||||
calc:textDown="!"
|
c:textDown="!"
|
||||||
calc:directionTextScale="0.5;0.5;0.5;0.33"
|
c:directionTextScale="0.5;0.5;0.5;0.33"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -7,11 +7,12 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.AngleUnitsButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<org.solovyev.android.view.widgets.AngleUnitsButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
calc:textUp="deg"
|
c:textUp="deg"
|
||||||
a:id="@+id/sixDigitButton"
|
a:id="@+id/sixDigitButton"
|
||||||
a:text="6"
|
a:text="6"
|
||||||
calc:textLeft="F"
|
c:textLeft="F"
|
||||||
calc:textDown="rad"
|
c:textRight="grad"
|
||||||
|
c:textDown="rad"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -6,10 +6,10 @@
|
|||||||
~ or visit http://se.solovyev.org
|
~ or visit http://se.solovyev.org
|
||||||
-->
|
-->
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/subtractionButton"
|
a:id="@+id/subtractionButton"
|
||||||
calc:textDown="∂,…"
|
c:textDown="∂,…"
|
||||||
a:text="-"
|
a:text="-"
|
||||||
calc:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -7,11 +7,11 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/threeDigitButton"
|
a:id="@+id/threeDigitButton"
|
||||||
a:text="3"
|
a:text="3"
|
||||||
calc:textUp="tan"
|
c:textUp="tan"
|
||||||
calc:textLeft="C"
|
c:textLeft="C"
|
||||||
calc:textDown="atan"
|
c:textDown="atan"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -7,11 +7,11 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/twoDigitButton"
|
a:id="@+id/twoDigitButton"
|
||||||
a:text="2"
|
a:text="2"
|
||||||
calc:textUp="cos"
|
c:textUp="cos"
|
||||||
calc:textLeft="B"
|
c:textLeft="B"
|
||||||
calc:textDown="acos"
|
c:textDown="acos"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -7,10 +7,10 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/varsButton"
|
a:id="@+id/varsButton"
|
||||||
calc:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
calc:textUp="+π"
|
c:textUp="+π"
|
||||||
a:text="π,…"
|
a:text="π,…"
|
||||||
a:textStyle="italic"
|
a:textStyle="italic"
|
||||||
a:onClick="varsButtonClickHandler"
|
a:onClick="varsButtonClickHandler"
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/zeroDigitButton"
|
a:id="@+id/zeroDigitButton"
|
||||||
a:text="0"
|
a:text="0"
|
||||||
calc:textDown="000"
|
c:textDown="000"
|
||||||
calc:directionTextScale="0.5"
|
c:directionTextScale="0.5"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -1,7 +1,7 @@
|
|||||||
<?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"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:orientation="vertical"
|
a:orientation="vertical"
|
||||||
a:layout_width="fill_parent"
|
a:layout_width="fill_parent"
|
||||||
a:layout_height="fill_parent"
|
a:layout_height="fill_parent"
|
||||||
@ -23,16 +23,16 @@
|
|||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/calibrationButtonLeft"
|
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/calibrationButtonLeft"
|
||||||
a:text=""
|
a:text=""
|
||||||
calc:textUp="@string/c_up"
|
c:textUp="@string/c_up"
|
||||||
calc:textDown="@string/c_down"
|
c:textDown="@string/c_down"
|
||||||
a:layout_width="80dp"
|
a:layout_width="80dp"
|
||||||
a:layout_height="80dp"
|
a:layout_height="80dp"
|
||||||
style="?digitButtonStyle"/>
|
style="?digitButtonStyle"/>
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/calibrationButtonRight"
|
<org.solovyev.android.view.widgets.DirectionDragButton a:id="@+id/calibrationButtonRight"
|
||||||
a:text=""
|
a:text=""
|
||||||
calc:textUp="@string/c_up"
|
c:textUp="@string/c_up"
|
||||||
calc:textDown="@string/c_down"
|
c:textDown="@string/c_down"
|
||||||
a:layout_width="80dp"
|
a:layout_width="80dp"
|
||||||
a:layout_height="80dp"
|
a:layout_height="80dp"
|
||||||
style="?digitButtonStyle"/>
|
style="?digitButtonStyle"/>
|
||||||
|
30
res/layout/history_tabs.xml
Normal file
30
res/layout/history_tabs.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?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
|
||||||
|
-->
|
||||||
|
|
||||||
|
<TabHost xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
|
a:id="@android:id/tabhost"
|
||||||
|
a:layout_width="fill_parent"
|
||||||
|
a:layout_height="fill_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
a:orientation="vertical"
|
||||||
|
a:layout_width="fill_parent"
|
||||||
|
a:layout_height="fill_parent">
|
||||||
|
|
||||||
|
<TabWidget
|
||||||
|
a:id="@android:id/tabs"
|
||||||
|
a:layout_width="fill_parent"
|
||||||
|
a:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
a:id="@android:id/tabcontent"
|
||||||
|
a:layout_width="fill_parent"
|
||||||
|
a:layout_height="fill_parent"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</TabHost>
|
@ -3,6 +3,7 @@
|
|||||||
<declare-styleable name="DragButton">
|
<declare-styleable name="DragButton">
|
||||||
<attr name="textUp" format="string"/>
|
<attr name="textUp" format="string"/>
|
||||||
<attr name="textDown" format="string"/>
|
<attr name="textDown" format="string"/>
|
||||||
|
<attr name="textRight" format="string"/>
|
||||||
<attr name="textLeft" format="string"/>
|
<attr name="textLeft" format="string"/>
|
||||||
<attr name="directionTextScale" format="string"/>
|
<attr name="directionTextScale" format="string"/>
|
||||||
<attr name="hTextPosition" format="float"/>
|
<attr name="hTextPosition" format="float"/>
|
||||||
|
@ -314,5 +314,6 @@ Check the \'Round result\' preference in application settings - it should be tur
|
|||||||
<string name="c_save_history">Save history</string>
|
<string name="c_save_history">Save history</string>
|
||||||
<string name="c_edit_history">Modify history</string>
|
<string name="c_edit_history">Modify history</string>
|
||||||
<string name="c_edit">Modify</string>
|
<string name="c_edit">Modify</string>
|
||||||
|
<string name="c_saved_history">Saved history</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -162,7 +162,7 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
|||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
if (dragButton instanceof AngleUnitsButton) {
|
if (dragButton instanceof AngleUnitsButton) {
|
||||||
if (dragDirection == DragDirection.up || dragDirection == DragDirection.down ) {
|
if (dragDirection != DragDirection.left ) {
|
||||||
final String directionText = ((AngleUnitsButton) dragButton).getText(dragDirection);
|
final String directionText = ((AngleUnitsButton) dragButton).getText(dragDirection);
|
||||||
if ( directionText != null ) {
|
if ( directionText != null ) {
|
||||||
try {
|
try {
|
||||||
@ -564,7 +564,9 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences preferences, @Nullable String key) {
|
public void onSharedPreferenceChanged(SharedPreferences preferences, @Nullable String key) {
|
||||||
dpclRegister.announce().onDragPreferencesChange(SimpleOnDragListener.getPreferences(preferences, this));
|
if (key != null && key.startsWith("org.solovyev.android.calculator.DragButtonCalibrationActivity")) {
|
||||||
|
dpclRegister.announce().onDragPreferencesChange(SimpleOnDragListener.getPreferences(preferences, this));
|
||||||
|
}
|
||||||
|
|
||||||
if (CalculatorEngine.GROUPING_SEPARATOR_P_KEY.equals(key) ||
|
if (CalculatorEngine.GROUPING_SEPARATOR_P_KEY.equals(key) ||
|
||||||
CalculatorEngine.MULTIPLICATION_SIGN_P_KEY.equals(key) ||
|
CalculatorEngine.MULTIPLICATION_SIGN_P_KEY.equals(key) ||
|
||||||
|
@ -8,6 +8,7 @@ import jscl.math.function.Constant;
|
|||||||
import org.achartengine.ChartFactory;
|
import org.achartengine.ChartFactory;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.solovyev.android.calculator.help.HelpActivity;
|
import org.solovyev.android.calculator.help.HelpActivity;
|
||||||
|
import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
|
||||||
import org.solovyev.common.utils.StringUtils;
|
import org.solovyev.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,242 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
|
||||||
* For more information, please, contact se.solovyev@gmail.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.solovyev.android.calculator;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.solovyev.android.view.widgets.*;
|
|
||||||
import org.solovyev.common.NumberIntervalMapper;
|
|
||||||
import org.solovyev.common.collections.ManyValuedHashMap;
|
|
||||||
import org.solovyev.common.collections.ManyValuedMap;
|
|
||||||
import org.solovyev.common.utils.*;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User: serso
|
|
||||||
* Date: 7/16/11
|
|
||||||
* Time: 7:28 PM
|
|
||||||
*/
|
|
||||||
public class DragButtonCalibrationActivity extends Activity {
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private final List<DragData> dragHistory = new ArrayList<DragData>();
|
|
||||||
|
|
||||||
private final Map<DragButton, CalibrationArrow> map = new HashMap<DragButton, CalibrationArrow>();
|
|
||||||
|
|
||||||
private static final float DEFAULT_VALUE = -999;
|
|
||||||
private static final int MIN_HISTORY_FOR_CALIBRATION = 10;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
setContentView(R.layout.drag_button_calibration);
|
|
||||||
|
|
||||||
createCalibrationButton(R.id.calibrationButtonRight, R.id.calibrationArrowRight);
|
|
||||||
createCalibrationButton(R.id.calibrationButtonLeft, R.id.calibrationArrowLeft);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createCalibrationButton(int buttonId, int arrowId) {
|
|
||||||
final DragButton calibrationButton = (DragButton) findViewById(buttonId);
|
|
||||||
calibrationButton.setOnDragListener(new CalibrationOnDragListener());
|
|
||||||
|
|
||||||
ImageView imageView = (ImageView) findViewById(arrowId);
|
|
||||||
CalibrationArrow calibrationArrow = new CalibrationArrow(imageView);
|
|
||||||
|
|
||||||
createDragDirection(0, calibrationArrow);
|
|
||||||
|
|
||||||
map.put(calibrationButton, calibrationArrow);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createDragDirection(long timeout, @NotNull final CalibrationArrow calibrationArrow) {
|
|
||||||
new Handler().postDelayed(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
calibrationArrow.dragDirection = Math.random() > 0.5 ? DragDirection.up : DragDirection.down;
|
|
||||||
|
|
||||||
calibrationArrow.calibrationArrow.setImageResource(calibrationArrow.dragDirection == DragDirection.down ? R.drawable.down : R.drawable.up);
|
|
||||||
}
|
|
||||||
}, timeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void restartClickHandler(View v) {
|
|
||||||
for (CalibrationArrow calibrationArrow : map.values()) {
|
|
||||||
createDragDirection(0, calibrationArrow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private class CalibrationOnDragListener implements OnDragListener {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSuppressOnClickEvent() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onDrag(@NotNull DragButton dragButton, @NotNull DragEvent event) {
|
|
||||||
final Point2d startPoint = event.getStartPoint();
|
|
||||||
final MotionEvent motionEvent = event.getMotionEvent();
|
|
||||||
|
|
||||||
// init end point
|
|
||||||
final Point2d endPoint = new Point2d(motionEvent.getX(), motionEvent.getY());
|
|
||||||
|
|
||||||
float distance = MathUtils.getDistance(startPoint, endPoint);
|
|
||||||
|
|
||||||
double angle = Math.toDegrees(MathUtils.getAngle(startPoint, MathUtils.sum(startPoint, SimpleOnDragListener.axis), endPoint));
|
|
||||||
|
|
||||||
final CalibrationArrow calibrationArrow = map.get(dragButton);
|
|
||||||
final DragDirection dragDirection = calibrationArrow.dragDirection;
|
|
||||||
|
|
||||||
assert dragDirection == DragDirection.up || dragDirection == DragDirection.down;
|
|
||||||
|
|
||||||
double deviationAngle = angle;
|
|
||||||
if (dragDirection == DragDirection.up) {
|
|
||||||
deviationAngle = 180 - deviationAngle;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (deviationAngle > 45) {
|
|
||||||
calibrationArrow.calibrationArrow.setImageResource(R.drawable.not_ok);
|
|
||||||
} else {
|
|
||||||
calibrationArrow.calibrationArrow.setImageResource(R.drawable.ok);
|
|
||||||
dragHistory.add(new DragData(dragDirection, distance, angle, (motionEvent.getEventTime() - motionEvent.getDownTime())));
|
|
||||||
}
|
|
||||||
|
|
||||||
createDragDirection(500, calibrationArrow);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
|
||||||
|
|
||||||
if (dragHistory.size() > MIN_HISTORY_FOR_CALIBRATION) {
|
|
||||||
final ManyValuedMap<DragDirection, Double> anglesByDirection = new ManyValuedHashMap<DragDirection, Double>();
|
|
||||||
final ManyValuedMap<DragDirection, Double> distancesByDirection = new ManyValuedHashMap<DragDirection, Double>();
|
|
||||||
final ManyValuedMap<DragDirection, Double> timesByDirection = new ManyValuedHashMap<DragDirection, Double>();
|
|
||||||
for (DragData dragData : dragHistory) {
|
|
||||||
anglesByDirection.put(dragData.getDirection(), dragData.getAngle());
|
|
||||||
distancesByDirection.put(dragData.getDirection(), (double) dragData.getDistance());
|
|
||||||
timesByDirection.put(dragData.getDirection(), dragData.getTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
final Map<DragDirection, MathUtils.StatData> angleStatData = getStatDataByDirection(anglesByDirection);
|
|
||||||
final Map<DragDirection, MathUtils.StatData> distanceStatData = getStatDataByDirection(distancesByDirection);
|
|
||||||
final Map<DragDirection, MathUtils.StatData> timeStatData = getStatDataByDirection(timesByDirection);
|
|
||||||
|
|
||||||
Log.d(this.getClass().getName(), "Angle statistics: ");
|
|
||||||
logStatData(angleStatData);
|
|
||||||
|
|
||||||
Log.d(this.getClass().getName(), "Distance statistics: ");
|
|
||||||
logStatData(distanceStatData);
|
|
||||||
|
|
||||||
Log.d(this.getClass().getName(), "Time statistics: ");
|
|
||||||
logStatData(timeStatData);
|
|
||||||
|
|
||||||
final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
final SharedPreferences.Editor editor = settings.edit();
|
|
||||||
|
|
||||||
setPreferences(angleStatData, editor, SimpleOnDragListener.PreferenceType.angle);
|
|
||||||
setPreferences(distanceStatData, editor, SimpleOnDragListener.PreferenceType.distance);
|
|
||||||
setPreferences(timeStatData, editor, SimpleOnDragListener.PreferenceType.duration);
|
|
||||||
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return super.onKeyDown(keyCode, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setPreferences(@NotNull Map<DragDirection, MathUtils.StatData> statData, @NotNull SharedPreferences.Editor editor, @NotNull SimpleOnDragListener.PreferenceType preferenceType) {
|
|
||||||
final Mapper<Interval<Float>> mapper = new NumberIntervalMapper<Float>(Float.class);
|
|
||||||
for (Map.Entry<DragDirection, MathUtils.StatData> entry : statData.entrySet()) {
|
|
||||||
final float min = (float) entry.getValue().getMean() - 2 * (float) entry.getValue().getStandardDeviation();
|
|
||||||
final float max = (float) entry.getValue().getMean() + 2 * (float) entry.getValue().getStandardDeviation();
|
|
||||||
editor.putString(SimpleOnDragListener.getPreferenceId(preferenceType, entry.getKey()), mapper.formatValue(SimpleOnDragListener.transformInterval(preferenceType, entry.getKey(), new NumberInterval<Float>(Math.max(0, min), max))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void logStatData(@NotNull Map<DragDirection, MathUtils.StatData> statData) {
|
|
||||||
for (Map.Entry<DragDirection, MathUtils.StatData> entry : statData.entrySet()) {
|
|
||||||
Log.d(this.getClass().getName(), entry.getKey() + "-> m: " + entry.getValue().getMean() + ", d: " + entry.getValue().getStandardDeviation());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<DragDirection, MathUtils.StatData> getStatDataByDirection(@NotNull ManyValuedMap<DragDirection, Double> valuesByDirection) {
|
|
||||||
final Map<DragDirection, MathUtils.StatData> result = new HashMap<DragDirection, MathUtils.StatData>();
|
|
||||||
|
|
||||||
for (Map.Entry<DragDirection, List<Double>> entry : valuesByDirection.entrySet()) {
|
|
||||||
result.put(entry.getKey(), MathUtils.getStatData(entry.getValue()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private class DragData {
|
|
||||||
|
|
||||||
private float distance;
|
|
||||||
|
|
||||||
private double angle;
|
|
||||||
|
|
||||||
private double time;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private DragDirection direction;
|
|
||||||
|
|
||||||
private DragData(@NotNull DragDirection direction, float distance, double angle, double time) {
|
|
||||||
this.distance = distance;
|
|
||||||
this.angle = angle;
|
|
||||||
this.direction = direction;
|
|
||||||
this.time = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getDistance() {
|
|
||||||
return distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getAngle() {
|
|
||||||
return angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public DragDirection getDirection() {
|
|
||||||
return direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getTime() {
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class CalibrationArrow {
|
|
||||||
@NotNull
|
|
||||||
private ImageView calibrationArrow;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private DragDirection dragDirection = DragDirection.up;
|
|
||||||
|
|
||||||
private CalibrationArrow(@NotNull ImageView calibrationArrow) {
|
|
||||||
this.calibrationArrow = calibrationArrow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -35,8 +35,6 @@ public class HelpActivity extends TabActivity {
|
|||||||
createTab(tabHost, "screens", R.string.c_screens, HelpScreensActivity.class);
|
createTab(tabHost, "screens", R.string.c_screens, HelpScreensActivity.class);
|
||||||
|
|
||||||
tabHost.setCurrentTab(0);
|
tabHost.setCurrentTab(0);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createTab(@NotNull TabHost tabHost,
|
private void createTab(@NotNull TabHost tabHost,
|
||||||
@ -49,8 +47,7 @@ public class HelpActivity extends TabActivity {
|
|||||||
final Intent intent = new Intent().setClass(this, activityClass);
|
final Intent intent = new Intent().setClass(this, activityClass);
|
||||||
|
|
||||||
// Initialize a TabSpec for each tab and add it to the TabHost
|
// Initialize a TabSpec for each tab and add it to the TabHost
|
||||||
spec = tabHost.newTabSpec(tabId).setIndicator(getString(tabCaptionId))
|
spec = tabHost.newTabSpec(tabId).setIndicator(getString(tabCaptionId)).setContent(intent);
|
||||||
.setContent(intent);
|
|
||||||
|
|
||||||
tabHost.addTab(spec);
|
tabHost.addTab(spec);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* or visit http://se.solovyev.org
|
* or visit http://se.solovyev.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator.history;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
@ -15,16 +15,15 @@ import android.view.*;
|
|||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
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.history.*;
|
import org.solovyev.android.calculator.CalculatorModel;
|
||||||
|
import org.solovyev.android.calculator.R;
|
||||||
import org.solovyev.android.calculator.jscl.JsclOperation;
|
import org.solovyev.android.calculator.jscl.JsclOperation;
|
||||||
import org.solovyev.android.view.AMenu;
|
import org.solovyev.android.view.AMenu;
|
||||||
import org.solovyev.android.view.AMenuItem;
|
import org.solovyev.android.view.AMenuItem;
|
||||||
import org.solovyev.android.view.MenuImpl;
|
import org.solovyev.android.view.MenuImpl;
|
||||||
import org.solovyev.android.view.prefs.ResourceCache;
|
|
||||||
import org.solovyev.common.utils.*;
|
import org.solovyev.common.utils.*;
|
||||||
import org.solovyev.common.utils.Filter;
|
import org.solovyev.common.utils.Filter;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,9 +31,9 @@ import java.util.*;
|
|||||||
* Date: 10/15/11
|
* Date: 10/15/11
|
||||||
* Time: 1:13 PM
|
* Time: 1:13 PM
|
||||||
*/
|
*/
|
||||||
public class CalculatorHistoryActivity extends ListActivity {
|
public abstract class AbstractHistoryActivity extends ListActivity {
|
||||||
|
|
||||||
private static final Comparator<CalculatorHistoryState> COMPARATOR = new Comparator<CalculatorHistoryState>() {
|
public static final Comparator<CalculatorHistoryState> COMPARATOR = new Comparator<CalculatorHistoryState>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(CalculatorHistoryState state1, CalculatorHistoryState state2) {
|
public int compare(CalculatorHistoryState state1, CalculatorHistoryState state2) {
|
||||||
if (state1.isSaved() == state2.isSaved()) {
|
if (state1.isSaved() == state2.isSaved()) {
|
||||||
@ -59,13 +58,12 @@ public class CalculatorHistoryActivity extends ListActivity {
|
|||||||
|
|
||||||
setContentView(R.layout.history_activity);
|
setContentView(R.layout.history_activity);
|
||||||
|
|
||||||
final List<CalculatorHistoryState> historyList = getHistoryList();
|
/* if ( historyList.isEmpty() ) {
|
||||||
if ( historyList.isEmpty() ) {
|
|
||||||
Toast.makeText(this, R.string.c_history_is_empty, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.c_history_is_empty, Toast.LENGTH_SHORT).show();
|
||||||
this.finish();
|
this.finish();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
adapter = new HistoryArrayAdapter(this, R.layout.history, R.id.history_item, historyList);
|
adapter = new HistoryArrayAdapter(this, R.layout.history, R.id.history_item, new ArrayList<CalculatorHistoryState>());
|
||||||
setListAdapter(adapter);
|
setListAdapter(adapter);
|
||||||
|
|
||||||
final ListView lv = getListView();
|
final ListView lv = getListView();
|
||||||
@ -77,7 +75,7 @@ public class CalculatorHistoryActivity extends ListActivity {
|
|||||||
final int position,
|
final int position,
|
||||||
final long id) {
|
final long id) {
|
||||||
|
|
||||||
useHistoryItem((CalculatorHistoryState) parent.getItemAtPosition(position), CalculatorHistoryActivity.this);
|
useHistoryItem((CalculatorHistoryState) parent.getItemAtPosition(position), AbstractHistoryActivity.this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -86,7 +84,7 @@ public class CalculatorHistoryActivity extends ListActivity {
|
|||||||
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
|
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
|
||||||
final CalculatorHistoryState historyState = (CalculatorHistoryState) parent.getItemAtPosition(position);
|
final CalculatorHistoryState historyState = (CalculatorHistoryState) parent.getItemAtPosition(position);
|
||||||
|
|
||||||
final Context context = CalculatorHistoryActivity.this;
|
final Context context = AbstractHistoryActivity.this;
|
||||||
|
|
||||||
final HistoryItemMenuData data = new HistoryItemMenuData(historyState, adapter);
|
final HistoryItemMenuData data = new HistoryItemMenuData(historyState, adapter);
|
||||||
|
|
||||||
@ -105,10 +103,11 @@ public class CalculatorHistoryActivity extends ListActivity {
|
|||||||
if (historyState.getDisplayState().isValid() && StringUtils.isEmpty(historyState.getDisplayState().getEditorState().getText())) {
|
if (historyState.getDisplayState().isValid() && StringUtils.isEmpty(historyState.getDisplayState().getEditorState().getText())) {
|
||||||
menuItems.remove(HistoryItemMenuItem.copy_result);
|
menuItems.remove(HistoryItemMenuItem.copy_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
final AMenu<HistoryItemMenuItem> historyItemMenu = new MenuImpl<HistoryItemMenuItem>(menuItems);
|
final AMenu<HistoryItemMenuItem> historyItemMenu = new MenuImpl<HistoryItemMenuItem>(menuItems);
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
final AlertDialog.Builder menuDialogBuilder = new AlertDialog.Builder(context);
|
||||||
builder.setItems(historyItemMenu.getMenuCaptions(), new DialogInterface.OnClickListener() {
|
menuDialogBuilder.setItems(historyItemMenu.getMenuCaptions(), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int item) {
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
final AMenuItem<HistoryItemMenuData> historyItemMenuItem = historyItemMenu.itemAt(item);
|
final AMenuItem<HistoryItemMenuData> historyItemMenuItem = historyItemMenu.itemAt(item);
|
||||||
if (historyItemMenuItem != null) {
|
if (historyItemMenuItem != null) {
|
||||||
@ -116,12 +115,31 @@ public class CalculatorHistoryActivity extends ListActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.create().show();
|
menuDialogBuilder.create().show();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
final List<CalculatorHistoryState> historyList = getHistoryList();
|
||||||
|
try {
|
||||||
|
this.adapter.setNotifyOnChange(false);
|
||||||
|
this.adapter.clear();
|
||||||
|
for (CalculatorHistoryState historyState : historyList) {
|
||||||
|
this.adapter.add(historyState);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
this.adapter.setNotifyOnChange(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isAlreadySaved(@NotNull CalculatorHistoryState historyState) {
|
public static boolean isAlreadySaved(@NotNull CalculatorHistoryState historyState) {
|
||||||
assert !historyState.isSaved();
|
assert !historyState.isSaved();
|
||||||
|
|
||||||
@ -145,7 +163,7 @@ public class CalculatorHistoryActivity extends ListActivity {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void useHistoryItem(@NotNull final CalculatorHistoryState historyState, @NotNull CalculatorHistoryActivity activity) {
|
public static void useHistoryItem(@NotNull final CalculatorHistoryState historyState, @NotNull AbstractHistoryActivity activity) {
|
||||||
|
|
||||||
CalculatorModel.instance.doTextOperation(new CalculatorModel.TextOperation() {
|
CalculatorModel.instance.doTextOperation(new CalculatorModel.TextOperation() {
|
||||||
@Override
|
@Override
|
||||||
@ -161,9 +179,9 @@ public class CalculatorHistoryActivity extends ListActivity {
|
|||||||
activity.finish();
|
activity.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<CalculatorHistoryState> getHistoryList() {
|
@NotNull
|
||||||
final List<CalculatorHistoryState> calculatorHistoryStates = new ArrayList<CalculatorHistoryState>(CalculatorHistory.instance.getStates());
|
private List<CalculatorHistoryState> getHistoryList() {
|
||||||
calculatorHistoryStates.addAll(CalculatorHistory.instance.getSavedHistory());
|
final List<CalculatorHistoryState> calculatorHistoryStates = getHistoryItems();
|
||||||
|
|
||||||
Collections.sort(calculatorHistoryStates, COMPARATOR);
|
Collections.sort(calculatorHistoryStates, COMPARATOR);
|
||||||
|
|
||||||
@ -180,54 +198,8 @@ public class CalculatorHistoryActivity extends ListActivity {
|
|||||||
return calculatorHistoryStates;
|
return calculatorHistoryStates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HistoryArrayAdapter extends ArrayAdapter<CalculatorHistoryState> {
|
@NotNull
|
||||||
|
protected abstract List<CalculatorHistoryState> getHistoryItems();
|
||||||
private HistoryArrayAdapter(Context context, int resource, int textViewResourceId, @NotNull List<CalculatorHistoryState> historyList) {
|
|
||||||
super(context, resource, textViewResourceId, historyList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
|
||||||
final ViewGroup result = (ViewGroup) super.getView(position, convertView, parent);
|
|
||||||
|
|
||||||
final CalculatorHistoryState state = getItem(position);
|
|
||||||
|
|
||||||
final TextView time = (TextView) result.findViewById(R.id.history_time);
|
|
||||||
time.setText(new SimpleDateFormat().format(new Date(state.getTime())));
|
|
||||||
|
|
||||||
final TextView editor = (TextView) result.findViewById(R.id.history_item);
|
|
||||||
editor.setText(getHistoryText(state));
|
|
||||||
|
|
||||||
final TextView commentView = (TextView) result.findViewById(R.id.history_item_comment);
|
|
||||||
final String comment = state.getComment();
|
|
||||||
if (!StringUtils.isEmpty(comment)) {
|
|
||||||
commentView.setText(comment);
|
|
||||||
} else {
|
|
||||||
commentView.setText("");
|
|
||||||
}
|
|
||||||
|
|
||||||
final TextView status = (TextView) result.findViewById(R.id.history_item_status);
|
|
||||||
if (state.isSaved()) {
|
|
||||||
status.setText(ResourceCache.instance.getCaption("c_history_item_saved"));
|
|
||||||
} else {
|
|
||||||
if ( isAlreadySaved(state) ) {
|
|
||||||
status.setText(ResourceCache.instance.getCaption("c_history_item_already_saved"));
|
|
||||||
} else {
|
|
||||||
status.setText(ResourceCache.instance.getCaption("c_history_item_not_saved"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notifyDataSetChanged() {
|
|
||||||
this.setNotifyOnChange(false);
|
|
||||||
this.sort(COMPARATOR);
|
|
||||||
this.setNotifyOnChange(true);
|
|
||||||
super.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String getHistoryText(@NotNull CalculatorHistoryState state) {
|
public static String getHistoryText(@NotNull CalculatorHistoryState state) {
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.solovyev.android.calculator.history;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.TabActivity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.TabHost;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.solovyev.android.calculator.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: serso
|
||||||
|
* Date: 12/18/11
|
||||||
|
* Time: 7:37 PM
|
||||||
|
*/
|
||||||
|
public class CalculatorHistoryActivity extends TabActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setContentView(R.layout.history_tabs);
|
||||||
|
|
||||||
|
final TabHost tabHost = getTabHost();
|
||||||
|
|
||||||
|
createTab(tabHost, "saved_history", R.string.c_saved_history, SavedHistoryActivityTab.class);
|
||||||
|
createTab(tabHost, "history", R.string.c_history, HistoryActivityTab.class);
|
||||||
|
|
||||||
|
tabHost.setCurrentTab(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createTab(@NotNull TabHost tabHost,
|
||||||
|
@NotNull String tabId,
|
||||||
|
int tabCaptionId,
|
||||||
|
@NotNull Class<? extends Activity> activityClass) {
|
||||||
|
|
||||||
|
TabHost.TabSpec spec;
|
||||||
|
|
||||||
|
final Intent intent = new Intent().setClass(this, activityClass);
|
||||||
|
|
||||||
|
// Initialize a TabSpec for each tab and add it to the TabHost
|
||||||
|
spec = tabHost.newTabSpec(tabId).setIndicator(getString(tabCaptionId)).setContent(intent);
|
||||||
|
|
||||||
|
tabHost.addTab(spec);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.solovyev.android.calculator.history;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: serso
|
||||||
|
* Date: 12/18/11
|
||||||
|
* Time: 7:39 PM
|
||||||
|
*/
|
||||||
|
public class HistoryActivityTab extends AbstractHistoryActivity {
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
protected List<CalculatorHistoryState> getHistoryItems() {
|
||||||
|
return new ArrayList<CalculatorHistoryState>(CalculatorHistory.instance.getStates());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.solovyev.android.calculator.history;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.solovyev.android.calculator.R;
|
||||||
|
import org.solovyev.android.view.prefs.ResourceCache;
|
||||||
|
import org.solovyev.common.utils.StringUtils;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: serso
|
||||||
|
* Date: 12/18/11
|
||||||
|
* Time: 7:39 PM
|
||||||
|
*/
|
||||||
|
public class HistoryArrayAdapter extends ArrayAdapter<CalculatorHistoryState> {
|
||||||
|
|
||||||
|
HistoryArrayAdapter(Context context, int resource, int textViewResourceId, @NotNull List<CalculatorHistoryState> historyList) {
|
||||||
|
super(context, resource, textViewResourceId, historyList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
final ViewGroup result = (ViewGroup) super.getView(position, convertView, parent);
|
||||||
|
|
||||||
|
final CalculatorHistoryState state = getItem(position);
|
||||||
|
|
||||||
|
final TextView time = (TextView) result.findViewById(R.id.history_time);
|
||||||
|
time.setText(new SimpleDateFormat().format(new Date(state.getTime())));
|
||||||
|
|
||||||
|
final TextView editor = (TextView) result.findViewById(R.id.history_item);
|
||||||
|
editor.setText(AbstractHistoryActivity.getHistoryText(state));
|
||||||
|
|
||||||
|
final TextView commentView = (TextView) result.findViewById(R.id.history_item_comment);
|
||||||
|
final String comment = state.getComment();
|
||||||
|
if (!StringUtils.isEmpty(comment)) {
|
||||||
|
commentView.setText(comment);
|
||||||
|
} else {
|
||||||
|
commentView.setText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
final TextView status = (TextView) result.findViewById(R.id.history_item_status);
|
||||||
|
if (state.isSaved()) {
|
||||||
|
status.setText(ResourceCache.instance.getCaption("c_history_item_saved"));
|
||||||
|
} else {
|
||||||
|
if ( AbstractHistoryActivity.isAlreadySaved(state) ) {
|
||||||
|
status.setText(ResourceCache.instance.getCaption("c_history_item_already_saved"));
|
||||||
|
} else {
|
||||||
|
status.setText(ResourceCache.instance.getCaption("c_history_item_not_saved"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyDataSetChanged() {
|
||||||
|
this.setNotifyOnChange(false);
|
||||||
|
this.sort(AbstractHistoryActivity.COMPARATOR);
|
||||||
|
this.setNotifyOnChange(true);
|
||||||
|
super.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,6 @@
|
|||||||
package org.solovyev.android.calculator.history;
|
package org.solovyev.android.calculator.history;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.solovyev.android.calculator.CalculatorHistoryActivity;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
@ -17,12 +16,12 @@ import org.solovyev.android.calculator.CalculatorHistoryActivity;
|
|||||||
public class HistoryItemMenuData {
|
public class HistoryItemMenuData {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final CalculatorHistoryActivity.HistoryArrayAdapter adapter;
|
private final HistoryArrayAdapter adapter;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final CalculatorHistoryState historyState;
|
private final CalculatorHistoryState historyState;
|
||||||
|
|
||||||
public HistoryItemMenuData(@NotNull CalculatorHistoryState historyState, CalculatorHistoryActivity.HistoryArrayAdapter adapter) {
|
public HistoryItemMenuData(@NotNull CalculatorHistoryState historyState, HistoryArrayAdapter adapter) {
|
||||||
this.historyState = historyState;
|
this.historyState = historyState;
|
||||||
this.adapter = adapter;
|
this.adapter = adapter;
|
||||||
}
|
}
|
||||||
@ -33,7 +32,7 @@ public class HistoryItemMenuData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public CalculatorHistoryActivity.HistoryArrayAdapter getAdapter() {
|
public HistoryArrayAdapter getAdapter() {
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ 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 org.jetbrains.annotations.NotNull;
|
||||||
import org.solovyev.android.calculator.CalculatorHistoryActivity;
|
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
import org.solovyev.android.view.AMenuItem;
|
import org.solovyev.android.view.AMenuItem;
|
||||||
import org.solovyev.android.view.prefs.ResourceCache;
|
import org.solovyev.android.view.prefs.ResourceCache;
|
||||||
@ -31,16 +30,18 @@ import org.solovyev.common.utils.StringUtils;
|
|||||||
* Time: 3:09 PM
|
* Time: 3:09 PM
|
||||||
*/
|
*/
|
||||||
public enum HistoryItemMenuItem implements AMenuItem<HistoryItemMenuData> {
|
public enum HistoryItemMenuItem implements AMenuItem<HistoryItemMenuData> {
|
||||||
|
|
||||||
use("c_use_expression") {
|
use("c_use_expression") {
|
||||||
@Override
|
@Override
|
||||||
public void doAction(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
public void doAction(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
||||||
if (context instanceof CalculatorHistoryActivity) {
|
if (context instanceof AbstractHistoryActivity) {
|
||||||
CalculatorHistoryActivity.useHistoryItem(data.getHistoryState(), (CalculatorHistoryActivity) context);
|
AbstractHistoryActivity.useHistoryItem(data.getHistoryState(), (AbstractHistoryActivity) context);
|
||||||
} else {
|
} else {
|
||||||
Log.e(HistoryItemMenuItem.class.getName(), CalculatorHistoryActivity.class + " must be passed as context!");
|
Log.e(HistoryItemMenuItem.class.getName(), CalculatorHistoryActivity.class + " must be passed as context!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
copy_expression("c_copy_expression") {
|
copy_expression("c_copy_expression") {
|
||||||
@Override
|
@Override
|
||||||
public void doAction(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
public void doAction(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
||||||
@ -53,6 +54,7 @@ public enum HistoryItemMenuItem implements AMenuItem<HistoryItemMenuData> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
copy_result("c_copy_result") {
|
copy_result("c_copy_result") {
|
||||||
@Override
|
@Override
|
||||||
public void doAction(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
public void doAction(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
||||||
@ -65,6 +67,7 @@ public enum HistoryItemMenuItem implements AMenuItem<HistoryItemMenuData> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
save("c_save") {
|
save("c_save") {
|
||||||
@Override
|
@Override
|
||||||
public void doAction(@NotNull final HistoryItemMenuData data, @NotNull final Context context) {
|
public void doAction(@NotNull final HistoryItemMenuData data, @NotNull final Context context) {
|
||||||
@ -76,6 +79,7 @@ public enum HistoryItemMenuItem implements AMenuItem<HistoryItemMenuData> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
edit("c_edit") {
|
edit("c_edit") {
|
||||||
@Override
|
@Override
|
||||||
public void doAction(@NotNull final HistoryItemMenuData data, @NotNull final Context context) {
|
public void doAction(@NotNull final HistoryItemMenuData data, @NotNull final Context context) {
|
||||||
@ -87,6 +91,7 @@ public enum HistoryItemMenuItem implements AMenuItem<HistoryItemMenuData> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
remove("c_remove") {
|
remove("c_remove") {
|
||||||
@Override
|
@Override
|
||||||
public void doAction(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
public void doAction(@NotNull HistoryItemMenuData data, @NotNull Context context) {
|
||||||
@ -106,7 +111,7 @@ public enum HistoryItemMenuItem implements AMenuItem<HistoryItemMenuData> {
|
|||||||
final LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
final LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
final View editView = layoutInflater.inflate(R.layout.history_edit, null);
|
final View editView = layoutInflater.inflate(R.layout.history_edit, null);
|
||||||
final TextView historyExpression = (TextView)editView.findViewById(R.id.history_edit_expression);
|
final TextView historyExpression = (TextView)editView.findViewById(R.id.history_edit_expression);
|
||||||
historyExpression.setText(CalculatorHistoryActivity.getHistoryText(historyState));
|
historyExpression.setText(AbstractHistoryActivity.getHistoryText(historyState));
|
||||||
|
|
||||||
final EditText comment = (EditText)editView.findViewById(R.id.history_edit_comment);
|
final EditText comment = (EditText)editView.findViewById(R.id.history_edit_comment);
|
||||||
comment.setText(historyState.getComment());
|
comment.setText(historyState.getComment());
|
||||||
@ -122,7 +127,8 @@ public enum HistoryItemMenuItem implements AMenuItem<HistoryItemMenuData> {
|
|||||||
final CalculatorHistoryState savedHistoryItem = CalculatorHistory.instance.addSavedState(historyState);
|
final CalculatorHistoryState savedHistoryItem = CalculatorHistory.instance.addSavedState(historyState);
|
||||||
savedHistoryItem.setComment(comment.getText().toString());
|
savedHistoryItem.setComment(comment.getText().toString());
|
||||||
CalculatorHistory.instance.save(context);
|
CalculatorHistory.instance.save(context);
|
||||||
data.getAdapter().add(savedHistoryItem);
|
// we don't need to add element to the adapter as adapter of another activity must be updated and not this
|
||||||
|
//data.getAdapter().add(savedHistoryItem);
|
||||||
} else {
|
} else {
|
||||||
historyState.setComment(comment.getText().toString());
|
historyState.setComment(comment.getText().toString());
|
||||||
CalculatorHistory.instance.save(context);
|
CalculatorHistory.instance.save(context);
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.solovyev.android.calculator.history;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: serso
|
||||||
|
* Date: 12/18/11
|
||||||
|
* Time: 7:40 PM
|
||||||
|
*/
|
||||||
|
public class SavedHistoryActivityTab extends AbstractHistoryActivity {
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
protected List<CalculatorHistoryState> getHistoryItems() {
|
||||||
|
return new ArrayList<CalculatorHistoryState>(CalculatorHistory.instance.getSavedHistory());
|
||||||
|
}
|
||||||
|
}
|
@ -136,26 +136,22 @@ public class DirectionDragButton extends DragButton {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Point2d getTextPosition(@NotNull Paint paint, @NotNull Paint basePaint, @NotNull CharSequence text, CharSequence baseText, int w, int h) {
|
public Point2d getTextPosition(@NotNull Paint paint, @NotNull Paint basePaint, @NotNull CharSequence text, CharSequence baseText, int w, int h) {
|
||||||
final Point2d result = new Point2d();
|
return getLeftRightTextPosition(paint, basePaint, text, baseText, w, h, true);
|
||||||
|
|
||||||
float width = paint.measureText(" ");
|
|
||||||
result.setX(width);
|
|
||||||
|
|
||||||
float selfHeight = paint.ascent() + paint.descent();
|
|
||||||
|
|
||||||
basePaint.measureText(StringUtils.getNotEmpty(baseText, "|"));
|
|
||||||
|
|
||||||
result.setY(h / 2 - selfHeight / 2);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}/*,
|
},
|
||||||
|
|
||||||
right(DragDirection.right, 1) {
|
right(DragDirection.right, 1) {
|
||||||
@Override
|
@Override
|
||||||
public int getAttributeId() {
|
public int getAttributeId() {
|
||||||
return 0;
|
return R.styleable.DragButton_textRight;
|
||||||
}
|
}
|
||||||
}*/;
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Point2d getTextPosition(@NotNull Paint paint, @NotNull Paint basePaint, @NotNull CharSequence text, CharSequence baseText, int w, int h) {
|
||||||
|
return getLeftRightTextPosition(paint, basePaint, text, baseText, w, h, false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final DragDirection dragDirection;
|
private final DragDirection dragDirection;
|
||||||
@ -176,6 +172,27 @@ public class DirectionDragButton extends DragButton {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public abstract Point2d getTextPosition(@NotNull Paint paint, @NotNull Paint basePaint, @NotNull CharSequence text, CharSequence baseText, int w, int h);
|
public abstract Point2d getTextPosition(@NotNull Paint paint, @NotNull Paint basePaint, @NotNull CharSequence text, CharSequence baseText, int w, int h);
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static Point2d getLeftRightTextPosition(@NotNull Paint paint, @NotNull Paint basePaint, CharSequence text, @NotNull CharSequence baseText, int w, int h, boolean left) {
|
||||||
|
final Point2d result = new Point2d();
|
||||||
|
|
||||||
|
if (left) {
|
||||||
|
float width = paint.measureText(" ");
|
||||||
|
result.setX(width);
|
||||||
|
} else {
|
||||||
|
float width = paint.measureText(text.toString() + " ");
|
||||||
|
result.setX(w - width);
|
||||||
|
}
|
||||||
|
|
||||||
|
float selfHeight = paint.ascent() + paint.descent();
|
||||||
|
|
||||||
|
basePaint.measureText(StringUtils.getNotEmpty(baseText, "|"));
|
||||||
|
|
||||||
|
result.setY(h / 2 - selfHeight / 2);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static Point2d getUpDownTextPosition(@NotNull Paint paint, @NotNull Paint basePaint, @NotNull CharSequence text, CharSequence baseText, float direction, int w, int h) {
|
private static Point2d getUpDownTextPosition(@NotNull Paint paint, @NotNull Paint basePaint, @NotNull CharSequence text, CharSequence baseText, float direction, int w, int h) {
|
||||||
final Point2d result = new Point2d();
|
final Point2d result = new Point2d();
|
||||||
|
@ -12,10 +12,7 @@ import android.view.MotionEvent;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
import org.solovyev.common.NumberIntervalMapper;
|
import org.solovyev.common.NumberIntervalMapper;
|
||||||
import org.solovyev.common.utils.Interval;
|
import org.solovyev.common.utils.*;
|
||||||
import org.solovyev.common.utils.Mapper;
|
|
||||||
import org.solovyev.common.utils.MathUtils;
|
|
||||||
import org.solovyev.common.utils.Point2d;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -53,7 +50,12 @@ public class SimpleOnDragListener implements OnDragListener, DragPreferencesChan
|
|||||||
final Point2d endPoint = new Point2d(motionEvent.getX(), motionEvent.getY());
|
final Point2d endPoint = new Point2d(motionEvent.getX(), motionEvent.getY());
|
||||||
|
|
||||||
final float distance = MathUtils.getDistance(startPoint, endPoint);
|
final float distance = MathUtils.getDistance(startPoint, endPoint);
|
||||||
final double angle = Math.toDegrees(MathUtils.getAngle(startPoint, MathUtils.sum(startPoint, axis), endPoint));
|
|
||||||
|
final MutableObject<Boolean> right = new MutableObject<Boolean>();
|
||||||
|
final double angle = Math.toDegrees(MathUtils.getAngle(startPoint, MathUtils.sum(startPoint, axis), endPoint, right));
|
||||||
|
Log.d(String.valueOf(dragButton.getId()), "Angle: " + angle);
|
||||||
|
Log.d(String.valueOf(dragButton.getId()), "Is right?: " + right.getObject());
|
||||||
|
|
||||||
final double duration = motionEvent.getEventTime() - motionEvent.getDownTime();
|
final double duration = motionEvent.getEventTime() - motionEvent.getDownTime();
|
||||||
|
|
||||||
final Preference distancePreferences = preferences.getPreferencesMap().get(PreferenceType.distance);
|
final Preference distancePreferences = preferences.getPreferencesMap().get(PreferenceType.distance);
|
||||||
@ -66,23 +68,21 @@ public class SimpleOnDragListener implements OnDragListener, DragPreferencesChan
|
|||||||
Log.d(String.valueOf(dragButton.getId()), "Trying direction interval: " + directionEntry.getValue().getInterval());
|
Log.d(String.valueOf(dragButton.getId()), "Trying direction interval: " + directionEntry.getValue().getInterval());
|
||||||
|
|
||||||
if (isInInterval(directionEntry.getValue().getInterval(), distance)) {
|
if (isInInterval(directionEntry.getValue().getInterval(), distance)) {
|
||||||
for (Map.Entry<DragDirection, DragPreference> angleEntry : anglePreferences.getDirectionPreferences().entrySet()) {
|
final DragPreference anglePreference = anglePreferences.getDirectionPreferences().get(directionEntry.getKey());
|
||||||
|
|
||||||
Log.d(String.valueOf(dragButton.getId()), "Trying angle interval: " + angleEntry.getValue().getInterval());
|
Log.d(String.valueOf(dragButton.getId()), "Trying angle interval: " + anglePreference.getInterval());
|
||||||
|
|
||||||
if (isInInterval(angleEntry.getValue().getInterval(), (float) angle)) {
|
if (directionEntry.getKey() == DragDirection.left && right.getObject()) {
|
||||||
|
} else if (directionEntry.getKey() == DragDirection.right && !right.getObject()) {
|
||||||
Log.d(String.valueOf(dragButton.getId()), "MATCH! Direction: " + angleEntry.getKey());
|
} else {
|
||||||
|
if (isInInterval(anglePreference.getInterval(), (float) angle)) {
|
||||||
direction = angleEntry.getKey();
|
direction = directionEntry.getKey();
|
||||||
|
Log.d(String.valueOf(dragButton.getId()), "MATCH! Direction: " + direction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direction != null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direction != null) {
|
if (direction != null) {
|
||||||
@ -116,7 +116,9 @@ public class SimpleOnDragListener implements OnDragListener, DragPreferencesChan
|
|||||||
|
|
||||||
Log.d(String.valueOf(dragButton.getId()), "Start point: " + startPoint + ", End point: " + endPoint);
|
Log.d(String.valueOf(dragButton.getId()), "Start point: " + startPoint + ", End point: " + endPoint);
|
||||||
Log.d(String.valueOf(dragButton.getId()), "Distance: " + MathUtils.getDistance(startPoint, endPoint));
|
Log.d(String.valueOf(dragButton.getId()), "Distance: " + MathUtils.getDistance(startPoint, endPoint));
|
||||||
Log.d(String.valueOf(dragButton.getId()), "Angle: " + Math.toDegrees(MathUtils.getAngle(startPoint, MathUtils.sum(startPoint, axis), endPoint)));
|
final MutableObject<Boolean> right = new MutableObject<Boolean>();
|
||||||
|
Log.d(String.valueOf(dragButton.getId()), "Angle: " + Math.toDegrees(MathUtils.getAngle(startPoint, MathUtils.sum(startPoint, axis), endPoint, right)));
|
||||||
|
Log.d(String.valueOf(dragButton.getId()), "Is right angle? " + right);
|
||||||
Log.d(String.valueOf(dragButton.getId()), "Axis: " + axis + " Vector: " + MathUtils.subtract(endPoint, startPoint));
|
Log.d(String.valueOf(dragButton.getId()), "Axis: " + axis + " Vector: " + MathUtils.subtract(endPoint, startPoint));
|
||||||
Log.d(String.valueOf(dragButton.getId()), "Total time: " + (motionEvent.getEventTime() - motionEvent.getDownTime()) + " ms");
|
Log.d(String.valueOf(dragButton.getId()), "Total time: " + (motionEvent.getEventTime() - motionEvent.getDownTime()) + " ms");
|
||||||
}
|
}
|
||||||
@ -209,11 +211,11 @@ public class SimpleOnDragListener implements OnDragListener, DragPreferencesChan
|
|||||||
interval.setLeftBorder(180f - rightBorder);
|
interval.setLeftBorder(180f - rightBorder);
|
||||||
interval.setRightBorder(180f - leftBorder);
|
interval.setRightBorder(180f - leftBorder);
|
||||||
} else if (dragDirection == DragDirection.left ) {
|
} else if (dragDirection == DragDirection.left ) {
|
||||||
interval.setLeftBorder(90f - rightBorder / 2);
|
interval.setLeftBorder(90f - rightBorder);
|
||||||
interval.setRightBorder(90f + rightBorder / 2);
|
interval.setRightBorder(90f + rightBorder);
|
||||||
} else if ( dragDirection == DragDirection.right ) {
|
} else if ( dragDirection == DragDirection.right ) {
|
||||||
interval.setLeftBorder(180f + 90f - rightBorder / 2);
|
interval.setLeftBorder(90f - rightBorder);
|
||||||
interval.setRightBorder(180f + 90f + rightBorder / 2);
|
interval.setRightBorder(90f + rightBorder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user