auto import from //depot/cupcake/@135843
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..555186d
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,36 @@
+#
+# 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_STATIC_JAVA_LIBRARIES := libarity
+
+LOCAL_MODULE_TAGS := eng development
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := Calculator
+
+include $(BUILD_PACKAGE)
+##################################################
+include $(CLEAR_VARS)
+
+LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libarity:arity-1.3.1.jar
+include $(BUILD_MULTI_PREBUILT)
+
+# Use the folloing include to make our test apk.
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100644
index 0000000..ce9063f
--- /dev/null
+++ b/AndroidManifest.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.calculator2">
+    <application android:label="@string/app_name" android:icon="@drawable/icon">
+        <activity android:name="Calculator" 
+                  android:theme="@android:style/Theme.Black">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+</manifest> 
diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MODULE_LICENSE_APACHE2
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..c5b1efa
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,190 @@
+
+   Copyright (c) 2005-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.
+
+   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.
+
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
diff --git a/arity-1.3.1.jar b/arity-1.3.1.jar
new file mode 100644
index 0000000..ceab57a
--- /dev/null
+++ b/arity-1.3.1.jar
Binary files differ
diff --git a/res/drawable/advanced.png b/res/drawable/advanced.png
new file mode 100644
index 0000000..aa634e7
--- /dev/null
+++ b/res/drawable/advanced.png
Binary files differ
diff --git a/res/drawable/button.png b/res/drawable/button.png
new file mode 100644
index 0000000..f28073c
--- /dev/null
+++ b/res/drawable/button.png
Binary files differ
diff --git a/res/drawable/button_bg.png b/res/drawable/button_bg.png
new file mode 100644
index 0000000..83eeb0f
--- /dev/null
+++ b/res/drawable/button_bg.png
Binary files differ
diff --git a/res/drawable/clear_history.png b/res/drawable/clear_history.png
new file mode 100644
index 0000000..ec3dc55
--- /dev/null
+++ b/res/drawable/clear_history.png
Binary files differ
diff --git a/res/drawable/icon.png b/res/drawable/icon.png
new file mode 100644
index 0000000..298c267
--- /dev/null
+++ b/res/drawable/icon.png
Binary files differ
diff --git a/res/drawable/lcd.9.png b/res/drawable/lcd.9.png
new file mode 100644
index 0000000..942ede9
--- /dev/null
+++ b/res/drawable/lcd.9.png
Binary files differ
diff --git a/res/drawable/simple.png b/res/drawable/simple.png
new file mode 100644
index 0000000..563ff0f
--- /dev/null
+++ b/res/drawable/simple.png
Binary files differ
diff --git a/res/drawable/small_button.9.png b/res/drawable/small_button.9.png
new file mode 100644
index 0000000..c6b60a8
--- /dev/null
+++ b/res/drawable/small_button.9.png
Binary files differ
diff --git a/res/drawable/small_button_pressed.9.png b/res/drawable/small_button_pressed.9.png
new file mode 100644
index 0000000..5b5c866
--- /dev/null
+++ b/res/drawable/small_button_pressed.9.png
Binary files differ
diff --git a/res/drawable/small_button_stateful.xml b/res/drawable/small_button_stateful.xml
new file mode 100644
index 0000000..a3326dd
--- /dev/null
+++ b/res/drawable/small_button_stateful.xml
@@ -0,0 +1,4 @@
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_pressed="true" android:drawable="@drawable/small_button_pressed" />
+    <item android:drawable="@drawable/small_button" />
+</selector>
diff --git a/res/layout-land/history_item.xml b/res/layout-land/history_item.xml
new file mode 100644
index 0000000..cc0a3c6
--- /dev/null
+++ b/res/layout-land/history_item.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+     xmlns:android="http://schemas.android.com/apk/res/android"
+     android:layout_width="fill_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
new file mode 100644
index 0000000..c116984
--- /dev/null
+++ b/res/layout-land/main.xml
@@ -0,0 +1,257 @@
+<?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.
+ */
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:orientation="vertical"
+              android:layout_width="fill_parent"
+              android:layout_height="fill_parent"
+              android:background="#ff000000">
+
+    <RelativeLayout
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="0"
+        android:layout_marginLeft="0px"
+        android:layout_marginRight="0px"
+        android:layout_marginBottom="0px"
+        >
+        
+        <LinearLayout
+             android:layout_width="fill_parent"
+             android:layout_height="wrap_content"
+             android:background="@drawable/lcd" 
+             android:layout_marginRight="0px"
+             >
+            
+            <com.android.calculator2.CalculatorDisplay 
+                 android:id="@+id/display"
+                 android:layout_width="fill_parent"
+                 android:layout_height="wrap_content"
+                 >
+
+                <EditText style="@style/display_style" />                
+                <EditText style="@style/display_style" />
+                
+            </com.android.calculator2.CalculatorDisplay>                      
+        </LinearLayout>
+    </RelativeLayout>
+
+    <com.android.calculator2.PanelSwitcher
+         android:id="@+id/panelswitch"
+         android:layout_width="fill_parent"
+         android:layout_height="fill_parent"
+         >
+
+    <LinearLayout 
+         android:id="@+id/simplePad"
+         android:layout_width="fill_parent"
+         android:layout_height="fill_parent"
+         android:orientation="vertical"
+         android:layout_gravity="center"
+         > 
+        <LinearLayout 
+             android:layout_weight="1"
+             android:layout_width="fill_parent"
+             android:layout_height="0px"
+             >    
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit7"
+                android:text="@string/digit7"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit8"
+                android:text="@string/digit8"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit9"
+                android:text="@string/digit9"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/leftParen"
+                android:text="@string/leftParen"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/rightParen"
+                android:text="@string/rightParen"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton 
+                android:id="@+id/mul"
+                android:text="@string/mul"
+                style="@style/button_style"
+                />
+        </LinearLayout>
+        
+        <LinearLayout 
+             android:layout_weight="1"
+             android:layout_width="fill_parent"
+             android:layout_height="0px"
+             >    
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit4"
+                android:text="@string/digit4"
+                style="@style/button_style"
+                />        
+            <com.android.calculator2.ColorButton 
+                android:id="@+id/digit5"
+                android:text="@string/digit5"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton 
+                android:id="@+id/digit6"
+                android:text="@string/digit6"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton 
+                android:id="@+id/dot"
+                android:text="@string/dot"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/div"
+                android:text="@string/div"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/minus"
+                android:text="@string/minus"
+                style="@style/button_style"
+                />
+        </LinearLayout>
+        
+        <LinearLayout 
+             android:layout_weight="1"
+             android:layout_width="fill_parent"
+             android:layout_height="0px"
+             >            
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit1"
+                android:text="@string/digit1"
+                style="@style/button_style"
+                />        
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit2"
+                android:text="@string/digit2"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton 
+                android:id="@+id/digit3"
+                android:text="@string/digit3"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit0"
+                android:text="@string/digit0"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/equal"
+                android:text="@string/equal"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/plus"
+                android:text="@string/plus"
+                style="@style/button_style"
+                />
+        </LinearLayout>
+    </LinearLayout>
+
+    <LinearLayout 
+         android:id="@+id/advancedPad"
+         android:layout_width="fill_parent"
+         android:layout_height="fill_parent"
+         android:layout_weight="1"
+         android:orientation="vertical"
+         android:layout_gravity="center"
+         android:layout_marginTop="5px"         
+         android:layout_marginBottom="0px"
+         > 
+        
+        <LinearLayout 
+            android:layout_weight="1"
+            android:layout_width="fill_parent"
+            android:layout_height="0px"
+            >            
+            <com.android.calculator2.ColorButton 
+                android:id="@+id/sin"
+                android:text="@string/sin"
+                style="@style/button_small_style"
+                />
+            <com.android.calculator2.ColorButton 
+                android:id="@+id/cos"
+                android:text="@string/cos"
+                style="@style/button_small_style"
+                />
+            <com.android.calculator2.ColorButton 
+                android:id="@+id/tan"
+                android:text="@string/tan"
+                style="@style/button_small_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/pi"
+                android:text="@string/pi"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/factorial"
+                android:text="@string/factorial"
+                style="@style/button_style"
+                />
+        </LinearLayout>
+        
+        <LinearLayout 
+            android:layout_weight="1"
+            android:layout_width="fill_parent"
+            android:layout_height="0px"
+            >            
+            <com.android.calculator2.ColorButton
+                android:id="@+id/ln"
+                android:text="@string/ln"
+                style="@style/button_small_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/lg"
+                android:text="@string/lg"
+                style="@style/button_small_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/e"
+                android:text="@string/e"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/power"
+                android:text="@string/power"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/sqrt"
+                android:text="@string/sqrt"
+                style="@style/button_style"
+                />
+        </LinearLayout>
+    </LinearLayout>
+    </com.android.calculator2.PanelSwitcher>
+</LinearLayout>
diff --git a/res/layout-port/history_item.xml b/res/layout-port/history_item.xml
new file mode 100644
index 0000000..cc0a3c6
--- /dev/null
+++ b/res/layout-port/history_item.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+     xmlns:android="http://schemas.android.com/apk/res/android"
+     android:layout_width="fill_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-port/main.xml b/res/layout-port/main.xml
new file mode 100644
index 0000000..b115e53
--- /dev/null
+++ b/res/layout-port/main.xml
@@ -0,0 +1,299 @@
+<?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.
+ */
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:orientation="vertical"
+              android:layout_width="fill_parent"
+              android:layout_height="fill_parent"
+              android:background="#ff000000">
+
+    <RelativeLayout
+         android:layout_width="fill_parent"
+         android:layout_height="wrap_content"
+         android:layout_marginTop="5px"
+         >
+
+        <LinearLayout
+              android:layout_width="fill_parent"
+              android:layout_height="wrap_content"
+              android:background="@drawable/lcd"
+              android:layout_marginRight="0px">
+
+            <com.android.calculator2.CalculatorDisplay
+                 android:id="@+id/display"
+                 android:layout_width="fill_parent"
+                 android:layout_height="wrap_content"
+                 >
+
+                <EditText style="@style/display_style" />
+                <EditText style="@style/display_style" />
+
+            </com.android.calculator2.CalculatorDisplay>
+        </LinearLayout>
+    </RelativeLayout>
+
+    <com.android.calculator2.PanelSwitcher
+         android:id="@+id/panelswitch"
+         android:layout_width="fill_parent"
+         android:layout_height="fill_parent"
+         >
+
+    <LinearLayout
+         android:id="@+id/simplePad"
+         android:layout_width="fill_parent"
+         android:layout_height="fill_parent"
+         android:orientation="vertical"
+         android:layout_gravity="center"
+         >
+
+        <LinearLayout
+             android:layout_width="fill_parent"
+             android:layout_height="wrap_content"
+             android:layout_marginBottom="8px"
+             android:layout_marginTop="5px"
+             >
+
+            <View
+                android:layout_width="0px"
+                android:layout_height="0px"
+                android:layout_weight="1"
+                />
+                        
+            <!-- marginRight has to be 0 to catch border-touch -->
+            <Button
+                 android:background="@drawable/small_button_stateful"
+                 android:id="@+id/del"
+                 android:text="@string/clear"
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"
+                 android:width="90px"
+                 android:height="50px"
+                 android:textColor="#ffffffff"
+                 android:layout_marginRight="0px"
+                 android:layout_marginBottom="3px"
+                 android:layout_weight="0"
+                 />
+	</LinearLayout>
+
+        <LinearLayout
+             android:layout_weight="1"
+             android:layout_width="fill_parent"
+             android:layout_height="0px">
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit7"
+                android:text="@string/digit7"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit8"
+                android:text="@string/digit8"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit9"
+                android:text="@string/digit9"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/div"
+                android:text="@string/div"
+                style="@style/button_style"
+                />
+        </LinearLayout>
+
+        <LinearLayout
+             android:layout_weight="1"
+             android:layout_width="fill_parent"
+             android:layout_height="0px"
+             >
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit4"
+                android:text="@string/digit4"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit5"
+                android:text="@string/digit5"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit6"
+                android:text="@string/digit6"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/mul"
+                android:text="@string/mul"
+                style="@style/button_style"
+                />
+        </LinearLayout>
+
+        <LinearLayout
+             android:layout_weight="1"
+             android:layout_width="fill_parent"
+             android:layout_height="0px"
+             >
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit1"
+                android:text="@string/digit1"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit2"
+                android:text="@string/digit2"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit3"
+                android:text="@string/digit3"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/minus"
+                android:text="@string/minus"
+                style="@style/button_style"
+                />
+        </LinearLayout>
+
+        <LinearLayout
+             android:layout_weight="1"
+             android:layout_width="fill_parent"
+             android:layout_height="0px"
+             >
+            <com.android.calculator2.ColorButton
+                android:id="@+id/dot"
+                android:text="@string/dot"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/digit0"
+                android:text="@string/digit0"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/equal"
+                android:text="@string/equal"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/plus"
+                android:text="@string/plus"
+                style="@style/button_style"
+                />
+        </LinearLayout>
+    </LinearLayout>
+
+    <LinearLayout android:id="@+id/advancedPad"
+                  android:layout_width="fill_parent"
+                  android:layout_height="fill_parent"
+                  android:orientation="vertical"
+                  android:layout_gravity="center"
+                  >
+
+        <LinearLayout
+             android:layout_weight="1"
+             android:layout_width="fill_parent"
+             android:layout_height="0px"
+             >
+            <com.android.calculator2.ColorButton
+                android:id="@+id/sin"
+                android:text="@string/sin"
+                style="@style/button_small_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/cos"
+                android:text="@string/cos"
+                style="@style/button_small_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/tan"
+                android:text="@string/tan"
+                style="@style/button_small_style"
+                />
+        </LinearLayout>
+
+        <LinearLayout
+             android:layout_weight="1"
+             android:layout_width="fill_parent"
+             android:layout_height="0px"
+             >
+            <com.android.calculator2.ColorButton
+                android:id="@+id/ln"
+                android:text="@string/ln"
+                style="@style/button_small_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/lg"
+                android:text="@string/lg"
+                style="@style/button_small_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/factorial"
+                android:text="@string/factorial"
+                style="@style/button_style"
+                />
+        </LinearLayout>
+
+        <LinearLayout
+             android:layout_weight="1"
+             android:layout_width="fill_parent"
+             android:layout_height="0px"
+             >
+            <com.android.calculator2.ColorButton
+                android:id="@+id/pi"
+                android:text="@string/pi"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/e"
+                android:text="@string/e"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/power"
+                android:text="@string/power"
+                style="@style/button_style"
+                />
+        </LinearLayout>
+
+        <LinearLayout
+             android:layout_weight="1"
+             android:layout_width="fill_parent"
+             android:layout_height="0px"
+             >
+            <com.android.calculator2.ColorButton
+                android:id="@+id/leftParen"
+                android:text="@string/leftParen"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/rightParen"
+                android:text="@string/rightParen"
+                style="@style/button_style"
+                />
+            <com.android.calculator2.ColorButton
+                android:id="@+id/sqrt"
+                android:text="@string/sqrt"
+                style="@style/button_style"
+                />
+        </LinearLayout>
+    </LinearLayout>
+    </com.android.calculator2.PanelSwitcher>
+</LinearLayout>
diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml
new file mode 100644
index 0000000..4d673e5
--- /dev/null
+++ b/res/values-cs/strings.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 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"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name">"Kalkulačka"</string>
+    <string name="error">"Chyba"</string>
+    <string name="digit0">"0"</string>
+    <string name="digit1">"1"</string>
+    <string name="digit2">"2"</string>
+    <string name="digit3">"3"</string>
+    <string name="digit4">"4"</string>
+    <string name="digit5">"5"</string>
+    <string name="digit6">"6"</string>
+    <string name="digit7">"7"</string>
+    <string name="digit8">"8"</string>
+    <string name="digit9">"9"</string>
+    <string name="del">"ODSTRANIT"</string>
+    <string name="clear">"VYMAZAT"</string>
+    <string name="sin">"sin"</string>
+    <string name="cos">"cos"</string>
+    <string name="tan">"tan"</string>
+    <string name="e">"e"</string>
+    <string name="ln">"ln"</string>
+    <string name="lg">"log"</string>
+    <string name="leftParen">"("</string>
+    <string name="rightParen">")"</string>
+    <string name="basic">"Základní funkce"</string>
+    <string name="advanced">"Pokročilé funkce"</string>
+    <string name="clear_history">"Vymazat historii"</string>
+</resources>
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
new file mode 100644
index 0000000..ab6fc36
--- /dev/null
+++ b/res/values-de/strings.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 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"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name">"Rechner"</string>
+    <string name="error">"Fehler"</string>
+    <string name="digit0">"0"</string>
+    <string name="digit1">"1"</string>
+    <string name="digit2">"2"</string>
+    <string name="digit3">"3"</string>
+    <string name="digit4">"4"</string>
+    <string name="digit5">"5"</string>
+    <string name="digit6">"6"</string>
+    <string name="digit7">"7"</string>
+    <string name="digit8">"8"</string>
+    <string name="digit9">"9"</string>
+    <string name="del">"C"</string>
+    <string name="clear">"AC"</string>
+    <string name="sin">"sin"</string>
+    <string name="cos">"cos"</string>
+    <string name="tan">"tan"</string>
+    <string name="e">"e"</string>
+    <string name="ln">"ln"</string>
+    <string name="lg">"log"</string>
+    <string name="leftParen">"("</string>
+    <string name="rightParen">")"</string>
+    <string name="basic">"Grundfunktionen"</string>
+    <string name="advanced">"Erweiterte Funktionen"</string>
+    <string name="clear_history">"Verlauf löschen"</string>
+</resources>
diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml
new file mode 100644
index 0000000..4a37445
--- /dev/null
+++ b/res/values-es/strings.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 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"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name">"Calculadora"</string>
+    <string name="error">"Error"</string>
+    <string name="digit0">"0"</string>
+    <string name="digit1">"1"</string>
+    <string name="digit2">"2"</string>
+    <string name="digit3">"3"</string>
+    <string name="digit4">"4"</string>
+    <string name="digit5">"5"</string>
+    <string name="digit6">"6"</string>
+    <string name="digit7">"7"</string>
+    <string name="digit8">"8"</string>
+    <string name="digit9">"9"</string>
+    <string name="del">"ELIMINAR"</string>
+    <string name="clear">"BORRAR"</string>
+    <string name="sin">"sen"</string>
+    <string name="cos">"cos"</string>
+    <string name="tan">"tan"</string>
+    <string name="e">"e"</string>
+    <string name="ln">"ln"</string>
+    <string name="lg">"log"</string>
+    <string name="leftParen">"("</string>
+    <string name="rightParen">")"</string>
+    <string name="basic">"Panel de funciones básicas"</string>
+    <string name="advanced">"Panel de funciones avanzadas"</string>
+    <string name="clear_history">"Borrar historial"</string>
+</resources>
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
new file mode 100644
index 0000000..26d012a
--- /dev/null
+++ b/res/values-fr/strings.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 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"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name">"Calculatrice"</string>
+    <string name="error">"Erreur"</string>
+    <string name="digit0">"0"</string>
+    <string name="digit1">"1"</string>
+    <string name="digit2">"2"</string>
+    <string name="digit3">"3"</string>
+    <string name="digit4">"4"</string>
+    <string name="digit5">"5"</string>
+    <string name="digit6">"6"</string>
+    <string name="digit7">"7"</string>
+    <string name="digit8">"8"</string>
+    <string name="digit9">"9"</string>
+    <string name="del">"SUPPRIMER"</string>
+    <string name="clear">"EFFACER"</string>
+    <string name="sin">"sin"</string>
+    <string name="cos">"cos"</string>
+    <string name="tan">"tan"</string>
+    <string name="e">"e"</string>
+    <string name="ln">"ln"</string>
+    <string name="lg">"log"</string>
+    <string name="leftParen">"("</string>
+    <string name="rightParen">")"</string>
+    <string name="basic">"Panneau de base"</string>
+    <string name="advanced">"Fonctions avancées"</string>
+    <string name="clear_history">"Effacer l\'historique"</string>
+</resources>
diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml
new file mode 100644
index 0000000..22e81e0
--- /dev/null
+++ b/res/values-it/strings.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 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"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name">"Calcolatrice"</string>
+    <string name="error">"Errore"</string>
+    <string name="digit0">"0"</string>
+    <string name="digit1">"1"</string>
+    <string name="digit2">"2"</string>
+    <string name="digit3">"3"</string>
+    <string name="digit4">"4"</string>
+    <string name="digit5">"5"</string>
+    <string name="digit6">"6"</string>
+    <string name="digit7">"7"</string>
+    <string name="digit8">"8"</string>
+    <string name="digit9">"9"</string>
+    <string name="del">"ELIMINA"</string>
+    <string name="clear">"CANCELLA"</string>
+    <string name="sin">"sin"</string>
+    <string name="cos">"cos"</string>
+    <string name="tan">"tan"</string>
+    <string name="e">"e"</string>
+    <string name="ln">"ln"</string>
+    <string name="lg">"log"</string>
+    <string name="leftParen">"("</string>
+    <string name="rightParen">")"</string>
+    <string name="basic">"Pannello base"</string>
+    <string name="advanced">"Pannello avanzato"</string>
+    <string name="clear_history">"Cancella cronologia"</string>
+</resources>
diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml
new file mode 100644
index 0000000..ae74f66
--- /dev/null
+++ b/res/values-ja/strings.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 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"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name">"電卓"</string>
+    <string name="error">"エラー"</string>
+    <string name="digit0">"0"</string>
+    <string name="digit1">"1"</string>
+    <string name="digit2">"2"</string>
+    <string name="digit3">"3"</string>
+    <string name="digit4">"4"</string>
+    <string name="digit5">"5"</string>
+    <string name="digit6">"6"</string>
+    <string name="digit7">"7"</string>
+    <string name="digit8">"8"</string>
+    <string name="digit9">"9"</string>
+    <string name="del">"削除"</string>
+    <string name="clear">"CLEAR"</string>
+    <string name="sin">"sin"</string>
+    <string name="cos">"cos"</string>
+    <string name="tan">"tan"</string>
+    <string name="e">"e"</string>
+    <string name="ln">"ln"</string>
+    <string name="lg">"log"</string>
+    <string name="leftParen">"("</string>
+    <string name="rightParen">")"</string>
+    <string name="basic">"標準機能"</string>
+    <string name="advanced">"関数機能"</string>
+    <string name="clear_history">"履歴消去"</string>
+</resources>
diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml
new file mode 100644
index 0000000..e7e537c
--- /dev/null
+++ b/res/values-ko/strings.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 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"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name">"계산기"</string>
+    <string name="error">"오류"</string>
+    <string name="digit0">"0"</string>
+    <string name="digit1">"1"</string>
+    <string name="digit2">"2"</string>
+    <string name="digit3">"3"</string>
+    <string name="digit4">"4"</string>
+    <string name="digit5">"5"</string>
+    <string name="digit6">"6"</string>
+    <string name="digit7">"7"</string>
+    <string name="digit8">"8"</string>
+    <string name="digit9">"9"</string>
+    <string name="del">"삭제"</string>
+    <string name="clear">"지우기"</string>
+    <string name="sin">"sin"</string>
+    <string name="cos">"cos"</string>
+    <string name="tan">"tan"</string>
+    <string name="e">"e"</string>
+    <string name="ln">"ln"</string>
+    <string name="lg">"log"</string>
+    <string name="leftParen">"("</string>
+    <string name="rightParen">")"</string>
+    <string name="basic">"기본 패널"</string>
+    <string name="advanced">"고급 패널"</string>
+    <string name="clear_history">"기록 지우기"</string>
+</resources>
diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml
new file mode 100644
index 0000000..ff4c824
--- /dev/null
+++ b/res/values-nb/strings.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 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"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name">"Kalkulator"</string>
+    <string name="error">"Feil"</string>
+    <string name="digit0">"0"</string>
+    <string name="digit1">"1"</string>
+    <string name="digit2">"2"</string>
+    <string name="digit3">"3"</string>
+    <string name="digit4">"4"</string>
+    <string name="digit5">"5"</string>
+    <string name="digit6">"6"</string>
+    <string name="digit7">"7"</string>
+    <string name="digit8">"8"</string>
+    <string name="digit9">"9"</string>
+    <string name="del">"SLETT"</string>
+    <string name="clear">"RYDD"</string>
+    <string name="sin">"sin"</string>
+    <string name="cos">"cos"</string>
+    <string name="tan">"tan"</string>
+    <string name="e">"e"</string>
+    <string name="ln">"ln"</string>
+    <string name="lg">"log"</string>
+    <string name="leftParen">"("</string>
+    <string name="rightParen">")"</string>
+    <string name="basic">"Grunnleggende panel"</string>
+    <string name="advanced">"Avansert panel"</string>
+    <string name="clear_history">"Nullstill historie"</string>
+</resources>
diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml
new file mode 100644
index 0000000..7c369aa
--- /dev/null
+++ b/res/values-nl/strings.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 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"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name">"Rekenmachine"</string>
+    <string name="error">"Fout"</string>
+    <string name="digit0">"0"</string>
+    <string name="digit1">"1"</string>
+    <string name="digit2">"2"</string>
+    <string name="digit3">"3"</string>
+    <string name="digit4">"4"</string>
+    <string name="digit5">"5"</string>
+    <string name="digit6">"6"</string>
+    <string name="digit7">"7"</string>
+    <string name="digit8">"8"</string>
+    <string name="digit9">"9"</string>
+    <string name="del">"VERWIJDEREN"</string>
+    <string name="clear">"WISSEN"</string>
+    <string name="sin">"sin"</string>
+    <string name="cos">"cos"</string>
+    <string name="tan">"tan"</string>
+    <string name="e">"e"</string>
+    <string name="ln">"ln"</string>
+    <string name="lg">"log"</string>
+    <string name="leftParen">"("</string>
+    <string name="rightParen">")"</string>
+    <string name="basic">"Basis"</string>
+    <string name="advanced">"Geavanceerd"</string>
+    <string name="clear_history">"Geschiedenis wissen"</string>
+</resources>
diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml
new file mode 100644
index 0000000..bf636c5
--- /dev/null
+++ b/res/values-pl/strings.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 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"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name">"Kalkulator"</string>
+    <string name="error">"Błąd"</string>
+    <string name="digit0">"0"</string>
+    <string name="digit1">"1"</string>
+    <string name="digit2">"2"</string>
+    <string name="digit3">"3"</string>
+    <string name="digit4">"4"</string>
+    <string name="digit5">"5"</string>
+    <string name="digit6">"6"</string>
+    <string name="digit7">"7"</string>
+    <string name="digit8">"8"</string>
+    <string name="digit9">"9"</string>
+    <string name="del">"USUŃ"</string>
+    <string name="clear">"WYCZYŚĆ"</string>
+    <string name="sin">"sin"</string>
+    <string name="cos">"cos"</string>
+    <string name="tan">"tg"</string>
+    <string name="e">"e"</string>
+    <string name="ln">"ln"</string>
+    <string name="lg">"log"</string>
+    <string name="leftParen">"("</string>
+    <string name="rightParen">")"</string>
+    <string name="basic">"Panel podstawowy"</string>
+    <string name="advanced">"Panel zaawansowany"</string>
+    <string name="clear_history">"Wyczyść historię"</string>
+</resources>
diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml
new file mode 100644
index 0000000..9b06fcc
--- /dev/null
+++ b/res/values-ru/strings.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 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"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name">"Калькулятор"</string>
+    <string name="error">"Ошибка"</string>
+    <string name="digit0">"0"</string>
+    <string name="digit1">"1"</string>
+    <string name="digit2">"2"</string>
+    <string name="digit3">"3"</string>
+    <string name="digit4">"4"</string>
+    <string name="digit5">"5"</string>
+    <string name="digit6">"6"</string>
+    <string name="digit7">"7"</string>
+    <string name="digit8">"8"</string>
+    <string name="digit9">"9"</string>
+    <string name="del">"УДАЛИТЬ"</string>
+    <string name="clear">"СБРОС"</string>
+    <string name="sin">"sin"</string>
+    <string name="cos">"cos"</string>
+    <string name="tan">"tan"</string>
+    <string name="e">"e"</string>
+    <string name="ln">"ln"</string>
+    <string name="lg">"log"</string>
+    <string name="leftParen">"("</string>
+    <string name="rightParen">")"</string>
+    <string name="basic">"Основная панель"</string>
+    <string name="advanced">"Расширенная панель"</string>
+    <string name="clear_history">"Очистить историю"</string>
+</resources>
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
new file mode 100644
index 0000000..38431f6
--- /dev/null
+++ b/res/values-zh-rCN/strings.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 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"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name">"计算器"</string>
+    <string name="error">"错误"</string>
+    <string name="digit0">"0"</string>
+    <string name="digit1">"1"</string>
+    <string name="digit2">"2"</string>
+    <string name="digit3">"3"</string>
+    <string name="digit4">"4"</string>
+    <string name="digit5">"5"</string>
+    <string name="digit6">"6"</string>
+    <string name="digit7">"7"</string>
+    <string name="digit8">"8"</string>
+    <string name="digit9">"9"</string>
+    <string name="del">"删除"</string>
+    <string name="clear">"清除"</string>
+    <string name="sin">"sin"</string>
+    <string name="cos">"cos"</string>
+    <string name="tan">"tan"</string>
+    <string name="e">"e"</string>
+    <string name="ln">"ln"</string>
+    <string name="lg">"log"</string>
+    <string name="leftParen">"("</string>
+    <string name="rightParen">")"</string>
+    <string name="basic">"基本面板"</string>
+    <string name="advanced">"高级面板"</string>
+    <string name="clear_history">"清除历史记录"</string>
+</resources>
diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml
new file mode 100644
index 0000000..f0a9646
--- /dev/null
+++ b/res/values-zh-rTW/strings.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 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"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name">"小算盤"</string>
+    <string name="error">"錯誤"</string>
+    <string name="digit0">"0"</string>
+    <string name="digit1">"1"</string>
+    <string name="digit2">"2"</string>
+    <string name="digit3">"3"</string>
+    <string name="digit4">"4"</string>
+    <string name="digit5">"5"</string>
+    <string name="digit6">"6"</string>
+    <string name="digit7">"7"</string>
+    <string name="digit8">"8"</string>
+    <string name="digit9">"9"</string>
+    <string name="del">"刪除"</string>
+    <string name="clear">"清除"</string>
+    <string name="sin">"sin"</string>
+    <string name="cos">"cos"</string>
+    <string name="tan">"tan"</string>
+    <string name="e">"e"</string>
+    <string name="ln">"ln"</string>
+    <string name="lg">"log"</string>
+    <string name="leftParen">"("</string>
+    <string name="rightParen">")"</string>
+    <string name="basic">"基本面板"</string>
+    <string name="advanced">"進階面板"</string>
+    <string name="clear_history">"Clear history"</string>
+</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
new file mode 100644
index 0000000..76f3f13
--- /dev/null
+++ b/res/values/colors.xml
@@ -0,0 +1,20 @@
+<?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">#00ff2222</color>
+    <color name="button_text">#ffffffff</color>
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
new file mode 100644
index 0000000..817dedf
--- /dev/null
+++ b/res/values/strings.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <!-- Application name -->
+    <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">DELETE</string>
+    <!-- Button name on screen to clear the entire calculation field -->
+    <string name="clear">CLEAR</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>
+    <!-- Displayed on buttons on screen for the cos function. -->
+    <string name="cos">cos</string>
+    <!-- Displayed on buttons on screen for the tan function. -->
+    <string name="tan">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>
+    <!-- Displayed on buttons on screen for the ln function. -->
+    <string name="ln">ln</string>
+    <!-- Displayed on buttons on screen for the log function. -->
+    <string name="lg">log</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>
+</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
new file mode 100644
index 0000000..1fc670b
--- /dev/null
+++ b/res/values/styles.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <style name="button_style">
+       <item name="android:textSize">40dp</item>
+       <item name="android:layout_width">fill_parent</item>
+       <item name="android:layout_height">fill_parent</item>
+       <item name="android:layout_weight">1</item>
+       <item name="android:focusable">true</item>
+    </style>
+
+    <style name="button_small_style">
+       <item name="android:textSize">30dp</item>
+       <item name="android:layout_width">fill_parent</item>
+       <item name="android:layout_height">fill_parent</item>
+       <item name="android:layout_weight">1</item>
+       <item name="android:focusable">true</item>
+    </style>
+
+    <style name="display_style">
+       <item name="android:textSize">40dp</item>
+       <item name="android:gravity">right</item>
+       <item name="android:textColor">#f000</item>
+       <item name="android:maxLines">1</item>
+       <item name="android:scrollbars">none</item>
+       <item name="android:scrollHorizontally">true</item>
+       <item name="android:layout_width">fill_parent</item>
+       <item name="android:layout_height">wrap_content</item>
+       <item name="android:padding">8dp</item>
+    </style>
+</resources>
diff --git a/src/com/android/calculator2/Calculator.java b/src/com/android/calculator2/Calculator.java
new file mode 100644
index 0000000..eb7453d
--- /dev/null
+++ b/src/com/android/calculator2/Calculator.java
@@ -0,0 +1,161 @@
+/*
+ * 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.util.Log;
+import android.util.Config;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.Window;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ListView;
+import android.content.res.Configuration;
+
+public class Calculator extends Activity {
+    EventListener mListener = new EventListener();
+    private CalculatorDisplay mDisplay;
+    private Persist mPersist;
+    private History mHistory;
+    private Logic mLogic;
+    private PanelSwitcher mPanelSwitcher;
+
+    private static final int CMD_CLEAR_HISTORY  = 1;
+    private static final int CMD_BASIC_PANEL    = 2;
+    private static final int CMD_ADVANCED_PANEL = 3;
+
+    static final int BASIC_PANEL    = 0;
+    static final int ADVANCED_PANEL = 1;
+
+    private static final String LOG_TAG = "Calculator";
+    private static final boolean DEBUG  = false;
+    private static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV;
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        requestWindowFeature(Window.FEATURE_NO_TITLE);
+        setContentView(R.layout.main);
+
+        mPersist = new Persist(this);
+        mHistory = mPersist.history;
+
+        mDisplay = (CalculatorDisplay) findViewById(R.id.display);
+
+        mLogic = new Logic(this, mHistory, mDisplay, (Button) findViewById(R.id.equal));
+        HistoryAdapter historyAdapter = new HistoryAdapter(this, mHistory, mLogic);
+        mHistory.setObserver(historyAdapter);
+        View view;
+        mPanelSwitcher = (PanelSwitcher) findViewById(R.id.panelswitch);
+                                       
+        mListener.setHandler(mLogic, mPanelSwitcher);
+
+        mDisplay.setOnKeyListener(mListener);
+
+
+        if ((view = findViewById(R.id.del)) != null) {
+            view.setOnClickListener(mListener);
+            view.setOnLongClickListener(mListener);
+        }
+        /*
+        if ((view = findViewById(R.id.clear)) != null) {
+            view.setOnClickListener(mListener);
+        }
+        */
+
+        /*
+        ListView historyPad = (ListView) findViewById(R.id.historyPad);
+        if (historyPad != null) {
+            historyPad.setAdapter(historyAdapter);
+        }
+        */
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        super.onCreateOptionsMenu(menu);
+        MenuItem item;
+        
+        item = menu.add(0, CMD_CLEAR_HISTORY, 0, R.string.clear_history);
+        item.setIcon(R.drawable.clear_history);
+        
+        item = menu.add(0, CMD_ADVANCED_PANEL, 0, R.string.advanced);
+        item.setIcon(R.drawable.advanced);
+        
+        item = menu.add(0, CMD_BASIC_PANEL, 0, R.string.basic);
+        item.setIcon(R.drawable.simple);
+
+        return true;
+    }
+    
+    @Override
+    public boolean onPrepareOptionsMenu(Menu menu) {
+        super.onPrepareOptionsMenu(menu);
+        menu.findItem(CMD_BASIC_PANEL).setVisible(mPanelSwitcher != null && 
+                          mPanelSwitcher.getCurrentIndex() == ADVANCED_PANEL);
+        
+        menu.findItem(CMD_ADVANCED_PANEL).setVisible(mPanelSwitcher != null && 
+                          mPanelSwitcher.getCurrentIndex() == BASIC_PANEL);
+        
+        return true;
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        switch (item.getItemId()) {
+        case CMD_CLEAR_HISTORY:
+            mHistory.clear();
+            break;
+
+        case CMD_BASIC_PANEL:
+            if (mPanelSwitcher != null && 
+                mPanelSwitcher.getCurrentIndex() == ADVANCED_PANEL) {
+                mPanelSwitcher.moveRight();
+            }
+            break;
+
+        case CMD_ADVANCED_PANEL:
+            if (mPanelSwitcher != null && 
+                mPanelSwitcher.getCurrentIndex() == BASIC_PANEL) {
+                mPanelSwitcher.moveLeft();
+            }
+            break;
+        }
+        return super.onOptionsItemSelected(item);
+    }
+
+    @Override
+    protected void onSaveInstanceState(Bundle icicle) {
+        // as work-around for ClassCastException in TextView on restart
+        // avoid calling superclass, to keep icicle empty
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+        mLogic.updateHistory();
+        mPersist.save();
+    }
+
+    static void log(String message) {
+        if (LOG_ENABLED) {
+            Log.v(LOG_TAG, message);
+        }
+    }
+}
diff --git a/src/com/android/calculator2/CalculatorDisplay.java b/src/com/android/calculator2/CalculatorDisplay.java
new file mode 100644
index 0000000..5e0d76f
--- /dev/null
+++ b/src/com/android/calculator2/CalculatorDisplay.java
@@ -0,0 +1,157 @@
+/*
+ * 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.text.Editable;
+import android.text.Spanned;
+import android.text.method.NumberKeyListener;
+import android.util.AttributeSet;
+import android.view.KeyEvent;
+import android.view.animation.TranslateAnimation;
+import android.text.InputType;
+import android.widget.EditText;
+import android.widget.ViewSwitcher;
+import android.graphics.Rect;
+
+import java.util.Map;
+
+/**
+ * Provides vertical scrolling for the input/result EditText.
+ */
+class CalculatorDisplay extends ViewSwitcher {
+    // 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;
+    
+    public CalculatorDisplay(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+    
+    protected void setLogic(Logic logic) {
+        NumberKeyListener calculatorKeyListener =
+            new NumberKeyListener() {
+                public int getInputType() {
+                    // Don't display soft keyboard.
+                    return InputType.TYPE_NULL;
+                }
+            
+                protected char[] getAcceptedChars() {
+                    return ACCEPTED_CHARS;
+                }
+
+                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.setBackgroundDrawable(null);
+            text.setEditableFactory(factory);
+            text.setKeyListener(calculatorKeyListener);
+        }
+    }
+
+    @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);
+    }
+
+    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();
+    }
+    
+    void setSelection(int i) {
+        EditText text = (EditText) getCurrentView();
+        text.setSelection(i);
+    }
+    
+    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/CalculatorEditable.java b/src/com/android/calculator2/CalculatorEditable.java
new file mode 100644
index 0000000..60ba817
--- /dev/null
+++ b/src/com/android/calculator2/CalculatorEditable.java
@@ -0,0 +1,110 @@
+/*
+ * 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]);
+        }
+
+        int length = delta.length();
+        if (length == 1) {
+            char text = delta.charAt(0);
+
+            //don't allow leading operator + * /
+            if (start == 0 && Logic.isOperator(text) && text != Logic.MINUS) {
+                return super.replace(start, end, "");
+            }
+
+            //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';
+                }
+            }
+        } 
+        return super.replace(start, end, delta);
+    }
+
+    public static class Factory extends Editable.Factory {
+        private Logic mLogic;
+
+        public Factory(Logic logic) {
+            mLogic = logic;
+        }
+
+        public Editable newEditable(CharSequence source) {
+            return new CalculatorEditable(source, mLogic);
+        }
+    }
+}
diff --git a/src/com/android/calculator2/ColorButton.java b/src/com/android/calculator2/ColorButton.java
new file mode 100644
index 0000000..5d78446
--- /dev/null
+++ b/src/com/android/calculator2/ColorButton.java
@@ -0,0 +1,147 @@
+/*
+ * 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.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.widget.Button;
+import android.view.View.OnClickListener;
+import android.view.View;
+import android.view.MotionEvent;
+import android.content.res.Resources;
+
+import java.util.Map;
+
+/**
+ * Button with click-animation effect.
+ */
+class ColorButton extends Button implements OnClickListener {
+    int CLICK_FEEDBACK_COLOR;
+    static final int CLICK_FEEDBACK_INTERVAL = 10;
+    static final int CLICK_FEEDBACK_DURATION = 350;
+    
+    Drawable mButtonBackground;
+    Drawable mButton;
+    float mTextX;
+    float mTextY;
+    long mAnimStart;
+    OnClickListener mListener;
+    
+    public ColorButton(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        init();
+        mListener = ((Calculator) context).mListener;
+        setOnClickListener(this);
+    }
+
+    public void onClick(View view) {
+        animateClickFeedback();
+        mListener.onClick(this);
+    }
+
+    private void init() {
+        setBackgroundDrawable(null);
+
+        Resources res = getResources();
+
+        mButtonBackground = res.getDrawable(R.drawable.button_bg);
+        mButton = res.getDrawable(R.drawable.button);
+        CLICK_FEEDBACK_COLOR = res.getColor(R.color.magic_flame);
+        getPaint().setColor(res.getColor(R.color.button_text));
+        
+        mAnimStart = -1;
+    }
+
+
+    @Override 
+    public void onSizeChanged(int w, int h, int oldW, int oldH) {
+        int selfW = mButton.getIntrinsicWidth();
+        int selfH = mButton.getIntrinsicHeight();
+        int marginX = (w - selfW) / 2;
+        int marginY = (h - selfH) / 2;
+        mButtonBackground.setBounds(marginX, marginY, marginX + selfW, marginY + selfH);
+        mButton.setBounds(marginX, marginY, marginX + selfW, marginY + selfH);
+        measureText();
+    }
+
+    private void measureText() {
+        Paint paint = getPaint();
+        mTextX = (getWidth() - paint.measureText(getText().toString())) / 2;
+        mTextY = (getHeight() - paint.ascent() - paint.descent()) / 2;
+    }
+
+    @Override
+    protected void onTextChanged(CharSequence text, int start, int before, int after) {
+        measureText();
+    }
+
+    private void drawMagicFlame(int duration, Canvas canvas) {
+        int alpha = 255 - 255 * duration / CLICK_FEEDBACK_DURATION;
+        int color = CLICK_FEEDBACK_COLOR | (alpha << 24);
+        mButtonBackground.setColorFilter(color, PorterDuff.Mode.SRC_IN);
+        
+        int cx = getWidth() / 2;
+        int cy = getHeight() / 2;
+        float angle = 250.0f * duration / CLICK_FEEDBACK_DURATION;
+        canvas.rotate(angle, cx, cy);
+        mButtonBackground.draw(canvas);
+        canvas.rotate(-angle, cx, cy);
+    }
+
+    @Override
+    public void onDraw(Canvas canvas) {
+        if (mAnimStart != -1) {
+            int animDuration = (int) (System.currentTimeMillis() - mAnimStart);
+            
+            if (animDuration >= CLICK_FEEDBACK_DURATION) {
+                mButtonBackground.clearColorFilter();
+                mAnimStart = -1;
+            } else {
+                drawMagicFlame(animDuration, canvas);
+                postInvalidateDelayed(CLICK_FEEDBACK_INTERVAL);
+            }
+        } else if (isPressed()) {
+            drawMagicFlame(0, canvas);
+        }
+        
+        mButton.draw(canvas);
+        
+        CharSequence text = getText();
+        canvas.drawText(text, 0, text.length(), mTextX, mTextY, getPaint());
+    }
+
+    public void animateClickFeedback() {
+        mAnimStart = System.currentTimeMillis();
+        invalidate();        
+    } 
+    
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        int a = event.getAction();
+        if (a == MotionEvent.ACTION_DOWN 
+                || a == MotionEvent.ACTION_CANCEL
+                || a == MotionEvent.ACTION_UP) {
+            invalidate();
+        }
+        return super.onTouchEvent(event);
+    }
+}
diff --git a/src/com/android/calculator2/EventListener.java b/src/com/android/calculator2/EventListener.java
new file mode 100644
index 0000000..0274a8b
--- /dev/null
+++ b/src/com/android/calculator2/EventListener.java
@@ -0,0 +1,129 @@
+/*
+ * 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.view.View;
+import android.view.KeyEvent;
+import android.view.View.OnClickListener;
+import android.view.View.OnLongClickListener;
+import android.view.View.OnKeyListener;
+import android.widget.Button;
+
+class EventListener implements View.OnKeyListener, 
+                               View.OnClickListener, 
+                               View.OnLongClickListener {
+    Logic mHandler;
+    PanelSwitcher mPanelSwitcher;
+    
+    void setHandler(Logic handler, PanelSwitcher panelSwitcher) {
+        mHandler = handler;
+        mPanelSwitcher = panelSwitcher;
+    }
+    
+    //@Override
+    public void onClick(View view) {
+        int id = view.getId();
+        switch (id) {
+        case R.id.del:
+            mHandler.onDelete();
+            break;
+
+        case R.id.equal:
+            mHandler.onEnter();
+            break;
+
+            /*
+        case R.id.clear:
+            mHandler.onClear();
+            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.insert(text);
+                if (mPanelSwitcher != null && 
+                    mPanelSwitcher.getCurrentIndex() == Calculator.ADVANCED_PANEL) {
+                    mPanelSwitcher.moveRight();
+                }                    
+            }
+        }
+    }
+
+    //@Override
+    public boolean onLongClick(View view) {
+        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) {
+        int action = keyEvent.getAction();
+        
+        if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT ||
+            keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
+            boolean eat = mHandler.eatHorizontalMove(keyCode == KeyEvent.KEYCODE_DPAD_LEFT);
+            return eat;
+        }
+
+        //Work-around for spurious key event from IME, bug #1639445
+        if (action == KeyEvent.ACTION_MULTIPLE && keyCode == KeyEvent.KEYCODE_UNKNOWN) {
+            return true; // eat it
+        }
+
+        //Calculator.log("KEY " + keyCode + "; " + action);
+        if (keyCode != KeyEvent.KEYCODE_DPAD_CENTER &&
+            keyCode != KeyEvent.KEYCODE_DPAD_UP &&
+            keyCode != KeyEvent.KEYCODE_DPAD_DOWN &&
+            keyCode != KeyEvent.KEYCODE_ENTER) {
+            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
new file mode 100644
index 0000000..ff2cc65
--- /dev/null
+++ b/src/com/android/calculator2/History.java
@@ -0,0 +1,118 @@
+/*
+ * 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;
+    Vector<HistoryEntry> mEntries = new Vector<HistoryEntry>();
+    int mPos;
+    BaseAdapter mObserver;
+
+    History() {
+        clear();
+    }
+
+    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);
+        }
+    }
+
+    void setObserver(BaseAdapter observer) {
+        mObserver = observer;
+    }
+
+    private void notifyChanged() {
+        if (mObserver != null) {
+            mObserver.notifyDataSetChanged();
+        }
+    }
+
+    void clear() {
+        mEntries.clear();
+        mEntries.add(new HistoryEntry(""));
+        mPos = 0;
+        notifyChanged();
+    }
+
+    void write(DataOutput out) throws IOException {
+        out.writeInt(mEntries.size());
+        for (HistoryEntry entry : mEntries) {
+            entry.write(out);
+        }
+        out.writeInt(mPos);
+    }
+
+    void update(String text) {
+        current().setEdited(text);
+    }
+
+    boolean moveToPrevious() {
+        if (mPos > 0) {
+            --mPos;
+            return true;
+        }
+        return false;
+    }
+
+    boolean moveToNext() {
+        if (mPos < mEntries.size() - 1) {
+            ++mPos;
+            return true;
+        }
+        return false;
+    }
+
+    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();
+    }
+
+    HistoryEntry current() {
+        return mEntries.elementAt(mPos);
+    }
+
+    String getText() {
+        return current().getEdited();
+    }
+
+    String getBase() {
+        return current().getBase();
+    }
+}
diff --git a/src/com/android/calculator2/HistoryAdapter.java b/src/com/android/calculator2/HistoryAdapter.java
new file mode 100644
index 0000000..02ceeee
--- /dev/null
+++ b/src/com/android/calculator2/HistoryAdapter.java
@@ -0,0 +1,87 @@
+/*
+ * 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.view.LayoutInflater;
+import android.view.ViewGroup;
+import android.view.View;
+import android.content.Context;
+import android.widget.BaseAdapter;
+import android.widget.TextView;
+
+import java.util.Vector;
+
+import org.javia.arity.SyntaxException;
+
+class HistoryAdapter extends BaseAdapter {
+    private Vector<HistoryEntry> mEntries;
+    private LayoutInflater mInflater;
+    private Logic mEval;
+    
+    HistoryAdapter(Context context, History history, Logic evaluator) {
+        mEntries = history.mEntries;
+        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) {
+        View view;
+        if (convertView == null) {
+            view = mInflater.inflate(R.layout.history_item, parent, false);
+        } else {
+            view = convertView;
+        }
+
+        TextView expr   = (TextView) view.findViewById(R.id.historyExpr);
+        TextView result = (TextView) view.findViewById(R.id.historyResult);
+
+        HistoryEntry entry = mEntries.elementAt(position);
+        String base = entry.getBase();
+        expr.setText(entry.getBase());
+
+        try {
+            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
new file mode 100644
index 0000000..80319d8
--- /dev/null
+++ b/src/com/android/calculator2/HistoryEntry.java
@@ -0,0 +1,69 @@
+/*
+ * 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
new file mode 100644
index 0000000..244f438
--- /dev/null
+++ b/src/com/android/calculator2/Logic.java
@@ -0,0 +1,208 @@
+/*
+ * 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.view.View;
+import android.view.KeyEvent;
+import android.widget.Button;
+import android.widget.EditText;
+import android.content.Context;
+import android.content.res.Configuration;
+
+import org.javia.arity.Symbols;
+import org.javia.arity.SyntaxException;
+import org.javia.arity.Util;
+
+class Logic {
+    private CalculatorDisplay mDisplay;
+    private Symbols mSymbols = new Symbols();
+    private History mHistory;
+    private String  mResult = "";
+    private Button mEqualButton;
+    private final String mEnterString;
+    private boolean mIsError = false;
+    private final boolean mOrientationPortrait;
+    private final int mLineLength;
+
+    private static final int LINE_LENGTH_PORTRAIT = 14;
+    private static final int LINE_LENGTH_LANDSCAPE = 21;
+    private static final String INFINITY_UNICODE = "\u221e";
+
+    // 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;
+
+    Logic(Context context, History history, CalculatorDisplay display, Button equalButton) {
+        mErrorString = context.getResources().getString(R.string.error);
+        mOrientationPortrait = context.getResources().getConfiguration().orientation
+            == Configuration.ORIENTATION_PORTRAIT;
+        mLineLength = mOrientationPortrait ? LINE_LENGTH_PORTRAIT : LINE_LENGTH_LANDSCAPE;
+
+        try {
+            // in calculator we use log() for base-10,
+            // unlike in arity-lib where log() is natural logarithm
+            mSymbols.define(mSymbols.compileWithName("log(x)=log10(x)"));
+        } catch (SyntaxException e) {
+            throw new Error("" + e); //never
+        }
+        mHistory = history;
+        mDisplay = display;
+        mDisplay.setLogic(this);
+        mEqualButton = equalButton;
+        mEnterString = context.getText(R.string.enter).toString();
+
+        clearWithHistory(false);
+    }
+
+    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);
+    }
+
+    private void setText(CharSequence text) {
+        mDisplay.setText(text, CalculatorDisplay.Scroll.UP);
+    }
+
+    private void clearWithHistory(boolean scroll) {
+        mDisplay.setText(mHistory.getText(), 
+                         scroll ? CalculatorDisplay.Scroll.UP : CalculatorDisplay.Scroll.NONE);
+        mResult = "";
+        mIsError = false;
+    }
+
+    private void clear(boolean scroll) {
+        mDisplay.setText("", scroll ? CalculatorDisplay.Scroll.UP : CalculatorDisplay.Scroll.NONE);
+        cleared();
+    }
+
+    void cleared() {
+        mResult = "";
+        mIsError = false;
+        updateHistory();
+    }
+
+    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(false);
+    }
+
+    void onEnter() {
+        String text = getText();
+        if (text.equals(mResult)) {
+            clearWithHistory(false); //clear after an Enter on result
+        } else {
+            mHistory.enter(text);
+            try {
+                mResult = evaluate(text);
+            } catch (SyntaxException e) {
+                mIsError = true;
+                mResult = mErrorString;
+            }
+            if (text.equals(mResult)) {
+                //no need to show result, it is exactly what the user entered
+                clearWithHistory(true);
+            } else {
+                setText(mResult);
+                //mEqualButton.setText(mEnterString);
+            }
+        }
+    }
+
+    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() {
+        mHistory.update(getText());
+    }
+
+    private static final int ROUND_DIGITS = 1;
+    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;
+        }
+
+        String result = Util.doubleToString(mSymbols.eval(input), mLineLength, ROUND_DIGITS);
+        if (result.equals(NAN)) { // treat NaN as Error
+            mIsError = true;
+            return mErrorString;
+        }
+        return result.replace('-', MINUS).replace(INFINITY, INFINITY_UNICODE);
+    }
+
+    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/PanelSwitcher.java b/src/com/android/calculator2/PanelSwitcher.java
new file mode 100644
index 0000000..c64022c
--- /dev/null
+++ b/src/com/android/calculator2/PanelSwitcher.java
@@ -0,0 +1,140 @@
+/*
+ * 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.view.animation.TranslateAnimation;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.GestureDetector;
+import android.widget.FrameLayout;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.os.Handler;
+
+import java.util.Map;
+
+class PanelSwitcher extends FrameLayout {
+    private static final int MAJOR_MOVE = 60;
+    private static final int ANIM_DURATION = 400;
+
+    private GestureDetector mGestureDetector;
+    private int mCurrentView;
+    private View mChild, mHistoryView;
+    private View children[];
+
+    private int mWidth;
+    private TranslateAnimation inLeft;
+    private TranslateAnimation outLeft;
+
+    private TranslateAnimation inRight;
+    private TranslateAnimation outRight;
+
+    private static final int NONE  = 1;
+    private static final int LEFT  = 2;
+    private static final int RIGHT = 3;
+    private int mPreviousMove;
+
+    public PanelSwitcher(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        mCurrentView = 0;
+        mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
+                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;
+                    }
+                }
+            });
+    }
+
+    @Override 
+    public void onSizeChanged(int w, int h, int oldW, int oldH) {
+        mWidth = w;
+        inLeft   = new TranslateAnimation(mWidth, 0, 0, 0);
+        outLeft  = new TranslateAnimation(0, -mWidth, 0, 0);        
+        inRight  = new TranslateAnimation(-mWidth, 0, 0, 0);
+        outRight = new TranslateAnimation(0, mWidth, 0, 0);
+
+        inLeft.setDuration(ANIM_DURATION);
+        outLeft.setDuration(ANIM_DURATION);
+        inRight.setDuration(ANIM_DURATION);
+        outRight.setDuration(ANIM_DURATION);
+    }
+
+    protected void onFinishInflate() {
+        int count = getChildCount();
+        children = new View[count];
+        for (int i = 0; i < count; ++i) {
+            children[i] = getChildAt(i);
+            if (i != mCurrentView) {
+                children[i].setVisibility(View.GONE);
+            }
+        }
+    }
+
+    @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 < children.length - 1 && mPreviousMove != LEFT) {
+            children[mCurrentView+1].setVisibility(View.VISIBLE);
+            children[mCurrentView+1].startAnimation(inLeft);
+            children[mCurrentView].startAnimation(outLeft);
+            children[mCurrentView].setVisibility(View.GONE);
+
+            mCurrentView++;
+            mPreviousMove = LEFT;
+        }
+    }
+
+    void moveRight() {
+        //  -->
+        if (mCurrentView > 0 && mPreviousMove != RIGHT) {
+            children[mCurrentView-1].setVisibility(View.VISIBLE);
+            children[mCurrentView-1].startAnimation(inRight);
+            children[mCurrentView].startAnimation(outRight);
+            children[mCurrentView].setVisibility(View.GONE);
+
+            mCurrentView--;
+            mPreviousMove = RIGHT;
+        }
+    }
+
+    int getCurrentIndex() {
+        return mCurrentView;
+    }
+}
diff --git a/src/com/android/calculator2/Persist.java b/src/com/android/calculator2/Persist.java
new file mode 100644
index 0000000..454f10b
--- /dev/null
+++ b/src/com/android/calculator2/Persist.java
@@ -0,0 +1,70 @@
+/*
+ * 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.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import android.content.Context;
+
+class Persist {
+    private static final int LAST_VERSION = 1;
+    private static final String FILE_NAME = "calculator.data";
+    private Context mContext;
+
+    History history = new History();
+
+    Persist(Context context) {
+        this.mContext = context;
+        load();
+    }
+
+    private void load() {
+        try {
+            InputStream is = new BufferedInputStream(mContext.openFileInput(FILE_NAME), 8192);
+            DataInputStream in = new DataInputStream(is);
+            int version = in.readInt();
+            if (version > LAST_VERSION) {
+                throw new IOException("data version " + version + "; expected " + LAST_VERSION);
+            }
+            history = new History(version, in);
+            in.close();
+        } catch (FileNotFoundException e) {
+            Calculator.log("" + e);
+        } catch (IOException e) {
+            Calculator.log("" + e);
+        }
+    }
+
+    void save() {
+        try {
+            OutputStream os = new BufferedOutputStream(mContext.openFileOutput(FILE_NAME, 0), 8192);
+            DataOutputStream out = new DataOutputStream(os);
+            out.writeInt(LAST_VERSION);
+            history.write(out);
+            out.close();
+        } catch (IOException e) {
+            Calculator.log("" + e);
+        } 
+    }
+}
diff --git a/tests/Android.mk b/tests/Android.mk
new file mode 100644
index 0000000..11455d0
--- /dev/null
+++ b/tests/Android.mk
@@ -0,0 +1,16 @@
+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
new file mode 100644
index 0000000..d8bed49
--- /dev/null
+++ b/tests/AndroidManifest.xml
@@ -0,0 +1,34 @@
+<?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
new file mode 100644
index 0000000..c512edd
--- /dev/null
+++ b/tests/src/com/android/calculator2/CalculatorHitSomeButtons.java
@@ -0,0 +1,140 @@
+/**
+ * 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
new file mode 100644
index 0000000..16c9d36
--- /dev/null
+++ b/tests/src/com/android/calculator2/CalculatorInstrumentationTestRunner.java
@@ -0,0 +1,41 @@
+/**
+ * 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
new file mode 100644
index 0000000..6c84e17
--- /dev/null
+++ b/tests/src/com/android/calculator2/tests/CalculatorLaunchPerformance.java
@@ -0,0 +1,53 @@
+/*
+ * 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);
+    }
+}