summaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorHans Boehm <hboehm@google.com>2015-04-03 18:41:52 -0700
committerHans Boehm <hboehm@google.com>2015-04-15 17:56:33 -0700
commit4a6b7cb235c305761af5d7f40e74d4704e5058c8 (patch)
treef5fd7d4bcc2195643c922519f24385924eb4b807 /res
parentbfe8c22fd15ff965ed97c7245b49565c645c2cee (diff)
downloadandroid_packages_apps_ExactCalculator-4a6b7cb235c305761af5d7f40e74d4704e5058c8.tar.gz
android_packages_apps_ExactCalculator-4a6b7cb235c305761af5d7f40e74d4704e5058c8.tar.bz2
android_packages_apps_ExactCalculator-4a6b7cb235c305761af5d7f40e74d4704e5058c8.zip
Fix UI holes and bugs. Fix eval bugs.
Change layout to make the result display use a fixed font size and limit the number of characters when it appears below the formula. This allows us to always get the proper expansion effect and prevents scrolling from affecting the font size. Add copy support for result display. Add paste support for the formula. Add keyboard input support. Copy/paste can be used to remember old results in the calculator. We save an identifying tag URI in the clip, in addition to text, allowing us to paste old calculator results without precision loss. Copy/paste currently does not rely on selection at all. I had trouble making it work that way in the formula. It's unclear that would be better, since we only allow copy of the entire text and paste at the end. Add a couple of alternate result display options to the overflow menu. (These appear quite useful, were trivial to implement, and give us a better excuse for the overflow menu.) Changed the behavior of the delete key in error state. Changing it to CLEAR seemed unfriendly, since it prevents corrections. This is a change from L. Made it clear that the CalculatorHitSomeButtons test is currently 95% worthless. It was apparentlly failing (due to test infrastructure issues) but throwing an exception in a thread from which it was not getting reported. Decided to keep it, since I would like a place to continue collecting regression tests, even if we can't actually run them yet. Includes some easy drive-by fixes for expression evaluation: a) 2 / 2 * 3 was mis-parsed as 2 / (2 * 3). b) Cosine evaluation had the sense of the test for a rational result reversed. c) Constants without leading digits, like .1, are now handled correctly, and decimal points in the formula are now internationalized. (That's not yet true for the result.) Change-Id: Ic24466b444b4a4633cfb036c67622c7f4fd644ec
Diffstat (limited to 'res')
-rw-r--r--res/layout/display.xml12
-rw-r--r--res/layout/extras.xml6
-rw-r--r--res/menu/copy.xml25
-rw-r--r--res/menu/overflow.xml (renamed from res/menu/menu.xml)6
-rw-r--r--res/menu/paste.xml25
-rw-r--r--res/values-land/styles.xml4
-rw-r--r--res/values-port/styles.xml4
-rw-r--r--res/values-sw600dp-land/styles.xml4
-rw-r--r--res/values-sw600dp-port/styles.xml4
-rw-r--r--res/values-sw800dp-land/styles.xml4
-rw-r--r--res/values-sw800dp-port/styles.xml4
-rw-r--r--res/values/strings.xml12
-rw-r--r--res/values/styles.xml8
13 files changed, 102 insertions, 16 deletions
diff --git a/res/layout/display.xml b/res/layout/display.xml
index 94f7848..b5a5b60 100644
--- a/res/layout/display.xml
+++ b/res/layout/display.xml
@@ -29,16 +29,24 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text|textNoSuggestions"
+ android:textIsSelectable="false"
android:textColor="@color/display_formula_text_color" />
+ <!--
+ We lay the result out to full width, but are careful to use only
+ 2/3 of the space, so that we have room when we expand.
+ -->
+
<com.android.calculator2.CalculatorResult
android:id="@+id/result"
- style="@style/DisplayEditTextStyle.Result"
+ style="@style/DisplayTextStyle.Result"
+ android:layout_alignParentRight="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/formula"
android:inputType="none"
- android:focusable="false"
+ android:clickable="true"
+ android:textIsSelectable="false"
android:textColor="@color/display_result_text_color" />
</RelativeLayout>
diff --git a/res/layout/extras.xml b/res/layout/extras.xml
index 0af0704..713413c 100644
--- a/res/layout/extras.xml
+++ b/res/layout/extras.xml
@@ -18,11 +18,15 @@
<!--
TODO: Use framework Toolbar instead of custom overflow menu.
+ Together with setActionBar, that should also fix the COPY/PASTE
+ ugliness.
+ It is not immediately obvious how to get the layout inside the
+ Toolbar correct.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/display"
+ android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
diff --git a/res/menu/copy.xml b/res/menu/copy.xml
new file mode 100644
index 0000000..5897f88
--- /dev/null
+++ b/res/menu/copy.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright (C) 2011, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item android:id="@+id/menu_copy"
+ android:title="@android:string/copy"/>
+
+</menu>
diff --git a/res/menu/menu.xml b/res/menu/overflow.xml
index 16712ea..af5c7cb 100644
--- a/res/menu/menu.xml
+++ b/res/menu/overflow.xml
@@ -25,4 +25,10 @@
<item android:id="@+id/menu_about"
android:title="@string/about"/>
+ <item android:id="@+id/menu_leading"
+ android:title="@string/leading"/>
+
+ <item android:id="@+id/menu_fraction"
+ android:title="@string/fraction"/>
+
</menu>
diff --git a/res/menu/paste.xml b/res/menu/paste.xml
new file mode 100644
index 0000000..964be0d
--- /dev/null
+++ b/res/menu/paste.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright (C) 2011, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item android:id="@+id/menu_paste"
+ android:title="@android:string/paste"/>
+
+</menu>
diff --git a/res/values-land/styles.xml b/res/values-land/styles.xml
index ac8a566..cc8e64c 100644
--- a/res/values-land/styles.xml
+++ b/res/values-land/styles.xml
@@ -26,12 +26,12 @@
<item name="android:textSize">30sp</item>
</style>
- <style name="DisplayEditTextStyle.Result">
+ <style name="DisplayTextStyle.Result">
<item name="android:paddingTop">8dip</item>
<item name="android:paddingBottom">24dip</item>
<item name="android:paddingStart">16dip</item>
<item name="android:paddingEnd">16dip</item>
- <item name="android:textSize">30sp</item>
+ <item name="android:textSize">28sp</item>
</style>
<style name="PadButtonStyle.Advanced">
diff --git a/res/values-port/styles.xml b/res/values-port/styles.xml
index ff6e303..348333f 100644
--- a/res/values-port/styles.xml
+++ b/res/values-port/styles.xml
@@ -28,12 +28,12 @@
<item name="stepTextSize">8sp</item>
</style>
- <style name="DisplayEditTextStyle.Result">
+ <style name="DisplayTextStyle.Result">
<item name="android:paddingTop">24dip</item>
<item name="android:paddingBottom">48dip</item>
<item name="android:paddingStart">16dip</item>
<item name="android:paddingEnd">16dip</item>
- <item name="android:textSize">36sp</item>
+ <item name="android:textSize">28sp</item>
</style>
<style name="PadButtonStyle.Advanced">
diff --git a/res/values-sw600dp-land/styles.xml b/res/values-sw600dp-land/styles.xml
index 050695d..21bdd90 100644
--- a/res/values-sw600dp-land/styles.xml
+++ b/res/values-sw600dp-land/styles.xml
@@ -26,12 +26,12 @@
<item name="android:textSize">48sp</item>
</style>
- <style name="DisplayEditTextStyle.Result">
+ <style name="DisplayTextStyle.Result">
<item name="android:paddingTop">26dip</item>
<item name="android:paddingBottom">46dip</item>
<item name="android:paddingStart">44dip</item>
<item name="android:paddingEnd">44dip</item>
- <item name="android:textSize">48sp</item>
+ <item name="android:textSize">36sp</item>
</style>
<style name="PadButtonStyle.Advanced">
diff --git a/res/values-sw600dp-port/styles.xml b/res/values-sw600dp-port/styles.xml
index 31f87c3..251c734 100644
--- a/res/values-sw600dp-port/styles.xml
+++ b/res/values-sw600dp-port/styles.xml
@@ -29,12 +29,12 @@
<item name="stepTextSize">8sp</item>
</style>
- <style name="DisplayEditTextStyle.Result">
+ <style name="DisplayTextStyle.Result">
<item name="android:paddingTop">32dip</item>
<item name="android:paddingBottom">90dip</item>
<item name="android:paddingStart">44dip</item>
<item name="android:paddingEnd">44dip</item>
- <item name="android:textSize">48sp</item>
+ <item name="android:textSize">36sp</item>
</style>
<style name="PadButtonStyle.Advanced">
diff --git a/res/values-sw800dp-land/styles.xml b/res/values-sw800dp-land/styles.xml
index e6d06b4..c88136d 100644
--- a/res/values-sw800dp-land/styles.xml
+++ b/res/values-sw800dp-land/styles.xml
@@ -28,12 +28,12 @@
<item name="stepTextSize">8sp</item>
</style>
- <style name="DisplayEditTextStyle.Result">
+ <style name="DisplayTextStyle.Result">
<item name="android:paddingTop">26dip</item>
<item name="android:paddingBottom">46dip</item>
<item name="android:paddingStart">44dip</item>
<item name="android:paddingEnd">44dip</item>
- <item name="android:textSize">56sp</item>
+ <item name="android:textSize">40sp</item>
</style>
<style name="PadButtonStyle.Advanced">
diff --git a/res/values-sw800dp-port/styles.xml b/res/values-sw800dp-port/styles.xml
index 6ed3886..3aec308 100644
--- a/res/values-sw800dp-port/styles.xml
+++ b/res/values-sw800dp-port/styles.xml
@@ -28,12 +28,12 @@
<item name="stepTextSize">8sp</item>
</style>
- <style name="DisplayEditTextStyle.Result">
+ <style name="DisplayTextStyle.Result">
<item name="android:paddingTop">32dip</item>
<item name="android:paddingBottom">90dip</item>
<item name="android:paddingStart">44dip</item>
<item name="android:paddingEnd">44dip</item>
- <item name="android:textSize">56sp</item>
+ <item name="android:textSize">40sp</item>
</style>
<style name="PadButtonStyle.Advanced">
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9b018da..2b621bb 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -141,6 +141,8 @@
<string name="desc_del">delete</string>
<!-- Content description for '=' button. [CHAR_LIMIT=NONE] -->
<string name="desc_eq">equals</string>
+ <!-- Toast shown when text is copied to the clipboard. -->
+ <string name="text_copied_toast">Text copied.</string>
<!-- TODO: Revisit everything below here -->
<!-- Displayed briefly to indicate not-yet-computed digit. -->
@@ -158,10 +160,18 @@
<!-- Content description for overflow menu button. -->
<string name="overflow_menu_description">overflow menu</string>
<!-- The help message that's displayed in response to pushing the above button. -->
- <string name="help_message">Use the keys to enter a standard arithmetic expression. It\'s fine to omit multiplication symbols and trailing parentheses. The result displayed after hitting = is computed to an error of less than one in the last displayed digit. Drag the display to see more digits.\n\nComputations involving infinite values may take forever. Touch a button to terminate computation or wait for the timeout.</string>
+ <string name="help_message">Use the keys to enter a standard arithmetic expression. It\'s fine to omit multiplication symbols and trailing parentheses. Long press delete key to clear. Drag the display to see more digits.\n\nComputations involving infinite values may take forever. Wait for the timeout or touch a button to terminate computation.</string>
<!-- Help message addendum for pager. -->
<string name="help_pager">\n\nSwipe the keyboard to the left to see additional functions.</string>
<!-- About menu entry; leads mostly to (English language!) copyright notice. -->
<string name="about">About &amp; Copyright</string>
+ <!-- Overflow menu entry to display result including leading digits. -->
+ <string name="leading">Answer with leading digits</string>
+ <!-- Overflow menu entry to display result as fraction. -->
+ <string name="fraction">Answer as fraction</string>
+ <!-- Appended indicator (for "leading" display) that result is exact. -->
+ <string name="exact">(exact)</string>
+ <!-- Indicator (for "leading" display) that result is inexact. -->
+ <string name="approximate">(±1 in last digit)</string>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 1732b73..843bf2d 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -32,6 +32,14 @@
<item name="android:gravity">bottom|end</item>
</style>
+ <style name="DisplayTextStyle" parent="@android:style/Widget.Material.Light.TextView">
+ <item name="android:background">@android:color/transparent</item>
+ <item name="android:cursorVisible">false</item>
+ <item name="android:fontFamily">sans-serif-light</item>
+ <item name="android:includeFontPadding">false</item>
+ <item name="android:gravity">bottom|end</item>
+ </style>
+
<style name="PadButtonStyle" parent="@android:style/Widget.Material.Light.Button.Borderless">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>