summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* Polish display and evaluate animationJustin Klaassen2015-05-295-182/+236
| | | | | | | | | | | | | | | | | Bug: 20915670 Bug: 21489377 - Adjust font metrics across all supported device configurations to support font scaling and min touch size requirements. - Support proper font scaling for non-scrollable results when performing the evaluate animation. - Remove restriction for only using 4/5 of the width of the result display (NOTE: the result's textSize must match the formula's minTextSize). - Add AlignedTextView base class to ensure formula/result padding is based on the displayed text's ascent/baseline. Change-Id: Id53e9bdc6e699fb05fdf331a6a472ecc170edf38
* Fix typo: invertable -> invertibleJustin Klaassen2015-05-281-12/+12
| | | | Change-Id: I2db32c54d0ceb3bd055129a08193fb3e65dc0ff3
* Update advanced pad layoutJustin Klaassen2015-05-285-193/+122
| | | | | | | | | | Bug: 7263319 Bug: 20841915 - Switch to using GridLayout instead of custom ViewGroup. - Added '%' operator button (Note: evaluation support WIP). Change-Id: I0d07f01fe4224c43e53c916b034362d906bea405
* Improve evaluate-ahead heuristicHans Boehm2015-05-262-6/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 21447808 This changes the existing heuristics to compute ahead significantly more aggressively. In my testing, this typically managed to prevent blanks from being displayed even during rapid scrolling. We start the next computation once we get near the end of what we've currently computed. By the time we get to the end, the new results are ready. With this change, we typically compute to nearly 100 digits even without scrolling, and the amount we compute ahead increases as we've scrolled further. With the previous asin() CL, that seems to be fine. I suspect, but have not confirmed, that for this size BigInteger operations, much of the latency is fixed, e.g. JNI, overhead, and the number of digits is not yet critical anyway. This should reduce the total amount of computation, and hence battery usage, during "extreme scrolling", since the evaluation precision now increases geometrically. Update a copyright notice. Change-Id: If3a162016b8ffbacc872361aaa99c77c7fd578a2
* Reformat and update commentsHans Boehm2015-05-261-128/+178
| | | | | | | | | | | | | | | | 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
* Merge "Use correct decimal separator in result." into mnc-devHans Boehm2015-05-221-9/+10
|\
| * Use correct decimal separator in result.Hans Boehm2015-05-201-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Prevent scrolling of finite results.Hans Boehm2015-05-203-51/+89
|/ | | | | | | | | | | | | | | | | | | | | | | Bug: 20562484 Inhibit scrolling past the last nonzero digit when we can identify it. Increase length of immediate result a bit, to make it closer to the L calculator. On "=", expand less for scrollable results, more for short non-scrollable results. This allows us to use larger fonts for short finite results. Fix up animation logic when displaying result. The old version was never quite right, and became more visibly wrong with variable enlargement. This version is simpler and seems to give much better results. This still does not add ellipsis at the right end of a result. But it is now easily possible to tell whether a result is known finite by attempting to scroll it. That may be good enough. Remove some obsolete TODO entries. Change-Id: I25a842a743e1c27191ca18ac69aa9eef0f0ea9b1
* Handle placeholder characters during translationHans Boehm2015-05-182-19/+24
| | | | | | | | | | | | | | | 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
* Merge "Reformat CalculatorResult.java to 100 columns" into mnc-devHans Boehm2015-05-141-108/+69
|\
| * Reformat CalculatorResult.java to 100 columnsHans Boehm2015-05-131-108/+69
| | | | | | | | | | | | In preparation for further changes. Change-Id: I6e2fbc1e1701e6832f1ca3a5272f6bb3e84338e6
* | Merge "Improve copy/paste handling, minor instant result fixes" into mnc-devHans Boehm2015-05-144-13/+56
|\|
| * Improve copy/paste handling, minor instant result fixesHans Boehm2015-05-134-13/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 20764417 Bug: 20838790 Finish the action mode when we do almost anything else. We should probably be even more aggressive about terminating it, and we may eventually want to use a different approach. But this avoids the crashes, and greatly improves the behavior. Display copy menu only when there is something to copy. Fix a couple of bugs introduced by recent instant display overhaul (one line each): - Instant display disappeared on rotation. - It was sometimes still possible to scroll the previous result after CLR. Change-Id: I1a91d312358898add1e281aaba116d709b4c92a7
* | Handle android.R.id.home clicks in Licenses activityJustin Klaassen2015-05-121-0/+10
|/ | | | | Bug: 21052927 Change-Id: I4916d159f3b98966cddae0cb27468df6ea2ffd76
* Set mCurrentButton after keyboard =Hans Boehm2015-05-111-0/+1
| | | | | | | | | | | | Bug: 20826880 This avoids a null pointer exception in reveal(). This avoids a crash produced by e.g. 2/0<rotate screen><keyboard => Change-Id: I651398104992e93137d8dd62523c74b0780d3c1e
* Fix CHAR_LIMIT for stringsJustin Klaassen2015-05-071-9/+10
| | | | | | | | | | | Bug: 20877857 Bug: 20815563 - Condensed strings to one string.xml with translatable="false". - Made functions and digits NOT localized. - Switched to U+2007 character for unknown digits. Change-Id: I51a108309ccfa9c40edd6f87f9e052ba7ee25e3a
* Cleanup options menu and licenses UIJustin Klaassen2015-05-052-45/+37
| | | | | | | | | | 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
* Fix paste bugHans Boehm2015-05-011-0/+1
| | | | | | | | Bug: 20764843 Pasting in a number changes the expression value. Duh. Change-Id: Ia4234632833767fd3d8614f56feec9dcf123ae3c
* Fix timeout, cancellation and instant display logicHans Boehm2015-05-014-112/+225
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 20668802 Bug: 20484451 Bug: 20734909 Bug: 20738335 Change the timeout implementation to not rely on removing scheduled timeouts when an evaluation completes. This seems simper, more clearly correct and, unlike its predessessor seems to work reliably. Correctly display "cancelled" message, but only when cancelled for a reason other than timeout. Change SyntaxError to not be a Java "Error", since we routinely recover from it. Better support evaluation of partial expressions by removing trailing operators. Make some attempt to avoid redundant evaluations, since they're not as cheap as they used to be. Change the display logic to avoid frequent clearing of the display, which resulted in visible flashing. Note that the evaluation logic can now stop evaluating before the end of an expression. Substantially lengthen timeout used when computing an unrequested result. Inverse trig functions can be slow. See b/20729963. Make large factorial computations interruptable, as I mistakenly thought they were. Ignore "=" on an empty expression. I'm not positive this fixes the b/20484451, but I haven't been able to reproduce it with this patch. I have no idea whether it addresses b/20738335, but it cleans up code in that vicinity, so it would be interesting to know whether that is still reproducible. Change-Id: I67af5afc00e19a6156e1547ce4e2060c70ca367f
* Fix strings, stability bug, easy UI & correctness issuesHans Boehm2015-04-296-31/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 20625562 Bug: 20649711 Bug: 20561890 Bug: 20561528 Bug: 20442590 Bug: 15473140 Bug: 20503008 Bug: 20503007 - Improve timeout text. - Recalculate when Calculator is rotated, e.g. in error state, thus reproducing message. It's unclear this is good enough, but it's better. - Fix square root parsing. - Fix concatenation of numbers when pasting by adding explicit multiplication. - Display divide by zero error differently from other domain errors. - Improved advanced keypad layout of portrait-mode tablet calculator. - Improved overflow menu order. (More to be done.) - Report zero division as zero division when we can recognize it. - Switch to floating menus for copy/paste. Change-Id: I3875414f293e62a59b0e41f0de822f29bd5ac6a6
* Restructure display formatting, use TextView for formula.Hans Boehm2015-04-286-161/+199
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix decimal log(), rename positive_den()Hans Boehm2015-04-231-10/+11
| | | | | | | | Bug: 20485102 The rational version of base 10 log(0) got into an infinite loop. Change-Id: Id6263f7244c71260daa124e5eb4eea8592d0e6c7
* Do not try to cache Paint.Hans Boehm2015-04-221-4/+3
| | | | | | | | It's not worthwhile, and it exposes us to initialization races. Bug: 20482937 Change-Id: Ida86d6ed001b9afa097ffce4f4292045c008df4a
* Fix result overlap, clear logic, display bugs, etc.Hans Boehm2015-04-203-9/+29
| | | | | | | | | | | | | | | | | | | | | Adjust result padding to prevent overlapping with options menu, resulting in inability to access options menu. Reset state correctly after clear, preventing occasional crashes. Do this at end of animation to prevent animation glitches. Have clear but the display in a state in which COPY does nothing interesting. Treat a not-known-to-be-exact zero result better. Before this we displayed it as just "0", giving the mistaken impression of exactness. It is unclear whether we should display it as "0.00000000" or add an exponent to indicate the real evaluation precision. The former probably works better for beginners; the latter for experts. We now do the former, which is probably right. Also correctly save and restore not-yet analyzed characters. Change-Id: Iac46d0d3b5a06f61beb6af7d4f0910e43284f52b
* Fix scrolling in formula windowHans Boehm2015-04-171-12/+7
| | | | Change-Id: Ie2b8c35793882a1cc2a9881aaf6f3cfea4dbf260
* Adopt Toolbar for overflow menuJustin Klaassen2015-04-172-37/+43
| | | | Change-Id: I55958260b4279b504e79b7a104a813a1273ae403
* Internationalize display again. Plus minor cleanups.Hans Boehm2015-04-156-63/+162
| | | | | | | | | Adds code for internationalization of numeric results, both in the result and formula displays. Update some now obsolete TODO comments. Change-Id: I42731bf87f5488375457f1c5c094c7f0d17b71da
* Fix UI holes and bugs. Fix eval bugs.Hans Boehm2015-04-157-210/+691
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add degree/radian mode, improve button layoutHans Boehm2015-04-083-11/+53
| | | | | | | | | | | | | Add a button for switching between degree and radian mode. Handle display updates in response to mode switching in a reasonoble way. Improve the button layout so that it is usable on tablets. Add DEG/RAD mode display at the top. Fiddle with some of the layout parameters so they make more sense to me. This may need further tuning. Change-Id: I8d04b235cfcb1f0a0d8f4a0ad6a0dc6e5eac8c5d
* Add tests, fix BoundedRational bugsHans Boehm2015-04-071-3/+7
| | | | | | | | | | | | | Add back some basic test infrastructure from the KitKat calculator, updated to make it work with the current code base and asynchronous expression evaluation. Add BoundedRational tests, designed to check that we get all the corner cases, particularly for degree-based trig functions, right. Fix a couple of BoundedRational typos that caused these tests to fail. Change-Id: I81d8f3d9bde6aa6c20f9958eabd62979babeff5b
* Add BoundedRational evaluationHans Boehm2015-03-103-125/+635
| | | | | | | | | | | | | | | | | | | | | We would like to display finite representations of calculator results when they clearly exist and are easy to identify, such as when adding currency values. We do this by computing a rational representation of the result when it exists, and using that to compute the number of digits in a finite representation. Since rational arithmetic can become very expensive, we bound the size of the results we are willing to keep. If things get too large we fall back on the standard constructive real arithmetic. Finite representations are extremely unlikely in such cases anyway. This also gives us a clear rule for when to normalize fractions, which is often a challenge with rational number packages. This also adds a couple of routines to set degree mode, but does not include the UI to actually invoke them. Thus there is still no way to test some important pieces of functionality. Change-Id: I3c1aca5aefd8d8c19bce79095bde59ee3b4127fe
* Beginnings of ExactCalculator based on LHans Boehm2015-03-069-367/+2352
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add reveal view to overlay before creating animatorJustin Klaassen2014-08-281-9/+6
| | | | | | | | | | Bug: 17316066 - Additional checks introduced by ag/534856 now require that the target of ViewAnimationUtils#createCircularReveal has a parent before being invoked. Change-Id: I21702486443e1c8fcae62d541e53a5237e50cfb4
* Improve hardware keyboard supportJustin Klaassen2014-08-272-6/+19
| | | | | | | | | | | | Bug: 17188394 - Ensure cursor is always at end of the current expression. - Allow the delete key to be handled by the EditText fixing an issue where delete would occur twice on keyUp and keyDown. - Prevent text freezing in onSaveInstanceState so that text can be restored at the Activity level. Change-Id: Ie20a7f88b9c43223ae840a1191361de7f1e35127
* Fix NPE resulting from invalid instance stateJustin Klaassen2014-08-261-3/+8
| | | | | | | | | Bug: 17281017 - Ensure any transient state is cleared before saving instance state by cancelling the current animator if applicable. Change-Id: Ibebf5f4d89046453d36f43b98240a2cbef74288e
* Add basic support to handle hardware keyboardBudi Kusmiantoro2014-08-122-11/+55
| | | | | Bug: 15710817 Change-Id: Icf50f4ddd6f7e3e8606074b533a34db66703da00
* Preserve/restore calculator instance stateJustin Klaassen2014-08-075-72/+69
| | | | | | | | | | | | | | Bug: 15597963 Bug: 16850193 - Manage tokenizer instance at activity level so it is re-created on locale changes. - Preserve normalized form of expression in instance state and restore/evaluate on activity creation. - Remove selection hack from CalculatorEditText since setting a selection makes TextView save instance state and it no longer appears necessary. Change-Id: Ic15924f4026ec45b4775b36568c3cdc46443cca8
* Rename CalculatorActivity back to CalculatorJustin Klaassen2014-06-271-4/+4
| | | | | Bug: 15907395 Change-Id: Idc3445230c541bdf50cc3b15187c0776010ccff3
* Use elevation for dynamic shadowsJustin Klaassen2014-06-201-1/+1
| | | | | Bug: 15550085 Change-Id: I21839913551cd7bbbab0b3ab22a708a09e7b6200
* Increase number of rounding digitsJustin Klaassen2014-06-191-1/+1
| | | | | Bug: 15747298 Change-Id: Iabb1a767fca0961ae441eb14769eed2ce1f649ce
* Use setStatusBarColor APIJustin Klaassen2014-06-191-15/+15
| | | | Change-Id: I3eb9a3511f7fe6b4dbac5d93d9edd3b98921e909
* Reveal animation on errorJustin Klaassen2014-06-121-39/+68
| | | | | Bug: 15597955 Change-Id: I8f87b25ce25fd344f2b62720f28ae10861d56bc5
* Slow down text scale animationJustin Klaassen2014-06-111-1/+1
| | | | | Bug: 15562035 Change-Id: I1894719f5066a0a2f4ac7db4e4d2d019b5421df4
* Pressing = twice shouldn't clear the calculation resultJustin Klaassen2014-06-111-3/+1
| | | | | Bug: 15517592 Change-Id: I682e6cf8d7b909b3712e5f604ea50edfc18ba883
* Preserve edited state across screen rotationJustin Klaassen2014-06-114-30/+34
| | | | | Bug: 15475165 Change-Id: I65f51ff720e1c6df968ab07427c93f293870eeba
* Disable remaining visible number keys when advanced panel is shownJustin Klaassen2014-06-111-7/+30
| | | | | Bug: 15289616 Change-Id: I595fb432335434af5ba1ac7687fec7f55d502f0d
* Merge "Provide animation when auto-scaling the font-size" into lmp-preview-devJustin Klaassen2014-06-102-1/+53
|\
| * Provide animation when auto-scaling the font-sizeJustin Klaassen2014-06-102-1/+53
| | | | | | | | | | Bug: 15287699 Change-Id: I5e7c5c3bdc96200efa6b4c6f221148647ff91e76
* | Back button should hide advanced padJustin Klaassen2014-06-091-0/+17
| | | | | | | | | | Bug: 15311457 Change-Id: I3ac6b89160efa137cfbc975adfefe2794573253a
* | API Review: update the createRevealAnimator to the new API designztenghui2014-06-051-2/+4
|/ | | | | | b/15451650 Change-Id: Ice87799c475af589be93ab5b849f71b0abe0b9c9