summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Klaassen <justinklaassen@google.com>2015-05-05 12:59:36 -0700
committerJustin Klaassen <justinklaassen@google.com>2015-05-05 12:59:36 -0700
commitd36d63e0b261d896e5bcfdab09e3aecb7e4d086c (patch)
treef1beb58e4feb416156707aa016de950b19ffb628
parented9e67864d9d54ed58ddb339a15115250d48bd30 (diff)
downloadandroid_packages_apps_ExactCalculator-d36d63e0b261d896e5bcfdab09e3aecb7e4d086c.tar.gz
android_packages_apps_ExactCalculator-d36d63e0b261d896e5bcfdab09e3aecb7e4d086c.tar.bz2
android_packages_apps_ExactCalculator-d36d63e0b261d896e5bcfdab09e3aecb7e4d086c.zip
Cleanup options menu and licenses UI
Bug: 20503109 - Open source licenses are now displayed as a standalone Licenses activity. - Show/hide result options instead of enabling/disabling them. Change-Id: I7e1e43ac83d2417b2f59f90e6a1fc3e491c6ddc7
-rw-r--r--AndroidManifest.xml11
-rw-r--r--assets/licenses.html (renamed from assets/about.txt)22
-rw-r--r--res/menu/activity_calculator.xml29
-rw-r--r--res/menu/overflow.xml34
-rw-r--r--res/values/strings.xml21
-rw-r--r--res/values/styles.xml13
-rw-r--r--src/com/android/calculator2/Calculator.java62
-rw-r--r--src/com/android/calculator2/Licenses.java20
8 files changed, 106 insertions, 106 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 3a03059..4f90e22 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -20,14 +20,14 @@
package="com.android.calculator2">
<application
+ android:allowBackup="false"
android:icon="@mipmap/ic_launcher_calculator"
- android:label="@string/app_name"
- android:theme="@style/CalculatorTheme">
+ android:label="@string/app_name">
<activity
android:name=".Calculator"
android:label="@string/app_name"
- android:windowSoftInputMode="stateAlwaysHidden">
+ android:theme="@style/Theme.Calculator">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@@ -35,6 +35,11 @@
</intent-filter>
</activity>
+ <activity
+ android:name=".Licenses"
+ android:parentActivityName=".Calculator"
+ android:theme="@style/Theme.Licenses" />
+
</application>
</manifest>
diff --git a/assets/about.txt b/assets/licenses.html
index 89ad1ad..4583bf7 100644
--- a/assets/about.txt
+++ b/assets/licenses.html
@@ -1,9 +1,14 @@
-The calculator uses a software implementation of arithmetic remembers how each number was computed, and always knows how to evaluate each intermediate result to any given precision. Numbers are reevaluated as you scroll.
-
-The underlying open source library was previously distributed as part of the "CRCalc" calculator. The version distributed here was very slightly modified.
-
-The library and its original test code is distributed under the following open source license:
-
+<html>
+<head>
+<meta name="viewport" content="width=device-width">
+<style> body { font-family: sans-serif; } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-wrap: break-word; } </style>
+</head>
+<body>
+<h3>Notices for files:</h3>
+<ul>
+<li>CRCalc</li>
+</ul>
+<pre>
Copyright (c) 1999, Silicon Graphics, Inc. -- ALL RIGHTS RESERVED
Permission is granted free of charge to copy, modify, use and distribute this software provided you include the entirety of this notice in all copies made.
@@ -21,5 +26,6 @@ Permission is granted free of charge to copy, modify, use and distribute this so
THIS SOFTWARE IS PROVIDED ON AN AS IS BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE SUBJECT SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. HEWLETT-PACKARD ASSUMES NO RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE. SHOULD THE SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, HEWLETT-PACKARD ASSUMES NO COST OR LIABILITY FOR ANY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY SUBJECT SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE OR STRICT LIABILITY), CONTRACT, OR OTHERWISE, SHALL HEWLETT-PACKARD BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER WITH RESPECT TO THE SOFTWARE INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, LOSS OF DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF HEWLETT-PACKARD SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY RESULTING FROM HEWLETT-PACKARD's NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THAT EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
-
-
+</pre>
+</body>
+</html>
diff --git a/res/menu/activity_calculator.xml b/res/menu/activity_calculator.xml
new file mode 100644
index 0000000..8d086d1
--- /dev/null
+++ b/res/menu/activity_calculator.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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_leading"
+ android:title="@string/menu_leading" />
+
+ <item android:id="@+id/menu_fraction"
+ android:title="@string/menu_fraction" />
+
+ <item android:id="@+id/menu_licenses"
+ android:title="@string/menu_licenses" />
+
+</menu>
diff --git a/res/menu/overflow.xml b/res/menu/overflow.xml
deleted file mode 100644
index d35832d..0000000
--- a/res/menu/overflow.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
- * Copyright (C) 2011, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
-
- <item android:id="@+id/menu_leading"
- android:title="@string/leading"/>
-
- <item android:id="@+id/menu_fraction"
- android:title="@string/fraction"/>
-
- <item android:id="@+id/menu_help"
- android:title="@string/help"/>
-
- <item android:id="@+id/menu_about"
- android:title="@string/about"/>
-
-</menu>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2c58db5..26161a2 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -154,23 +154,16 @@
<string name="timeout">That\'s too hard! Undefined or infinite value?</string>
<!-- Button label for "remove timeout" button. -->
<string name="ok_remove_timeout">OK, but longer timeouts, please!</string>
- <!-- Help menu entry for context menu. -->
- <string name="help">Help</string>
- <!-- 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. 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 operator pad 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>
+ <!-- Menu option to display result including leading digits. [CHAR_LIMIT=16] -->
+ <string name="menu_leading">Answer with leading digits</string>
+ <!-- Menu option to display result as fraction. [CHAR_LIMIT=16] -->
+ <string name="menu_fraction">Answer as fraction</string>
+ <!-- Menu option to view the app's open source licenses. [CHAR_LIMIT=16] -->
+ <string name="menu_licenses">Open source licenses</string>
+
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 69a537a..c88391e 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -17,12 +17,21 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
- <style name="CalculatorTheme" parent="@android:style/Theme.Material.Light.NoActionBar">
+ <style name="Theme" parent="@android:style/Theme.Material.Light.DarkActionBar">
<item name="android:colorPrimary">@color/calculator_accent_color</item>
- <item name="android:navigationBarColor">@android:color/black</item>
<item name="android:statusBarColor">@color/calculator_accent_color</item>
+ <item name="android:windowSoftInputMode">stateAlwaysHidden</item>
+ </style>
+
+ <style name="Theme.Calculator">
+ <item name="android:windowActionBar">false</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowContentOverlay">@null</item>
+ <item name="android:windowNoTitle">true</item>
+ </style>
+
+ <style name="Theme.Licenses">
+ <item name="android:title">@string/menu_licenses</item>
</style>
<style name="DisplayTextStyle" parent="@android:style/Widget.Material.Light.TextView">
diff --git a/src/com/android/calculator2/Calculator.java b/src/com/android/calculator2/Calculator.java
index 2b06575..124a071 100644
--- a/src/com/android/calculator2/Calculator.java
+++ b/src/com/android/calculator2/Calculator.java
@@ -40,14 +40,11 @@ import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
-import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
-import android.animation.ValueAnimator;
-import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.app.Activity;
import android.app.AlertDialog;
-import android.content.Context;
import android.content.DialogInterface;
+import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Rect;
@@ -55,13 +52,9 @@ import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewPager;
-import android.text.Editable;
import android.text.SpannableString;
import android.text.Spanned;
-import android.text.TextUtils;
-import android.text.TextWatcher;
import android.text.style.ForegroundColorSpan;
-import android.util.Log;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.Menu;
@@ -72,7 +65,6 @@ import android.view.View.OnLongClickListener;
import android.view.ViewAnimationUtils;
import android.view.ViewGroupOverlay;
import android.view.animation.AccelerateDecelerateInterpolator;
-import android.webkit.WebView;
import android.widget.TextView;
import android.widget.Toolbar;
@@ -85,7 +77,6 @@ import java.io.ObjectOutputStream;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.IOException;
-import java.text.DecimalFormatSymbols; // TODO: May eventually not need this here.
public class Calculator extends Activity
implements OnTextSizeChangeListener, OnLongClickListener, CalculatorText.PasteListener {
@@ -714,35 +705,37 @@ public class Calculator extends Activity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.overflow, menu);
+ super.onCreateOptionsMenu(menu);
+
+ getMenuInflater().inflate(R.menu.activity_calculator, menu);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
- if (mCurrentState != CalculatorState.RESULT) {
- menu.findItem(R.id.menu_fraction).setEnabled(false);
- menu.findItem(R.id.menu_leading).setEnabled(false);
- } else if (mEvaluator.getRational() == null) {
- menu.findItem(R.id.menu_fraction).setEnabled(false);
- }
+ super.onPrepareOptionsMenu(menu);
+
+ // Show the leading option when displaying a result.
+ menu.findItem(R.id.menu_leading).setVisible(mCurrentState == CalculatorState.RESULT);
+
+ // Show the fraction option when displaying a rational result.
+ menu.findItem(R.id.menu_fraction).setVisible(mCurrentState == CalculatorState.RESULT
+ && mEvaluator.getRational() != null);
+
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.menu_help:
- displayHelpMessage();
- return true;
- case R.id.menu_about:
- displayAboutPage();
+ case R.id.menu_leading:
+ displayFull();
return true;
case R.id.menu_fraction:
displayFraction();
return true;
- case R.id.menu_leading:
- displayFull();
+ case R.id.menu_licenses:
+ startActivity(new Intent(this, Licenses.class));
return true;
default:
return super.onOptionsItemSelected(item);
@@ -759,15 +752,6 @@ public class Calculator extends Activity
.show();
}
- private void displayHelpMessage() {
- Resources res = getResources();
- String msg = res.getString(R.string.help_message);
- if (mPadViewPager != null) {
- msg += res.getString(R.string.help_pager);
- }
- displayMessage(msg);
- }
-
private void displayFraction() {
BoundedRational result = mEvaluator.getRational();
displayMessage(KeyMaps.translateResult(result.toNiceString()));
@@ -785,18 +769,6 @@ public class Calculator extends Activity
displayMessage(msg);
}
- private void displayAboutPage() {
- WebView wv = new WebView(this);
- wv.loadUrl("file:///android_asset/about.txt");
- new AlertDialog.Builder(this)
- .setView(wv)
- .setNegativeButton(R.string.dismiss,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface d, int which) { }
- })
- .show();
- }
-
// Add input characters to the end of the expression by mapping them to
// the appropriate button pushes when possible. Leftover characters
// are added to mUnprocessedChars, which is presumed to immediately
diff --git a/src/com/android/calculator2/Licenses.java b/src/com/android/calculator2/Licenses.java
new file mode 100644
index 0000000..053154d
--- /dev/null
+++ b/src/com/android/calculator2/Licenses.java
@@ -0,0 +1,20 @@
+package com.android.calculator2;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.webkit.WebView;
+
+public class Licenses extends Activity {
+
+ private static final String LICENSE_URL = "file:///android_asset/licenses.html";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final WebView webView = new WebView(this);
+ webView.loadUrl(LICENSE_URL);
+
+ setContentView(webView);
+ }
+}