History log of /packages/apps/ExactCalculator/src/com/android/calculator2/KeyMaps.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
8a4f81c5b30edd4e62d222a17f4e0e2140bfd99d 09-Jul-2015 Hans Boehm <hboehm@google.com> More correctly pronounce advanced operators in Talkback

Bug: 19190211
Bug: 19202945
Bug: 21052751
Bug: 19165054
Bug: 22594908

Add TtsSpans for operators that are otherwise misread by TalkBack.
Force correct reading for some individual characters.

This greatly improves Talkback for advanced operators in Calculator.

This is imperfect. There is no guarantee that the strings I'm
using will work in all languages. But they're almost certainly better than
what we have now. And it makes parentheses and factorial usable,
though perhaps a bit verbose.

We also no longer pronounce "sine" as "sin".

Removed some now obsolete TODO comments.

Change-Id: I5236f682be828699e08dca04ee6fa073269964f6
/packages/apps/ExactCalculator/src/com/android/calculator2/KeyMaps.java
0b9806f624f25e7e0302da4cf55eda21f8c28163 30-Jun-2015 Hans Boehm <hboehm@google.com> Support pasting of scientific notation numbers

Bug: 21470972

Support pasting of numbers using scientific notation with 'E'. This
is intentionally very restricted to dodge ambiguities with the
constant e. We only accept a scientific notation constant if it is

1) Contained within a single pasted text element.
2) Uses capital 'E' to introduce the exponent.
3) Does not contain an explicit '+' in the exponent.

We do currently use the same notion of 'digit' as elsewhere, i.e.
Character.isDigit(), which might be too general.

For consistency, and to make sure that we can recognize machine
generated output, this also adds a few more aliases for text input
of arithmetic operators.

For consistency, always use 'E' internally for scientific notation as
well.

We ensure that a pasted numeric string is not concatenated with
a pre-existing constant. This is a judgment call, but it means
that pasting a previous calculator result gets similar treatment
whether or not we are still running the same calculator instance.

We support limited editing on exponents. Once an exponent is deleted,
the only way to restore it is via pasting. The 10^x button
produces similar results, though with different operator precedence
behavior.

Change-Id: I2d0f3dceb641cdad327fd3c3540b5eea38030146
/packages/apps/ExactCalculator/src/com/android/calculator2/KeyMaps.java
017de9893efd33e179db10bc71189e150bc3486d 11-Jun-2015 Hans Boehm <hboehm@google.com> Rework the key insertion logic

Bug: 21495243

This changes the behavior to be much more compatible with L.

We generally do not allow consecutive binary operators to be inserted.
In the case of a minus operator however, the logic is more complicated.
We do allow a minus after multiplication, division and power.
When the minus is explicitly entered, so the user sees our corrections,
we do not allow a minus after additive operators. In pasted text,
we do.

We no longer reject additions that would result in implicit
multiplications. We do immediately reject binary operators in leading
contexts, e.g. after a left parenthesis, in which they must result in
a syntax error.

Change-Id: I1d35d74335371f6f113808d68a4f293b699d9bd0
/packages/apps/ExactCalculator/src/com/android/calculator2/KeyMaps.java
4db31b490443e4454d98a5ae2bc44b87149accfe 31-May-2015 Hans Boehm <hboehm@google.com> Implement percent and new inverse functions

Bug: 21493470

Add x^2 10^x and e^x functions, to make the recently added INV key
work as expected.

Implement % functionality.

10^x is essentially just macro expansions for now.

% and x^2 need trivial evaluator support to provide reasonable display
syntax.

We decided to add evaluator support for exp() as well.

Add corresponding exp() support to BoundedRational and its tests.

Tiny incidental changes for problems uncovered in the process:
Fix bug in tests/README.txt
Evaluate the constant e only once.
Add one more power test along with the exp() test.
Fix proguard.flags so BRTest runs again.

Change-Id: I26cfcaf6d99aeec11387297cc5586e2ddcab6add
/packages/apps/ExactCalculator/src/com/android/calculator2/KeyMaps.java
e2711cbb1569ab6c7a7c4506505ec403286d5ab4 28-May-2015 Justin Klaassen <justinklaassen@google.com> Update advanced pad layout

Bug: 7263319
Bug: 20841915

- Switch to using GridLayout instead of custom ViewGroup.
- Added '%' operator button (Note: evaluation support WIP).

Change-Id: I0d07f01fe4224c43e53c916b034362d906bea405
/packages/apps/ExactCalculator/src/com/android/calculator2/KeyMaps.java
0b3a9fd4405fd023e4343d4ff6c8da5ffb1346f4 22-May-2015 Hans Boehm <hboehm@google.com> Reformat and update comments

Reformat to 100 columns. Use indentation, especially for switch
statements, that matches current coding style.

Update some obsolete comments.

Break a single-line if-statement into 3 lines.

No substantive code changes.

