changes
Before Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 785 B After Width: | Height: | Size: 785 B |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 807 B After Width: | Height: | Size: 807 B |
Before Width: | Height: | Size: 630 B After Width: | Height: | Size: 630 B |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 3.6 KiB |
BIN
calculatorpp/res/drawable-mdpi/kb_delete.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
calculatorpp/res/drawable-mdpi/kb_heart.png
Normal file
After Width: | Height: | Size: 785 B |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 9.0 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
@ -1,113 +1,113 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:layout_width="fill_parent"
|
||||
a:layout_height="fill_parent"
|
||||
a:id="@+id/main_layout"
|
||||
a:orientation="vertical"
|
||||
a:layout_gravity="center"
|
||||
a:background="#ff000000">
|
||||
|
||||
<include layout="@layout/calc_editor"/>
|
||||
|
||||
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
||||
|
||||
<org.solovyev.android.view.drag.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/leftButton"
|
||||
c:textUp="◀◀"
|
||||
a:text="◀"
|
||||
c:directionTextScale="0.5"
|
||||
style="?controlButtonStyle"
|
||||
a:onClick="moveLeftButtonClickHandler"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_weight="1"/>
|
||||
|
||||
|
||||
<org.solovyev.android.view.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/eraseButton"
|
||||
a:drawableTop="@drawable/sym_keyboard_delete"
|
||||
style="?controlImageButtonStyle"
|
||||
a:onClick="eraseButtonClickHandler"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_weight="1"/>
|
||||
|
||||
|
||||
<include layout="@layout/calc_display"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_weight="4"/>
|
||||
|
||||
<org.solovyev.android.calculator.view.NumeralBasesButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/clearButton"
|
||||
c:textUp="dec"
|
||||
a:text="@string/c_clear"
|
||||
c:textDown="bin"
|
||||
c:textLeft="hex"
|
||||
a:textStyle="bold"
|
||||
style="?controlImageButtonStyle"
|
||||
a:onClick="clearButtonClickHandler"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_weight="1"/>
|
||||
|
||||
<org.solovyev.android.view.drag.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/rightButton"
|
||||
c:textUp="▶▶"
|
||||
a:text="▶"
|
||||
c:directionTextScale="0.5"
|
||||
style="?controlButtonStyle"
|
||||
a:onClick="moveRightButtonClickHandler"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_vars_button"/>
|
||||
<include layout="@layout/calc_copy_button"/>
|
||||
<include layout="@layout/calc_one_digit_button"/>
|
||||
<include layout="@layout/calc_two_digit_button"/>
|
||||
<include layout="@layout/calc_three_digit_button"/>
|
||||
<include layout="@layout/calc_multiplication_button"/>
|
||||
<include layout="@layout/calc_division_button"/>
|
||||
<include layout="@layout/calc_equals_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_functions_button"/>
|
||||
<include layout="@layout/calc_paste_button"/>
|
||||
<include layout="@layout/calc_four_digit_button"/>
|
||||
<include layout="@layout/calc_five_digit_button"/>
|
||||
<include layout="@layout/calc_six_digit_button"/>
|
||||
<include layout="@layout/calc_plus_button"/>
|
||||
<include layout="@layout/calc_subtraction_button"/>
|
||||
<include layout="@layout/calc_round_brackets_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_operators_button"/>
|
||||
<include layout="@layout/calc_donate_button"/>
|
||||
<include layout="@layout/calc_seven_digit_button"/>
|
||||
<include layout="@layout/calc_eight_digit_button"/>
|
||||
<include layout="@layout/calc_nine_digit_button"/>
|
||||
<include layout="@layout/calc_zero_digit_button"/>
|
||||
<include layout="@layout/calc_dot_button"/>
|
||||
<include layout="@layout/calc_history_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:layout_width="fill_parent"
|
||||
a:layout_height="fill_parent"
|
||||
a:id="@+id/main_layout"
|
||||
a:orientation="vertical"
|
||||
a:layout_gravity="center"
|
||||
a:background="#ff000000">
|
||||
|
||||
<include layout="@layout/calc_editor"/>
|
||||
|
||||
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
||||
|
||||
<org.solovyev.android.view.drag.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/leftButton"
|
||||
c:textUp="◀◀"
|
||||
a:text="◀"
|
||||
c:directionTextScale="0.5"
|
||||
style="?controlButtonStyle"
|
||||
a:onClick="moveLeftButtonClickHandler"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_weight="1"/>
|
||||
|
||||
|
||||
<org.solovyev.android.view.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/eraseButton"
|
||||
a:drawableTop="@drawable/kb_delete"
|
||||
style="?controlImageButtonStyle"
|
||||
a:onClick="eraseButtonClickHandler"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_weight="1"/>
|
||||
|
||||
|
||||
<include layout="@layout/calc_display"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_weight="4"/>
|
||||
|
||||
<org.solovyev.android.calculator.view.NumeralBasesButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/clearButton"
|
||||
c:textUp="dec"
|
||||
a:text="@string/c_clear"
|
||||
c:textDown="bin"
|
||||
c:textLeft="hex"
|
||||
a:textStyle="bold"
|
||||
style="?controlImageButtonStyle"
|
||||
a:onClick="clearButtonClickHandler"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_weight="1"/>
|
||||
|
||||
<org.solovyev.android.view.drag.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/rightButton"
|
||||
c:textUp="▶▶"
|
||||
a:text="▶"
|
||||
c:directionTextScale="0.5"
|
||||
style="?controlButtonStyle"
|
||||
a:onClick="moveRightButtonClickHandler"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="fill_parent"
|
||||
a:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_vars_button"/>
|
||||
<include layout="@layout/calc_copy_button"/>
|
||||
<include layout="@layout/calc_one_digit_button"/>
|
||||
<include layout="@layout/calc_two_digit_button"/>
|
||||
<include layout="@layout/calc_three_digit_button"/>
|
||||
<include layout="@layout/calc_multiplication_button"/>
|
||||
<include layout="@layout/calc_division_button"/>
|
||||
<include layout="@layout/calc_equals_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_functions_button"/>
|
||||
<include layout="@layout/calc_paste_button"/>
|
||||
<include layout="@layout/calc_four_digit_button"/>
|
||||
<include layout="@layout/calc_five_digit_button"/>
|
||||
<include layout="@layout/calc_six_digit_button"/>
|
||||
<include layout="@layout/calc_plus_button"/>
|
||||
<include layout="@layout/calc_subtraction_button"/>
|
||||
<include layout="@layout/calc_round_brackets_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1" a:layout_width="fill_parent" a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_operators_button"/>
|
||||
<include layout="@layout/calc_donate_button"/>
|
||||
<include layout="@layout/calc_seven_digit_button"/>
|
||||
<include layout="@layout/calc_eight_digit_button"/>
|
||||
<include layout="@layout/calc_nine_digit_button"/>
|
||||
<include layout="@layout/calc_zero_digit_button"/>
|
||||
<include layout="@layout/calc_dot_button"/>
|
||||
<include layout="@layout/calc_history_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -1,53 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent"
|
||||
a:orientation="vertical">
|
||||
|
||||
<LinearLayout a:layout_weight="1"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_vars_button"/>
|
||||
<include layout="@layout/calc_copy_button"/>
|
||||
<include layout="@layout/calc_seven_digit_button"/>
|
||||
<include layout="@layout/calc_eight_digit_button"/>
|
||||
<include layout="@layout/calc_nine_digit_button"/>
|
||||
<include layout="@layout/calc_multiplication_button"/>
|
||||
<include layout="@layout/calc_division_button"/>
|
||||
<include layout="@layout/calc_equals_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_functions_button"/>
|
||||
<include layout="@layout/calc_paste_button"/>
|
||||
<include layout="@layout/calc_four_digit_button"/>
|
||||
<include layout="@layout/calc_five_digit_button"/>
|
||||
<include layout="@layout/calc_six_digit_button"/>
|
||||
<include layout="@layout/calc_plus_button"/>
|
||||
<include layout="@layout/calc_subtraction_button"/>
|
||||
<include layout="@layout/calc_round_brackets_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_operators_button"/>
|
||||
<include layout="@layout/calc_donate_button"/>
|
||||
<include layout="@layout/calc_one_digit_button"/>
|
||||
<include layout="@layout/calc_two_digit_button"/>
|
||||
<include layout="@layout/calc_three_digit_button"/>
|
||||
<include layout="@layout/calc_zero_digit_button"/>
|
||||
<include layout="@layout/calc_dot_button"/>
|
||||
<include layout="@layout/calc_history_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent"
|
||||
a:orientation="vertical">
|
||||
|
||||
<LinearLayout a:layout_weight="1"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_left_button"/>
|
||||
<include layout="@layout/calc_erase_button"/>
|
||||
<include layout="@layout/calc_empty_button"/>
|
||||
<include layout="@layout/calc_empty_button"/>
|
||||
<include layout="@layout/calc_empty_button"/>
|
||||
<include layout="@layout/calc_empty_button"/>
|
||||
<include layout="@layout/calc_clear_button"/>
|
||||
<include layout="@layout/calc_right_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_vars_button"/>
|
||||
<include layout="@layout/calc_copy_button"/>
|
||||
<include layout="@layout/calc_seven_digit_button"/>
|
||||
<include layout="@layout/calc_eight_digit_button"/>
|
||||
<include layout="@layout/calc_nine_digit_button"/>
|
||||
<include layout="@layout/calc_multiplication_button"/>
|
||||
<include layout="@layout/calc_division_button"/>
|
||||
<include layout="@layout/calc_equals_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_functions_button"/>
|
||||
<include layout="@layout/calc_paste_button"/>
|
||||
<include layout="@layout/calc_four_digit_button"/>
|
||||
<include layout="@layout/calc_five_digit_button"/>
|
||||
<include layout="@layout/calc_six_digit_button"/>
|
||||
<include layout="@layout/calc_plus_button"/>
|
||||
<include layout="@layout/calc_subtraction_button"/>
|
||||
<include layout="@layout/calc_round_brackets_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout a:layout_weight="1"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="0dp">
|
||||
|
||||
<include layout="@layout/calc_operators_button"/>
|
||||
<include layout="@layout/calc_donate_button"/>
|
||||
<include layout="@layout/calc_one_digit_button"/>
|
||||
<include layout="@layout/calc_two_digit_button"/>
|
||||
<include layout="@layout/calc_three_digit_button"/>
|
||||
<include layout="@layout/calc_zero_digit_button"/>
|
||||
<include layout="@layout/calc_dot_button"/>
|
||||
<include layout="@layout/calc_history_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -1,14 +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.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/pasteButton"
|
||||
a:drawableTop="@drawable/copy"
|
||||
style="?controlImageButtonStyle"
|
||||
<?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.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/pasteButton"
|
||||
a:drawableTop="@drawable/kb_copy"
|
||||
style="?controlImageButtonStyle"
|
||||
a:onClick="copyButtonClickHandler"/>
|
@ -1,13 +1,13 @@
|
||||
<?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.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:id="@+id/pasteButton"
|
||||
a:drawableTop="@drawable/heart2"
|
||||
style="?controlImageButtonStyle"
|
||||
<?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.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:id="@+id/pasteButton"
|
||||
a:drawableTop="@drawable/kb_heart"
|
||||
style="?controlImageButtonStyle"
|
||||
a:onClick="donateButtonClickHandler"/>
|
@ -1,14 +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.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/eraseButton"
|
||||
a:drawableTop="@drawable/sym_keyboard_delete"
|
||||
style="?controlImageButtonStyle"
|
||||
<?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.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/eraseButton"
|
||||
a:drawableTop="@drawable/kb_delete"
|
||||
style="?controlImageButtonStyle"
|
||||
a:onClick="eraseButtonClickHandler"/>
|
@ -1,14 +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.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/pasteButton"
|
||||
a:drawableTop="@drawable/paste"
|
||||
style="?controlImageButtonStyle"
|
||||
<?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.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||
a:id="@+id/pasteButton"
|
||||
a:drawableTop="@drawable/kb_paste"
|
||||
style="?controlImageButtonStyle"
|
||||
a:onClick="pasteButtonClickHandler"/>
|
@ -7,20 +7,21 @@
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:orientation="vertical"
|
||||
a:layout_width="fill_parent"
|
||||
a:layout_height="fill_parent">
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
a:paddingBottom="@dimen/pane_padding"
|
||||
a:orientation="vertical">
|
||||
|
||||
<TextView a:id="@+id/math_entity_text"
|
||||
a:layout_width="fill_parent"
|
||||
a:layout_height="fill_parent"
|
||||
style="@style/math_entity_text">
|
||||
</TextView>
|
||||
<TextView a:id="@+id/math_entity_text"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
style="@style/math_entity_text">
|
||||
</TextView>
|
||||
|
||||
<TextView a:id="@+id/math_entity_description"
|
||||
a:layout_width="fill_parent"
|
||||
a:layout_height="fill_parent"
|
||||
style="@style/math_entity_description">
|
||||
</TextView>
|
||||
<TextView a:id="@+id/math_entity_description"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
style="@style/math_entity_description">
|
||||
</TextView>
|
||||
|
||||
</LinearLayout>
|
@ -1,81 +1,81 @@
|
||||
<?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
|
||||
-->
|
||||
|
||||
<ScrollView xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
a:minWidth="200dp">
|
||||
|
||||
<LinearLayout a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
a:orientation="vertical">
|
||||
|
||||
<TextView a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
a:padding="6dp"
|
||||
style="@style/default_text_size"
|
||||
a:text="@string/c_var_name"/>
|
||||
|
||||
<EditText a:id="@+id/var_edit_name"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
style="@style/default_text_size"
|
||||
a:inputType="text"/>
|
||||
|
||||
<TextView a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
style="@style/default_text_size"
|
||||
a:padding="6dp"
|
||||
a:text="@string/c_var_value"/>
|
||||
|
||||
<EditText a:id="@+id/var_edit_value"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
style="@style/default_text_size"
|
||||
a:inputType="text"/>
|
||||
|
||||
<TextView a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
a:padding="6dp"
|
||||
style="@style/default_text_size"
|
||||
a:text="@string/c_var_description"/>
|
||||
|
||||
<EditText a:id="@+id/var_edit_description"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
style="@style/default_text_size"
|
||||
a:inputType="text"/>
|
||||
|
||||
<LinearLayout
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent">
|
||||
|
||||
<Button a:id="@+id/cancel_button"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="0dp"
|
||||
a:layout_weight="1"
|
||||
a:text="@string/c_cancel"/>
|
||||
|
||||
<Button a:id="@+id/remove_button"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="0dp"
|
||||
a:layout_weight="1"
|
||||
a:text="@string/c_remove"/>
|
||||
|
||||
<Button a:id="@+id/save_button"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="0dp"
|
||||
a:layout_weight="1"
|
||||
a:text="@string/c_save"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<?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
|
||||
-->
|
||||
|
||||
<ScrollView xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
a:minWidth="300dp">
|
||||
|
||||
<LinearLayout a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
a:orientation="vertical">
|
||||
|
||||
<TextView a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
a:padding="6dp"
|
||||
style="@style/default_text_size"
|
||||
a:text="@string/c_var_name"/>
|
||||
|
||||
<EditText a:id="@+id/var_edit_name"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
style="@style/default_text_size"
|
||||
a:inputType="text"/>
|
||||
|
||||
<TextView a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
style="@style/default_text_size"
|
||||
a:padding="6dp"
|
||||
a:text="@string/c_var_value"/>
|
||||
|
||||
<EditText a:id="@+id/var_edit_value"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
style="@style/default_text_size"
|
||||
a:inputType="text"/>
|
||||
|
||||
<TextView a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
a:padding="6dp"
|
||||
style="@style/default_text_size"
|
||||
a:text="@string/c_var_description"/>
|
||||
|
||||
<EditText a:id="@+id/var_edit_description"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
style="@style/default_text_size"
|
||||
a:inputType="text"/>
|
||||
|
||||
<LinearLayout
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent">
|
||||
|
||||
<Button a:id="@+id/cancel_button"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="0dp"
|
||||
a:layout_weight="1"
|
||||
a:text="@string/c_cancel"/>
|
||||
|
||||
<Button a:id="@+id/remove_button"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="0dp"
|
||||
a:layout_weight="1"
|
||||
a:text="@string/c_remove"/>
|
||||
|
||||
<Button a:id="@+id/save_button"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="0dp"
|
||||
a:layout_weight="1"
|
||||
a:text="@string/c_save"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
<resources>
|
||||
<dimen name="editor_text_size">15sp</dimen>
|
||||
<dimen name="display_text_size">15sp</dimen>
|
||||
<dimen name="keyboard_button_text_size">20dp</dimen>
|
||||
<resources>
|
||||
<dimen name="editor_text_size">15sp</dimen>
|
||||
<dimen name="display_text_size">15sp</dimen>
|
||||
<dimen name="keyboard_button_text_size">20dp</dimen>
|
||||
<dimen name="math_entity_text_size">15sp</dimen>
|
||||
<dimen name="math_entity_description_text_size">10sp</dimen>
|
||||
</resources>
|
@ -1,14 +1,16 @@
|
||||
<resources>
|
||||
<dimen name="button_margin">0.5dp</dimen>
|
||||
<dimen name="text_size">20sp</dimen>
|
||||
<dimen name="keyboard_button_text_size">30dp</dimen>
|
||||
<dimen name="button_text_size">20dp</dimen>
|
||||
<dimen name="display_text_size">25sp</dimen>
|
||||
<dimen name="editor_text_size">25sp</dimen>
|
||||
<dimen name="pane_margin">5dp</dimen>
|
||||
<dimen name="pane_padding">5dp</dimen>
|
||||
|
||||
<!--only for not multipane-->
|
||||
<dimen name="editor_padding">5dp</dimen>
|
||||
<dimen name="display_padding">3dp</dimen>
|
||||
<resources>
|
||||
<dimen name="button_margin">0.5dp</dimen>
|
||||
<dimen name="text_size">20sp</dimen>
|
||||
<dimen name="keyboard_button_text_size">30dp</dimen>
|
||||
<dimen name="button_text_size">20dp</dimen>
|
||||
<dimen name="display_text_size">25sp</dimen>
|
||||
<dimen name="editor_text_size">25sp</dimen>
|
||||
<dimen name="pane_margin">5dp</dimen>
|
||||
<dimen name="pane_padding">5dp</dimen>
|
||||
<dimen name="math_entity_text_size">20sp</dimen>
|
||||
<dimen name="math_entity_description_text_size">15sp</dimen>
|
||||
|
||||
<!--only for not multipane-->
|
||||
<dimen name="editor_padding">5dp</dimen>
|
||||
<dimen name="display_padding">3dp</dimen>
|
||||
</resources>
|
@ -8,16 +8,11 @@
|
||||
<resources>
|
||||
|
||||
<style name="math_entity_text" parent="math_entity_text_parent">
|
||||
<item name="android:paddingTop">0dp</item>
|
||||
<item name="android:paddingLeft">0dp</item>
|
||||
<item name="android:paddingRight">0dp</item>
|
||||
<item name="android:paddingBottom">@dimen/pane_padding</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
<item name="android:textColor">@android:color/white</item>
|
||||
</style>
|
||||
|
||||
<style name="math_entity_description" parent="math_entity_description_parent">
|
||||
<item name="android:padding">0dp</item>
|
||||
<item name="android:textColor">#bebebe</item>
|
||||
</style>
|
||||
|
||||
|
@ -1,63 +1,63 @@
|
||||
<!--
|
||||
~ 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
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<style name="WindowTitle">
|
||||
<item name="android:singleLine">true</item>
|
||||
<item name="android:textAppearance">@style/TextAppearance_WindowTitle</item>
|
||||
<item name="android:shadowColor">#BB000000</item>
|
||||
<item name="android:shadowRadius">2.75</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance_WindowTitle">
|
||||
<item name="android:textColor">#fff</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="default_text_size">
|
||||
<item name="android:textSize">@dimen/text_size</item>
|
||||
</style>
|
||||
|
||||
<style name="keyboard_button_style_parent">
|
||||
<item name="android:textSize">@dimen/keyboard_button_text_size</item>
|
||||
<item name="android:textColor">@color/button_text_color</item>
|
||||
</style>
|
||||
|
||||
<style name="button_style_parent">
|
||||
<item name="android:textSize">@dimen/button_text_size</item>
|
||||
<item name="android:textColor">@color/button_text_color</item>
|
||||
</style>
|
||||
|
||||
<style name="display_style_parent" parent="default_text">
|
||||
<item name="android:textSize">@dimen/display_text_size</item>
|
||||
</style>
|
||||
|
||||
<style name="editor_style_parent" parent="default_text">
|
||||
<item name="android:textSize">@dimen/editor_text_size</item>
|
||||
</style>
|
||||
|
||||
<style name="about_style_parent" parent="default_text">
|
||||
<item name="android:textSize">15dp</item>
|
||||
<item name="android:padding">5dp</item>
|
||||
</style>
|
||||
|
||||
<style name="math_entity_text_parent">
|
||||
<item name="android:textSize">20dp</item>
|
||||
</style>
|
||||
|
||||
<style name="math_entity_description_parent">
|
||||
<item name="android:textSize">15dp</item>
|
||||
</style>
|
||||
|
||||
<style name="add_var_button_parent">
|
||||
<item name="android:paddingLeft">40dp</item>
|
||||
<item name="android:paddingRight">40dp</item>
|
||||
</style>
|
||||
|
||||
<!--
|
||||
~ 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
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<style name="WindowTitle">
|
||||
<item name="android:singleLine">true</item>
|
||||
<item name="android:textAppearance">@style/TextAppearance_WindowTitle</item>
|
||||
<item name="android:shadowColor">#BB000000</item>
|
||||
<item name="android:shadowRadius">2.75</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance_WindowTitle">
|
||||
<item name="android:textColor">#fff</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="default_text_size">
|
||||
<item name="android:textSize">@dimen/text_size</item>
|
||||
</style>
|
||||
|
||||
<style name="keyboard_button_style_parent">
|
||||
<item name="android:textSize">@dimen/keyboard_button_text_size</item>
|
||||
<item name="android:textColor">@color/button_text_color</item>
|
||||
</style>
|
||||
|
||||
<style name="button_style_parent">
|
||||
<item name="android:textSize">@dimen/button_text_size</item>
|
||||
<item name="android:textColor">@color/button_text_color</item>
|
||||
</style>
|
||||
|
||||
<style name="display_style_parent" parent="default_text">
|
||||
<item name="android:textSize">@dimen/display_text_size</item>
|
||||
</style>
|
||||
|
||||
<style name="editor_style_parent" parent="default_text">
|
||||
<item name="android:textSize">@dimen/editor_text_size</item>
|
||||
</style>
|
||||
|
||||
<style name="about_style_parent" parent="default_text">
|
||||
<item name="android:textSize">15dp</item>
|
||||
<item name="android:padding">5dp</item>
|
||||
</style>
|
||||
|
||||
<style name="math_entity_text_parent">
|
||||
<item name="android:textSize">@dimen/math_entity_text_size</item>
|
||||
</style>
|
||||
|
||||
<style name="math_entity_description_parent">
|
||||
<item name="android:textSize">@dimen/math_entity_description_text_size</item>
|
||||
</style>
|
||||
|
||||
<style name="add_var_button_parent">
|
||||
<item name="android:paddingLeft">40dp</item>
|
||||
<item name="android:paddingRight">40dp</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
@ -1,225 +1,232 @@
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Vibrator;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.calculator.history.CalculatorHistoryState;
|
||||
import org.solovyev.android.calculator.view.AngleUnitsButton;
|
||||
import org.solovyev.android.calculator.view.NumeralBasesButton;
|
||||
import org.solovyev.android.calculator.view.OnDragListenerVibrator;
|
||||
import org.solovyev.android.history.HistoryDragProcessor;
|
||||
import org.solovyev.android.view.drag.*;
|
||||
import org.solovyev.common.Announcer;
|
||||
import org.solovyev.common.math.Point2d;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 9/28/12
|
||||
* Time: 12:12 AM
|
||||
*/
|
||||
public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
@NotNull
|
||||
private CalculatorPreferences.Gui.Layout layout;
|
||||
|
||||
@Nullable
|
||||
private Vibrator vibrator;
|
||||
|
||||
@NotNull
|
||||
private final Announcer<DragPreferencesChangeListener> dpclRegister = new Announcer<DragPreferencesChangeListener>(DragPreferencesChangeListener.class);
|
||||
|
||||
@NotNull
|
||||
private String logTag = "CalculatorActivity";
|
||||
|
||||
protected AbstractCalculatorHelper() {
|
||||
}
|
||||
|
||||
protected AbstractCalculatorHelper(@NotNull String logTag) {
|
||||
this.logTag = logTag;
|
||||
}
|
||||
|
||||
protected void onCreate(@NotNull Activity activity) {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
|
||||
vibrator = (Vibrator) activity.getSystemService(Activity.VIBRATOR_SERVICE);
|
||||
layout = CalculatorPreferences.Gui.layout.getPreferenceNoError(preferences);
|
||||
|
||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
public void logDebug(@NotNull String message) {
|
||||
Log.d(logTag, message);
|
||||
}
|
||||
|
||||
public void processButtons(@NotNull final Activity activity, @NotNull View root) {
|
||||
dpclRegister.clear();
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
final SimpleOnDragListener.Preferences dragPreferences = SimpleOnDragListener.getPreferences(preferences, activity);
|
||||
|
||||
setOnDragListeners(root, dragPreferences, preferences);
|
||||
|
||||
final OnDragListener historyOnDragListener = new OnDragListenerVibrator(newOnDragListener(new HistoryDragProcessor<CalculatorHistoryState>(getCalculator()), dragPreferences), vibrator, preferences);
|
||||
final DragButton historyButton = getButton(root, R.id.historyButton);
|
||||
if (historyButton != null) {
|
||||
historyButton.setOnDragListener(historyOnDragListener);
|
||||
}
|
||||
|
||||
final DragButton subtractionButton = getButton(root, R.id.subtractionButton);
|
||||
if (subtractionButton != null) {
|
||||
subtractionButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new SimpleOnDragListener.DragProcessor() {
|
||||
@Override
|
||||
public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) {
|
||||
if (dragDirection == DragDirection.down) {
|
||||
CalculatorActivity.operatorsButtonClickHandler(activity);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}, dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final OnDragListener toPositionOnDragListener = new OnDragListenerVibrator(new SimpleOnDragListener(new CursorDragProcessor(), dragPreferences), vibrator, preferences);
|
||||
|
||||
final DragButton rightButton = getButton(root, R.id.rightButton);
|
||||
if (rightButton != null) {
|
||||
rightButton.setOnDragListener(toPositionOnDragListener);
|
||||
}
|
||||
|
||||
final DragButton leftButton = getButton(root, R.id.leftButton);
|
||||
if (leftButton != null) {
|
||||
leftButton.setOnDragListener(toPositionOnDragListener);
|
||||
}
|
||||
|
||||
final DragButton equalsButton = getButton(root, R.id.equalsButton);
|
||||
if (equalsButton != null) {
|
||||
equalsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new EvalDragProcessor(), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final AngleUnitsButton angleUnitsButton = (AngleUnitsButton) getButton(root, R.id.sixDigitButton);
|
||||
if (angleUnitsButton != null) {
|
||||
angleUnitsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.AngleUnitsChanger(activity), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final NumeralBasesButton clearButton = (NumeralBasesButton) getButton(root, R.id.clearButton);
|
||||
if (clearButton != null) {
|
||||
clearButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.NumeralBasesChanger(activity), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final DragButton varsButton = getButton(root, R.id.varsButton);
|
||||
if (varsButton != null) {
|
||||
varsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.VarsDragProcessor(activity), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final DragButton roundBracketsButton = getButton(root, R.id.roundBracketsButton);
|
||||
if (roundBracketsButton != null) {
|
||||
roundBracketsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.RoundBracketsDragProcessor(), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
if (layout == CalculatorPreferences.Gui.Layout.simple) {
|
||||
toggleButtonDirectionText(root, R.id.oneDigitButton, false, DragDirection.up, DragDirection.down);
|
||||
toggleButtonDirectionText(root, R.id.twoDigitButton, false, DragDirection.up, DragDirection.down);
|
||||
toggleButtonDirectionText(root, R.id.threeDigitButton, false, DragDirection.up, DragDirection.down);
|
||||
|
||||
toggleButtonDirectionText(root, R.id.sixDigitButton, false, DragDirection.up, DragDirection.down);
|
||||
toggleButtonDirectionText(root, R.id.sevenDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
||||
toggleButtonDirectionText(root, R.id.eightDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
||||
|
||||
toggleButtonDirectionText(root, R.id.clearButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
||||
|
||||
toggleButtonDirectionText(root, R.id.fourDigitButton, false, DragDirection.down);
|
||||
toggleButtonDirectionText(root, R.id.fiveDigitButton, false, DragDirection.down);
|
||||
|
||||
toggleButtonDirectionText(root, R.id.nineDigitButton, false, DragDirection.left);
|
||||
|
||||
toggleButtonDirectionText(root, R.id.multiplicationButton, false, DragDirection.left);
|
||||
toggleButtonDirectionText(root, R.id.plusButton, false, DragDirection.down, DragDirection.up);
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleButtonDirectionText(@NotNull View root, int id, boolean showDirectionText, @NotNull DragDirection... dragDirections) {
|
||||
final View v = getButton(root, id);
|
||||
if (v instanceof DirectionDragButton ) {
|
||||
final DirectionDragButton button = (DirectionDragButton)v;
|
||||
for (DragDirection dragDirection : dragDirections) {
|
||||
button.showDirectionText(showDirectionText, dragDirection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Calculator getCalculator() {
|
||||
return CalculatorLocatorImpl.getInstance().getCalculator();
|
||||
}
|
||||
|
||||
|
||||
private void setOnDragListeners(@NotNull View root, @NotNull SimpleOnDragListener.Preferences dragPreferences, @NotNull SharedPreferences preferences) {
|
||||
final OnDragListener onDragListener = new OnDragListenerVibrator(newOnDragListener(new DigitButtonDragProcessor(getKeyboard()), dragPreferences), vibrator, preferences);
|
||||
|
||||
final List<Integer> dragButtonIds = new ArrayList<Integer>();
|
||||
|
||||
for (Field field : R.id.class.getDeclaredFields()) {
|
||||
int modifiers = field.getModifiers();
|
||||
if (Modifier.isFinal(modifiers) && Modifier.isStatic(modifiers)) {
|
||||
try {
|
||||
int viewId = field.getInt(R.id.class);
|
||||
final View view = root.findViewById(viewId);
|
||||
if (view instanceof DragButton) {
|
||||
dragButtonIds.add(viewId);
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e(R.id.class.getName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Integer dragButtonId : dragButtonIds) {
|
||||
final DragButton button = getButton(root, dragButtonId);
|
||||
if (button != null) {
|
||||
button.setOnDragListener(onDragListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private CalculatorKeyboard getKeyboard() {
|
||||
return CalculatorLocatorImpl.getInstance().getKeyboard();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <T extends DragButton> T getButton(@NotNull View root, int buttonId) {
|
||||
return (T) root.findViewById(buttonId);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private SimpleOnDragListener newOnDragListener(@NotNull SimpleOnDragListener.DragProcessor dragProcessor,
|
||||
@NotNull SimpleOnDragListener.Preferences dragPreferences) {
|
||||
final SimpleOnDragListener onDragListener = new SimpleOnDragListener(dragProcessor, dragPreferences);
|
||||
dpclRegister.addListener(onDragListener);
|
||||
return onDragListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
||||
if (key != null && key.startsWith("org.solovyev.android.calculator.DragButtonCalibrationActivity")) {
|
||||
dpclRegister.announce().onDragPreferencesChange(SimpleOnDragListener.getPreferences(preferences, CalculatorApplication.getInstance()));
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy(@NotNull Activity activity) {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
|
||||
preferences.unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
}
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Vibrator;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.calculator.history.CalculatorHistoryState;
|
||||
import org.solovyev.android.calculator.view.AngleUnitsButton;
|
||||
import org.solovyev.android.calculator.view.NumeralBasesButton;
|
||||
import org.solovyev.android.calculator.view.OnDragListenerVibrator;
|
||||
import org.solovyev.android.history.HistoryDragProcessor;
|
||||
import org.solovyev.android.view.drag.*;
|
||||
import org.solovyev.common.Announcer;
|
||||
import org.solovyev.common.math.Point2d;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 9/28/12
|
||||
* Time: 12:12 AM
|
||||
*/
|
||||
public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
@NotNull
|
||||
private CalculatorPreferences.Gui.Layout layout;
|
||||
|
||||
@NotNull
|
||||
private CalculatorPreferences.Gui.Theme theme;
|
||||
|
||||
@Nullable
|
||||
private Vibrator vibrator;
|
||||
|
||||
@NotNull
|
||||
private final Announcer<DragPreferencesChangeListener> dpclRegister = new Announcer<DragPreferencesChangeListener>(DragPreferencesChangeListener.class);
|
||||
|
||||
@NotNull
|
||||
private String logTag = "CalculatorActivity";
|
||||
|
||||
protected AbstractCalculatorHelper() {
|
||||
}
|
||||
|
||||
protected AbstractCalculatorHelper(@NotNull String logTag) {
|
||||
this.logTag = logTag;
|
||||
}
|
||||
|
||||
protected void onCreate(@NotNull Activity activity) {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
|
||||
vibrator = (Vibrator) activity.getSystemService(Activity.VIBRATOR_SERVICE);
|
||||
layout = CalculatorPreferences.Gui.layout.getPreferenceNoError(preferences);
|
||||
theme = CalculatorPreferences.Gui.theme.getPreferenceNoError(preferences);
|
||||
|
||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
public void logDebug(@NotNull String message) {
|
||||
Log.d(logTag, message);
|
||||
}
|
||||
|
||||
public void processButtons(@NotNull final Activity activity, @NotNull View root) {
|
||||
dpclRegister.clear();
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
final SimpleOnDragListener.Preferences dragPreferences = SimpleOnDragListener.getPreferences(preferences, activity);
|
||||
|
||||
setOnDragListeners(root, dragPreferences, preferences);
|
||||
|
||||
final OnDragListener historyOnDragListener = new OnDragListenerVibrator(newOnDragListener(new HistoryDragProcessor<CalculatorHistoryState>(getCalculator()), dragPreferences), vibrator, preferences);
|
||||
final DragButton historyButton = getButton(root, R.id.historyButton);
|
||||
if (historyButton != null) {
|
||||
historyButton.setOnDragListener(historyOnDragListener);
|
||||
}
|
||||
|
||||
final DragButton subtractionButton = getButton(root, R.id.subtractionButton);
|
||||
if (subtractionButton != null) {
|
||||
subtractionButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new SimpleOnDragListener.DragProcessor() {
|
||||
@Override
|
||||
public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) {
|
||||
if (dragDirection == DragDirection.down) {
|
||||
CalculatorActivity.operatorsButtonClickHandler(activity);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}, dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final OnDragListener toPositionOnDragListener = new OnDragListenerVibrator(new SimpleOnDragListener(new CursorDragProcessor(), dragPreferences), vibrator, preferences);
|
||||
|
||||
final DragButton rightButton = getButton(root, R.id.rightButton);
|
||||
if (rightButton != null) {
|
||||
rightButton.setOnDragListener(toPositionOnDragListener);
|
||||
}
|
||||
|
||||
final DragButton leftButton = getButton(root, R.id.leftButton);
|
||||
if (leftButton != null) {
|
||||
leftButton.setOnDragListener(toPositionOnDragListener);
|
||||
}
|
||||
|
||||
final DragButton equalsButton = getButton(root, R.id.equalsButton);
|
||||
if (equalsButton != null) {
|
||||
equalsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new EvalDragProcessor(), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final AngleUnitsButton angleUnitsButton = (AngleUnitsButton) getButton(root, R.id.sixDigitButton);
|
||||
if (angleUnitsButton != null) {
|
||||
angleUnitsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.AngleUnitsChanger(activity), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final NumeralBasesButton clearButton = (NumeralBasesButton) getButton(root, R.id.clearButton);
|
||||
if (clearButton != null) {
|
||||
clearButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.NumeralBasesChanger(activity), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final DragButton varsButton = getButton(root, R.id.varsButton);
|
||||
if (varsButton != null) {
|
||||
varsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.VarsDragProcessor(activity), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
final DragButton roundBracketsButton = getButton(root, R.id.roundBracketsButton);
|
||||
if (roundBracketsButton != null) {
|
||||
roundBracketsButton.setOnDragListener(new OnDragListenerVibrator(newOnDragListener(new CalculatorButtons.RoundBracketsDragProcessor(), dragPreferences), vibrator, preferences));
|
||||
}
|
||||
|
||||
if (layout == CalculatorPreferences.Gui.Layout.simple) {
|
||||
toggleButtonDirectionText(root, R.id.oneDigitButton, false, DragDirection.up, DragDirection.down);
|
||||
toggleButtonDirectionText(root, R.id.twoDigitButton, false, DragDirection.up, DragDirection.down);
|
||||
toggleButtonDirectionText(root, R.id.threeDigitButton, false, DragDirection.up, DragDirection.down);
|
||||
|
||||
toggleButtonDirectionText(root, R.id.sixDigitButton, false, DragDirection.up, DragDirection.down);
|
||||
toggleButtonDirectionText(root, R.id.sevenDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
||||
toggleButtonDirectionText(root, R.id.eightDigitButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
||||
|
||||
toggleButtonDirectionText(root, R.id.clearButton, false, DragDirection.left, DragDirection.up, DragDirection.down);
|
||||
|
||||
toggleButtonDirectionText(root, R.id.fourDigitButton, false, DragDirection.down);
|
||||
toggleButtonDirectionText(root, R.id.fiveDigitButton, false, DragDirection.down);
|
||||
|
||||
toggleButtonDirectionText(root, R.id.nineDigitButton, false, DragDirection.left);
|
||||
|
||||
toggleButtonDirectionText(root, R.id.multiplicationButton, false, DragDirection.left);
|
||||
toggleButtonDirectionText(root, R.id.plusButton, false, DragDirection.down, DragDirection.up);
|
||||
}
|
||||
|
||||
CalculatorButtons.processButtons(true, theme, root);
|
||||
CalculatorButtons.toggleEqualsButton(preferences, activity);
|
||||
}
|
||||
|
||||
private void toggleButtonDirectionText(@NotNull View root, int id, boolean showDirectionText, @NotNull DragDirection... dragDirections) {
|
||||
final View v = getButton(root, id);
|
||||
if (v instanceof DirectionDragButton ) {
|
||||
final DirectionDragButton button = (DirectionDragButton)v;
|
||||
for (DragDirection dragDirection : dragDirections) {
|
||||
button.showDirectionText(showDirectionText, dragDirection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Calculator getCalculator() {
|
||||
return CalculatorLocatorImpl.getInstance().getCalculator();
|
||||
}
|
||||
|
||||
|
||||
private void setOnDragListeners(@NotNull View root, @NotNull SimpleOnDragListener.Preferences dragPreferences, @NotNull SharedPreferences preferences) {
|
||||
final OnDragListener onDragListener = new OnDragListenerVibrator(newOnDragListener(new DigitButtonDragProcessor(getKeyboard()), dragPreferences), vibrator, preferences);
|
||||
|
||||
final List<Integer> dragButtonIds = new ArrayList<Integer>();
|
||||
|
||||
for (Field field : R.id.class.getDeclaredFields()) {
|
||||
int modifiers = field.getModifiers();
|
||||
if (Modifier.isFinal(modifiers) && Modifier.isStatic(modifiers)) {
|
||||
try {
|
||||
int viewId = field.getInt(R.id.class);
|
||||
final View view = root.findViewById(viewId);
|
||||
if (view instanceof DragButton) {
|
||||
dragButtonIds.add(viewId);
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e(R.id.class.getName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Integer dragButtonId : dragButtonIds) {
|
||||
final DragButton button = getButton(root, dragButtonId);
|
||||
if (button != null) {
|
||||
button.setOnDragListener(onDragListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private CalculatorKeyboard getKeyboard() {
|
||||
return CalculatorLocatorImpl.getInstance().getKeyboard();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <T extends DragButton> T getButton(@NotNull View root, int buttonId) {
|
||||
return (T) root.findViewById(buttonId);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private SimpleOnDragListener newOnDragListener(@NotNull SimpleOnDragListener.DragProcessor dragProcessor,
|
||||
@NotNull SimpleOnDragListener.Preferences dragPreferences) {
|
||||
final SimpleOnDragListener onDragListener = new SimpleOnDragListener(dragProcessor, dragPreferences);
|
||||
dpclRegister.addListener(onDragListener);
|
||||
return onDragListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
||||
if (key != null && key.startsWith("org.solovyev.android.calculator.DragButtonCalibrationActivity")) {
|
||||
dpclRegister.announce().onDragPreferencesChange(SimpleOnDragListener.getPreferences(preferences, CalculatorApplication.getInstance()));
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy(@NotNull Activity activity) {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
|
||||
preferences.unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
}
|
||||
|
@ -1,354 +1,352 @@
|
||||
/*
|
||||
* 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.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import net.robotmedia.billing.BillingController;
|
||||
import net.robotmedia.billing.IBillingObserver;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.AndroidUtils;
|
||||
import org.solovyev.android.calculator.about.CalculatorReleaseNotesActivity;
|
||||
import org.solovyev.android.calculator.history.CalculatorHistoryFragment;
|
||||
import org.solovyev.android.calculator.history.CalculatorSavedHistoryFragment;
|
||||
import org.solovyev.android.calculator.math.edit.CalculatorFunctionsFragment;
|
||||
import org.solovyev.android.calculator.math.edit.CalculatorOperatorsFragment;
|
||||
import org.solovyev.android.calculator.math.edit.CalculatorVarsFragment;
|
||||
import org.solovyev.android.calculator.plot.CalculatorPlotFragment;
|
||||
import org.solovyev.android.fragments.FragmentUtils;
|
||||
import org.solovyev.android.prefs.Preference;
|
||||
import org.solovyev.android.view.ColorButton;
|
||||
import org.solovyev.common.equals.EqualsTool;
|
||||
import org.solovyev.common.history.HistoryAction;
|
||||
import org.solovyev.common.text.StringUtils;
|
||||
|
||||
public class CalculatorActivity extends SherlockFragmentActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
@NotNull
|
||||
public static final String TAG = CalculatorActivity.class.getSimpleName();
|
||||
|
||||
@Nullable
|
||||
private IBillingObserver billingObserver;
|
||||
|
||||
private boolean useBackAsPrev;
|
||||
|
||||
@NotNull
|
||||
private CalculatorActivityHelper activityHelper;
|
||||
|
||||
/**
|
||||
* Called when the activity is first created.
|
||||
*/
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
|
||||
CalculatorApplication.registerOnRemoteStackTrace();
|
||||
|
||||
/*final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);*/
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.layout.getPreferenceNoError(preferences);
|
||||
|
||||
activityHelper = CalculatorApplication.getInstance().createActivityHelper(layout.getLayoutId(), TAG);
|
||||
activityHelper.logDebug("onCreate");
|
||||
activityHelper.onCreate(this, savedInstanceState);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
activityHelper.logDebug("super.onCreate");
|
||||
|
||||
if (findViewById(R.id.main_second_pane) != null) {
|
||||
activityHelper.addTab(this, "history", CalculatorHistoryFragment.class, null, R.string.c_history, R.id.main_second_pane);
|
||||
activityHelper.addTab(this, "saved_history", CalculatorSavedHistoryFragment.class, null, R.string.c_saved_history, R.id.main_second_pane);
|
||||
activityHelper.addTab(this, "vars", CalculatorVarsFragment.class, null, R.string.c_vars, R.id.main_second_pane);
|
||||
activityHelper.addTab(this, "functions", CalculatorFunctionsFragment.class, null, R.string.c_functions, R.id.main_second_pane);
|
||||
activityHelper.addTab(this, "operators", CalculatorOperatorsFragment.class, null, R.string.c_operators, R.id.main_second_pane);
|
||||
activityHelper.addTab(this, "plot", CalculatorPlotFragment.class, null, R.string.c_plot, R.id.main_second_pane);
|
||||
|
||||
activityHelper.restoreSavedTab(this);
|
||||
} else {
|
||||
getSupportActionBar().hide();
|
||||
}
|
||||
|
||||
FragmentUtils.createFragment(this, CalculatorEditorFragment.class, R.id.editorContainer, "editor");
|
||||
FragmentUtils.createFragment(this, CalculatorDisplayFragment.class, R.id.displayContainer, "display");
|
||||
FragmentUtils.createFragment(this, CalculatorKeyboardFragment.class, R.id.keyboardContainer, "keyboard");
|
||||
|
||||
/*if (customTitleSupported) {
|
||||
try {
|
||||
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.calc_title);
|
||||
final CalculatorAdditionalTitle additionalAdditionalTitleText = (CalculatorAdditionalTitle)findViewById(R.id.additional_title_text);
|
||||
additionalAdditionalTitleText.init(preferences);
|
||||
preferences.registerOnSharedPreferenceChangeListener(additionalAdditionalTitleText);
|
||||
} catch (ClassCastException e) {
|
||||
// super fix for issue with class cast in android.view.Window.setFeatureInt() (see app error reports)
|
||||
Log.e(CalculatorActivity.class.getName(), e.getMessage(), e);
|
||||
}
|
||||
}*/
|
||||
|
||||
billingObserver = new CalculatorBillingObserver(this);
|
||||
BillingController.registerObserver(billingObserver);
|
||||
|
||||
this.useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences);
|
||||
firstTimeInit(preferences, this);
|
||||
|
||||
// init billing controller
|
||||
BillingController.checkBillingSupported(this);
|
||||
|
||||
toggleOrientationChange(preferences);
|
||||
|
||||
CalculatorButtons.toggleEqualsButton(preferences, this, activityHelper.getTheme(), findViewById(R.id.main_layout));
|
||||
|
||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private AndroidCalculator getCalculator() {
|
||||
return ((AndroidCalculator) CalculatorLocatorImpl.getInstance().getCalculator());
|
||||
}
|
||||
|
||||
private static void firstTimeInit(@NotNull SharedPreferences preferences, @NotNull Context context) {
|
||||
final Integer appOpenedCounter = CalculatorPreferences.appOpenedCounter.getPreference(preferences);
|
||||
if (appOpenedCounter != null) {
|
||||
CalculatorPreferences.appOpenedCounter.putPreference(preferences, appOpenedCounter + 1);
|
||||
}
|
||||
|
||||
final Integer savedVersion = CalculatorPreferences.appVersion.getPreference(preferences);
|
||||
|
||||
final int appVersion = AndroidUtils.getAppVersionCode(context, CalculatorActivity.class.getPackage().getName());
|
||||
|
||||
CalculatorPreferences.appVersion.putPreference(preferences, appVersion);
|
||||
|
||||
boolean dialogShown = false;
|
||||
if (EqualsTool.areEqual(savedVersion, CalculatorPreferences.appVersion.getDefaultValue())) {
|
||||
// new start
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(R.string.c_first_start_text);
|
||||
builder.setPositiveButton(android.R.string.ok, null);
|
||||
builder.setTitle(R.string.c_first_start_text_title);
|
||||
builder.create().show();
|
||||
dialogShown = true;
|
||||
} else {
|
||||
if (savedVersion < appVersion) {
|
||||
final boolean showReleaseNotes = CalculatorPreferences.Gui.showReleaseNotes.getPreference(preferences);
|
||||
if (showReleaseNotes) {
|
||||
final String releaseNotes = CalculatorReleaseNotesActivity.getReleaseNotes(context, savedVersion + 1);
|
||||
if (!StringUtils.isEmpty(releaseNotes)) {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(Html.fromHtml(releaseNotes));
|
||||
builder.setPositiveButton(android.R.string.ok, null);
|
||||
builder.setTitle(R.string.c_release_notes);
|
||||
builder.create().show();
|
||||
dialogShown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Log.d(this.getClass().getName(), "Application was opened " + appOpenedCounter + " time!");
|
||||
if (!dialogShown) {
|
||||
if (appOpenedCounter != null && appOpenedCounter > 10) {
|
||||
dialogShown = showSpecialWindow(preferences, CalculatorPreferences.Gui.feedbackWindowShown, R.layout.feedback, R.id.feedbackText, context);
|
||||
}
|
||||
}
|
||||
|
||||
if (!dialogShown) {
|
||||
dialogShown = showSpecialWindow(preferences, CalculatorPreferences.Gui.notesppAnnounceShown, R.layout.notespp_announce, R.id.notespp_announce, context);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean showSpecialWindow(@NotNull SharedPreferences preferences, @NotNull Preference<Boolean> specialWindowShownPref, int layoutId, int textViewId, @NotNull Context context) {
|
||||
boolean result = false;
|
||||
|
||||
final Boolean specialWindowShown = specialWindowShownPref.getPreference(preferences);
|
||||
if ( specialWindowShown != null && !specialWindowShown ) {
|
||||
final LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
final View view = layoutInflater.inflate(layoutId, null);
|
||||
|
||||
final TextView feedbackTextView = (TextView) view.findViewById(textViewId);
|
||||
feedbackTextView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context).setView(view);
|
||||
builder.setPositiveButton(android.R.string.ok, null);
|
||||
builder.create().show();
|
||||
|
||||
result = true;
|
||||
specialWindowShownPref.putPreference(preferences, true);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (useBackAsPrev) {
|
||||
getCalculator().doHistoryAction(HistoryAction.undo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void equalsButtonClickHandler(@NotNull View v) {
|
||||
getCalculator().evaluate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
final CalculatorPreferences.Gui.Layout newLayout = CalculatorPreferences.Gui.layout.getPreference(preferences);
|
||||
if ( newLayout.getLayoutId() != activityHelper.getLayoutId() ) {
|
||||
AndroidUtils.restartActivity(this);
|
||||
}
|
||||
|
||||
this.activityHelper.onResume(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (billingObserver != null) {
|
||||
BillingController.unregisterObserver(billingObserver);
|
||||
}
|
||||
|
||||
activityHelper.onDestroy(this);
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences preferences, @Nullable String key) {
|
||||
if ( CalculatorPreferences.Gui.usePrevAsBack.getKey().equals(key) ) {
|
||||
useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences);
|
||||
}
|
||||
|
||||
if ( CalculatorPreferences.Gui.autoOrientation.getKey().equals(key) ) {
|
||||
toggleOrientationChange(preferences);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
activityHelper.onSaveInstanceState(this, outState);
|
||||
}
|
||||
|
||||
private void toggleOrientationChange(@Nullable SharedPreferences preferences) {
|
||||
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(this) : preferences;
|
||||
if (CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||
} else {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* BUTTON HANDLERS
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void elementaryButtonClickHandler(@NotNull View v) {
|
||||
throw new UnsupportedOperationException("Not implemented yet!");
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void historyButtonClickHandler(@NotNull View v) {
|
||||
CalculatorActivityLauncher.showHistory(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void eraseButtonClickHandler(@NotNull View v) {
|
||||
CalculatorLocatorImpl.getInstance().getEditor().erase();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void simplifyButtonClickHandler(@NotNull View v) {
|
||||
throw new UnsupportedOperationException("Not implemented yet!");
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void moveLeftButtonClickHandler(@NotNull View v) {
|
||||
getKeyboard().moveCursorLeft();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void moveRightButtonClickHandler(@NotNull View v) {
|
||||
getKeyboard().moveCursorRight();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void pasteButtonClickHandler(@NotNull View v) {
|
||||
getKeyboard().pasteButtonPressed();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void copyButtonClickHandler(@NotNull View v) {
|
||||
getKeyboard().copyButtonPressed();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static CalculatorKeyboard getKeyboard() {
|
||||
return CalculatorLocatorImpl.getInstance().getKeyboard();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void clearButtonClickHandler(@NotNull View v) {
|
||||
getKeyboard().clearButtonPressed();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void digitButtonClickHandler(@NotNull View v) {
|
||||
Log.d(String.valueOf(v.getId()), "digitButtonClickHandler() for: " + v.getId() + ". Pressed: " + v.isPressed());
|
||||
if (((ColorButton) v).isShowText()) {
|
||||
getKeyboard().digitButtonPressed(((ColorButton) v).getText().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void functionsButtonClickHandler(@NotNull View v) {
|
||||
CalculatorActivityLauncher.showFunctions(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void operatorsButtonClickHandler(@NotNull View v) {
|
||||
CalculatorActivityLauncher.showOperators(this);
|
||||
}
|
||||
|
||||
public static void operatorsButtonClickHandler(@NotNull Activity activity) {
|
||||
CalculatorActivityLauncher.showOperators(activity);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void varsButtonClickHandler(@NotNull View v) {
|
||||
CalculatorActivityLauncher.showVars(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void donateButtonClickHandler(@NotNull View v) {
|
||||
CalculatorApplication.showDonationDialog(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import net.robotmedia.billing.BillingController;
|
||||
import net.robotmedia.billing.IBillingObserver;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.AndroidUtils;
|
||||
import org.solovyev.android.calculator.about.CalculatorReleaseNotesActivity;
|
||||
import org.solovyev.android.calculator.history.CalculatorHistoryFragment;
|
||||
import org.solovyev.android.calculator.history.CalculatorSavedHistoryFragment;
|
||||
import org.solovyev.android.calculator.math.edit.CalculatorFunctionsFragment;
|
||||
import org.solovyev.android.calculator.math.edit.CalculatorOperatorsFragment;
|
||||
import org.solovyev.android.calculator.math.edit.CalculatorVarsFragment;
|
||||
import org.solovyev.android.calculator.plot.CalculatorPlotFragment;
|
||||
import org.solovyev.android.fragments.FragmentUtils;
|
||||
import org.solovyev.android.prefs.Preference;
|
||||
import org.solovyev.android.view.ColorButton;
|
||||
import org.solovyev.common.equals.EqualsTool;
|
||||
import org.solovyev.common.history.HistoryAction;
|
||||
import org.solovyev.common.text.StringUtils;
|
||||
|
||||
public class CalculatorActivity extends SherlockFragmentActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
@NotNull
|
||||
public static final String TAG = CalculatorActivity.class.getSimpleName();
|
||||
|
||||
@Nullable
|
||||
private IBillingObserver billingObserver;
|
||||
|
||||
private boolean useBackAsPrev;
|
||||
|
||||
@NotNull
|
||||
private CalculatorActivityHelper activityHelper;
|
||||
|
||||
/**
|
||||
* Called when the activity is first created.
|
||||
*/
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
|
||||
CalculatorApplication.registerOnRemoteStackTrace();
|
||||
|
||||
/*final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);*/
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.layout.getPreferenceNoError(preferences);
|
||||
|
||||
activityHelper = CalculatorApplication.getInstance().createActivityHelper(layout.getLayoutId(), TAG);
|
||||
activityHelper.logDebug("onCreate");
|
||||
activityHelper.onCreate(this, savedInstanceState);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
activityHelper.logDebug("super.onCreate");
|
||||
|
||||
if (findViewById(R.id.main_second_pane) != null) {
|
||||
activityHelper.addTab(this, "history", CalculatorHistoryFragment.class, null, R.string.c_history, R.id.main_second_pane);
|
||||
activityHelper.addTab(this, "saved_history", CalculatorSavedHistoryFragment.class, null, R.string.c_saved_history, R.id.main_second_pane);
|
||||
activityHelper.addTab(this, "vars", CalculatorVarsFragment.class, null, R.string.c_vars, R.id.main_second_pane);
|
||||
activityHelper.addTab(this, "functions", CalculatorFunctionsFragment.class, null, R.string.c_functions, R.id.main_second_pane);
|
||||
activityHelper.addTab(this, "operators", CalculatorOperatorsFragment.class, null, R.string.c_operators, R.id.main_second_pane);
|
||||
activityHelper.addTab(this, "plot", CalculatorPlotFragment.class, null, R.string.c_plot, R.id.main_second_pane);
|
||||
|
||||
activityHelper.restoreSavedTab(this);
|
||||
} else {
|
||||
getSupportActionBar().hide();
|
||||
}
|
||||
|
||||
FragmentUtils.createFragment(this, CalculatorEditorFragment.class, R.id.editorContainer, "editor");
|
||||
FragmentUtils.createFragment(this, CalculatorDisplayFragment.class, R.id.displayContainer, "display");
|
||||
FragmentUtils.createFragment(this, CalculatorKeyboardFragment.class, R.id.keyboardContainer, "keyboard");
|
||||
|
||||
/*if (customTitleSupported) {
|
||||
try {
|
||||
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.calc_title);
|
||||
final CalculatorAdditionalTitle additionalAdditionalTitleText = (CalculatorAdditionalTitle)findViewById(R.id.additional_title_text);
|
||||
additionalAdditionalTitleText.init(preferences);
|
||||
preferences.registerOnSharedPreferenceChangeListener(additionalAdditionalTitleText);
|
||||
} catch (ClassCastException e) {
|
||||
// super fix for issue with class cast in android.view.Window.setFeatureInt() (see app error reports)
|
||||
Log.e(CalculatorActivity.class.getName(), e.getMessage(), e);
|
||||
}
|
||||
}*/
|
||||
|
||||
billingObserver = new CalculatorBillingObserver(this);
|
||||
BillingController.registerObserver(billingObserver);
|
||||
|
||||
this.useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences);
|
||||
firstTimeInit(preferences, this);
|
||||
|
||||
// init billing controller
|
||||
BillingController.checkBillingSupported(this);
|
||||
|
||||
toggleOrientationChange(preferences);
|
||||
|
||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private AndroidCalculator getCalculator() {
|
||||
return ((AndroidCalculator) CalculatorLocatorImpl.getInstance().getCalculator());
|
||||
}
|
||||
|
||||
private static void firstTimeInit(@NotNull SharedPreferences preferences, @NotNull Context context) {
|
||||
final Integer appOpenedCounter = CalculatorPreferences.appOpenedCounter.getPreference(preferences);
|
||||
if (appOpenedCounter != null) {
|
||||
CalculatorPreferences.appOpenedCounter.putPreference(preferences, appOpenedCounter + 1);
|
||||
}
|
||||
|
||||
final Integer savedVersion = CalculatorPreferences.appVersion.getPreference(preferences);
|
||||
|
||||
final int appVersion = AndroidUtils.getAppVersionCode(context, CalculatorActivity.class.getPackage().getName());
|
||||
|
||||
CalculatorPreferences.appVersion.putPreference(preferences, appVersion);
|
||||
|
||||
boolean dialogShown = false;
|
||||
if (EqualsTool.areEqual(savedVersion, CalculatorPreferences.appVersion.getDefaultValue())) {
|
||||
// new start
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(R.string.c_first_start_text);
|
||||
builder.setPositiveButton(android.R.string.ok, null);
|
||||
builder.setTitle(R.string.c_first_start_text_title);
|
||||
builder.create().show();
|
||||
dialogShown = true;
|
||||
} else {
|
||||
if (savedVersion < appVersion) {
|
||||
final boolean showReleaseNotes = CalculatorPreferences.Gui.showReleaseNotes.getPreference(preferences);
|
||||
if (showReleaseNotes) {
|
||||
final String releaseNotes = CalculatorReleaseNotesActivity.getReleaseNotes(context, savedVersion + 1);
|
||||
if (!StringUtils.isEmpty(releaseNotes)) {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context).setMessage(Html.fromHtml(releaseNotes));
|
||||
builder.setPositiveButton(android.R.string.ok, null);
|
||||
builder.setTitle(R.string.c_release_notes);
|
||||
builder.create().show();
|
||||
dialogShown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Log.d(this.getClass().getName(), "Application was opened " + appOpenedCounter + " time!");
|
||||
if (!dialogShown) {
|
||||
if (appOpenedCounter != null && appOpenedCounter > 10) {
|
||||
dialogShown = showSpecialWindow(preferences, CalculatorPreferences.Gui.feedbackWindowShown, R.layout.feedback, R.id.feedbackText, context);
|
||||
}
|
||||
}
|
||||
|
||||
if (!dialogShown) {
|
||||
dialogShown = showSpecialWindow(preferences, CalculatorPreferences.Gui.notesppAnnounceShown, R.layout.notespp_announce, R.id.notespp_announce, context);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean showSpecialWindow(@NotNull SharedPreferences preferences, @NotNull Preference<Boolean> specialWindowShownPref, int layoutId, int textViewId, @NotNull Context context) {
|
||||
boolean result = false;
|
||||
|
||||
final Boolean specialWindowShown = specialWindowShownPref.getPreference(preferences);
|
||||
if ( specialWindowShown != null && !specialWindowShown ) {
|
||||
final LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
final View view = layoutInflater.inflate(layoutId, null);
|
||||
|
||||
final TextView feedbackTextView = (TextView) view.findViewById(textViewId);
|
||||
feedbackTextView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context).setView(view);
|
||||
builder.setPositiveButton(android.R.string.ok, null);
|
||||
builder.create().show();
|
||||
|
||||
result = true;
|
||||
specialWindowShownPref.putPreference(preferences, true);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (useBackAsPrev) {
|
||||
getCalculator().doHistoryAction(HistoryAction.undo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void equalsButtonClickHandler(@NotNull View v) {
|
||||
getCalculator().evaluate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
final CalculatorPreferences.Gui.Layout newLayout = CalculatorPreferences.Gui.layout.getPreference(preferences);
|
||||
if ( newLayout.getLayoutId() != activityHelper.getLayoutId() ) {
|
||||
AndroidUtils.restartActivity(this);
|
||||
}
|
||||
|
||||
this.activityHelper.onResume(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (billingObserver != null) {
|
||||
BillingController.unregisterObserver(billingObserver);
|
||||
}
|
||||
|
||||
activityHelper.onDestroy(this);
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences preferences, @Nullable String key) {
|
||||
if ( CalculatorPreferences.Gui.usePrevAsBack.getKey().equals(key) ) {
|
||||
useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences);
|
||||
}
|
||||
|
||||
if ( CalculatorPreferences.Gui.autoOrientation.getKey().equals(key) ) {
|
||||
toggleOrientationChange(preferences);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
activityHelper.onSaveInstanceState(this, outState);
|
||||
}
|
||||
|
||||
private void toggleOrientationChange(@Nullable SharedPreferences preferences) {
|
||||
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(this) : preferences;
|
||||
if (CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||
} else {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* BUTTON HANDLERS
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void elementaryButtonClickHandler(@NotNull View v) {
|
||||
throw new UnsupportedOperationException("Not implemented yet!");
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void historyButtonClickHandler(@NotNull View v) {
|
||||
CalculatorActivityLauncher.showHistory(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void eraseButtonClickHandler(@NotNull View v) {
|
||||
CalculatorLocatorImpl.getInstance().getEditor().erase();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void simplifyButtonClickHandler(@NotNull View v) {
|
||||
throw new UnsupportedOperationException("Not implemented yet!");
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void moveLeftButtonClickHandler(@NotNull View v) {
|
||||
getKeyboard().moveCursorLeft();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void moveRightButtonClickHandler(@NotNull View v) {
|
||||
getKeyboard().moveCursorRight();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void pasteButtonClickHandler(@NotNull View v) {
|
||||
getKeyboard().pasteButtonPressed();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void copyButtonClickHandler(@NotNull View v) {
|
||||
getKeyboard().copyButtonPressed();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static CalculatorKeyboard getKeyboard() {
|
||||
return CalculatorLocatorImpl.getInstance().getKeyboard();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void clearButtonClickHandler(@NotNull View v) {
|
||||
getKeyboard().clearButtonPressed();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void digitButtonClickHandler(@NotNull View v) {
|
||||
Log.d(String.valueOf(v.getId()), "digitButtonClickHandler() for: " + v.getId() + ". Pressed: " + v.isPressed());
|
||||
if (((ColorButton) v).isShowText()) {
|
||||
getKeyboard().digitButtonPressed(((ColorButton) v).getText().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void functionsButtonClickHandler(@NotNull View v) {
|
||||
CalculatorActivityLauncher.showFunctions(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void operatorsButtonClickHandler(@NotNull View v) {
|
||||
CalculatorActivityLauncher.showOperators(this);
|
||||
}
|
||||
|
||||
public static void operatorsButtonClickHandler(@NotNull Activity activity) {
|
||||
CalculatorActivityLauncher.showOperators(activity);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void varsButtonClickHandler(@NotNull View v) {
|
||||
CalculatorActivityLauncher.showVars(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void donateButtonClickHandler(@NotNull View v) {
|
||||
CalculatorApplication.showDonationDialog(this);
|
||||
}
|
||||
|
||||
}
|
@ -1,190 +1,195 @@
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.AndroidUtils;
|
||||
import org.solovyev.android.sherlock.tabs.ActionBarFragmentTabListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 9/25/12
|
||||
* Time: 10:32 PM
|
||||
*/
|
||||
public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper implements CalculatorActivityHelper {
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* CONSTANTS
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
private static final String SELECTED_NAV = "selected_nav";
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* FIELDS
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
private int layoutId;
|
||||
|
||||
private boolean homeIcon = false;
|
||||
|
||||
@NotNull
|
||||
private final List<String> fragmentTags = new ArrayList<String>();
|
||||
|
||||
@NotNull
|
||||
private CalculatorPreferences.Gui.Theme theme;
|
||||
private int navPosition = 0;
|
||||
|
||||
|
||||
public CalculatorActivityHelperImpl(int layoutId, @NotNull String logTag) {
|
||||
super(logTag);
|
||||
this.layoutId = layoutId;
|
||||
}
|
||||
|
||||
public CalculatorActivityHelperImpl(int layoutId, boolean homeIcon) {
|
||||
this.layoutId = layoutId;
|
||||
this.homeIcon = homeIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@NotNull Activity activity, @Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(activity);
|
||||
|
||||
if ( activity instanceof CalculatorEventListener) {
|
||||
CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener)activity);
|
||||
}
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
|
||||
this.theme = CalculatorPreferences.Gui.getTheme(preferences);
|
||||
activity.setTheme(this.theme.getThemeId());
|
||||
|
||||
activity.setContentView(layoutId);
|
||||
|
||||
final View root = activity.findViewById(R.id.main_layout);
|
||||
if (root != null) {
|
||||
CalculatorButtons.processButtons(true, theme, root);
|
||||
} else {
|
||||
Log.e(CalculatorActivityHelperImpl.class.getSimpleName(), "Root is null for " + activity.getClass().getName());
|
||||
}
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
navPosition = savedInstanceState.getInt(SELECTED_NAV, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@NotNull final SherlockFragmentActivity activity, @Nullable Bundle savedInstanceState) {
|
||||
this.onCreate((Activity) activity, savedInstanceState);
|
||||
|
||||
final ActionBar actionBar = activity.getSupportActionBar();
|
||||
actionBar.setDisplayUseLogoEnabled(false);
|
||||
actionBar.setDisplayHomeAsUpEnabled(homeIcon);
|
||||
actionBar.setHomeButtonEnabled(false);
|
||||
actionBar.setDisplayShowHomeEnabled(true);
|
||||
if (activity instanceof CalculatorActivity) {
|
||||
actionBar.setDisplayShowTitleEnabled(false);
|
||||
} else {
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
}
|
||||
actionBar.setIcon(R.drawable.icon_action_bar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreSavedTab(@NotNull SherlockFragmentActivity activity) {
|
||||
final ActionBar actionBar = activity.getSupportActionBar();
|
||||
if (navPosition >= 0 && navPosition < actionBar.getTabCount()) {
|
||||
activity.getSupportActionBar().setSelectedNavigationItem(navPosition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NotNull SherlockFragmentActivity activity, @NotNull Bundle outState) {
|
||||
onSaveInstanceState((Activity) activity, outState);
|
||||
outState.putInt(SELECTED_NAV, activity.getSupportActionBar().getSelectedNavigationIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NotNull Activity activity, @NotNull Bundle outState) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(@NotNull Activity activity) {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
|
||||
final CalculatorPreferences.Gui.Theme newTheme = CalculatorPreferences.Gui.theme.getPreference(preferences);
|
||||
if (!theme.equals(newTheme)) {
|
||||
AndroidUtils.restartActivity(activity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(@NotNull Activity activity) {
|
||||
super.onDestroy(activity);
|
||||
|
||||
if ( activity instanceof CalculatorEventListener) {
|
||||
CalculatorLocatorImpl.getInstance().getCalculator().removeCalculatorEventListener((CalculatorEventListener)activity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(@NotNull SherlockFragmentActivity activity) {
|
||||
this.onDestroy((Activity)activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTab(@NotNull SherlockFragmentActivity activity,
|
||||
@NotNull String tag,
|
||||
@NotNull Class<? extends Fragment> fragmentClass,
|
||||
@Nullable Bundle fragmentArgs,
|
||||
int captionResId,
|
||||
int parentViewId) {
|
||||
activity.getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
|
||||
|
||||
final ActionBar actionBar = activity.getSupportActionBar();
|
||||
final ActionBar.Tab tab = actionBar.newTab();
|
||||
tab.setTag(tag);
|
||||
tab.setText(captionResId);
|
||||
|
||||
final ActionBarFragmentTabListener listener = new ActionBarFragmentTabListener(activity, tag, fragmentClass, fragmentArgs, parentViewId);
|
||||
tab.setTabListener(listener);
|
||||
actionBar.addTab(tab);
|
||||
|
||||
fragmentTags.add(tag);
|
||||
|
||||
restoreSavedTab(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return layoutId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public CalculatorPreferences.Gui.Theme getTheme() {
|
||||
return theme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(@NotNull SherlockFragmentActivity activity) {
|
||||
onResume((Activity) activity);
|
||||
}
|
||||
}
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.AndroidUtils;
|
||||
import org.solovyev.android.sherlock.tabs.ActionBarFragmentTabListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 9/25/12
|
||||
* Time: 10:32 PM
|
||||
*/
|
||||
public class CalculatorActivityHelperImpl extends AbstractCalculatorHelper implements CalculatorActivityHelper {
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* CONSTANTS
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
private static final String SELECTED_NAV = "selected_nav";
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* FIELDS
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
private int layoutId;
|
||||
|
||||
private boolean homeIcon = false;
|
||||
|
||||
@NotNull
|
||||
private final List<String> fragmentTags = new ArrayList<String>();
|
||||
|
||||
@NotNull
|
||||
private CalculatorPreferences.Gui.Theme theme;
|
||||
private int navPosition = 0;
|
||||
|
||||
|
||||
public CalculatorActivityHelperImpl(int layoutId, @NotNull String logTag) {
|
||||
super(logTag);
|
||||
this.layoutId = layoutId;
|
||||
}
|
||||
|
||||
public CalculatorActivityHelperImpl(int layoutId, boolean homeIcon) {
|
||||
this.layoutId = layoutId;
|
||||
this.homeIcon = homeIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@NotNull Activity activity, @Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(activity);
|
||||
|
||||
if ( activity instanceof CalculatorEventListener) {
|
||||
CalculatorLocatorImpl.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener)activity);
|
||||
}
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
|
||||
this.theme = CalculatorPreferences.Gui.getTheme(preferences);
|
||||
activity.setTheme(this.theme.getThemeId());
|
||||
|
||||
activity.setContentView(layoutId);
|
||||
|
||||
final View root = activity.findViewById(R.id.main_layout);
|
||||
if (root != null) {
|
||||
processButtons(activity, root);
|
||||
} else {
|
||||
Log.e(CalculatorActivityHelperImpl.class.getSimpleName(), "Root is null for " + activity.getClass().getName());
|
||||
}
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
navPosition = savedInstanceState.getInt(SELECTED_NAV, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@NotNull final SherlockFragmentActivity activity, @Nullable Bundle savedInstanceState) {
|
||||
this.onCreate((Activity) activity, savedInstanceState);
|
||||
|
||||
final ActionBar actionBar = activity.getSupportActionBar();
|
||||
actionBar.setDisplayUseLogoEnabled(false);
|
||||
actionBar.setDisplayHomeAsUpEnabled(homeIcon);
|
||||
actionBar.setHomeButtonEnabled(false);
|
||||
actionBar.setDisplayShowHomeEnabled(true);
|
||||
|
||||
if (activity instanceof CalculatorActivity) {
|
||||
if ( AndroidUtils.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT ) {
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
}
|
||||
actionBar.setIcon(R.drawable.icon_action_bar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreSavedTab(@NotNull SherlockFragmentActivity activity) {
|
||||
final ActionBar actionBar = activity.getSupportActionBar();
|
||||
if (navPosition >= 0 && navPosition < actionBar.getTabCount()) {
|
||||
activity.getSupportActionBar().setSelectedNavigationItem(navPosition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NotNull SherlockFragmentActivity activity, @NotNull Bundle outState) {
|
||||
onSaveInstanceState((Activity) activity, outState);
|
||||
outState.putInt(SELECTED_NAV, activity.getSupportActionBar().getSelectedNavigationIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NotNull Activity activity, @NotNull Bundle outState) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(@NotNull Activity activity) {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
|
||||
final CalculatorPreferences.Gui.Theme newTheme = CalculatorPreferences.Gui.theme.getPreference(preferences);
|
||||
if (!theme.equals(newTheme)) {
|
||||
AndroidUtils.restartActivity(activity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(@NotNull Activity activity) {
|
||||
super.onDestroy(activity);
|
||||
|
||||
if ( activity instanceof CalculatorEventListener) {
|
||||
CalculatorLocatorImpl.getInstance().getCalculator().removeCalculatorEventListener((CalculatorEventListener)activity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(@NotNull SherlockFragmentActivity activity) {
|
||||
this.onDestroy((Activity)activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTab(@NotNull SherlockFragmentActivity activity,
|
||||
@NotNull String tag,
|
||||
@NotNull Class<? extends Fragment> fragmentClass,
|
||||
@Nullable Bundle fragmentArgs,
|
||||
int captionResId,
|
||||
int parentViewId) {
|
||||
activity.getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
|
||||
|
||||
final ActionBar actionBar = activity.getSupportActionBar();
|
||||
final ActionBar.Tab tab = actionBar.newTab();
|
||||
tab.setTag(tag);
|
||||
tab.setText(captionResId);
|
||||
|
||||
final ActionBarFragmentTabListener listener = new ActionBarFragmentTabListener(activity, tag, fragmentClass, fragmentArgs, parentViewId);
|
||||
tab.setTabListener(listener);
|
||||
actionBar.addTab(tab);
|
||||
|
||||
fragmentTags.add(tag);
|
||||
|
||||
restoreSavedTab(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return layoutId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public CalculatorPreferences.Gui.Theme getTheme() {
|
||||
return theme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(@NotNull SherlockFragmentActivity activity) {
|
||||
onResume((Activity) activity);
|
||||
}
|
||||
}
|
||||
|
@ -1,244 +1,243 @@
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
import jscl.AngleUnit;
|
||||
import jscl.NumeralBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.AndroidUtils;
|
||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||
import org.solovyev.android.calculator.view.AngleUnitsButton;
|
||||
import org.solovyev.android.calculator.view.NumeralBasesButton;
|
||||
import org.solovyev.android.view.ColorButton;
|
||||
import org.solovyev.android.view.drag.DragButton;
|
||||
import org.solovyev.android.view.drag.DragDirection;
|
||||
import org.solovyev.android.view.drag.SimpleOnDragListener;
|
||||
import org.solovyev.common.math.Point2d;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 9/28/12
|
||||
* Time: 12:06 AM
|
||||
*/
|
||||
public final class CalculatorButtons {
|
||||
|
||||
private CalculatorButtons () {
|
||||
}
|
||||
|
||||
|
||||
public static void processButtons(boolean fixMagicFlames,
|
||||
@NotNull CalculatorPreferences.Gui.Theme theme,
|
||||
@NotNull View root) {
|
||||
if (theme.getThemeType() == CalculatorPreferences.Gui.ThemeType.metro) {
|
||||
|
||||
if (fixMagicFlames) {
|
||||
// for metro themes we should turn off magic flames
|
||||
AndroidUtils.processViewsOfType(root, ColorButton.class, new AndroidUtils.ViewProcessor<ColorButton>() {
|
||||
@Override
|
||||
public void process(@NotNull ColorButton colorButton) {
|
||||
colorButton.setDrawMagicFlame(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void initMultiplicationButton(@NotNull View root) {
|
||||
final View multiplicationButton = root.findViewById(R.id.multiplicationButton);
|
||||
if ( multiplicationButton instanceof Button) {
|
||||
((Button) multiplicationButton).setText(CalculatorLocatorImpl.getInstance().getEngine().getMultiplicationSign());
|
||||
}
|
||||
}
|
||||
|
||||
public static void toggleEqualsButton(@Nullable SharedPreferences preferences,
|
||||
@NotNull Activity activity,
|
||||
@NotNull CalculatorPreferences.Gui.Theme theme,
|
||||
@NotNull View root) {
|
||||
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences;
|
||||
|
||||
if (AndroidUtils.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT || !CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) {
|
||||
final Display display = activity.getWindowManager().getDefaultDisplay();
|
||||
|
||||
final DragButton equalsButton = (DragButton)activity.findViewById(R.id.equalsButton);
|
||||
if (equalsButton != null) {
|
||||
if (CalculatorPreferences.Gui.showEqualsButton.getPreference(preferences)) {
|
||||
equalsButton.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.FILL_PARENT, 1f));
|
||||
if (display.getWidth() <= 480) {
|
||||
// mobile phones
|
||||
final AndroidCalculatorDisplayView calculatorDisplayView = getCalculatorDisplayView();
|
||||
if (calculatorDisplayView != null) {
|
||||
calculatorDisplayView.setBackgroundDrawable(null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
equalsButton.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.FILL_PARENT, 0f));
|
||||
if (display.getWidth() <= 480) {
|
||||
// mobile phones
|
||||
final AndroidCalculatorDisplayView calculatorDisplayView = getCalculatorDisplayView();
|
||||
if (calculatorDisplayView != null) {
|
||||
calculatorDisplayView.setBackgroundDrawable(activity.getResources().getDrawable(R.drawable.equals9));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static AndroidCalculatorDisplayView getCalculatorDisplayView() {
|
||||
return (AndroidCalculatorDisplayView) CalculatorLocatorImpl.getInstance().getDisplay().getView();
|
||||
}
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* STATIC CLASSES
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
static class RoundBracketsDragProcessor implements SimpleOnDragListener.DragProcessor {
|
||||
@Override
|
||||
public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) {
|
||||
final boolean result;
|
||||
|
||||
if (dragDirection == DragDirection.left) {
|
||||
getKeyboard().roundBracketsButtonPressed();
|
||||
result = true;
|
||||
} else {
|
||||
result = new DigitButtonDragProcessor(getKeyboard()).processDragEvent(dragDirection, dragButton, startPoint2d, motionEvent);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static CalculatorKeyboard getKeyboard() {
|
||||
return CalculatorLocatorImpl.getInstance().getKeyboard();
|
||||
}
|
||||
|
||||
static class VarsDragProcessor implements SimpleOnDragListener.DragProcessor {
|
||||
|
||||
@NotNull
|
||||
private Context context;
|
||||
|
||||
VarsDragProcessor(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processDragEvent(@NotNull DragDirection dragDirection,
|
||||
@NotNull DragButton dragButton,
|
||||
@NotNull Point2d startPoint2d,
|
||||
@NotNull MotionEvent motionEvent) {
|
||||
boolean result = false;
|
||||
|
||||
if (dragDirection == DragDirection.up) {
|
||||
CalculatorActivityLauncher.createVar(context, CalculatorLocatorImpl.getInstance().getDisplay());
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
static class AngleUnitsChanger implements SimpleOnDragListener.DragProcessor {
|
||||
|
||||
@NotNull
|
||||
private final DigitButtonDragProcessor processor;
|
||||
|
||||
@NotNull
|
||||
private final Context context;
|
||||
|
||||
AngleUnitsChanger(@NotNull Context context) {
|
||||
this.context = context;
|
||||
this.processor = new DigitButtonDragProcessor(CalculatorLocatorImpl.getInstance().getKeyboard());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processDragEvent(@NotNull DragDirection dragDirection,
|
||||
@NotNull DragButton dragButton,
|
||||
@NotNull Point2d startPoint2d,
|
||||
@NotNull MotionEvent motionEvent) {
|
||||
boolean result = false;
|
||||
|
||||
if (dragButton instanceof AngleUnitsButton) {
|
||||
if (dragDirection != DragDirection.left) {
|
||||
final String directionText = ((AngleUnitsButton) dragButton).getText(dragDirection);
|
||||
if (directionText != null) {
|
||||
try {
|
||||
|
||||
final AngleUnit angleUnits = AngleUnit.valueOf(directionText);
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
AndroidCalculatorEngine.Preferences.angleUnit.putPreference(preferences, angleUnits);
|
||||
|
||||
Toast.makeText(context, context.getString(R.string.c_angle_units_changed_to, angleUnits.name()), Toast.LENGTH_LONG).show();
|
||||
|
||||
result = true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.d(this.getClass().getName(), "Unsupported angle units: " + directionText);
|
||||
}
|
||||
}
|
||||
} else if (dragDirection == DragDirection.left) {
|
||||
result = processor.processDragEvent(dragDirection, dragButton, startPoint2d, motionEvent);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
static class NumeralBasesChanger implements SimpleOnDragListener.DragProcessor {
|
||||
|
||||
@NotNull
|
||||
private final Context context;
|
||||
|
||||
NumeralBasesChanger(@NotNull Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processDragEvent(@NotNull DragDirection dragDirection,
|
||||
@NotNull DragButton dragButton,
|
||||
@NotNull Point2d startPoint2d,
|
||||
@NotNull MotionEvent motionEvent) {
|
||||
boolean result = false;
|
||||
|
||||
if (dragButton instanceof NumeralBasesButton) {
|
||||
final String directionText = ((NumeralBasesButton) dragButton).getText(dragDirection);
|
||||
if (directionText != null) {
|
||||
try {
|
||||
|
||||
final NumeralBase numeralBase = NumeralBase.valueOf(directionText);
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
AndroidCalculatorEngine.Preferences.numeralBase.putPreference(preferences, numeralBase);
|
||||
|
||||
Toast.makeText(context, context.getString(R.string.c_numeral_base_changed_to, numeralBase.name()), Toast.LENGTH_LONG).show();
|
||||
|
||||
result = true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.d(this.getClass().getName(), "Unsupported numeral base: " + directionText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
import jscl.AngleUnit;
|
||||
import jscl.NumeralBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.AndroidUtils;
|
||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||
import org.solovyev.android.calculator.view.AngleUnitsButton;
|
||||
import org.solovyev.android.calculator.view.NumeralBasesButton;
|
||||
import org.solovyev.android.view.ColorButton;
|
||||
import org.solovyev.android.view.drag.DragButton;
|
||||
import org.solovyev.android.view.drag.DragDirection;
|
||||
import org.solovyev.android.view.drag.SimpleOnDragListener;
|
||||
import org.solovyev.common.math.Point2d;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 9/28/12
|
||||
* Time: 12:06 AM
|
||||
*/
|
||||
public final class CalculatorButtons {
|
||||
|
||||
private CalculatorButtons () {
|
||||
}
|
||||
|
||||
|
||||
public static void processButtons(boolean fixMagicFlames,
|
||||
@NotNull CalculatorPreferences.Gui.Theme theme,
|
||||
@NotNull View root) {
|
||||
if (theme.getThemeType() == CalculatorPreferences.Gui.ThemeType.metro) {
|
||||
|
||||
if (fixMagicFlames) {
|
||||
// for metro themes we should turn off magic flames
|
||||
AndroidUtils.processViewsOfType(root, ColorButton.class, new AndroidUtils.ViewProcessor<ColorButton>() {
|
||||
@Override
|
||||
public void process(@NotNull ColorButton colorButton) {
|
||||
colorButton.setDrawMagicFlame(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void initMultiplicationButton(@NotNull View root) {
|
||||
final View multiplicationButton = root.findViewById(R.id.multiplicationButton);
|
||||
if ( multiplicationButton instanceof Button) {
|
||||
((Button) multiplicationButton).setText(CalculatorLocatorImpl.getInstance().getEngine().getMultiplicationSign());
|
||||
}
|
||||
}
|
||||
|
||||
public static void toggleEqualsButton(@Nullable SharedPreferences preferences,
|
||||
@NotNull Activity activity) {
|
||||
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences;
|
||||
|
||||
if (AndroidUtils.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT || !CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) {
|
||||
final Display display = activity.getWindowManager().getDefaultDisplay();
|
||||
|
||||
final DragButton equalsButton = (DragButton)activity.findViewById(R.id.equalsButton);
|
||||
if (equalsButton != null) {
|
||||
// todo serso: visibility should be changed only for some cases (like small screens)
|
||||
if (CalculatorPreferences.Gui.showEqualsButton.getPreference(preferences)) {
|
||||
equalsButton.setVisibility(View.VISIBLE);
|
||||
if (display.getWidth() <= 480) {
|
||||
// mobile phones
|
||||
final AndroidCalculatorDisplayView calculatorDisplayView = getCalculatorDisplayView();
|
||||
if (calculatorDisplayView != null) {
|
||||
calculatorDisplayView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
equalsButton.setVisibility(View.GONE);
|
||||
if (display.getWidth() <= 480) {
|
||||
// mobile phones
|
||||
final AndroidCalculatorDisplayView calculatorDisplayView = getCalculatorDisplayView();
|
||||
if (calculatorDisplayView != null) {
|
||||
calculatorDisplayView.setCompoundDrawablesWithIntrinsicBounds(activity.getResources().getDrawable(R.drawable.equals9), null, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static AndroidCalculatorDisplayView getCalculatorDisplayView() {
|
||||
return (AndroidCalculatorDisplayView) CalculatorLocatorImpl.getInstance().getDisplay().getView();
|
||||
}
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* STATIC CLASSES
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
static class RoundBracketsDragProcessor implements SimpleOnDragListener.DragProcessor {
|
||||
@Override
|
||||
public boolean processDragEvent(@NotNull DragDirection dragDirection, @NotNull DragButton dragButton, @NotNull Point2d startPoint2d, @NotNull MotionEvent motionEvent) {
|
||||
final boolean result;
|
||||
|
||||
if (dragDirection == DragDirection.left) {
|
||||
getKeyboard().roundBracketsButtonPressed();
|
||||
result = true;
|
||||
} else {
|
||||
result = new DigitButtonDragProcessor(getKeyboard()).processDragEvent(dragDirection, dragButton, startPoint2d, motionEvent);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static CalculatorKeyboard getKeyboard() {
|
||||
return CalculatorLocatorImpl.getInstance().getKeyboard();
|
||||
}
|
||||
|
||||
static class VarsDragProcessor implements SimpleOnDragListener.DragProcessor {
|
||||
|
||||
@NotNull
|
||||
private Context context;
|
||||
|
||||
VarsDragProcessor(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processDragEvent(@NotNull DragDirection dragDirection,
|
||||
@NotNull DragButton dragButton,
|
||||
@NotNull Point2d startPoint2d,
|
||||
@NotNull MotionEvent motionEvent) {
|
||||
boolean result = false;
|
||||
|
||||
if (dragDirection == DragDirection.up) {
|
||||
CalculatorActivityLauncher.createVar(context, CalculatorLocatorImpl.getInstance().getDisplay());
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
static class AngleUnitsChanger implements SimpleOnDragListener.DragProcessor {
|
||||
|
||||
@NotNull
|
||||
private final DigitButtonDragProcessor processor;
|
||||
|
||||
@NotNull
|
||||
private final Context context;
|
||||
|
||||
AngleUnitsChanger(@NotNull Context context) {
|
||||
this.context = context;
|
||||
this.processor = new DigitButtonDragProcessor(CalculatorLocatorImpl.getInstance().getKeyboard());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processDragEvent(@NotNull DragDirection dragDirection,
|
||||
@NotNull DragButton dragButton,
|
||||
@NotNull Point2d startPoint2d,
|
||||
@NotNull MotionEvent motionEvent) {
|
||||
boolean result = false;
|
||||
|
||||
if (dragButton instanceof AngleUnitsButton) {
|
||||
if (dragDirection != DragDirection.left) {
|
||||
final String directionText = ((AngleUnitsButton) dragButton).getText(dragDirection);
|
||||
if (directionText != null) {
|
||||
try {
|
||||
|
||||
final AngleUnit angleUnits = AngleUnit.valueOf(directionText);
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
AndroidCalculatorEngine.Preferences.angleUnit.putPreference(preferences, angleUnits);
|
||||
|
||||
Toast.makeText(context, context.getString(R.string.c_angle_units_changed_to, angleUnits.name()), Toast.LENGTH_LONG).show();
|
||||
|
||||
result = true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.d(this.getClass().getName(), "Unsupported angle units: " + directionText);
|
||||
}
|
||||
}
|
||||
} else if (dragDirection == DragDirection.left) {
|
||||
result = processor.processDragEvent(dragDirection, dragButton, startPoint2d, motionEvent);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
static class NumeralBasesChanger implements SimpleOnDragListener.DragProcessor {
|
||||
|
||||
@NotNull
|
||||
private final Context context;
|
||||
|
||||
NumeralBasesChanger(@NotNull Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processDragEvent(@NotNull DragDirection dragDirection,
|
||||
@NotNull DragButton dragButton,
|
||||
@NotNull Point2d startPoint2d,
|
||||
@NotNull MotionEvent motionEvent) {
|
||||
boolean result = false;
|
||||
|
||||
if (dragButton instanceof NumeralBasesButton) {
|
||||
final String directionText = ((NumeralBasesButton) dragButton).getText(dragDirection);
|
||||
if (directionText != null) {
|
||||
try {
|
||||
|
||||
final NumeralBase numeralBase = NumeralBase.valueOf(directionText);
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
AndroidCalculatorEngine.Preferences.numeralBase.putPreference(preferences, numeralBase);
|
||||
|
||||
Toast.makeText(context, context.getString(R.string.c_numeral_base_changed_to, numeralBase.name()), Toast.LENGTH_LONG).show();
|
||||
|
||||
result = true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.d(this.getClass().getName(), "Unsupported numeral base: " + directionText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,134 +1,134 @@
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import com.actionbarsherlock.app.SherlockFragment;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||
|
||||
/**
|
||||
* User: Solovyev_S
|
||||
* Date: 25.09.12
|
||||
* Time: 12:25
|
||||
*/
|
||||
public class CalculatorKeyboardFragment extends SherlockFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
@NotNull
|
||||
private NumeralBaseButtons numeralBaseButtons = new NumeralBaseButtons();
|
||||
|
||||
@NotNull
|
||||
private CalculatorPreferences.Gui.Theme theme;
|
||||
|
||||
@NotNull
|
||||
private CalculatorFragmentHelper fragmentHelper;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
|
||||
|
||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.calc_keyboard);
|
||||
fragmentHelper.onCreate(this);
|
||||
|
||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
theme = CalculatorPreferences.Gui.theme.getPreferenceNoError(preferences);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return fragmentHelper.onCreateView(this, inflater, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View root, Bundle savedInstanceState) {
|
||||
super.onViewCreated(root, savedInstanceState);
|
||||
|
||||
fragmentHelper.onViewCreated(this, root);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
this.fragmentHelper.onResume(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
this.fragmentHelper.onPause(this);
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
fragmentHelper.onDestroy(this);
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
|
||||
preferences.unregisterOnSharedPreferenceChangeListener(this);
|
||||
|
||||
}
|
||||
|
||||
/* private static void setMarginsForView(@Nullable View view, int marginLeft, int marginBottom, @NotNull Context context) {
|
||||
// IMPORTANT: this is workaround for probably android bug
|
||||
// currently margin values set in styles are not applied for some reasons to the views (using include tag) => set them manually
|
||||
|
||||
if (view != null) {
|
||||
final DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
||||
if (view.getLayoutParams() instanceof LinearLayout.LayoutParams) {
|
||||
final LinearLayout.LayoutParams oldParams = (LinearLayout.LayoutParams) view.getLayoutParams();
|
||||
final LinearLayout.LayoutParams newParams = new LinearLayout.LayoutParams(oldParams.width, oldParams.height, oldParams.weight);
|
||||
newParams.setMargins(AndroidUtils.toPixels(dm, marginLeft), 0, 0, AndroidUtils.toPixels(dm, marginBottom));
|
||||
view.setLayoutParams(newParams);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
||||
if (AndroidCalculatorEngine.Preferences.numeralBase.getKey().equals(key)) {
|
||||
numeralBaseButtons.toggleNumericDigits(this.getActivity(), preferences);
|
||||
}
|
||||
|
||||
if ( CalculatorPreferences.Gui.showEqualsButton.getKey().equals(key) ) {
|
||||
CalculatorButtons.toggleEqualsButton(preferences, this.getActivity(), theme, getView());
|
||||
}
|
||||
|
||||
if ( AndroidCalculatorEngine.Preferences.multiplicationSign.getKey().equals(key) ) {
|
||||
CalculatorButtons.initMultiplicationButton(getView());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
private static AndroidCalculatorDisplayView getCalculatorDisplayView() {
|
||||
return (AndroidCalculatorDisplayView) CalculatorLocatorImpl.getInstance().getDisplay().getView();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Calculator getCalculator() {
|
||||
return CalculatorLocatorImpl.getInstance().getCalculator();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static CalculatorKeyboard getKeyboard() {
|
||||
return CalculatorLocatorImpl.getInstance().getKeyboard();
|
||||
}
|
||||
}
|
||||
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import com.actionbarsherlock.app.SherlockFragment;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||
|
||||
/**
|
||||
* User: Solovyev_S
|
||||
* Date: 25.09.12
|
||||
* Time: 12:25
|
||||
*/
|
||||
public class CalculatorKeyboardFragment extends SherlockFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
@NotNull
|
||||
private NumeralBaseButtons numeralBaseButtons = new NumeralBaseButtons();
|
||||
|
||||
@NotNull
|
||||
private CalculatorPreferences.Gui.Theme theme;
|
||||
|
||||
@NotNull
|
||||
private CalculatorFragmentHelper fragmentHelper;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
|
||||
|
||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.calc_keyboard);
|
||||
fragmentHelper.onCreate(this);
|
||||
|
||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
theme = CalculatorPreferences.Gui.theme.getPreferenceNoError(preferences);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return fragmentHelper.onCreateView(this, inflater, container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View root, Bundle savedInstanceState) {
|
||||
super.onViewCreated(root, savedInstanceState);
|
||||
|
||||
fragmentHelper.onViewCreated(this, root);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
this.fragmentHelper.onResume(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
this.fragmentHelper.onPause(this);
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
fragmentHelper.onDestroy(this);
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
|
||||
preferences.unregisterOnSharedPreferenceChangeListener(this);
|
||||
|
||||
}
|
||||
|
||||
/* private static void setMarginsForView(@Nullable View view, int marginLeft, int marginBottom, @NotNull Context context) {
|
||||
// IMPORTANT: this is workaround for probably android bug
|
||||
// currently margin values set in styles are not applied for some reasons to the views (using include tag) => set them manually
|
||||
|
||||
if (view != null) {
|
||||
final DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
||||
if (view.getLayoutParams() instanceof LinearLayout.LayoutParams) {
|
||||
final LinearLayout.LayoutParams oldParams = (LinearLayout.LayoutParams) view.getLayoutParams();
|
||||
final LinearLayout.LayoutParams newParams = new LinearLayout.LayoutParams(oldParams.width, oldParams.height, oldParams.weight);
|
||||
newParams.setMargins(AndroidUtils.toPixels(dm, marginLeft), 0, 0, AndroidUtils.toPixels(dm, marginBottom));
|
||||
view.setLayoutParams(newParams);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
||||
if (AndroidCalculatorEngine.Preferences.numeralBase.getKey().equals(key)) {
|
||||
numeralBaseButtons.toggleNumericDigits(this.getActivity(), preferences);
|
||||
}
|
||||
|
||||
if ( CalculatorPreferences.Gui.showEqualsButton.getKey().equals(key) ) {
|
||||
CalculatorButtons.toggleEqualsButton(preferences, this.getActivity());
|
||||
}
|
||||
|
||||
if ( AndroidCalculatorEngine.Preferences.multiplicationSign.getKey().equals(key) ) {
|
||||
CalculatorButtons.initMultiplicationButton(getView());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
private static AndroidCalculatorDisplayView getCalculatorDisplayView() {
|
||||
return (AndroidCalculatorDisplayView) CalculatorLocatorImpl.getInstance().getDisplay().getView();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Calculator getCalculator() {
|
||||
return CalculatorLocatorImpl.getInstance().getCalculator();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static CalculatorKeyboard getKeyboard() {
|
||||
return CalculatorLocatorImpl.getInstance().getKeyboard();
|
||||
}
|
||||
}
|
||||
|
||||
|