Overhaul Calculator UI.
Bug: 14418545
Bug: 14419084
Bug: 14419142
Bug: 14420277
Bug: 14466652
Bug: 14564559
Bug: 14564608
Bug: 14846724
Bug: 15090154
Bug: 15287699
Bug: 15289526
Bug: 15289616
Change-Id: I93e1530446d5bd6a4c3189f751c88ece1abc7767
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f610603..6218374 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,24 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.calculator2" >
+<!--
+ Copyright (C) 2014 The Android Open Source Project
- <original-package android:name="com.android.calculator2" />
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<manifest
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.calculator2">
<application
android:icon="@mipmap/ic_launcher_calculator"
- android:label="@string/app_name" >
+ android:label="@string/app_name"
+ android:theme="@style/CalculatorTheme">
+
<activity
- android:name="Calculator"
- android:theme="@style/AppTheme"
- android:windowSoftInputMode="stateAlwaysHidden" >
+ android:name="com.android.calculator2.CalculatorActivity"
+ android:label="@string/app_name"
+ android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.APP_CALCULATOR" />
</intent-filter>
</activity>
+
</application>
</manifest>
diff --git a/res/drawable-hdpi/card_background.9.png b/res/drawable-hdpi/card_background.9.png
deleted file mode 100644
index bffcb47..0000000
--- a/res/drawable-hdpi/card_background.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_delete_alpha.png b/res/drawable-hdpi/ic_delete_alpha.png
deleted file mode 100644
index 03b6655..0000000
--- a/res/drawable-hdpi/ic_delete_alpha.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldpi/ic_delete_alpha.png b/res/drawable-ldpi/ic_delete_alpha.png
deleted file mode 100644
index 7f6b461..0000000
--- a/res/drawable-ldpi/ic_delete_alpha.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/card_background.9.png b/res/drawable-mdpi/card_background.9.png
deleted file mode 100644
index dd2f251..0000000
--- a/res/drawable-mdpi/card_background.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_delete_alpha.png b/res/drawable-mdpi/ic_delete_alpha.png
deleted file mode 100644
index 4765362..0000000
--- a/res/drawable-mdpi/ic_delete_alpha.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/card_background.9.png b/res/drawable-xhdpi/card_background.9.png
deleted file mode 100644
index 68e9743..0000000
--- a/res/drawable-xhdpi/card_background.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_delete_alpha.png b/res/drawable-xhdpi/ic_delete_alpha.png
deleted file mode 100644
index 8232c2a..0000000
--- a/res/drawable-xhdpi/ic_delete_alpha.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_delete_alpha.png b/res/drawable-xxhdpi/ic_delete_alpha.png
deleted file mode 100644
index e60f09c..0000000
--- a/res/drawable-xxhdpi/ic_delete_alpha.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/btn_advanced.xml b/res/drawable/btn_advanced.xml
deleted file mode 100644
index 8f99f46..0000000
--- a/res/drawable/btn_advanced.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:tint="@color/primary_dark" android:pinned="true" />
diff --git a/res/drawable/btn_digit.xml b/res/drawable/btn_digit.xml
deleted file mode 100644
index 286b735..0000000
--- a/res/drawable/btn_digit.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:tint="@color/gray_50" android:pinned="true" />
diff --git a/res/drawable/btn_function.xml b/res/drawable/btn_function.xml
deleted file mode 100644
index fc4fa56..0000000
--- a/res/drawable/btn_function.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:tint="@color/gray_60" android:pinned="true" />
diff --git a/res/drawable/display_shadow.xml b/res/drawable/display_shadow.xml
new file mode 100644
index 0000000..e68b63d
--- /dev/null
+++ b/res/drawable/display_shadow.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <gradient
+ android:angle="90"
+ android:startColor="@android:color/transparent"
+ android:endColor="#33000000" />
+</shape>
\ No newline at end of file
diff --git a/res/drawable/ic_delete.xml b/res/drawable/ic_delete.xml
deleted file mode 100644
index 367e7cf..0000000
--- a/res/drawable/ic_delete.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/ic_delete_alpha"
- android:tint="@color/text_light" />
diff --git a/res/drawable/pad_btn_background.xml b/res/drawable/pad_btn_background.xml
new file mode 100644
index 0000000..1366dfc
--- /dev/null
+++ b/res/drawable/pad_btn_background.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<ripple
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:tint="@color/pad_button_tint_color"
+ android:pinned="true" />
\ No newline at end of file
diff --git a/res/drawable/pad_page_shadow.xml b/res/drawable/pad_page_shadow.xml
new file mode 100644
index 0000000..4cd079b
--- /dev/null
+++ b/res/drawable/pad_page_shadow.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <gradient
+ android:startColor="@android:color/transparent"
+ android:endColor="#33000000" />
+</shape>
\ No newline at end of file
diff --git a/res/drawable/shadow_bottom.xml b/res/drawable/shadow_bottom.xml
deleted file mode 100644
index e07dfdf..0000000
--- a/res/drawable/shadow_bottom.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<shape xmlns:android="http://schemas.android.com/apk/res/android" >
-
- <gradient
- android:angle="90"
- android:endColor="#C0000000"
- android:startColor="#00000000" />
-
-</shape>
\ No newline at end of file
diff --git a/res/drawable/shadow_right.xml b/res/drawable/shadow_right.xml
deleted file mode 100644
index c842311..0000000
--- a/res/drawable/shadow_right.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<shape xmlns:android="http://schemas.android.com/apk/res/android" >
-
- <gradient
- android:angle="0"
- android:endColor="#33000000"
- android:startColor="#00000000" />
-
-</shape>
\ No newline at end of file
diff --git a/res/drawable/shadow_top.xml b/res/drawable/shadow_top.xml
deleted file mode 100644
index fa30d3e..0000000
--- a/res/drawable/shadow_top.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<shape xmlns:android="http://schemas.android.com/apk/res/android" >
-
- <gradient
- android:angle="270"
- android:endColor="#C0000000"
- android:startColor="#00000000" />
-
-</shape>
\ No newline at end of file
diff --git a/res/layout-land/advanced_pad.xml b/res/layout-land/advanced_pad.xml
deleted file mode 100644
index 06cb823..0000000
--- a/res/layout-land/advanced_pad.xml
+++ /dev/null
@@ -1,120 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
-/*
-* Copyright (C) 2011, The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/advancedPad"
- style="@style/advanced_pad"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:layout_weight="1"
- android:orientation="vertical" >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/sin"
- style="@style/advanced_button_small"
- android:contentDescription="@string/sinDesc"
- android:text="@string/sin" />
-
- <Button
- android:id="@+id/cos"
- style="@style/advanced_button_small"
- android:contentDescription="@string/cosDesc"
- android:text="@string/cos" />
-
- <Button
- android:id="@+id/tan"
- style="@style/advanced_button_small"
- android:contentDescription="@string/tanDesc"
- android:text="@string/tan" />
-
- <Button
- android:id="@+id/leftParen"
- style="@style/function_button"
- android:contentDescription="@string/leftParenDesc"
- android:text="@string/leftParen" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/ln"
- style="@style/advanced_button_small"
- android:contentDescription="@string/lnDesc"
- android:text="@string/ln" />
-
- <Button
- android:id="@+id/lg"
- style="@style/advanced_button_small"
- android:contentDescription="@string/lgDesc"
- android:text="@string/lg" />
-
- <Button
- android:id="@+id/factorial"
- style="@style/advanced_button"
- android:contentDescription="@string/factorialDesc"
- android:text="@string/factorial" />
-
- <Button
- android:id="@+id/rightParen"
- style="@style/function_button"
- android:contentDescription="@string/rightParenDesc"
- android:text="@string/rightParen" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/pi"
- style="@style/advanced_button"
- android:contentDescription="@string/piDesc"
- android:text="@string/pi" />
-
- <Button
- android:id="@+id/e"
- style="@style/advanced_button"
- android:contentDescription="@string/eDesc"
- android:text="@string/e" />
-
- <Button
- android:id="@+id/power"
- style="@style/advanced_button"
- android:contentDescription="@string/powerDesc"
- android:text="@string/power" />
-
- <Button
- android:id="@+id/sqrt"
- style="@style/advanced_button"
- android:contentDescription="@string/sqrtDesc"
- android:text="@string/sqrt" />
- </LinearLayout>
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-land/history_item.xml b/res/layout-land/history_item.xml
deleted file mode 100644
index 2147da7..0000000
--- a/res/layout-land/history_item.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- >
-
- <TextView
- android:id="@+id/historyExpr"
- android:layout_width="0px"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:textSize="23dp"
- android:singleLine="true"
- />
-
- <TextView
- android:id="@+id/historyResult"
- android:layout_width="180px"
- android:layout_height="wrap_content"
- android:layout_weight="0"
- android:textSize="23dp"
- android:singleLine="true"
- />
-
-</LinearLayout>
diff --git a/res/layout-land/main.xml b/res/layout-land/main.xml
deleted file mode 100644
index a633e22..0000000
--- a/res/layout-land/main.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <com.android.calculator2.CalculatorDisplay
- android:id="@+id/display"
- style="@style/display_holder_style"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- maxDigits="@integer/max_digits" >
-
- <com.android.calculator2.CalculatorEditText style="@style/display_style" />
-
- <com.android.calculator2.CalculatorEditText style="@style/display_style" />
- </com.android.calculator2.CalculatorDisplay>
-
- <com.android.calculator2.CalculatorViewPager
- android:id="@+id/panelswitch"
- android:layout_width="match_parent"
- android:layout_height="200dp" />
-
-</LinearLayout>
diff --git a/res/layout-land/simple_pad.xml b/res/layout-land/simple_pad.xml
deleted file mode 100644
index 84cd94a..0000000
--- a/res/layout-land/simple_pad.xml
+++ /dev/null
@@ -1,156 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/simplePad"
- style="@style/digit_pad"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:orientation="vertical" >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/digit7"
- style="@style/digit_button"
- android:text="@string/digit7" />
-
- <Button
- android:id="@+id/digit8"
- style="@style/digit_button"
- android:text="@string/digit8" />
-
- <Button
- android:id="@+id/digit9"
- style="@style/digit_button"
- android:text="@string/digit9" />
-
- <Button
- android:id="@+id/div"
- style="@style/function_button"
- android:contentDescription="@string/divDesc"
- android:text="@string/div" />
-
- <Button
- android:id="@+id/mul"
- style="@style/function_button"
- android:contentDescription="@string/mulDesc"
- android:text="@string/mul" />
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1" >
-
- <ImageButton
- android:id="@+id/del"
- style="@style/function_button"
- android:contentDescription="@string/delDesc"
- android:src="@drawable/ic_delete"
- android:textSize="@dimen/small_text_size" />
-
- <Button
- android:id="@+id/clear"
- style="@style/function_button"
- android:contentDescription="@string/clearDesc"
- android:text="@string/clear"
- android:textSize="@dimen/small_text_size"
- android:visibility="invisible" />
- </FrameLayout>
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/digit4"
- style="@style/digit_button"
- android:text="@string/digit4" />
-
- <Button
- android:id="@+id/digit5"
- style="@style/digit_button"
- android:text="@string/digit5" />
-
- <Button
- android:id="@+id/digit6"
- style="@style/digit_button"
- android:text="@string/digit6" />
-
- <Button
- android:id="@+id/plus"
- style="@style/function_button"
- android:contentDescription="@string/plusDesc"
- android:text="@string/plus" />
-
- <Button
- android:id="@+id/minus"
- style="@style/function_button"
- android:contentDescription="@string/minusDesc"
- android:text="@string/minus" />
-
- <View
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/digit1"
- style="@style/digit_button"
- android:text="@string/digit1" />
-
- <Button
- android:id="@+id/digit2"
- style="@style/digit_button"
- android:text="@string/digit2" />
-
- <Button
- android:id="@+id/digit3"
- style="@style/digit_button"
- android:text="@string/digit3" />
-
- <Button
- android:id="@+id/digit0"
- style="@style/digit_button"
- android:text="@string/digit0" />
-
- <Button
- android:id="@+id/dot"
- style="@style/digit_button"
- android:contentDescription="@string/dotDesc"
- android:text="@string/dot" />
-
- <Button
- android:id="@+id/equal"
- style="@style/function_button"
- android:contentDescription="@string/equalDesc"
- android:text="@string/equal" />
- </LinearLayout>
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-port/advanced_pad.xml b/res/layout-port/advanced_pad.xml
deleted file mode 100644
index 73409f1..0000000
--- a/res/layout-port/advanced_pad.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
-/*
-* Copyright (C) 2011, The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/advancedPad"
- style="@style/advanced_pad"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/sin"
- style="@style/advanced_button_small"
- android:contentDescription="@string/sinDesc"
- android:text="@string/sin" />
-
- <Button
- android:id="@+id/cos"
- style="@style/advanced_button_small"
- android:contentDescription="@string/cosDesc"
- android:text="@string/cos" />
-
- <Button
- android:id="@+id/tan"
- style="@style/advanced_button_small"
- android:contentDescription="@string/tanDesc"
- android:text="@string/tan" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/ln"
- style="@style/advanced_button_small"
- android:contentDescription="@string/lnDesc"
- android:text="@string/ln" />
-
- <Button
- android:id="@+id/lg"
- style="@style/advanced_button_small"
- android:contentDescription="@string/lgDesc"
- android:text="@string/lg" />
-
- <Button
- android:id="@+id/factorial"
- style="@style/advanced_button"
- android:contentDescription="@string/factorialDesc"
- android:text="@string/factorial" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/pi"
- style="@style/advanced_button"
- android:contentDescription="@string/piDesc"
- android:text="@string/pi" />
-
- <Button
- android:id="@+id/e"
- style="@style/advanced_button"
- android:contentDescription="@string/eDesc"
- android:text="@string/e" />
-
- <Button
- android:id="@+id/power"
- style="@style/advanced_button"
- android:contentDescription="@string/powerDesc"
- android:text="@string/power" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/leftParen"
- style="@style/advanced_button"
- android:contentDescription="@string/leftParenDesc"
- android:text="@string/leftParen" />
-
- <Button
- android:id="@+id/rightParen"
- style="@style/advanced_button"
- android:contentDescription="@string/rightParenDesc"
- android:text="@string/rightParen" />
-
- <Button
- android:id="@+id/sqrt"
- style="@style/advanced_button"
- android:contentDescription="@string/sqrtDesc"
- android:text="@string/sqrt" />
- </LinearLayout>
-
-</LinearLayout>
diff --git a/res/layout-port/history_item.xml b/res/layout-port/history_item.xml
deleted file mode 100644
index 61f7099..0000000
--- a/res/layout-port/history_item.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@drawable/card_background"
- android:padding="8dp"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/historyExpr"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textSize="24sp" />
-
- <TextView
- android:id="@+id/historyResult"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textSize="48sp" />
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-port/main.xml b/res/layout-port/main.xml
deleted file mode 100644
index 8ed7aad..0000000
--- a/res/layout-port/main.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <com.android.calculator2.CalculatorDisplay
- android:id="@+id/display"
- style="@style/display_holder_style"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- maxDigits="@integer/max_digits" >
-
- <com.android.calculator2.CalculatorEditText style="@style/display_style" />
-
- <com.android.calculator2.CalculatorEditText style="@style/display_style" />
- </com.android.calculator2.CalculatorDisplay>
-
- <com.android.calculator2.CalculatorViewPager
- android:id="@+id/panelswitch"
- android:layout_width="match_parent"
- android:layout_height="360dp" />
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-port/simple_pad.xml b/res/layout-port/simple_pad.xml
deleted file mode 100644
index 276e079..0000000
--- a/res/layout-port/simple_pad.xml
+++ /dev/null
@@ -1,161 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/simplePad"
- style="@style/digit_pad"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:baselineAligned="true"
- android:orientation="horizontal" >
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/digit7"
- style="@style/digit_button"
- android:text="@string/digit7" />
-
- <Button
- android:id="@+id/digit4"
- style="@style/digit_button"
- android:text="@string/digit4" />
-
- <Button
- android:id="@+id/digit1"
- style="@style/digit_button"
- android:text="@string/digit1" />
-
- <Button
- android:id="@+id/dot"
- style="@style/digit_button"
- android:contentDescription="@string/dotDesc"
- android:text="@string/dot" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/digit8"
- style="@style/digit_button"
- android:text="@string/digit8" />
-
- <Button
- android:id="@+id/digit5"
- style="@style/digit_button"
- android:text="@string/digit5" />
-
- <Button
- android:id="@+id/digit2"
- style="@style/digit_button"
- android:text="@string/digit2" />
-
- <Button
- android:id="@+id/digit0"
- style="@style/digit_button"
- android:text="@string/digit0" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/digit9"
- style="@style/digit_button"
- android:text="@string/digit9" />
-
- <Button
- android:id="@+id/digit6"
- style="@style/digit_button"
- android:text="@string/digit6" />
-
- <Button
- android:id="@+id/digit3"
- style="@style/digit_button"
- android:text="@string/digit3" />
-
- <Button
- android:id="@+id/equal"
- style="@style/digit_button"
- android:contentDescription="@string/equalDesc"
- android:text="@string/equal" />
- </LinearLayout>
-
- <LinearLayout
- style="@style/function_pad"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical" >
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1" >
-
- <ImageButton
- android:id="@+id/del"
- style="@style/function_button"
- android:contentDescription="@string/delDesc"
- android:src="@drawable/ic_delete"
- android:textSize="@dimen/small_text_size" />
-
- <Button
- android:id="@+id/clear"
- style="@style/function_button"
- android:contentDescription="@string/clearDesc"
- android:text="@string/clear"
- android:textSize="@dimen/small_text_size"
- android:visibility="invisible" />
- </FrameLayout>
-
- <Button
- android:id="@+id/div"
- style="@style/function_button"
- android:contentDescription="@string/divDesc"
- android:text="@string/div" />
-
- <Button
- android:id="@+id/mul"
- style="@style/function_button"
- android:contentDescription="@string/mulDesc"
- android:text="@string/mul" />
-
- <Button
- android:id="@+id/minus"
- style="@style/function_button"
- android:contentDescription="@string/minusDesc"
- android:text="@string/minus" />
-
- <Button
- android:id="@+id/plus"
- style="@style/function_button"
- android:contentDescription="@string/plusDesc"
- android:text="@string/plus" />
- </LinearLayout>
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-sw600dp-land/advanced_pad.xml b/res/layout-sw600dp-land/advanced_pad.xml
deleted file mode 100644
index 73409f1..0000000
--- a/res/layout-sw600dp-land/advanced_pad.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
-/*
-* Copyright (C) 2011, The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/advancedPad"
- style="@style/advanced_pad"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/sin"
- style="@style/advanced_button_small"
- android:contentDescription="@string/sinDesc"
- android:text="@string/sin" />
-
- <Button
- android:id="@+id/cos"
- style="@style/advanced_button_small"
- android:contentDescription="@string/cosDesc"
- android:text="@string/cos" />
-
- <Button
- android:id="@+id/tan"
- style="@style/advanced_button_small"
- android:contentDescription="@string/tanDesc"
- android:text="@string/tan" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/ln"
- style="@style/advanced_button_small"
- android:contentDescription="@string/lnDesc"
- android:text="@string/ln" />
-
- <Button
- android:id="@+id/lg"
- style="@style/advanced_button_small"
- android:contentDescription="@string/lgDesc"
- android:text="@string/lg" />
-
- <Button
- android:id="@+id/factorial"
- style="@style/advanced_button"
- android:contentDescription="@string/factorialDesc"
- android:text="@string/factorial" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/pi"
- style="@style/advanced_button"
- android:contentDescription="@string/piDesc"
- android:text="@string/pi" />
-
- <Button
- android:id="@+id/e"
- style="@style/advanced_button"
- android:contentDescription="@string/eDesc"
- android:text="@string/e" />
-
- <Button
- android:id="@+id/power"
- style="@style/advanced_button"
- android:contentDescription="@string/powerDesc"
- android:text="@string/power" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/leftParen"
- style="@style/advanced_button"
- android:contentDescription="@string/leftParenDesc"
- android:text="@string/leftParen" />
-
- <Button
- android:id="@+id/rightParen"
- style="@style/advanced_button"
- android:contentDescription="@string/rightParenDesc"
- android:text="@string/rightParen" />
-
- <Button
- android:id="@+id/sqrt"
- style="@style/advanced_button"
- android:contentDescription="@string/sqrtDesc"
- android:text="@string/sqrt" />
- </LinearLayout>
-
-</LinearLayout>
diff --git a/res/layout-sw600dp-land/main.xml b/res/layout-sw600dp-land/main.xml
deleted file mode 100644
index 309afae..0000000
--- a/res/layout-sw600dp-land/main.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <com.android.calculator2.CalculatorDisplay
- android:id="@+id/display"
- style="@style/display_holder_style"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- maxDigits="@integer/max_digits" >
-
- <com.android.calculator2.CalculatorEditText style="@style/display_style" />
-
- <com.android.calculator2.CalculatorEditText style="@style/display_style" />
- </com.android.calculator2.CalculatorDisplay>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="360dp"
- android:baselineAligned="false"
- android:orientation="horizontal" >
-
- <include
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- layout="@layout/simple_pad" />
-
- <include
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- layout="@layout/advanced_pad" />
- </LinearLayout>
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-sw600dp-land/simple_pad.xml b/res/layout-sw600dp-land/simple_pad.xml
deleted file mode 100644
index 276e079..0000000
--- a/res/layout-sw600dp-land/simple_pad.xml
+++ /dev/null
@@ -1,161 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/simplePad"
- style="@style/digit_pad"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:baselineAligned="true"
- android:orientation="horizontal" >
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/digit7"
- style="@style/digit_button"
- android:text="@string/digit7" />
-
- <Button
- android:id="@+id/digit4"
- style="@style/digit_button"
- android:text="@string/digit4" />
-
- <Button
- android:id="@+id/digit1"
- style="@style/digit_button"
- android:text="@string/digit1" />
-
- <Button
- android:id="@+id/dot"
- style="@style/digit_button"
- android:contentDescription="@string/dotDesc"
- android:text="@string/dot" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/digit8"
- style="@style/digit_button"
- android:text="@string/digit8" />
-
- <Button
- android:id="@+id/digit5"
- style="@style/digit_button"
- android:text="@string/digit5" />
-
- <Button
- android:id="@+id/digit2"
- style="@style/digit_button"
- android:text="@string/digit2" />
-
- <Button
- android:id="@+id/digit0"
- style="@style/digit_button"
- android:text="@string/digit0" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/digit9"
- style="@style/digit_button"
- android:text="@string/digit9" />
-
- <Button
- android:id="@+id/digit6"
- style="@style/digit_button"
- android:text="@string/digit6" />
-
- <Button
- android:id="@+id/digit3"
- style="@style/digit_button"
- android:text="@string/digit3" />
-
- <Button
- android:id="@+id/equal"
- style="@style/digit_button"
- android:contentDescription="@string/equalDesc"
- android:text="@string/equal" />
- </LinearLayout>
-
- <LinearLayout
- style="@style/function_pad"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical" >
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1" >
-
- <ImageButton
- android:id="@+id/del"
- style="@style/function_button"
- android:contentDescription="@string/delDesc"
- android:src="@drawable/ic_delete"
- android:textSize="@dimen/small_text_size" />
-
- <Button
- android:id="@+id/clear"
- style="@style/function_button"
- android:contentDescription="@string/clearDesc"
- android:text="@string/clear"
- android:textSize="@dimen/small_text_size"
- android:visibility="invisible" />
- </FrameLayout>
-
- <Button
- android:id="@+id/div"
- style="@style/function_button"
- android:contentDescription="@string/divDesc"
- android:text="@string/div" />
-
- <Button
- android:id="@+id/mul"
- style="@style/function_button"
- android:contentDescription="@string/mulDesc"
- android:text="@string/mul" />
-
- <Button
- android:id="@+id/minus"
- style="@style/function_button"
- android:contentDescription="@string/minusDesc"
- android:text="@string/minus" />
-
- <Button
- android:id="@+id/plus"
- style="@style/function_button"
- android:contentDescription="@string/plusDesc"
- android:text="@string/plus" />
- </LinearLayout>
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-sw600dp/advanced_pad.xml b/res/layout-sw600dp/advanced_pad.xml
deleted file mode 100644
index 73409f1..0000000
--- a/res/layout-sw600dp/advanced_pad.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
-/*
-* Copyright (C) 2011, The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/advancedPad"
- style="@style/advanced_pad"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/sin"
- style="@style/advanced_button_small"
- android:contentDescription="@string/sinDesc"
- android:text="@string/sin" />
-
- <Button
- android:id="@+id/cos"
- style="@style/advanced_button_small"
- android:contentDescription="@string/cosDesc"
- android:text="@string/cos" />
-
- <Button
- android:id="@+id/tan"
- style="@style/advanced_button_small"
- android:contentDescription="@string/tanDesc"
- android:text="@string/tan" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/ln"
- style="@style/advanced_button_small"
- android:contentDescription="@string/lnDesc"
- android:text="@string/ln" />
-
- <Button
- android:id="@+id/lg"
- style="@style/advanced_button_small"
- android:contentDescription="@string/lgDesc"
- android:text="@string/lg" />
-
- <Button
- android:id="@+id/factorial"
- style="@style/advanced_button"
- android:contentDescription="@string/factorialDesc"
- android:text="@string/factorial" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/pi"
- style="@style/advanced_button"
- android:contentDescription="@string/piDesc"
- android:text="@string/pi" />
-
- <Button
- android:id="@+id/e"
- style="@style/advanced_button"
- android:contentDescription="@string/eDesc"
- android:text="@string/e" />
-
- <Button
- android:id="@+id/power"
- style="@style/advanced_button"
- android:contentDescription="@string/powerDesc"
- android:text="@string/power" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/leftParen"
- style="@style/advanced_button"
- android:contentDescription="@string/leftParenDesc"
- android:text="@string/leftParen" />
-
- <Button
- android:id="@+id/rightParen"
- style="@style/advanced_button"
- android:contentDescription="@string/rightParenDesc"
- android:text="@string/rightParen" />
-
- <Button
- android:id="@+id/sqrt"
- style="@style/advanced_button"
- android:contentDescription="@string/sqrtDesc"
- android:text="@string/sqrt" />
- </LinearLayout>
-
-</LinearLayout>
diff --git a/res/layout-sw600dp/main.xml b/res/layout-sw600dp/main.xml
deleted file mode 100644
index 964fe48..0000000
--- a/res/layout-sw600dp/main.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <com.android.calculator2.CalculatorDisplay
- android:id="@+id/display"
- style="@style/display_holder_style"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- maxDigits="@integer/max_digits" >
-
- <com.android.calculator2.CalculatorEditText style="@style/display_style" />
-
- <com.android.calculator2.CalculatorEditText style="@style/display_style" />
- </com.android.calculator2.CalculatorDisplay>
-
- <include
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- layout="@layout/advanced_pad" />
-
- <include
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- layout="@layout/simple_pad" />
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout-sw600dp/simple_pad.xml b/res/layout-sw600dp/simple_pad.xml
deleted file mode 100644
index 276e079..0000000
--- a/res/layout-sw600dp/simple_pad.xml
+++ /dev/null
@@ -1,161 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/simplePad"
- style="@style/digit_pad"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:baselineAligned="true"
- android:orientation="horizontal" >
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/digit7"
- style="@style/digit_button"
- android:text="@string/digit7" />
-
- <Button
- android:id="@+id/digit4"
- style="@style/digit_button"
- android:text="@string/digit4" />
-
- <Button
- android:id="@+id/digit1"
- style="@style/digit_button"
- android:text="@string/digit1" />
-
- <Button
- android:id="@+id/dot"
- style="@style/digit_button"
- android:contentDescription="@string/dotDesc"
- android:text="@string/dot" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/digit8"
- style="@style/digit_button"
- android:text="@string/digit8" />
-
- <Button
- android:id="@+id/digit5"
- style="@style/digit_button"
- android:text="@string/digit5" />
-
- <Button
- android:id="@+id/digit2"
- style="@style/digit_button"
- android:text="@string/digit2" />
-
- <Button
- android:id="@+id/digit0"
- style="@style/digit_button"
- android:text="@string/digit0" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/digit9"
- style="@style/digit_button"
- android:text="@string/digit9" />
-
- <Button
- android:id="@+id/digit6"
- style="@style/digit_button"
- android:text="@string/digit6" />
-
- <Button
- android:id="@+id/digit3"
- style="@style/digit_button"
- android:text="@string/digit3" />
-
- <Button
- android:id="@+id/equal"
- style="@style/digit_button"
- android:contentDescription="@string/equalDesc"
- android:text="@string/equal" />
- </LinearLayout>
-
- <LinearLayout
- style="@style/function_pad"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical" >
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1" >
-
- <ImageButton
- android:id="@+id/del"
- style="@style/function_button"
- android:contentDescription="@string/delDesc"
- android:src="@drawable/ic_delete"
- android:textSize="@dimen/small_text_size" />
-
- <Button
- android:id="@+id/clear"
- style="@style/function_button"
- android:contentDescription="@string/clearDesc"
- android:text="@string/clear"
- android:textSize="@dimen/small_text_size"
- android:visibility="invisible" />
- </FrameLayout>
-
- <Button
- android:id="@+id/div"
- style="@style/function_button"
- android:contentDescription="@string/divDesc"
- android:text="@string/div" />
-
- <Button
- android:id="@+id/mul"
- style="@style/function_button"
- android:contentDescription="@string/mulDesc"
- android:text="@string/mul" />
-
- <Button
- android:id="@+id/minus"
- style="@style/function_button"
- android:contentDescription="@string/minusDesc"
- android:text="@string/minus" />
-
- <Button
- android:id="@+id/plus"
- style="@style/function_button"
- android:contentDescription="@string/plusDesc"
- android:text="@string/plus" />
- </LinearLayout>
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/activity_calculator_land.xml b/res/layout/activity_calculator_land.xml
new file mode 100644
index 0000000..8a1fac2
--- /dev/null
+++ b/res/layout/activity_calculator_land.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <include
+ android:id="@+id/display"
+ layout="@layout/display"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_below="@id/display">
+
+ <include layout="@layout/pad_numeric" />
+ <include layout="@layout/pad_operator_two_col" />
+ <include layout="@layout/pad_advanced" />
+
+ </LinearLayout>
+
+ <View
+ style="@style/DisplayShadowStyle"
+ android:layout_below="@id/display" />
+
+</RelativeLayout>
diff --git a/res/layout/activity_calculator_port.xml b/res/layout/activity_calculator_port.xml
new file mode 100644
index 0000000..ddc7c8b
--- /dev/null
+++ b/res/layout/activity_calculator_port.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <include
+ android:id="@+id/display"
+ layout="@layout/display"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <com.android.calculator2.CalculatorPadViewPager
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_below="@id/display">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <include layout="@layout/pad_numeric" />
+ <include layout="@layout/pad_operator_one_col" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <View style="@style/PadPageShadow" />
+ <include layout="@layout/pad_advanced" />
+
+ </LinearLayout>
+
+ </com.android.calculator2.CalculatorPadViewPager>
+
+ <View
+ style="@style/DisplayShadowStyle"
+ android:layout_below="@id/display" />
+
+</RelativeLayout>
diff --git a/res/layout/activity_calculator_tablet_port.xml b/res/layout/activity_calculator_tablet_port.xml
new file mode 100644
index 0000000..d5a99db
--- /dev/null
+++ b/res/layout/activity_calculator_tablet_port.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <include
+ android:id="@+id/display"
+ layout="@layout/display"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_below="@id/display"
+ android:orientation="vertical">
+
+ <include layout="@layout/pad_advanced" />
+
+ <LinearLayout style="@style/PadLinearLayoutStyle">
+
+ <include layout="@layout/pad_numeric" />
+ <include layout="@layout/pad_operator_two_col" />
+
+ </LinearLayout>
+
+ </LinearLayout>
+
+ <View
+ style="@style/DisplayShadowStyle"
+ android:layout_below="@id/display" />
+
+</RelativeLayout>
diff --git a/res/layout/display.xml b/res/layout/display.xml
new file mode 100644
index 0000000..3b9b624
--- /dev/null
+++ b/res/layout/display.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@color/display_background_color">
+
+ <com.android.calculator2.CalculatorEditText
+ android:id="@+id/formula"
+ style="@style/DisplayEditTextStyle.Formula"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="text|textNoSuggestions"
+ android:textColor="@color/display_formula_text_color" />
+
+ <com.android.calculator2.CalculatorEditText
+ android:id="@+id/result"
+ style="@style/DisplayEditTextStyle.Result"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/formula"
+ android:inputType="none"
+ android:textColor="@color/display_result_text_color" />
+
+ <View
+ android:id="@+id/reveal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignTop="@id/formula"
+ android:layout_alignBottom="@id/result"
+ android:background="@color/calculator_accent_color"
+ android:visibility="gone" />
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/res/layout/pad_advanced.xml b/res/layout/pad_advanced.xml
new file mode 100644
index 0000000..5e8fec0
--- /dev/null
+++ b/res/layout/pad_advanced.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<com.android.calculator2.CalculatorPadLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/pad_advanced"
+ style="@style/PadLayoutStyle.Advanced"
+ android:background="@color/pad_advanced_background_color">
+
+ <Button
+ android:id="@+id/fun_sin"
+ style="@style/PadButtonStyle.Advanced"
+ android:contentDescription="@string/desc_fun_sin"
+ android:onClick="onButtonClick"
+ android:text="@string/fun_sin" />
+
+ <Button
+ android:id="@+id/fun_cos"
+ style="@style/PadButtonStyle.Advanced"
+ android:contentDescription="@string/desc_fun_cos"
+ android:onClick="onButtonClick"
+ android:text="@string/fun_cos" />
+
+ <Button
+ android:id="@+id/fun_tan"
+ style="@style/PadButtonStyle.Advanced"
+ android:contentDescription="@string/desc_fun_tan"
+ android:onClick="onButtonClick"
+ android:text="@string/fun_tan" />
+
+ <Button
+ android:id="@+id/fun_ln"
+ style="@style/PadButtonStyle.Advanced"
+ android:contentDescription="@string/desc_fun_ln"
+ android:onClick="onButtonClick"
+ android:text="@string/fun_ln" />
+
+ <Button
+ android:id="@+id/fun_log"
+ style="@style/PadButtonStyle.Advanced"
+ android:contentDescription="@string/desc_fun_log"
+ android:onClick="onButtonClick"
+ android:text="@string/fun_log" />
+
+ <Button
+ android:id="@+id/op_fact"
+ style="@style/PadButtonStyle.Advanced"
+ android:contentDescription="@string/desc_op_fact"
+ android:onClick="onButtonClick"
+ android:text="@string/op_fact" />
+
+ <Button
+ android:id="@+id/const_pi"
+ style="@style/PadButtonStyle.Advanced"
+ android:contentDescription="@string/desc_const_pi"
+ android:onClick="onButtonClick"
+ android:text="@string/const_pi" />
+
+ <Button
+ android:id="@+id/const_e"
+ style="@style/PadButtonStyle.Advanced"
+ android:contentDescription="@string/desc_const_e"
+ android:onClick="onButtonClick"
+ android:text="@string/const_e" />
+
+ <Button
+ android:id="@+id/op_pow"
+ style="@style/PadButtonStyle.Advanced"
+ android:contentDescription="@string/desc_op_pow"
+ android:onClick="onButtonClick"
+ android:text="@string/op_pow" />
+
+ <Button
+ android:id="@+id/lparen"
+ style="@style/PadButtonStyle.Advanced"
+ android:contentDescription="@string/desc_lparen"
+ android:onClick="onButtonClick"
+ android:text="@string/lparen" />
+
+ <Button
+ android:id="@+id/rparen"
+ style="@style/PadButtonStyle.Advanced"
+ android:contentDescription="@string/desc_rparen"
+ android:onClick="onButtonClick"
+ android:text="@string/rparen" />
+
+ <Button
+ android:id="@+id/op_sqrt"
+ style="@style/PadButtonStyle.Advanced"
+ android:contentDescription="@string/desc_op_sqrt"
+ android:onClick="onButtonClick"
+ android:text="@string/op_sqrt" />
+
+</com.android.calculator2.CalculatorPadLayout>
diff --git a/res/layout/pad_numeric.xml b/res/layout/pad_numeric.xml
new file mode 100644
index 0000000..c03f58b
--- /dev/null
+++ b/res/layout/pad_numeric.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<com.android.calculator2.CalculatorPadLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/pad_numeric"
+ style="@style/PadLayoutStyle.Numeric"
+ android:background="@color/pad_numeric_background_color"
+ android:columnCount="3"
+ android:rowCount="4">
+
+ <Button
+ android:id="@+id/digit_7"
+ style="@style/PadButtonStyle.Numeric"
+ android:onClick="onButtonClick"
+ android:text="@string/digit_7" />
+
+ <Button
+ android:id="@+id/digit_8"
+ style="@style/PadButtonStyle.Numeric"
+ android:onClick="onButtonClick"
+ android:text="@string/digit_8" />
+
+ <Button
+ android:id="@+id/digit_9"
+ style="@style/PadButtonStyle.Numeric"
+ android:onClick="onButtonClick"
+ android:text="@string/digit_9" />
+
+ <Button
+ android:id="@+id/digit_4"
+ style="@style/PadButtonStyle.Numeric"
+ android:onClick="onButtonClick"
+ android:text="@string/digit_4" />
+
+ <Button
+ android:id="@+id/digit_5"
+ style="@style/PadButtonStyle.Numeric"
+ android:onClick="onButtonClick"
+ android:text="@string/digit_5" />
+
+ <Button
+ android:id="@+id/digit_6"
+ style="@style/PadButtonStyle.Numeric"
+ android:onClick="onButtonClick"
+ android:text="@string/digit_6" />
+
+ <Button
+ android:id="@+id/digit_1"
+ style="@style/PadButtonStyle.Numeric"
+ android:onClick="onButtonClick"
+ android:text="@string/digit_1" />
+
+ <Button
+ android:id="@+id/digit_2"
+ style="@style/PadButtonStyle.Numeric"
+ android:onClick="onButtonClick"
+ android:text="@string/digit_2" />
+
+ <Button
+ android:id="@+id/digit_3"
+ style="@style/PadButtonStyle.Numeric"
+ android:onClick="onButtonClick"
+ android:text="@string/digit_3" />
+
+ <Button
+ android:id="@+id/dec_point"
+ style="@style/PadButtonStyle.Numeric"
+ android:onClick="onButtonClick"
+ android:text="@string/dec_point" />
+
+ <Button
+ android:id="@+id/digit_0"
+ style="@style/PadButtonStyle.Numeric"
+ android:onClick="onButtonClick"
+ android:text="@string/digit_0" />
+
+ <Button
+ android:id="@+id/eq"
+ style="@style/PadButtonStyle.Numeric.Equals"
+ android:contentDescription="@string/desc_eq"
+ android:onClick="onButtonClick"
+ android:text="@string/eq" />
+
+</com.android.calculator2.CalculatorPadLayout>
diff --git a/res/layout/pad_operator_one_col.xml b/res/layout/pad_operator_one_col.xml
new file mode 100644
index 0000000..a794f72
--- /dev/null
+++ b/res/layout/pad_operator_one_col.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<com.android.calculator2.CalculatorPadLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/pad_operator"
+ style="@style/PadLayoutStyle.Operator"
+ android:background="@color/pad_operator_background_color"
+ android:columnCount="1"
+ android:rowCount="5">
+
+ <Button
+ android:id="@+id/del"
+ style="@style/PadButtonStyle.Operator.Text"
+ android:contentDescription="@string/desc_del"
+ android:onClick="onButtonClick"
+ android:text="@string/del" />
+
+ <Button
+ android:id="@+id/clr"
+ style="@style/PadButtonStyle.Operator.Text"
+ android:contentDescription="@string/desc_clr"
+ android:onClick="onButtonClick"
+ android:text="@string/clr"
+ android:visibility="gone" />
+
+ <Button
+ android:id="@+id/op_div"
+ style="@style/PadButtonStyle.Operator"
+ android:contentDescription="@string/desc_op_div"
+ android:onClick="onButtonClick"
+ android:text="@string/op_div" />
+
+ <Button
+ android:id="@+id/op_mul"
+ style="@style/PadButtonStyle.Operator"
+ android:contentDescription="@string/desc_op_mul"
+ android:onClick="onButtonClick"
+ android:text="@string/op_mul" />
+
+ <Button
+ android:id="@+id/op_sub"
+ style="@style/PadButtonStyle.Operator"
+ android:contentDescription="@string/desc_op_sub"
+ android:onClick="onButtonClick"
+ android:text="@string/op_sub" />
+
+ <Button
+ android:id="@+id/op_add"
+ style="@style/PadButtonStyle.Operator"
+ android:contentDescription="@string/desc_op_add"
+ android:onClick="onButtonClick"
+ android:text="@string/op_add" />
+
+</com.android.calculator2.CalculatorPadLayout>
diff --git a/res/layout/pad_operator_two_col.xml b/res/layout/pad_operator_two_col.xml
new file mode 100644
index 0000000..6009e89
--- /dev/null
+++ b/res/layout/pad_operator_two_col.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<com.android.calculator2.CalculatorPadLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/pad_operator"
+ style="@style/PadLayoutStyle.Operator"
+ android:background="@color/pad_operator_background_color"
+ android:columnCount="2"
+ android:rowCount="4">
+
+ <Button
+ android:id="@+id/op_div"
+ style="@style/PadButtonStyle.Operator"
+ android:contentDescription="@string/desc_op_div"
+ android:onClick="onButtonClick"
+ android:text="@string/op_div" />
+
+ <Button
+ android:id="@+id/del"
+ style="@style/PadButtonStyle.Operator.Text"
+ android:contentDescription="@string/desc_del"
+ android:onClick="onButtonClick"
+ android:text="@string/del" />
+
+ <Button
+ android:id="@+id/clr"
+ style="@style/PadButtonStyle.Operator.Text"
+ android:contentDescription="@string/desc_clr"
+ android:onClick="onButtonClick"
+ android:text="@string/clr"
+ android:visibility="gone" />
+
+ <Button
+ android:id="@+id/op_mul"
+ style="@style/PadButtonStyle.Operator"
+ android:contentDescription="@string/op_mul"
+ android:onClick="onButtonClick"
+ android:text="@string/op_mul" />
+
+ <Space style="@style/PadButtonStyle.Operator" />
+
+ <Button
+ android:id="@+id/op_sub"
+ style="@style/PadButtonStyle.Operator"
+ android:contentDescription="@string/desc_op_sub"
+ android:onClick="onButtonClick"
+ android:text="@string/op_sub" />
+
+ <Space style="@style/PadButtonStyle.Operator" />
+
+ <Button
+ android:id="@+id/op_add"
+ style="@style/PadButtonStyle.Operator"
+ android:contentDescription="@string/desc_op_add"
+ android:onClick="onButtonClick"
+ android:text="@string/op_add" />
+
+ <Button
+ android:id="@+id/eq"
+ style="@style/PadButtonStyle.Operator"
+ android:contentDescription="@string/desc_eq"
+ android:onClick="onButtonClick"
+ android:text="@string/eq" />
+
+</com.android.calculator2.CalculatorPadLayout>
diff --git a/res/values-land/arrays.xml b/res/values-land/arrays.xml
deleted file mode 100644
index 0046fe0..0000000
--- a/res/values-land/arrays.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
- * Copyright 2011, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <array name="simple_buttons">
- <item>@+id/digit0</item>
- <item>@+id/digit1</item>
- <item>@+id/digit2</item>
- <item>@+id/digit3</item>
- <item>@+id/digit4</item>
- <item>@+id/digit5</item>
- <item>@+id/digit6</item>
- <item>@+id/digit7</item>
- <item>@+id/digit8</item>
- <item>@+id/digit9</item>
- <item>@+id/dot</item>
- <item>@+id/plus</item>
- <item>@+id/minus</item>
- <item>@+id/div</item>
- <item>@+id/mul</item>
- <item>@+id/equal</item>
- <item>@+id/leftParen</item>
- <item>@+id/rightParen</item>
- </array>
-
- <array name="advanced_buttons">
- <item>@+id/sin</item>
- <item>@+id/cos</item>
- <item>@+id/tan</item>
- <item>@+id/ln</item>
- <item>@+id/lg</item>
- <item>@+id/e</item>
- <item>@+id/pi</item>
- <item>@+id/power</item>
- <item>@+id/factorial</item>
- <item>@+id/sqrt</item>
- </array>
-
-</resources>
diff --git a/res/values-land/layout.xml b/res/values-land/layout.xml
new file mode 100644
index 0000000..8bc268c
--- /dev/null
+++ b/res/values-land/layout.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<resources>
+ <item name="activity_calculator" type="layout">@layout/activity_calculator_land</item>
+</resources>
\ No newline at end of file
diff --git a/res/values-land/styles.xml b/res/values-land/styles.xml
new file mode 100644
index 0000000..f0c08bb
--- /dev/null
+++ b/res/values-land/styles.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<!-- Styles for landscape phone (e.g. Nexus 4/5). -->
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <style name="DisplayEditTextStyle.Formula">
+ <item name="android:paddingTop">24dip</item>
+ <item name="android:paddingBottom">8dip</item>
+ <item name="android:paddingStart">16dip</item>
+ <item name="android:paddingEnd">16dip</item>
+ <item name="android:textSize">30sp</item>
+ </style>
+
+ <style name="DisplayEditTextStyle.Result">
+ <item name="android:paddingTop">8dip</item>
+ <item name="android:paddingBottom">24dip</item>
+ <item name="android:paddingStart">16dip</item>
+ <item name="android:paddingEnd">16dip</item>
+ <item name="android:textSize">30sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Advanced">
+ <item name="android:layout_marginTop">4dip</item>
+ <item name="android:layout_marginBottom">4dip</item>
+ <item name="android:layout_marginStart">8dip</item>
+ <item name="android:layout_marginEnd">8dip</item>
+ <item name="android:textColor">@color/pad_button_advanced_text_color</item>
+ <item name="android:textSize">15sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Numeric">
+ <item name="android:layout_margin">4dip</item>
+ <item name="android:textSize">23sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Numeric.Equals">
+ <item name="android:visibility">gone</item>
+ </style>
+
+ <style name="PadButtonStyle.Operator">
+ <item name="android:layout_marginTop">4dip</item>
+ <item name="android:layout_marginBottom">4dip</item>
+ <item name="android:layout_marginStart">8dip</item>
+ <item name="android:layout_marginEnd">8dip</item>
+ <item name="android:textSize">20sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Operator.Text">
+ <item name="android:textAllCaps">true</item>
+ <item name="android:textSize">15sp</item>
+ </style>
+
+ <style name="PadLayoutStyle.Advanced">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_weight">208</item>
+ <item name="android:paddingTop">4dip</item>
+ <item name="android:paddingBottom">4dip</item>
+ <item name="android:paddingStart">8dip</item>
+ <item name="android:paddingEnd">8dip</item>
+ <item name="android:columnCount">3</item>
+ <item name="android:rowCount">4</item>
+ </style>
+
+ <style name="PadLayoutStyle.Numeric">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_weight">240</item>
+ <item name="android:paddingTop">4dip</item>
+ <item name="android:paddingBottom">4dip</item>
+ <item name="android:paddingStart">8dip</item>
+ <item name="android:paddingEnd">8dip</item>
+ </style>
+
+ <style name="PadLayoutStyle.Operator">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_weight">144</item>
+ <item name="android:paddingTop">4dip</item>
+ <item name="android:paddingBottom">4dip</item>
+ <item name="android:paddingStart">12dip</item>
+ <item name="android:paddingEnd">12dip</item>
+ </style>
+
+</resources>
diff --git a/res/values-port/arrays.xml b/res/values-port/arrays.xml
deleted file mode 100644
index 8bc888c..0000000
--- a/res/values-port/arrays.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
- * Copyright 2011, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <array name="simple_buttons">
- <item>@+id/digit0</item>
- <item>@+id/digit1</item>
- <item>@+id/digit2</item>
- <item>@+id/digit3</item>
- <item>@+id/digit4</item>
- <item>@+id/digit5</item>
- <item>@+id/digit6</item>
- <item>@+id/digit7</item>
- <item>@+id/digit8</item>
- <item>@+id/digit9</item>
- <item>@+id/dot</item>
- <item>@+id/plus</item>
- <item>@+id/minus</item>
- <item>@+id/div</item>
- <item>@+id/mul</item>
- <item>@+id/equal</item>
- </array>
-
- <array name="advanced_buttons">
- <item>@+id/leftParen</item>
- <item>@+id/rightParen</item>
- <item>@+id/sin</item>
- <item>@+id/cos</item>
- <item>@+id/tan</item>
- <item>@+id/ln</item>
- <item>@+id/lg</item>
- <item>@+id/e</item>
- <item>@+id/pi</item>
- <item>@+id/power</item>
- <item>@+id/factorial</item>
- <item>@+id/sqrt</item>
- </array>
-
-</resources>
\ No newline at end of file
diff --git a/res/values-port/dimens.xml b/res/values-port/dimens.xml
new file mode 100644
index 0000000..bf71f71
--- /dev/null
+++ b/res/values-port/dimens.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<resources>
+
+ <!-- The margin between the pad pages when displayed using a view pager. -->
+ <dimen name="pad_page_margin">-32dip</dimen>
+
+</resources>
diff --git a/res/values-port/layout.xml b/res/values-port/layout.xml
new file mode 100644
index 0000000..99ea0b8
--- /dev/null
+++ b/res/values-port/layout.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<resources>
+ <item name="activity_calculator" type="layout">@layout/activity_calculator_port</item>
+</resources>
\ No newline at end of file
diff --git a/res/values-port/styles.xml b/res/values-port/styles.xml
new file mode 100644
index 0000000..b998d62
--- /dev/null
+++ b/res/values-port/styles.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<!-- Styles for portrait phone (e.g. Nexus 4/5). -->
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <style name="DisplayEditTextStyle.Formula">
+ <item name="android:paddingTop">48dip</item>
+ <item name="android:paddingBottom">24dip</item>
+ <item name="android:paddingStart">16dip</item>
+ <item name="android:paddingEnd">16dip</item>
+ <item name="minTextSize">36sp</item>
+ <item name="maxTextSize">64sp</item>
+ <item name="stepTextSize">8sp</item>
+ </style>
+
+ <style name="DisplayEditTextStyle.Result">
+ <item name="android:paddingTop">24dip</item>
+ <item name="android:paddingBottom">48dip</item>
+ <item name="android:paddingStart">16dip</item>
+ <item name="android:paddingEnd">16dip</item>
+ <item name="android:textSize">36sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Advanced">
+ <item name="android:layout_margin">4dip</item>
+ <item name="android:textColor">@color/pad_button_advanced_text_color</item>
+ <item name="android:textSize">20sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Numeric">
+ <item name="android:layout_margin">4dip</item>
+ <item name="android:textSize">32sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Numeric.Equals">
+ <item name="android:visibility">visible</item>
+ </style>
+
+ <style name="PadButtonStyle.Operator">
+ <item name="android:layout_margin">8dip</item>
+ <item name="android:textSize">23sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Operator.Text">
+ <item name="android:textAllCaps">true</item>
+ <item name="android:textSize">15sp</item>
+ </style>
+
+ <style name="PadLayoutStyle.Advanced">
+ <item name="android:paddingTop">12dip</item>
+ <item name="android:paddingBottom">20dip</item>
+ <item name="android:paddingStart">20dip</item>
+ <item name="android:paddingEnd">20dip</item>
+ <item name="android:columnCount">3</item>
+ <item name="android:rowCount">4</item>
+ </style>
+
+ <style name="PadLayoutStyle.Numeric">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_weight">264</item>
+ <item name="android:paddingTop">12dip</item>
+ <item name="android:paddingBottom">20dip</item>
+ <item name="android:paddingStart">12dip</item>
+ <item name="android:paddingEnd">12dip</item>
+ </style>
+
+ <style name="PadLayoutStyle.Operator">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_weight">96</item>
+ <item name="android:paddingTop">8dip</item>
+ <item name="android:paddingBottom">24dip</item>
+ <item name="android:paddingStart">8dip</item>
+ <item name="android:paddingEnd">24dip</item>
+ </style>
+
+ <style name="PadPageShadow">
+ <item name="android:layout_width">8dip</item>
+ <item name="android:layout_height">match_parent</item>
+ <item name="android:background">@drawable/pad_page_shadow</item>
+ </style>
+
+</resources>
\ No newline at end of file
diff --git a/res/values-sw600dp-land/styles.xml b/res/values-sw600dp-land/styles.xml
new file mode 100644
index 0000000..7de1e8a
--- /dev/null
+++ b/res/values-sw600dp-land/styles.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<!-- Styles for landscape 600dip-wide tablet (e.g. Nexus 7). -->
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <style name="DisplayEditTextStyle.Formula">
+ <item name="android:paddingTop">72dip</item>
+ <item name="android:paddingBottom">26dip</item>
+ <item name="android:paddingStart">44dip</item>
+ <item name="android:paddingEnd">44dip</item>
+ <item name="minTextSize">48sp</item>
+ <item name="maxTextSize">80sp</item>
+ <item name="stepTextSize">8sp</item>
+ </style>
+
+ <style name="DisplayEditTextStyle.Result">
+ <item name="android:paddingTop">26dip</item>
+ <item name="android:paddingBottom">46dip</item>
+ <item name="android:paddingStart">44dip</item>
+ <item name="android:paddingEnd">44dip</item>
+ <item name="android:textSize">48sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Advanced">
+ <item name="android:layout_margin">6dip</item>
+ <item name="android:textColor">@color/pad_button_advanced_text_color</item>
+ <item name="android:textSize">27sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Numeric">
+ <item name="android:layout_margin">6dip</item>
+ <item name="android:textSize">36sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Numeric.Equals">
+ <item name="android:visibility">gone</item>
+ </style>
+
+ <style name="PadButtonStyle.Operator">
+ <item name="android:layout_margin">6dip</item>
+ <item name="android:textSize">36sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Operator.Text">
+ <item name="android:textAllCaps">true</item>
+ <item name="android:textSize">24sp</item>
+ </style>
+
+ <style name="PadLayoutStyle.Advanced">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_weight">508</item>
+ <item name="android:paddingTop">10dip</item>
+ <item name="android:paddingBottom">10dip</item>
+ <item name="android:paddingStart">18dip</item>
+ <item name="android:paddingEnd">22dip</item>
+ <item name="android:columnCount">3</item>
+ <item name="android:rowCount">4</item>
+ </style>
+
+ <style name="PadLayoutStyle.Numeric">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_weight">532</item>
+ <item name="android:paddingTop">10dip</item>
+ <item name="android:paddingBottom">10dip</item>
+ <item name="android:paddingStart">22dip</item>
+ <item name="android:paddingEnd">18dip</item>
+ </style>
+
+ <style name="PadLayoutStyle.Operator">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_weight">240</item>
+ <item name="android:paddingTop">10dip</item>
+ <item name="android:paddingBottom">10dip</item>
+ <item name="android:paddingStart">18dip</item>
+ <item name="android:paddingEnd">18dip</item>
+ </style>
+
+</resources>
diff --git a/res/values-sw600dp-port/dimens.xml b/res/values-sw600dp-port/dimens.xml
deleted file mode 100644
index 799f6fe..0000000
--- a/res/values-sw600dp-port/dimens.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<resources>
- <dimen name="group_padding">48sp</dimen>
-</resources>
diff --git a/res/values-sw600dp-port/layout.xml b/res/values-sw600dp-port/layout.xml
new file mode 100644
index 0000000..46d71cb
--- /dev/null
+++ b/res/values-sw600dp-port/layout.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<resources>
+ <item name="activity_calculator" type="layout">@layout/activity_calculator_tablet_port</item>
+</resources>
\ No newline at end of file
diff --git a/res/values-sw600dp-port/styles.xml b/res/values-sw600dp-port/styles.xml
new file mode 100644
index 0000000..3a4c188
--- /dev/null
+++ b/res/values-sw600dp-port/styles.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+
+<!-- Styles for portrait 600dip-wide tablet (e.g. Nexus 7). -->
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <style name="DisplayEditTextStyle.Formula">
+ <item name="android:paddingTop">72dip</item>
+ <item name="android:paddingBottom">32dip</item>
+ <item name="android:paddingStart">44dip</item>
+ <item name="android:paddingEnd">44dip</item>
+ <item name="minTextSize">48sp</item>
+ <item name="maxTextSize">80sp</item>
+ <item name="stepTextSize">8sp</item>
+ </style>
+
+ <style name="DisplayEditTextStyle.Result">
+ <item name="android:paddingTop">32dip</item>
+ <item name="android:paddingBottom">90dip</item>
+ <item name="android:paddingStart">44dip</item>
+ <item name="android:paddingEnd">44dip</item>
+ <item name="android:textSize">48sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Advanced">
+ <item name="android:layout_marginTop">8dip</item>
+ <item name="android:layout_marginBottom">8dip</item>
+ <item name="android:layout_marginStart">12dip</item>
+ <item name="android:layout_marginEnd">12dip</item>
+ <item name="android:textColor">@color/pad_button_advanced_text_color</item>
+ <item name="android:textSize">27sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Numeric">
+ <item name="android:layout_margin">8dip</item>
+ <item name="android:textSize">36sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Numeric.Equals">
+ <item name="android:visibility">gone</item>
+ </style>
+
+ <style name="PadButtonStyle.Operator">
+ <item name="android:layout_marginTop">8dip</item>
+ <item name="android:layout_marginBottom">8dip</item>
+ <item name="android:layout_marginStart">16dip</item>
+ <item name="android:layout_marginEnd">16dip</item>
+ <item name="android:textSize">36sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Operator.Text">
+ <item name="android:textAllCaps">true</item>
+ <item name="android:textSize">24sp</item>
+ </style>
+
+ <style name="PadLayoutStyle.Advanced">
+ <item name="android:layout_height">0dip</item>
+ <item name="android:layout_weight">256</item>
+ <item name="android:paddingTop">8dip</item>
+ <item name="android:paddingBottom">8dip</item>
+ <item name="android:paddingStart">16dip</item>
+ <item name="android:paddingEnd">16dip</item>
+ <item name="android:columnCount">6</item>
+ <item name="android:rowCount">2</item>
+ </style>
+
+ <style name="PadLayoutStyle.Numeric">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_weight">532</item>
+ <item name="android:paddingTop">8dip</item>
+ <item name="android:paddingBottom">8dip</item>
+ <item name="android:paddingStart">16dip</item>
+ <item name="android:paddingEnd">16dip</item>
+ </style>
+
+ <style name="PadLayoutStyle.Operator">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_weight">240</item>
+ <item name="android:paddingTop">8dip</item>
+ <item name="android:paddingBottom">8dip</item>
+ <item name="android:paddingStart">0dip</item>
+ <item name="android:paddingEnd">8dip</item>
+ </style>
+
+ <style name="PadLinearLayoutStyle">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">0dip</item>
+ <item name="android:layout_weight">508</item>
+ </style>
+
+</resources>
diff --git a/res/values-sw600dp/arrays.xml b/res/values-sw600dp/arrays.xml
deleted file mode 100644
index 219b3e5..0000000
--- a/res/values-sw600dp/arrays.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
- * Copyright 2011, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <array name="buttons">
- <item>@+id/digit0</item>
- <item>@+id/digit1</item>
- <item>@+id/digit2</item>
- <item>@+id/digit3</item>
- <item>@+id/digit4</item>
- <item>@+id/digit5</item>
- <item>@+id/digit6</item>
- <item>@+id/digit7</item>
- <item>@+id/digit8</item>
- <item>@+id/digit9</item>
- <item>@+id/dot</item>
- <item>@+id/plus</item>
- <item>@+id/minus</item>
- <item>@+id/div</item>
- <item>@+id/mul</item>
- <item>@+id/equal</item>
- <item>@+id/leftParen</item>
- <item>@+id/rightParen</item>
- <item>@+id/sin</item>
- <item>@+id/cos</item>
- <item>@+id/tan</item>
- <item>@+id/ln</item>
- <item>@+id/lg</item>
- <item>@+id/e</item>
- <item>@+id/pi</item>
- <item>@+id/power</item>
- <item>@+id/factorial</item>
- <item>@+id/sqrt</item>
- </array>
-
-</resources>
\ No newline at end of file
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
deleted file mode 100644
index ec548bb..0000000
--- a/res/values-sw600dp/dimens.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<resources>
- <dimen name="btn_digit_text_size">50sp</dimen>
- <dimen name="btn_operation_text_size">50sp</dimen>
- <dimen name="btn_function_text_size">25sp</dimen>
- <dimen name="btn_clear_text_size">40sp</dimen>
-
- <dimen name="left_right_padding">16sp</dimen>
- <dimen name="top_bottom_padding">16sp</dimen>
- <dimen name="group_padding">16sp</dimen>
-</resources>
diff --git a/res/values-sw800dp-land/dimens.xml b/res/values-sw800dp-land/dimens.xml
deleted file mode 100644
index 9d1c26c..0000000
--- a/res/values-sw800dp-land/dimens.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<resources>
- <dimen name="left_right_padding">48sp</dimen>
- <dimen name="top_bottom_padding">48sp</dimen>
- <dimen name="group_padding">48sp</dimen>
-</resources>
diff --git a/res/values-sw800dp-land/styles.xml b/res/values-sw800dp-land/styles.xml
new file mode 100644
index 0000000..da69230
--- /dev/null
+++ b/res/values-sw800dp-land/styles.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<!-- Styles for landscape 800dip-wide tablet (e.g. Nexus 10). -->
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <style name="DisplayEditTextStyle.Formula">
+ <item name="android:paddingTop">72dip</item>
+ <item name="android:paddingBottom">26dip</item>
+ <item name="android:paddingStart">44dip</item>
+ <item name="android:paddingEnd">44dip</item>
+ <item name="minTextSize">56sp</item>
+ <item name="maxTextSize">96sp</item>
+ <item name="stepTextSize">8sp</item>
+ </style>
+
+ <style name="DisplayEditTextStyle.Result">
+ <item name="android:paddingTop">26dip</item>
+ <item name="android:paddingBottom">46dip</item>
+ <item name="android:paddingStart">44dip</item>
+ <item name="android:paddingEnd">44dip</item>
+ <item name="android:textSize">56sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Advanced">
+ <item name="android:layout_margin">6dip</item>
+ <item name="android:textColor">@color/pad_button_advanced_text_color</item>
+ <item name="android:textSize">36sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Numeric">
+ <item name="android:layout_margin">6dip</item>
+ <item name="android:textSize">48sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Numeric.Equals">
+ <item name="android:visibility">gone</item>
+ </style>
+
+ <style name="PadButtonStyle.Operator">
+ <item name="android:layout_margin">6dip</item>
+ <item name="android:textSize">48sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Operator.Text">
+ <item name="android:textAllCaps">true</item>
+ <item name="android:textSize">32sp</item>
+ </style>
+
+ <style name="PadLayoutStyle.Advanced">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_weight">508</item>
+ <item name="android:paddingTop">10dip</item>
+ <item name="android:paddingBottom">10dip</item>
+ <item name="android:paddingStart">18dip</item>
+ <item name="android:paddingEnd">22dip</item>
+ <item name="android:columnCount">3</item>
+ <item name="android:rowCount">4</item>
+ </style>
+
+ <style name="PadLayoutStyle.Numeric">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_weight">532</item>
+ <item name="android:paddingTop">10dip</item>
+ <item name="android:paddingBottom">10dip</item>
+ <item name="android:paddingStart">22dip</item>
+ <item name="android:paddingEnd">18dip</item>
+ </style>
+
+ <style name="PadLayoutStyle.Operator">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_weight">240</item>
+ <item name="android:paddingTop">10dip</item>
+ <item name="android:paddingBottom">10dip</item>
+ <item name="android:paddingStart">18dip</item>
+ <item name="android:paddingEnd">18dip</item>
+ </style>
+
+</resources>
diff --git a/res/values-sw800dp-port/dimens.xml b/res/values-sw800dp-port/dimens.xml
deleted file mode 100644
index a6b181e..0000000
--- a/res/values-sw800dp-port/dimens.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<resources>
- <dimen name="left_right_padding">32sp</dimen>
- <dimen name="top_bottom_padding">64sp</dimen>
- <dimen name="group_padding">72sp</dimen>
-</resources>
diff --git a/res/values-sw800dp-port/layout.xml b/res/values-sw800dp-port/layout.xml
new file mode 100644
index 0000000..46d71cb
--- /dev/null
+++ b/res/values-sw800dp-port/layout.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<resources>
+ <item name="activity_calculator" type="layout">@layout/activity_calculator_tablet_port</item>
+</resources>
\ No newline at end of file
diff --git a/res/values-sw800dp-port/styles.xml b/res/values-sw800dp-port/styles.xml
new file mode 100644
index 0000000..9b7475a
--- /dev/null
+++ b/res/values-sw800dp-port/styles.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<!-- Styles for portrait 800dip-wide tablet (e.g. Nexus 10). -->
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <style name="DisplayEditTextStyle.Formula">
+ <item name="android:paddingTop">72dip</item>
+ <item name="android:paddingBottom">32dip</item>
+ <item name="android:paddingStart">44dip</item>
+ <item name="android:paddingEnd">44dip</item>
+ <item name="minTextSize">56sp</item>
+ <item name="maxTextSize">96sp</item>
+ <item name="stepTextSize">8sp</item>
+ </style>
+
+ <style name="DisplayEditTextStyle.Result">
+ <item name="android:paddingTop">32dip</item>
+ <item name="android:paddingBottom">90dip</item>
+ <item name="android:paddingStart">44dip</item>
+ <item name="android:paddingEnd">44dip</item>
+ <item name="android:textSize">56sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Advanced">
+ <item name="android:layout_marginTop">8dip</item>
+ <item name="android:layout_marginBottom">8dip</item>
+ <item name="android:layout_marginStart">12dip</item>
+ <item name="android:layout_marginEnd">12dip</item>
+ <item name="android:textColor">@color/pad_button_advanced_text_color</item>
+ <item name="android:textSize">36sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Numeric">
+ <item name="android:layout_margin">8dip</item>
+ <item name="android:textSize">48sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Numeric.Equals">
+ <item name="android:visibility">gone</item>
+ </style>
+
+ <style name="PadButtonStyle.Operator">
+ <item name="android:layout_marginTop">8dip</item>
+ <item name="android:layout_marginBottom">8dip</item>
+ <item name="android:layout_marginStart">16dip</item>
+ <item name="android:layout_marginEnd">16dip</item>
+ <item name="android:textSize">48sp</item>
+ </style>
+
+ <style name="PadButtonStyle.Operator.Text">
+ <item name="android:textAllCaps">true</item>
+ <item name="android:textSize">32sp</item>
+ </style>
+
+ <style name="PadLayoutStyle.Advanced">
+ <item name="android:layout_height">0dip</item>
+ <item name="android:layout_weight">256</item>
+ <item name="android:paddingTop">8dip</item>
+ <item name="android:paddingBottom">8dip</item>
+ <item name="android:paddingStart">16dip</item>
+ <item name="android:paddingEnd">16dip</item>
+ <item name="android:columnCount">6</item>
+ <item name="android:rowCount">2</item>
+ </style>
+
+ <style name="PadLayoutStyle.Numeric">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_weight">532</item>
+ <item name="android:paddingTop">8dip</item>
+ <item name="android:paddingBottom">8dip</item>
+ <item name="android:paddingStart">16dip</item>
+ <item name="android:paddingEnd">16dip</item>
+ </style>
+
+ <style name="PadLayoutStyle.Operator">
+ <item name="android:layout_width">0dip</item>
+ <item name="android:layout_weight">240</item>
+ <item name="android:paddingTop">8dip</item>
+ <item name="android:paddingBottom">8dip</item>
+ <item name="android:paddingStart">0dip</item>
+ <item name="android:paddingEnd">8dip</item>
+ </style>
+
+ <style name="PadLinearLayoutStyle">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">0dip</item>
+ <item name="android:layout_weight">508</item>
+ </style>
+
+</resources>
diff --git a/res/values-sw800dp/dimens.xml b/res/values-sw800dp/dimens.xml
deleted file mode 100644
index 7bd649f..0000000
--- a/res/values-sw800dp/dimens.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<resources>
- <dimen name="btn_digit_text_size">64sp</dimen>
- <dimen name="btn_operation_text_size">64sp</dimen>
- <dimen name="btn_function_text_size">32sp</dimen>
- <dimen name="btn_clear_text_size">48sp</dimen>
-</resources>
diff --git a/res/values/attr.xml b/res/values/attr.xml
new file mode 100644
index 0000000..5043663
--- /dev/null
+++ b/res/values/attr.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <declare-styleable name="CalculatorEditText">
+ <attr name="minTextSize" format="dimension" />
+ <attr name="maxTextSize" format="dimension" />
+ <attr name="stepTextSize" format="dimension" />
+ </declare-styleable>
+
+</resources>
diff --git a/res/values/color.xml b/res/values/color.xml
new file mode 100644
index 0000000..488f3ad
--- /dev/null
+++ b/res/values/color.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<resources>
+
+ <!-- Default background color for the status bar. -->
+ <color name="calculator_accent_color">#00BCD4</color>
+
+ <!-- Color to indicate an error has occured. -->
+ <color name="calculator_error_color">#F40056</color>
+
+ <!-- Background color of the calculator display. -->
+ <color name="display_background_color">#FFF</color>
+
+ <!-- Text color for the formula in the calculator display. -->
+ <color name="display_formula_text_color">#AAA</color>
+
+ <!-- Text color for the result in the calculator display. -->
+ <color name="display_result_text_color">#CCC</color>
+
+ <!-- Background color for the numeric pad. -->
+ <color name="pad_numeric_background_color">#434343</color>
+
+ <!-- Background color for the operator pad. -->
+ <color name="pad_operator_background_color">#636363</color>
+
+ <!-- Background color for the advanced pad. -->
+ <color name="pad_advanced_background_color">#1DE9B6</color>
+
+ <!-- Text color for a button in a pad. -->
+ <color name="pad_button_text_color">#FFF</color>
+
+ <!-- Text color for a button in the advanced pad. -->
+ <color name="pad_button_advanced_text_color">#85000000</color>
+
+ <!-- Tint color when a button is pressed in a pad. -->
+ <color name="pad_button_tint_color">#80CCCCCC</color>
+
+</resources>
\ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
deleted file mode 100644
index 3eaf995..0000000
--- a/res/values/colors.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <color name="magic_flame">#00ffffff</color>
-
- <color name="accent">#18FFFF</color>
-
- <color name="primary_light">#B3E5FC</color>
- <color name="primary">#03A9F4</color>
- <color name="primary_dark">#0288D1</color>
-
- <color name="gray_80">#CCCCCC</color>
- <color name="gray_70">#B3B3B3</color>
- <color name="gray_60">#999999</color>
- <color name="gray_50">#808080</color>
- <color name="gray_40">#666666</color>
- <color name="gray_30">#4D4D4D</color>
- <color name="gray_20">#333333</color>
-
- <color name="white">#FFFFFF</color>
- <color name="black">#000000</color>
-
- <color name="text_light">#B3FFFFFF</color>
- <color name="text_dark">#B3000000</color>
-</resources>
diff --git a/res/values/constants.xml b/res/values/constants.xml
deleted file mode 100644
index 98c14ec..0000000
--- a/res/values/constants.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <integer name="max_digits">14</integer>
-</resources>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
deleted file mode 100644
index 74a949b..0000000
--- a/res/values/dimens.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <dimen name="btn_digit_text_size">40sp</dimen>
- <dimen name="btn_operation_text_size">40sp</dimen>
- <dimen name="btn_function_text_size">30sp</dimen>
- <dimen name="btn_clear_text_size">30sp</dimen>
- <dimen name="small_text_size">16dp</dimen>
- <dimen name="pager_shadow_width">16dp</dimen>
- <dimen name="activity_horizontal_margin">16dp</dimen>
- <dimen name="activity_vertical_margin">16dp</dimen>
-
- <!-- 72 = 16 + 8N -->
- <dimen name="display_maximum_text_size">72sp</dimen>
- <dimen name="display_minimum_text_size">16sp</dimen>
- <dimen name="display_step_text_size">8sp</dimen>
-
-</resources>
diff --git a/res/values/donottranslate_strings.xml b/res/values/donottranslate_strings.xml
new file mode 100644
index 0000000..69d2959
--- /dev/null
+++ b/res/values/donottranslate_strings.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<resources>
+
+ <!-- Constant for Euler's number (i.e. "2.7182…"). [CHAR_LIMIT=1] -->
+ <string name="const_e">e</string>
+ <!-- Constant for pi (i.e. "3.1415…"). [CHAR_LIMIT=1] -->
+ <string name="const_pi">π</string>
+
+ <!-- Left parenthesis (e.g. "log(", "2 × (3 - 1)". [CHAR_LIMIT=1] -->
+ <string name="lparen">(</string>
+ <!-- Right parenthesis (e.g. "log(2)", "(3 - 1) × 2". [CHAR_LIMIT=1] -->
+ <string name="rparen">)</string>
+
+ <!-- Addition operator (e.g. "1 + 2"). [CHAR_LIMIT=1] -->
+ <string name="op_add">+</string>
+ <!-- Divide operator (e.g. "1 ÷ 2"). [CHAR_LIMIT=1] -->
+ <string name="op_div">÷</string>
+ <!-- Factorial operator (e.g. "2!"). [CHAR_LIMIT=1] -->
+ <string name="op_fact">!</string>
+ <!-- Multiply operator (e.g. "1 × 2"). [CHAR_LIMIT=1] -->
+ <string name="op_mul">×</string>
+ <!-- Power operator (e.g. "1 ^ 2"). [CHAR_LIMIT=1] -->
+ <string name="op_pow">^</string>
+ <!-- Square root operator (e.g. "√1"). [CHAR_LIMIT=1] -->
+ <string name="op_sqrt">√</string>
+ <!-- Subtraction operator (e.g. "1 - 2"). [CHAR_LIMIT=1] -->
+ <string name="op_sub">−</string>
+
+ <!-- Equals operator (e.g. "1 + 2 = ?"). [CHAR_LIMIT=1] -->
+ <string name="eq">=</string>
+ <!-- Result displayed when expression evaluates to infinity. [CHAR_LIMIT=1] -->
+ <string name="inf">∞</string>
+
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b1c990a..bcdd55e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,202 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2007 The Android Open Source Project
+ Copyright (C) 2014 The Android Open Source Project
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
<resources>
- <!-- Application name -->
+ <!-- Name of the application. [CHAR_LIMIT=NONE] -->
<string name="app_name">Calculator</string>
- <!-- If there is a syntax error in the user entered calculation, an error dialog will appear. This is the title. -->
- <string name="error">Error</string>
- <!-- Displayed numbers for the digit buttons -->
- <string name="digit0">0</string>
- <!-- Displayed numbers for the digit buttons -->
- <string name="digit1">1</string>
- <!-- Displayed numbers for the digit buttons -->
- <string name="digit2">2</string>
- <!-- Displayed numbers for the digit buttons -->
- <string name="digit3">3</string>
- <!-- Displayed numbers for the digit buttons -->
- <string name="digit4">4</string>
- <!-- Displayed numbers for the digit buttons -->
- <string name="digit5">5</string>
- <!-- Displayed numbers for the digit buttons -->
- <string name="digit6">6</string>
- <!-- Displayed numbers for the digit buttons -->
- <string name="digit7">7</string>
- <!-- Displayed numbers for the digit buttons -->
- <string name="digit8">8</string>
- <!-- Displayed numbers for the digit buttons -->
- <string name="digit9">9</string>
- <!-- Button name on screen to delete the last entered digit or operator -->
- <string name="del">DEL</string>
- <!-- Button name on screen to clear the entire calculation field. [CHAR LIMIT=6] -->
- <string name="clear">CLR</string>
- <!-- Do not translate. Unicode division sign; don't translate. Displayed as button on screen. -->
- <string name="div">\u00f7</string>
- <!-- Do not translate. Unicode multiplication sign; don't translate. Displayed as button on screen. -->
- <string name="mul">\u00d7</string>
- <!-- Do not translate. Plus sign, displayed as button on screen -->
- <string name="plus">+</string>
- <!-- Do not translate. Unicode minus sign; don't translate. Displayed as button on screen. -->
- <string name="minus">\u2212</string>
- <!-- Do not translate. Decimal point; don't translate. Displayed as button on screen. -->
- <string name="dot">.</string>
- <!-- Do not translate. Equal sign; don't translate. Displayed as button on screen. -->
- <string name="equal">=</string>
- <!-- Do not translate. Down arrow; don't translate. Displayed as button on screen. -->
- <string name="enter">\u2193</string>
- <!-- Displayed on buttons on screen for the sin function. -->
- <string name="sin">sin</string>
- <!-- Do not translate. What we replace translated SIN with for calculating sin. -->
- <string name="sin_mathematical_value" translate="false">sin</string>
- <!-- Displayed on buttons on screen for the cos function. -->
- <string name="cos">cos</string>
- <!-- Do not translate. What we replace translated COS with for calculating cos. -->
- <string name="cos_mathematical_value" translate="false">cos</string>
- <!-- Displayed on buttons on screen for the tan function. -->
- <string name="tan">tan</string>
- <!-- Do not translate. What we replace translated TAN with for calculating tan. -->
- <string name="tan_mathematical_value" translate="false">tan</string>
- <!-- Do not translate. Unicode pi sign; don't translate. Displayed as button on screen. -->
- <string name="pi">\u03c0</string>
- <!-- Displayed on buttons on screen for the e function. -->
- <string name="e">e</string>
- <!-- Do not translate. What we replace translated e with for calculating e. -->
- <string name="e_mathematical_value" translate="false">e</string>
- <!-- Displayed on buttons on screen for the ln function. -->
- <string name="ln">ln</string>
- <!-- Do not translate. What we replace translated ln with for calculating ln. -->
- <string name="ln_mathematical_value" translate="false">ln</string>
- <!-- Displayed on buttons on screen for the log function. -->
- <string name="lg">log</string>
- <!-- Do not translate. What we replace translated lg with for calculating lg. -->
- <string name="lg_mathematical_value" translate="false">lg</string>
- <!-- Displayed on buttons on screen for a left parenthesis. -->
- <string name="leftParen">(</string>
- <!-- Displayed on buttons on screen for a right parenthesis. -->
- <string name="rightParen">)</string>
- <!-- Do not translate. Unicode square root sign; don't translate. Displayed on button on screen. -->
- <string name="sqrt">\u221a</string>
- <!-- Do not translate. Displayed on buttons on screen. -->
- <string name="power">^</string>
- <!-- Do not translate. -->
- <string name="factorial">!</string>
- <!-- Menu item text to take user to the screen with the basic digits and operators. -->
- <string name="basic">Basic panel</string>
- <!-- Menu item text to take user to the screen with the advanced functions, such as sin, cos, ln, log, etc. -->
- <string name="advanced">Advanced panel</string>
- <!-- Menu item text to clear the calculation history. -->
- <string name="clear_history">Clear history</string>
- <!-- Toast shown when text is copied to the clipboard. -->
- <string name="text_copied_toast">Text copied.</string>
- <!--
- Content descriptions for accessibility. These strings will be read aloud to users who are using the calculator with
- accessibility features enabled and should reflect the mathematical concept instead of a direct representation of what is shown
- on the button
- -->
- <string name="leftParenDesc">left parenthesis</string>
- <string name="rightParenDesc">right parenthesis</string>
- <string name="factorialDesc">factorial</string>
- <string name="lnDesc">natural logarithm</string>
- <string name="lgDesc">logarithm</string>
- <string name="sqrtDesc">square root</string>
- <string name="divDesc">divide</string>
- <string name="mulDesc">multiply</string>
- <string name="plusDesc">plus</string>
- <string name="minusDesc">minus</string>
- <string name="dotDesc">point</string>
- <string name="powerDesc">power</string>
- <string name="delDesc">delete</string>
- <string name="clearDesc">clear</string>
- <string name="tanDesc">tangent</string>
- <string name="sinDesc">sine</string>
- <string name="cosDesc">cosine</string>
- <string name="eDesc">Euler\'s number</string>
- <string name="piDesc">pi</string>
- <string name="equalDesc">equals</string>
+ <!-- Error displayed when expression evaluates to NaN. [CHAR_LIMIT=14] -->
+ <string name="error_nan">Not a number</string>
+ <!-- Error displayed when expression contains a syntax error. [CHAR_LIMIT=14] -->
+ <string name="error_syntax">Error</string>
- <!--
- Content descriptions for accessibility used as keys when determining which mathematical
- concept description to speak when accessibility features are enabled. Order of the array is
- important.
- -->
- <string-array name="operators" translatable="false">
- <item>(</item>
- <item>)</item>
- <item>!</item>
- <item>ln</item>
- <item>log</item>
- <item>\u221a</item>
- <item>\u00f7</item>
- <item>\u00d7</item>
- <item>+</item>
- <item>\u2212</item>
- <item>.</item>
- <item>^</item>
- <item>tan</item>
- <item>sin</item>
- <item>cos</item>
- <item>\u03c0</item>
- <item>=</item>
- </string-array>
+ <!-- Decimal separator (e.g. "1.23"). [CHAR_LIMIT=1] -->
+ <string name="dec_point">.</string>
- <!--
- Content descriptions for accessibility. These strings will be read aloud to users who
- are using the calculator with accessibility features enabled and hover over the edit text
- field. These should reflect the mathematical concept instead of a direct representation of
- what is shown in the text field. Order of the array is important.
- -->
- <string-array name="operatorDescs">
+ <!-- Decimal representation of zero (e.g. "0", "10", "1.0", "1e0"). [CHAR_LIMIT=1] -->
+ <string name="digit_0">0</string>
+ <!-- Decimal representation of one (e.g. "1", "11", "1.1", "1e1"). [CHAR_LIMIT=1] -->
+ <string name="digit_1">1</string>
+ <!-- Decimal representation of two (e.g. "2", "22", "2.2", "2e2"). [CHAR_LIMIT=1] -->
+ <string name="digit_2">2</string>
+ <!-- Decimal representation of three (e.g. "3", "33", "3.3", "3e3"). [CHAR_LIMIT=1] -->
+ <string name="digit_3">3</string>
+ <!-- Decimal representation of four (e.g. "4", "44", "4.4", "4e4"). [CHAR_LIMIT=1] -->
+ <string name="digit_4">4</string>
+ <!-- Decimal representation of five (e.g. "5", "55", "5.5", "5e5"). [CHAR_LIMIT=1] -->
+ <string name="digit_5">5</string>
+ <!-- Decimal representation of six (e.g. "6", "66", "6.6", "6e6"). [CHAR_LIMIT=1] -->
+ <string name="digit_6">6</string>
+ <!-- Decimal representation of seven (e.g. "7", "77", "7.7", "7e7"). [CHAR_LIMIT=1] -->
+ <string name="digit_7">7</string>
+ <!-- Decimal representation of eight (e.g. "8", "88", "8.8", "8e8"). [CHAR_LIMIT=1] -->
+ <string name="digit_8">8</string>
+ <!-- Decimal representation of eight (e.g. "9", "99", "9.9", "9e9"). [CHAR_LIMIT=1] -->
+ <string name="digit_9">9</string>
- <!-- Description for mathematical ( [CHAR LIMIT=200] -->
- <item>left parenthesis</item>
- <!-- Description for mathematical ) [CHAR LIMIT=200] -->
- <item>right parenthesis</item>
- <!-- Description for mathematical ! (factorial) function [CHAR LIMIT=200] -->
- <item>factorial</item>
- <!-- Description for mathematical ln [CHAR LIMIT=200] -->
- <item>natural logarithm</item>
- <!-- Description for mathematical log [CHAR LIMIT=200] -->
- <item>logarithm</item>
- <!-- Description for mathematical square root [CHAR LIMIT=200] -->
- <item>square root</item>
- <!-- Description for mathematical / [CHAR LIMIT=200] -->
- <item>divided by</item>
- <!-- Description for mathematical x [CHAR LIMIT=200] -->
- <item>multiplied by</item>
- <!-- Description for mathematical + [CHAR LIMIT=200] -->
- <item>plus</item>
- <!-- Description for mathematical - [CHAR LIMIT=200] -->
- <item>minus</item>
- <!-- Description for mathematical . [CHAR LIMIT=200] -->
- <item> point </item>
- <!-- Description for mathematical ^ [CHAR LIMIT=200] -->
- <item>power</item>
- <!-- Description for mathematical TAN [CHAR LIMIT=200] -->
- <item>tangent</item>
- <!-- Description for mathematical SIN [CHAR LIMIT=200] -->
- <item>sine</item>
- <!-- Description for mathematical COS [CHAR LIMIT=200] -->
- <item>cosine</item>
- <!-- Description for mathematical PI [CHAR LIMIT=200] -->
- <item>pi</item>
- <!-- Description for mathematical = [CHAR LIMIT=200] -->
- <item>equals</item>
- </string-array>
+ <!-- Abbrev. name of cosine function (e.g. "cos(π)". [CHAR_LIMIT=3] -->
+ <string name="fun_cos">cos</string>
+ <!-- Natural logarithm function (e.g. "ln(2)"). [CHAR_LIMIT=3] -->
+ <string name="fun_ln">ln</string>
+ <!-- Logarithm function (e.g. "log(10)"). [CHAR_LIMIT=3] -->
+ <string name="fun_log">log</string>
+ <!-- Abbrev. name of sine function (e.g. "sin(π)". [CHAR_LIMIT=3] -->
+ <string name="fun_sin">sin</string>
+ <!-- Abbrev. name of tangent function (e.g. "tan(π)". [CHAR_LIMIT=3] -->
+ <string name="fun_tan">tan</string>
+
+ <!-- Clear operation to clear the currently entered expression. [CHAR_LIMIT=3] -->
+ <string name="clr">clr</string>
+ <!-- Delete operation to remove last entered token. [CHAR_LIMIT=3] -->
+ <string name="del">del</string>
+
+ <!-- Content Descriptions -->
+ <eat-comment />
+
+ <!-- Content description for 'e' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_const_e">Euler\'s number</string>
+ <!-- Content description for 'π' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_const_pi">pi</string>
+
+ <!-- Content description for '.' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_dec_point">point</string>
+
+ <!-- Content description for '(' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_lparen">left parenthesis</string>
+ <!-- Content description for ')' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_rparen">right parenthesis</string>
+
+ <!-- Content description for 'cos' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_fun_cos">cosine</string>
+ <!-- Content description for 'ln' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_fun_ln">natural logarithm</string>
+ <!-- Content description for 'log' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_fun_log">logarithm</string>
+ <!-- Content description for 'sin' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_fun_sin">sine</string>
+ <!-- Content description for 'tan' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_fun_tan">tangent</string>
+
+ <!-- Content description for '+' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_op_add">plus</string>
+ <!-- Content description for '÷' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_op_div">divide</string>
+ <!-- Content description for '!' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_op_fact">factorial</string>
+ <!-- Content description for '×' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_op_mul">times</string>
+ <!-- Content description for '^' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_op_pow">power</string>
+ <!-- Content description for '√' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_op_sqrt">square root</string>
+ <!-- Content description for '-' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_op_sub">minus</string>
+
+ <!-- Content description for "clr" button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_clr">clear</string>
+ <!-- Content description for "del" button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_del">delete</string>
+ <!-- Content description for '=' button. [CHAR_LIMIT=NONE] -->
+ <string name="desc_eq">equals</string>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 156da37..f561b98 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -1,126 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2007 The Android Open Source Project
+ Copyright (C) 2014 The Android Open Source Project
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
<resources xmlns:android="http://schemas.android.com/apk/res/android">
- <style name="button_style" parent="@android:style/Widget.Quantum.Button.Borderless">
- <item name="android:textSize">24dp</item>
+ <style name="CalculatorTheme" parent="@android:style/Theme.Quantum.Light.NoActionBar">
+ <item name="android:navigationBarColor">@android:color/black</item>
+ <item name="android:statusBarColor">@color/calculator_accent_color</item>
+ <item name="android:windowContentOverlay">@null</item>
+ </style>
+
+ <style name="DisplayEditTextStyle" parent="@android:style/Widget.Quantum.Light.EditText">
+ <item name="android:background">@android:color/transparent</item>
+ <item name="android:cursorVisible">false</item>
<item name="android:fontFamily">sans-serif-light</item>
+ <item name="android:includeFontPadding">false</item>
+ <item name="android:gravity">bottom|end</item>
+ </style>
+
+ <style name="DisplayShadowStyle">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">8dip</item>
+ <item name="android:background">@drawable/display_shadow</item>
+ </style>
+
+ <style name="PadButtonStyle" parent="@android:style/Widget.Quantum.Light.Button.Borderless">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:background">@drawable/pad_btn_background</item>
+ <item name="android:fontFamily">sans-serif-light</item>
+ <item name="android:gravity">center</item>
+ <item name="android:includeFontPadding">false</item>
+ <item name="android:minWidth">0dip</item>
+ <item name="android:minHeight">0dip</item>
<item name="android:textAllCaps">false</item>
+ <item name="android:textColor">@color/pad_button_text_color</item>
+ </style>
+
+ <style name="PadLayoutStyle">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
- <item name="android:layout_weight">1</item>
- <item name="android:focusable">true</item>
- <item name="android:onClick">onClick</item>
- </style>
-
- <style name="function_pad">
- <item name="android:background">@color/gray_40</item>
- </style>
-
- <style name="function_button" parent="button_style">
- <item name="android:background">@drawable/btn_digit</item>
- <item name="android:textColor">@color/text_light</item>
- </style>
-
- <!-- Function button used on sw600 devices. -->
- <style name="function_button_sw600" parent="function_button">
- <item name="android:layout_width">0dip</item>
- <item name="android:layout_weight">1</item>
- </style>
-
- <style name="digit_pad">
- <item name="android:background">@color/gray_30</item>
- </style>
-
- <style name="digit_button" parent="button_style">
- <item name="android:background">@drawable/btn_digit</item>
- <item name="android:textColor">@color/text_light</item>
- </style>
-
- <!-- Digit button used on sw600 devices. -->
- <style name="digit_button_sw600" parent="digit_button">
- <item name="android:layout_width">0dip</item>
- <item name="android:layout_weight">1</item>
- </style>
-
- <style name="advanced_pad">
- <item name="android:background">@color/primary</item>
- </style>
-
- <style name="advanced_button" parent="button_style">
- <item name="android:background">@drawable/btn_advanced</item>
- <item name="android:textColor">@color/text_light</item>
- </style>
-
- <!-- Advanced button used on sw600 devices. -->
- <style name="advanced_button_s600" parent="advanced_button">
- <item name="android:layout_width">0dip</item>
- <item name="android:layout_weight">1</item>
- </style>
-
- <style name="advanced_button_small" parent="advanced_button">
- <item name="android:textSize">30dp</item>
- </style>
-
- <style name="button_small_style" parent="button_style">
- <item name="android:textSize">30dp</item>
- </style>
-
- <!-- Style applied to a display card. -->
- <style name="display_style">
- <item name="android:textSize">@dimen/display_maximum_text_size</item>
- <item name="android:inputType">text|textNoSuggestions</item>
- <item name="android:gravity">right|center_vertical</item>
- <item name="android:textColor">@color/text_dark</item>
- <item name="android:maxLines">1</item>
- <item name="android:scrollbars">none</item>
- <item name="android:scrollHorizontally">true</item>
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">match_parent</item>
- <item name="android:paddingTop">16dp</item>
- <item name="android:paddingLeft">8dp</item>
- <item name="android:paddingRight">8dp</item>
- <item name="android:paddingBottom">16dp</item>
- <item name="android:background">@drawable/card_background</item>
- <item name="android:layout_margin">8sp</item>
- </style>
-
- <!-- Style applied to the display card container. -->
- <style name="display_holder_style">
- <item name="android:background">@color/gray_80</item>
- </style>
-
- <!-- Style used in sw600dp single-screen mode. -->
- <style name="btn_row_style">
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">0dip</item>
- <item name="android:layout_weight">1</item>
- <item name="android:orientation">horizontal</item>
- </style>
-
- <style name="btn_clear">
- <item name="android:background">?android:attr/selectableItemBackground</item>
- <item name="android:textSize">@dimen/btn_clear_text_size</item>
- </style>
-
- <style name="AppTheme" parent="@android:style/Theme.Quantum.NoActionBar">
- <item name="android:colorPrimary">@color/primary</item>
- <item name="android:colorPrimaryLight">@color/primary_light</item>
- <item name="android:colorPrimaryDark">@color/primary_dark</item>
</style>
</resources>
diff --git a/src/com/android/calculator2/Calculator.java b/src/com/android/calculator2/Calculator.java
deleted file mode 100644
index bb48147..0000000
--- a/src/com/android/calculator2/Calculator.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.calculator2;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.support.v4.view.ViewPager;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.WindowManager;
-import android.widget.PopupMenu.OnMenuItemClickListener;
-
-import com.android.calculator2.R;
-
-public class Calculator extends Activity implements PanelSwitcher.Listener, Logic.Listener,
- OnMenuItemClickListener, View.OnClickListener {
- private static final String STATE_CURRENT_VIEW = "state-current-view";
-
- private final EventListener mListener = new EventListener();
-
- private CalculatorDisplay mDisplay;
- private Persist mPersist;
- private History mHistory;
- private Logic mLogic;
- private ViewPager mPager;
-
- private View mClr;
- private View mDel;
-
- @Override
- public void onCreate(Bundle state) {
- super.onCreate(state);
-
- setContentView(R.layout.main);
-
- mPager = (ViewPager) findViewById(R.id.panelswitch);
- if (mPager != null) {
- final LayoutInflater inflater = LayoutInflater.from(this);
- final View simple = inflater.inflate(R.layout.simple_pad, mPager, false);
- final View advanced = inflater.inflate(R.layout.advanced_pad, mPager, false);
- mClr = simple.findViewById(R.id.clear);
- mDel = simple.findViewById(R.id.del);
-
- final PageAdapter adapter = new PageAdapter();
- adapter.add(simple);
- adapter.add(advanced);
-
- mPager.setAdapter(adapter);
- mPager.setCurrentItem(state == null ? 0 : state.getInt(STATE_CURRENT_VIEW, 0));
- } else {
- mClr = findViewById(R.id.clear);
- mDel = findViewById(R.id.del);
- }
-
- mPersist = new Persist(this);
- mPersist.load();
-
- mHistory = mPersist.getHistory();
-
- mDisplay = (CalculatorDisplay) findViewById(R.id.display);
-
- mLogic = new Logic(this, mHistory, mDisplay);
- mLogic.setListener(this);
- mLogic.setDeleteMode(mPersist.getDeleteMode());
- mLogic.setLineLength(mDisplay.getMaxDigits());
-
- final HistoryAdapter historyAdapter = new HistoryAdapter(this, mHistory, mLogic);
- mHistory.setObserver(historyAdapter);
-
- mListener.setHandler(mLogic, mPager);
- mDisplay.setOnKeyListener(mListener);
- mLogic.resumeWithHistory();
- }
-
- @Override
- public boolean onMenuItemClick(MenuItem item) {
- return onOptionsItemSelected(item);
- }
-
- @Override
- public void onClick(View v) {
- mListener.onClick(v);
- }
-
- @Override
- protected void onSaveInstanceState(Bundle state) {
- super.onSaveInstanceState(state);
-
- if (mPager != null) {
- state.putInt(STATE_CURRENT_VIEW, mPager.getCurrentItem());
- }
- }
-
- @Override
- public void onPause() {
- super.onPause();
-
- mLogic.updateHistory();
- mPersist.setDeleteMode(mLogic.getDeleteMode());
- mPersist.save();
- }
-
- @Override
- public void onDeleteModeChange(int deleteMode) {
- if (deleteMode == Logic.DELETE_MODE_BACKSPACE) {
- mDel.setVisibility(View.VISIBLE);
- mClr.setVisibility(View.GONE);
- } else {
- mDel.setVisibility(View.GONE);
- mClr.setVisibility(View.VISIBLE);
- }
- }
-
- @Override
- public void onChange() {
- invalidateOptionsMenu();
- }
-}
diff --git a/src/com/android/calculator2/CalculatorActivity.java b/src/com/android/calculator2/CalculatorActivity.java
new file mode 100644
index 0000000..5c47535
--- /dev/null
+++ b/src/com/android/calculator2/CalculatorActivity.java
@@ -0,0 +1,318 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.calculator2;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.AnimatorSet;
+import android.animation.ArgbEvaluator;
+import android.animation.ObjectAnimator;
+import android.animation.ValueAnimator;
+import android.animation.ValueAnimator.AnimatorUpdateListener;
+import android.app.Activity;
+import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextUtils;
+import android.text.TextWatcher;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.View.OnLongClickListener;
+import android.view.animation.AccelerateDecelerateInterpolator;
+import android.widget.Button;
+
+public class CalculatorActivity extends Activity
+ implements CalculatorExpressionEvaluator.EvaluateCallback, OnLongClickListener {
+
+ public static final String CALCULATOR_ACTIVITY_CURRENT_STATE =
+ CalculatorActivity.class.getSimpleName() + "_currentState";
+
+ private enum CalculatorState {
+ INPUT, EVALUATE, RESULT, ERROR
+ }
+
+ private final TextWatcher mFormulaTextWatcher = new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence charSequence, int start, int count, int after) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable editable) {
+ setState(CalculatorState.INPUT);
+ mEvaluator.evaluate(editable, CalculatorActivity.this);
+ }
+ };
+
+ private CalculatorState mCurrentState;
+ private CalculatorExpressionEvaluator mEvaluator;
+
+ private CalculatorEditText mFormulaEditText;
+ private CalculatorEditText mResultEditText;
+
+ private View mRevealView;
+ private View mDeleteButton;
+ private View mClearButton;
+
+ private Animator mCurrentAnimator;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_calculator);
+
+ mCurrentState = CalculatorState.INPUT;
+ mEvaluator = new CalculatorExpressionEvaluator(this);
+
+ mFormulaEditText = (CalculatorEditText) findViewById(R.id.formula);
+ mResultEditText = (CalculatorEditText) findViewById(R.id.result);
+
+ mRevealView = findViewById(R.id.reveal);
+ mDeleteButton = findViewById(R.id.del);
+ mClearButton = findViewById(R.id.clr);
+
+ mFormulaEditText.setEditableFactory(new CalculatorExpressionBuilder.Factory(this));
+ mFormulaEditText.addTextChangedListener(mFormulaTextWatcher);
+ mDeleteButton.setOnLongClickListener(this);
+ }
+
+ @Override
+ protected void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ setState(CalculatorState.values()[savedInstanceState.getInt(
+ CALCULATOR_ACTIVITY_CURRENT_STATE, CalculatorState.INPUT.ordinal())]);
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putInt(CALCULATOR_ACTIVITY_CURRENT_STATE, mCurrentState.ordinal());
+ }
+
+ private void setState(CalculatorState state) {
+ if (mCurrentState != state) {
+ mCurrentState = state;
+
+ if (state == CalculatorState.RESULT || state == CalculatorState.ERROR) {
+ mDeleteButton.setVisibility(View.GONE);
+ mClearButton.setVisibility(View.VISIBLE);
+ } else {
+ mDeleteButton.setVisibility(View.VISIBLE);
+ mClearButton.setVisibility(View.GONE);
+ }
+
+ if (state == CalculatorState.ERROR) {
+ final int errorColor = getResources().getColor(R.color.calculator_error_color);
+ mFormulaEditText.setTextColor(errorColor);
+ mResultEditText.setTextColor(errorColor);
+ getWindow().setStatusBarColor(errorColor);
+ } else {
+ mFormulaEditText.setTextColor(
+ getResources().getColor(R.color.display_formula_text_color));
+ mResultEditText.setTextColor(
+ getResources().getColor(R.color.display_result_text_color));
+ getWindow().setStatusBarColor(
+ getResources().getColor(R.color.calculator_accent_color));
+ }
+ }
+ }
+
+ @Override
+ public void onUserInteraction() {
+ super.onUserInteraction();
+
+ // If there's an animation in progress, cancel it so the user interaction can be handled
+ // immediately.
+ if (mCurrentAnimator != null) {
+ mCurrentAnimator.cancel();
+ }
+ }
+
+ public void onButtonClick(View view) {
+ switch (view.getId()) {
+ case R.id.eq:
+ if (mCurrentState != CalculatorState.INPUT) {
+ mFormulaEditText.getEditableText().clear();
+ } else {
+ setState(CalculatorState.EVALUATE);
+ mEvaluator.evaluate(mFormulaEditText.getText(), this);
+ }
+ break;
+ case R.id.del:
+ mFormulaEditText.dispatchKeyEvent(
+ new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
+ break;
+ case R.id.clr:
+ onClear(view);
+ break;
+ case R.id.fun_cos:
+ case R.id.fun_ln:
+ case R.id.fun_log:
+ case R.id.fun_sin:
+ case R.id.fun_tan:
+ // add left paren after functions
+ mFormulaEditText.append(((Button) view).getText() + "(");
+ break;
+ default:
+ mFormulaEditText.append(((Button) view).getText());
+ break;
+ }
+ }
+
+ @Override
+ public boolean onLongClick(View view) {
+ if (view.getId() == R.id.del) {
+ onClear(view);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void onEvaluate(String expr, String result, String error) {
+ if (mCurrentState == CalculatorState.INPUT) {
+ mResultEditText.setText(result);
+ } else if (!TextUtils.isEmpty(error)) {
+ setState(CalculatorState.ERROR);
+ mResultEditText.setText(error);
+ } else if (!TextUtils.isEmpty(result)) {
+ onResult(result);
+ } else if (mCurrentState == CalculatorState.EVALUATE) {
+ // The current expression cannot be evaluated -> return to the input state.
+ setState(CalculatorState.INPUT);
+ }
+ }
+
+ private void onClear(View sourceView) {
+ final int[] clearLocation = new int[2];
+ sourceView.getLocationInWindow(clearLocation);
+ clearLocation[0] += sourceView.getWidth() / 2;
+ clearLocation[1] += sourceView.getHeight() / 2;
+
+ final int[] revealLocation = new int[2];
+ mRevealView.getLocationInWindow(revealLocation);
+
+ final int revealCenterX = clearLocation[0] - revealLocation[0];
+ final int revealCenterY = clearLocation[1] - revealLocation[1];
+
+ final double x1_2 = Math.pow(mRevealView.getLeft() - revealCenterX, 2);
+ final double x2_2 = Math.pow(mRevealView.getRight() - revealCenterX, 2);
+ final double y_2 = Math.pow(mRevealView.getTop() - revealCenterY, 2);
+ final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2));
+
+ final Animator clearAnimator = mRevealView.createRevealAnimator(
+ revealCenterX, revealCenterY, 0.0f, revealRadius);
+ clearAnimator.setDuration(
+ getResources().getInteger(android.R.integer.config_longAnimTime));
+ clearAnimator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ // Clear the formula after the reveal is finished, but before it's faded out.
+ mFormulaEditText.getEditableText().clear();
+ }
+ });
+
+ final Animator alphaAnimator = ObjectAnimator.ofFloat(mRevealView, View.ALPHA, 0.0f);
+ alphaAnimator.setDuration(
+ getResources().getInteger(android.R.integer.config_shortAnimTime));
+
+ final AnimatorSet animatorSet = new AnimatorSet();
+ animatorSet.play(clearAnimator).before(alphaAnimator);
+ animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
+ animatorSet.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationStart(Animator animator) {
+ mRevealView.setAlpha(1.0f);
+ mRevealView.setVisibility(View.VISIBLE);
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animator) {
+ mRevealView.setVisibility(View.GONE);
+ mCurrentAnimator = null;
+ }
+ });
+
+ mCurrentAnimator = animatorSet;
+ animatorSet.start();
+ }
+
+ private void onResult(final String result) {
+ // Calculate the values needed to perform the scale and translation animations,
+ // accounting for how the scale will affect the final position of the text.
+ final float resultScale =
+ mFormulaEditText.getVariableTextSize(result) / mResultEditText.getTextSize();
+ final float resultTranslationX = (1.0f - resultScale) *
+ (mResultEditText.getWidth() / 2.0f - mResultEditText.getPaddingEnd());
+ final float resultTranslationY = (1.0f - resultScale) *
+ (mResultEditText.getHeight() / 2.0f - mResultEditText.getPaddingBottom()) +
+ (mFormulaEditText.getBottom() - mResultEditText.getBottom()) +
+ (mResultEditText.getPaddingBottom() - mFormulaEditText.getPaddingBottom());
+ final float formulaTranslationY = -mFormulaEditText.getBottom();
+
+ // Use a value animator to fade to the final text color over the course of the animation.
+ final int resultTextColor = mResultEditText.getCurrentTextColor();
+ final int formulaTextColor = mFormulaEditText.getCurrentTextColor();
+ final ValueAnimator textColorAnimator =
+ ValueAnimator.ofObject(new ArgbEvaluator(), resultTextColor, formulaTextColor);
+ textColorAnimator.addUpdateListener(new AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator valueAnimator) {
+ mResultEditText.setTextColor((int) valueAnimator.getAnimatedValue());
+ }
+ });
+
+ final AnimatorSet animatorSet = new AnimatorSet();
+ animatorSet.playTogether(
+ textColorAnimator,
+ ObjectAnimator.ofFloat(mResultEditText, View.SCALE_X, resultScale),
+ ObjectAnimator.ofFloat(mResultEditText, View.SCALE_Y, resultScale),
+ ObjectAnimator.ofFloat(mResultEditText, View.TRANSLATION_X, resultTranslationX),
+ ObjectAnimator.ofFloat(mResultEditText, View.TRANSLATION_Y, resultTranslationY),
+ ObjectAnimator.ofFloat(mFormulaEditText, View.TRANSLATION_Y, formulaTranslationY));
+ animatorSet.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime));
+ animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
+ animatorSet.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ mResultEditText.setText(result);
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ // Reset all of the values modified during the animation.
+ mResultEditText.setTextColor(resultTextColor);
+ mResultEditText.setScaleX(1.0f);
+ mResultEditText.setScaleY(1.0f);
+ mResultEditText.setTranslationX(0.0f);
+ mResultEditText.setTranslationY(0.0f);
+ mFormulaEditText.setTranslationY(0.0f);
+
+ // Finally update the formula to use the current result.
+ mFormulaEditText.setText(result);
+ setState(CalculatorState.RESULT);
+
+ mCurrentAnimator = null;
+ }
+ });
+
+ mCurrentAnimator = animatorSet;
+ animatorSet.start();
+ }
+}
diff --git a/src/com/android/calculator2/CalculatorDisplay.java b/src/com/android/calculator2/CalculatorDisplay.java
deleted file mode 100644
index ec4070e..0000000
--- a/src/com/android/calculator2/CalculatorDisplay.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.calculator2;
-
-import android.content.Context;
-import android.graphics.Rect;
-import android.text.Editable;
-import android.text.InputType;
-import android.text.Spanned;
-import android.text.method.NumberKeyListener;
-import android.util.AttributeSet;
-import android.view.animation.TranslateAnimation;
-import android.widget.EditText;
-import android.widget.ViewSwitcher;
-
-/**
- * Provides vertical scrolling for the input/result EditText.
- */
-class CalculatorDisplay extends ViewSwitcher {
-
- private static final String ATTR_MAX_DIGITS = "maxDigits";
- private static final int DEFAULT_MAX_DIGITS = 10;
-
- // only these chars are accepted from keyboard
- private static final char[] ACCEPTED_CHARS =
- "0123456789.+-*/\u2212\u00d7\u00f7()!%^".toCharArray();
-
- private static final int ANIM_DURATION = 500;
-
- enum Scroll { UP, DOWN, NONE }
-
- TranslateAnimation inAnimUp;
- TranslateAnimation outAnimUp;
- TranslateAnimation inAnimDown;
- TranslateAnimation outAnimDown;
-
- private int mMaxDigits = DEFAULT_MAX_DIGITS;
-
- public CalculatorDisplay(Context context) {
- this(context, null);
- }
-
- public CalculatorDisplay(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- if (attrs != null) {
- mMaxDigits = attrs.getAttributeIntValue(null, ATTR_MAX_DIGITS, DEFAULT_MAX_DIGITS);
- }
- }
-
- public int getMaxDigits() {
- return mMaxDigits;
- }
-
- protected void setLogic(Logic logic) {
- NumberKeyListener calculatorKeyListener =
- new NumberKeyListener() {
- @Override
- public int getInputType() {
- return InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
- }
-
- @Override
- protected char[] getAcceptedChars() {
- return ACCEPTED_CHARS;
- }
-
- @Override
- public CharSequence filter(CharSequence source, int start, int end,
- Spanned dest, int dstart, int dend) {
- /* the EditText should still accept letters (eg. 'sin')
- coming from the on-screen touch buttons, so don't filter anything.
- */
- return null;
- }
- };
-
- Editable.Factory factory = new CalculatorEditable.Factory(logic);
- for (int i = 0; i < 2; ++i) {
- EditText text = (EditText) getChildAt(i);
- text.setEditableFactory(factory);
- text.setKeyListener(calculatorKeyListener);
- text.setSingleLine();
- }
- }
-
- @Override
- public void setOnKeyListener(OnKeyListener l) {
- getChildAt(0).setOnKeyListener(l);
- getChildAt(1).setOnKeyListener(l);
- }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldW, int oldH) {
- inAnimUp = new TranslateAnimation(0, 0, h, 0);
- inAnimUp.setDuration(ANIM_DURATION);
- outAnimUp = new TranslateAnimation(0, 0, 0, -h);
- outAnimUp.setDuration(ANIM_DURATION);
-
- inAnimDown = new TranslateAnimation(0, 0, -h, 0);
- inAnimDown.setDuration(ANIM_DURATION);
- outAnimDown = new TranslateAnimation(0, 0, 0, h);
- outAnimDown.setDuration(ANIM_DURATION);
- }
-
- void insert(String delta) {
- EditText editor = (EditText) getCurrentView();
- int cursor = editor.getSelectionStart();
- editor.getText().insert(cursor, delta);
- }
-
- void append(String delta) {
- EditText editor = (EditText) getCurrentView();
- editor.getText().append(delta);
- }
-
- EditText getEditText() {
- return (EditText) getCurrentView();
- }
-
- Editable getText() {
- EditText text = (EditText) getCurrentView();
- return text.getText();
- }
-
- void setText(CharSequence text, Scroll dir) {
- if (getText().length() == 0) {
- dir = Scroll.NONE;
- }
-
- if (dir == Scroll.UP) {
- setInAnimation(inAnimUp);
- setOutAnimation(outAnimUp);
- } else if (dir == Scroll.DOWN) {
- setInAnimation(inAnimDown);
- setOutAnimation(outAnimDown);
- } else { // Scroll.NONE
- setInAnimation(null);
- setOutAnimation(null);
- }
-
- EditText editText = (EditText) getNextView();
- editText.setText(text);
- //Calculator.log("selection to " + text.length() + "; " + text);
- editText.setSelection(text.length());
- showNext();
- }
-
- int getSelectionStart() {
- EditText text = (EditText) getCurrentView();
- return text.getSelectionStart();
- }
-
- @Override
- protected void onFocusChanged(boolean gain, int direction, Rect prev) {
- //Calculator.log("focus " + gain + "; " + direction + "; " + prev);
- if (!gain) {
- requestFocus();
- }
- }
-}
diff --git a/src/com/android/calculator2/CalculatorEditText.java b/src/com/android/calculator2/CalculatorEditText.java
index b40bb1e..e31d571 100644
--- a/src/com/android/calculator2/CalculatorEditText.java
+++ b/src/com/android/calculator2/CalculatorEditText.java
@@ -1,11 +1,11 @@
/*
- * Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,290 +16,24 @@
package com.android.calculator2;
-import android.content.ClipData;
-import android.content.ClipboardManager;
import android.content.Context;
-import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.graphics.Paint;
-import android.text.Editable;
-import android.text.InputType;
-import android.text.TextUtils;
+import android.graphics.Paint.FontMetricsInt;
+import android.graphics.Rect;
+import android.text.method.ScrollingMovementMethod;
+import android.text.TextPaint;
import android.util.AttributeSet;
-import android.util.Log;
import android.util.TypedValue;
import android.view.ActionMode;
-import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.EditText;
-import android.widget.Toast;
-
-import com.android.calculator2.R;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
public class CalculatorEditText extends EditText {
- private static final String LOG_TAG = "Calculator2";
- private static final int CUT = 0;
- private static final int COPY = 1;
- private static final int PASTE = 2;
- private static Map<String, String> sReplacementTable;
- private static String[] sOperators;
-
- private final int mMaximumTextSize;
- private final int mMinimumTextSize;
- private final int mStepTextSize;
-
- private int mWidthConstraint = -1;
-
- private String[] mMenuItemsStrings;
-
- public CalculatorEditText(Context context) {
- this(context, null);
- }
-
- public CalculatorEditText(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- setCustomSelectionActionModeCallback(new NoTextSelectionMode());
- setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
- setCursorVisible(false);
-
- final Resources res = getResources();
- mMaximumTextSize = res.getDimensionPixelSize(R.dimen.display_maximum_text_size);
- mMinimumTextSize = res.getDimensionPixelSize(R.dimen.display_minimum_text_size);
- mStepTextSize = res.getDimensionPixelSize(R.dimen.display_step_text_size);
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (event.getActionMasked() == MotionEvent.ACTION_UP) {
- // Hack to prevent keyboard and insertion handle from showing.
- cancelLongPress();
- }
-
- return super.onTouchEvent(event);
- }
-
- @Override
- public boolean performLongClick() {
- showContextMenu();
-
- return true;
- }
-
- @Override
- public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
- super.onInitializeAccessibilityEvent(event);
-
- final String mathText = mathParse(getText().toString());
- // Parse the string into something more "mathematical" sounding.
- if (!TextUtils.isEmpty(mathText)) {
- event.getText().clear();
- event.getText().add(mathText);
- setContentDescription(mathText);
- }
- }
-
- @Override
- public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
- super.onInitializeAccessibilityNodeInfo(info);
-
- info.setText(mathParse(getText().toString()));
- }
-
- @Override
- public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
- // Do nothing.
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-
- mWidthConstraint =
- MeasureSpec.getSize(widthMeasureSpec) - getPaddingLeft() - getPaddingRight();
- setVariableFontSize();
- }
-
- @Override
- protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
- super.onTextChanged(text, start, lengthBefore, lengthAfter);
-
- if (TextUtils.isEmpty(text)) {
- setTextSize(TypedValue.COMPLEX_UNIT_PX, mMaximumTextSize);
- return;
- }
-
- setVariableFontSize();
- }
-
- private void setVariableFontSize() {
- if (mWidthConstraint < 0) {
- // Not measured, bail early.
- return;
- }
-
- final Paint paint = new Paint();
- final String measureText = getText().toString();
- int lastFitTextSize = mMinimumTextSize;
-
- while (lastFitTextSize < mMaximumTextSize) {
- final int nextSize = lastFitTextSize + mStepTextSize;
- paint.setTextSize(nextSize);
- final float measuredTextWidth = paint.measureText(measureText);
- if (measuredTextWidth > mWidthConstraint) {
- break;
- } else {
- lastFitTextSize = nextSize;
- }
- }
-
- setTextSize(TypedValue.COMPLEX_UNIT_PX, lastFitTextSize);
- }
-
- private String mathParse(String plainText) {
- String parsedText = plainText;
- if (!TextUtils.isEmpty(parsedText)) {
- // Initialize replacement table.
- initializeReplacementTable();
- for (String operator : sOperators) {
- if (sReplacementTable.containsKey(operator)) {
- parsedText = parsedText.replace(operator, sReplacementTable.get(operator));
- }
- }
- }
-
- return parsedText;
- }
-
- private synchronized void initializeReplacementTable() {
- if (sReplacementTable == null) {
- final Resources res = getContext().getResources();
- final String[] descs = res.getStringArray(R.array.operatorDescs);
- final String[] ops = res.getStringArray(R.array.operators);
- final HashMap<String, String> table = new HashMap<String, String>();
- final int len = ops.length;
- for (int i = 0; i < len; i++) {
- table.put(ops[i], descs[i]);
- }
-
- sOperators = ops;
- sReplacementTable = Collections.unmodifiableMap(table);
- }
- }
-
- public boolean onTextContextMenuItem(CharSequence title) {
- if (TextUtils.equals(title, mMenuItemsStrings[CUT])) {
- cutContent();
- return true;
- } else if (TextUtils.equals(title, mMenuItemsStrings[COPY])) {
- copyContent();
- return true;
- } else if (TextUtils.equals(title, mMenuItemsStrings[PASTE])) {
- pasteContent();
- return true;
- }
-
- return false;
- }
-
- @Override
- public void onCreateContextMenu(ContextMenu menu) {
- if (mMenuItemsStrings == null) {
- final Resources resources = getResources();
- mMenuItemsStrings = new String[3];
- mMenuItemsStrings[CUT] = resources.getString(android.R.string.cut);
- mMenuItemsStrings[COPY] = resources.getString(android.R.string.copy);
- mMenuItemsStrings[PASTE] = resources.getString(android.R.string.paste);
- }
-
- final MenuHandler handler = new MenuHandler();
- final int len = mMenuItemsStrings.length;
- for (int i = 0; i < len; i++) {
- menu.add(Menu.NONE, i, i, mMenuItemsStrings[i]).setOnMenuItemClickListener(handler);
- }
-
- if (getText().length() == 0) {
- menu.getItem(CUT).setVisible(false);
- menu.getItem(COPY).setVisible(false);
- }
-
- final ClipData primaryClip = getPrimaryClip();
- if (primaryClip == null || primaryClip.getItemCount() == 0
- || !canPaste(primaryClip.getItemAt(0).coerceToText(getContext()))) {
- menu.getItem(PASTE).setVisible(false);
- }
- }
-
- private void setPrimaryClip(ClipData clip) {
- final ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(
- Context.CLIPBOARD_SERVICE);
- clipboard.setPrimaryClip(clip);
- }
-
- private void copyContent() {
- final Editable text = getText();
- final int textLength = text.length();
- setSelection(0, textLength);
- setPrimaryClip(ClipData.newPlainText(null, text));
- setSelection(textLength);
-
- Toast.makeText(getContext(), R.string.text_copied_toast, Toast.LENGTH_SHORT).show();
- }
-
- private void cutContent() {
- final Editable text = getText();
- final int textLength = text.length();
- setSelection(0, textLength);
- setPrimaryClip(ClipData.newPlainText(null, text));
- getText().delete(0, textLength);
- setSelection(0);
- }
-
- private ClipData getPrimaryClip() {
- final ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(
- Context.CLIPBOARD_SERVICE);
- return clipboard.getPrimaryClip();
- }
-
- private void pasteContent() {
- final ClipData clip = getPrimaryClip();
- if (clip != null) {
- final int len = clip.getItemCount();
- for (int i = 0; i < len; i++) {
- final CharSequence paste = clip.getItemAt(i).coerceToText(getContext());
- if (canPaste(paste)) {
- getText().insert(getSelectionEnd(), paste);
- }
- }
- }
- }
-
- private boolean canPaste(CharSequence paste) {
- try {
- Float.parseFloat(paste.toString());
- return true;
- } catch (NumberFormatException e) {
- Log.e(LOG_TAG, "Error turning string to integer. Ignoring paste.", e);
- return false;
- }
- }
-
- private class MenuHandler implements MenuItem.OnMenuItemClickListener {
- @Override
- public boolean onMenuItemClick(MenuItem item) {
- return onTextContextMenuItem(item.getTitle());
- }
- }
-
- private class NoTextSelectionMode implements ActionMode.Callback {
+ private final ActionMode.Callback mNoSelectionActionModeCallback = new ActionMode.Callback() {
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
@@ -307,7 +41,6 @@
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
- copyContent();
// Prevents the selection action mode on double tap.
return false;
}
@@ -320,5 +53,118 @@
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
+ };
+
+ private final float mMaximumTextSize;
+ private final float mMinimumTextSize;
+ private final float mStepTextSize;
+
+ private int mWidthConstraint = -1;
+
+ public CalculatorEditText(Context context) {
+ this(context, null);
+ }
+
+ public CalculatorEditText(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public CalculatorEditText(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+
+ final TypedArray a = context.obtainStyledAttributes(
+ attrs, R.styleable.CalculatorEditText, defStyle, 0);
+ mMaximumTextSize = a.getDimension(
+ R.styleable.CalculatorEditText_maxTextSize, getTextSize());
+ mMinimumTextSize = a.getDimension(
+ R.styleable.CalculatorEditText_minTextSize, getTextSize());
+ mStepTextSize = a.getDimension(R.styleable.CalculatorEditText_stepTextSize,
+ (mMaximumTextSize - mMinimumTextSize) / 3);
+
+ a.recycle();
+
+ setCustomSelectionActionModeCallback(mNoSelectionActionModeCallback);
+ setMovementMethod(ScrollingMovementMethod.getInstance());
+ setTextSize(TypedValue.COMPLEX_UNIT_PX, mMaximumTextSize);
+ setMinHeight(getLineHeight() + getCompoundPaddingBottom() + getCompoundPaddingTop());
+ }
+
+ @Override
+ protected void onSelectionChanged(int selStart, int selEnd) {
+ final int textLength = getText() == null ? 0 : getText().length();
+ if (selStart != textLength || selEnd != textLength) {
+ // Pin the selection to the end of the current text.
+ setSelection(textLength);
+ }
+
+ super.onSelectionChanged(selStart, selEnd);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ if (event.getActionMasked() == MotionEvent.ACTION_UP) {
+ // Hack to prevent keyboard and insertion handle from showing.
+ cancelLongPress();
+ }
+ return super.onTouchEvent(event);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ mWidthConstraint =
+ MeasureSpec.getSize(widthMeasureSpec) - getPaddingLeft() - getPaddingRight();
+ setTextSize(TypedValue.COMPLEX_UNIT_PX, getVariableTextSize(getText().toString()));
+ }
+
+ @Override
+ protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
+ super.onTextChanged(text, start, lengthBefore, lengthAfter);
+
+ setSelection(text.length());
+ setTextSize(TypedValue.COMPLEX_UNIT_PX, getVariableTextSize(text.toString()));
+ }
+
+ public float getVariableTextSize(String text) {
+ if (mWidthConstraint < 0 || mMaximumTextSize <= mMinimumTextSize) {
+ // Not measured, bail early.
+ return getTextSize();
+ }
+
+ final Paint paint = new TextPaint(getPaint());
+ float lastFitTextSize = mMinimumTextSize;
+ while (lastFitTextSize < mMaximumTextSize) {
+ final float nextSize = Math.min(lastFitTextSize + mStepTextSize, mMaximumTextSize);
+ paint.setTextSize(nextSize);
+ if (paint.measureText(text) > mWidthConstraint) {
+ break;
+ } else {
+ lastFitTextSize = nextSize;
+ }
+ }
+
+ return lastFitTextSize;
+ }
+
+ @Override
+ public int getCompoundPaddingTop() {
+ // Measure the top padding from the capital letter height of the text instead of the top,
+ // but don't remove more than the available top padding otherwise clipping may occur.
+ final Rect capBounds = new Rect();
+ getPaint().getTextBounds("H", 0, 1, capBounds);
+
+ final FontMetricsInt fontMetrics = getPaint().getFontMetricsInt();
+ final int paddingOffset = -(fontMetrics.ascent + capBounds.height());
+
+ return super.getCompoundPaddingTop() - Math.min(getPaddingTop(), paddingOffset);
+ }
+
+ @Override
+ public int getCompoundPaddingBottom() {
+ // Measure the bottom padding from the baseline of the text instead of the bottom, but don't
+ // remove more than the available bottom padding otherwise clipping may occur.
+ final FontMetricsInt fontMetrics = getPaint().getFontMetricsInt();
+ return super.getCompoundPaddingBottom() - Math.min(getPaddingBottom(), fontMetrics.descent);
}
}
diff --git a/src/com/android/calculator2/CalculatorEditable.java b/src/com/android/calculator2/CalculatorEditable.java
deleted file mode 100644
index 4550971..0000000
--- a/src/com/android/calculator2/CalculatorEditable.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.calculator2;
-
-import android.text.SpannableStringBuilder;
-import android.text.Editable;
-
-class CalculatorEditable extends SpannableStringBuilder {
- private static final char[] ORIGINALS = { '-', '*', '/' };
- private static final char[] REPLACEMENTS = { '\u2212', '\u00d7', '\u00f7' };
-
- private boolean isInsideReplace = false;
- private Logic mLogic;
-
- private CalculatorEditable(CharSequence source, Logic logic) {
- super(source);
- mLogic = logic;
- }
-
- @Override
- public SpannableStringBuilder replace(int start, int end, CharSequence tb, int tbstart,
- int tbend) {
- if (isInsideReplace) {
- return super.replace(start, end, tb, tbstart, tbend);
- } else {
- isInsideReplace = true;
- try {
- String delta = tb.subSequence(tbstart, tbend).toString();
- return internalReplace(start, end, delta);
- } finally {
- isInsideReplace = false;
- }
- }
- }
-
- private SpannableStringBuilder internalReplace(int start, int end, String delta) {
- if (!mLogic.acceptInsert(delta)) {
- mLogic.cleared();
- start = 0;
- end = length();
- }
-
- for (int i = ORIGINALS.length - 1; i >= 0; --i) {
- delta = delta.replace(ORIGINALS[i], REPLACEMENTS[i]);
- }
-
- final int length = delta.length();
- if (length == 1) {
- final char text = delta.charAt(0);
-
- // don't allow two dots in the same number
- if (text == '.') {
- int p = start - 1;
- while (p >= 0 && Character.isDigit(charAt(p))) {
- --p;
- }
- if (p >= 0 && charAt(p) == '.') {
- return super.replace(start, end, "");
- }
- }
-
- char prevChar = start > 0 ? charAt(start - 1) : '\0';
-
- // don't allow 2 successive minuses
- if (text == Logic.MINUS && prevChar == Logic.MINUS) {
- return super.replace(start, end, "");
- }
-
- // don't allow multiple successive operators
- if (Logic.isOperator(text)) {
- while (Logic.isOperator(prevChar) && (text != Logic.MINUS || prevChar == '+')) {
- --start;
- prevChar = start > 0 ? charAt(start - 1) : '\0';
- }
- }
-
- // don't allow leading operator + * /
- if (start == 0 && Logic.isOperator(text) && text != Logic.MINUS) {
- return super.replace(start, end, "");
- }
- }
-
- return super.replace(start, end, delta);
- }
-
- public static class Factory extends Editable.Factory {
- private final Logic mLogic;
-
- public Factory(Logic logic) {
- mLogic = logic;
- }
-
- @Override
- public Editable newEditable(CharSequence source) {
- return new CalculatorEditable(source, mLogic);
- }
- }
-}
diff --git a/src/com/android/calculator2/CalculatorExpressionBuilder.java b/src/com/android/calculator2/CalculatorExpressionBuilder.java
new file mode 100644
index 0000000..f2125a4
--- /dev/null
+++ b/src/com/android/calculator2/CalculatorExpressionBuilder.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.calculator2;
+
+import android.content.Context;
+import android.text.Editable;
+import android.text.SpannableStringBuilder;
+import android.text.TextUtils;
+
+public class CalculatorExpressionBuilder extends SpannableStringBuilder {
+
+ private final CalculatorExpressionTokenizer mTokenizer;
+ private boolean mIsEdited;
+
+ public CalculatorExpressionBuilder(CharSequence text, CalculatorExpressionTokenizer tokenizer) {
+ super(text);
+ mIsEdited = false;
+ mTokenizer = tokenizer;
+ }
+
+ @Override
+ public SpannableStringBuilder replace(int start, int end, CharSequence tb, int tbstart,
+ int tbend) {
+ if (start != length() || end != length()) {
+ mIsEdited = true;
+ return super.replace(start, end, tb, tbstart, tbend);
+ }
+
+ String appendExpr =
+ mTokenizer.getNormalizedExpression(tb.subSequence(tbstart, tbend).toString());
+ if (appendExpr.length() == 1) {
+ final String expr = mTokenizer.getNormalizedExpression(toString());
+ switch (appendExpr.charAt(0)) {
+ case '.':
+ // don't allow two decimals in the same number
+ final int index = expr.lastIndexOf('.');
+ if (index != -1 && TextUtils.isDigitsOnly(expr.substring(index + 1, start))) {
+ appendExpr = "";
+ }
+ break;
+ case '+':
+ case '*':
+ case '/':
+ // don't allow leading operator
+ if (start == 0) {
+ appendExpr = "";
+ break;
+ }
+
+ // don't allow multiple successive operators
+ while (start > 0 && "+-*/".indexOf(expr.charAt(start - 1)) != -1) {
+ --start;
+ }
+ // fall through
+ case '-':
+ // don't allow -- or +-
+ if (start > 0 && "+-".indexOf(expr.charAt(start - 1)) != -1) {
+ --start;
+ }
+
+ // mark as edited since operators can always be appended
+ mIsEdited = true;
+ break;
+ default:
+ break;
+ }
+ }
+
+ // since this is the first edit replace the entire string
+ if (!mIsEdited && appendExpr.length() > 0) {
+ start = 0;
+ mIsEdited = true;
+ }
+
+ appendExpr = mTokenizer.getLocalizedExpression(appendExpr);
+ return super.replace(start, end, appendExpr, 0, appendExpr.length());
+ }
+
+ public static class Factory extends Editable.Factory {
+
+ private final CalculatorExpressionTokenizer mTokenizer;
+
+ public Factory(Context context) {
+ mTokenizer = new CalculatorExpressionTokenizer(context);
+ }
+
+ @Override
+ public Editable newEditable(CharSequence source) {
+ return new CalculatorExpressionBuilder(source, mTokenizer);
+ }
+ }
+}
diff --git a/src/com/android/calculator2/CalculatorExpressionEvaluator.java b/src/com/android/calculator2/CalculatorExpressionEvaluator.java
new file mode 100644
index 0000000..0f41423
--- /dev/null
+++ b/src/com/android/calculator2/CalculatorExpressionEvaluator.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.calculator2;
+
+import android.content.Context;
+
+import org.javia.arity.Symbols;
+import org.javia.arity.SyntaxException;
+import org.javia.arity.Util;
+
+public class CalculatorExpressionEvaluator {
+ private static final int MAX_DIGITS = 14;
+
+ private final Symbols mSymbols;
+ private final CalculatorExpressionTokenizer mTokenizer;
+
+ private final String mErrorNaN;
+ private final String mErrorSyntax;
+
+ public CalculatorExpressionEvaluator(Context context) {
+ mSymbols = new Symbols();
+ mTokenizer = new CalculatorExpressionTokenizer(context);
+
+ mErrorNaN = context.getString(R.string.error_nan);
+ mErrorSyntax = context.getString(R.string.error_syntax);
+ }
+
+ public void evaluate(CharSequence expr, EvaluateCallback callback) {
+ evaluate(expr.toString(), callback);
+ }
+
+ public void evaluate(String expr, EvaluateCallback callback) {
+ expr = mTokenizer.getNormalizedExpression(expr);
+
+ // remove any trailing operators
+ while (expr.length() > 0 && "+-/*".indexOf(expr.charAt(expr.length() - 1)) != -1) {
+ expr = expr.substring(0, expr.length() - 1);
+ }
+
+ try {
+ if (expr == null || expr.length() == 0 || Double.valueOf(expr) != null) {
+ callback.onEvaluate(expr, null, null);
+ return;
+ }
+ } catch (NumberFormatException e) {
+ // expr is not a simple number
+ }
+
+ try {
+ double result = mSymbols.eval(expr);
+ if (Double.isNaN(result)) {
+ callback.onEvaluate(expr, null, mErrorNaN);
+ } else {
+ callback.onEvaluate(expr, mTokenizer.getLocalizedExpression(
+ Util.doubleToString(result, MAX_DIGITS, 0)), null);
+ }
+ } catch (SyntaxException e) {
+ callback.onEvaluate(expr, null, mErrorSyntax);
+ }
+ }
+
+ public interface EvaluateCallback {
+ public void onEvaluate(String expr, String result, String error);
+ }
+}
diff --git a/src/com/android/calculator2/CalculatorExpressionTokenizer.java b/src/com/android/calculator2/CalculatorExpressionTokenizer.java
new file mode 100644
index 0000000..c0e0abd
--- /dev/null
+++ b/src/com/android/calculator2/CalculatorExpressionTokenizer.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.calculator2;
+
+import android.content.Context;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+public class CalculatorExpressionTokenizer {
+ private final Map<String, String> mReplacementMap;
+
+ public CalculatorExpressionTokenizer(Context context) {
+ mReplacementMap = new HashMap<>();
+
+ mReplacementMap.put(".", context.getString(R.string.dec_point));
+
+ mReplacementMap.put("0", context.getString(R.string.digit_0));
+ mReplacementMap.put("1", context.getString(R.string.digit_1));
+ mReplacementMap.put("2", context.getString(R.string.digit_2));
+ mReplacementMap.put("3", context.getString(R.string.digit_3));
+ mReplacementMap.put("4", context.getString(R.string.digit_4));
+ mReplacementMap.put("5", context.getString(R.string.digit_5));
+ mReplacementMap.put("6", context.getString(R.string.digit_6));
+ mReplacementMap.put("7", context.getString(R.string.digit_7));
+ mReplacementMap.put("8", context.getString(R.string.digit_8));
+ mReplacementMap.put("9", context.getString(R.string.digit_9));
+
+ mReplacementMap.put("/", context.getString(R.string.op_div));
+ mReplacementMap.put("*", context.getString(R.string.op_mul));
+ mReplacementMap.put("-", context.getString(R.string.op_sub));
+
+ mReplacementMap.put("cos", context.getString(R.string.fun_cos));
+ mReplacementMap.put("ln", context.getString(R.string.fun_ln));
+ mReplacementMap.put("log", context.getString(R.string.fun_log));
+ mReplacementMap.put("sin", context.getString(R.string.fun_sin));
+ mReplacementMap.put("tan", context.getString(R.string.fun_tan));
+
+ mReplacementMap.put("Infinity", context.getString(R.string.inf));
+ }
+
+ public String getNormalizedExpression(String expr) {
+ for (Entry<String, String> replacementEntry : mReplacementMap.entrySet()) {
+ expr = expr.replace(replacementEntry.getValue(), replacementEntry.getKey());
+ }
+ return expr;
+ }
+
+ public String getLocalizedExpression(String expr) {
+ for (Entry<String, String> replacementEntry : mReplacementMap.entrySet()) {
+ expr = expr.replace(replacementEntry.getKey(), replacementEntry.getValue());
+ }
+ return expr;
+ }
+}
diff --git a/src/com/android/calculator2/CalculatorPadLayout.java b/src/com/android/calculator2/CalculatorPadLayout.java
new file mode 100644
index 0000000..729c55b
--- /dev/null
+++ b/src/com/android/calculator2/CalculatorPadLayout.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.calculator2;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+
+/**
+ * A layout that places children in an evenly distributed grid based on the specified
+ * {@link android.R.attr#columnCount} and {@link android.R.attr#rowCount} attributes.
+ */
+public class CalculatorPadLayout extends ViewGroup {
+
+ private int mRowCount;
+ private int mColumnCount;
+
+ public CalculatorPadLayout(Context context) {
+ this(context, null);
+ }
+
+ public CalculatorPadLayout(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public CalculatorPadLayout(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+
+ final TypedArray a = context.obtainStyledAttributes(attrs,
+ new int[] { android.R.attr.rowCount, android.R.attr.columnCount }, defStyle, 0);
+ mRowCount = a.getInt(0, 1);
+ mColumnCount = a.getInt(1, 1);
+
+ a.recycle();
+ }
+
+ @Override
+ public boolean shouldDelayChildPressedState() {
+ return false;
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ final int paddingLeft = getPaddingLeft();
+ final int paddingRight = getPaddingRight();
+ final int paddingTop = getPaddingTop();
+ final int paddingBottom = getPaddingBottom();
+
+ final boolean isRTL = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
+ final int columnWidth =
+ Math.round((float) (right - left - paddingLeft - paddingRight)) / mColumnCount;
+ final int rowHeight =
+ Math.round((float) (bottom - top - paddingTop - paddingBottom)) / mRowCount;
+
+ int rowIndex = 0, columnIndex = 0;
+ for (int childIndex = 0; childIndex < getChildCount(); ++childIndex) {
+ final View childView = getChildAt(childIndex);
+ if (childView.getVisibility() == View.GONE) {
+ continue;
+ }
+
+ final MarginLayoutParams lp = (MarginLayoutParams) childView.getLayoutParams();
+
+ final int childTop = paddingTop + lp.topMargin + rowIndex * rowHeight;
+ final int childBottom = childTop - lp.topMargin - lp.bottomMargin + rowHeight;
+ final int childLeft = paddingLeft + lp.leftMargin +
+ (isRTL ? (mColumnCount - 1) - columnIndex : columnIndex) * columnWidth;
+ final int childRight = childLeft - lp.leftMargin - lp.rightMargin + columnWidth;
+
+ final int childWidth = childRight - childLeft;
+ final int childHeight = childBottom - childTop;
+ if (childWidth != childView.getMeasuredWidth() ||
+ childHeight != childView.getMeasuredHeight()) {
+ childView.measure(
+ MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY),
+ MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.EXACTLY));
+ }
+ childView.layout(childLeft, childTop, childRight, childBottom);
+
+ rowIndex = (rowIndex + (columnIndex + 1) / mColumnCount) % mRowCount;
+ columnIndex = (columnIndex + 1) % mColumnCount;
+ }
+ }
+
+ @Override
+ public LayoutParams generateLayoutParams(AttributeSet attrs) {
+ return new MarginLayoutParams(getContext(), attrs);
+ }
+
+ @Override
+ protected LayoutParams generateDefaultLayoutParams() {
+ return new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ }
+
+ @Override
+ protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
+ return new MarginLayoutParams(p);
+ }
+
+ @Override
+ protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
+ return p instanceof MarginLayoutParams;
+ }
+}
diff --git a/src/com/android/calculator2/CalculatorPadViewPager.java b/src/com/android/calculator2/CalculatorPadViewPager.java
new file mode 100644
index 0000000..af16d47
--- /dev/null
+++ b/src/com/android/calculator2/CalculatorPadViewPager.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.calculator2;
+
+import android.content.Context;
+import android.support.v4.view.PagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+
+public class CalculatorPadViewPager extends ViewPager {
+
+ private final PagerAdapter mStaticPagerAdapter = new PagerAdapter() {
+ @Override
+ public int getCount() {
+ return getChildCount();
+ }
+
+ @Override
+ public Object instantiateItem(ViewGroup container, int position) {
+ return getChildAt(position);
+ }
+
+ @Override
+ public void destroyItem(ViewGroup container, int position, Object object) {
+ removeViewAt(position);
+ }
+
+ @Override
+ public boolean isViewFromObject(View view, Object object) {
+ return view == object;
+ }
+
+ @Override
+ public float getPageWidth(int position) {
+ return position == 1 ? 0.8f : 1.0f;
+ }
+ };
+ private final PageTransformer mPageTransformer = new PageTransformer() {
+ @Override
+ public void transformPage(View view, float position) {
+ if (position < -1.0f) {
+ view.setAlpha(0.0f);
+ } else if (position <= 0.0f) {
+ // Pin the left page to the left side.
+ view.setTranslationX(getWidth() * -position);
+ } else if (position <= 1.0f) {
+ // Use the default slide transition when moving to the next page.
+ view.setAlpha(1.0f);
+ view.setTranslationX(0.0f);
+ } else {
+ view.setAlpha(0.0f);
+ }
+ }
+ };
+
+ public CalculatorPadViewPager(Context context) {
+ this(context, null);
+ }
+
+ public CalculatorPadViewPager(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ setAdapter(mStaticPagerAdapter);
+ setPageMargin(getResources().getDimensionPixelSize(R.dimen.pad_page_margin));
+ setPageTransformer(false, mPageTransformer);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+
+ // Invalidate the adapter's data set since children may have been added during inflation.
+ if (getAdapter() == mStaticPagerAdapter) {
+ mStaticPagerAdapter.notifyDataSetChanged();
+ }
+ }
+}
diff --git a/src/com/android/calculator2/CalculatorViewPager.java b/src/com/android/calculator2/CalculatorViewPager.java
deleted file mode 100644
index 25e9575..0000000
--- a/src/com/android/calculator2/CalculatorViewPager.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.calculator2;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Canvas;
-import android.graphics.drawable.Drawable;
-import android.support.v4.view.ViewPager;
-import android.util.AttributeSet;
-import android.view.View;
-
-import com.android.calculator2.R;
-
-public class CalculatorViewPager extends ViewPager {
- private Drawable mShadowRight;
- private int mShadowWidth;
-
- public CalculatorViewPager(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- setPageTransformer(false, mTransformer);
-
- final Resources res = context.getResources();
- mShadowRight = res.getDrawable(R.drawable.shadow_right);
- mShadowWidth = res.getDimensionPixelSize(R.dimen.pager_shadow_width);
- }
-
- /**
- * ViewPager inherits ViewGroup's default behavior of delayed clicks on its
- * children, but in order to make the calc buttons more responsive we
- * disable that here.
- */
- @Override
- public boolean shouldDelayChildPressedState() {
- return false;
- }
-
- @Override
- protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
- final boolean result = super.drawChild(canvas, child, drawingTime);
- mShadowRight.setBounds(child.getLeft() - mShadowWidth, child.getTop(), child.getLeft(),
- child.getBottom());
- mShadowRight.draw(canvas);
- return result;
- }
-
- private final PageTransformer mTransformer = new PageTransformer() {
- @Override
- public void transformPage(View v, float position) {
- final int pageWidth = v.getWidth();
-
- if (position < -1) {
- v.setAlpha(0);
- } else if (position <= 0) {
- // Pin the left page to the left side.
- v.setTranslationX(pageWidth * -position);
- } else if (position <= 1) {
- // Use the default slide transition when moving to the right
- // page
- v.setAlpha(1);
- v.setTranslationX(0);
- } else {
- v.setAlpha(0);
- }
- }
- };
-}
diff --git a/src/com/android/calculator2/EventListener.java b/src/com/android/calculator2/EventListener.java
deleted file mode 100644
index 580ff9b..0000000
--- a/src/com/android/calculator2/EventListener.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.calculator2;
-
-import android.support.v4.view.ViewPager;
-import android.view.KeyEvent;
-import android.view.View;
-import android.widget.Button;
-
-import com.android.calculator2.R;
-
-class EventListener implements View.OnKeyListener, View.OnClickListener, View.OnLongClickListener {
- private Logic mHandler;
- private ViewPager mPager;
-
- public void setHandler(Logic handler, ViewPager pager) {
- mHandler = handler;
- mPager = pager;
- }
-
- @Override
- public void onClick(View view) {
- final int id = view.getId();
- switch (id) {
- case R.id.del:
- mHandler.onDelete();
- break;
- case R.id.clear:
- mHandler.onClear();
- break;
- case R.id.equal:
- mHandler.onEnter();
- break;
- default:
- if (view instanceof Button) {
- String text = ((Button) view).getText().toString();
- if (text.length() >= 2) {
- // Add paren after sin, cos, ln, etc. from buttons.
- text += '(';
- }
-
- mHandler.append(text);
- }
- }
- }
-
- @Override
- public boolean onLongClick(View view) {
- final int id = view.getId();
- if (id == R.id.del) {
- mHandler.onClear();
- return true;
- }
-
- return false;
- }
-
- @Override
- public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
- if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
- return mHandler.eatHorizontalMove(keyCode == KeyEvent.KEYCODE_DPAD_LEFT);
- }
-
- // Work-around for spurious key event from IME, bug #1639445
- final int action = keyEvent.getAction();
- if (action == KeyEvent.ACTION_MULTIPLE && keyCode == KeyEvent.KEYCODE_UNKNOWN) {
- return true;
- }
-
- if (keyEvent.getUnicodeChar() == '=') {
- if (action == KeyEvent.ACTION_UP) {
- mHandler.onEnter();
- }
- return true;
- }
-
- if (keyCode != KeyEvent.KEYCODE_DPAD_CENTER && keyCode != KeyEvent.KEYCODE_DPAD_UP &&
- keyCode != KeyEvent.KEYCODE_DPAD_DOWN && keyCode != KeyEvent.KEYCODE_ENTER) {
- if (keyEvent.isPrintingKey() && action == KeyEvent.ACTION_UP) {
- // Tell the handler that text was updated.
- mHandler.onTextChanged();
- }
- return false;
- }
-
- // We should act on KeyEvent.ACTION_DOWN, but strangely sometimes the
- // DOWN event isn't received, only the UP. So the workaround is to act
- // on UP... http://b/issue?id=1022478
- if (action == KeyEvent.ACTION_UP) {
- switch (keyCode) {
- case KeyEvent.KEYCODE_ENTER:
- case KeyEvent.KEYCODE_DPAD_CENTER:
- mHandler.onEnter();
- break;
-
- case KeyEvent.KEYCODE_DPAD_UP:
- mHandler.onUp();
- break;
-
- case KeyEvent.KEYCODE_DPAD_DOWN:
- mHandler.onDown();
- break;
- }
- }
-
- return true;
- }
-}
diff --git a/src/com/android/calculator2/History.java b/src/com/android/calculator2/History.java
deleted file mode 100644
index c205209..0000000
--- a/src/com/android/calculator2/History.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.calculator2;
-
-import android.widget.BaseAdapter;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.Vector;
-
-class History {
- private static final int VERSION_1 = 1;
- private static final int MAX_ENTRIES = 100;
-
- private final Vector<HistoryEntry> mEntries = new Vector<HistoryEntry>();
-
- private int mPos;
- private BaseAdapter mObserver;
-
- public History() {
- clear();
- }
-
- public History(int version, DataInput in) throws IOException {
- if (version >= VERSION_1) {
- int size = in.readInt();
- for (int i = 0; i < size; ++i) {
- mEntries.add(new HistoryEntry(version, in));
- }
-
- mPos = in.readInt();
- } else {
- throw new IOException("invalid version " + version);
- }
- }
-
- public void setObserver(BaseAdapter observer) {
- mObserver = observer;
- }
-
- private void notifyChanged() {
- if (mObserver != null) {
- mObserver.notifyDataSetChanged();
- }
- }
-
- public Vector<HistoryEntry> getEntries() {
- return mEntries;
- }
-
- public void clear() {
- mEntries.clear();
- mEntries.add(new HistoryEntry(""));
- mPos = 0;
-
- notifyChanged();
- }
-
- public void write(DataOutput out) throws IOException {
- out.writeInt(mEntries.size());
-
- for (HistoryEntry entry : mEntries) {
- entry.write(out);
- }
-
- out.writeInt(mPos);
- }
-
- public void update(String text) {
- current().setEdited(text);
- }
-
- public boolean moveToPrevious() {
- if (mPos > 0) {
- --mPos;
- return true;
- }
-
- return false;
- }
-
- public boolean moveToNext() {
- if (mPos < mEntries.size() - 1) {
- ++mPos;
- return true;
- }
-
- return false;
- }
-
- public void enter(String text) {
- current().clearEdited();
-
- if (mEntries.size() >= MAX_ENTRIES) {
- mEntries.remove(0);
- }
-
- if (mEntries.size() < 2 ||
- !text.equals(mEntries.elementAt(mEntries.size() - 2).getBase())) {
- mEntries.insertElementAt(new HistoryEntry(text), mEntries.size() - 1);
- }
-
- mPos = mEntries.size() - 1;
- notifyChanged();
- }
-
- public HistoryEntry current() {
- return mEntries.elementAt(mPos);
- }
-
- public String getText() {
- return current().getEdited();
- }
-
- public String getBase() {
- return current().getBase();
- }
-}
diff --git a/src/com/android/calculator2/HistoryAdapter.java b/src/com/android/calculator2/HistoryAdapter.java
deleted file mode 100644
index 061e68e..0000000
--- a/src/com/android/calculator2/HistoryAdapter.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.calculator2;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.TextView;
-
-import com.android.calculator2.R;
-
-import org.javia.arity.SyntaxException;
-
-import java.util.Vector;
-
-class HistoryAdapter extends BaseAdapter {
- private final Vector<HistoryEntry> mEntries;
- private final LayoutInflater mInflater;
- private final Logic mEval;
-
- public HistoryAdapter(Context context, History history, Logic evaluator) {
- mEntries = history.getEntries();
- mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- mEval = evaluator;
- }
-
- @Override
- public int getCount() {
- return mEntries.size() - 1;
- }
-
- @Override
- public Object getItem(int position) {
- return mEntries.elementAt(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public boolean hasStableIds() {
- return true;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- final View view;
- if (convertView == null) {
- view = mInflater.inflate(R.layout.history_item, parent, false);
- } else {
- view = convertView;
- }
-
- final TextView expr = (TextView) view.findViewById(R.id.historyExpr);
- final TextView result = (TextView) view.findViewById(R.id.historyResult);
-
- final HistoryEntry entry = mEntries.elementAt(position);
- final String base = entry.getBase();
- expr.setText(entry.getBase());
-
- try {
- final String res = mEval.evaluate(base);
- result.setText("= " + res);
- } catch (SyntaxException e) {
- result.setText("");
- }
-
- return view;
- }
-}
diff --git a/src/com/android/calculator2/HistoryEntry.java b/src/com/android/calculator2/HistoryEntry.java
deleted file mode 100644
index 80319d8..0000000
--- a/src/com/android/calculator2/HistoryEntry.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.calculator2;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-class HistoryEntry {
- private static final int VERSION_1 = 1;
- private String mBase;
- private String mEdited;
-
- HistoryEntry(String str) {
- mBase = str;
- clearEdited();
- }
-
- HistoryEntry(int version, DataInput in) throws IOException {
- if (version >= VERSION_1) {
- mBase = in.readUTF();
- mEdited = in.readUTF();
- //Calculator.log("load " + mEdited);
- } else {
- throw new IOException("invalid version " + version);
- }
- }
-
- void write(DataOutput out) throws IOException {
- out.writeUTF(mBase);
- out.writeUTF(mEdited);
- //Calculator.log("save " + mEdited);
- }
-
- @Override
- public String toString() {
- return mBase;
- }
-
- void clearEdited() {
- mEdited = mBase;
- }
-
- String getEdited() {
- return mEdited;
- }
-
- void setEdited(String edited) {
- mEdited = edited;
- }
-
- String getBase() {
- return mBase;
- }
-}
diff --git a/src/com/android/calculator2/Logic.java b/src/com/android/calculator2/Logic.java
deleted file mode 100644
index 839e6f3..0000000
--- a/src/com/android/calculator2/Logic.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.calculator2;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.text.TextUtils;
-import android.view.KeyEvent;
-import android.widget.EditText;
-
-import com.android.calculator2.R;
-import com.android.calculator2.CalculatorDisplay.Scroll;
-
-import org.javia.arity.Symbols;
-import org.javia.arity.SyntaxException;
-
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map.Entry;
-import java.util.Set;
-
-class Logic {
- private CalculatorDisplay mDisplay;
- private Symbols mSymbols = new Symbols();
- private History mHistory;
- private String mResult = "";
- private boolean mIsError = false;
- private int mLineLength = 0;
-
- private static final String INFINITY_UNICODE = "\u221e";
-
- public static final String MARKER_EVALUATE_ON_RESUME = "?";
-
- // the two strings below are the result of Double.toString() for Infinity & NaN
- // they are not output to the user and don't require internationalization
- private static final String INFINITY = "Infinity";
- private static final String NAN = "NaN";
-
- static final char MINUS = '\u2212';
-
- private final String mErrorString;
-
- public final static int DELETE_MODE_BACKSPACE = 0;
- public final static int DELETE_MODE_CLEAR = 1;
-
- private int mDeleteMode = DELETE_MODE_BACKSPACE;
-
- public interface Listener {
- void onDeleteModeChange(int mode);
- }
-
- private Listener mListener;
- private Context mContext;
- private Set<Entry<String, String>> mTranslationsSet;
-
- Logic(Context context, History history, CalculatorDisplay display) {
- mContext = context;
- mErrorString = mContext.getResources().getString(R.string.error);
- mHistory = history;
- mDisplay = display;
- mDisplay.setLogic(this);
- }
-
- public void setListener(Listener listener) {
- this.mListener = listener;
- }
-
- public void setDeleteMode(int mode) {
- if (mDeleteMode != mode) {
- mDeleteMode = mode;
- mListener.onDeleteModeChange(mode);
- }
- }
-
- public int getDeleteMode() {
- return mDeleteMode;
- }
-
- void setLineLength(int nDigits) {
- mLineLength = nDigits;
- }
-
- boolean eatHorizontalMove(boolean toLeft) {
- EditText editText = mDisplay.getEditText();
- int cursorPos = editText.getSelectionStart();
- return toLeft ? cursorPos == 0 : cursorPos >= editText.length();
- }
-
- private String getText() {
- return mDisplay.getText().toString();
- }
-
- void insert(String delta) {
- mDisplay.insert(delta);
- setDeleteMode(DELETE_MODE_BACKSPACE);
- }
-
- void append(String delta) {
- mDisplay.append(delta);
- setDeleteMode(DELETE_MODE_BACKSPACE);
- }
-
- public void onTextChanged() {
- setDeleteMode(DELETE_MODE_BACKSPACE);
- }
-
- public void resumeWithHistory() {
- clearWithHistory(false);
- }
-
- private void clearWithHistory(boolean scroll) {
- String text = mHistory.getText();
- if (MARKER_EVALUATE_ON_RESUME.equals(text)) {
- if (!mHistory.moveToPrevious()) {
- text = "";
- }
- text = mHistory.getText();
- evaluateAndShowResult(text, CalculatorDisplay.Scroll.NONE);
- } else {
- mResult = "";
- mDisplay.setText(
- text, scroll ? CalculatorDisplay.Scroll.UP : CalculatorDisplay.Scroll.NONE);
- mIsError = false;
- }
- }
-
- private void clear(boolean scroll) {
- mHistory.enter("");
- mDisplay.setText("", scroll ? CalculatorDisplay.Scroll.UP : CalculatorDisplay.Scroll.NONE);
- cleared();
- }
-
- void cleared() {
- mResult = "";
- mIsError = false;
- updateHistory();
-
- setDeleteMode(DELETE_MODE_BACKSPACE);
- }
-
- boolean acceptInsert(String delta) {
- String text = getText();
- return !mIsError &&
- (!mResult.equals(text) ||
- isOperator(delta) ||
- mDisplay.getSelectionStart() != text.length());
- }
-
- void onDelete() {
- if (getText().equals(mResult) || mIsError) {
- clear(false);
- } else {
- mDisplay.dispatchKeyEvent(new KeyEvent(0, KeyEvent.KEYCODE_DEL));
- mResult = "";
- }
- }
-
- void onClear() {
- clear(mDeleteMode == DELETE_MODE_CLEAR);
- }
-
- void onEnter() {
- if (mDeleteMode == DELETE_MODE_CLEAR) {
- clearWithHistory(false); // clear after an Enter on result
- } else {
- evaluateAndShowResult(getText(), CalculatorDisplay.Scroll.UP);
- }
- }
-
- public void evaluateAndShowResult(String text, Scroll scroll) {
- try {
- String result = evaluate(text);
- if (!text.equals(result)) {
- mHistory.enter(text);
- mResult = result;
- mDisplay.setText(mResult, scroll);
- setDeleteMode(DELETE_MODE_CLEAR);
- }
- } catch (SyntaxException e) {
- mIsError = true;
- mResult = mErrorString;
- mDisplay.setText(mResult, scroll);
- setDeleteMode(DELETE_MODE_CLEAR);
- }
- }
-
- void onUp() {
- String text = getText();
- if (!text.equals(mResult)) {
- mHistory.update(text);
- }
- if (mHistory.moveToPrevious()) {
- mDisplay.setText(mHistory.getText(), CalculatorDisplay.Scroll.DOWN);
- }
- }
-
- void onDown() {
- String text = getText();
- if (!text.equals(mResult)) {
- mHistory.update(text);
- }
- if (mHistory.moveToNext()) {
- mDisplay.setText(mHistory.getText(), CalculatorDisplay.Scroll.UP);
- }
- }
-
- void updateHistory() {
- String text = getText();
- // Don't set the ? marker for empty text or the error string.
- // There is no need to evaluate those later.
- if (!TextUtils.isEmpty(text) && !TextUtils.equals(text, mErrorString)
- && text.equals(mResult)) {
- mHistory.update(MARKER_EVALUATE_ON_RESUME);
- } else {
- mHistory.update(getText());
- }
- }
-
- String evaluate(String input) throws SyntaxException {
- if (input.trim().equals("")) {
- return "";
- }
-
- // drop final infix operators (they can only result in error)
- int size = input.length();
- while (size > 0 && isOperator(input.charAt(size - 1))) {
- input = input.substring(0, size - 1);
- --size;
- }
- // Find and replace any translated mathematical functions.
- input = replaceTranslations(input);
- double value = mSymbols.eval(input);
-
- String result = "";
- for (int precision = mLineLength; precision > 6; precision--) {
- result = tryFormattingWithPrecision(value, precision);
- if (result.length() <= mLineLength) {
- break;
- }
- }
- return result.replace('-', MINUS).replace(INFINITY, INFINITY_UNICODE);
- }
-
- private void addTranslation(HashMap<String, String> map, int t, int m) {
- Resources res = mContext.getResources();
- String translated = res.getString(t);
- String math = res.getString(m);
- if (!TextUtils.equals(translated, math)) {
- map.put(translated, math);
- }
- }
-
- private String replaceTranslations(String input) {
- if (mTranslationsSet == null) {
- HashMap<String, String> map = new HashMap<String, String>();
- addTranslation(map, R.string.sin, R.string.sin_mathematical_value);
- addTranslation(map, R.string.cos, R.string.cos_mathematical_value);
- addTranslation(map, R.string.tan, R.string.tan_mathematical_value);
- addTranslation(map, R.string.e, R.string.e_mathematical_value);
- addTranslation(map, R.string.ln, R.string.ln_mathematical_value);
- addTranslation(map, R.string.lg, R.string.lg_mathematical_value);
- mTranslationsSet = map.entrySet();
- }
- for (Entry<String, String> entry : mTranslationsSet) {
- input = input.replace(entry.getKey(), entry.getValue());
- }
- return input;
- }
-
- private String tryFormattingWithPrecision(double value, int precision) {
- // The standard scientific formatter is basically what we need. We will
- // start with what it produces and then massage it a bit.
- String result = String.format(Locale.US, "%" + mLineLength + "." + precision + "g", value);
- if (result.equals(NAN)) { // treat NaN as Error
- mIsError = true;
- return mErrorString;
- }
- String mantissa = result;
- String exponent = null;
- int e = result.indexOf('e');
- if (e != -1) {
- mantissa = result.substring(0, e);
-
- // Strip "+" and unnecessary 0's from the exponent
- exponent = result.substring(e + 1);
- if (exponent.startsWith("+")) {
- exponent = exponent.substring(1);
- }
- exponent = String.valueOf(Integer.parseInt(exponent));
- } else {
- mantissa = result;
- }
-
- int period = mantissa.indexOf('.');
- if (period == -1) {
- period = mantissa.indexOf(',');
- }
- if (period != -1) {
- // Strip trailing 0's
- while (mantissa.length() > 0 && mantissa.endsWith("0")) {
- mantissa = mantissa.substring(0, mantissa.length() - 1);
- }
- if (mantissa.length() == period + 1) {
- mantissa = mantissa.substring(0, mantissa.length() - 1);
- }
- }
-
- if (exponent != null) {
- result = mantissa + 'e' + exponent;
- } else {
- result = mantissa;
- }
- return result;
- }
-
- static boolean isOperator(String text) {
- return text.length() == 1 && isOperator(text.charAt(0));
- }
-
- static boolean isOperator(char c) {
- //plus minus times div
- return "+\u2212\u00d7\u00f7/*".indexOf(c) != -1;
- }
-}
diff --git a/src/com/android/calculator2/PageAdapter.java b/src/com/android/calculator2/PageAdapter.java
deleted file mode 100644
index a8ff566..0000000
--- a/src/com/android/calculator2/PageAdapter.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.calculator2;
-
-import android.os.Parcelable;
-import android.support.v4.view.PagerAdapter;
-import android.view.View;
-import android.view.ViewGroup;
-
-import java.util.ArrayList;
-
-class PageAdapter extends PagerAdapter {
- private final ArrayList<View> mPages = new ArrayList<View>();
-
- public void add(View page) {
- mPages.add(page);
-
- notifyDataSetChanged();
- }
-
- @Override
- public int getCount() {
- return mPages.size();
- }
-
- @Override
- public float getPageWidth(int position) {
- return 0.90f;
- }
-
- @Override
- public Object instantiateItem(ViewGroup container, int position) {
- final View page = mPages.get(position);
- container.addView(page);
- return page;
- }
-
- @Override
- public void destroyItem(ViewGroup container, int position, Object object) {
- container.removeView((View) object);
- }
-
- @Override
- public boolean isViewFromObject(View view, Object object) {
- return view == object;
- }
-
- @Override
- public Parcelable saveState() {
- return null;
- }
-
- @Override
- public void restoreState(Parcelable state, ClassLoader loader) {
- }
-}
diff --git a/src/com/android/calculator2/PanelSwitcher.java b/src/com/android/calculator2/PanelSwitcher.java
deleted file mode 100644
index 0933c21..0000000
--- a/src/com/android/calculator2/PanelSwitcher.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.calculator2;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.GestureDetector;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.animation.Animation;
-import android.view.animation.Animation.AnimationListener;
-import android.view.animation.TranslateAnimation;
-import android.widget.FrameLayout;
-
-class PanelSwitcher extends FrameLayout implements AnimationListener {
- private static final int MAJOR_MOVE = 60;
- private static final int ANIM_DURATION = 400;
-
- private GestureDetector mGestureDetector;
- private int mCurrentView;
- private View mChildren[] = new View[0];
-
- private int mWidth;
- private TranslateAnimation inLeft;
- private TranslateAnimation outLeft;
-
- private TranslateAnimation inRight;
- private TranslateAnimation outRight;
-
- private static final int LEFT = 1;
- private static final int RIGHT = 2;
- private int mPreviousMove;
-
- public interface Listener {
- void onChange();
- }
-
- private Listener mListener;
-
- public PanelSwitcher(Context context, AttributeSet attrs) {
- super(context, attrs);
- mCurrentView = 0;
- mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
- @Override
- public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
- float velocityY) {
- int dx = (int) (e2.getX() - e1.getX());
-
- // don't accept the fling if it's too short
- // as it may conflict with a button push
- if (Math.abs(dx) > MAJOR_MOVE && Math.abs(velocityX) > Math.abs(velocityY)) {
- if (velocityX > 0) {
- moveRight();
- } else {
- moveLeft();
- }
- return true;
- } else {
- return false;
- }
- }
- });
- }
-
- public void setListener(Listener listener) {
- this.mListener = listener;
- }
-
- void setCurrentIndex(int current) {
- boolean changed = mCurrentView != current;
- mCurrentView = current;
- updateCurrentView();
- if (changed && mListener != null) {
- mListener.onChange();
- }
- }
-
- private void updateCurrentView() {
- for (int i = mChildren.length-1; i >= 0 ; --i) {
- mChildren[i].setVisibility(i==mCurrentView ? View.VISIBLE : View.GONE);
- }
- }
-
- @Override
- public void onSizeChanged(int w, int h, int oldW, int oldH) {
- mWidth = w;
- inLeft = new TranslateAnimation(mWidth, 0, 0, 0);
- inLeft.setAnimationListener(this);
- outLeft = new TranslateAnimation(0, -mWidth, 0, 0);
- inRight = new TranslateAnimation(-mWidth, 0, 0, 0);
- inRight.setAnimationListener(this);
- outRight = new TranslateAnimation(0, mWidth, 0, 0);
-
- inLeft.setDuration(ANIM_DURATION);
- outLeft.setDuration(ANIM_DURATION);
- inRight.setDuration(ANIM_DURATION);
- outRight.setDuration(ANIM_DURATION);
- }
-
- @Override
- protected void onFinishInflate() {
- int count = getChildCount();
- mChildren = new View[count];
- for (int i = 0; i < count; ++i) {
- mChildren[i] = getChildAt(i);
- }
- updateCurrentView();
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- mGestureDetector.onTouchEvent(event);
- return true;
- }
-
- @Override
- public boolean onInterceptTouchEvent(MotionEvent event) {
- return mGestureDetector.onTouchEvent(event);
- }
-
- void moveLeft() {
- // <--
- if (mCurrentView < mChildren.length - 1 && mPreviousMove != LEFT) {
- mChildren[mCurrentView+1].setVisibility(View.VISIBLE);
- mChildren[mCurrentView+1].startAnimation(inLeft);
- mChildren[mCurrentView].startAnimation(outLeft);
- mChildren[mCurrentView].setVisibility(View.GONE);
-
- mCurrentView++;
- mPreviousMove = LEFT;
- }
- }
-
- void moveRight() {
- // -->
- if (mCurrentView > 0 && mPreviousMove != RIGHT) {
- mChildren[mCurrentView-1].setVisibility(View.VISIBLE);
- mChildren[mCurrentView-1].startAnimation(inRight);
- mChildren[mCurrentView].startAnimation(outRight);
- mChildren[mCurrentView].setVisibility(View.GONE);
-
- mCurrentView--;
- mPreviousMove = RIGHT;
- }
- }
-
- int getCurrentIndex() {
- return mCurrentView;
- }
-
- @Override
- public void onAnimationRepeat(Animation animation) {
- }
-
- @Override
- public void onAnimationStart(Animation animation) {
- }
-
- @Override
- public void onAnimationEnd(Animation animation) {
- if (mListener != null) {
- mListener.onChange();
- }
- }
-}
diff --git a/src/com/android/calculator2/Persist.java b/src/com/android/calculator2/Persist.java
deleted file mode 100644
index 5f23551..0000000
--- a/src/com/android/calculator2/Persist.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.calculator2;
-
-import android.content.Context;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-class Persist {
- private static final int LAST_VERSION = 2;
- private static final String FILE_NAME = "calculator.data";
-
- private Context mContext;
- private History mHistory;
- private int mDeleteMode;
-
- public Persist(Context context) {
- mContext = context;
- }
-
- public History getHistory() {
- return mHistory;
- }
-
- public void setDeleteMode(int mode) {
- mDeleteMode = mode;
- }
-
- public int getDeleteMode() {
- return mDeleteMode;
- }
-
- public void load() {
- try {
- final DataInputStream in = new DataInputStream(
- new BufferedInputStream(mContext.openFileInput(FILE_NAME), 8192));
- final int version = in.readInt();
- if (version > 1) {
- mDeleteMode = in.readInt();
- } else if (version > LAST_VERSION) {
- throw new IOException("data version " + version + "; expected " + LAST_VERSION);
- }
-
- mHistory = new History(version, in);
-
- in.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- if (mHistory == null) {
- mHistory = new History();
- }
- }
-
- public void save() {
- if (mHistory == null) {
- return;
- }
-
- try {
- final DataOutputStream out = new DataOutputStream(
- new BufferedOutputStream(mContext.openFileOutput(FILE_NAME, 0), 8192));
- out.writeInt(LAST_VERSION);
- out.writeInt(mDeleteMode);
-
- mHistory.write(out);
-
- out.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/tests/Android.mk b/tests/Android.mk
deleted file mode 100644
index 11455d0..0000000
--- a/tests/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_JAVA_LIBRARIES := android.test.runner
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := CalculatorTests
-
-LOCAL_INSTRUMENTATION_FOR := Calculator
-
-include $(BUILD_PACKAGE)
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
deleted file mode 100644
index d8bed49..0000000
--- a/tests/AndroidManifest.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.calculator2.tests">
-
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation android:name="CalculatorLaunchPerformance"
- android:targetPackage="com.android.calculator2"
- android:label="Calculator Launch Performance">
- </instrumentation>
-
- <instrumentation android:name="android.test.InstrumentationTestRunner"
- android:targetPackage="com.android.calculator2"
- android:label="Calculator Functional Testset">
- </instrumentation>
-
-</manifest>
diff --git a/tests/src/com/android/calculator2/CalculatorHitSomeButtons.java b/tests/src/com/android/calculator2/CalculatorHitSomeButtons.java
deleted file mode 100644
index c512edd..0000000
--- a/tests/src/com/android/calculator2/CalculatorHitSomeButtons.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * Copyright (c) 2008, Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.calculator2;
-
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.app.Instrumentation.ActivityMonitor;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.test.ActivityInstrumentationTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.view.View;
-import android.widget.EditText;
-import android.widget.Button;
-import android.widget.LinearLayout;
-import android.graphics.Rect;
-import android.test.TouchUtils;
-
-import com.android.calculator2.Calculator;
-import com.android.calculator2.R;
-import com.android.calculator2.CalculatorDisplay;
-
-/**
- * Instrumentation tests for poking some buttons
- *
- */
-
-public class CalculatorHitSomeButtons extends ActivityInstrumentationTestCase <Calculator>{
- public boolean setup = false;
- private static final String TAG = "CalculatorTests";
- Calculator mActivity = null;
- Instrumentation mInst = null;
-
- public CalculatorHitSomeButtons() {
- super("com.android.calculator2", Calculator.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- mActivity = getActivity();
- mInst = getInstrumentation();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- @LargeTest
- public void testPressSomeKeys() {
- Log.v(TAG, "Pressing some keys!");
-
- // Make sure that we clear the output
- press(KeyEvent.KEYCODE_ENTER);
- press(KeyEvent.KEYCODE_CLEAR);
-
- // 3 + 4 * 5 => 23
- press(KeyEvent.KEYCODE_3);
- press(KeyEvent.KEYCODE_PLUS);
- press(KeyEvent.KEYCODE_4);
- press(KeyEvent.KEYCODE_9 | KeyEvent.META_SHIFT_ON);
- press(KeyEvent.KEYCODE_5);
- press(KeyEvent.KEYCODE_ENTER);
-
- assertEquals(displayVal(), "23");
- }
-
- @LargeTest
- public void testTapSomeButtons() {
- Log.v(TAG, "Tapping some buttons!");
-
- // Make sure that we clear the output
- tap(R.id.equal);
- tap(R.id.del);
-
- // 567 / 3 => 189
- tap(R.id.digit5);
- tap(R.id.digit6);
- tap(R.id.digit7);
- tap(R.id.div);
- tap(R.id.digit3);
- tap(R.id.equal);
-
- assertEquals(displayVal(), "189");
-
- // make sure we can continue calculations also
- // 189 - 789 => -600
- tap(R.id.minus);
- tap(R.id.digit7);
- tap(R.id.digit8);
- tap(R.id.digit9);
- tap(R.id.equal);
-
- // Careful: the first digit in the expected value is \u2212, not "-" (a hyphen)
- assertEquals(displayVal(), mActivity.getString(R.string.minus) + "600");
- }
-
- // helper functions
- private void press(int keycode) {
- mInst.sendKeyDownUpSync(keycode);
- }
-
- private boolean tap(int id) {
- View view = mActivity.findViewById(id);
- if(view != null) {
- TouchUtils.clickView(this, view);
- return true;
- }
- return false;
- }
-
- private String displayVal() {
- CalculatorDisplay display = (CalculatorDisplay) mActivity.findViewById(R.id.display);
- assertNotNull(display);
-
- EditText box = (EditText) display.getCurrentView();
- assertNotNull(box);
-
- return box.getText().toString();
- }
-}
-
diff --git a/tests/src/com/android/calculator2/CalculatorInstrumentationTestRunner.java b/tests/src/com/android/calculator2/CalculatorInstrumentationTestRunner.java
deleted file mode 100644
index 16c9d36..0000000
--- a/tests/src/com/android/calculator2/CalculatorInstrumentationTestRunner.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright (c) 2008, Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.calculator2;
-
-import android.test.InstrumentationTestRunner;
-import android.test.InstrumentationTestSuite;
-
-import com.android.calculator2.CalculatorHitSomeButtons;
-
-import junit.framework.TestSuite;
-
-public class CalculatorInstrumentationTestRunner extends InstrumentationTestRunner {
-
- @Override
- public TestSuite getAllTests() {
- TestSuite suite = new InstrumentationTestSuite(this);
- suite.addTestSuite(CalculatorHitSomeButtons.class);
-
- return suite;
- }
-
- @Override
- public ClassLoader getLoader() {
- return CalculatorInstrumentationTestRunner.class.getClassLoader();
- }
-}
-
diff --git a/tests/src/com/android/calculator2/tests/CalculatorLaunchPerformance.java b/tests/src/com/android/calculator2/tests/CalculatorLaunchPerformance.java
deleted file mode 100644
index 6c84e17..0000000
--- a/tests/src/com/android/calculator2/tests/CalculatorLaunchPerformance.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.calculator2.tests;
-
-import android.app.Activity;
-import android.test.LaunchPerformanceBase;
-import android.os.Bundle;
-
-import java.util.Map;
-
-/**
- * Instrumentation class for Calculator launch performance testing.
- */
-public class CalculatorLaunchPerformance extends LaunchPerformanceBase {
-
- public static final String LOG_TAG = "CalculatorLaunchPerformance";
-
- public CalculatorLaunchPerformance() {
- super();
- }
-
- @Override
- public void onCreate(Bundle arguments) {
- super.onCreate(arguments);
-
- mIntent.setClassName(getTargetContext(), "com.android.calculator2.Calculator");
- start();
- }
-
- /**
- * Calls LaunchApp and finish.
- */
- @Override
- public void onStart() {
- super.onStart();
- LaunchApp();
- finish(Activity.RESULT_OK, mResults);
- }
-}