Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

animated historybar, tablet ui tweaks

formatting tweaks, disable going back to basic in settings
  • Loading branch information...
commit e6b0399332a0a617925b0975caa50a5d7d6b6c73 1 parent a0bd7b1
Will authored

Showing 26 changed files with 750 additions and 502 deletions. Show diff stats Hide diff stats

  1. +3 3 AndroidManifest.xml
  2. BIN  res/drawable-hdpi/calculator_up_handle.9.png
  3. BIN  res/drawable-hdpi/calculator_up_handle_press.9.png
  4. +66 75 res/layout-land/main.xml
  5. +40 59 res/layout-port/main.xml
  6. +12 18 res/layout-sw600dp-land/advanced_pad.xml
  7. +33 30 res/layout-sw600dp-land/main.xml
  8. +18 11 res/layout-sw600dp/advanced_pad.xml
  9. +32 28 res/layout-sw600dp/main.xml
  10. +2 0  res/layout/history_entry.xml
  11. +1 2  res/layout/history_panel.xml
  12. +6 0 res/layout/preferences.xml
  13. +1 0  res/values/colors.xml
  14. +4 1 res/values/constants.xml
  15. +3 1 res/values/strings.xml
  16. +45 120 src/com/android2/calculator3/Calculator.java
  17. +1 1  src/com/android2/calculator3/CalculatorEditText.java
  18. +1 1  src/com/android2/calculator3/ColorButton.java
  19. +1 1  src/{net/sf/jchemistry/util → com/android2/calculator3}/CommonMathUtils.java
  20. +26 20 src/com/android2/calculator3/EventListener.java
  21. +20 20 src/com/android2/calculator3/Graph.java
  22. +2 2 src/com/android2/calculator3/HistoryTextView.java
  23. +84 93 src/com/android2/calculator3/Logic.java
  24. +35 0 src/com/android2/calculator3/LogicalDensity.java
  25. +301 0 src/com/android2/calculator3/Slider.java
  26. +13 16 src/com/android2/calculator3/WolframAlpha.java
6 AndroidManifest.xml
... ... @@ -1,14 +1,14 @@
1 1 <?xml version="1.0" encoding="utf-8"?>
2 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 3 package="com.android2.calculator3"
4   - android:versionCode="14"
5   - android:versionName="1.5.4"
  4 + android:versionCode="16"
  5 + android:versionName="1.7"
6 6 android:installLocation="auto">
7 7
8 8 <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="16"/>
9 9
10 10 <application android:label="@string/app_name" android:icon="@mipmap/ic_launcher_calculator">
11   - <activity android:name=".Calculator"
  11 + <activity android:name=".Calculator"
12 12 android:theme="@android:style/Theme.Holo.NoActionBar"
13 13 android:windowSoftInputMode="stateAlwaysHidden">
14 14 <intent-filter>
BIN  res/drawable-hdpi/calculator_up_handle.9.png
BIN  res/drawable-hdpi/calculator_up_handle_press.9.png
141 res/layout-land/main.xml
@@ -22,83 +22,74 @@
22 22 android:orientation="vertical"
23 23 android:layout_width="match_parent"
24 24 android:layout_height="match_parent"
25   - android:background="#ff000000"
26   - android:id="@+id/window">
  25 + android:background="@color/background">
27 26 <LinearLayout
28   - android:layout_width="match_parent"
29   - android:layout_height="0dp"
30   - android:layout_weight="2"
31   - >
  27 + android:layout_width="match_parent"
  28 + android:layout_height="0dp"
  29 + android:layout_weight="1.5" >
  30 + <com.android2.calculator3.CalculatorDisplay
  31 + android:id="@+id/display"
  32 + android:layout_width="0dp"
  33 + android:layout_weight="5"
  34 + android:layout_height="match_parent"
  35 + maxDigits="@integer/max_digits">
32 36
33   - <LinearLayout
34   - android:layout_width="match_parent"
35   - android:layout_height="match_parent">
36   - <com.android2.calculator3.CalculatorDisplay
37   - android:id="@+id/display"
38   - android:layout_width="0dp"
39   - android:layout_weight="5"
  37 + <com.android2.calculator3.CalculatorEditText
  38 + style="@style/display_style" />
  39 + <com.android2.calculator3.CalculatorEditText
  40 + style="@style/display_style" />
  41 +
  42 + </com.android2.calculator3.CalculatorDisplay>
  43 + <ImageButton android:id="@+id/overflow_menu"
  44 + android:layout_width="48dip"
  45 + android:layout_height="match_parent"
  46 + android:src="@drawable/ic_menu_overflow"
  47 + android:background="@android:color/transparent"
  48 + android:layout_marginLeft="8dip"
  49 + android:visibility="gone"
  50 + android:contentDescription="@null"/>
  51 + <FrameLayout
  52 + android:layout_width="0dp"
  53 + android:layout_weight="1"
  54 + android:layout_height="match_parent">
  55 + <!-- marginRight has to be 0 to catch border-touch -->
  56 + <com.android2.calculator3.ColorButton
  57 + android:id="@+id/clear"
  58 + android:text="@string/clear"
  59 + android:layout_width="match_parent"
  60 + android:layout_height="match_parent"
  61 + android:layout_marginRight="0dp"
  62 + android:textSize="15dp"
  63 + style="@style/button_style"
  64 + />
  65 + <!-- marginRight has to be 0 to catch border-touch -->
  66 + <com.android2.calculator3.ColorButton
  67 + android:id="@+id/del"
  68 + android:text="@string/del"
  69 + android:layout_width="match_parent"