This was requested during review of previous CL for b/21282652, but
factored out into a separate CL.

Change-Id: Id5f319ff2226703b413fb08f265677ce7d4dd205
/packages/apps/ExactCalculator/src/com/android/calculator2/KeyMaps.java
425ed0a15c7c755a94701457b671b8b86765dc59 20-May-2015 Hans Boehm <hboehm@google.com> Use correct decimal separator in result.

Bug: 21282652

Consistently use key labels to internationalize result.

This makes the Farsi locale, and possibly others where we diverge
from the normal digit representation specified by the locale, work
sanely.

It remains unclear whether this divergence is a bug or a feature.

Don't statically initialize mDecimalPt, since it is already initialized
when needed, and may need to be reinitialized with locale changes.

Always recognize ',' as a decimal separator.

Remove mFactChar, since it doesn't seem to buy us anything.

Change-Id: I3f7c413d380e009fc562903dc23475a7d7cd6d0a
/packages/apps/ExactCalculator/src/com/android/calculator2/KeyMaps.java
ffda52845ca6cca5f72795706988a11f6bcf5b03 19-May-2015 Hans Boehm <hboehm@google.com> Handle placeholder characters during translation

Bug: 21131556

If we fall behind, initially use blanks as placeholder characters.
Convert these to the right character (currently a correctly sized
space) during translation.

This avoids log spam by the translation code with minimal complication.
It also seems a bit cleaner.

Add some missing private qualifiers in the same vicinity.

Change-Id: I9c53d74ce2a234c888cee55ba72575c884f18cae
/packages/apps/ExactCalculator/src/com/android/calculator2/KeyMaps.java
08e8f322b0d93e06aaa2a15acc869dfd70791461 21-Apr-2015 Hans Boehm <hboehm@google.com> Restructure display formatting, use TextView for formula.

This fixes issues with inappropriate keyboard popups and cleans
up the code.

This substantially rewrites the result formatting code;
it intentionally removes a heuristic to avoid conventional scientific
notation for short results, which only seemed to confuse things.
There are some other tweaks and simplifications. Transitions
to and from conventional scientific notation should be smoother,
though there is still an issue with numbers like 10^-30.
The formatting code is completely extracted from Evaluator, cutting
off various tentacles, and moved to CalculatorResult.

Fixes a bug that resulted in digits being inappropriately
displayed without an exponent if the decimal point was just off
the left edge of the screen.

It's still not clear that we should always be integrating the
exponent into the result window.

Bug: 20483801
Bug: 20480081

Change-Id: I1bb777b871e9fa8b6cd510c533e4b94bde6d4a20
/packages/apps/ExactCalculator/src/com/android/calculator2/KeyMaps.java
013969e98ce9e3eb4f87ec6159b06a74d07b2592 14-Apr-2015 Hans Boehm <hboehm@google.com> Internationalize display again. Plus minor cleanups.

Adds code for internationalization of numeric results, both in the
result and formula displays.

Update some now obsolete TODO comments.

Change-Id: I42731bf87f5488375457f1c5c094c7f0d17b71da
/packages/apps/ExactCalculator/src/com/android/calculator2/KeyMaps.java
4a6b7cb235c305761af5d7f40e74d4704e5058c8 04-Apr-2015 Hans Boehm <hboehm@google.com> 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
/packages/apps/ExactCalculator/src/com/android/calculator2/KeyMaps.java
84614957604253d51296e06c97daced699a0a9de 26-Nov-2014 Hans Boehm <hboehm@google.com> Beginnings of ExactCalculator based on L

Replace the arity library with a new evaluation engine based on
an open source "constructive reals" library. This provides answers
that are correct to the last displayed digit, and can be scrolled to
get more precision, with evaluation to additional precision
proceeding on demand.

This uses pieces of an old prototype calculator with a
pre-Material-Design UI. Since the code structure of the KitKat and
Lollipop calculators is quite different, this merge required major
changes to make the pieces fit again. An egregious bug in the
prototype related to the evaluation of the power operator was
fixed. Many new UI bugs are introduced to compensate :-)

Add separate buttons for inverse trig functions.

Add long TODO lists for various missing pieces.

This is really designed to get something up and running
that looks like it has a Material Design UI.

This version kind of works, though with many UI deficiencies.

This addresses external issues 63368, 81089, and 80990. It
partially address the degree vs radian (80330) issue as well,
though we're still missing the UI for that.

This fixes

Bug:15284587

(More work is needed to make this interact correctly with keyboard support.)

Degree/Radian mode is also internal

Bug:17059768

This provides much more robust solutions to the following, which were
previously fixed by favoring round numbers over precise solutions:

Bug:15747298
Bug:15332726

Change-Id: Ib64ffcee9760a3195ae2a48302308eeb09a156bd
/packages/apps/ExactCalculator/src/com/android/calculator2/KeyMaps.java