1. 09 Oct, 2015 1 commit
    • Hans Boehm's avatar
      Evaluator.java and CalculatorExpr.java cleanup · b13daf10
      Hans Boehm authored
      Bug: 24811759
      Bug: 21960281
      Bug: 22047258
      
      No substantive changes.
      
      Reformat to 100 columns.
      
      Correct and/or remove obsolete comments and occasional bits of clearly
      dead code.
      
      Better follow coding conventions.
      
      Rename variables for both internal consistency and consistency with
      other files.  This included a few renamings in Calculator.java
      and CalculatorResult.java, and a comment fix in CalculatorResult.java.
      
      Rename public fields per coding convention.  Correctly declare more
      nested classes static.
      
      Document FIXME issues to be addressed in followup CL.  This includes
      a careful look at the msd computations.  I cannot construct any
      failing examples, but I also cannot currently construct a correctness
      argument.
      
      Change-Id: I5c67493eeb7730edb4b3ca3ba1cb8b7d2b87dbc2
      (cherry picked from commit abe2862bc936dd083b5ba19b68c68ea4cc44b2f6)
      b13daf10
  2. 18 Sep, 2015 1 commit
  3. 04 Aug, 2015 1 commit
  4. 03 Aug, 2015 1 commit
    • Hans Boehm's avatar
      Properly reserve display space for non-digits · 80018c88
      Hans Boehm authored
      Bug: 22882700
      
      We did not correctly calculate the extra space we might need to add
      a decimal point to a scientific notation results.  We also
      incorrectly assumed that minus signs are the same width as a
      digit. As a workaround we now reserve extra space for the possible
      non-digit characters to ensure that a result is never inadvertently
      truncated.
      
      Change-Id: I79b499121703cd51bbbf3e1d85b2285a2dd5e025
      80018c88
  5. 28 Jul, 2015 3 commits
  6. 22 Jul, 2015 1 commit
  7. 21 Jul, 2015 2 commits
    • Hans Boehm's avatar
      Avoid starting long uninterruptible computations · 82e5a2f6
      Hans Boehm authored
      Bug: 21957088
      
      Shorten timeouts.
      
      We usually do short computations first, so this helps to avoid
      starting absurdly big ones.
      
      Check size of result before converting to decimal.  If the decimal
      conversion is likely to time out anyway, just pretent we timed out.
      This turns out to avoid a lot of problems, since BigInteger decimal
      conversion is the clear bottleneck for something like 100000!
      And its uninterruptible.
      
      Remove the timeout in one case in which we had previously forgotten.
      
      Check for interrupts in a couple of more places in BoundedRational.
      One of these caused log(10^100000) to hang for a long time.
      
      One or two trivial cleanups in code that was touched anyway.
      
      Change-Id: I3494a8ed28f681fb26634ecd90042e2f2a8008a8
      82e5a2f6
    • Hans Boehm's avatar
      am 8a4f81c5: More correctly pronounce advanced operators in Talkback · 9d75c1ac
      Hans Boehm authored
      * commit '8a4f81c5':
        More correctly pronounce advanced operators in Talkback
      9d75c1ac
  8. 20 Jul, 2015 1 commit
    • Hans Boehm's avatar
      More correctly pronounce advanced operators in Talkback · 8a4f81c5
      Hans Boehm authored
      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
      8a4f81c5
  9. 15 Jul, 2015 2 commits
  10. 14 Jul, 2015 2 commits
  11. 11 Jul, 2015 1 commit
  12. 09 Jul, 2015 2 commits
    • Hans Boehm's avatar
      am 0b9806f6: Support pasting of scientific notation numbers · 8f4a8c73
      Hans Boehm authored
      * commit '0b9806f6':
        Support pasting of scientific notation numbers
      8f4a8c73
    • Hans Boehm's avatar
      Support pasting of scientific notation numbers · 0b9806f6
      Hans Boehm authored
      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
      0b9806f6
  13. 08 Jul, 2015 3 commits
  14. 06 Jul, 2015 2 commits
  15. 01 Jul, 2015 3 commits
    • Justin Klaassen's avatar
      Tweak text sizes and padding to prevent clipping · b43e6810
      Justin Klaassen authored
      Bug: 22206007
      
      Some languages contain oversized glyphs which may inadvertently be
      clipped when displayed by AlignedTextView. The updated text sizes and
      padding values should ensure that enough room is always reserved for
      these glyphs (even when font scaling is set to HUGE).
      
      Change-Id: Ic62df3104d033b1eafcf7d83f7e91d5329c8be70
      b43e6810
    • Justin Klaassen's avatar
      Always use "H" for formula text alignment · b2c3e440
      Justin Klaassen authored
      Bug: 22208425
      
      Most of the mathematical operators/symbols (e.g. "π") cannot be encoded
      using "ISO-8859-1" however they still should be aligned using the
      default capital letter height ("H").
      
      Change-Id: I4ca6674de6e6a96b0ce513ecd8acea775f2e7081
      b2c3e440
    • Geoff Mendal's avatar
      Import translations. DO NOT MERGE · 6a83e391
      Geoff Mendal authored
      Change-Id: I631ffe9434ba119d50835247c1bd6cfcbc77355c
      Auto-generated-cl: translation import
      6a83e391
  16. 30 Jun, 2015 1 commit
    • Hans Boehm's avatar
      Reimplement overflow menu messages as DialogFragments · a3723849
      Hans Boehm authored
      Bug: 20650813
      
      This preserves fraction and "with leading digits" displays during
      rotation.
      
      It also turns out to easily support copy, which is a useful bonus,
      since it was an obvious hole in the UI for the fraction display.
      For the "with leading digits" display, this is similar to a
      plain display copy, but it allows character-level selection.
      
      Much of the code here was cloned from Justin's.
      
      Change-Id: I4805280fa6a46f06833be0bde9563c3ce04dca45
      a3723849
  17. 27 Jun, 2015 1 commit
    • Hans Boehm's avatar
      Make trailing operator handling consistent with L · e8553769
      Hans Boehm authored
      Bug: 246391
      
      Only ignore trailing BINARY operators when computing instant results.
      We used to be much more aggressive.
      
      Also ignore trailing binary operators when the user hits "=".
      
      This makes us consistent with the L design and ensures that instant
      results don't turn into errors when the user hits "=".
      
      Change-Id: I260e95d152168b70774330ac95d5bc567cf79b3d
      e8553769
  18. 24 Jun, 2015 4 commits
    • Hans Boehm's avatar
      Reflect conversion of CR to unchecked exceptions · 19e93c98
      Hans Boehm authored
      Bug: 20667245
      
      Update calculator code to reflect the fact that CR Errors have
      become exceptions, and they are now delcared local to CR.
      
      Change-Id: Ie9c9e10cef2f98a23856aa9e49328ae7ba52c9bc
      19e93c98
    • Hans Boehm's avatar
    • Hans Boehm's avatar
      Restore original scroll position on = · 15a853dd
      Hans Boehm authored
      Bug: 22041219
      
      Restore default scrolling position when hitting enter after scrolling
      an instant display result.
      
      We could instead preserve the position and fix the display logic to
      no longer get confused by a non-default initial position.  But this
      feels more natural to me.
      
      Change-Id: I43bb936b5bb1b5af7a7befb90fdfc0f745fb7729
      15a853dd
    • Hans Boehm's avatar
      Improve logic for evaluation/animation interruption · c1ea091a
      Hans Boehm authored
      Bug: 21471857
      Bug: 20819212
      
      End rather than cancel() in-progress animation in the event of user
      interaction.
      
      Discard input that interrupted a computation only for delete,
      and clear, where it seems to make sense.
      
      Use similar interruption logic for physical keyboard input as for
      touch.
      
      Make integer exponentiation more interruptible.  This remains
      imperfect; the latencies in a single BigInteger multiplication
      can be high. Filed b/21957088 to track that.
      
      Clear "instant" result before launching reevaluation.  Otherwise the
      example from b/21957088 shows incorrect instant results for an
      uncomfortably long time as it's being entered.
      
      Correct some of the state maintenance operations in Calculator.java.
      The ANIMATE state was not being used correctly.
      
      Remove redundant cancelAll() and onCancelled() calls.
      
      Add an option to cancel without a message.  Use it for clear.
      
      Change-Id: Ibab90dca0cb894e7985642f212ff41030f2fc52d
      c1ea091a
  19. 23 Jun, 2015 2 commits
    • Hans Boehm's avatar
    • Hans Boehm's avatar
      Correct off-by-1 errors in display formatting code. · 5e802f30
      Hans Boehm authored
      Bug: 21986868
      Bug: 21960281
      
      Fix and restructure the formatting and scroll-limit-calculation
      code.  This code is inherently tricky, and has had more bugs than
      we would like to admit to.  Use the opportunity to clean up the
      code a bit, renaming variables consistently.
      
      The good news is that the code seems to be getting slightly
      simpler with each bug fix.
      
      This fixes several separate off-by-one errors related to result
      formatting:
      
      The expLen() exponent string length calculation was off by 1
      for exact powers of 10.
      
      The dropDigits calculation in the formatting code was off for
      negative exponents just shorter than an exact power of 10.
      
      The exponent space calculation for a few results like -1.2*10^-8
      was off by one.
      
      For a result like -10^-500 we did not reserve space for the leading
      minus sign, since that's not computed until after scrolling.
      
      [Less serious] The ellipses were omitted when we had just barely
      scrolled a leading minus sign off the screen.  (This only occurred
      in exactly one position, which could never be the default one.)
      
      Change-Id: If1bfbbb70a624998be3d996592d129b16aade745
      5e802f30
  20. 22 Jun, 2015 2 commits
  21. 20 Jun, 2015 1 commit
  22. 19 Jun, 2015 2 commits
    • Hans Boehm's avatar
      Improve copy/paste menu appearance · 7f83e36b
      Hans Boehm authored
      Bug: 20503008
      
      Correctly provide content position information to the ActionMode so
      that menues can be better positioned.
      
      Highlight a result that's about to be copied.
      
      Ensure that the end of the current formula becomes visible when
      the paste menu appears.
      
      Change-Id: I318985776e59175b827d5089c0ca4978f3a658cb
      7f83e36b
    • Hans Boehm's avatar
      Fix "with leading digits" display. · f6dae114
      Hans Boehm authored
      Bug: 21759654
      
      Previously the number of displayed digits didn't quite match the
      number of digits in the normal display, and results with positive
      exponents always came out as inexact.  This fixes both.
      
      Remove an obsolete FIXME comment.
      
      Change-Id: I9aa0217d7804218c54fe929e59dfbc6bbf880db7
      f6dae114
  23. 18 Jun, 2015 1 commit
    • Hans Boehm's avatar
      Rework the key insertion logic · 017de989
      Hans Boehm authored
      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
      017de989