← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-app-bracket-push-fix into lp:ubuntu-calculator-app

 

Bartosz Kosiorek has proposed merging lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-app-bracket-push-fix into lp:ubuntu-calculator-app.

Commit message:
Allow add brackets in middle of calculation (LP: #1510982)


Requested reviews:
  Ubuntu Calculator Developers (ubuntu-calculator-dev)
Related bugs:
  Bug #1510982 in Ubuntu Calculator App: "No way to insert brackets in the middle of a calculation"
  https://bugs.launchpad.net/ubuntu-calculator-app/+bug/1510982

For more details, see:
https://code.launchpad.net/~gang65/ubuntu-calculator-app/ubuntu-calculator-app-bracket-push-fix/+merge/276055

Allow add brackets in middle of calculation (LP: #1510982)

-- 
Your team Ubuntu Calculator Developers is requested to review the proposed merge of lp:~gang65/ubuntu-calculator-app/ubuntu-calculator-app-bracket-push-fix into lp:ubuntu-calculator-app.
=== modified file 'app/ubuntu-calculator-app.qml'
--- app/ubuntu-calculator-app.qml	2015-08-02 12:16:28 +0000
+++ app/ubuntu-calculator-app.qml	2015-10-28 21:00:04 +0000
@@ -146,16 +146,19 @@
         }
         isLastCalculate = false;
 
-        if (visual === "()") {
-            visual = Formula.determineBracketTypeToAdd(longFormula)
-        }
         // Validate whole longFormula if the cursor is at the end of string
         if (textInputField.cursorPosition === textInputField.length) {
+            if (visual === "()") {
+                visual = Formula.determineBracketTypeToAdd(longFormula)
+            }
             if (Formula.validateStringForAddingToFormula(longFormula, visual) === false) {
                 errorAnimation.restart();
                 return;
             }
         } else {
+            if (visual === "()") {
+                visual = Formula.determineBracketTypeToAdd(longFormula.slice(0, textInputField.cursorPosition))
+            }
             if (Formula.validateStringForAddingToFormula(longFormula.slice(0, textInputField.cursorPosition), visual) === false) {
                 errorAnimation.restart();
                 return;
@@ -190,8 +193,6 @@
             textInputField.cursorPosition = preservedCursorPosition + visual.length;
         }
 
-
-
         // Add here operators that have always priority
         if ((visual.toString() === "*") || (visual.toString() === ")")) {
             isFormulaIsValidToCalculate = true;

=== modified file 'debian/changelog'
--- debian/changelog	2015-10-19 22:36:57 +0000
+++ debian/changelog	2015-10-28 21:00:04 +0000
@@ -27,8 +27,9 @@
   * Upgrade math.js to 2.1.1 to improve performance (LP: #1484851)
   * Upgrade math.js to 2.4.0 to resolve wrong calculation of sin and cos functions, 
     for values around multiples of tau (i.e. sin(7)) (LP: #1507799)
+  * Allow add brackets in middle of calculation (LP: #1510982)
 
- -- Bartosz Kosiorek <gang65@xxxxxxxxxxxxxx>  Fri, 14 Aug 2015 11:04:30 +0200
+ -- Bartosz Kosiorek <gang65@xxxxxxxxxxxxxx>  Wed, 28 Oct 2015 21:56:29 +0100
 
 ubuntu-calculator-app (2.0.182) vivid; urgency=medium
   * Add haptic feedback to buttons


Follow ups