40 70 android:layout_height="match_parent"
41   - maxDigits="@integer/max_digits">
42   -
43   - <com.android2.calculator3.CalculatorEditText
44   - style="@style/display_style" />
45   - <com.android2.calculator3.CalculatorEditText
46   - style="@style/display_style" />
47   -
48   - </com.android2.calculator3.CalculatorDisplay>
49   - <ImageButton android:id="@+id/overflow_menu"
50   - android:layout_width="48dip"
51   - android:layout_height="match_parent"
52   - android:src="@drawable/ic_menu_overflow"
53   - android:background="@android:color/transparent"
54   - android:layout_marginLeft="8dip"
55   - android:visibility="gone"
56   - android:contentDescription="@null"/>
57   - <FrameLayout
58   - android:layout_width="0dp"
59   - android:layout_weight="1"
60   - android:layout_height="match_parent">
61   - <!-- marginRight has to be 0 to catch border-touch -->
62   - <com.android2.calculator3.ColorButton
63   - android:id="@+id/clear"
64   - android:text="@string/clear"
65   - android:layout_width="match_parent"
66   - android:layout_height="match_parent"
67   - android:layout_marginRight="0dp"
68   - android:textSize="15dp"
69   - style="@style/button_style"
70   - />
71   - <!-- marginRight has to be 0 to catch border-touch -->
72   - <com.android2.calculator3.ColorButton
73   - android:id="@+id/del"
74   - android:text="@string/del"
75   - android:layout_width="match_parent"
76   - android:layout_height="match_parent"
77   - android:layout_marginRight="0dp"
78   - android:textSize="15dp"
79   - style="@style/button_style"
80   - />
81   - </FrameLayout>
82   - </LinearLayout>
83   - <include layout="@layout/history_panel"/>
  71 + android:layout_marginRight="0dp"
  72 + android:textSize="15dp"
  73 + style="@style/button_style"
  74 + />
  75 + </FrameLayout>
84 76 </LinearLayout>
85   -
86   - <ImageButton
87   - android:id="@+id/pulldown"
88   - android:src="@drawable/pulldown_down"
89   - android:background="@android:color/transparent"
90   - android:layout_width="match_parent"
91   - android:layout_height="21dp"
92   - android:paddingTop="4dp"
93   - android:paddingBottom="4dp"
94   - android:contentDescription="@null"
95   - android:scaleType="fitXY" />
96   -
97   - <com.android2.calculator3.CalculatorViewPager
98   - android:id="@+id/panelswitch"
99   - android:layout_width="match_parent"
100   - android:layout_height="0dp"
101   - android:layout_weight="4"
102   - />
103   -
  77 + <RelativeLayout
  78 + android:layout_width="match_parent"
  79 + android:layout_height="0dp"
  80 + android:layout_weight="4">
  81 + <com.android2.calculator3.Slider
  82 + android:id="@+id/pulldown"
  83 + android:layout_width="match_parent"
  84 + android:layout_height="match_parent"
  85 + android:background="@color/background"
  86 + android:scrollbarThumbHorizontal="@drawable/pulldown_up" >
  87 + <include layout="@layout/history_panel" />
  88 + </com.android2.calculator3.Slider>
  89 + <com.android2.calculator3.CalculatorViewPager
  90 + android:id="@+id/panelswitch"
  91 + android:layout_width="match_parent"
  92 + android:layout_height="match_parent"
  93 + android:layout_marginTop="@integer/barHeight" />
  94 + </RelativeLayout>
104 95 </LinearLayout>
99 res/layout-port/main.xml
@@ -22,9 +22,7 @@
22 22 android:orientation="vertical"
23 23 android:layout_width="match_parent"
24 24 android:layout_height="match_parent"
25   - android:background="#ff000000"
26   - android:id="@+id/window">
27   -
  25 + android:background="@color/background">
28 26 <LinearLayout
29 27 android:layout_width="match_parent"
30 28 android:layout_height="0dip"
@@ -32,59 +30,35 @@
32 30 android:orientation="horizontal"
33 31 android:layout_gravity="center_vertical"
34 32 android:gravity="center_vertical">
35   -
36   - <LinearLayout
37   - android:layout_width="match_parent"
38   - android:layout_height="match_parent">
39   - <com.android2.calculator3.CalculatorDisplay
40   - android:id="@+id/display"
41   - android:layout_width="0dip"
42   - android:layout_height="match_parent"
43   - android:layout_weight="1"
44   - maxDigits="@integer/max_digits">
45   -
46   - <com.android2.calculator3.CalculatorEditText
47   - style="@style/display_style" />
48   - <com.android2.calculator3.CalculatorEditText
49   - style="@style/display_style" />
50   -
51   - </com.android2.calculator3.CalculatorDisplay>
52   - <ImageButton android:id="@+id/overflow_menu"
53   - android:layout_width="48dip"
54   - android:layout_height="match_parent"
55   - android:src="@drawable/ic_menu_overflow"
56   - android:background="@android:color/transparent"
57   - android:layout_marginLeft="8dip"
58   - android:visibility="gone"
59   - android:contentDescription="@null"/>
60   - </LinearLayout>
61   - <include layout="@layout/history_panel"/>
  33 + <com.android2.calculator3.CalculatorDisplay
  34 + android:id="@+id/display"
  35 + android:layout_width="0dip"
  36 + android:layout_height="match_parent"
  37 + android:layout_weight="1"
  38 + maxDigits="@integer/max_digits">
  39 + <com.android2.calculator3.CalculatorEditText
  40 + style="@style/display_style" />
  41 + <com.android2.calculator3.CalculatorEditText
  42 + style="@style/display_style" />
  43 + </com.android2.calculator3.CalculatorDisplay>
  44 + <ImageButton android:id="@+id/overflow_menu"
  45 + android:layout_width="48dip"
  46 + android:layout_height="match_parent"
  47 + android:src="@drawable/ic_menu_overflow"
  48 + android:background="@android:color/transparent"
  49 + android:layout_marginLeft="8dip"
  50 + android:visibility="gone"
  51 + android:contentDescription="@null"/>
62 52 </LinearLayout>
63   -
64   - <ImageButton
65   - android:id="@+id/pulldown"
66   - android:src="@drawable/pulldown_down"
67   - android:background="@android:color/transparent"
68   - android:layout_width="match_parent"
69   - android:layout_height="21dp"
70   - android:paddingTop="4dp"
71   - android:paddingBottom="4dp"
72   - android:contentDescription="@null"
73   - android:scaleType="fitXY" />
74   -
75 53 <LinearLayout
76 54 android:layout_width="match_parent"
77 55 android:layout_height="0dp"
78   - android:layout_weight="1.5"
79   - >
80   -
  56 + android:layout_weight="1.5" >
