Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

auto import from //depot/cupcake/@135843

  • Loading branch information...
commit b301ed2e1720fc9190eaf99ab33b5f49eabcebc5 1 parent 852aa32
The Android Open Source Project authored
Showing with 3,216 additions and 0 deletions.
  1. +36 −0 Android.mk
  2. +13 −0 AndroidManifest.xml
  3. 0  MODULE_LICENSE_APACHE2
  4. +190 −0 NOTICE
  5. BIN  arity-1.3.1.jar
  6. BIN  res/drawable/advanced.png
  7. BIN  res/drawable/button.png
  8. BIN  res/drawable/button_bg.png
  9. BIN  res/drawable/clear_history.png
  10. BIN  res/drawable/icon.png
  11. BIN  res/drawable/lcd.9.png
  12. BIN  res/drawable/simple.png
  13. BIN  res/drawable/small_button.9.png
  14. BIN  res/drawable/small_button_pressed.9.png
  15. +4 −0 res/drawable/small_button_stateful.xml
  16. +26 −0 res/layout-land/history_item.xml
  17. +257 −0 res/layout-land/main.xml
  18. +26 −0 res/layout-port/history_item.xml
  19. +299 −0 res/layout-port/main.xml
  20. +43 −0 res/values-cs/strings.xml
  21. +43 −0 res/values-de/strings.xml
  22. +43 −0 res/values-es/strings.xml
  23. +43 −0 res/values-fr/strings.xml
  24. +43 −0 res/values-it/strings.xml
  25. +43 −0 res/values-ja/strings.xml
  26. +43 −0 res/values-ko/strings.xml
  27. +43 −0 res/values-nb/strings.xml
  28. +43 −0 res/values-nl/strings.xml
  29. +43 −0 res/values-pl/strings.xml
  30. +43 −0 res/values-ru/strings.xml
  31. +43 −0 res/values-zh-rCN/strings.xml
  32. +43 −0 res/values-zh-rTW/strings.xml
  33. +20 −0 res/values/colors.xml
  34. +76 −0 res/values/strings.xml
  35. +30 −0 res/values/styles.xml
  36. +161 −0 src/com/android/calculator2/Calculator.java
  37. +157 −0 src/com/android/calculator2/CalculatorDisplay.java
  38. +110 −0 src/com/android/calculator2/CalculatorEditable.java
  39. +147 −0 src/com/android/calculator2/ColorButton.java
  40. +129 −0 src/com/android/calculator2/EventListener.java
  41. +118 −0 src/com/android/calculator2/History.java
  42. +87 −0 src/com/android/calculator2/HistoryAdapter.java
  43. +69 −0 src/com/android/calculator2/HistoryEntry.java
  44. +208 −0 src/com/android/calculator2/Logic.java
  45. +140 −0 src/com/android/calculator2/PanelSwitcher.java
  46. +70 −0 src/com/android/calculator2/Persist.java
  47. +16 −0 tests/Android.mk
  48. +34 −0 tests/AndroidManifest.xml
  49. +140 −0 tests/src/com/android/calculator2/CalculatorHitSomeButtons.java
  50. +41 −0 tests/src/com/android/calculator2/CalculatorInstrumentationTestRunner.java
  51. +53 −0 tests/src/com/android/calculator2/tests/CalculatorLaunchPerformance.java
View
36 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))
View
13 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>
View
0  MODULE_LICENSE_APACHE2
No changes.
View
190 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
+
View
BIN  arity-1.3.1.jar
Binary file not shown
View
BIN  res/drawable/advanced.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  res/drawable/button.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  res/drawable/button_bg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  res/drawable/clear_history.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  res/drawable/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  res/drawable/lcd.9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  res/drawable/simple.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  res/drawable/small_button.9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  res/drawable/small_button_pressed.9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
4 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>
View
26 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>
View
257 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>
View
26 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>
View
299 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>
View
43 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>
View
43 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>
View
43 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>
View
43 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>
View
43 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>
View
43 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>
View
43 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>
View
43 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>
View
43 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>
View
43 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>
View
43 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>
View
43 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>
View
43 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>
View
20 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>
View
76 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>
View
30 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>
View
161 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);
+ }
+ }
+}
View
157 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();
+ }
+ }
+}
View
110 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);
+ }
+ }
+}
View
147 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;