81 57 <View
82 58 android:background="@drawable/btn_function"
83 59 android:layout_width="0dp"
84 60 android:layout_height="match_parent"
85   - android:layout_weight="3"
86   - />
87   -
  61 + android:layout_weight="3" />
88 62 <FrameLayout
89 63 android:layout_width="0dp"
90 64 android:layout_weight="1"
@@ -97,8 +71,7 @@
97 71 android:layout_height="match_parent"
98 72 android:layout_marginRight="0dp"
99 73 android:textSize="15dp"
100   - style="@style/button_style"
101   - />
  74 + style="@style/button_style" />
102 75 <!-- marginRight has to be 0 to catch border-touch -->
103 76 <com.android2.calculator3.ColorButton
104 77 android:id="@+id/del"
@@ -107,17 +80,25 @@
107 80 android:layout_height="match_parent"
108 81 android:layout_marginRight="0dp"
109 82 android:textSize="15dp"
110   - style="@style/button_style"
111   - />
  83 + style="@style/button_style" />
112 84 </FrameLayout>
113   -
114 85 </LinearLayout>
115   -
116   - <com.android2.calculator3.CalculatorViewPager
117   - android:id="@+id/panelswitch"
  86 + <RelativeLayout
118 87 android:layout_width="match_parent"
119 88 android:layout_height="0dp"
120   - android:layout_weight="10"
121   - />
122   -
  89 + android:layout_weight="10" >
  90 + <com.android2.calculator3.Slider
  91 + android:id="@+id/pulldown"
  92 + android:layout_width="match_parent"
  93 + android:layout_height="match_parent"
  94 + android:background="@color/background"
  95 + android:scrollbarThumbHorizontal="@drawable/pulldown_up" >
  96 + <include layout="@layout/history_panel" />
  97 + </com.android2.calculator3.Slider>
  98 + <com.android2.calculator3.CalculatorViewPager
  99 + android:id="@+id/panelswitch"
  100 + android:layout_width="match_parent"
  101 + android:layout_height="match_parent"
  102 + android:layout_marginTop="@integer/barHeight" />
  103 + </RelativeLayout>
123 104 </LinearLayout>
30 res/layout-sw600dp-land/advanced_pad.xml
@@ -30,26 +30,23 @@
30 30 android:text="@string/sin"
31 31 style="@style/btn_function_cell_style" />
32 32 <com.android2.calculator3.ColorButton
33   - android:id="@+id/ln"
34   - android:text="@string/ln"
35   - style="@style/btn_function_cell_style" />
36   - </LinearLayout>
37   - <LinearLayout
38   - style="@style/btn_row_style">
39   - <com.android2.calculator3.ColorButton
40 33 android:id="@+id/cos"
41 34 android:text="@string/cos"
42 35 style="@style/btn_function_cell_style" />
43 36 <com.android2.calculator3.ColorButton
44   - android:id="@+id/lg"
45   - android:text="@string/lg"
  37 + android:id="@+id/tan"
  38 + android:text="@string/tan"
46 39 style="@style/btn_function_cell_style" />
47 40 </LinearLayout>
48 41 <LinearLayout
49 42 style="@style/btn_row_style">
50 43 <com.android2.calculator3.ColorButton
51   - android:id="@+id/tan"
52   - android:text="@string/tan"
  44 + android:id="@+id/lg"
  45 + android:text="@string/lg"
  46 + style="@style/btn_function_cell_style" />
  47 + <com.android2.calculator3.ColorButton
  48 + android:id="@+id/ln"
  49 + android:text="@string/ln"
53 50 style="@style/btn_function_cell_style" />
54 51 <com.android2.calculator3.ColorButton
55 52 android:id="@+id/e"
@@ -63,6 +60,10 @@
63 60 android:text="@string/pi"
64 61 style="@style/btn_function_cell_style" />
65 62 <com.android2.calculator3.ColorButton
  63 + android:id="@+id/i"
  64 + android:text="@string/i"
  65 + style="@style/btn_function_cell_style" />
  66 + <com.android2.calculator3.ColorButton
66 67 android:id="@+id/power"
67 68 android:text="@string/power"
68 69 style="@style/btn_function_cell_style" />
@@ -77,13 +78,6 @@
77 78 android:id="@+id/sqrt"
78 79 android:text="@string/sqrt"
79 80 style="@style/btn_function_cell_style" />
80   - </LinearLayout>
81   - <LinearLayout
82   - style="@style/btn_row_style">
83   - <com.android2.calculator3.ColorButton
84   - android:id="@+id/i"
85   - android:text="@string/i"
86   - style="@style/btn_function_cell_style" />
87 81 <com.android2.calculator3.ColorButton
88 82 android:id="@+id/percentage"
89 83 android:text="@string/percentage"
63 res/layout-sw600dp-land/main.xml
@@ -21,7 +21,7 @@
21 21 android:orientation="vertical"
22 22 android:layout_width="match_parent"
23 23 android:layout_height="match_parent"
24   - android:background="#ff000000"
  24 + android:background="@color/background"
25 25 android:paddingLeft="@dimen/left_right_padding"
26 26 android:paddingRight="@dimen/left_right_padding"
27 27 android:id="@+id/window">
@@ -81,37 +81,40 @@
81 81 </LinearLayout>
82 82 <include layout="@layout/history_panel"/>
83 83 </LinearLayout>
84   -
85   - <ImageButton
86   - android:id="@+id/pulldown"
87   - android:src="@drawable/pulldown_down"
88   - android:background="@android:color/transparent"
89   - android:layout_width="match_parent"
90   - android:layout_height="21dp"
91   - android:paddingTop="4dp"
92   - android:paddingBottom="4dp"
93   - android:contentDescription="@null"
94   - android:scaleType="fitXY" />
95   -
96   - <LinearLayout
  84 + <RelativeLayout
97 85 android:layout_width="match_parent"
98 86 android:layout_height="0dip"
99   - android:layout_weight="4"
100   - android:orientation="horizontal">
101   -
102   - <com.android2.calculator3.CalculatorViewPager
103   - android:id="@+id/smallPanelswitch"
104   - android:layout_width="0dip"
  87 + android:layout_weight="4">
  88 +
  89 + <com.android2.calculator3.Slider
  90 + android:id="@+id/pulldown"
  91 + android:layout_width="match_parent"
105 92 android:layout_height="match_parent"
106   - android:layout_weight="2"
107   - android:layout_marginRight="@dimen/group_padding"
108   - />
  93 + android:background="@color/background"
  94 + android:scrollbarThumbHorizontal="@drawable/pulldown_up" >
  95 + <include layout="@layout/history_panel" />
  96 + </com.android2.calculator3.Slider>
109 97
110   - <com.android2.calculator3.CalculatorViewPager
111   - android:id="@+id/largePanelswitch"
112   - android:layout_width="0dip"
113   - android:layout_height="match_parent"
114   - android:layout_weight="5"
115   - />
116   - </LinearLayout>
  98 + <LinearLayout
  99 + android:layout_width="match_parent"
  100 + android:layout_height="match_parent"
  101 + android:orientation="horizontal"
  102 + android:layout_marginTop="@integer/barHeight">
  103 +
  104 + <com.android2.calculator3.CalculatorViewPager
  105 + android:id="@+id/smallPanelswitch"
  106 + android:layout_width="0dip"
  107 + android:layout_height="match_parent"
  108 + android:layout_weight="3"
  109 + android:layout_marginRight="@dimen/group_padding"
  110 + />
  111 +
  112 + <com.android2.calculator3.CalculatorViewPager
  113 + android:id="@+id/largePanelswitch"
  114 + android:layout_width="0dip"
  115 + android:layout_height="match_parent"
  116 + android:layout_weight="5"
  117 + />
  118 + </LinearLayout>
  119 + </RelativeLayout>
117 120 </LinearLayout>
29 res/layout-sw600dp/advanced_pad.xml
@@ -47,14 +47,6 @@
47 47 android:id="@+id/factorial"
48 48 android:text="@string/factorial"
49 49 style="@style/btn_function_cell_style" />
50   - <com.android2.calculator3.ColorButton
51   - android:id="@+id/i"
52   - android:text="@string/i"
53   - style="@style/btn_function_cell_style" />
54   - <com.android2.calculator3.ColorButton
55   - android:id="@+id/X"
56   - android:text="@string/X"
57   - style="@style/btn_digit_cell_style" />
58 50 </LinearLayout>
59 51 <LinearLayout
60 52 style="@style/btn_row_style">
@@ -78,14 +70,29 @@
78 70 android:id="@+id/sqrt"
79 71 android:text="@string/sqrt"
80 72 style="@style/btn_function_cell_style" />
  73 + </LinearLayout>
  74 + <LinearLayout
  75 + style="@style/btn_row_style">
81 76 <com.android2.calculator3.ColorButton
82   - android:id="@+id/percentage"
83   - android:text="@string/percentage"
84   - style="@style/btn_function_cell_style" />
  77 + android:id="@+id/X"
  78 + android:text="@string/X"
  79 + style="@style/btn_digit_cell_style" />
85 80 <com.android2.calculator3.ColorButton
86 81 android:id="@+id/Y"
87 82 android:text="@string/Y"
88 83 style="@style/btn_digit_cell_style" />
  84 + <com.android2.calculator3.ColorButton
  85 + android:id="@+id/percentage"
  86 + android:text="@string/percentage"
  87 + style="@style/btn_function_cell_style" />
  88 + <com.android2.calculator3.ColorButton
  89 + android:id="@+id/i"
  90 + android:text="@string/i"
  91 + style="@style/btn_function_cell_style" />
  92 + <com.android2.calculator3.ColorButton
  93 + android:id="@+id/parentheses"
  94 + android:text="@string/parentheses"
  95 + style="@style/btn_function_cell_style" />
89 96 </LinearLayout>
90 97
91 98 </LinearLayout>
60 res/layout-sw600dp/main.xml
@@ -22,7 +22,7 @@
22 22 android:orientation="vertical"
23 23 android:layout_width="match_parent"
24 24 android:layout_height="match_parent"
25   - android:background="#ff000000"
  25 + android:background="@color/background"
26 26 android:paddingLeft="@dimen/left_right_padding"
27 27 android:paddingRight="@dimen/left_right_padding"
28 28 android:id="@+id/window">
@@ -82,32 +82,36 @@
82 82 </FrameLayout>
83 83
84 84 </LinearLayout>
85   - <include layout="@layout/history_panel"/>
86 85 </LinearLayout>
87   -
88   - <ImageButton
89   - android:id="@+id/pulldown"
90   - android:src="@drawable/pulldown_down"
91   - android:background="@android:color/transparent"
92   - android:layout_width="match_parent"
93   - android:layout_height="21dp"
94   - android:paddingTop="4dp"
95   - android:paddingBottom="4dp"
96   - android:contentDescription="@null"
97   - android:scaleType="fitXY" />
98   -
99   - <com.android2.calculator3.CalculatorViewPager
100   - android:id="@+id/smallPanelswitch"
101   - android:layout_width="match_parent"
102   - android:layout_height="0dp"
103   - android:layout_weight="2"
104   - android:layout_marginBottom="@dimen/group_padding"
105   - />
106   -
107   - <com.android2.calculator3.CalculatorViewPager
108   - android:id="@+id/largePanelswitch"
109   - android:layout_width="match_parent"
110   - android:layout_height="0dp"
111   - android:layout_weight="5"
112   - />
  86 + <RelativeLayout
  87 + android:layout_width="match_parent"
  88 + android:layout_height="0dp"
  89 + android:layout_weight="7">
  90 + <com.android2.calculator3.Slider
  91 + android:id="@+id/pulldown"
  92 + android:layout_width="match_parent"
  93 + android:layout_height="match_parent"
  94 + android:background="@color/background"
  95 + android:scrollbarThumbHorizontal="@drawable/pulldown_up" >
  96 + <include layout="@layout/history_panel" />
  97 + </com.android2.calculator3.Slider>
  98 + <LinearLayout
  99 + android:layout_width="match_parent"
  100 + android:layout_height="match_parent"
  101 + android:orientation="vertical"
  102 + android:layout_marginTop="@integer/barHeight">
  103 + <com.android2.calculator3.CalculatorViewPager
  104 + android:id="@+id/smallPanelswitch"
  105 + android:layout_width="match_parent"
  106 + android:layout_height="0dp"
  107 + android:layout_weight="2"
  108 + android:layout_marginBottom="@dimen/group_padding" />
  109 +
  110 + <com.android2.calculator3.CalculatorViewPager
  111 + android:id="@+id/largePanelswitch"
  112 + android:layout_width="match_parent"
  113 + android:layout_height="0dp"
  114 + android:layout_weight="5" />
  115 + </LinearLayout>
  116 + </RelativeLayout>
113 117 </LinearLayout>
2  res/layout/history_entry.xml
@@ -11,6 +11,8 @@
11 11 android:layout_width="wrap_content"
12 12 android:layout_height="wrap_content"
13 13 android:textSize="@dimen/display_text_size"
  14 + android:paddingLeft="8dp"
  15 + android:paddingRight="8dp"
14 16 android:text="@string/equal"/>
15 17 <com.android2.calculator3.HistoryTextView
16 18 android:layout_width="wrap_content"
3  res/layout/history_panel.xml
... ... @@ -1,8 +1,7 @@
1 1 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
2 2 android:layout_width="match_parent"
3 3 android:layout_height="match_parent"
4   - android:isScrollContainer="true"
5   - android:visibility="gone">
  4 + android:isScrollContainer="true">
6 5 <LinearLayout
7 6 android:layout_width="match_parent"
8 7 android:layout_height="wrap_content"
6 res/layout/preferences.xml
@@ -26,4 +26,10 @@
26 26 android:key="MATRIX"
27 27 android:defaultValue="@bool/MATRIX" />
28 28 </PreferenceCategory>
  29 + <PreferenceCategory>
  30 + <CheckBoxPreference
  31 + android:title="@string/returnToBasic"
  32 + android:key="RETURN_TO_BASIC"
  33 + android:defaultValue="@bool/RETURN_TO_BASIC" />
  34 + </PreferenceCategory>
29 35 </PreferenceScreen>
1  res/values/colors.xml
@@ -19,4 +19,5 @@
19 19 <color name="button_text">#FFFFFFFF</color>
20 20 <color name="pressed_color">#07547B</color>
21 21 <color name="history_result">#FFC40C</color>
  22 + <color name="background">#ff000000</color>
22 23 </resources>
5 res/values/constants.xml
@@ -14,7 +14,7 @@
14 14 limitations under the License.
15 15 -->
16 16
17   -<resources>
  17 +<resources xmlns:android="http://schemas.android.com/apk/res/android">
18 18 <integer name="max_digits">14</integer>
19 19 <item type="bool" name="GRAPH">true</item>
20 20 <item type="bool" name="FUNCTION">false</item>
@@ -22,4 +22,7 @@
22 22 <item type="bool" name="BASIC">true</item>
23 23 <item type="bool" name="ADVANCED">true</item>
24 24 <item type="bool" name="MATRIX">true</item>
  25 + <item type="bool" name="RETURN_TO_BASIC">true</item>
  26 + <item type="integer" name="barHeight">25dp</item>
  27 + <item type="string" name="wolframAlphaKey">T2YJW3-7XQX257LAP</item>
25 28 </resources>
4 res/values/strings.xml
@@ -148,4 +148,6 @@
148 148
149 149 <string name="settings">Settings</string>
150 150 <string name="showHistory">Show History</string>
151   - <string name="hideHistory">Hide History</string> </resources>
  151 + <string name="hideHistory">Hide History</string>
  152 +
  153 + <string name="returnToBasic">Return to the basic panel</string> </resources>
165 src/com/android2/calculator3/Calculator.java
@@ -17,6 +17,10 @@
17 17 package com.android2.calculator3;
18 18
19 19 import org.achartengine.GraphicalView;
  20 +
  21 +import com.android2.calculator3.Slider.Direction;
  22 +import com.android2.calculator3.Slider.OnSlideListener;
  23 +
20 24 import android.app.Activity;
21 25 import android.content.Intent;
22 26 import android.content.SharedPreferences;
@@ -30,23 +34,20 @@
30 34 import android.view.LayoutInflater;
31 35 import android.view.Menu;
32 36 import android.view.MenuItem;
33   -import android.view.MotionEvent;
34 37 import android.view.View;
35 38 import android.view.View.OnClickListener;
36 39 import android.view.View.OnLongClickListener;
37   -import android.view.View.OnTouchListener;
38 40 import android.view.ViewGroup.LayoutParams;
39 41 import android.view.ViewConfiguration;
40 42 import android.view.ViewGroup;
41 43 import android.view.WindowManager;
42   -import android.widget.ImageButton;
43 44 import android.widget.LinearLayout;
44 45 import android.widget.PopupMenu;
45 46 import android.widget.PopupMenu.OnMenuItemClickListener;
46 47 import android.widget.TextView;
47 48
48 49 public class Calculator extends Activity implements PanelSwitcher.Listener, Logic.Listener,
49   - OnClickListener, OnMenuItemClickListener, OnTouchListener, OnLongClickListener {
  50 + OnClickListener, OnMenuItemClickListener, OnLongClickListener {
50 51 EventListener mListener = new EventListener();
51 52 private CalculatorDisplay mDisplay;
52 53 private Persist mPersist;
@@ -59,16 +60,8 @@
59 60 private View mClearButton;
60 61 private View mBackspaceButton;
61 62 private View mOverflowMenuButton;
62   - private ImageButton mPulldown;
63   - private View mWindow;
  63 + private Slider mPulldown;
64 64 private Graph mGraph;
65   - private int mDistance;
66   - private int mDefaultDisplayHeight;
67   - private int mDefaultPulldownHeight;
68   - private int mWindowHeight;
69   - private int mWindowWidth;
70   - private boolean heightSet = false;
71   - private boolean showingHistory = false;
72 65 private SharedPreferences mPreferences;
73 66
74 67 public enum Panel {
@@ -83,7 +76,7 @@ public int getOrder() {
83 76 return order;
84 77 }
85 78 }
86   -
  79 +
87 80 public enum SmallPanel {
88 81 HEX, ADVANCED, FUNCTION;
89 82
@@ -96,7 +89,7 @@ public int getOrder() {
96 89 return order;
97 90 }
98 91 }
99   -
  92 +
100 93 public enum LargePanel {
101 94 GRAPH, BASIC, MATRIX;
102 95
@@ -126,9 +119,6 @@ public void onCreate(Bundle state) {
126 119
127 120 mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
128 121 setContentView(R.layout.main);
129   - mWindow = findViewById(R.id.window);
130   - heightSet = false;
131   - mHistoryView = (LinearLayout) findViewById(R.id.history);
132 122 mPager = (ViewPager) findViewById(R.id.panelswitch);
133 123 mSmallPager = (ViewPager) findViewById(R.id.smallPanelswitch);
134 124 mLargePager = (ViewPager) findViewById(R.id.largePanelswitch);
@@ -151,18 +141,19 @@ public void onCreate(Bundle state) {
151 141
152 142 mDisplay = (CalculatorDisplay) findViewById(R.id.display);
153 143
154   - mPulldown = (ImageButton) findViewById(R.id.pulldown);
155   - mPulldown.setOnTouchListener(this);
156   - mPulldown.setOnClickListener(new OnClickListener() {
  144 + mPulldown = (Slider) findViewById(R.id.pulldown);
  145 + mPulldown.setBarHeight((int) LogicalDensity.convertDpToPixel(25, this));
  146 + mPulldown.setSlideDirection(Direction.DOWN);
  147 + mPulldown.setOnSlideListener(new OnSlideListener() {
157 148 @Override
158   - public void onClick(View v) {
159   - if(showingHistory) {
160   - minimizeHistory();
161   - } else {
162   - maximizeHistory();
  149 + public void onSlide(Direction d) {
  150 + if(d.equals(Direction.UP)) {
  151 + setUpHistory();
163 152 }
164 153 }
165 154 });
  155 + mHistoryView = (LinearLayout) mPulldown.findViewById(R.id.history);
  156 + setUpHistory();
166 157
167 158 mLogic = new Logic(this, mHistory, mDisplay);
168 159 mLogic.setListener(this);
@@ -196,10 +187,7 @@ else if (mSmallPager != null && mLargePager != null) {
196 187 updateDeleteMode();
197 188
198 189 mGraph = new Graph(mLogic);
199   -
200   - if(showingHistory) {
201   - maximizeHistory();
202   - }
  190 + mPulldown.bringToFront();
203 191 }
204 192
205 193 private void updateDeleteMode() {
@@ -229,33 +217,32 @@ public boolean onPrepareOptionsMenu(Menu menu) {
229 217 super.onPrepareOptionsMenu(menu);
230 218
231 219 MenuItem mShowHistory = menu.findItem(R.id.show_history);
232   - mShowHistory.setVisible(!showingHistory);
  220 + mShowHistory.setVisible(!mPulldown.isSliderOpen());
233 221
234 222 MenuItem mHideHistory = menu.findItem(R.id.hide_history);
235   - mHideHistory.setVisible(showingHistory);
  223 + mHideHistory.setVisible(mPulldown.isSliderOpen());
236 224
237 225 MenuItem mMatrixPanel = menu.findItem(R.id.matrix);
238 226 if(mMatrixPanel != null) mMatrixPanel.setVisible(!getMatrixVisibility() && mPreferences.getBoolean(Panel.MATRIX.toString(), getResources().getBoolean(R.bool.MATRIX)));
239   -
  227 +
240 228 MenuItem mGraphPanel = menu.findItem(R.id.graph);
241 229 if(mGraphPanel != null) mGraphPanel.setVisible(!getGraphVisibility() && mPreferences.getBoolean(Panel.GRAPH.toString(), getResources().getBoolean(R.bool.GRAPH)));
242   -
  230 +
243 231 MenuItem mFunctionPanel = menu.findItem(R.id.function);
244 232 if(mFunctionPanel != null) mFunctionPanel.setVisible(!getFunctionVisibility() && mPreferences.getBoolean(Panel.FUNCTION.toString(), getResources().getBoolean(R.bool.FUNCTION)));
245   -
  233 +
246 234 MenuItem mBasicPanel = menu.findItem(R.id.basic);
247 235 if(mBasicPanel != null) mBasicPanel.setVisible(!getBasicVisibility() && mPreferences.getBoolean(Panel.BASIC.toString(), getResources().getBoolean(R.bool.BASIC)));
248   -
  236 +
249 237 MenuItem mAdvancedPanel = menu.findItem(R.id.advanced);
250 238 if(mAdvancedPanel != null) mAdvancedPanel.setVisible(!getAdvancedVisibility() && mPreferences.getBoolean(Panel.ADVANCED.toString(), getResources().getBoolean(R.bool.ADVANCED)));
251   -
  239 +
252 240 MenuItem mHexPanel = menu.findItem(R.id.hex);
253 241 if(mHexPanel != null) mHexPanel.setVisible(!getHexVisibility() && mPreferences.getBoolean(Panel.HEX.toString(), getResources().getBoolean(R.bool.HEX)));
254   -
  242 +
255 243 return true;
256 244 }
257 245
258   -
259 246 private void createFakeMenu() {
260 247 mOverflowMenuButton = findViewById(R.id.overflow_menu);
261 248 if (mOverflowMenuButton != null) {
@@ -285,7 +272,6 @@ private PopupMenu constructPopupMenu() {
285 272 return popupMenu;
286 273 }
287 274
288   -
289 275 @Override
290 276 public boolean onMenuItemClick(MenuItem item) {
291 277 return onOptionsItemSelected(item);
@@ -300,7 +286,7 @@ else if(mLargePager != null) {
300 286 }
301 287 return false;
302 288 }
303   -
  289 +
304 290 private boolean getFunctionVisibility() {
305 291 // if(mPager != null) {
306 292 // return mPager.getCurrentItem() == Panel.FUNCTION.getOrder() && mPreferences.getBoolean(Panel.FUNCTION.toString(), getResources().getBoolean(R.bool.FUNCTION));
@@ -310,7 +296,7 @@ private boolean getFunctionVisibility() {
310 296 // }
311 297 return false;
312 298 }
313   -
  299 +
314 300 private boolean getBasicVisibility() {
315 301 if(mPager != null) {
316 302 return mPager.getCurrentItem() == Panel.BASIC.getOrder() && mPreferences.getBoolean(Panel.BASIC.toString(), getResources().getBoolean(R.bool.BASIC));
@@ -330,7 +316,7 @@ else if(mSmallPager != null) {
330 316 }
331 317 return false;
332 318 }
333   -
  319 +
334 320 private boolean getHexVisibility() {
335 321 if(mPager != null) {
336 322 return mPager.getCurrentItem() == Panel.HEX.getOrder() && mPreferences.getBoolean(Panel.HEX.toString(), getResources().getBoolean(R.bool.HEX));
@@ -340,7 +326,7 @@ else if(mSmallPager != null) {
340 326 }
341 327 return false;
342 328 }
343   -
  329 +
344 330 private boolean getMatrixVisibility() {
345 331 if(mPager != null) {
346 332 return mPager.getCurrentItem() == Panel.MATRIX.getOrder() && mPreferences.getBoolean(Panel.MATRIX.toString(), getResources().getBoolean(R.bool.MATRIX));
@@ -361,11 +347,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
361 347 break;
362 348
363 349 case R.id.show_history:
364   - maximizeHistory();
  350 + mPulldown.animateSliderUp();
365 351 break;
366 352
367 353 case R.id.hide_history:
368   - minimizeHistory();
  354 + mPulldown.animateSliderDown();
369 355 break;
370 356
371 357 case R.id.basic:
@@ -422,20 +408,20 @@ public boolean onOptionsItemSelected(MenuItem item) {
422 408 @Override
423 409 protected void onSaveInstanceState(Bundle state) {
424 410 super.onSaveInstanceState(state);
425   -
  411 +
426 412 if (mPager != null) {
427 413 state.putInt(STATE_CURRENT_VIEW, mPager.getCurrentItem());
428 414 }
429   -
  415 +
430 416 if (mSmallPager != null) {
431 417 state.putInt(STATE_CURRENT_VIEW_SMALL, mSmallPager.getCurrentItem());
432 418 }
433   -
  419 +
434 420 if (mLargePager != null) {
435 421 state.putInt(STATE_CURRENT_VIEW_LARGE, mLargePager.getCurrentItem());
436 422 }
437 423 }
438   -
  424 +
439 425 @Override
440 426 public void onPause() {
441 427 super.onPause();
@@ -447,8 +433,8 @@ public void onPause() {
447 433
448 434 @Override
449 435 public boolean onKeyDown(int keyCode, KeyEvent keyEvent) {
450   - if(keyCode == KeyEvent.KEYCODE_BACK && showingHistory) {
451   - minimizeHistory();
  436 + if(keyCode == KeyEvent.KEYCODE_BACK && mPulldown.isSliderOpen()) {
  437 + mPulldown.animateSliderDown();
452 438 return true;
453 439 }
454 440 else if(keyCode == KeyEvent.KEYCODE_BACK && mPager != null && (getAdvancedVisibility() || getFunctionVisibility() || getGraphVisibility() || getMatrixVisibility() || getHexVisibility()) && mPreferences.getBoolean(Panel.BASIC.toString(), getResources().getBoolean(R.bool.BASIC))) {
@@ -479,68 +465,20 @@ public void onDeleteModeChange() {
479 465 updateDeleteMode();
480 466 }
481 467
482   - @Override
483   - public boolean onTouch(View v, MotionEvent event) {
484   - switch (event.getAction()) {
485   - case MotionEvent.ACTION_DOWN:
486   - if(showingHistory) {
487   - mPulldown.setImageResource(R.drawable.calculator_up_handle_press);
488   - } else {
489   - mPulldown.setImageResource(R.drawable.calculator_down_handle_press);
490   - }
491   - break;
492   - case MotionEvent.ACTION_UP:
493   - if(((View) mDisplay.getParent().getParent()).getHeight() > mWindowHeight/2) {
494   - maximizeHistory();
495   - } else{
496   - minimizeHistory();
497   - }
498   - break;
499   - case MotionEvent.ACTION_MOVE:
500   - if(mDistance == mWindowHeight-mDefaultPulldownHeight && event.getY() > 0) break;
501   - if(mDistance == mDefaultDisplayHeight && event.getY() < 0) break;
502   - mDistance += event.getY();
503   - if(mDistance > mWindowHeight-mDefaultPulldownHeight && event.getY() > 0) mDistance = mWindowHeight-mDefaultPulldownHeight;
504   - if(mDistance < mDefaultDisplayHeight && event.getY() < 0) mDistance = mDefaultDisplayHeight;
505   - ((View) mDisplay.getParent().getParent()).setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mDistance));
506   - break;
507   - }
508   - return false;
509   - }
510   -
511   - private void minimizeHistory() {
512   - ((View) mDisplay.getParent().getParent()).setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mDefaultDisplayHeight));
513   - mDistance = mDefaultDisplayHeight;
514   - ((View) mDisplay.getParent()).setVisibility(View.VISIBLE);
515   - ((View) mHistoryView.getParent()).setVisibility(View.GONE);
516   - showingHistory = false;
517   - mPulldown.setImageResource(R.drawable.calculator_down_handle);
518   - }
519   -
520   - private void maximizeHistory() {
521   - setUpHistory();
522   - ((View) mDisplay.getParent().getParent()).setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mWindowHeight-mDefaultPulldownHeight));
523   - mDistance = mWindowHeight-mDefaultPulldownHeight;
524   - ((View) mDisplay.getParent()).setVisibility(View.GONE);
525   - ((View) mHistoryView.getParent()).setVisibility(View.VISIBLE);
526   - showingHistory = true;
527   - mPulldown.setImageResource(R.drawable.calculator_up_handle);
528   - }
529   -
530 468 private void setUpHistory() {
531 469 mHistoryView.removeAllViews();
532 470 final LayoutInflater inflater = LayoutInflater.from(this);
533 471 for(HistoryEntry he : mHistory.mEntries) {
534 472 if(!he.getBase().isEmpty()) {
535   - View entry = inflater.inflate(R.layout.history_entry, null);
  473 + LinearLayout entry = (LinearLayout) inflater.inflate(R.layout.history_entry, null);
536 474 TextView base = (TextView) entry.findViewById(R.id.base);
537 475 base.setOnLongClickListener(this);
538   - base.setMaxWidth(mWindowWidth/2);
  476 + base.setMaxWidth(mPulldown.getWidth()/2);
539 477 TextView edited = (TextView) entry.findViewById(R.id.edited);
540 478 edited.setOnLongClickListener(this);
541 479 base.setText(he.getBase());
542 480 edited.setText(he.getEdited());
543   - edited.setMaxWidth(mWindowWidth/2);
  481 + edited.setMaxWidth(mPulldown.getWidth()-base.getWidth()-entry.getChildAt(1).getWidth());
544 482 mHistoryView.addView(entry);
545 483 }
546 484 }
@@ -551,19 +489,6 @@ public boolean onLongClick(View v) {
551 489 return false;
552 490 }
553 491
554   - @Override
555   - public void onWindowFocusChanged (boolean hasFocus) {
556   - super.onWindowFocusChanged(hasFocus);
557   - if(!showingHistory && !heightSet) {
558   - mWindowHeight = mWindow.getHeight();
559   - mWindowWidth = mWindow.getWidth();
560   - mDefaultPulldownHeight = mPulldown.getHeight();
561   - mDefaultDisplayHeight = ((View) mDisplay.getParent().getParent()).getMeasuredHeight();
562   - mDistance = mDefaultDisplayHeight;
563   - heightSet = true;
564   - }
565   - }
566   -
567 492 class PageAdapter extends PagerAdapter {
568 493 private View mGraphPage;
569 494 private View mFunctionPage;
@@ -583,7 +508,7 @@ public PageAdapter(ViewPager parent) {
583 508 final View advancedPage = inflater.inflate(R.layout.advanced_pad, parent, false);
584 509 final View hexPage = inflater.inflate(R.layout.hex_pad, parent, false);
585 510 final View matrixPage = inflater.inflate(R.layout.matrix_pad, parent, false);
586   -
  511 +
587 512 mGraphPage = graphPage;
588 513 mFunctionPage = functionPage;
589 514 mHexPage = hexPage;
@@ -719,7 +644,7 @@ private void setOrder() {
719 644 }
720 645 }
721 646 }
722   -
  647 +
723 648 class SmallPageAdapter extends PagerAdapter {
724 649 private View mHexPage;
725 650 private View mFunctionPage;
@@ -823,7 +748,7 @@ private void setOrder() {
823 748 }
824 749 }
825 750 }
826   -
  751 +
827 752 class LargePageAdapter extends PagerAdapter {
828 753 private View mGraphPage;
829 754 private View mSimplePage;
@@ -837,7 +762,7 @@ public LargePageAdapter(ViewPager parent) {
837 762 final View graphPage = inflater.inflate(R.layout.graph_pad, parent, false);
838 763 final View simplePage = inflater.inflate(R.layout.simple_pad, parent, false);
839 764 final View matrixPage = inflater.inflate(R.layout.matrix_pad, parent, false);
840   -
  765 +
841 766 mGraphPage = graphPage;
842 767 mSimplePage = simplePage;
843 768 mMatrixPage = matrixPage;
2  src/com/android2/calculator3/CalculatorEditText.java
@@ -149,7 +149,7 @@ private void pasteContent() {
149 149 }
150 150
151 151 private boolean canPaste(CharSequence paste) {
152   - return paste.length()>0;
  152 + return paste.length() > 0;
153 153 }
154 154
155 155 class NoTextSelectionMode implements ActionMode.Callback {
2  src/com/android2/calculator3/ColorButton.java
@@ -28,7 +28,7 @@
28 28 /**
29 29 * Button with click-animation effect.
30 30 */
31   -class ColorButton extends Button{
  31 +class ColorButton extends Button {
32 32 int CLICK_FEEDBACK_COLOR;
33 33 static final int CLICK_FEEDBACK_INTERVAL = 10;
34 34 static final int CLICK_FEEDBACK_DURATION = 350;
2  src/net/sf/jchemistry/util/CommonMathUtils.java → src/com/android2/calculator3/CommonMathUtils.java
@@ -15,7 +15,7 @@
15 15 * You should have received a copy of the GNU Lesser General Public License
16 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17 */
18   -package net.sf.jchemistry.util;
  18 +package com.android2.calculator3;
19 19
20 20 import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
21 21 import org.apache.commons.math3.linear.Array2DRowRealMatrix;
46 src/com/android2/calculator3/EventListener.java
@@ -20,7 +20,9 @@
20 20 import com.android2.calculator3.Logic.Mode;
21 21
22 22 import android.content.Context;
  23 +import android.content.SharedPreferences;
23 24 import android.os.Handler;
  25 +import android.preference.PreferenceManager;
24 26 import android.support.v4.view.ViewPager;
25 27 import android.view.KeyEvent;
26 28 import android.view.View;
@@ -33,6 +35,7 @@
33 35 Context mContext;
34 36 Logic mHandler;
35 37 ViewPager mPager;
  38 + private SharedPreferences mPreferences;
36 39